|
|
@@ -131,6 +131,321 @@ $(document).ready(function() {
|
|
|
const ancGclSpread = SpreadJsObj.createNewSpread($('#anc-gcl-spread')[0]);
|
|
|
const ancGclSheet = ancGclSpread.getActiveSheet();
|
|
|
|
|
|
+ // 设计量明细相关
|
|
|
+ const posCalcDetail = (function() {
|
|
|
+ const detail = createPosCalcDetail({ id: 'id', masterId: 'pid', topId: 'lid', sort: [['pcd_order', 'asc']]});
|
|
|
+ const spread = SpreadJsObj.createNewSpread($('#pos-detail-spread')[0]);
|
|
|
+ const sheet = spread.getActiveSheet();
|
|
|
+ const emptySetting = {
|
|
|
+ cols: [],
|
|
|
+ emptyRows: 3,
|
|
|
+ headRows: 1,
|
|
|
+ headRowHeight: [32],
|
|
|
+ defaultRowHeight: 21,
|
|
|
+ headerFont: '12px 微软雅黑',
|
|
|
+ font: '12px 微软雅黑',
|
|
|
+ frozenLineColor: '#93b5e4',
|
|
|
+ };
|
|
|
+ const refresh = function() {
|
|
|
+ if (spread) spread.refresh();
|
|
|
+ };
|
|
|
+ let template;
|
|
|
+ const reloadCurDetailData = function() {
|
|
|
+ const curPos = SpreadJsObj.getSelectObject(posSheet);
|
|
|
+ const detailData = curPos ? detail.getPartData(curPos.id) || [] : [];
|
|
|
+ SpreadJsObj.loadSheetData(sheet, SpreadJsObj.DataType.Data, detailData);
|
|
|
+ };
|
|
|
+ const loadCurDetailData = function() {
|
|
|
+ const node = treeOperationObj.getSelectNode(ledgerSheet);
|
|
|
+ template = posCalcTemplate.find(x => { return x.id === node.calc_template });
|
|
|
+ SpreadJsObj.initSheet(sheet, template ? template.spread_cache : emptySetting);
|
|
|
+ reloadCurDetailData();
|
|
|
+ };
|
|
|
+ const ctrlObj = {
|
|
|
+ afterPostData: function(result) {
|
|
|
+ detail.updateDatas(result.detail);
|
|
|
+ reloadCurDetailData();
|
|
|
+ const updateRst = pos.updateDatas(result.pos);
|
|
|
+ billsTag.refreshPosTagView(updateRst.update);
|
|
|
+ const loadResult = ledgerTree.loadPostData({ update: result.bills });
|
|
|
+ treeOperationObj.refreshTree(ledgerSpread.getActiveSheet(), loadResult);
|
|
|
+ posOperationObj.loadCurPosData();
|
|
|
+ treeOperationObj.refreshOperationValid(ledgerSpread.getActiveSheet());
|
|
|
+ },
|
|
|
+ baseOpr: function (type) {
|
|
|
+ const data = {};
|
|
|
+
|
|
|
+ const detailRange = sheet.zh_data;
|
|
|
+ if (type !== 'insert' && (!detailRange || detailRange.length === 0)) return;
|
|
|
+
|
|
|
+ const sel = sheet.getSelections();
|
|
|
+ if (!sel[0]) return;
|
|
|
+
|
|
|
+ const row = sel[0].row, count = sel[0].rowCount;
|
|
|
+ const first = detailRange[row];
|
|
|
+ if (type === 'insert') {
|
|
|
+ const node = SpreadJsObj.getSelectObject(ledgerSheet);
|
|
|
+ data.add = [{ lid: node.id, pcd_order: detailRange.length + 1 }];
|
|
|
+ } else if (type === 'delete') {
|
|
|
+ data.del = [];
|
|
|
+ for (let iRow = 0; iRow < count; iRow++) {
|
|
|
+ const detailData = detailRange[row + iRow];
|
|
|
+ if (!detailData) continue;
|
|
|
+ data.del.push(detailData.id);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (data.del.length === 0) return;
|
|
|
+ } else if (type === 'up-move') {
|
|
|
+ data.update = [];
|
|
|
+ const pre = detailRange[row - 1];
|
|
|
+ if (!pre) return;
|
|
|
+
|
|
|
+ const preUpdate = { id: pre.id };
|
|
|
+ for (let iRow = 0; iRow < count; iRow++) {
|
|
|
+ const detailData = detailRange[iRow + row];
|
|
|
+ if (!detailData) continue;
|
|
|
+ data.update.push({ id: detailData.id, pcd_order: detailRange[iRow + row - 1].pcd_order });
|
|
|
+ preUpdate.pcd_order = detailData.pcd_order;
|
|
|
+ }
|
|
|
+ data.update.push(preUpdate);
|
|
|
+
|
|
|
+ if (data.update <= 1) return;
|
|
|
+ } else if (type === 'down-move') {
|
|
|
+ data.update = [];
|
|
|
+ const next = detailRange[row + count];
|
|
|
+ if (!next) return;
|
|
|
+
|
|
|
+ const nextUpdate = { id: next.id };
|
|
|
+ for (let iRow = count - 1; iRow >= 0; iRow--) {
|
|
|
+ const detailData = detailRange[iRow + row];
|
|
|
+ if (!detailData) continue;
|
|
|
+
|
|
|
+ data.update.push({ id: detailData.id, pcd_order: detailRange[iRow + row + 1].g_order});
|
|
|
+ nextUpdate.g_order = detailData.g_order;
|
|
|
+ }
|
|
|
+ data.update.push(nextUpdate);
|
|
|
+
|
|
|
+ if (data.update <= 1) return;
|
|
|
+ }
|
|
|
+
|
|
|
+ postData('/tender/' + getTenderId() + '/pos-calc/update', data, function(result) {
|
|
|
+ ctrlObj.afterPostData(result);
|
|
|
+ if (type !== 'delete') SpreadJsObj.locateData(sheet, first);
|
|
|
+ });
|
|
|
+ },
|
|
|
+ editStarting: function (e, info) {
|
|
|
+ ctrlObj.ledgerTreeNode = SpreadJsObj.getSelectObject(ledgerSheet);
|
|
|
+ ctrlObj.posNode = SpreadJsObj.getSelectObject(posSheet);
|
|
|
+ },
|
|
|
+ editEnded: function (e, info) {
|
|
|
+ const setting = info.sheet.zh_setting;
|
|
|
+ if (!setting) return;
|
|
|
+ const detailData = SpreadJsObj.getSelectObject(info.sheet);
|
|
|
+
|
|
|
+ const col = setting.cols[info.col];
|
|
|
+ const orgText = detailData ? detailData[col.field] : '', newText = trimInvalidChar(info.editingText);
|
|
|
+ if (orgText === newText || (!orgText && !newText)) return;
|
|
|
+
|
|
|
+ const pos = ctrlObj.posNode;
|
|
|
+ if (!pos) {
|
|
|
+ toastr.error('数据错误,请选择计量单元后再试');
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ const data = {};
|
|
|
+ if (detailData) {
|
|
|
+ const updateData = { id: detailData.id };
|
|
|
+ if (col.type === 'Number') {
|
|
|
+ const num = _.toNumber(newText);
|
|
|
+ if (!_.isFinite(num)) {
|
|
|
+ toastr.error('输入的数字非法');
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ updateData[col.field] = num;
|
|
|
+ } else {
|
|
|
+ updateData[col.field] = newText;
|
|
|
+ }
|
|
|
+ data.update = [ updateData ];
|
|
|
+ } else {
|
|
|
+ const sortData = info.sheet.zh_data;
|
|
|
+ const order = (!sortData || sortData.length === 0) ? 1 : Math.max(sortData[sortData.length - 1].pcd_order + 1, sortData.length + 1);
|
|
|
+ const addData = { lid: pos.lid, pid: pos.id, pcd_order: order };
|
|
|
+ if (col.type === 'Number') {
|
|
|
+ const num = _.toNumber(newText);
|
|
|
+ if (!_.isFinite(num)) {
|
|
|
+ toastr.error('输入的数字非法');
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ addData[col.field] = num;
|
|
|
+ } else {
|
|
|
+ addData[col.field] = newText;
|
|
|
+ }
|
|
|
+ data.add = [addData];
|
|
|
+ }
|
|
|
+ postData('/tender/' + getTenderId() + '/pos-calc/update', data, function (result) {
|
|
|
+ ctrlObj.afterPostData(result);
|
|
|
+ }, function () {
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
+ });
|
|
|
+ },
|
|
|
+ deletePress: function (sheet) {
|
|
|
+ const setting = sheet.zh_setting;
|
|
|
+ if (!setting) return;
|
|
|
+
|
|
|
+ const sortData = sheet.zh_data;
|
|
|
+ if (!sortData || sortData.length === 0) return;
|
|
|
+
|
|
|
+ const sel = sheet.getSelections()[0];
|
|
|
+ const data = { update: [] };
|
|
|
+ for (let iRow = sel.row; iRow < sel.row + sel.rowCount; iRow++) {
|
|
|
+ let bDel = false;
|
|
|
+ const node = sortData[iRow];
|
|
|
+ if (!node) continue;
|
|
|
+
|
|
|
+ const updateData = { id: node.id };
|
|
|
+ for (let iCol = sel.col; iCol < sel.col + sel.colCount; iCol++) {
|
|
|
+ const style = sheet.getStyle(iRow, iCol);
|
|
|
+ if (style.locked) continue;
|
|
|
+
|
|
|
+ const col = setting.cols[iCol];
|
|
|
+ updateData[col.field] = col.type === 'Number' ? 0 : '';
|
|
|
+ bDel = true;
|
|
|
+ }
|
|
|
+ if (bDel) data.update.push(updateData);
|
|
|
+ }
|
|
|
+ if (data.update.length === 0) return;
|
|
|
+
|
|
|
+ postData('/tender/' + getTenderId() + '/pos-calc/update', data, function (result) {
|
|
|
+ ctrlObj.afterPostData(result);
|
|
|
+ }, function () {
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
+ });
|
|
|
+ },
|
|
|
+ clipboardPasting: function(e, info) {
|
|
|
+ info.cancel = true;
|
|
|
+ const relaPos = ctrlObj.posNode;
|
|
|
+ if (!relaPos) {
|
|
|
+ toastr.error('数据错误,请选择计量单元后再试');
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ const hint = {
|
|
|
+ num: {type: 'warning', msg: '输入的 数字 非法,已过滤'},
|
|
|
+ };
|
|
|
+ const setting = info.sheet.zh_setting;
|
|
|
+ const sortData = info.sheet.zh_data || [];
|
|
|
+ const pasteData = SpreadJsObj.analysisPasteText(info.pasteData.text);
|
|
|
+ const data = {};
|
|
|
+ const analysisData = function(pasteRow, targetData) {
|
|
|
+ pasteRow.forEach((value, iCol) => {
|
|
|
+ const col = setting.cols[info.cellRange.col + iCol];
|
|
|
+ if (col.type === 'Number') {
|
|
|
+ const num = _.toNumber(value);
|
|
|
+ if (!_.isFinite(num)) {
|
|
|
+ toastMessageUniq(hint.num);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ targetData[col.field] = num;
|
|
|
+ } else {
|
|
|
+ targetData[col.field] = value;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ };
|
|
|
+ for (let iRow = 0; iRow < pasteData.length; iRow++) {
|
|
|
+ const curRow = iRow + info.cellRange.row;
|
|
|
+ const detailData = sortData[curRow];
|
|
|
+ if (detailData) {
|
|
|
+ if (!data.update) data.update = [];
|
|
|
+ const updateData = { id: detailData.id };
|
|
|
+ analysisData(pasteData[iRow], updateData);
|
|
|
+ data.update.push(updateData);
|
|
|
+ } else {
|
|
|
+ if (!data.add) data.add = [];
|
|
|
+ const addData = { lid: relaPos.lid, pid: relaPos.id, g_order: curRow + 1};
|
|
|
+ analysisData(pasteData[iRow], addData);
|
|
|
+ data.add.push(addData);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ((!data.update || data.update.length === 0) && (!data.add || data.add.length === 0)) return;
|
|
|
+
|
|
|
+ postData('/tender/' + getTenderId() + '/pos-calc/update', data, function (result) {
|
|
|
+ ctrlObj.afterPostData(result);
|
|
|
+ }, function () {
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
+ });
|
|
|
+ },
|
|
|
+ };
|
|
|
+ SpreadJsObj.addDeleteBind(spread, ctrlObj.deletePress);
|
|
|
+ spread.bind(spreadNS.Events.EditStarting, ctrlObj.editStarting);
|
|
|
+ spread.bind(spreadNS.Events.EditEnded, ctrlObj.editEnded);
|
|
|
+ spread.bind(spreadNS.Events.ClipboardPasting, ctrlObj.clipboardPasting);
|
|
|
+ $.contextMenu({
|
|
|
+ selector: '#pos-detail-spread',
|
|
|
+ build: function ($trigger, e) {
|
|
|
+ const target = SpreadJsObj.safeRightClickSelection($trigger, e, spread);
|
|
|
+ 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 pos = SpreadJsObj.getSelectObject(posSheet);
|
|
|
+ return !pos;
|
|
|
+ },
|
|
|
+ callback: function (key, opt) {
|
|
|
+ ctrlObj.baseOpr('insert');
|
|
|
+ }
|
|
|
+ },
|
|
|
+ 'delete': {
|
|
|
+ name: '删除',
|
|
|
+ icon: 'fa-remove',
|
|
|
+ disabled: function (key, opt) {
|
|
|
+ const detailData = SpreadJsObj.getSelectObject(sheet);
|
|
|
+ return !detailData;
|
|
|
+ },
|
|
|
+ callback: function (key, opt) {
|
|
|
+ ctrlObj.baseOpr('delete');
|
|
|
+ }
|
|
|
+ },
|
|
|
+ 'down-move': {
|
|
|
+ name: '下移',
|
|
|
+ icon: 'fa-arrow-down',
|
|
|
+ disabled: function(key, opt) {
|
|
|
+ const sel = sheet.getSelections()[0];
|
|
|
+ const row = sel ? sel.row : -1;
|
|
|
+ const first = sheet.zh_data[row];
|
|
|
+ const next = sheet.zh_data[sel.row + sel.rowCount];
|
|
|
+ return !first || !next;
|
|
|
+ },
|
|
|
+ callback: function(key, opt) {
|
|
|
+ ctrlObj.baseOpr('down-move');
|
|
|
+ }
|
|
|
+ },
|
|
|
+ 'up-move': {
|
|
|
+ name: '上移',
|
|
|
+ icon: 'fa-arrow-up',
|
|
|
+ disabled: function(key, opt) {
|
|
|
+ const sel = sheet.getSelections()[0];
|
|
|
+ const row = sel ? sel.row : -1;
|
|
|
+ const first = sheet.zh_data[row];
|
|
|
+ const preNode = sheet.zh_data[row - 1];
|
|
|
+ return !first || !preNode;
|
|
|
+ },
|
|
|
+ callback: function(key, opt) {
|
|
|
+ ctrlObj.baseOpr('up-move');
|
|
|
+ }
|
|
|
+ },
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ return { detail, spread, sheet, refresh, loadCurDetailData }
|
|
|
+ })();
|
|
|
+
|
|
|
const billsTag = $.billsTag({
|
|
|
relaTree: ledgerTree,
|
|
|
selector: '#bills-tag',
|
|
|
@@ -153,6 +468,7 @@ $(document).ready(function() {
|
|
|
ledgerSpread.refresh();
|
|
|
if (posSpread) posSpread.refresh();
|
|
|
if (ancGclSpread) ancGclSpread.refresh();
|
|
|
+ if (posCalcDetail) posCalcDetail.refresh();
|
|
|
},
|
|
|
});
|
|
|
const errorList = $.cs_errorList({
|
|
|
@@ -168,6 +484,7 @@ $(document).ready(function() {
|
|
|
ledgerSpread.refresh();
|
|
|
if (posSpread) posSpread.refresh();
|
|
|
if (ancGclSpread) ancGclSpread.refresh();
|
|
|
+ if (posCalcDetail) posCalcDetail.refresh();
|
|
|
},
|
|
|
});
|
|
|
const checkList = $.ledger_checkList({
|
|
|
@@ -185,6 +502,7 @@ $(document).ready(function() {
|
|
|
ledgerSpread.refresh();
|
|
|
if (posSpread) posSpread.refresh();
|
|
|
if (ancGclSpread) ancGclSpread.refresh();
|
|
|
+ if (posCalcDetail) posCalcDetail.refresh();
|
|
|
},
|
|
|
});
|
|
|
|
|
|
@@ -211,6 +529,7 @@ $(document).ready(function() {
|
|
|
ledgerSpread.refresh();
|
|
|
if (posSpread) posSpread.refresh();
|
|
|
if (ancGclSpread) ancGclSpread.refresh();
|
|
|
+ if (posCalcDetail) posCalcDetail.refresh();
|
|
|
if (stdXmj) stdXmj.spread.refresh();
|
|
|
if (stdGcl) stdGcl.spread.refresh();
|
|
|
if (dealBills) dealBills.spread.refresh();
|
|
|
@@ -569,88 +888,91 @@ $(document).ready(function() {
|
|
|
* @param {Object} info
|
|
|
*/
|
|
|
editEnded: function (e, info) {
|
|
|
- if (info.sheet.zh_setting) {
|
|
|
- const col = info.sheet.zh_setting.cols[info.col];
|
|
|
- const sortData = info.sheet.zh_dataType === 'tree' ? info.sheet.zh_tree.nodes : info.sheet.zh_data;
|
|
|
- const node = sortData[info.row];
|
|
|
- const data = {
|
|
|
+ if (!info.sheet.zh_setting) return;
|
|
|
+
|
|
|
+ const col = info.sheet.zh_setting.cols[info.col];
|
|
|
+ const sortData = info.sheet.zh_dataType === 'tree' ? info.sheet.zh_tree.nodes : info.sheet.zh_data;
|
|
|
+ const node = sortData[info.row];
|
|
|
+ const updateData = {postType: 'update', postData: {
|
|
|
id: node.id,
|
|
|
tender_id: node.tender_id,
|
|
|
ledger_id: node.ledger_id
|
|
|
- };
|
|
|
- // 未改变值则不提交
|
|
|
- const orgValue = node[col.field];
|
|
|
- if (info.editingText === null) info.editingText = '';
|
|
|
- const newValue = col.wordWrap ? info.editingText : trimInvalidChar(info.editingText);
|
|
|
- if (orgValue == info.editingText || ((!orgValue || orgValue === '') && (newValue === ''))) {
|
|
|
- return;
|
|
|
- }
|
|
|
- // 台账模式,检查计量单元相关
|
|
|
- if (checkTzMeasureType()) {
|
|
|
- if (col.field === 'sgfh_qty' || col.field === 'sgfh_tp' ||
|
|
|
- col.field === 'sjcl_qty' || col.field === 'sjcl_tp' ||
|
|
|
- col.field === 'qtcl_qty' || col.field === 'qtcl_tp' ||
|
|
|
- col.field === 'ex_qty1' || col.field === 'ex_tp1') {
|
|
|
- if (!node.children || node.children.length ===0) {
|
|
|
- const lPos = pos.getLedgerPos(node.id);
|
|
|
- if (lPos && lPos.length > 0) {
|
|
|
- toastr.error('清单含有计量单元,请在计量单元输入数量');
|
|
|
- SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if (col.field === 'b_code' && (info.editingText === '' || !info.editingText)) {
|
|
|
+ }};
|
|
|
+ // 未改变值则不提交
|
|
|
+ const orgValue = node[col.field];
|
|
|
+ if (info.editingText === null) info.editingText = '';
|
|
|
+ const newValue = col.wordWrap ? info.editingText : trimInvalidChar(info.editingText);
|
|
|
+ if (orgValue == info.editingText || ((!orgValue || orgValue === '') && (newValue === ''))) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 台账模式,检查计量单元相关
|
|
|
+ if (checkTzMeasureType()) {
|
|
|
+ if (col.field === 'sgfh_qty' || col.field === 'sgfh_tp' ||
|
|
|
+ col.field === 'sjcl_qty' || col.field === 'sjcl_tp' ||
|
|
|
+ col.field === 'qtcl_qty' || col.field === 'qtcl_tp' ||
|
|
|
+ col.field === 'ex_qty1' || col.field === 'ex_tp1') {
|
|
|
+ if (!node.children || node.children.length ===0) {
|
|
|
const lPos = pos.getLedgerPos(node.id);
|
|
|
if (lPos && lPos.length > 0) {
|
|
|
- toastr.error('清单含有计量单元,请先删除计量单元,再删除清单编号');
|
|
|
+ toastr.error('清单含有计量单元,请在计量单元输入数量');
|
|
|
SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if (col.field === 'node_type' && newValue && newValue !== '0' && newValue !== '19') {
|
|
|
- const sameNodeType = sortData.find(x => { return x.node_type == newValue; });
|
|
|
- if (sameNodeType) {
|
|
|
- toastr.error('已存在该费用类别,请勿重复选择');
|
|
|
+ if (col.field === 'b_code' && (info.editingText === '' || !info.editingText)) {
|
|
|
+ const lPos = pos.getLedgerPos(node.id);
|
|
|
+ if (lPos && lPos.length > 0) {
|
|
|
+ toastr.error('清单含有计量单元,请先删除计量单元,再删除清单编号');
|
|
|
SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
- // 获取更新数据
|
|
|
- if (col.type === 'Number') {
|
|
|
- const exprInfo = getExprInfo(col.field);
|
|
|
- if (newValue) {
|
|
|
- const num = _.toNumber(newValue);
|
|
|
- if (_.isFinite(num)) {
|
|
|
- data[col.field] = num;
|
|
|
- } else {
|
|
|
- try {
|
|
|
- data[col.field] = ZhCalc.mathCalcExpr(transExpr(newValue));
|
|
|
- if (exprInfo) {
|
|
|
- data[exprInfo.expr] = newValue;
|
|
|
- }
|
|
|
- } catch(err) {
|
|
|
- toastr.error('输入的表达式非法');
|
|
|
- SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
+ }
|
|
|
+ if (col.field === 'node_type' && newValue && newValue !== '0' && newValue !== '19') {
|
|
|
+ const sameNodeType = sortData.find(x => { return x.node_type == newValue; });
|
|
|
+ if (sameNodeType) {
|
|
|
+ toastr.error('已存在该费用类别,请勿重复选择');
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 获取更新数据
|
|
|
+ if (col.type === 'Number') {
|
|
|
+ const exprInfo = getExprInfo(col.field);
|
|
|
+ if (newValue) {
|
|
|
+ const num = _.toNumber(newValue);
|
|
|
+ if (_.isFinite(num)) {
|
|
|
+ updateData.postData[col.field] = num;
|
|
|
} else {
|
|
|
- data[col.field] = null;
|
|
|
- if (exprInfo) {
|
|
|
- data[exprInfo.expr] = '';
|
|
|
+ try {
|
|
|
+ updateData.postData[col.field] = ZhCalc.mathCalcExpr(transExpr(newValue));
|
|
|
+ if (exprInfo) {
|
|
|
+ updateData.postData[exprInfo.expr] = newValue;
|
|
|
+ }
|
|
|
+ } catch(err) {
|
|
|
+ toastr.error('输入的表达式非法');
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
+ return;
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
- data[col.field] = newValue;
|
|
|
+ updateData.postData[col.field] = null;
|
|
|
+ if (exprInfo) {
|
|
|
+ updateData.postData[exprInfo.expr] = '';
|
|
|
+ }
|
|
|
}
|
|
|
- // 更新至服务器
|
|
|
- postData(window.location.pathname + '/update', {postType: 'update', postData: data}, function (result) {
|
|
|
- const refreshNode = ledgerTree.loadPostData(result);
|
|
|
- treeOperationObj.refreshTree(info.sheet, refreshNode);
|
|
|
- });
|
|
|
+ } else if (col.field === 'calc_template') {
|
|
|
+ updateData.postType = 'extra';
|
|
|
+ updateData.postData.calc_template = newValue;
|
|
|
+ } else {
|
|
|
+ updateData.postData[col.field] = newValue;
|
|
|
}
|
|
|
+ // 更新至服务器
|
|
|
+ postData(window.location.pathname + '/update', updateData, function (result) {
|
|
|
+ const refreshNode = ledgerTree.loadPostData(result);
|
|
|
+ treeOperationObj.refreshTree(info.sheet, refreshNode);
|
|
|
+ });
|
|
|
},
|
|
|
buttonClicked: function(e, info) {
|
|
|
if (!info.sheet.zh_setting) return;
|
|
|
@@ -1075,6 +1397,9 @@ $(document).ready(function() {
|
|
|
info.cancel = true;
|
|
|
}
|
|
|
break;
|
|
|
+ case 'calc_template':
|
|
|
+ info.cancel = node.children && node.children.length > 0 && node.code;
|
|
|
+ break;
|
|
|
}
|
|
|
},
|
|
|
sortCode: function (sheet) {
|
|
|
@@ -1186,6 +1511,7 @@ $(document).ready(function() {
|
|
|
// {title: 'node_type', colSpan: '1', rowSpan: '2', field: 'node_type', hAlign: 2, width: 60, type: 'Number', readOnly: true}
|
|
|
// );
|
|
|
sjsSettingObj.setNodeTypeCol(ledgerSpreadSetting.cols, [{ field: 'node_type' }]);
|
|
|
+ sjsSettingObj.setCalcTemplateCol(ledgerSpreadSetting.cols, [{ field: 'calc_template' }]);
|
|
|
sjsSettingObj.setFromCol(posSpreadSetting.cols, [{field: 'from'}]);
|
|
|
sjsSettingObj.setFromCol(ledgerSpreadSetting.cols, [{ field: 'from'}]);
|
|
|
SpreadJsObj.initSheet(ledgerSpread.getActiveSheet(), ledgerSpreadSetting);
|
|
|
@@ -1873,6 +2199,7 @@ $(document).ready(function() {
|
|
|
$(".sp-wrap").height(bcontent-30);
|
|
|
posSpread.refresh();
|
|
|
if (ancGclSpread) ancGclSpread.refresh();
|
|
|
+ if (posCalcDetail) posCalcDetail.refresh();
|
|
|
}
|
|
|
});
|
|
|
sjsSettingObj.setGridSelectStyle(posSpreadSetting);
|
|
|
@@ -2000,6 +2327,7 @@ $(document).ready(function() {
|
|
|
}
|
|
|
posOperationObj.loadExprToInput();
|
|
|
posOperationObj.refreshOperationValid(posSpread.getActiveSheet());
|
|
|
+ posCalcDetail.loadCurDetailData();
|
|
|
},
|
|
|
baseOpr: function (sheet, type) {
|
|
|
const data = {
|
|
|
@@ -2932,6 +3260,10 @@ $(document).ready(function() {
|
|
|
ancGclObj.loadCurAncillaryGcl();
|
|
|
SpreadJsObj.resetTopAndSelect(ancGclSheet);
|
|
|
|
|
|
+ posCalcDetail.detail.loadDatas(data.posCalcDetail);
|
|
|
+ posCalcDetail.loadCurDetailData();
|
|
|
+ SpreadJsObj.resetTopAndSelect(posCalcDetail.sheet);
|
|
|
+
|
|
|
treeOperationObj.refreshOperationValid(ledgerSpread.getActiveSheet());
|
|
|
treeOperationObj.loadExprToInput(ledgerSpread.getActiveSheet());
|
|
|
|
|
|
@@ -2944,6 +3276,7 @@ $(document).ready(function() {
|
|
|
ledgerSpread.refresh();
|
|
|
if (posSpread) posSpread.refresh();
|
|
|
if (ancGclSpread) ancGclSpread.refresh();
|
|
|
+ if (posCalcDetail) posCalcDetail.refresh();
|
|
|
if (stdXmj) stdXmj.spread.refresh();
|
|
|
if (stdGcl) stdGcl.spread.refresh();
|
|
|
if (dealBills) dealBills.spread.refresh();
|
|
|
@@ -3170,6 +3503,7 @@ $(document).ready(function() {
|
|
|
posSpread.refresh();
|
|
|
}
|
|
|
if (ancGclSpread) ancGclSpread.refresh();
|
|
|
+ if (posCalcDetail) posCalcDetail.refresh();
|
|
|
});
|
|
|
class DealBills {
|
|
|
constructor (selector, spreadSetting) {
|
|
|
@@ -4124,9 +4458,9 @@ $(document).ready(function() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- $('a', '#anc-gcl-nav').bind('click', function(e) {
|
|
|
+ $('a', '#pos-right-btn').bind('click', function(e) {
|
|
|
e.preventDefault();
|
|
|
- const tab = $(this);
|
|
|
+ const tab = $(this), tabPanel = $(tab.attr('content'));
|
|
|
const showSideTab = function (show) {
|
|
|
const left = $('#pos-spread'), right = $('#pos-right'), parent = left.parent();
|
|
|
if (show) {
|
|
|
@@ -4150,20 +4484,26 @@ $(document).ready(function() {
|
|
|
|
|
|
};
|
|
|
if (!tab.hasClass('active')) {
|
|
|
+ $('a', '#pos-right-btn').removeClass('active');
|
|
|
+ $('.tab-pane', '#pos-right').removeClass('active');
|
|
|
tab.addClass('active');
|
|
|
+ tabPanel.addClass('active');
|
|
|
showSideTab(tab.hasClass('active'));
|
|
|
} else {
|
|
|
tab.removeClass('active');
|
|
|
+ tabPanel.removeClass('active');
|
|
|
showSideTab(tab.hasClass('active'));
|
|
|
}
|
|
|
if (posSpread) posSpread.refresh();
|
|
|
if (ancGclSpread) ancGclSpread.refresh();
|
|
|
+ if (posCalcDetail) posCalcDetail.refresh();
|
|
|
});
|
|
|
$.divResizer({
|
|
|
select: '#pos-right-spr',
|
|
|
callback: function () {
|
|
|
if (posSpread) posSpread.refresh();
|
|
|
if (ancGclSpread) ancGclSpread.refresh();
|
|
|
+ if (posCalcDetail) posCalcDetail.refresh();
|
|
|
}
|
|
|
});
|
|
|
|