|
@@ -176,7 +176,7 @@ $(document).ready(() => {
|
|
},
|
|
},
|
|
};
|
|
};
|
|
// 数字只判断几个值(unit_price, oamount, camount)
|
|
// 数字只判断几个值(unit_price, oamount, camount)
|
|
- const numField = ['unit_price', 'oamount', 'camount'];
|
|
|
|
|
|
+ const numField = ['unit_price', 'oamount'];
|
|
const changeSpreadObj = {
|
|
const changeSpreadObj = {
|
|
makeSjsFooter: function () {
|
|
makeSjsFooter: function () {
|
|
// 增加汇总行并设为锁定禁止编辑状态
|
|
// 增加汇总行并设为锁定禁止编辑状态
|
|
@@ -393,6 +393,15 @@ $(document).ready(() => {
|
|
}
|
|
}
|
|
SpreadJsObj.loadSheetData(xmjSpread.getActiveSheet(), SpreadJsObj.DataType.Data, xmj);
|
|
SpreadJsObj.loadSheetData(xmjSpread.getActiveSheet(), SpreadJsObj.DataType.Data, xmj);
|
|
},
|
|
},
|
|
|
|
+ editStarting: function (e, info) {
|
|
|
|
+ const col = info.sheet.zh_setting.cols[info.col];
|
|
|
|
+ const select = SpreadJsObj.getSelectObject(info.sheet);
|
|
|
|
+ if (col.field === 'camount') {
|
|
|
|
+ if (select.camount_expr && select.camount_expr !== '') {
|
|
|
|
+ info.sheet.getCell(info.row, info.col).text(select.camount_expr);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ },
|
|
selectionChanged: function (e, info) {
|
|
selectionChanged: function (e, info) {
|
|
const sel = info.sheet.getSelections()[0];
|
|
const sel = info.sheet.getSelections()[0];
|
|
const col = info.sheet.zh_setting.cols[sel.col];
|
|
const col = info.sheet.zh_setting.cols[sel.col];
|
|
@@ -400,6 +409,11 @@ $(document).ready(() => {
|
|
if (col && col.field === 'del_list' && data && !_.find(changeUsedData, { cbid: data.id })) {
|
|
if (col && col.field === 'del_list' && data && !_.find(changeUsedData, { cbid: data.id })) {
|
|
changeSpreadObj.del();
|
|
changeSpreadObj.del();
|
|
}
|
|
}
|
|
|
|
+ if (col && col.field === 'camount' && data) {
|
|
|
|
+ $('#camount-expr').removeAttr('readonly').val(data.camount_expr ? data.camount_expr : data.camount);
|
|
|
|
+ } else {
|
|
|
|
+ $('#camount-expr').attr('readonly', true).val('');
|
|
|
|
+ }
|
|
changeSpreadObj.resetXmjSpread(data);
|
|
changeSpreadObj.resetXmjSpread(data);
|
|
changeSpreadObj.refreshActn();
|
|
changeSpreadObj.refreshActn();
|
|
},
|
|
},
|
|
@@ -442,31 +456,44 @@ $(document).ready(() => {
|
|
if (col.field === 'del_list') {
|
|
if (col.field === 'del_list') {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- // 未改变值则不提交
|
|
|
|
let validText = is_numeric(info.editingText) && _.indexOf(numField, col.field) !== -1 ? parseFloat(info.editingText) : (info.editingText ? trimInvalidChar(info.editingText) : '');
|
|
let validText = is_numeric(info.editingText) && _.indexOf(numField, col.field) !== -1 ? parseFloat(info.editingText) : (info.editingText ? trimInvalidChar(info.editingText) : '');
|
|
- const orgValue = select[col.field];
|
|
|
|
- if (orgValue == validText || ((!orgValue || orgValue === '') && (validText === ''))) {
|
|
|
|
|
|
+ let orgValue;
|
|
|
|
+ if (col.field === 'camount') {
|
|
|
|
+ orgValue = validText && validText !== ''
|
|
|
|
+ ? (_.toNumber(validText) ? select.camount : select.camount_expr)
|
|
|
|
+ : (select.camount_expr && select.camount_expr !== '' ? select.camount_expr : select.camount);
|
|
|
|
+ } else {
|
|
|
|
+ orgValue = select[col.field];
|
|
|
|
+ }
|
|
|
|
+ if (orgValue == validText || ((!orgValue || orgValue === '') && (validText === '' || validText === null))) {
|
|
SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
+ // // 未改变值则不提交
|
|
|
|
+ // let validText = is_numeric(info.editingText) && _.indexOf(numField, col.field) !== -1 ? parseFloat(info.editingText) : (info.editingText ? trimInvalidChar(info.editingText) : '');
|
|
|
|
+ // const orgValue = select[col.field];
|
|
|
|
+ // if (orgValue == validText || ((!orgValue || orgValue === '') && (validText === ''))) {
|
|
|
|
+ // SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
|
+ // return;
|
|
|
|
+ // }
|
|
// 判断部分值是否输入的是数字判断和数据计算
|
|
// 判断部分值是否输入的是数字判断和数据计算
|
|
- if (col.type === 'Number') {
|
|
|
|
- if (isNaN(validText)) {
|
|
|
|
- toastr.error('不能输入其它非数字类型字符');
|
|
|
|
|
|
+ if(col.field === 'camount') {
|
|
|
|
+ const exprQuantity = {
|
|
|
|
+ expr: '',
|
|
|
|
+ quantity: 0,
|
|
|
|
+ };
|
|
|
|
+ const [valid, msg] = changeSpreadObj._checkExpr(validText, exprQuantity);
|
|
|
|
+ if (!valid) {
|
|
|
|
+ toastr.error(msg);
|
|
SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- if (col.field === 'unit_price') {
|
|
|
|
- validText = ZhCalc.round(validText, unitPriceUnit);
|
|
|
|
- } else {
|
|
|
|
- validText = ZhCalc.round(validText, findDecimal(select.unit)) || 0;
|
|
|
|
|
|
+ if (isNaN(exprQuantity.quantity)) {
|
|
|
|
+ toastr.error('不能输入其它非数字类型字符');
|
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
- }
|
|
|
|
- if (col.field === 'unit') {
|
|
|
|
- select.camount = ZhCalc.round(select.camount, findDecimal(validText)) || 0;
|
|
|
|
- select.oamount = ZhCalc.round(select.oamount, findDecimal(validText)) || 0;
|
|
|
|
- }
|
|
|
|
- if(col.field === 'camount') {
|
|
|
|
|
|
+ validText = parseFloat(exprQuantity.quantity);
|
|
// 判断是否 正数必须大于等于限制值,负数必须小于等于限制值,否则无法更改
|
|
// 判断是否 正数必须大于等于限制值,负数必须小于等于限制值,否则无法更改
|
|
const usedInfo = _.find(changeUsedData, { cbid: select.id });
|
|
const usedInfo = _.find(changeUsedData, { cbid: select.id });
|
|
if (usedInfo && usedInfo.qty >= 0 && validText < usedInfo.qty) {
|
|
if (usedInfo && usedInfo.qty >= 0 && validText < usedInfo.qty) {
|
|
@@ -479,6 +506,23 @@ $(document).ready(() => {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
select.spamount = ZhCalc.round(validText, findDecimal(select.unit)) || 0;
|
|
select.spamount = ZhCalc.round(validText, findDecimal(select.unit)) || 0;
|
|
|
|
+ select.camount_expr = exprQuantity.expr;
|
|
|
|
+ }
|
|
|
|
+ if (col.type === 'Number') {
|
|
|
|
+ if (isNaN(validText)) {
|
|
|
|
+ toastr.error('不能输入其它非数字类型字符');
|
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ if (col.field === 'unit_price') {
|
|
|
|
+ validText = ZhCalc.round(validText, unitPriceUnit);
|
|
|
|
+ } else {
|
|
|
|
+ validText = ZhCalc.round(validText, findDecimal(select.unit)) || 0;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (col.field === 'unit') {
|
|
|
|
+ select.camount = ZhCalc.round(select.camount, findDecimal(validText)) || 0;
|
|
|
|
+ select.oamount = ZhCalc.round(select.oamount, findDecimal(validText)) || 0;
|
|
}
|
|
}
|
|
select[col.field] = validText;
|
|
select[col.field] = validText;
|
|
// console.log(select);
|
|
// console.log(select);
|
|
@@ -543,7 +587,14 @@ $(document).ready(() => {
|
|
|
|
|
|
let validText = info.sheet.getText(curRow, curCol);
|
|
let validText = info.sheet.getText(curRow, curCol);
|
|
validText = is_numeric(validText) && _.indexOf(numField, colSetting.field) !== -1 ? parseFloat(validText) : (validText ? trimInvalidChar(validText) : '');
|
|
validText = is_numeric(validText) && _.indexOf(numField, colSetting.field) !== -1 ? parseFloat(validText) : (validText ? trimInvalidChar(validText) : '');
|
|
- const orgValue = sortData[curRow][colSetting.field];
|
|
|
|
|
|
+ let orgValue;
|
|
|
|
+ if (colSetting.field === 'camount') {
|
|
|
|
+ orgValue = validText && validText !== ''
|
|
|
|
+ ? (_.toNumber(validText) ? sortData[curRow].camount : sortData[curRow].camount_expr)
|
|
|
|
+ : (sortData[curRow].camount_expr && sortData[curRow].camount_expr !== '' ? sortData[curRow].camount_expr : sortData[curRow].camount);
|
|
|
|
+ } else {
|
|
|
|
+ orgValue = sortData[curRow][colSetting.field];
|
|
|
|
+ }
|
|
if (orgValue == validText || ((!orgValue || orgValue === '') && (validText === ''))) {
|
|
if (orgValue == validText || ((!orgValue || orgValue === '') && (validText === ''))) {
|
|
sameCol++;
|
|
sameCol++;
|
|
if (range.colCount === sameCol) {
|
|
if (range.colCount === sameCol) {
|
|
@@ -552,6 +603,37 @@ $(document).ready(() => {
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if(colSetting.field === 'camount') {
|
|
|
|
+ const exprQuantity = {
|
|
|
|
+ expr: '',
|
|
|
|
+ quantity: 0,
|
|
|
|
+ };
|
|
|
|
+ const [valid, msg] = changeSpreadObj._checkExpr(validText, exprQuantity);
|
|
|
|
+ if (!valid) {
|
|
|
|
+ toastMessageUniq(getPasteHint(msg, hintRow));
|
|
|
|
+ bPaste = false;
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ if (isNaN(exprQuantity.quantity)) {
|
|
|
|
+ toastMessageUniq(getPasteHint(hint.numberExpr, hintRow));
|
|
|
|
+ bPaste = false;
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ validText = parseFloat(exprQuantity.quantity);
|
|
|
|
+ // 判断是否 正数必须大于等于限制值,负数必须小于等于限制值,否则无法更改
|
|
|
|
+ const usedInfo = _.find(changeUsedData, { cbid: sortData[curRow].id });
|
|
|
|
+ if (usedInfo && usedInfo.qty >= 0 && validText < usedInfo.qty) {
|
|
|
|
+ toastr.error(hintRow ? '清单' + (hintRow+1) + '行变更数值必须大于等于已调用值 ' + usedInfo.qty : '清单变更数值必须大于等于已调用值 ' + usedInfo.qty);
|
|
|
|
+ bPaste = false;
|
|
|
|
+ continue;
|
|
|
|
+ } else if (usedInfo && usedInfo.qty < 0 && validText > usedInfo.qty) {
|
|
|
|
+ toastr.error(hintRow ? '清单' + (hintRow+1) + '行变更数值必须小于等于已调用值 ' + usedInfo.qty : '清单变更数值必须小于等于已调用值 ' + usedInfo.qty);
|
|
|
|
+ bPaste = false;
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ cLData.camount_expr = exprQuantity.expr;
|
|
|
|
+ sortData[curRow].camount_expr = exprQuantity.expr;
|
|
|
|
+ }
|
|
if (colSetting.type === 'Number') {
|
|
if (colSetting.type === 'Number') {
|
|
if (isNaN(validText)) {
|
|
if (isNaN(validText)) {
|
|
toastMessageUniq(getPasteHint(hint.numberExpr, hintRow));
|
|
toastMessageUniq(getPasteHint(hint.numberExpr, hintRow));
|
|
@@ -563,19 +645,6 @@ $(document).ready(() => {
|
|
} else {
|
|
} else {
|
|
validText = ZhCalc.round(validText, findDecimal(sortData[curRow].unit)) || 0;
|
|
validText = ZhCalc.round(validText, findDecimal(sortData[curRow].unit)) || 0;
|
|
}
|
|
}
|
|
- if(colSetting.field === 'camount') {
|
|
|
|
- // 判断是否 正数必须大于等于限制值,负数必须小于等于限制值,否则无法更改
|
|
|
|
- const usedInfo = _.find(changeUsedData, { cbid: sortData[curRow].id });
|
|
|
|
- if (usedInfo && usedInfo.qty >= 0 && validText < usedInfo.qty) {
|
|
|
|
- toastr.error(hintRow ? '清单' + (hintRow+1) + '行变更数值必须大于等于已调用值 ' + usedInfo.qty : '清单变更数值必须大于等于已调用值 ' + usedInfo.qty);
|
|
|
|
- bPaste = false;
|
|
|
|
- continue;
|
|
|
|
- } else if (usedInfo && usedInfo.qty < 0 && validText > usedInfo.qty) {
|
|
|
|
- toastr.error(hintRow ? '清单' + (hintRow+1) + '行变更数值必须小于等于已调用值 ' + usedInfo.qty : '清单变更数值必须小于等于已调用值 ' + usedInfo.qty);
|
|
|
|
- bPaste = false;
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
let unitdecimal = validText;
|
|
let unitdecimal = validText;
|
|
if (colSetting.field === 'unit') {
|
|
if (colSetting.field === 'unit') {
|
|
@@ -618,7 +687,132 @@ $(document).ready(() => {
|
|
valueChanged(e, info) {
|
|
valueChanged(e, info) {
|
|
// 防止ctrl+z撤销数据
|
|
// 防止ctrl+z撤销数据
|
|
SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
- }
|
|
|
|
|
|
+ },
|
|
|
|
+ _checkExprValid(expr) {
|
|
|
|
+ if (!expr) return [true, null];
|
|
|
|
+ const param = [];
|
|
|
|
+ let num = '', base = '';
|
|
|
|
+ for (let i = 0, iLen = expr.length; i < iLen; i++) {
|
|
|
|
+ if (/^[\d\.%]+/.test(expr[i])) {
|
|
|
|
+ if (base !== '') {
|
|
|
|
+ param.push({type: 'base', value: base});
|
|
|
|
+ base = '';
|
|
|
|
+ }
|
|
|
|
+ num = num + expr[i];
|
|
|
|
+ } else if (expr[i] === '(') {
|
|
|
|
+ if (num !== '') {
|
|
|
|
+ param.push({type: 'num', value: num});
|
|
|
|
+ num = '';
|
|
|
|
+ }
|
|
|
|
+ if (base !== '') {
|
|
|
|
+ param.push({type: 'base', value: base});
|
|
|
|
+ base = '';
|
|
|
|
+ }
|
|
|
|
+ param.push({type: 'left', value: '('});
|
|
|
|
+ } else if (expr[i] === ')') {
|
|
|
|
+ if (num !== '') {
|
|
|
|
+ param.push({type: 'num', value: num});
|
|
|
|
+ num = '';
|
|
|
|
+ }
|
|
|
|
+ if (base !== '') {
|
|
|
|
+ param.push({type: 'base', value: base});
|
|
|
|
+ base = '';
|
|
|
|
+ }
|
|
|
|
+ param.push({type: 'right', value: ')'});
|
|
|
|
+ } else if (/^[\+\-*\/]/.test(expr[i])) {
|
|
|
|
+ if (num !== '') {
|
|
|
|
+ param.push({type: 'num', value: num});
|
|
|
|
+ num = '';
|
|
|
|
+ }
|
|
|
|
+ if (base !== '') {
|
|
|
|
+ param.push({type: 'base', value: base});
|
|
|
|
+ base = '';
|
|
|
|
+ }
|
|
|
|
+ param.push({type: 'calc', value: expr[i]});
|
|
|
|
+ } else {
|
|
|
|
+ return [false, '输入的表达式含有非法字符: ' + expr[i]];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (num !== '') {
|
|
|
|
+ param.push({type: 'num', value: num});
|
|
|
|
+ num = '';
|
|
|
|
+ }
|
|
|
|
+ if (base !== '') {
|
|
|
|
+ param.push({type: 'base', value: base});
|
|
|
|
+ base = '';
|
|
|
|
+ }
|
|
|
|
+ if (param.length === 0) return true;
|
|
|
|
+ if (param.length > 1) {
|
|
|
|
+ if (param[0].value === '-') {
|
|
|
|
+ param[1].value = '-' + param[1];
|
|
|
|
+ }
|
|
|
|
+ param.unshift();
|
|
|
|
+ }
|
|
|
|
+ const iLen = param.length;
|
|
|
|
+ let iLeftCount = 0, iRightCount = 0;
|
|
|
|
+ for (const [i, p] of param.entries()) {
|
|
|
|
+ if (p.type === 'calc') {
|
|
|
|
+ if (i === 0 || i === iLen - 1)
|
|
|
|
+ return [false, '输入的表达式非法:计算符号' + p.value + '前后应有数字'];
|
|
|
|
+ }
|
|
|
|
+ if (p.type === 'num') {
|
|
|
|
+ num = p.value.replace('%', '');
|
|
|
|
+ if (p.value.length - num.length > 1)
|
|
|
|
+ return [false, '输入的表达式非法:' + p.value + '不是一个有效的数字'];
|
|
|
|
+ num = _.toNumber(num);
|
|
|
|
+ if (num === undefined || num === null || _.isNaN(num))
|
|
|
|
+ return [false, '输入的表达式非法:' + p.value + '不是一个有效的数字'];
|
|
|
|
+ if (i > 0) {
|
|
|
|
+ if (param[i - 1].type !== 'calc' && param[i - 1].type !== 'left') {
|
|
|
|
+ return [false, '输入的表达式非法:' + p.value + '前应有运算符'];
|
|
|
|
+ } else if (param[i - 1].value === '/' && num === 0) {
|
|
|
|
+ return [false, '输入的表达式非法:请勿除0'];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (p.type === 'base') {
|
|
|
|
+ if (i > 0 && (param[i - 1].type === 'num' || param[i - 1].type === 'right'))
|
|
|
|
+ return [false, '输入的表达式非法:' + p.value + '前应有运算符'];
|
|
|
|
+ }
|
|
|
|
+ if (p.type === 'left') {
|
|
|
|
+ iLeftCount += 1;
|
|
|
|
+ if (i !== 0 && param[i-1].type !== 'calc')
|
|
|
|
+ return [false, '输入的表达式非法:(前应有运算符'];
|
|
|
|
+ }
|
|
|
|
+ if (p.type === 'right') {
|
|
|
|
+ iRightCount += 1;
|
|
|
|
+ if (i !== iLen - 1 && param[i+1].type !== 'calc')
|
|
|
|
+ return [false, '输入的表达式非法:)后应有运算符'];
|
|
|
|
+ if (iRightCount > iLeftCount)
|
|
|
|
+ return [false, '输入的表达式非法:")"前无对应的"("'];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (iLeftCount > iRightCount)
|
|
|
|
+ return [false, '输入的表达式非法:"("后无对应的")"'];
|
|
|
|
+ return [true, ''];
|
|
|
|
+ },
|
|
|
|
+ _checkExpr: function (text, data) {
|
|
|
|
+ if (text) {
|
|
|
|
+ const num = _.toNumber(text);
|
|
|
|
+ if (num) {
|
|
|
|
+ data.quantity = num;
|
|
|
|
+ data.expr = '';
|
|
|
|
+ } else {
|
|
|
|
+ const expr = $.trim(text).replace('\t', '').replace('=', '').toLowerCase();
|
|
|
|
+ const [valid, msg] = this._checkExprValid(expr);
|
|
|
|
+ if (!valid) return [valid, msg];
|
|
|
|
+ data.expr = expr;
|
|
|
|
+ data.quantity = ZhCalc.calcExpr.calcExprStrRpn(expr);
|
|
|
|
+ // const ce = new CalcEvalMin();
|
|
|
|
+ // data.quantity = ce.eval(expr);
|
|
|
|
+ // console.log(data.quantity);
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ data.quantity = 0;
|
|
|
|
+ data.expr = '';
|
|
|
|
+ }
|
|
|
|
+ return [true, ''];
|
|
|
|
+ },
|
|
};
|
|
};
|
|
|
|
|
|
const preUrl = window.location.pathname.split('/').slice(0, 4).join('/');
|
|
const preUrl = window.location.pathname.split('/').slice(0, 4).join('/');
|
|
@@ -736,6 +930,7 @@ $(document).ready(() => {
|
|
$('#up-move').click(changeSpreadObj.upMove);
|
|
$('#up-move').click(changeSpreadObj.upMove);
|
|
$('#down-move').click(changeSpreadObj.downMove);
|
|
$('#down-move').click(changeSpreadObj.downMove);
|
|
changeSpread.bind(spreadNS.Events.EditEnded, changeSpreadObj.editEnded);
|
|
changeSpread.bind(spreadNS.Events.EditEnded, changeSpreadObj.editEnded);
|
|
|
|
+ changeSpread.bind(spreadNS.Events.EditStarting, changeSpreadObj.editStarting);
|
|
changeSpread.bind(spreadNS.Events.SelectionChanged, changeSpreadObj.selectionChanged);
|
|
changeSpread.bind(spreadNS.Events.SelectionChanged, changeSpreadObj.selectionChanged);
|
|
changeSpread.bind(spreadNS.Events.ClipboardPasted, changeSpreadObj.clipboardPasted);
|
|
changeSpread.bind(spreadNS.Events.ClipboardPasted, changeSpreadObj.clipboardPasted);
|
|
changeSpread.bind(spreadNS.Events.ValueChanged, changeSpreadObj.valueChanged);
|
|
changeSpread.bind(spreadNS.Events.ValueChanged, changeSpreadObj.valueChanged);
|
|
@@ -974,6 +1169,70 @@ $(document).ready(() => {
|
|
},
|
|
},
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
+
|
|
|
|
+ // 表达式判断
|
|
|
|
+ $('#camount-expr').change(function () {
|
|
|
|
+ if (this.readOnly) return;
|
|
|
|
+ let validText = $(this).val();
|
|
|
|
+ const sel = changeSpreadSheet.getSelections()[0];
|
|
|
|
+ const row = sel ? sel.row : -1;
|
|
|
|
+ const col = changeSpreadSheet.zh_setting.cols[sel.col];
|
|
|
|
+ if (row === -1 || !(col && col.field === 'camount')) return;
|
|
|
|
+ const select = SpreadJsObj.getSelectObject(changeSpreadSheet);
|
|
|
|
+ if (!select) return;
|
|
|
|
+ validText = is_numeric(validText) ? parseFloat(validText) : (validText ? trimInvalidChar(validText) : '');
|
|
|
|
+ let orgValue = validText && validText !== ''
|
|
|
|
+ ? (_.toNumber(validText) ? select.camount : select.camount_expr)
|
|
|
|
+ : (select.camount_expr && select.camount_expr !== '' ? select.camount_expr : select.camount);
|
|
|
|
+ const orgExprValue = _.clone(select.camount_expr);
|
|
|
|
+ if (orgValue == validText || ((!orgValue || orgValue === '') && (validText === '' || validText === null))) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ const exprQuantity = {
|
|
|
|
+ expr: '',
|
|
|
|
+ quantity: 0,
|
|
|
|
+ };
|
|
|
|
+ const [valid, msg] = changeSpreadObj._checkExpr(validText, exprQuantity);
|
|
|
|
+ if (!valid) {
|
|
|
|
+ toastr.error(msg);
|
|
|
|
+ $(this).val(select.camount_expr ? select.camount_expr : select.camount);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ if (isNaN(exprQuantity.quantity)) {
|
|
|
|
+ toastr.error('不能输入其它非数字类型字符');
|
|
|
|
+ $(this).val(select.camount_expr ? select.camount_expr : select.camount);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ validText = parseFloat(exprQuantity.quantity);
|
|
|
|
+ // 判断是否 正数必须大于等于限制值,负数必须小于等于限制值,否则无法更改
|
|
|
|
+ const usedInfo = _.find(changeUsedData, { cbid: select.id });
|
|
|
|
+ if (usedInfo && usedInfo.qty >= 0 && validText < usedInfo.qty) {
|
|
|
|
+ toastr.error('清单变更数值必须大于等于已调用值 ' + usedInfo.qty);
|
|
|
|
+ $(this).val(select.camount_expr ? select.camount_expr : select.camount);
|
|
|
|
+ return;
|
|
|
|
+ } else if (usedInfo && usedInfo.qty < 0 && validText > usedInfo.qty) {
|
|
|
|
+ toastr.error('清单变更数值必须小于等于已调用值 ' + usedInfo.qty);
|
|
|
|
+ $(this).val(select.camount_expr ? select.camount_expr : select.camount);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ select.spamount = ZhCalc.round(validText, findDecimal(select.unit)) || 0;
|
|
|
|
+ select.camount_expr = exprQuantity.expr;
|
|
|
|
+ select.camount = validText;
|
|
|
|
+ // console.log(select);
|
|
|
|
+ delete select.waitingLoading;
|
|
|
|
+
|
|
|
|
+ // 更新至服务器
|
|
|
|
+ postData(window.location.pathname + '/save', { type:'update', updateData: select }, function (result) {
|
|
|
|
+ changeList.splice(row, 1, select);
|
|
|
|
+ SpreadJsObj.reLoadRowData(changeSpreadSheet, row);
|
|
|
|
+ changeSpreadObj.countSum();
|
|
|
|
+ }, function () {
|
|
|
|
+ select.camount = orgValue;
|
|
|
|
+ select.camount_expr = orgExprValue;
|
|
|
|
+ select.spamount = orgValue;
|
|
|
|
+ SpreadJsObj.reLoadRowData(changeSpreadSheet, row);
|
|
|
|
+ });
|
|
|
|
+ });
|
|
}
|
|
}
|
|
|
|
|
|
// 清单选中和移除
|
|
// 清单选中和移除
|
|
@@ -986,7 +1245,7 @@ $(document).ready(() => {
|
|
const data_charu = $(this).attr('data-charu') ? $(this).attr('data-charu').split('$#$') : [];
|
|
const data_charu = $(this).attr('data-charu') ? $(this).attr('data-charu').split('$#$') : [];
|
|
const isDeal = $(this).data('gcl') !== undefined ? true : false;
|
|
const isDeal = $(this).data('gcl') !== undefined ? true : false;
|
|
let codeHtml = '<tr quantity="'+ $(this).children('td').eq(5).text() +'" gcl_id="" mx_id=""><td class="text-center">1</td><td colspan="7" class="colspan_1"> </td><td class="colspan_2 text-center"><input type="checkbox"></td></tr>';
|
|
let codeHtml = '<tr quantity="'+ $(this).children('td').eq(5).text() +'" gcl_id="" mx_id=""><td class="text-center">1</td><td colspan="7" class="colspan_1"> </td><td class="colspan_2 text-center"><input type="checkbox"></td></tr>';
|
|
- console.log(isDeal, isCheck);
|
|
|
|
|
|
+ // console.log(isDeal, isCheck);
|
|
if (isDeal) {
|
|
if (isDeal) {
|
|
const lid = $(this).data('lid');
|
|
const lid = $(this).data('lid');
|
|
let gcl = _.find(gclGatherData, function (item) {
|
|
let gcl = _.find(gclGatherData, function (item) {
|
|
@@ -1929,6 +2188,7 @@ function remakeChangeSpread(cOrder = changeOrder) {
|
|
unit_price: price,
|
|
unit_price: price,
|
|
oamount,
|
|
oamount,
|
|
camount: scnum,
|
|
camount: scnum,
|
|
|
|
+ camount_expr: '',
|
|
detail: '',
|
|
detail: '',
|
|
lid,
|
|
lid,
|
|
xmj_code,
|
|
xmj_code,
|
|
@@ -1945,6 +2205,7 @@ function remakeChangeSpread(cOrder = changeOrder) {
|
|
});
|
|
});
|
|
if (radionInfo) {
|
|
if (radionInfo) {
|
|
trlist.camount = radionInfo.camount;
|
|
trlist.camount = radionInfo.camount;
|
|
|
|
+ trlist.camount_expr = radionInfo.camount_expr;
|
|
trlist.detail = radionInfo.detail;
|
|
trlist.detail = radionInfo.detail;
|
|
}
|
|
}
|
|
newTableList.push(trlist);
|
|
newTableList.push(trlist);
|