42245435 by lihua

修复千分位计算以及数字输入限制

1 parent 0f05ea10
...@@ -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, ".")
...@@ -598,13 +598,29 @@ const inputEventChange = (val, scope, field, max: any = null) => { ...@@ -598,13 +598,29 @@ const inputEventChange = (val, scope, field, max: any = null) => {
598 if (row[field].startsWith('-')) { 598 if (row[field].startsWith('-')) {
599 // 对于负数,去掉负号进行处理 599 // 对于负数,去掉负号进行处理
600 let tempValue = row[field].substring(1); 600 let tempValue = row[field].substring(1);
601 tempValue = tempValue.replace(/^0*(\d+(\.\d{0,2})?)/, '$1'); 601 tempValue = tempValue.replace(/-/g, '');;
602 row[field] = '-' + tempValue; 602 row[field] = '-' + tempValue;
603 } else { 603 } else {
604 // 对于正数直接处理 604 // 对于正数直接处理
605 row[field] = row[field].replace(/^0*(\d+(\.\d{0,2})?)/, '$1'); 605 row[field] = row[field].replace(/-/g, '');
606 } 606 }
607 row[field] = row[field].toString().replace(/^(-?\d{0,12})(\.\d{0,2})?$/, '$1$2'); 607 row[field] = row[field].toString().replace(/^(-?\d{0,12})(\.\d{0,2})?$/, '$1$2');
608
609 let parts = row[field].split('.');
610 let integerPart = parts[0];
611 let decimalPart = parts.length > 1 ? parts[1] : '';
612
613 // 限制整数部分最多12位
614 if (integerPart.length > 12) {
615 integerPart = integerPart.substring(0, 12);
616 }
617
618 // 限制小数部分最多2位
619 if (decimalPart.length > 2) {
620 decimalPart = decimalPart.substring(0, 2);
621 }
622 row[field] = integerPart + (decimalPart ? '.' + decimalPart : (row[field].includes('.') ? '.' : ''))
623
608 if (max !== null) { 624 if (max !== null) {
609 if (row[field] > max) { 625 if (row[field] > max) {
610 row[field] = max; 626 row[field] = max;
...@@ -657,10 +673,10 @@ const incomeCalculateData = computed(() => { //响应式不生效 ...@@ -657,10 +673,10 @@ const incomeCalculateData = computed(() => { //响应式不生效
657 } 673 }
658 let C10 = transfer(data[9][year.field]); 674 let C10 = transfer(data[9][year.field]);
659 resultInfo['折现因子'].push(changeNum(1 / Math.pow((1 + C10), parseFloat(resultInfo['折现年期'][i])), 2, true)); 675 resultInfo['折现因子'].push(changeNum(1 / Math.pow((1 + C10), parseFloat(resultInfo['折现年期'][i])), 2, true));
660 resultInfo['折现现值'].push(changeNum(parseFloat(resultInfo['折现因子'][i]) * parseFloat(resultInfo['现金流'][i]), 2, true)); 676 resultInfo['折现现值'].push(changeNum(parseFloat(resultInfo['折现因子'][i]) * parseFloat(resultInfo['现金流'][i].replace(/,/g, '')), 2, true));
661 }) 677 })
662 resultInfo['数据资产估值'] = changeNum(resultInfo['折现现值'].reduce(function (prev, curr, idx, arr) { 678 resultInfo['数据资产估值'] = changeNum(resultInfo['折现现值'].reduce(function (prev, curr, idx, arr) {
663 return parseFloat(prev) + parseFloat(curr); 679 return parseFloat(prev.replace(/,/g, '')) + parseFloat(curr.replace(/,/g, ''));
664 }), 2, true); 680 }), 2, true);
665 return resultInfo; 681 return resultInfo;
666 }) 682 })
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!