Commit 085f800b5e9437974836879c9f80934dd240508e

Authored by 史婷婷
1 parent 795b6561

feat: 补货单-新增&编辑-需发数、实发数、需求补货数量、审核-需求补货数量-改为两位小数(包括合计)

@@ -274,9 +274,13 @@ export default { @@ -274,9 +274,13 @@ export default {
274 acc.totalQuantity += orderQty 274 acc.totalQuantity += orderQty
275 return acc 275 return acc
276 }, { totalQuantity: 0, totalShippedQuantity: 0, totalSupplementaryQuantity: 0 }) 276 }, { totalQuantity: 0, totalShippedQuantity: 0, totalSupplementaryQuantity: 0 })
277 - this.form.totalQuantity = summary.totalQuantity  
278 - this.form.totalShippedQuantity = summary.totalShippedQuantity  
279 - this.form.totalSupplementaryQuantity = summary.totalSupplementaryQuantity 277 +
  278 + const fixedTotalQuantity = Number(summary.totalQuantity.toFixed(2))
  279 + const fixedTotalShippedQuantity = Number(summary.totalShippedQuantity.toFixed(2))
  280 + const fixedTotalSupplementaryQuantity = Number(summary.totalSupplementaryQuantity.toFixed(2))
  281 + this.form.totalQuantity = fixedTotalQuantity
  282 + this.form.totalShippedQuantity = fixedTotalShippedQuantity
  283 + this.form.totalSupplementaryQuantity = fixedTotalSupplementaryQuantity
280 }, 284 },
281 purchaseOrderLineListChange(data) { 285 purchaseOrderLineListChange(data) {
282 const list = Array.isArray(data) ? data : [] 286 const list = Array.isArray(data) ? data : []
@@ -125,9 +125,13 @@ export default { @@ -125,9 +125,13 @@ export default {
125 acc.totalQuantity += orderQty 125 acc.totalQuantity += orderQty
126 return acc 126 return acc
127 }, { totalQuantity: 0, totalShippedQuantity: 0, totalSupplementaryQuantity: 0 }) 127 }, { totalQuantity: 0, totalShippedQuantity: 0, totalSupplementaryQuantity: 0 })
128 - this.form.totalQuantity = summary.totalQuantity  
129 - this.form.totalShippedQuantity = summary.totalShippedQuantity  
130 - this.form.totalSupplementaryQuantity = summary.totalSupplementaryQuantity 128 +
  129 + const fixedTotalQuantity = Number(summary.totalQuantity.toFixed(2))
  130 + const fixedTotalShippedQuantity = Number(summary.totalShippedQuantity.toFixed(2))
  131 + const fixedTotalSupplementaryQuantity = Number(summary.totalSupplementaryQuantity.toFixed(2))
  132 + this.form.totalQuantity = fixedTotalQuantity
  133 + this.form.totalShippedQuantity = fixedTotalShippedQuantity
  134 + this.form.totalSupplementaryQuantity = fixedTotalSupplementaryQuantity
131 }, 135 },
132 purchaseOrderLineListChange(data) { 136 purchaseOrderLineListChange(data) {
133 const list = Array.isArray(data) ? data : [] 137 const list = Array.isArray(data) ? data : []
@@ -226,9 +226,13 @@ export default { @@ -226,9 +226,13 @@ export default {
226 acc.totalQuantity += orderQty 226 acc.totalQuantity += orderQty
227 return acc 227 return acc
228 }, { totalQuantity: 0, totalShippedQuantity: 0, totalSupplementaryQuantity: 0 }) 228 }, { totalQuantity: 0, totalShippedQuantity: 0, totalSupplementaryQuantity: 0 })
229 - this.form.totalQuantity = summary.totalQuantity  
230 - this.form.totalShippedQuantity = summary.totalShippedQuantity  
231 - this.form.totalSupplementaryQuantity = summary.totalSupplementaryQuantity 229 +
  230 + const fixedTotalQuantity = Number(summary.totalQuantity.toFixed(2))
  231 + const fixedTotalShippedQuantity = Number(summary.totalShippedQuantity.toFixed(2))
  232 + const fixedTotalSupplementaryQuantity = Number(summary.totalSupplementaryQuantity.toFixed(2))
  233 + this.form.totalQuantity = fixedTotalQuantity
  234 + this.form.totalShippedQuantity = fixedTotalShippedQuantity
  235 + this.form.totalSupplementaryQuantity = fixedTotalSupplementaryQuantity
232 }, 236 },
233 purchaseOrderLineListChange(data) { 237 purchaseOrderLineListChange(data) {
234 const list = Array.isArray(data) ? data : [] 238 const list = Array.isArray(data) ? data : []
@@ -96,24 +96,27 @@ @@ -96,24 +96,27 @@
96 <template v-slot:footer> 96 <template v-slot:footer>
97 <uni-easyinput type="digit" v-model="item.quantity" placeholder="请输入数量kg" 97 <uni-easyinput type="digit" v-model="item.quantity" placeholder="请输入数量kg"
98 :inputBorder="false" 98 :inputBorder="false"
99 - @input="onNonNegativeNumberInput($event, item, idx, 'quantity')"  
100 - @blur="onNonNegativeNumberBlur(item, idx, 'quantity')" /> 99 + @input="onTwoDecimalInput($event, item, idx, 'quantity')"
  100 + @blur="onTwoDecimalBlur(item, idx, 'quantity')"
  101 + />
101 </template> 102 </template>
102 </uni-list-item> 103 </uni-list-item>
103 <uni-list-item title="实发数量(kg)"> 104 <uni-list-item title="实发数量(kg)">
104 <template v-slot:footer> 105 <template v-slot:footer>
105 <uni-easyinput type="digit" v-model="item.shippedQuantity" placeholder="请输入实发数量kg" 106 <uni-easyinput type="digit" v-model="item.shippedQuantity" placeholder="请输入实发数量kg"
106 :inputBorder="false" 107 :inputBorder="false"
107 - @input="onNonNegativeNumberInput($event, item, idx, 'shippedQuantity')"  
108 - @blur="onNonNegativeNumberBlur(item, idx, 'shippedQuantity')" /> 108 + @input="onTwoDecimalInput($event, item, idx, 'shippedQuantity')"
  109 + @blur="onTwoDecimalBlur(item, idx, 'shippedQuantity')"
  110 + />
109 </template> 111 </template>
110 </uni-list-item> 112 </uni-list-item>
111 <uni-list-item title="需求补货数量(kg)"> 113 <uni-list-item title="需求补货数量(kg)">
112 <template v-slot:footer> 114 <template v-slot:footer>
113 <uni-easyinput type="digit" v-model="item.supplementaryQuantity" 115 <uni-easyinput type="digit" v-model="item.supplementaryQuantity"
114 placeholder="请输入需求补货数量kg" :inputBorder="false" 116 placeholder="请输入需求补货数量kg" :inputBorder="false"
115 - @input="onNonNegativeNumberInput($event, item, idx, 'supplementaryQuantity')"  
116 - @blur="onNonNegativeNumberBlur(item, idx, 'supplementaryQuantity')" /> 117 + @input="onTwoDecimalInput($event, item, idx, 'supplementaryQuantity')"
  118 + @blur="onTwoDecimalBlur(item, idx, 'supplementaryQuantity')"
  119 + />
117 </template> 120 </template>
118 </uni-list-item> 121 </uni-list-item>
119 <uni-list-item class="amount-item"> 122 <uni-list-item class="amount-item">
@@ -350,8 +353,9 @@ @@ -350,8 +353,9 @@
350 <template v-slot:footer> 353 <template v-slot:footer>
351 <uni-easyinput v-if="canEditSupplementary" type="digit" v-model="item.supplementaryQuantity" 354 <uni-easyinput v-if="canEditSupplementary" type="digit" v-model="item.supplementaryQuantity"
352 placeholder="请输入需求补货数量kg" :inputBorder="false" 355 placeholder="请输入需求补货数量kg" :inputBorder="false"
353 - @input="onNonNegativeNumberInput($event, item, idx, 'supplementaryQuantity')"  
354 - @blur="onNonNegativeNumberBlur(item, idx, 'supplementaryQuantity')" /> 356 + @input="onTwoDecimalInput($event, item, idx, 'supplementaryQuantity')"
  357 + @blur="onTwoDecimalBlur(item, idx, 'supplementaryQuantity')"
  358 + />
355 <text v-else class="value">{{ item.supplementaryQuantity }}</text> 359 <text v-else class="value">{{ item.supplementaryQuantity }}</text>
356 </template> 360 </template>
357 </uni-list-item> 361 </uni-list-item>
@@ -630,6 +634,49 @@ export default { @@ -630,6 +634,49 @@ export default {
630 if (isNaN(n)) item[field] = '' 634 if (isNaN(n)) item[field] = ''
631 if (typeof idx === 'number') this.$set(this.items, idx, { ...item }) 635 if (typeof idx === 'number') this.$set(this.items, idx, { ...item })
632 }, 636 },
  637 + // 限制输入为2位小数
  638 + onTwoDecimalInput(val, item, idx, field) {
  639 + let v = String(val != null ? val : (item && item[field]) || '')
  640 + v = v.replace(/[^0-9.]/g, '')
  641 + v = v.replace(/(\..*)\./g, '$1')
  642 +
  643 + // Restrict to 2 decimal places
  644 + const decimalIndex = v.indexOf('.')
  645 + if (decimalIndex !== -1 && v.length > decimalIndex + 3) {
  646 + v = v.substring(0, decimalIndex + 3)
  647 + }
  648 +
  649 + if (v.startsWith('.')) v = '0' + v
  650 +
  651 + // If the value was modified (truncated or cleaned)
  652 + if (String(val) !== v) {
  653 + // Hack: Temporarily set the dirty value to trigger Vue update mechanism
  654 + // This ensures that when we set the clean value back, Vue detects a change
  655 + item[field] = val
  656 + if (typeof idx === 'number') this.$set(this.items, idx, { ...item })
  657 +
  658 + // Then revert to the clean value asynchronously
  659 + setTimeout(() => {
  660 + item[field] = v
  661 + if (typeof idx === 'number') this.$set(this.items, idx, { ...item })
  662 + }, 0)
  663 + } else {
  664 + item[field] = v
  665 + if (typeof idx === 'number') this.$set(this.items, idx, { ...item })
  666 + }
  667 + },
  668 + onTwoDecimalBlur(item, idx, field) {
  669 + let v = String((item && item[field]) || '')
  670 + const num = Number(v)
  671 + if (isNaN(num) || num < 0) {
  672 + item[field] = '0'
  673 + } else {
  674 + if (v.endsWith('.')) {
  675 + item[field] = v.slice(0, -1)
  676 + }
  677 + }
  678 + if (typeof idx === 'number') this.$set(this.items, idx, { ...item })
  679 + },
633 toggleViewCollapse() { 680 toggleViewCollapse() {
634 this.collapsedView = !this.collapsedView 681 this.collapsedView = !this.collapsedView
635 }, 682 },