|
@@ -16,13 +16,13 @@ const invalidFields = {
|
|
|
posCalc: ['sgfh_qty', 'sgfh_tp', 'sjcl_qty', 'sjcl_tp', 'qtcl_qty', 'qtcl_tp'],
|
|
|
posXmj: ['code'],
|
|
|
};
|
|
|
-function getExprInfo (field) {
|
|
|
+function getExprInfo (field, converse = false) {
|
|
|
const exprField = [
|
|
|
{qty: 'sgfh_qty', expr: 'sgfh_expr'},
|
|
|
{qty: 'sjcl_qty', expr: 'sjcl_expr'},
|
|
|
{qty: 'qtcl_qty', expr: 'qtcl_expr'},
|
|
|
];
|
|
|
- return _.find(exprField, {qty: field});
|
|
|
+ return converse ? _.find(exprField, {expr: field}) : _.find(exprField, {qty: field});
|
|
|
}
|
|
|
function transExpr(expr) {
|
|
|
return $.trim(expr).replace('\t', '').replace('=', '').replace('%', '/100');
|
|
@@ -1938,6 +1938,23 @@ $(document).ready(() => {
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
+ } else if (col.field.indexOf('_expr') > 0) {
|
|
|
+ const exprInfo = getExprInfo(col.field, true);
|
|
|
+ if (!exprInfo) return;
|
|
|
+
|
|
|
+ if (newText) {
|
|
|
+ try {
|
|
|
+ data.postData[exprInfo.qty] = math.evaluate(transExpr(newText));
|
|
|
+ data.postData[exprInfo.expr] = newText;
|
|
|
+ } catch(err) {
|
|
|
+ toastr.error('输入的表达式非法');
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ data.postData[exprInfo.qty] = 0;
|
|
|
+ data.postData[exprInfo.expr] = '';
|
|
|
+ }
|
|
|
} else {
|
|
|
data.postData[col.field] = newText;
|
|
|
}
|
|
@@ -1981,10 +1998,15 @@ $(document).ready(() => {
|
|
|
const style = sheet.getStyle(iRow, iCol);
|
|
|
if (!style.locked) {
|
|
|
const colSetting = sheet.zh_setting.cols[iCol];
|
|
|
- data[colSetting.field] = null;
|
|
|
- const exprInfo = getExprInfo(colSetting.field);
|
|
|
- if (exprInfo) {
|
|
|
+ if (colSetting.field.indexOf('_expr') > 0) {
|
|
|
+ const exprInfo = getExprInfo(colSetting.field, true);
|
|
|
+ if (!exprInfo) continue;
|
|
|
data[exprInfo.expr] = '';
|
|
|
+ data[exprInfo.qty] = 0;
|
|
|
+ } else {
|
|
|
+ data[colSetting.field] = null;
|
|
|
+ const exprInfo = getExprInfo(colSetting.field);
|
|
|
+ if (exprInfo) data[exprInfo.expr] = '';
|
|
|
}
|
|
|
bDel = true;
|
|
|
}
|
|
@@ -2124,6 +2146,19 @@ $(document).ready(() => {
|
|
|
bPaste = false;
|
|
|
}
|
|
|
}
|
|
|
+ } else if (colSetting.field.indexOf('_expr') > 0) {
|
|
|
+ try {
|
|
|
+ const exprInfo = getExprInfo(colSetting.field, true);
|
|
|
+ posData[exprInfo.expr] = trimInvalidChar(info.sheet.getText(curRow, curCol));
|
|
|
+ if (posData[exprInfo.expr] || !posData[exprInfo.qty]) {
|
|
|
+ posData[exprInfo.qty] = math.evaluate(transExpr(posData[exprInfo.expr]));
|
|
|
+ }
|
|
|
+ bPaste = true;
|
|
|
+ } catch (err) {
|
|
|
+ toastMessageUniq(hint.expr);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ bPaste = true;
|
|
|
}
|
|
|
}
|
|
|
if (bPaste) {
|