|
@@ -1476,7 +1476,15 @@ $(document).ready(() => {
|
|
|
});
|
|
|
},
|
|
|
exportExcel: function (filename, nodes, withPos = true) {
|
|
|
- const exportNodesData = function (data, nodes) {
|
|
|
+ stageTree.recursiveExe(function(node) {
|
|
|
+ if (node.children && node.children.length > 0) {
|
|
|
+ node._export_group = _.sum(node.children.map(x => { return x._export_group; })) + node.children.length;
|
|
|
+ } else {
|
|
|
+ const posRange = stagePos.getLedgerPos(node.id);
|
|
|
+ node._export_group = posRange ? posRange.length : 0;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ const exportNodesData = function (data, nodes, groupData) {
|
|
|
for (const node of nodes) {
|
|
|
data.push({
|
|
|
code: node.code, b_code: node.b_code, name: node.name, unit: node.unit,
|
|
@@ -1494,28 +1502,28 @@ $(document).ready(() => {
|
|
|
contract_expr_str: node.calc_expr ? TreeExprCalc.expr2ExprStr(node.calc_expr) : '',
|
|
|
});
|
|
|
if (node.children && node.children.length > 0) {
|
|
|
- exportNodesData(data, node.children);
|
|
|
+ exportNodesData(data, node.children, groupData);
|
|
|
} else {
|
|
|
if (!withPos) continue;
|
|
|
const posRange = stagePos.getLedgerPos(node.id);
|
|
|
- if (posRange && posRange.length > 0) {
|
|
|
- for (const [i, p] of posRange.entries()) {
|
|
|
- data.push({
|
|
|
- pos_code: (i + 1) + '', name: p.name,
|
|
|
- quantity: p.quantity,
|
|
|
- contract_qty: p.contract_qty, qc_qty: p.qc_qty, gather_qty: p.gather_qty,
|
|
|
- end_contract_qty: p.end_contract_qty, end_qc_qty: p.end_qc_qty, end_gather_qty: p.end_gather_qty,
|
|
|
- qc_minus_qty: p.qc_minus_qty, end_qc_minus_qty: p.end_qc_minus_qty,
|
|
|
- drawing_code: p.drawing_code, memo: p.memo, postil: p.postil, position: p.position,
|
|
|
- });
|
|
|
- }
|
|
|
+ if (!posRange || posRange.length === 0) continue;
|
|
|
+ if (node._export_group) groupData.push({ code: node.code, b_code: node.b_code, start: data.length, count: node._export_group });
|
|
|
+ for (const [i, p] of posRange.entries()) {
|
|
|
+ data.push({
|
|
|
+ pos_code: (i + 1) + '', name: p.name,
|
|
|
+ quantity: p.quantity,
|
|
|
+ contract_qty: p.contract_qty, qc_qty: p.qc_qty, gather_qty: p.gather_qty,
|
|
|
+ end_contract_qty: p.end_contract_qty, end_qc_qty: p.end_qc_qty, end_gather_qty: p.end_gather_qty,
|
|
|
+ qc_minus_qty: p.qc_minus_qty, end_qc_minus_qty: p.end_qc_minus_qty,
|
|
|
+ drawing_code: p.drawing_code, memo: p.memo, postil: p.postil, position: p.position,
|
|
|
+ });
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
- const data = [];
|
|
|
- exportNodesData(data, nodes ? nodes : stageTree.children);
|
|
|
- SpreadExcelObj.exportSimpleXlsxSheet(exportExcelSetting, data, filename);
|
|
|
+ const data = [], groupData = [];
|
|
|
+ exportNodesData(data, nodes ? nodes : stageTree.children, groupData);
|
|
|
+ SpreadExcelObj.exportSimpleXlsxSheet(exportExcelSetting, data, filename, groupData);
|
|
|
}
|
|
|
};
|
|
|
slSpread.bind(spreadNS.Events.EditEnded, stageTreeSpreadObj.editEnded);
|