|
|
@@ -306,18 +306,19 @@ $(document).ready(() => {
|
|
|
}
|
|
|
const num = parseFloat(validText.toPrecision(10));
|
|
|
if (validText !== null && num < 0) {
|
|
|
- toastr.error('请输入10位以内有效数字并且小于3位小数的浮点数');
|
|
|
+ toastr.error('请输入10位以内有效数字并且小于' + materialExponentDecimal.up + '位小数的浮点数');
|
|
|
SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
return;
|
|
|
} else if (validText !== null) {
|
|
|
- if(!Number.isInteger(num) && !/^(\d{1,10}\.\d{1,3})?$/.test(num)) {
|
|
|
- toastr.warning('已保留3位小数');
|
|
|
+ const reg = new RegExp("^(\\d{1,10}\\.\\d{1,"+ materialExponentDecimal.up +"})?$");
|
|
|
+ if(!Number.isInteger(num) && !reg.test(num)) {
|
|
|
+ toastr.warning('已保留' + materialExponentDecimal.up + '位小数');
|
|
|
} else if (validText.toString().length > 11) {
|
|
|
toastr.warning('已保留10位有效数字');
|
|
|
}
|
|
|
// SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
// return;
|
|
|
- validText = ZhCalc.round(num, 3);
|
|
|
+ validText = ZhCalc.round(num, materialExponentDecimal.up);
|
|
|
}
|
|
|
}
|
|
|
if (col.field === 'weight_num') {
|
|
|
@@ -327,14 +328,15 @@ $(document).ready(() => {
|
|
|
return;
|
|
|
}
|
|
|
let num = parseFloat(validText);
|
|
|
+ const reg = new RegExp("^\\d+(\\.\\d{1,"+ materialExponentDecimal.qty +"})?$");
|
|
|
if (validText !== null && (num < 0 || num >= 1)) {
|
|
|
- toastr.error('请输入0~1范围内并且小于3位小数的浮点数');
|
|
|
+ toastr.error('请输入0~1范围内并且小于' + materialExponentDecimal.qty +'位小数的浮点数');
|
|
|
SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
return;
|
|
|
- } else if (validText !== null && num > 0 && num < 1 && !/^\d+(\.\d{1,3})?$/.test(num)) {
|
|
|
- toastr.warning('已保留3位小数');
|
|
|
- validText = ZhCalc.round(num, 3);
|
|
|
- num = ZhCalc.round(num, 3);
|
|
|
+ } else if (validText !== null && num > 0 && num < 1 && !reg.test(num)) {
|
|
|
+ toastr.warning('已保留' + materialExponentDecimal.qty + '位小数');
|
|
|
+ validText = ZhCalc.round(num, materialExponentDecimal.qty);
|
|
|
+ num = ZhCalc.round(num, materialExponentDecimal.qty);
|
|
|
}
|
|
|
const weight_datas = showStageExponent || exponent_nodes ? _.filter(materialExponentShardData, { ms_id: parseInt($('#myTab').find('.active').attr('data-msid')) || null, mn_id: parseInt($('#myTab2').find('.active').attr('data-mnid')) || null }) : materialExponentData;
|
|
|
const total_weight = ZhCalc.add(ZhCalc.sub(ZhCalc.sum(_.map(weight_datas, 'weight_num')), parseFloat(orgValue)), num);
|
|
|
@@ -466,9 +468,10 @@ $(document).ready(() => {
|
|
|
const hint = {
|
|
|
cellError: {type: 'error', msg: '粘贴内容超出了表格范围'},
|
|
|
numberExpr: {type: 'error', msg: '不能粘贴其它非数字类型字符'},
|
|
|
- numberCan: {type: 'error', msg: '请粘贴10位以内有效数字并且小于3位小数的浮点数'},
|
|
|
- numberCan2: {type: 'error', msg: '请粘贴0~1范围内并且小于3位小数的浮点数'},
|
|
|
- numberCan3: {type: 'warning', msg: '已保留3位小数'},
|
|
|
+ numberCan: {type: 'error', msg: '请粘贴10位以内有效数字并且小于'+ materialExponentDecimal.up +'位小数的浮点数'},
|
|
|
+ numberCan2: {type: 'error', msg: '请粘贴0~1范围内并且小于'+ materialExponentDecimal.qty +'位小数的浮点数'},
|
|
|
+ numberCanUp: {type: 'warning', msg: '已保留'+ materialExponentDecimal.up +'位小数'},
|
|
|
+ numberCanQty: {type: 'warning', msg: '已保留'+ materialExponentDecimal.qty +'位小数'},
|
|
|
numberCan4: {type: 'warning', msg: '已保留10位有效数字'},
|
|
|
weightNumberCan: {type: 'error', msg: '粘贴的加权系数总和不能大于1'},
|
|
|
};
|
|
|
@@ -523,14 +526,15 @@ $(document).ready(() => {
|
|
|
bPaste = false;
|
|
|
continue;
|
|
|
} else if (validText !== null) {
|
|
|
- if(!Number.isInteger(num) && !/^(\d{1,10}\.\d{1,3})?$/.test(num)) {
|
|
|
- toastMessageUniq(getPasteHint(hint.numberCan3, hintRow));
|
|
|
+ const reg = new RegExp("^(\\d{1,10}\\.\\d{1,"+ materialExponentDecimal.up +"})?$");
|
|
|
+ if(!Number.isInteger(num) && !reg.test(num)) {
|
|
|
+ toastMessageUniq(getPasteHint(hint.numberCanUp, hintRow));
|
|
|
} else if (validText.toString().length > 11) {
|
|
|
toastMessageUniq(getPasteHint(hint.numberCan4, hintRow));
|
|
|
}
|
|
|
// SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
// return;
|
|
|
- validText = ZhCalc.round(num, 3);
|
|
|
+ validText = ZhCalc.round(num, materialExponentDecimal.up);
|
|
|
}
|
|
|
}
|
|
|
if (colSetting.field === 'weight_num') {
|
|
|
@@ -540,14 +544,15 @@ $(document).ready(() => {
|
|
|
continue;
|
|
|
}
|
|
|
let num = parseFloat(validText);
|
|
|
+ const reg = new RegExp("^\\d+(\\.\\d{1,"+ materialExponentDecimal.qty +"})?$");
|
|
|
if (validText !== null && (num < 0 || num >= 1)) {
|
|
|
toastMessageUniq(getPasteHint(hint.numberCan2, hintRow));
|
|
|
bPaste = false;
|
|
|
continue;
|
|
|
- } else if (validText !== null && num > 0 && num < 1 && !/^\d+(\.\d{1,3})?$/.test(num)) {
|
|
|
- toastMessageUniq(getPasteHint(hint.numberCan3, hintRow));
|
|
|
- validText = ZhCalc.round(num, 3);
|
|
|
- num = ZhCalc.round(num, 3);
|
|
|
+ } else if (validText !== null && num > 0 && num < 1 && !reg.test(num)) {
|
|
|
+ toastMessageUniq(getPasteHint(hint.numberCanQty, hintRow));
|
|
|
+ validText = ZhCalc.round(num, materialExponentDecimal.qty);
|
|
|
+ num = ZhCalc.round(num, materialExponentDecimal.qty);
|
|
|
}
|
|
|
const weight_datas = showStageExponent || exponent_nodes ? _.filter(materialExponentShardData, { ms_id: parseInt($('#myTab').find('.active').attr('data-msid')) || null, mn_id: parseInt($('#myTab2').find('.active').attr('data-mnid')) || null }) : materialExponentData;
|
|
|
const total_weight = ZhCalc.add(ZhCalc.sub(ZhCalc.sum(_.map(weight_datas, 'weight_num')), parseFloat(orgValue)), num);
|