|
@@ -293,13 +293,13 @@ $(document).ready(() => {
|
|
|
} else if (/^[a-z]/.test(expr[i])) {
|
|
|
if (num !== '') {
|
|
|
param.push({type: 'num', value: num});
|
|
|
- base = '';
|
|
|
+ num = '';
|
|
|
}
|
|
|
base = base + expr[i];
|
|
|
} else if (expr[i] === '(') {
|
|
|
if (num !== '') {
|
|
|
param.push({type: 'num', value: num});
|
|
|
- base = '';
|
|
|
+ num = '';
|
|
|
}
|
|
|
if (base !== '') {
|
|
|
param.push({type: 'base', value: base});
|
|
@@ -309,7 +309,7 @@ $(document).ready(() => {
|
|
|
} else if (expr[i] === ')') {
|
|
|
if (num !== '') {
|
|
|
param.push({type: 'num', value: num});
|
|
|
- base = '';
|
|
|
+ num = '';
|
|
|
}
|
|
|
if (base !== '') {
|
|
|
param.push({type: 'base', value: base});
|
|
@@ -319,7 +319,7 @@ $(document).ready(() => {
|
|
|
} else if (/^[\+\-*\/]/.test(expr[i])) {
|
|
|
if (num !== '') {
|
|
|
param.push({type: 'num', value: num});
|
|
|
- base = '';
|
|
|
+ num = '';
|
|
|
}
|
|
|
if (base !== '') {
|
|
|
param.push({type: 'base', value: base});
|
|
@@ -332,7 +332,7 @@ $(document).ready(() => {
|
|
|
}
|
|
|
if (num !== '') {
|
|
|
param.push({type: 'num', value: num});
|
|
|
- base = '';
|
|
|
+ num = '';
|
|
|
}
|
|
|
if (base !== '') {
|
|
|
param.push({type: 'base', value: base});
|
|
@@ -373,7 +373,7 @@ $(document).ready(() => {
|
|
|
return [false, '输入的表达式非法:不存在计算基数' + p.value];
|
|
|
if (invalidParam && invalidParam.indexOf(p.value) >= 0)
|
|
|
return [false, '不可使用计算基数' + p.value];
|
|
|
- if (i > 0 && param[i - 1].type === 'calc')
|
|
|
+ if (i > 0 && (param[i - 1].type === 'num' || param[i - 1].type === 'right'))
|
|
|
return [false, '输入的表达式非法:' + p.value + '前应有运算符'];
|
|
|
}
|
|
|
if (p.type === 'left') {
|
|
@@ -478,6 +478,24 @@ $(document).ready(() => {
|
|
|
setObjEnable($('#up-move'), !readOnly && select && !payBase.isSpecial(select) && dealPay.indexOf(select) > 3);
|
|
|
setObjEnable($('#down-move'), !readOnly && select && !payBase.isSpecial(select) && dealPay.indexOf(select) < dealPay.length - 1);
|
|
|
},
|
|
|
+ loadExprToInput: function () {
|
|
|
+ const sheet = paySpread.getActiveSheet();
|
|
|
+ const sel = sheet.getSelections()[0];
|
|
|
+ const col = sheet.zh_setting.cols[sel.col];
|
|
|
+ const data = SpreadJsObj.getSelectObject(sheet);
|
|
|
+ if (col.field === 'tp') {
|
|
|
+ $('#expr').val(data.expr).attr('field', 'expr').attr('org', data.expr)
|
|
|
+ .attr('readOnly', readOnly|| payBase.isSpecial(data));
|
|
|
+ } else if (col.field === 'sprice') {
|
|
|
+ $('#expr').val(data.sexpr).attr('field', 'sexpr').attr('org', data.sexpr)
|
|
|
+ .attr('readOnly', readOnly|| payCol.readOnly.sprice(data));
|
|
|
+ } else if (col.field === 'rprice') {
|
|
|
+ $('#expr').val(data.rexpr).attr('field', 'rexpr').attr('org', data.rexpr)
|
|
|
+ .attr('readOnly', readOnly|| payCol.readOnly.rprice(data));
|
|
|
+ } else {
|
|
|
+ $('#expr').val('').attr('readOnly', true);
|
|
|
+ }
|
|
|
+ },
|
|
|
add: function () {
|
|
|
const sheet = paySpread.getActiveSheet();
|
|
|
postData(window.location.pathname + '/save', {type: 'add'}, function (result) {
|
|
@@ -555,21 +573,7 @@ $(document).ready(() => {
|
|
|
},
|
|
|
selectionChanged: function (e, info) {
|
|
|
paySpreadObj.refreshActn();
|
|
|
- const sel = info.sheet.getSelections()[0];
|
|
|
- const col = info.sheet.zh_setting.cols[sel.col];
|
|
|
- const data = SpreadJsObj.getSelectObject(info.sheet);
|
|
|
- if (col.field === 'tp') {
|
|
|
- $('#expr').val(data.expr).attr('field', 'expr').attr('org', data.expr)
|
|
|
- .attr('readOnly', readOnly|| payBase.isSpecial(data));
|
|
|
- } else if (col.field === 'sprice') {
|
|
|
- $('#expr').val(data.sexpr).attr('field', 'sexpr').attr('org', data.sexpr)
|
|
|
- .attr('readOnly', readOnly|| payCol.readOnly.sprice(data));
|
|
|
- } else if (col.field === 'rprice') {
|
|
|
- $('#expr').val(data.rexpr).attr('field', 'rexpr').attr('org', data.rexpr)
|
|
|
- .attr('readOnly', readOnly|| payCol.readOnly.rprice(data));
|
|
|
- } else {
|
|
|
- $('#expr').val('').attr('readOnly', true);
|
|
|
- }
|
|
|
+ paySpreadObj.loadExprToInput();
|
|
|
},
|
|
|
editEnded: function (e, info) {
|
|
|
if (info.sheet.zh_setting) {
|
|
@@ -645,6 +649,7 @@ $(document).ready(() => {
|
|
|
postData(window.location.pathname + '/save', data, function (result) {
|
|
|
loadUpdateDealPays(result, col.field === 'name' ? ['name'] : null);
|
|
|
SpreadJsObj.reLoadSheetData(paySpread.getActiveSheet());
|
|
|
+ paySpreadObj.loadExprToInput();
|
|
|
}, function () {
|
|
|
SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
});
|
|
@@ -743,6 +748,7 @@ $(document).ready(() => {
|
|
|
postData(window.location.pathname + '/save', data, function (result) {
|
|
|
loadUpdateDealPays(result, col.field === 'name' ? ['name'] : null);
|
|
|
SpreadJsObj.reLoadSheetData(paySpread.getActiveSheet());
|
|
|
+ paySpreadObj.loadExprToInput();
|
|
|
})
|
|
|
}
|
|
|
}
|
|
@@ -811,6 +817,7 @@ $(document).ready(() => {
|
|
|
postData(window.location.pathname + '/save', data, function (result) {
|
|
|
loadUpdateDealPays(result, col.field === 'name' ? ['name'] : null);
|
|
|
SpreadJsObj.reLoadSheetData(paySpread.getActiveSheet());
|
|
|
+ paySpreadObj.loadExprToInput();
|
|
|
}, function () {
|
|
|
SpreadJsObj.reLoadSheetData(paySpread.getActiveSheet());
|
|
|
});
|
|
@@ -842,7 +849,13 @@ $(document).ready(() => {
|
|
|
const data = {};
|
|
|
if (field === 'expr') {
|
|
|
data.type = 'stage';
|
|
|
- data.updateData = { pid: select.pid, tp: null, expr: newValue }
|
|
|
+ data.updateData = { pid: select.pid, tp: null, expr: newValue };
|
|
|
+ const [valid, msg] = paySpreadObj._checkExpr(newValue, data.updateData);
|
|
|
+ if (!valid) {
|
|
|
+ toastr.warning(msg);
|
|
|
+ this.value = select.expr;
|
|
|
+ return;
|
|
|
+ }
|
|
|
} else if (field === 'sexpr') {
|
|
|
data.type = 'info';
|
|
|
data.updateData = {id: select.pid};
|
|
@@ -870,7 +883,10 @@ $(document).ready(() => {
|
|
|
loadUpdateDealPays(result);
|
|
|
SpreadJsObj.reLoadSheetData(paySpread.getActiveSheet());
|
|
|
});
|
|
|
- })
|
|
|
+ });
|
|
|
+ // $('#expr').bind('onpaste', function (e) {
|
|
|
+ // console.log(e);
|
|
|
+ // });
|
|
|
}
|
|
|
|
|
|
const deadlineObj = {
|
|
@@ -1180,3 +1196,12 @@ $(document).ready(() => {
|
|
|
});
|
|
|
})
|
|
|
});
|
|
|
+const pasteExpr = function (e, obj) {
|
|
|
+ let text = e.clipboardData.getData('text');
|
|
|
+ e.preventDefault();
|
|
|
+ text = trimInvalidChar(_.trim(text));
|
|
|
+ const start = obj.selectionStart, end = obj.selectionEnd;
|
|
|
+ obj.value = obj.value.substr(0, start) + text + obj.value.substring(end, obj.value.length);
|
|
|
+ obj.selectionStart = start + text.length;
|
|
|
+ obj.selectionEnd = start + text.length;
|
|
|
+};
|