fa94c746 by lihua

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

1 parent 51140dba
......@@ -580,7 +580,7 @@ const inputChange = (val, scope, field) => {
/** 输入框输入触发事件 */
const inputEventChange = (val, scope, field, max: any = null) => {
let row = scope.row;
if (row.indexName == '综合分成率' || row.indexName == '衰减率') { //只能输入正数
if (row.indexName == '数据资产分成率' || row.indexName == '衰减率' || formRef.value.formInline?.evaluateMethod == '1') { //只能输入正数
let row = scope.row;
row[field] = row[field].toString().replace(/[^\d.]/g, "")
row[field] = row[field].toString().replace(/\.{2,}/g, ".")
......@@ -597,13 +597,29 @@ const inputEventChange = (val, scope, field, max: any = null) => {
if (row[field].startsWith('-')) {
// 对于负数,去掉负号进行处理
let tempValue = row[field].substring(1);
tempValue = tempValue.replace(/^0*(\d+(\.\d{0,2})?)/, '$1');
tempValue = tempValue.replace(/-/g, '');;
row[field] = '-' + tempValue;
} else {
// 对于正数直接处理
row[field] = row[field].replace(/^0*(\d+(\.\d{0,2})?)/, '$1');
row[field] = row[field].replace(/-/g, '');
}
row[field] = row[field].toString().replace(/^(-?\d{0,12})(\.\d{0,2})?$/, '$1$2');
let parts = row[field].split('.');
let integerPart = parts[0];
let decimalPart = parts.length > 1 ? parts[1] : '';
// 限制整数部分最多12位
if (integerPart.length > 12) {
integerPart = integerPart.substring(0, 12);
}
// 限制小数部分最多2位
if (decimalPart.length > 2) {
decimalPart = decimalPart.substring(0, 2);
}
row[field] = integerPart + (decimalPart ? '.' + decimalPart : (row[field].includes('.') ? '.' : ''))
if (max !== null) {
if (row[field] > max) {
row[field] = max;
......@@ -656,10 +672,10 @@ const incomeCalculateData = computed(() => { //响应式不生效
}
let C10 = transfer(data[9][year.field]);
resultInfo['折现因子'].push(changeNum(1 / Math.pow((1 + C10), parseFloat(resultInfo['折现年期'][i])), 2, true));
resultInfo['折现现值'].push(changeNum(parseFloat(resultInfo['折现因子'][i]) * parseFloat(resultInfo['现金流'][i]), 2, true));
resultInfo['折现现值'].push(changeNum(parseFloat(resultInfo['折现因子'][i]) * parseFloat(resultInfo['现金流'][i].replace(/,/g, '')), 2, true));
})
resultInfo['数据资产估值'] = changeNum(resultInfo['折现现值'].reduce(function (prev, curr, idx, arr) {
return parseFloat(prev) + parseFloat(curr);
return parseFloat(prev.replace(/,/g, '')) + parseFloat(curr.replace(/,/g, ''));
}), 2, true);
return resultInfo;
})
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!