Commit e407775e8e8930fdacab62e1019b01395e2f894a

Authored by 史婷婷
1 parent 505e42a4

feat: 订货单-包装费放到产品里面,可输入-编辑&审核, 只读-审核详情&详情 number 大于等于0,可小数

... ... @@ -68,17 +68,6 @@
68 68 </view>
69 69 </template>
70 70 </uni-list-item>
71   - <uni-list-item class="amount-item">
72   - <template v-slot:body>
73   - <view class="item-title"><text>包装费</text></view>
74   - </template>
75   - <template v-slot:footer>
76   - <view class="amount-row">
77   - <uni-easyinput type="number" v-model="form.packagingFee" placeholder="0.00" :inputBorder="false" />
78   - <text class="unit">元</text>
79   - </view>
80   - </template>
81   - </uni-list-item>
82 71 <uni-list-item class="select-item" :class="form.executionStandardName ? 'is-filled' : 'is-empty'" clickable
83 72 @click="openSheet('executionStandard')" :rightText="form.executionStandardName || '请选择'" showArrow>
84 73 <template v-slot:body>
... ... @@ -276,6 +265,7 @@ export default {
276 265 }
277 266 },
278 267 purchaseOrderLineListChange(data) {
  268 + console.log('purchaseOrderLineListChange__data', data)
279 269 const list = Array.isArray(data) ? data : []
280 270 this.form.purchaseOrderLineList = list;
281 271 },
... ...
... ... @@ -52,8 +52,21 @@
52 52 <view class="row" :class="{ 'noneStyle': item.showSalesPrice }" v-if="item.showSalesPrice"><text
53 53 class="label">销售价格</text><text class="value">{{
54 54 item.salesPrice }}</text></view>
55   -
56 55 <uni-list class="edit-list">
  56 + <uni-list-item class="amount-item">
  57 + <template v-slot:body>
  58 + <view class="item-title"><text>包装费</text></view>
  59 + </template>
  60 + <template v-slot:footer>
  61 + <view class="amount-row">
  62 + <uni-easyinput type="digit" v-model="item.packagingFee" placeholder="0.00"
  63 + :inputBorder="false"
  64 + @input="onNonNegativeNumberInput($event, item, idx, 'packagingFee')"
  65 + @blur="onNonNegativeNumberBlur(item, idx, 'packagingFee')" />
  66 + <text class="unit">元</text>
  67 + </view>
  68 + </template>
  69 + </uni-list-item>
57 70 <uni-list-item title="发货日期">
58 71 <template v-slot:footer>
59 72 <uni-datetime-picker type="date" v-model="item.deliveryDate" :start="minDeliveryDate"
... ... @@ -114,6 +127,8 @@
114 127 <!-- showSalesPrice 判断是否显示 -->
115 128 <view class="row" v-if="item.showSalesPrice"><text class="label">销售价格</text><text class="value">{{
116 129 item.salesPrice }}</text></view>
  130 + <view class="row"><text class="label">包装费</text><text class="value">{{
  131 + item.packagingFee }}</text></view>
117 132 <view class="row"><text class="label">发货日期</text><text class="value">{{ item.deliveryDate }}</text>
118 133 </view>
119 134 <view class="row"><text class="label">考核超协</text><text class="value">{{ item.assessmentExceedsAgreement
... ... @@ -187,7 +202,7 @@ export default {
187 202 },
188 203 methods: {
189 204 defaultItem() {
190   - return { collapsed: false }
  205 + return { collapsed: false, packagingFee: '' }
191 206 },
192 207 toggleItem(idx) {
193 208 const it = this.items[idx]
... ... @@ -196,7 +211,9 @@ export default {
196 211 this.$set(this.items, idx, it)
197 212 },
198 213 emitChange() {
199   - const out = this.items.map(it => ({ ...it }))
  214 + console.log('emitChange__items', this.items)
  215 + const out = this.items.map(it => JSON.parse(JSON.stringify(it)))
  216 + console.log('emitChange__out', out)
200 217 this.$emit('input', out)
201 218 this.$emit('update:value', out)
202 219 this.$emit('change', out)
... ... @@ -226,6 +243,26 @@ export default {
226 243 this.$set(this.items, idx, { ...item })
227 244 uni.showToast({ title: '发货日期必须大于订货日期', icon: 'none' })
228 245 }
  246 + },
  247 + onNonNegativeNumberInput(val, item, idx, field) {
  248 + let v = String(val != null ? val : (item && item[field]) || '')
  249 + v = v.replace(/[^0-9.]/g, '')
  250 + v = v.replace(/(\..*)\./g, '$1')
  251 + if (v.startsWith('.')) v = '0' + v
  252 + if (v === '') { item[field] = ''; if (typeof idx === 'number') this.$set(this.items, idx, { ...item }); return }
  253 + const num = Number(v)
  254 + if (isNaN(num) || num < 0) {
  255 + item[field] = '0'
  256 + } else {
  257 + item[field] = v
  258 + }
  259 + if (typeof idx === 'number') this.$set(this.items, idx, { ...item })
  260 + },
  261 + onNonNegativeNumberBlur(item, idx, field) {
  262 + const v = String((item && item[field]) || '')
  263 + const num = Number(v)
  264 + if (isNaN(num) || num < 0) item[field] = '0'
  265 + if (typeof idx === 'number') this.$set(this.items, idx, { ...item })
229 266 }
230 267 }
231 268 }
... ...