修复千分位计算以及数字输入限制
Showing
1 changed file
with
21 additions
and
5 deletions
| ... | @@ -580,7 +580,7 @@ const inputChange = (val, scope, field) => { | ... | @@ -580,7 +580,7 @@ const inputChange = (val, scope, field) => { |
| 580 | /** 输入框输入触发事件 */ | 580 | /** 输入框输入触发事件 */ |
| 581 | const inputEventChange = (val, scope, field, max: any = null) => { | 581 | const inputEventChange = (val, scope, field, max: any = null) => { |
| 582 | let row = scope.row; | 582 | let row = scope.row; |
| 583 | if (row.indexName == '综合分成率' || row.indexName == '衰减率') { //只能输入正数 | 583 | if (row.indexName == '数据资产分成率' || row.indexName == '衰减率' || formRef.value.formInline?.evaluateMethod == '1') { //只能输入正数 |
| 584 | let row = scope.row; | 584 | let row = scope.row; |
| 585 | row[field] = row[field].toString().replace(/[^\d.]/g, "") | 585 | row[field] = row[field].toString().replace(/[^\d.]/g, "") |
| 586 | row[field] = row[field].toString().replace(/\.{2,}/g, ".") | 586 | row[field] = row[field].toString().replace(/\.{2,}/g, ".") |
| ... | @@ -597,13 +597,29 @@ const inputEventChange = (val, scope, field, max: any = null) => { | ... | @@ -597,13 +597,29 @@ const inputEventChange = (val, scope, field, max: any = null) => { |
| 597 | if (row[field].startsWith('-')) { | 597 | if (row[field].startsWith('-')) { |
| 598 | // 对于负数,去掉负号进行处理 | 598 | // 对于负数,去掉负号进行处理 |
| 599 | let tempValue = row[field].substring(1); | 599 | let tempValue = row[field].substring(1); |
| 600 | tempValue = tempValue.replace(/^0*(\d+(\.\d{0,2})?)/, '$1'); | 600 | tempValue = tempValue.replace(/-/g, '');; |
| 601 | row[field] = '-' + tempValue; | 601 | row[field] = '-' + tempValue; |
| 602 | } else { | 602 | } else { |
| 603 | // 对于正数直接处理 | 603 | // 对于正数直接处理 |
| 604 | row[field] = row[field].replace(/^0*(\d+(\.\d{0,2})?)/, '$1'); | 604 | row[field] = row[field].replace(/-/g, ''); |
| 605 | } | 605 | } |
| 606 | row[field] = row[field].toString().replace(/^(-?\d{0,12})(\.\d{0,2})?$/, '$1$2'); | 606 | row[field] = row[field].toString().replace(/^(-?\d{0,12})(\.\d{0,2})?$/, '$1$2'); |
| 607 | |||
| 608 | let parts = row[field].split('.'); | ||
| 609 | let integerPart = parts[0]; | ||
| 610 | let decimalPart = parts.length > 1 ? parts[1] : ''; | ||
| 611 | |||
| 612 | // 限制整数部分最多12位 | ||
| 613 | if (integerPart.length > 12) { | ||
| 614 | integerPart = integerPart.substring(0, 12); | ||
| 615 | } | ||
| 616 | |||
| 617 | // 限制小数部分最多2位 | ||
| 618 | if (decimalPart.length > 2) { | ||
| 619 | decimalPart = decimalPart.substring(0, 2); | ||
| 620 | } | ||
| 621 | row[field] = integerPart + (decimalPart ? '.' + decimalPart : (row[field].includes('.') ? '.' : '')) | ||
| 622 | |||
| 607 | if (max !== null) { | 623 | if (max !== null) { |
| 608 | if (row[field] > max) { | 624 | if (row[field] > max) { |
| 609 | row[field] = max; | 625 | row[field] = max; |
| ... | @@ -656,10 +672,10 @@ const incomeCalculateData = computed(() => { //响应式不生效 | ... | @@ -656,10 +672,10 @@ const incomeCalculateData = computed(() => { //响应式不生效 |
| 656 | } | 672 | } |
| 657 | let C10 = transfer(data[9][year.field]); | 673 | let C10 = transfer(data[9][year.field]); |
| 658 | resultInfo['折现因子'].push(changeNum(1 / Math.pow((1 + C10), parseFloat(resultInfo['折现年期'][i])), 2, true)); | 674 | resultInfo['折现因子'].push(changeNum(1 / Math.pow((1 + C10), parseFloat(resultInfo['折现年期'][i])), 2, true)); |
| 659 | resultInfo['折现现值'].push(changeNum(parseFloat(resultInfo['折现因子'][i]) * parseFloat(resultInfo['现金流'][i]), 2, true)); | 675 | resultInfo['折现现值'].push(changeNum(parseFloat(resultInfo['折现因子'][i]) * parseFloat(resultInfo['现金流'][i].replace(/,/g, '')), 2, true)); |
| 660 | }) | 676 | }) |
| 661 | resultInfo['数据资产估值'] = changeNum(resultInfo['折现现值'].reduce(function (prev, curr, idx, arr) { | 677 | resultInfo['数据资产估值'] = changeNum(resultInfo['折现现值'].reduce(function (prev, curr, idx, arr) { |
| 662 | return parseFloat(prev) + parseFloat(curr); | 678 | return parseFloat(prev.replace(/,/g, '')) + parseFloat(curr.replace(/,/g, '')); |
| 663 | }), 2, true); | 679 | }), 2, true); |
| 664 | return resultInfo; | 680 | return resultInfo; |
| 665 | }) | 681 | }) | ... | ... |
-
Please register or sign in to post a comment