|
...
|
...
|
@@ -96,24 +96,27 @@ |
|
96
|
96
|
<template v-slot:footer>
|
|
97
|
97
|
<uni-easyinput type="digit" v-model="item.quantity" placeholder="请输入数量kg"
|
|
98
|
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
|
102
|
</template>
|
|
102
|
103
|
</uni-list-item>
|
|
103
|
104
|
<uni-list-item title="实发数量(kg)">
|
|
104
|
105
|
<template v-slot:footer>
|
|
105
|
106
|
<uni-easyinput type="digit" v-model="item.shippedQuantity" placeholder="请输入实发数量kg"
|
|
106
|
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
|
111
|
</template>
|
|
110
|
112
|
</uni-list-item>
|
|
111
|
113
|
<uni-list-item title="需求补货数量(kg)">
|
|
112
|
114
|
<template v-slot:footer>
|
|
113
|
115
|
<uni-easyinput type="digit" v-model="item.supplementaryQuantity"
|
|
114
|
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
|
120
|
</template>
|
|
118
|
121
|
</uni-list-item>
|
|
119
|
122
|
<uni-list-item class="amount-item">
|
|
...
|
...
|
@@ -350,8 +353,9 @@ |
|
350
|
353
|
<template v-slot:footer>
|
|
351
|
354
|
<uni-easyinput v-if="canEditSupplementary" type="digit" v-model="item.supplementaryQuantity"
|
|
352
|
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
|
359
|
<text v-else class="value">{{ item.supplementaryQuantity }}</text>
|
|
356
|
360
|
</template>
|
|
357
|
361
|
</uni-list-item>
|
|
...
|
...
|
@@ -630,6 +634,49 @@ export default { |
|
630
|
634
|
if (isNaN(n)) item[field] = ''
|
|
631
|
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
|
680
|
toggleViewCollapse() {
|
|
634
|
681
|
this.collapsedView = !this.collapsedView
|
|
635
|
682
|
},
|
...
|
...
|
|