Commit e1167f08847b9920ce5dd44525ef44ebd98f8574
1 parent
8ce52909
feat: 规格变更单-新增&编辑-产品:厚度、厚度公差 +、厚度公差 -、宽度、宽度公差 +、宽度公差 -、长度、长度公差 +、长度公差 -、数量kg、销售价…
…格 都改成 只能输入数字,且大于等于0,可输入小数
Showing
1 changed file
with
42 additions
and
17 deletions
| @@ -36,53 +36,56 @@ | @@ -36,53 +36,56 @@ | ||
| 36 | <view v-show="!item.collapsed"> | 36 | <view v-show="!item.collapsed"> |
| 37 | <uni-list-item title="厚度"> | 37 | <uni-list-item title="厚度"> |
| 38 | <template v-slot:footer> | 38 | <template v-slot:footer> |
| 39 | - <uni-easyinput v-model="item.thickness" placeholder="请输入厚度" :inputBorder="false" /> | 39 | + <uni-easyinput type="digit" v-model="item.thickness" placeholder="请输入厚度" :inputBorder="false" |
| 40 | + @input="onNonNegativeNumberInput($event, item, idx, 'thickness')" @blur="onNonNegativeNumberBlur(item, idx, 'thickness')" /> | ||
| 40 | </template> | 41 | </template> |
| 41 | </uni-list-item> | 42 | </uni-list-item> |
| 42 | <uni-list-item title="厚度公差 +"> | 43 | <uni-list-item title="厚度公差 +"> |
| 43 | <template v-slot:footer> | 44 | <template v-slot:footer> |
| 44 | - <uni-easyinput v-model="item.thicknessTolPos" placeholder="请输入厚度公差 +" | ||
| 45 | - :inputBorder="false" /> | 45 | + <uni-easyinput type="digit" v-model="item.thicknessTolPos" placeholder="请输入厚度公差 +" |
| 46 | + :inputBorder="false" @input="onNonNegativeNumberInput($event, item, idx, 'thicknessTolPos')" @blur="onNonNegativeNumberBlur(item, idx, 'thicknessTolPos')" /> | ||
| 46 | </template> | 47 | </template> |
| 47 | </uni-list-item> | 48 | </uni-list-item> |
| 48 | <uni-list-item title="厚度公差 -"> | 49 | <uni-list-item title="厚度公差 -"> |
| 49 | <template v-slot:footer> | 50 | <template v-slot:footer> |
| 50 | - <uni-easyinput v-model="item.thicknessTolNeg" placeholder="请输入厚度公差 -" | ||
| 51 | - :inputBorder="false" /> | 51 | + <uni-easyinput type="digit" v-model="item.thicknessTolNeg" placeholder="请输入厚度公差 -" |
| 52 | + :inputBorder="false" @input="onNonNegativeNumberInput($event, item, idx, 'thicknessTolNeg')" @blur="onNonNegativeNumberBlur(item, idx, 'thicknessTolNeg')" /> | ||
| 52 | </template> | 53 | </template> |
| 53 | </uni-list-item> | 54 | </uni-list-item> |
| 54 | <uni-list-item title="宽度"> | 55 | <uni-list-item title="宽度"> |
| 55 | <template v-slot:footer> | 56 | <template v-slot:footer> |
| 56 | - <uni-easyinput v-model="item.width" placeholder="请输入宽度" :inputBorder="false" /> | 57 | + <uni-easyinput type="digit" v-model="item.width" placeholder="请输入宽度" :inputBorder="false" |
| 58 | + @input="onNonNegativeNumberInput($event, item, idx, 'width')" @blur="onNonNegativeNumberBlur(item, idx, 'width')" /> | ||
| 57 | </template> | 59 | </template> |
| 58 | </uni-list-item> | 60 | </uni-list-item> |
| 59 | <uni-list-item title="宽度公差 +"> | 61 | <uni-list-item title="宽度公差 +"> |
| 60 | <template v-slot:footer> | 62 | <template v-slot:footer> |
| 61 | - <uni-easyinput v-model="item.widthTolPos" placeholder="请输入宽度公差 +" | ||
| 62 | - :inputBorder="false" /> | 63 | + <uni-easyinput type="digit" v-model="item.widthTolPos" placeholder="请输入宽度公差 +" |
| 64 | + :inputBorder="false" @input="onNonNegativeNumberInput($event, item, idx, 'widthTolPos')" @blur="onNonNegativeNumberBlur(item, idx, 'widthTolPos')" /> | ||
| 63 | </template> | 65 | </template> |
| 64 | </uni-list-item> | 66 | </uni-list-item> |
| 65 | <uni-list-item title="宽度公差 -"> | 67 | <uni-list-item title="宽度公差 -"> |
| 66 | <template v-slot:footer> | 68 | <template v-slot:footer> |
| 67 | - <uni-easyinput v-model="item.widthTolNeg" placeholder="请输入宽度公差 -" | ||
| 68 | - :inputBorder="false" /> | 69 | + <uni-easyinput type="digit" v-model="item.widthTolNeg" placeholder="请输入宽度公差 -" |
| 70 | + :inputBorder="false" @input="onNonNegativeNumberInput($event, item, idx, 'widthTolNeg')" @blur="onNonNegativeNumberBlur(item, idx, 'widthTolNeg')" /> | ||
| 69 | </template> | 71 | </template> |
| 70 | </uni-list-item> | 72 | </uni-list-item> |
| 71 | <uni-list-item title="长度"> | 73 | <uni-list-item title="长度"> |
| 72 | <template v-slot:footer> | 74 | <template v-slot:footer> |
| 73 | - <uni-easyinput v-model="item.length" placeholder="请输入长度" :inputBorder="false" /> | 75 | + <uni-easyinput type="digit" v-model="item.length" placeholder="请输入长度" :inputBorder="false" |
| 76 | + @input="onNonNegativeNumberInput($event, item, idx, 'length')" @blur="onNonNegativeNumberBlur(item, idx, 'length')" /> | ||
| 74 | </template> | 77 | </template> |
| 75 | </uni-list-item> | 78 | </uni-list-item> |
| 76 | <uni-list-item title="长度公差 +"> | 79 | <uni-list-item title="长度公差 +"> |
| 77 | <template v-slot:footer> | 80 | <template v-slot:footer> |
| 78 | - <uni-easyinput v-model="item.lengthTolPos" placeholder="请输入长度公差 +" | ||
| 79 | - :inputBorder="false" /> | 81 | + <uni-easyinput type="digit" v-model="item.lengthTolPos" placeholder="请输入长度公差 +" |
| 82 | + :inputBorder="false" @input="onNonNegativeNumberInput($event, item, idx, 'lengthTolPos')" @blur="onNonNegativeNumberBlur(item, idx, 'lengthTolPos')" /> | ||
| 80 | </template> | 83 | </template> |
| 81 | </uni-list-item> | 84 | </uni-list-item> |
| 82 | <uni-list-item title="长度公差 -"> | 85 | <uni-list-item title="长度公差 -"> |
| 83 | <template v-slot:footer> | 86 | <template v-slot:footer> |
| 84 | - <uni-easyinput v-model="item.lengthTolNeg" placeholder="请输入长度公差 -" | ||
| 85 | - :inputBorder="false" /> | 87 | + <uni-easyinput type="digit" v-model="item.lengthTolNeg" placeholder="请输入长度公差 -" |
| 88 | + :inputBorder="false" @input="onNonNegativeNumberInput($event, item, idx, 'lengthTolNeg')" @blur="onNonNegativeNumberBlur(item, idx, 'lengthTolNeg')" /> | ||
| 86 | </template> | 89 | </template> |
| 87 | </uni-list-item> | 90 | </uni-list-item> |
| 88 | <uni-list-item title="状态"> | 91 | <uni-list-item title="状态"> |
| @@ -92,12 +95,14 @@ | @@ -92,12 +95,14 @@ | ||
| 92 | </uni-list-item> | 95 | </uni-list-item> |
| 93 | <uni-list-item title="数量kg"> | 96 | <uni-list-item title="数量kg"> |
| 94 | <template v-slot:footer> | 97 | <template v-slot:footer> |
| 95 | - <uni-easyinput v-model="item.quantity" placeholder="请输入数量kg" :inputBorder="false" /> | 98 | + <uni-easyinput type="digit" v-model="item.quantity" placeholder="请输入数量kg" :inputBorder="false" |
| 99 | + @input="onNonNegativeNumberInput($event, item, idx, 'quantity')" @blur="onNonNegativeNumberBlur(item, idx, 'quantity')" /> | ||
| 96 | </template> | 100 | </template> |
| 97 | </uni-list-item> | 101 | </uni-list-item> |
| 98 | <uni-list-item v-if="item.showSalesPrice" title="销售价格"> | 102 | <uni-list-item v-if="item.showSalesPrice" title="销售价格"> |
| 99 | <template v-slot:footer> | 103 | <template v-slot:footer> |
| 100 | - <uni-easyinput v-model="item.salesPrice" placeholder="请输入销售价格" :inputBorder="false" /> | 104 | + <uni-easyinput type="digit" v-model="item.salesPrice" placeholder="请输入销售价格" :inputBorder="false" |
| 105 | + @input="onNonNegativeNumberInput($event, item, idx, 'salesPrice')" @blur="onNonNegativeNumberBlur(item, idx, 'salesPrice')" /> | ||
| 101 | </template> | 106 | </template> |
| 102 | </uni-list-item> | 107 | </uni-list-item> |
| 103 | <uni-list-item title="发货日期"> | 108 | <uni-list-item title="发货日期"> |
| @@ -280,6 +285,26 @@ export default { | @@ -280,6 +285,26 @@ export default { | ||
| 280 | this.$emit('update:value', out) | 285 | this.$emit('update:value', out) |
| 281 | this.$emit('change', out) | 286 | this.$emit('change', out) |
| 282 | }, | 287 | }, |
| 288 | + onNonNegativeNumberInput(val, item, idx, field) { | ||
| 289 | + let v = String(val != null ? val : (item && item[field]) || '') | ||
| 290 | + v = v.replace(/[^0-9.]/g, '') | ||
| 291 | + v = v.replace(/(\..*)\./g, '$1') | ||
| 292 | + if (v.startsWith('.')) v = '0' + v | ||
| 293 | + if (v === '') { item[field] = ''; if (typeof idx === 'number') this.$set(this.items, idx, { ...item }); return } | ||
| 294 | + const num = Number(v) | ||
| 295 | + if (isNaN(num) || num < 0) { | ||
| 296 | + item[field] = '0' | ||
| 297 | + } else { | ||
| 298 | + item[field] = v | ||
| 299 | + } | ||
| 300 | + if (typeof idx === 'number') this.$set(this.items, idx, { ...item }) | ||
| 301 | + }, | ||
| 302 | + onNonNegativeNumberBlur(item, idx, field) { | ||
| 303 | + const v = String((item && item[field]) || '') | ||
| 304 | + const num = Number(v) | ||
| 305 | + if (isNaN(num) || num < 0) item[field] = '0' | ||
| 306 | + if (typeof idx === 'number') this.$set(this.items, idx, { ...item }) | ||
| 307 | + }, | ||
| 283 | toggleViewCollapse() { | 308 | toggleViewCollapse() { |
| 284 | this.collapsedView = !this.collapsedView | 309 | this.collapsedView = !this.collapsedView |
| 285 | } | 310 | } |