|
|
@@ -128,7 +128,7 @@ $(document).ready(function() {
|
|
|
const posSheet = posSpread.getActiveSheet();
|
|
|
|
|
|
// 初始化 附属工程量
|
|
|
- const ancGcl = createAncillaryGcl({ id: 'id', masterId: 'lid', sort: [['g_order', 'asc']] });
|
|
|
+ const ancGcl = createAncillaryGcl({ id: 'id', masterId: 'pid', topId: 'lid', sort: [['g_order', 'asc']] });
|
|
|
const ancGclSpread = SpreadJsObj.createNewSpread($('#anc-gcl-spread')[0]);
|
|
|
const ancGclSheet = ancGclSpread.getActiveSheet();
|
|
|
|
|
|
@@ -531,7 +531,7 @@ $(document).ready(function() {
|
|
|
};
|
|
|
const loadCurDetailData = function() {
|
|
|
const curAncGcl = SpreadJsObj.getSelectObject(ancGclSheet);
|
|
|
- template = node ? posCalcTemplate.find(x => { return x.id === node.calc_template }) : null;
|
|
|
+ template = curAncGcl ? posCalcTemplate.find(x => { return x.id === curAncGcl.calc_template }) : null;
|
|
|
if (template) {
|
|
|
const specCol = template.spread_cache.cols.find(x => { return x.field === 'spec'; });
|
|
|
if (specCol) {
|
|
|
@@ -553,8 +553,8 @@ $(document).ready(function() {
|
|
|
detail.updateDatas(result.detail);
|
|
|
reloadCurDetailData();
|
|
|
if (result.ancGcl) {
|
|
|
- ancGcl.updateDatas(result.ancGcl);
|
|
|
- // todo 刷新附属工程量
|
|
|
+ ancGcl.updateDatas({ update: result.ancGcl });
|
|
|
+ ancGclObj.loadCurAncillaryGcl();
|
|
|
}
|
|
|
},
|
|
|
baseOpr: function (type, addCount = 1) {
|
|
|
@@ -569,10 +569,10 @@ $(document).ready(function() {
|
|
|
const row = sel[0].row, count = sel[0].rowCount;
|
|
|
const first = detailRange[row];
|
|
|
if (type === 'insert') {
|
|
|
- const node = SpreadJsObj.getSelectObject(posSheet);
|
|
|
+ const node = SpreadJsObj.getSelectObject(ancGclSheet);
|
|
|
data.add = [];
|
|
|
for (let i = 1; i <= addCount; i++) {
|
|
|
- data.add.push({ lid: node.lid, pid: node.id, pcd_order: detailRange.length + i });
|
|
|
+ data.add.push({ lid: node.lid, pid: node.pid, ag_id: node.id, agd_order: detailRange.length + i });
|
|
|
}
|
|
|
if (first) data.select = first.id;
|
|
|
} else if (type === 'delete') {
|
|
|
@@ -617,7 +617,7 @@ $(document).ready(function() {
|
|
|
if (data.update <= 1) return;
|
|
|
}
|
|
|
|
|
|
- postData('/tender/' + getTenderId() + '/anc-gcl-calc/update', data, function(result) {
|
|
|
+ postData('/tender/' + getTenderId() + '/anc-gcl-detail/update', data, function(result) {
|
|
|
ctrlObj.afterPostData(result);
|
|
|
if (type !== 'delete') SpreadJsObj.locateData(sheet, first);
|
|
|
});
|
|
|
@@ -636,9 +636,9 @@ $(document).ready(function() {
|
|
|
const orgText = detailData ? detailData[col.field] : '', newText = trimInvalidChar(info.editingText);
|
|
|
if (orgText === newText || (!orgText && !newText)) return;
|
|
|
|
|
|
- const pos = ctrlObj.posNode;
|
|
|
- if (!pos) {
|
|
|
- toastr.error('数据错误,请选择计量单元后再试');
|
|
|
+ const ancGcl = ctrlObj.ancGclNode;
|
|
|
+ if (!ancGcl) {
|
|
|
+ toastr.error('数据错误,请选择附属工程量后再试');
|
|
|
SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
return;
|
|
|
}
|
|
|
@@ -666,7 +666,7 @@ $(document).ready(function() {
|
|
|
} 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 };
|
|
|
+ const addData = { lid: ancGcl.lid, pid: ancGcl.pid, ag_id: ancGcl.id, agd_order: order };
|
|
|
if (col.type === 'Number') {
|
|
|
const num = _.toNumber(newText);
|
|
|
if (!_.isFinite(num)) {
|
|
|
@@ -685,7 +685,7 @@ $(document).ready(function() {
|
|
|
}
|
|
|
data.add = [addData];
|
|
|
}
|
|
|
- postData('/tender/' + getTenderId() + '/pos-calc/update', data, function (result) {
|
|
|
+ postData('/tender/' + getTenderId() + '/anc-gcl-detail/update', data, function (result) {
|
|
|
ctrlObj.afterPostData(result);
|
|
|
}, function () {
|
|
|
SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
@@ -718,7 +718,7 @@ $(document).ready(function() {
|
|
|
}
|
|
|
if (data.update.length === 0) return;
|
|
|
|
|
|
- postData('/tender/' + getTenderId() + '/pos-calc/update', data, function (result) {
|
|
|
+ postData('/tender/' + getTenderId() + '/anc-gcl-detail/update', data, function (result) {
|
|
|
ctrlObj.afterPostData(result);
|
|
|
}, function () {
|
|
|
SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
@@ -726,8 +726,8 @@ $(document).ready(function() {
|
|
|
},
|
|
|
clipboardPasting: function(e, info) {
|
|
|
info.cancel = true;
|
|
|
- const relaPos = SpreadJsObj.getSelectObject(posSheet);
|
|
|
- if (!relaPos) {
|
|
|
+ const relaAncGcl = SpreadJsObj.getSelectObject(ancGclSheet);
|
|
|
+ if (!relaAncGcl) {
|
|
|
toastr.error('数据错误,请选择计量单元后再试');
|
|
|
SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
return;
|
|
|
@@ -771,14 +771,14 @@ $(document).ready(function() {
|
|
|
data.update.push(updateData);
|
|
|
} else {
|
|
|
if (!data.add) data.add = [];
|
|
|
- const addData = { lid: relaPos.lid, pid: relaPos.id, pcd_order: curRow + 1};
|
|
|
+ const addData = { lid: relaAncGcl.lid, pid: relaAncGcl.pid, ag_id: relaAncGcl.id, agd_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) {
|
|
|
+ postData('/tender/' + getTenderId() + '/anc-gcl-detail/update', data, function (result) {
|
|
|
ctrlObj.afterPostData(result);
|
|
|
}, function () {
|
|
|
SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
@@ -791,7 +791,7 @@ $(document).ready(function() {
|
|
|
spread.bind(spreadNS.Events.EditEnded, ctrlObj.editEnded);
|
|
|
spread.bind(spreadNS.Events.ClipboardPasting, ctrlObj.clipboardPasting);
|
|
|
$.contextMenu({
|
|
|
- selector: '#pos-detail-spread',
|
|
|
+ selector: '#anc-gcl-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;
|
|
|
@@ -888,7 +888,6 @@ $(document).ready(function() {
|
|
|
},
|
|
|
afterLocated: function (lid, pos_id) {
|
|
|
posOperationObj.loadCurPosData();
|
|
|
- ancGclObj.loadCurAncillaryGcl();
|
|
|
if (pos_id) {
|
|
|
const posSheet = posSpread.getActiveSheet();
|
|
|
const relaPos = posSheet.zh_data.find(x => { return x.id === pos_id; });
|
|
|
@@ -910,7 +909,6 @@ $(document).ready(function() {
|
|
|
storeKey: 'ledger-error-' + getTenderId(),
|
|
|
afterLocated: function () {
|
|
|
posOperationObj.loadCurPosData();
|
|
|
- ancGclObj.loadCurAncillaryGcl();
|
|
|
},
|
|
|
afterShow: function () {
|
|
|
ledgerSpread.refresh();
|
|
|
@@ -929,7 +927,6 @@ $(document).ready(function() {
|
|
|
checkType: getCheckType(checkOption),
|
|
|
afterLocated: function () {
|
|
|
posOperationObj.loadCurPosData();
|
|
|
- ancGclObj.loadCurAncillaryGcl();
|
|
|
},
|
|
|
afterShow: function () {
|
|
|
ledgerSpread.refresh();
|
|
|
@@ -1190,7 +1187,6 @@ $(document).ready(function() {
|
|
|
self.refreshTree(sheet, refreshNode);
|
|
|
self.refreshOperationValid(sheet);
|
|
|
posOperationObj.loadCurPosData();
|
|
|
- ancGclObj.loadCurAncillaryGcl();
|
|
|
billsTag.afterDeleteBills(refreshNode.delete);
|
|
|
});
|
|
|
});
|
|
|
@@ -1710,7 +1706,6 @@ $(document).ready(function() {
|
|
|
},
|
|
|
loadRelaData: function () {
|
|
|
posOperationObj.loadCurPosData();
|
|
|
- ancGclObj.loadCurAncillaryGcl();
|
|
|
posSearch.search($('#pos-keyword').val());
|
|
|
treeOperationObj.loadExprToInput(ledgerSpread.getActiveSheet());
|
|
|
},
|
|
|
@@ -1939,22 +1934,41 @@ $(document).ready(function() {
|
|
|
for (const b of cbl) {
|
|
|
const posRange = pos.getLedgerPos(b.id);
|
|
|
if (posRange && posRange.length > 0) b.pos = posRange;
|
|
|
- if (b.calc_template) {
|
|
|
- const template = posCalcTemplate.find(x => { return x.id === b.calc_template; });
|
|
|
- b.calc_template_str = template ? template.name : '';
|
|
|
- if (b.pos) {
|
|
|
+
|
|
|
+ if (b.pos) {
|
|
|
+ for (p of b.pos) {
|
|
|
+ p.ancGcl = ancGcl.getPartData(p.id) || [];
|
|
|
+ for (const ag of p.ancGcl) {
|
|
|
+ if (ag.calc_template) ag.calcDetail = ancGclDetail.detail.getPartData(ag.id);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (b.calc_template) {
|
|
|
+ const template = posCalcTemplate.find(x => { return x.id === b.calc_template; });
|
|
|
+ b.calc_template_str = template ? template.name : '';
|
|
|
for (const p of b.pos) {
|
|
|
const detailRange = posCalcDetail.detail.getPartData(p.id);
|
|
|
p.calcDetail = detailRange;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- const gclRange = ancGcl.getPartData(b.id);
|
|
|
- if (gclRange && gclRange.length > 0) b.ancGcl = gclRange;
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
return copyBlockList;
|
|
|
- }
|
|
|
+ },
|
|
|
+ removeCalcTemplate: function(node) {
|
|
|
+ const billsUpdateData = {postType: 'extra', postData: { id: node.id, tender_id: node.tender_id, ledger_id: node.ledger_id, calc_template: '' }};
|
|
|
+ postData(window.location.pathname + '/update', billsUpdateData, function (result) {
|
|
|
+ const refreshNode = ledgerTree.loadPostData(result);
|
|
|
+ treeOperationObj.refreshTree(ledgerSheet, refreshNode);
|
|
|
+ if (result.pos) {
|
|
|
+ pos.updateDatas(result.pos);
|
|
|
+ posOperationObj.loadCurPosData(false);
|
|
|
+ }
|
|
|
+ posCalcDetail.detail.removeDatasByTopId(node.id);
|
|
|
+ posCalcDetail.loadCurDetailData();
|
|
|
+ });
|
|
|
+ },
|
|
|
};
|
|
|
const ledgerTemplate = $.ledger_template({
|
|
|
selector: '#ledger-template',
|
|
|
@@ -2165,7 +2179,7 @@ $(document).ready(function() {
|
|
|
}
|
|
|
|
|
|
const calcTemplateSelect = (function(){
|
|
|
- let ctrlBills = {}, first = 1;
|
|
|
+ let ctrlNode = {}, first = 1, nodeType = 'bills';
|
|
|
const tree = createNewPathTree('gather', {
|
|
|
id: 'tree_id', pid: 'tree_pid', order: 'tree_order',
|
|
|
level: 'tree_level', isLeaf: 'tree_is_leaf', fullPath: 'tree_full_path',
|
|
|
@@ -2200,12 +2214,13 @@ $(document).ready(function() {
|
|
|
return !data.is_calc_template ? defaultFont : 'bold ' + defaultFont;
|
|
|
},
|
|
|
getColor: function(sheet, data, row, col, defaultColor) {
|
|
|
- return data && data.id === ctrlBills.calc_template ? spreadColor.common.invalid : defaultColor;
|
|
|
+ return data && data.id === ctrlNode.calc_template ? spreadColor.common.invalid : defaultColor;
|
|
|
}
|
|
|
});
|
|
|
SpreadJsObj.loadSheetData(sheet, SpreadJsObj.DataType.Tree, tree);
|
|
|
- const select = function(node) {
|
|
|
- ctrlBills = node;
|
|
|
+ const select = function(node, type) {
|
|
|
+ nodeType = type || 'bills';
|
|
|
+ ctrlNode = node;
|
|
|
SpreadJsObj.reloadRowBackColor(sheet, 0, tree.nodes.length);
|
|
|
$('#select-calc-template').modal('show');
|
|
|
};
|
|
|
@@ -2216,23 +2231,79 @@ $(document).ready(function() {
|
|
|
toastr.warning('请勿选择文件夹');
|
|
|
return;
|
|
|
}
|
|
|
- if (ct.id === ctrlBills.calc_template) {
|
|
|
+ if (ct.id === ctrlNode.calc_template) {
|
|
|
toastr.warning('选择的计算模板与之前相同');
|
|
|
return;
|
|
|
}
|
|
|
- const updateData = {postType: 'extra', postData: { id: ctrlBills.id, tender_id: ctrlBills.tender_id, ledger_id: ctrlBills.ledger_id, calc_template: ct.id }};
|
|
|
- postData(window.location.pathname + '/update', updateData, function (result) {
|
|
|
- const refreshNode = ledgerTree.loadPostData(result);
|
|
|
- treeOperationObj.refreshTree(ledgerSheet, refreshNode);
|
|
|
- posCalcDetail.loadCurDetailData();
|
|
|
- $('#select-calc-template').modal('hide');
|
|
|
- });
|
|
|
+ switch (nodeType) {
|
|
|
+ case 'ancGcl':
|
|
|
+ const ancGclUpdateData = { calcTmpl: { id: ctrlNode.id, calc_template: ct.id } };
|
|
|
+ postData('/tender/' + getTenderId() + '/anc-gcl/update', ancGclUpdateData, function(result) {
|
|
|
+ ancGcl.updateDatas(result);
|
|
|
+ ancGclObj.loadCurAncillaryGcl();
|
|
|
+ ancGclDetail.detail.updateDatas({ update: result.detail });
|
|
|
+ ancGclDetail.reloadCurDetailData();
|
|
|
+ $('#select-calc-template').modal('hide');
|
|
|
+ });
|
|
|
+ break;
|
|
|
+ case 'bills':
|
|
|
+ default:
|
|
|
+ const billsUpdateData = {postType: 'extra', postData: { id: ctrlNode.id, tender_id: ctrlNode.tender_id, ledger_id: ctrlNode.ledger_id, calc_template: ct.id }};
|
|
|
+ postData(window.location.pathname + '/update', billsUpdateData, function (result) {
|
|
|
+ const refreshNode = ledgerTree.loadPostData(result);
|
|
|
+ treeOperationObj.refreshTree(ledgerSheet, refreshNode);
|
|
|
+ posCalcDetail.loadCurDetailData();
|
|
|
+ $('#select-calc-template').modal('hide');
|
|
|
+ });
|
|
|
+ break;
|
|
|
+ }
|
|
|
});
|
|
|
$('#select-calc-template').on('shown.bs.modal', function() {
|
|
|
if (first) {
|
|
|
spread.refresh();
|
|
|
first = 0;
|
|
|
}
|
|
|
+ searchObj.clear();
|
|
|
+ });
|
|
|
+ const searchObj = {
|
|
|
+ result: [],
|
|
|
+ cur: 0,
|
|
|
+ search: function() {
|
|
|
+ const keyword = $(`#select-calc-template-sk`).val();
|
|
|
+ searchObj.result = keyword ? tree.nodes.filter(x => {
|
|
|
+ return x.name.indexOf(keyword) >= 0;
|
|
|
+ }) : [];
|
|
|
+ $(`#select-calc-template-sr`)[0].innerText = `结果:${searchObj.result.length}`;
|
|
|
+ searchObj.cur = 0;
|
|
|
+ if (searchObj.result.length > 0) {
|
|
|
+ SpreadJsObj.locateTreeNode(sheet, tree.getNodeKey(searchObj.result[searchObj.cur]));
|
|
|
+ }
|
|
|
+ },
|
|
|
+ searchPre: function () {
|
|
|
+ if (searchObj.result.length === 0) return;
|
|
|
+ searchObj.cur = searchObj.cur === 0 ? searchObj.result.length - 1 : this.cur - 1;
|
|
|
+ SpreadJsObj.locateTreeNode(sheet, tree.getNodeKey(searchObj.result[searchObj.cur]), true);
|
|
|
+ },
|
|
|
+ searchNext: function () {
|
|
|
+ if (searchObj.result.length === 0) return;
|
|
|
+ searchObj.cur = searchObj.cur === searchObj.result.length - 1 ? 0 : searchObj.cur + 1;
|
|
|
+ SpreadJsObj.locateTreeNode(sheet, tree.getNodeKey(searchObj.result[searchObj.cur]), true);
|
|
|
+ },
|
|
|
+ clear: function () {
|
|
|
+ $(`#select-calc-template-sk`).val('');
|
|
|
+ $(`#select-calc-template-sr`)[0].innerText = `结果:${0}`;
|
|
|
+ searchObj.result = [];
|
|
|
+ searchObj.cur = 0;
|
|
|
+ }
|
|
|
+ };
|
|
|
+ $('#select-calc-template-sk').change(function() {
|
|
|
+ searchObj.search();
|
|
|
+ });
|
|
|
+ $('#select-calc-template-sp').click(function() {
|
|
|
+ searchObj.searchPre();
|
|
|
+ });
|
|
|
+ $('#select-calc-template-sn').click(function() {
|
|
|
+ searchObj.searchNext();
|
|
|
});
|
|
|
return { select }
|
|
|
})();
|
|
|
@@ -2372,11 +2443,20 @@ $(document).ready(function() {
|
|
|
disabled: function(key, opt) {
|
|
|
const node = SpreadJsObj.getSelectObject(ledgerSheet);
|
|
|
return !node || !node.b_code;
|
|
|
+ }
|
|
|
+ };
|
|
|
+ billsContextMenuOptions.items.removeCalcTmpl = {
|
|
|
+ name: '移除计算模板',
|
|
|
+ callback: function(key, opt) {
|
|
|
+ const node = SpreadJsObj.getSelectObject(ledgerSheet);
|
|
|
+ treeOperationObj.removeCalcTemplate(node);
|
|
|
},
|
|
|
- visible: function(key, opt) {
|
|
|
- return !readOnly;
|
|
|
+ disabled: function(key, opt) {
|
|
|
+ const node = SpreadJsObj.getSelectObject(ledgerSheet);
|
|
|
+ return !node || !node.b_code || !node.calc_template;
|
|
|
}
|
|
|
};
|
|
|
+ billsContextMenuOptions.items.calcTmplSpr = '----';
|
|
|
billsContextMenuOptions.items.batchInsert = {
|
|
|
name: '批量插入',
|
|
|
type: 'batchInsert',
|
|
|
@@ -2673,7 +2753,6 @@ $(document).ready(function() {
|
|
|
SpreadJsObj.loadSheetData(ledgerSpread.getActiveSheet(), 'tree', ledgerTree);
|
|
|
pos.loadDatas(result.pos);
|
|
|
posOperationObj.loadCurPosData();
|
|
|
- ancGclObj.loadCurAncillaryGcl();
|
|
|
checkShowLast(result.bills.length);
|
|
|
}, null);
|
|
|
},
|
|
|
@@ -2984,6 +3063,7 @@ $(document).ready(function() {
|
|
|
posOperationObj.loadExprToInput();
|
|
|
posOperationObj.refreshOperationValid(posSpread.getActiveSheet());
|
|
|
if (refreshDetail) posCalcDetail.loadCurDetailData();
|
|
|
+ ancGclObj.loadCurAncillaryGcl();
|
|
|
},
|
|
|
baseOpr: function (sheet, type) {
|
|
|
const data = {
|
|
|
@@ -3034,6 +3114,7 @@ $(document).ready(function() {
|
|
|
const loadResult = ledgerTree.loadPostData(result.ledger);
|
|
|
treeOperationObj.refreshTree(ledgerSpread.getActiveSheet(), loadResult);
|
|
|
treeOperationObj.refreshOperationValid(ledgerSpread.getActiveSheet());
|
|
|
+ posOperationObj.loadCurPosData();
|
|
|
} else {
|
|
|
const updateRst = pos.updateDatas(result.pos);
|
|
|
billsTag.refreshPosTagView(updateRst.update);
|
|
|
@@ -3230,6 +3311,7 @@ $(document).ready(function() {
|
|
|
const loadResult = ledgerTree.loadPostData(result.ledger);
|
|
|
treeOperationObj.refreshTree(ledgerSpread.getActiveSheet(), loadResult);
|
|
|
treeOperationObj.refreshOperationValid(ledgerSpread.getActiveSheet());
|
|
|
+ posOperationObj.loadCurPosData();
|
|
|
});
|
|
|
}
|
|
|
},
|
|
|
@@ -3358,6 +3440,7 @@ $(document).ready(function() {
|
|
|
posOperationObj.loadExprToInput();
|
|
|
posOperationObj.refreshOperationValid(posSpread.getActiveSheet());
|
|
|
posCalcDetail.loadCurDetailData();
|
|
|
+ ancGclObj.loadCurAncillaryGcl();
|
|
|
},
|
|
|
addPegs: function (pegs) {
|
|
|
if (!pegs || pegs.length <= 0) return;
|
|
|
@@ -3389,6 +3472,10 @@ $(document).ready(function() {
|
|
|
const detailRange = posCalcDetail.detail.getPartData(p.id);
|
|
|
p.calcDetail = detailRange;
|
|
|
}
|
|
|
+ p.ancGcl = ancGcl.getPartData(p.id) || [];
|
|
|
+ for (const ag of p.ancGcl) {
|
|
|
+ if (ag.calc_template) ag.calcDetail = ancGclDetail.detail.getPartData(ag.id);
|
|
|
+ }
|
|
|
iRow++;
|
|
|
}
|
|
|
return copyBlockList;
|
|
|
@@ -3414,6 +3501,8 @@ $(document).ready(function() {
|
|
|
if (result.posCalcDetail) posCalcDetail.detail.updateDatas(result.posCalcDetail);
|
|
|
const ledgerResult = ledgerTree.loadPostData(data.ledger);
|
|
|
treeOperationObj.refreshTree(ledgerSheet, ledgerResult);
|
|
|
+ if (result.ancGcl) ancGcl.updateDatas(result.ancGcl);
|
|
|
+ if (result.ancGclDetail) ancGclDetail.detail.updateDatas(result.ancGclDetail);
|
|
|
removeLocalCache(copyBlockTag);
|
|
|
posOperationObj.loadCurPosData();
|
|
|
});
|
|
|
@@ -3591,6 +3680,10 @@ $(document).ready(function() {
|
|
|
{title: '设计量', colSpan: '1', rowSpan: '1', field: 'quantity', hAlign: 2, width: 60, type: 'Number'},
|
|
|
{title: '设计量公式', colSpan: '1', rowSpan: '1', field: 'expr', hAlign: 0, width: 80, formatter: '@'},
|
|
|
{title: '图册号', colSpan: '1', rowSpan: '1', field: 'drawing_code', hAlign: 0, width: 80, formatter: '@'},
|
|
|
+ {title: '计算模板', colSpan: '1', rowSpan: '1', field: 'calc_template', hAlign: 1, width: 80, formatter: '@', readOnly: true, getValue: function(data) {
|
|
|
+ const ct = data ? posCalcTemplate.find(x => { return x.id === data.calc_template }) : null;
|
|
|
+ return ct ? ct.name : '';
|
|
|
+ }},
|
|
|
{title: '备注', colSpan: '1', rowSpan: '1', field: 'memo', hAlign: 0, width: 80, formatter: '@'},
|
|
|
],
|
|
|
emptyRows: 3,
|
|
|
@@ -3605,9 +3698,10 @@ $(document).ready(function() {
|
|
|
SpreadJsObj.initSheet(ancGclSheet, ancGclSpreadSetting);
|
|
|
const ancGclObj = {
|
|
|
loadCurAncillaryGcl: function () {
|
|
|
- const node = treeOperationObj.getSelectNode(ledgerSheet);
|
|
|
- const gclData = node ? ancGcl.getPartData(node.id) || [] : [];
|
|
|
+ const posNode = SpreadJsObj.getSelectObject(posSheet);
|
|
|
+ const gclData = posNode ? ancGcl.getPartData(posNode.id) || [] : [];
|
|
|
SpreadJsObj.loadSheetData(ancGclSheet, SpreadJsObj.DataType.Data, gclData);
|
|
|
+ ancGclDetail.loadCurDetailData();
|
|
|
},
|
|
|
baseOpr: function (type) {
|
|
|
const data = {};
|
|
|
@@ -3621,8 +3715,8 @@ $(document).ready(function() {
|
|
|
const row = sel[0].row, count = sel[0].rowCount;
|
|
|
const first = gclRange[row];
|
|
|
if (type === 'insert') {
|
|
|
- const node = SpreadJsObj.getSelectObject(ledgerSheet);
|
|
|
- data.add = [{ lid: node.id, g_order: gclRange.length + 1 }];
|
|
|
+ const posNode = SpreadJsObj.getSelectObject(posSheet);
|
|
|
+ data.add = [{ lid: posNode.lid, pid: posNode.id, g_order: gclRange.length + 1 }];
|
|
|
} else if (type === 'delete') {
|
|
|
data.del = [];
|
|
|
for (let iRow = 0; iRow < count; iRow++) {
|
|
|
@@ -3673,6 +3767,7 @@ $(document).ready(function() {
|
|
|
},
|
|
|
editStarting: function (e, info) {
|
|
|
ancGclObj.ledgerTreeNode = SpreadJsObj.getSelectObject(ledgerSheet);
|
|
|
+ ancGclObj.posNode = SpreadJsObj.getSelectObject(posSheet);
|
|
|
},
|
|
|
editEnded: function (e, info) {
|
|
|
const setting = info.sheet.zh_setting;
|
|
|
@@ -3683,19 +3778,9 @@ $(document).ready(function() {
|
|
|
const orgText = gclData ? gclData[col.field] : '', newText = trimInvalidChar(info.editingText);
|
|
|
if (orgText === newText || (!orgText && !newText)) return;
|
|
|
|
|
|
- const node = ancGclObj.ledgerTreeNode;
|
|
|
- if (!node) {
|
|
|
- toastr.error('数据错误,请选择台账节点后再试');
|
|
|
- SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
- return;
|
|
|
- }
|
|
|
- if (!!newText && node.children && node.children.length > 0) {
|
|
|
- toastr.error('父节点不可添加附属工程量');
|
|
|
- SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
- return;
|
|
|
- }
|
|
|
- if (!!newText && (!node.b_code || node.b_code === '')) {
|
|
|
- toastr.error('项目节不可插入附属工程量');
|
|
|
+ const posNode = ancGclObj.posNode;
|
|
|
+ if (!posNode) {
|
|
|
+ toastr.error('数据错误,请选择计量单元后再试');
|
|
|
SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
return;
|
|
|
}
|
|
|
@@ -3728,7 +3813,7 @@ $(document).ready(function() {
|
|
|
} else {
|
|
|
const sortData = info.sheet.zh_data;
|
|
|
const order = (!sortData || sortData.length === 0) ? 1 : Math.max(sortData[sortData.length - 1].g_order + 1, sortData.length + 1);
|
|
|
- const addData = { lid: node.id, g_order: order };
|
|
|
+ const addData = { lid: posNode.lid, pid: posNode.id, g_order: order };
|
|
|
if (col.type === 'Number') {
|
|
|
const num = _.toNumber(newText);
|
|
|
if (!_.isFinite(num)) {
|
|
|
@@ -3801,19 +3886,9 @@ $(document).ready(function() {
|
|
|
},
|
|
|
clipboardPasting: function(e, info) {
|
|
|
info.cancel = true;
|
|
|
- const node = SpreadJsObj.getSelectObject(ledgerSheet);
|
|
|
- if (!node) {
|
|
|
- toastr.error('数据错误,请选择台账节点后再试');
|
|
|
- SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
- return;
|
|
|
- }
|
|
|
- if (node.children && node.children.length > 0) {
|
|
|
- toastr.error('父节点不可添加附属工程量');
|
|
|
- SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
- return;
|
|
|
- }
|
|
|
- if ((!node.b_code || node.b_code === '')) {
|
|
|
- toastr.error('项目节不可插入附属工程量');
|
|
|
+ const posNode = ancGclObj.posNode;
|
|
|
+ if (!posNode) {
|
|
|
+ toastr.error('数据错误,请选择计量单元后再试');
|
|
|
SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
return;
|
|
|
}
|
|
|
@@ -3861,7 +3936,7 @@ $(document).ready(function() {
|
|
|
data.update.push(updateData);
|
|
|
} else {
|
|
|
if (!data.add) data.add = [];
|
|
|
- const addData = { lid: node.id, g_order: curRow + 1};
|
|
|
+ const addData = { lid: posNode.lid, pid: posNode.id, g_order: curRow + 1};
|
|
|
analysisData(pasteData[iRow], addData);
|
|
|
data.add.push(addData);
|
|
|
}
|
|
|
@@ -3896,7 +3971,51 @@ $(document).ready(function() {
|
|
|
SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
});
|
|
|
},
|
|
|
+ selectionChanged: function(e, info) {
|
|
|
+ ancGclDetail.loadCurDetailData();
|
|
|
+ },
|
|
|
+ removeCalcTemplate: function(node) {
|
|
|
+ const ancGclUpdateData = { calcTmpl: { id: node.id, calc_template: '' } };
|
|
|
+ postData('/tender/' + getTenderId() + '/anc-gcl/update', ancGclUpdateData, function(result) {
|
|
|
+ ancGcl.updateDatas(result);
|
|
|
+ ancGclObj.loadCurAncillaryGcl();
|
|
|
+ ancGclDetail.detail.updateDatas({ update: result.detail });
|
|
|
+ ancGclDetail.reloadCurDetailData();
|
|
|
+ });
|
|
|
+ },
|
|
|
+ getBlockData: function() {
|
|
|
+ const copyBlockList = [];
|
|
|
+ const sheet = ancGclSheet;
|
|
|
+ const sel = sheet.getSelections()[0];
|
|
|
+ let iRow = sel.row;
|
|
|
+ while (iRow < sel.row + sel.rowCount) {
|
|
|
+ const p = sheet.zh_data[iRow];
|
|
|
+ if (!p) break;
|
|
|
+ copyBlockList.push(p);
|
|
|
+ if (p.calc_template) {
|
|
|
+ const detailRange = ancGclDetail.detail.getPartData(p.id);
|
|
|
+ p.calcDetail = detailRange;
|
|
|
+ }
|
|
|
+ iRow++;
|
|
|
+ }
|
|
|
+ return copyBlockList;
|
|
|
+ },
|
|
|
+ pasteBlock: function(copyInfo) {
|
|
|
+ const posNode = SpreadJsObj.getSelectObject(posSheet);
|
|
|
+ if (!posNode) {
|
|
|
+ toastr.error('数据错误,请选择计量单元后再试');
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const data = { pasteBlock: { pid: posNode.id, tid: copyInfo.tid, block: copyInfo.block } };
|
|
|
+ postData('/tender/' + getTenderId() + '/anc-gcl/update', data, function (result) {
|
|
|
+ ancGcl.updateDatas(result);
|
|
|
+ if (result.details) ancGclDetail.detail.updateDatas(result.details);
|
|
|
+ ancGclObj.loadCurAncillaryGcl();
|
|
|
+ });
|
|
|
+ }
|
|
|
};
|
|
|
+ ancGclSpread.bind(spreadNS.Events.SelectionChanged, ancGclObj.selectionChanged);
|
|
|
if (!readOnly) {
|
|
|
SpreadJsObj.addDeleteBind(ancGclSpread, ancGclObj.deletePress);
|
|
|
ancGclSpread.bind(spreadNS.Events.EditStarting, ancGclObj.editStarting);
|
|
|
@@ -3960,6 +4079,60 @@ $(document).ready(function() {
|
|
|
ancGclObj.baseOpr('up-move');
|
|
|
}
|
|
|
},
|
|
|
+ editSpr: '----',
|
|
|
+ selectCalcTemplate: {
|
|
|
+ name: '选择计算模板',
|
|
|
+ callback: function(key, opt) {
|
|
|
+ const node = SpreadJsObj.getSelectObject(ancGclSheet);
|
|
|
+ calcTemplateSelect.select(node, 'ancGcl');
|
|
|
+ },
|
|
|
+ disabled: function(key, opt) {
|
|
|
+ const node = SpreadJsObj.getSelectObject(ancGclSheet);
|
|
|
+ return !node;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ removeCalcTemplate: {
|
|
|
+ name: '移除计算模板',
|
|
|
+ callback: function(key, opt) {
|
|
|
+ const node = SpreadJsObj.getSelectObject(ancGclSheet);
|
|
|
+ ancGclObj.removeCalcTemplate(node);
|
|
|
+ },
|
|
|
+ disabled: function(key, opt) {
|
|
|
+ const node = SpreadJsObj.getSelectObject(ancGclSheet);
|
|
|
+ return !node || !node.calc_template;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ calcTmplSpr: '----',
|
|
|
+ copyBlock: {
|
|
|
+ name: '复制整块',
|
|
|
+ callback: function(key, opt) {
|
|
|
+ ancGclObj.block = [];
|
|
|
+ const copyBlockList = ancGclObj.getBlockData();
|
|
|
+ setLocalCache(copyBlockTag, JSON.stringify({ block: copyBlockList, tag: 'ancGcl' }));
|
|
|
+ },
|
|
|
+ disabled: function(key, opt) {
|
|
|
+ const node = SpreadJsObj.getSelectObject(ancGclSheet);
|
|
|
+ return !node;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ pasteBlock: {
|
|
|
+ name: '粘贴整块',
|
|
|
+ callback: function(key, opt) {
|
|
|
+ const copyInfo = JSON.parse(getLocalCache(copyBlockTag));
|
|
|
+ if (copyInfo.block.length > 0) {
|
|
|
+ ancGclObj.pasteBlock(copyInfo);
|
|
|
+ } else {
|
|
|
+ document.execCommand('paste');
|
|
|
+ }
|
|
|
+ },
|
|
|
+ disabled: function(key, opt) {
|
|
|
+ const pos = SpreadJsObj.getSelectObject(posSheet);
|
|
|
+ if (!pos) return true;
|
|
|
+
|
|
|
+ const copyInfo = JSON.parse(getLocalCache(copyBlockTag));
|
|
|
+ return !(copyInfo && copyInfo.block && copyInfo.block.length > 0 && copyInfo.tag === 'ancGcl');
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
@@ -4001,6 +4174,9 @@ $(document).ready(function() {
|
|
|
|
|
|
ancGclObj.loadCurAncillaryGcl();
|
|
|
SpreadJsObj.resetTopAndSelect(ancGclSheet);
|
|
|
+ ancGclDetail.detail.loadDatas(data.ancGclDetail);
|
|
|
+ ancGclDetail.loadCurDetailData();
|
|
|
+ SpreadJsObj.resetTopAndSelect(ancGclDetail.sheet);
|
|
|
|
|
|
posCalcDetail.detail.loadDatas(data.posCalcDetail);
|
|
|
posCalcDetail.loadCurDetailData();
|
|
|
@@ -4507,7 +4683,6 @@ $(document).ready(function() {
|
|
|
treeOperationObj.refreshOperationValid(mainSheet);
|
|
|
ledgerSpread.focus();
|
|
|
posOperationObj.loadCurPosData();
|
|
|
- ancGclObj.loadCurAncillaryGcl();
|
|
|
});
|
|
|
});
|
|
|
}
|
|
|
@@ -4926,7 +5101,6 @@ $(document).ready(function() {
|
|
|
SpreadJsObj.reloadRowsBackColor(sheet, [sel.row, result.create[0].index]);
|
|
|
treeOperationObj.refreshOperationValid(sheet);
|
|
|
posOperationObj.loadCurPosData();
|
|
|
- ancGclObj.loadCurAncillaryGcl();
|
|
|
self.obj.modal('hide');
|
|
|
}, null, true);
|
|
|
} else {
|
|
|
@@ -5823,7 +5997,6 @@ $(document).ready(function() {
|
|
|
SpreadJsObj.loadSheetData(ledgerSpread.getActiveSheet(), 'tree', ledgerTree);
|
|
|
pos.loadDatas(result.pos);
|
|
|
posOperationObj.loadCurPosData();
|
|
|
- ancGclObj.loadCurAncillaryGcl();
|
|
|
checkShowLast(result.bills.length);
|
|
|
});
|
|
|
});
|
|
|
@@ -5835,7 +6008,6 @@ $(document).ready(function() {
|
|
|
const loadResult = ledgerTree.loadPostData({update: data.source.bills});
|
|
|
treeOperationObj.refreshTree(ledgerSpread.getActiveSheet(), loadResult);
|
|
|
posOperationObj.loadCurPosData();
|
|
|
- ancGclObj.loadCurAncillaryGcl();
|
|
|
for (const e of data.error) {
|
|
|
e.serialNo = ledgerTree.getNodeIndex(ledgerTree.getItems(e.ledger_id)) + 1;
|
|
|
}
|
|
|
@@ -6089,7 +6261,6 @@ $(document).ready(function() {
|
|
|
if (Object.keys(att).length) {
|
|
|
SpreadJsObj.locateTreeNode(ledgerSpread.getActiveSheet(), att.ledger_id, true);
|
|
|
posOperationObj.loadCurPosData();
|
|
|
- ancGclObj.loadCurAncillaryGcl();
|
|
|
}
|
|
|
}
|
|
|
});
|