|
|
@@ -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) {
|
|
|
@@ -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());
|
|
|
},
|
|
|
@@ -2165,7 +2160,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 +2195,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,17 +2212,32 @@ $(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) {
|
|
|
@@ -2673,7 +2684,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 +2994,7 @@ $(document).ready(function() {
|
|
|
posOperationObj.loadExprToInput();
|
|
|
posOperationObj.refreshOperationValid(posSpread.getActiveSheet());
|
|
|
if (refreshDetail) posCalcDetail.loadCurDetailData();
|
|
|
+ ancGclObj.loadCurAncillaryGcl();
|
|
|
},
|
|
|
baseOpr: function (sheet, type) {
|
|
|
const data = {
|
|
|
@@ -3034,6 +3045,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 +3242,7 @@ $(document).ready(function() {
|
|
|
const loadResult = ledgerTree.loadPostData(result.ledger);
|
|
|
treeOperationObj.refreshTree(ledgerSpread.getActiveSheet(), loadResult);
|
|
|
treeOperationObj.refreshOperationValid(ledgerSpread.getActiveSheet());
|
|
|
+ posOperationObj.loadCurPosData();
|
|
|
});
|
|
|
}
|
|
|
},
|
|
|
@@ -3358,6 +3371,7 @@ $(document).ready(function() {
|
|
|
posOperationObj.loadExprToInput();
|
|
|
posOperationObj.refreshOperationValid(posSpread.getActiveSheet());
|
|
|
posCalcDetail.loadCurDetailData();
|
|
|
+ ancGclObj.loadCurAncillaryGcl();
|
|
|
},
|
|
|
addPegs: function (pegs) {
|
|
|
if (!pegs || pegs.length <= 0) return;
|
|
|
@@ -3591,6 +3605,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 +3623,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 +3640,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 +3692,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 +3703,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 +3738,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 +3811,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 +3861,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 +3896,11 @@ $(document).ready(function() {
|
|
|
SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
});
|
|
|
},
|
|
|
+ selectionChanged: function(e, info) {
|
|
|
+ ancGclDetail.loadCurDetailData();
|
|
|
+ },
|
|
|
};
|
|
|
+ ancGclSpread.bind(spreadNS.Events.SelectionChanged, ancGclObj.selectionChanged);
|
|
|
if (!readOnly) {
|
|
|
SpreadJsObj.addDeleteBind(ancGclSpread, ancGclObj.deletePress);
|
|
|
ancGclSpread.bind(spreadNS.Events.EditStarting, ancGclObj.editStarting);
|
|
|
@@ -3960,6 +3964,18 @@ $(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;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
@@ -4507,7 +4523,6 @@ $(document).ready(function() {
|
|
|
treeOperationObj.refreshOperationValid(mainSheet);
|
|
|
ledgerSpread.focus();
|
|
|
posOperationObj.loadCurPosData();
|
|
|
- ancGclObj.loadCurAncillaryGcl();
|
|
|
});
|
|
|
});
|
|
|
}
|
|
|
@@ -4926,7 +4941,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 +5837,6 @@ $(document).ready(function() {
|
|
|
SpreadJsObj.loadSheetData(ledgerSpread.getActiveSheet(), 'tree', ledgerTree);
|
|
|
pos.loadDatas(result.pos);
|
|
|
posOperationObj.loadCurPosData();
|
|
|
- ancGclObj.loadCurAncillaryGcl();
|
|
|
checkShowLast(result.bills.length);
|
|
|
});
|
|
|
});
|
|
|
@@ -5835,7 +5848,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 +6101,6 @@ $(document).ready(function() {
|
|
|
if (Object.keys(att).length) {
|
|
|
SpreadJsObj.locateTreeNode(ledgerSpread.getActiveSheet(), att.ledger_id, true);
|
|
|
posOperationObj.loadCurPosData();
|
|
|
- ancGclObj.loadCurAncillaryGcl();
|
|
|
}
|
|
|
}
|
|
|
});
|