|
@@ -1849,57 +1849,38 @@ $(document).ready(function() {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- const data = {};
|
|
|
- if (col.field === 'name') {
|
|
|
- if (newText === '' && posData) {
|
|
|
- toastr.error('计量单元名称不可为空');
|
|
|
- SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
- return;
|
|
|
- } else if (!posData) {
|
|
|
- if (newText && newText !== '') {
|
|
|
- data.updateType = 'add';
|
|
|
- const sortData = info.sheet.zh_data;
|
|
|
- const order = (!sortData || sortData.length === 0) ? 1 : Math.max(sortData[sortData.length - 1].porder + 1, sortData.length + 1);
|
|
|
- data.updateData = { name: newText, lid: node.id, tid: tender.id, porder: order};
|
|
|
- } else {
|
|
|
- return;
|
|
|
+ const data = { updateType: posData ? 'update' : 'add' };
|
|
|
+ if (!posData) {
|
|
|
+ const sortData = info.sheet.zh_data;
|
|
|
+ const order = (!sortData || sortData.length === 0) ? 1 : Math.max(sortData[sortData.length - 1].porder + 1, sortData.length + 1);
|
|
|
+ data.updateData = { lid: node.id, tid: tender.id, porder: order };
|
|
|
+ } else {
|
|
|
+ data.updateData = { id: posData.id };
|
|
|
+ }
|
|
|
+ if (col.type === 'Number') {
|
|
|
+ const exprInfo = getExprInfo(col.field);
|
|
|
+ const num = _.toNumber(newText);
|
|
|
+ if (_.isFinite(num)) {
|
|
|
+ data.updateData[col.field] = num;
|
|
|
+ if (exprInfo) {
|
|
|
+ data.updateData[exprInfo.expr] = '';
|
|
|
}
|
|
|
} else {
|
|
|
- data.updateType = 'update';
|
|
|
- data.updateData = {id: posData.id, name: newText};
|
|
|
- }
|
|
|
- } else if (!posData) {
|
|
|
- toastr.warning('新增计量单元请先输入名称');
|
|
|
- SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
- return;
|
|
|
- } else {
|
|
|
- data.updateType = 'update';
|
|
|
- data.updateData = {id: posData.id};
|
|
|
-
|
|
|
- if (col.type === 'Number') {
|
|
|
- const exprInfo = getExprInfo(col.field);
|
|
|
- const num = _.toNumber(newText);
|
|
|
- if (_.isFinite(num)) {
|
|
|
- data.updateData[col.field] = num;
|
|
|
+ try {
|
|
|
+ data.updateData[col.field] = math.evaluate(transExpr(newText));
|
|
|
if (exprInfo) {
|
|
|
- data.updateData[exprInfo.expr] = '';
|
|
|
- }
|
|
|
- } else {
|
|
|
- try {
|
|
|
- data.updateData[col.field] = math.evaluate(transExpr(newText));
|
|
|
- if (exprInfo) {
|
|
|
- data.updateData[exprInfo.expr] = newText;
|
|
|
- }
|
|
|
- } catch(err) {
|
|
|
- toastr.error('输入的表达式非法');
|
|
|
- SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
- return;
|
|
|
+ data.updateData[exprInfo.expr] = newText;
|
|
|
}
|
|
|
+ } catch(err) {
|
|
|
+ toastr.error('输入的表达式非法');
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
+ return;
|
|
|
}
|
|
|
- } else {
|
|
|
- data.updateData[col.field] = newText;
|
|
|
}
|
|
|
+ } else {
|
|
|
+ data.updateData[col.field] = newText;
|
|
|
}
|
|
|
+
|
|
|
postData('/tender/' + getTenderId() + '/pos/update', data, function (result) {
|
|
|
const updateRst = pos.updateDatas(result.pos);
|
|
|
// 刷新当前行, 不适用于新增(在非下一空白行新增)
|
|
@@ -1938,18 +1919,12 @@ $(document).ready(function() {
|
|
|
const data = {id: node.id};
|
|
|
for (let iCol = sel.col; iCol < sel.col + sel.colCount; iCol++) {
|
|
|
const colSetting = sheet.zh_setting.cols[iCol];
|
|
|
- if (colSetting.field === 'name') {
|
|
|
- toastr.error('部位名称不能为空');
|
|
|
- return;
|
|
|
- }
|
|
|
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) {
|
|
|
- data[exprInfo.expr] = '';
|
|
|
- }
|
|
|
+ if (exprInfo) data[exprInfo.expr] = '';
|
|
|
bDel = true;
|
|
|
}
|
|
|
}
|
|
@@ -1999,6 +1974,22 @@ $(document).ready(function() {
|
|
|
});
|
|
|
}
|
|
|
},
|
|
|
+ insertPos: function (sheet) {
|
|
|
+ const selection = sheet.getSelections();
|
|
|
+ const sortData = sheet.zh_data;
|
|
|
+ const row = selection[0].row;
|
|
|
+ const node = SpreadJsObj.getSelectObject(ledgerSpread.getActiveSheet());
|
|
|
+ const data = {
|
|
|
+ updateType: 'insert',
|
|
|
+ updateData: [ { lid: node.id, tid: tender.id, porder: Math.min(row + 1, sortData.length + 1) } ],
|
|
|
+ };
|
|
|
+ postData('/tender/' + getTenderId() + '/pos/update', data, function (result) {
|
|
|
+ const updateRst = pos.updateDatas(result.pos);
|
|
|
+ posOperationObj.loadCurPosData();
|
|
|
+ treeOperationObj.refreshOperationValid(ledgerSpread.getActiveSheet());
|
|
|
+ });
|
|
|
+
|
|
|
+ },
|
|
|
/**
|
|
|
* 粘贴单元格响应事件
|
|
|
* @param e
|
|
@@ -2021,7 +2012,6 @@ $(document).ready(function() {
|
|
|
}
|
|
|
|
|
|
const hint = {
|
|
|
- name: {type: 'warning', msg: '计量单元名称不可为空,已过滤'},
|
|
|
expr: {type: 'warning', msg: '粘贴了表达式非法,已过滤'},
|
|
|
};
|
|
|
if (info.sheet.zh_setting) {
|
|
@@ -2065,15 +2055,6 @@ $(document).ready(function() {
|
|
|
toastMessageUniq(hint.expr);
|
|
|
}
|
|
|
}
|
|
|
- } else if (colSetting.field === 'name') {
|
|
|
- if (!posData[colSetting.field]) {
|
|
|
- delete posData[colSetting.field];
|
|
|
- toastMessageUniq(hint.name);
|
|
|
- bPaste = false;
|
|
|
- break;
|
|
|
- } else {
|
|
|
- bPaste = true;
|
|
|
- }
|
|
|
} else {
|
|
|
bPaste = true;
|
|
|
}
|
|
@@ -2184,6 +2165,17 @@ $(document).ready(function() {
|
|
|
return target.hitTestType === GC.Spread.Sheets.SheetArea.viewport || target.hitTestType === GC.Spread.Sheets.SheetArea.rowHeader;
|
|
|
},
|
|
|
items: {
|
|
|
+ 'insert': {
|
|
|
+ name: '插入',
|
|
|
+ icon: 'fa-plus',
|
|
|
+ disabled: function (key, opt) {
|
|
|
+ const node = SpreadJsObj.getSelectObject(ledgerSpread.getActiveSheet());
|
|
|
+ return node && node.children && node.children.length > 0;
|
|
|
+ },
|
|
|
+ callback: function (key, opt) {
|
|
|
+ posOperationObj.insertPos(posSpread.getActiveSheet());
|
|
|
+ }
|
|
|
+ },
|
|
|
'delete': {
|
|
|
name: '删除',
|
|
|
icon: 'fa-remove',
|
|
@@ -2212,8 +2204,6 @@ $(document).ready(function() {
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
- } else {
|
|
|
- SpreadJsObj.forbiddenSpreadContextMenu('#pos-spread', posSpread);
|
|
|
}
|
|
|
|
|
|
postData(window.location.pathname + '/load', {}, function (data) {
|