Commit 157f6c7cb67776bf88af31e91e29a86d0eb844d2
1 parent
5893d6fa
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 |
| @@ -331,7 +331,10 @@ export default { | @@ -331,7 +331,10 @@ export default { | ||
| 331 | const m = res.data || {} | 331 | const m = res.data || {} |
| 332 | const next = { ...this.form, ...m } | 332 | const next = { ...this.form, ...m } |
| 333 | next.id = m.id || m.code || id | 333 | next.id = m.id || m.code || id |
| 334 | - next.purchaseOrderLineList = Array.isArray(m.purchaseOrderLineList) ? m.purchaseOrderLineList.map(x => ({ ...x })) : [] | 334 | + next.purchaseOrderLineList = Array.isArray(m.purchaseOrderLineList) ? m.purchaseOrderLineList.map(x => ({ |
| 335 | + ...x, | ||
| 336 | + assessmentExceedsAgreement: Number(x.assessmentExceedsAgreement || 0).toFixed(2) || 0.00, | ||
| 337 | + })) : [] | ||
| 335 | this.form = next; | 338 | this.form = next; |
| 336 | this.initPurchaseOrderLineList = next.purchaseOrderLineList || []; | 339 | this.initPurchaseOrderLineList = next.purchaseOrderLineList || []; |
| 337 | this.refreshStandardName() | 340 | this.refreshStandardName() |
| @@ -230,7 +230,10 @@ export default { | @@ -230,7 +230,10 @@ export default { | ||
| 230 | const m = res.data || {} | 230 | const m = res.data || {} |
| 231 | const next = { ...this.form, ...m } | 231 | const next = { ...this.form, ...m } |
| 232 | next.id = m.id || m.code || id | 232 | next.id = m.id || m.code || id |
| 233 | - next.purchaseOrderLineList = Array.isArray(m.purchaseOrderLineList) ? m.purchaseOrderLineList.map(x => ({ ...x })) : [] | 233 | + next.purchaseOrderLineList = Array.isArray(m.purchaseOrderLineList) ? m.purchaseOrderLineList.map(x => ({ |
| 234 | + ...x, | ||
| 235 | + assessmentExceedsAgreement: Number(x.assessmentExceedsAgreement || 0).toFixed(2) || 0.00, | ||
| 236 | + })) : [] | ||
| 234 | this.form = next; | 237 | this.form = next; |
| 235 | this.initPurchaseOrderLineList = next.purchaseOrderLineList || []; | 238 | this.initPurchaseOrderLineList = next.purchaseOrderLineList || []; |
| 236 | this.refreshStandardName() | 239 | 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> |
| @@ -377,6 +378,49 @@ export default { | @@ -377,6 +378,49 @@ export default { | ||
| 377 | toggleViewCollapse() { | 378 | toggleViewCollapse() { |
| 378 | this.collapsedView = !this.collapsedView | 379 | this.collapsedView = !this.collapsedView |
| 379 | }, | 380 | }, |
| 381 | + onAssessmentInput(val, idx) { | ||
| 382 | + const it = this.items[idx] | ||
| 383 | + if (!it) return | ||
| 384 | + // 允许负号、数字、小数点 | ||
| 385 | + let v = String(val).replace(/[^0-9.-]/g, '') | ||
| 386 | + // 处理多个小数点 | ||
| 387 | + const parts = v.split('.') | ||
| 388 | + if (parts.length > 2) { | ||
| 389 | + v = parts[0] + '.' + parts.slice(1).join('') | ||
| 390 | + } | ||
| 391 | + // 处理多个负号(仅允许出现在开头) | ||
| 392 | + if (v.indexOf('-') > 0) { | ||
| 393 | + v = v.replace(/-/g, '') | ||
| 394 | + } | ||
| 395 | + if (v.startsWith('-') && (v.match(/-/g) || []).length > 1) { | ||
| 396 | + v = '-' + v.replace(/-/g, '') | ||
| 397 | + } | ||
| 398 | + // 限制两位小数 | ||
| 399 | + if (v.includes('.')) { | ||
| 400 | + const [int, dec] = v.split('.') | ||
| 401 | + v = int + '.' + dec.slice(0, 2) | ||
| 402 | + } | ||
| 403 | + this.$set(this.items[idx], 'assessmentExceedsAgreement', v) | ||
| 404 | + this.emitChange() | ||
| 405 | + }, | ||
| 406 | + onAssessmentBlur(val, idx) { | ||
| 407 | + const it = this.items[idx] | ||
| 408 | + if (!it) return | ||
| 409 | + let v = it.assessmentExceedsAgreement | ||
| 410 | + if (!v || v === '-') { | ||
| 411 | + v = '' | ||
| 412 | + } else { | ||
| 413 | + // 尝试转数字并保留两位小数 | ||
| 414 | + const n = parseFloat(v) | ||
| 415 | + if (!isNaN(n)) { | ||
| 416 | + v = n.toFixed(2) | ||
| 417 | + } else { | ||
| 418 | + v = '' | ||
| 419 | + } | ||
| 420 | + } | ||
| 421 | + this.$set(this.items[idx], 'assessmentExceedsAgreement', v) | ||
| 422 | + this.emitChange() | ||
| 423 | + }, | ||
| 380 | onDeliveryChange(e, item, idx) { | 424 | onDeliveryChange(e, item, idx) { |
| 381 | const getStr = (x) => { | 425 | const getStr = (x) => { |
| 382 | if (x && x.detail && x.detail.value !== undefined) return x.detail.value | 426 | if (x && x.detail && x.detail.value !== undefined) return x.detail.value |