|
@@ -1590,54 +1590,37 @@ $(document).ready(() => {
|
|
|
}
|
|
|
|
|
|
const data = {postType: 'pos'};
|
|
|
- if (col.field === 'name') {
|
|
|
- if (newText === '' && posData) {
|
|
|
- toastr.error('部位名称不可为空', 'error');
|
|
|
- SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
- return;
|
|
|
- } else if (!posData) {
|
|
|
- if (newText && newText !== '') {
|
|
|
- data.posPostType = '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.postData = { name: newText, lid: node.id, porder: order};
|
|
|
- } else {
|
|
|
- return;
|
|
|
- }
|
|
|
- } else {
|
|
|
- data.posPostType = 'update';
|
|
|
- data.postData = {id: posData.id, name: newText};
|
|
|
- }
|
|
|
- } else if (!posData) {
|
|
|
- toastr.warning('新增计量单元请先输入名称');
|
|
|
- SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
- return;
|
|
|
+ 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.posPostType = 'add';
|
|
|
+ data.postData = { lid: node.id, porder: order };
|
|
|
} else {
|
|
|
data.posPostType = 'update';
|
|
|
- data.postData = {id: posData.id};
|
|
|
- if (col.type === 'Number') {
|
|
|
- const exprInfo = getExprInfo(col.field);
|
|
|
- const num = _.toNumber(newText);
|
|
|
- if (_.isFinite(num)) {
|
|
|
- data.postData[col.field] = num;
|
|
|
+ data.postData = { id: posData.id };
|
|
|
+ }
|
|
|
+ if (col.type === 'Number') {
|
|
|
+ const exprInfo = getExprInfo(col.field);
|
|
|
+ const num = _.toNumber(newText);
|
|
|
+ if (_.isFinite(num)) {
|
|
|
+ data.postData[col.field] = num;
|
|
|
+ if (exprInfo) {
|
|
|
+ data.postData[exprInfo.expr] = '';
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ try {
|
|
|
+ data.postData[col.field] = math.evaluate(transExpr(newText));
|
|
|
if (exprInfo) {
|
|
|
- data.postData[exprInfo.expr] = '';
|
|
|
- }
|
|
|
- } else {
|
|
|
- try {
|
|
|
- data.postData[col.field] = math.evaluate(transExpr(newText));
|
|
|
- if (exprInfo) {
|
|
|
- data.postData[exprInfo.expr] = newText;
|
|
|
- }
|
|
|
- } catch(err) {
|
|
|
- toastr.error('输入的表达式非法');
|
|
|
- SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
- return;
|
|
|
+ data.postData[exprInfo.expr] = newText;
|
|
|
}
|
|
|
+ } catch(err) {
|
|
|
+ toastr.error('输入的表达式非法');
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
+ return;
|
|
|
}
|
|
|
- } else {
|
|
|
- data.postData[col.field] = newText;
|
|
|
}
|
|
|
+ } else {
|
|
|
+ data.postData[col.field] = newText;
|
|
|
}
|
|
|
postData(window.location.pathname + '/update', data, function (result) {
|
|
|
const updateRst = pos.updateDatas(result.pos);
|
|
@@ -1671,10 +1654,6 @@ $(document).ready(() => {
|
|
|
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];
|
|
@@ -1704,6 +1683,23 @@ $(document).ready(() => {
|
|
|
});
|
|
|
}
|
|
|
},
|
|
|
+ insertPos: function (sheet) {
|
|
|
+ const selection = sheet.getSelections();
|
|
|
+ const sortData = sheet.zh_data;
|
|
|
+ const row = selection[0].row;
|
|
|
+ const node = SpreadJsObj.getSelectObject(billsSheet);
|
|
|
+ const data = {
|
|
|
+ postType: 'pos',
|
|
|
+ posPostType: 'insert',
|
|
|
+ postData: [ { lid: node.id, porder: Math.min(row + 1, sortData.length + 1) } ],
|
|
|
+ };
|
|
|
+ postData(window.location.pathname + '/update', data, function (result) {
|
|
|
+ const updateRst = pos.updateDatas(result.pos);
|
|
|
+ posSpreadObj.loadCurPosData();
|
|
|
+ billsTreeSpreadObj.refreshOperationValid(billsSheet);
|
|
|
+ });
|
|
|
+
|
|
|
+ },
|
|
|
/**
|
|
|
* 删除 计量单元
|
|
|
* @param sheet
|
|
@@ -1765,15 +1761,7 @@ $(document).ready(() => {
|
|
|
|
|
|
const data = [];
|
|
|
const sortData = info.sheet.zh_data || [];
|
|
|
- if (sortData.length === 0 || info.cellRange.row + info.cellRange.rowCount > sortData.length) {
|
|
|
- if (info.cellRange.col !== 0) {
|
|
|
- toastr.warning('新增计量单元请先输入名称');
|
|
|
- posSpreadObj.loadCurPosData();
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
const hint = {
|
|
|
- name: {type: 'warning', msg: '计量单元名称不可为空,已过滤'},
|
|
|
expr: {type: 'warning', msg: '粘贴了表达式非法,已过滤'},
|
|
|
};
|
|
|
const lastOrder = sortData.length > 0 ? sortData[sortData.length - 1].porder + 1 : 1;
|
|
@@ -1803,11 +1791,6 @@ $(document).ready(() => {
|
|
|
bPaste = false;
|
|
|
}
|
|
|
}
|
|
|
- } else if (colSetting.field === 'name') {
|
|
|
- if (!posData[colSetting.field]) {
|
|
|
- toastMessageUniq(hint.name);
|
|
|
- bPaste = false;
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
if (bPaste) {
|
|
@@ -1911,6 +1894,17 @@ $(document).ready(() => {
|
|
|
return target.hitTestType === spreadNS.SheetArea.viewport || target.hitTestType === spreadNS.SheetArea.rowHeader;
|
|
|
},
|
|
|
items: {
|
|
|
+ 'insert': {
|
|
|
+ name: '插入',
|
|
|
+ icon: 'fa-plus',
|
|
|
+ disabled: function (key, opt) {
|
|
|
+ const node = SpreadJsObj.getSelectObject(billsSheet);
|
|
|
+ return node && node.children && node.children.length > 0;
|
|
|
+ },
|
|
|
+ callback: function (key, opt) {
|
|
|
+ posSpreadObj.insertPos(posSheet);
|
|
|
+ }
|
|
|
+ },
|
|
|
'delete': {
|
|
|
name: '删除',
|
|
|
icon: 'fa-remove',
|