Commit 3cd8e51bca360b4082fab7c887e7f5e853447eaf
1 parent
0e4a8a37
feat: 订货单-编辑&审核+变更单-新增&编辑--考核超协改为number(可正可负两位小数)
Showing
6 changed files
with
108 additions
and
8 deletions
| @@ -216,7 +216,10 @@ export default { | @@ -216,7 +216,10 @@ export default { | ||
| 216 | const m = res.data || {} | 216 | const m = res.data || {} |
| 217 | const next = { ...this.form, ...m } | 217 | const next = { ...this.form, ...m } |
| 218 | next.id = m.id || m.code || id | 218 | next.id = m.id || m.code || id |
| 219 | - next.purchaseOrderLineList = Array.isArray(m.purchaseOrderLineList) ? m.purchaseOrderLineList.map(x => ({ ...x })) : [] | 219 | + next.purchaseOrderLineList = Array.isArray(m.purchaseOrderLineList) ? m.purchaseOrderLineList.map(x => ({ |
| 220 | + ...x, | ||
| 221 | + assessmentExceedsAgreement: Number(x.assessmentExceedsAgreement || 0).toFixed(2) || 0.00, | ||
| 222 | + })) : [] | ||
| 220 | this.form = next; | 223 | this.form = next; |
| 221 | this.initPurchaseOrderLineList = next.purchaseOrderLineList || []; | 224 | this.initPurchaseOrderLineList = next.purchaseOrderLineList || []; |
| 222 | this.refreshStandardName() | 225 | this.refreshStandardName() |
| @@ -212,7 +212,10 @@ export default { | @@ -212,7 +212,10 @@ export default { | ||
| 212 | const next = { ...this.form, ...m } | 212 | const next = { ...this.form, ...m } |
| 213 | next.id = m.id || m.code || id; | 213 | next.id = m.id || m.code || id; |
| 214 | next.purchaseOrderId = m.orderId || ''; | 214 | next.purchaseOrderId = m.orderId || ''; |
| 215 | - next.purchaseOrderLineList = Array.isArray(m.afterChangeSpecList) ? m.afterChangeSpecList.map(x => ({ ...x })) : [] | 215 | + next.purchaseOrderLineList = Array.isArray(m.afterChangeSpecList) ? m.afterChangeSpecList.map(x => ({ |
| 216 | + ...x, | ||
| 217 | + assessmentExceedsAgreement: Number(x.assessmentExceedsAgreement || 0).toFixed(2) || 0.00, | ||
| 218 | + })) : [] | ||
| 216 | this.form = next; | 219 | this.form = next; |
| 217 | this.initPurchaseOrderLineList = next.purchaseOrderLineList || []; | 220 | this.initPurchaseOrderLineList = next.purchaseOrderLineList || []; |
| 218 | this.refreshStandardName() | 221 | this.refreshStandardName() |
| @@ -148,8 +148,9 @@ | @@ -148,8 +148,9 @@ | ||
| 148 | </uni-list-item> | 148 | </uni-list-item> |
| 149 | <uni-list-item title="考核超协"> | 149 | <uni-list-item title="考核超协"> |
| 150 | <template v-slot:footer> | 150 | <template v-slot:footer> |
| 151 | - <uni-easyinput v-model="item.assessmentExceedsAgreement" placeholder="请输入考核超协" | ||
| 152 | - :inputBorder="false" /> | 151 | + <uni-easyinput type="digit" v-model="item.assessmentExceedsAgreement" |
| 152 | + placeholder="请输入考核超协" :inputBorder="false" | ||
| 153 | + @input="onAssessmentInput($event, idx)" @blur="onAssessmentBlur($event, idx)" /> | ||
| 153 | </template> | 154 | </template> |
| 154 | </uni-list-item> | 155 | </uni-list-item> |
| 155 | </view> | 156 | </view> |
| @@ -330,6 +331,49 @@ export default { | @@ -330,6 +331,49 @@ export default { | ||
| 330 | } | 331 | } |
| 331 | }) | 332 | }) |
| 332 | }, | 333 | }, |
| 334 | + onAssessmentInput(val, idx) { | ||
| 335 | + const it = this.items[idx] | ||
| 336 | + if (!it) return | ||
| 337 | + // 允许负号、数字、小数点 | ||
| 338 | + let v = String(val).replace(/[^0-9.-]/g, '') | ||
| 339 | + // 处理多个小数点 | ||
| 340 | + const parts = v.split('.') | ||
| 341 | + if (parts.length > 2) { | ||
| 342 | + v = parts[0] + '.' + parts.slice(1).join('') | ||
| 343 | + } | ||
| 344 | + // 处理多个负号(仅允许出现在开头) | ||
| 345 | + if (v.indexOf('-') > 0) { | ||
| 346 | + v = v.replace(/-/g, '') | ||
| 347 | + } | ||
| 348 | + if (v.startsWith('-') && (v.match(/-/g) || []).length > 1) { | ||
| 349 | + v = '-' + v.replace(/-/g, '') | ||
| 350 | + } | ||
| 351 | + // 限制两位小数 | ||
| 352 | + if (v.includes('.')) { | ||
| 353 | + const [int, dec] = v.split('.') | ||
| 354 | + v = int + '.' + dec.slice(0, 2) | ||
| 355 | + } | ||
| 356 | + this.$set(this.items[idx], 'assessmentExceedsAgreement', v) | ||
| 357 | + this.emitChange() | ||
| 358 | + }, | ||
| 359 | + onAssessmentBlur(val, idx) { | ||
| 360 | + const it = this.items[idx] | ||
| 361 | + if (!it) return | ||
| 362 | + let v = it.assessmentExceedsAgreement | ||
| 363 | + if (!v || v === '-') { | ||
| 364 | + v = '' | ||
| 365 | + } else { | ||
| 366 | + // 尝试转数字并保留两位小数 | ||
| 367 | + const n = parseFloat(v) | ||
| 368 | + if (!isNaN(n)) { | ||
| 369 | + v = n.toFixed(2) | ||
| 370 | + } else { | ||
| 371 | + v = '' | ||
| 372 | + } | ||
| 373 | + } | ||
| 374 | + this.$set(this.items[idx], 'assessmentExceedsAgreement', v) | ||
| 375 | + this.emitChange() | ||
| 376 | + }, | ||
| 333 | toggleItem(idx) { | 377 | toggleItem(idx) { |
| 334 | const it = this.items[idx] | 378 | const it = this.items[idx] |
| 335 | if (!it) return | 379 | if (!it) return |
| @@ -316,7 +316,10 @@ export default { | @@ -316,7 +316,10 @@ export default { | ||
| 316 | const m = res.data || {} | 316 | const m = res.data || {} |
| 317 | const next = { ...this.form, ...m } | 317 | const next = { ...this.form, ...m } |
| 318 | next.id = m.id || m.code || id | 318 | next.id = m.id || m.code || id |
| 319 | - next.purchaseOrderLineList = Array.isArray(m.purchaseOrderLineList) ? m.purchaseOrderLineList.map(x => ({ ...x })) : [] | 319 | + next.purchaseOrderLineList = Array.isArray(m.purchaseOrderLineList) ? m.purchaseOrderLineList.map(x => ({ |
| 320 | + ...x, | ||
| 321 | + assessmentExceedsAgreement: Number(x.assessmentExceedsAgreement || 0).toFixed(2) || 0.00, | ||
| 322 | + })) : [] | ||
| 320 | this.form = next; | 323 | this.form = next; |
| 321 | this.initPurchaseOrderLineList = next.purchaseOrderLineList || []; | 324 | this.initPurchaseOrderLineList = next.purchaseOrderLineList || []; |
| 322 | this.refreshStandardName() | 325 | this.refreshStandardName() |
| @@ -225,7 +225,10 @@ export default { | @@ -225,7 +225,10 @@ export default { | ||
| 225 | const m = res.data || {} | 225 | const m = res.data || {} |
| 226 | const next = { ...this.form, ...m } | 226 | const next = { ...this.form, ...m } |
| 227 | next.id = m.id || m.code || id | 227 | next.id = m.id || m.code || id |
| 228 | - next.purchaseOrderLineList = Array.isArray(m.purchaseOrderLineList) ? m.purchaseOrderLineList.map(x => ({ ...x })) : [] | 228 | + next.purchaseOrderLineList = Array.isArray(m.purchaseOrderLineList) ? m.purchaseOrderLineList.map(x => ({ |
| 229 | + ...x, | ||
| 230 | + assessmentExceedsAgreement: Number(x.assessmentExceedsAgreement || 0).toFixed(2) || 0.00, | ||
| 231 | + })) : [] | ||
| 229 | this.form = next; | 232 | this.form = next; |
| 230 | this.initPurchaseOrderLineList = next.purchaseOrderLineList || []; | 233 | this.initPurchaseOrderLineList = next.purchaseOrderLineList || []; |
| 231 | this.refreshStandardName() | 234 | this.refreshStandardName() |
| @@ -75,9 +75,10 @@ | @@ -75,9 +75,10 @@ | ||
| 75 | </uni-list-item> | 75 | </uni-list-item> |
| 76 | <uni-list-item title="考核超协"> | 76 | <uni-list-item title="考核超协"> |
| 77 | <template v-slot:footer> | 77 | <template v-slot:footer> |
| 78 | - <uni-easyinput :disabled="pageType === 'modify'" | 78 | + <uni-easyinput type="digit" :disabled="pageType === 'modify'" |
| 79 | v-model="item.assessmentExceedsAgreement" | 79 | v-model="item.assessmentExceedsAgreement" |
| 80 | - :placeholder="pageType === 'modify' ? '' : '请输入考核超协'" :inputBorder="false" /> | 80 | + :placeholder="pageType === 'modify' ? '' : '请输入考核超协'" :inputBorder="false" |
| 81 | + @input="onAssessmentInput($event, idx)" @blur="onAssessmentBlur($event, idx)" /> | ||
| 81 | </template> | 82 | </template> |
| 82 | </uni-list-item> | 83 | </uni-list-item> |
| 83 | </uni-list> | 84 | </uni-list> |
| @@ -223,6 +224,49 @@ export default { | @@ -223,6 +224,49 @@ export default { | ||
| 223 | toggleViewCollapse() { | 224 | toggleViewCollapse() { |
| 224 | this.collapsedView = !this.collapsedView | 225 | this.collapsedView = !this.collapsedView |
| 225 | }, | 226 | }, |
| 227 | + onAssessmentInput(val, idx) { | ||
| 228 | + const it = this.items[idx] | ||
| 229 | + if (!it) return | ||
| 230 | + // 允许负号、数字、小数点 | ||
| 231 | + let v = String(val).replace(/[^0-9.-]/g, '') | ||
| 232 | + // 处理多个小数点 | ||
| 233 | + const parts = v.split('.') | ||
| 234 | + if (parts.length > 2) { | ||
| 235 | + v = parts[0] + '.' + parts.slice(1).join('') | ||
| 236 | + } | ||
| 237 | + // 处理多个负号(仅允许出现在开头) | ||
| 238 | + if (v.indexOf('-') > 0) { | ||
| 239 | + v = v.replace(/-/g, '') | ||
| 240 | + } | ||
| 241 | + if (v.startsWith('-') && (v.match(/-/g) || []).length > 1) { | ||
| 242 | + v = '-' + v.replace(/-/g, '') | ||
| 243 | + } | ||
| 244 | + // 限制两位小数 | ||
| 245 | + if (v.includes('.')) { | ||
| 246 | + const [int, dec] = v.split('.') | ||
| 247 | + v = int + '.' + dec.slice(0, 2) | ||
| 248 | + } | ||
| 249 | + this.$set(this.items[idx], 'assessmentExceedsAgreement', v) | ||
| 250 | + this.emitChange() | ||
| 251 | + }, | ||
| 252 | + onAssessmentBlur(val, idx) { | ||
| 253 | + const it = this.items[idx] | ||
| 254 | + if (!it) return | ||
| 255 | + let v = it.assessmentExceedsAgreement | ||
| 256 | + if (!v || v === '-') { | ||
| 257 | + v = '' | ||
| 258 | + } else { | ||
| 259 | + // 尝试转数字并保留两位小数 | ||
| 260 | + const n = parseFloat(v) | ||
| 261 | + if (!isNaN(n)) { | ||
| 262 | + v = n.toFixed(2) | ||
| 263 | + } else { | ||
| 264 | + v = '' | ||
| 265 | + } | ||
| 266 | + } | ||
| 267 | + this.$set(this.items[idx], 'assessmentExceedsAgreement', v) | ||
| 268 | + this.emitChange() | ||
| 269 | + }, | ||
| 226 | onDeliveryChange(e, item, idx) { | 270 | onDeliveryChange(e, item, idx) { |
| 227 | const getStr = (x) => { | 271 | const getStr = (x) => { |
| 228 | if (x && x.detail && x.detail.value !== undefined) return x.detail.value | 272 | if (x && x.detail && x.detail.value !== undefined) return x.detail.value |