|
@@ -200,6 +200,27 @@ $(function () {
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
+ reCalcHuizong: function(row, yearmonth, orgValue, validText) {
|
|
|
+ // 下方汇总sjs实时更新计量数据
|
|
|
+ // 先判断当前修改月份与汇总sjs月份是否一致或更大,获取修改的对应台账行
|
|
|
+ const huizongSelect = SpreadJsObj.getRowObject(huizongSpread.getActiveSheet(), row);
|
|
|
+ if (yearmonth.split('-')[0] === curScheduleMonth.yearmonth.split('-')[0]) {
|
|
|
+ huizongSelect.year_sj_gcl = ZhCalc.add(ZhCalc.sub(huizongSelect.year_sj_gcl, orgValue), validText);
|
|
|
+ huizongSelect.year_sj_tp = huizongSelect.dgn_price && huizongSelect.dgn_price !== 0 ? ZhCalc.round(ZhCalc.mul(huizongSelect.year_sj_gcl, huizongSelect.dgn_price), 0) : 0;
|
|
|
+ }
|
|
|
+ if (yearmonth === curScheduleMonth.yearmonth) {
|
|
|
+ // 判断是否同年同月,是则修改本年,截至本月,本月计量数据,否则只修改截至本月计量数据
|
|
|
+ huizongSelect.sj_gcl = validText;
|
|
|
+ huizongSelect.sj_tp = huizongSelect.dgn_price && huizongSelect.dgn_price !== 0 ? ZhCalc.round(ZhCalc.mul(huizongSelect.sj_gcl, huizongSelect.dgn_price), 0) : 0;
|
|
|
+ }
|
|
|
+ if (yearmonth <= curScheduleMonth.yearmonth) {
|
|
|
+ huizongSelect.end_sj_gcl = ZhCalc.add(ZhCalc.sub(huizongSelect.end_sj_gcl, orgValue), validText);
|
|
|
+ huizongSelect.end_sj_tp = huizongSelect.dgn_price && huizongSelect.dgn_price !== 0 ? ZhCalc.round(ZhCalc.mul(huizongSelect.end_sj_gcl, huizongSelect.dgn_price), 0) : 0;
|
|
|
+ }
|
|
|
+ const nodes = treeCalc.calculateParent(huizongSpread.getActiveSheet().zh_tree, huizongSelect);
|
|
|
+ const refreshNode = huizongTree.loadPostData({update: nodes});
|
|
|
+ huizongObj.refreshTree(huizongSpread.getActiveSheet(), refreshNode);
|
|
|
+ },
|
|
|
editEnded: function (e, info) {
|
|
|
if (info.sheet.zh_setting) {
|
|
|
const select = SpreadJsObj.getSelectObject(info.sheet);
|
|
@@ -239,6 +260,7 @@ $(function () {
|
|
|
const nodes = treeCalc.calculateParent(info.sheet.zh_tree, select);
|
|
|
const refreshNode = ledgerTree.loadPostData({update: nodes});
|
|
|
ledgerSpreadObj.refreshTree(info.sheet, refreshNode);
|
|
|
+ ledgerSpreadObj.reCalcHuizong(info.row, yearmonth, orgValue, validText);
|
|
|
},function () {
|
|
|
select[col.field] = orgValue;
|
|
|
const nodes = treeCalc.calculateParent(info.sheet.zh_tree, select);
|
|
@@ -279,6 +301,7 @@ $(function () {
|
|
|
const nodes = treeCalc.calculateParent(sheet.zh_tree, select);
|
|
|
const refreshNode = ledgerTree.loadPostData({update: nodes});
|
|
|
ledgerSpreadObj.refreshTree(sheet, refreshNode);
|
|
|
+ ledgerSpreadObj.reCalcHuizong(info.row, yearmonth, orgValue, validText);
|
|
|
},function () {
|
|
|
select[col.field] = orgValue;
|
|
|
const nodes = treeCalc.calculateParent(sheet.zh_tree, select);
|
|
@@ -336,6 +359,7 @@ $(function () {
|
|
|
const nodes = treeCalc.calculateParent(info.sheet.zh_tree, select);
|
|
|
const refreshNode = ledgerTree.loadPostData({update: nodes});
|
|
|
ledgerSpreadObj.refreshTree(info.sheet, refreshNode);
|
|
|
+ ledgerSpreadObj.reCalcHuizong(info.row, yearmonth, orgValue, validText);
|
|
|
},function () {
|
|
|
select[col.field] = orgValue;
|
|
|
const nodes = treeCalc.calculateParent(info.sheet.zh_tree, select);
|
|
@@ -362,7 +386,7 @@ $(function () {
|
|
|
calcFun: function (node) {
|
|
|
node.dgn_price = ZhCalc.round(ZhCalc.div(node.total_price, node.dgn_qty1), 2);
|
|
|
},
|
|
|
- calcFields: ['plan_tp', 'next_plan_tp', 'end_plan_tp', 'year_plan_tp', 'total_price', 'end_gather_tp', 'year_gather_tp', 'gather_tp'],
|
|
|
+ calcFields: ['plan_tp', 'next_plan_tp', 'end_plan_tp', 'year_plan_tp', 'total_price', 'end_sj_tp', 'year_sj_tp', 'sj_tp'],
|
|
|
};
|
|
|
|
|
|
const huizong_static_cols = [
|
|
@@ -374,14 +398,16 @@ $(function () {
|
|
|
{title: '|金额(元)', colSpan: '|1', rowSpan: '|1', field: 'total_price', hAlign: 2, width: 70, type: 'Number', readOnly: true},
|
|
|
{title: '自开工至本月计划完成|工程量', colSpan: '2|1', rowSpan: '1|1', field: 'end_plan_gcl', hAlign: 2, width: 70, type: 'Number', readOnly: true},
|
|
|
{title: '|金额(元)', colSpan: '|1', rowSpan: '|1', field: 'end_plan_tp', hAlign: 2, width: 70, type: 'Number', readOnly: true},
|
|
|
- {title: '截止本月完成计量|工程量', colSpan: '2|1', rowSpan: '1|1', field: 'end_gather_qty', hAlign: 2, width: 70, type: 'Number', readOnly: true},
|
|
|
- {title: '|金额(元)', colSpan: '|1', rowSpan: '|1', field: 'end_gather_tp', hAlign: 2, width: 70, type: 'Number', readOnly: true},
|
|
|
+ {title: '截止本月完成计量|工程量', colSpan: '2|1', rowSpan: '1|1', field: 'end_sj_gcl', hAlign: 2, width: 70, type: 'Number', readOnly: true},
|
|
|
+ {title: '|金额(元)', colSpan: '|1', rowSpan: '|1', field: 'end_sj_tp', hAlign: 2, width: 70, type: 'Number', readOnly: true},
|
|
|
{title: '本年计划完成|工程量', colSpan: '2|1', rowSpan: '1|1', field: 'year_plan_gcl', hAlign: 2, width: 70, type: 'Number', readOnly: true},
|
|
|
{title: '|金额(元)', colSpan: '|1', rowSpan: '|1', field: 'year_plan_tp', hAlign: 2, width: 70, type: 'Number', readOnly: true},
|
|
|
- {title: '本年累计完成|工程量', colSpan: '2|1', rowSpan: '1|1', field: 'year_contract_qty', hAlign: 2, width: 70, type: 'Number', readOnly: true},
|
|
|
- {title: '|金额(元)', colSpan: '|1', rowSpan: '|1', field: 'year_gather_tp', hAlign: 2, width: 70, type: 'Number', readOnly: true},
|
|
|
+ {title: '本年累计完成|工程量', colSpan: '2|1', rowSpan: '1|1', field: 'year_sj_gcl', hAlign: 2, width: 70, type: 'Number', readOnly: true},
|
|
|
+ {title: '|金额(元)', colSpan: '|1', rowSpan: '|1', field: 'year_sj_tp', hAlign: 2, width: 70, type: 'Number', readOnly: true},
|
|
|
{title: '本月计划完成|工程量', colSpan: '2|1', rowSpan: '1|1', field: 'plan_gcl', hAlign: 2, width: 70, type: 'Number', readOnly: true},
|
|
|
{title: '|金额(元)', colSpan: '|1', rowSpan: '|1', field: 'plan_tp', hAlign: 2, width: 70, type: 'Number', readOnly: true},
|
|
|
+ {title: '本月计量完成|工程量', colSpan: '2|1', rowSpan: '1|1', field: 'sj_gcl', hAlign: 2, width: 70, type: 'Number', readOnly: true},
|
|
|
+ {title: '|金额(元)', colSpan: '|1', rowSpan: '|1', field: 'sj_tp', hAlign: 2, width: 70, type: 'Number', readOnly: true},
|
|
|
{title: '下月计划|工程量', colSpan: '2|1', rowSpan: '1|1', field: 'next_plan_gcl', hAlign: 2, width: 70, type: 'Number', readOnly: true},
|
|
|
{title: '|金额(元)', colSpan: '|1', rowSpan: '|1', field: 'next_plan_tp', hAlign: 2, width: 70, type: 'Number', readOnly: true},
|
|
|
];
|
|
@@ -408,17 +434,65 @@ $(function () {
|
|
|
huizongSpread.getActiveSheet().frozenColumnCount(6);
|
|
|
huizongSpread.getActiveSheet().options.frozenlineColor = '#93b5e4';
|
|
|
|
|
|
+ let huizongTree = '';
|
|
|
+
|
|
|
const huizongObj = {
|
|
|
+ refreshTree: function (sheet, data) {
|
|
|
+ SpreadJsObj.massOperationSheet(sheet, function () {
|
|
|
+ const tree = sheet.zh_tree;
|
|
|
+ // 处理删除
|
|
|
+ if (data.delete) {
|
|
|
+ data.delete.sort(function (x, y) {
|
|
|
+ return y.deleteIndex - x.deleteIndex;
|
|
|
+ });
|
|
|
+ for (const d of data.delete) {
|
|
|
+ sheet.deleteRows(d.deleteIndex, 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 处理新增
|
|
|
+ if (data.create) {
|
|
|
+ const newNodes = data.create;
|
|
|
+ if (newNodes) {
|
|
|
+ newNodes.sort(function (a, b) {
|
|
|
+ return a.index - b.index;
|
|
|
+ });
|
|
|
+
|
|
|
+ for (const node of newNodes) {
|
|
|
+ sheet.addRows(node.index, 1);
|
|
|
+ SpreadJsObj.reLoadRowData(sheet, tree.nodes.indexOf(node), 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 处理更新
|
|
|
+ if (data.update) {
|
|
|
+ const rows = [];
|
|
|
+ for (const u of data.update) {
|
|
|
+ rows.push(tree.nodes.indexOf(u));
|
|
|
+ }
|
|
|
+ SpreadJsObj.reLoadRowsData(sheet, rows);
|
|
|
+ }
|
|
|
+ // 处理展开
|
|
|
+ if (data.expand) {
|
|
|
+ const expanded = [];
|
|
|
+ for (const e of data.expand) {
|
|
|
+ if (expanded.indexOf(e) === -1) {
|
|
|
+ const posterity = tree.getPosterity(e);
|
|
|
+ for (const p of posterity) {
|
|
|
+ sheet.setRowVisible(tree.nodes.indexOf(p), p.visible);
|
|
|
+ expanded.push(p);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
setSjs: function (order) {
|
|
|
- postData('/tender/' + getTenderId() + '/schedule/stage/' + order + '/load', {filter: 'gcl' }, function (data) {
|
|
|
- const calcList = ['year_gather_tp',
|
|
|
- 'contract_tp', 'qc_qty', 'qc_tp', 'total_price', 'contract_tp', 'qc_tp', 'gather_tp',
|
|
|
- 'pre_contract_tp', 'pre_qc_tp', 'pre_gather_tp', 'end_contract_tp', 'end_qc_tp', 'end_gather_tp', 'end_correct_tp'];
|
|
|
+ postData('/tender/' + getTenderId() + '/schedule/stage/gcl/' + order + '/load', {}, function (data) {
|
|
|
+ const calcList = ['total_price'];
|
|
|
const showList = ['plan_gcl', 'plan_tp', 'next_plan_gcl', 'next_plan_tp', 'end_plan_gcl', 'end_plan_tp', 'year_plan_gcl', 'year_plan_tp',
|
|
|
- 'year_contract_qty', 'year_gather_tp',
|
|
|
- 'contract_qty', 'end_gather_qty', 'contract_tp', 'qc_qty', 'qc_tp', 'ledger_id', 'ledger_pid', 'order', 'level', 'tender_id', 'full_path',
|
|
|
- 'code', 'name', 'unit', 'dgn_qty1', 'dgn_qty2', 'dgn_price', 'quantity', 'total_price', 'contract_tp', 'qc_tp', 'gather_tp',
|
|
|
- 'pre_contract_tp', 'pre_qc_tp', 'pre_gather_tp', 'end_contract_tp', 'end_qc_tp', 'end_gather_tp', 'end_correct_tp'];
|
|
|
+ 'sj_gcl', 'sj_tp', 'year_sj_gcl', 'year_sj_tp', 'end_sj_gcl', 'end_sj_tp',
|
|
|
+ 'ledger_id', 'ledger_pid', 'order', 'level', 'tender_id', 'full_path',
|
|
|
+ 'code', 'name', 'unit', 'dgn_qty1', 'dgn_qty2', 'dgn_price', 'quantity', 'total_price'];
|
|
|
const baseLedgerTreeSetting = {
|
|
|
id: 'ledger_id',
|
|
|
pid: 'ledger_pid',
|
|
@@ -428,38 +502,16 @@ $(function () {
|
|
|
fullPath: 'full_path',
|
|
|
calcFields: calcList,
|
|
|
};
|
|
|
- baseLedgerTreeSetting.updateFields = ['year_contract_qty', 'year_gather_tp', 'contract_qty', 'end_gather_qty', 'contract_tp', 'qc_qty', 'qc_tp', 'postil', 'used', 'contract_expr'];
|
|
|
+ // baseLedgerTreeSetting.updateFields = ['year_sj_qty', 'year_gather_tp', 'contract_qty', 'end_gather_qty', 'contract_tp', 'qc_qty', 'qc_tp', 'postil', 'used', 'contract_expr'];
|
|
|
baseLedgerTreeSetting.calcFun = function (node) {
|
|
|
- if (!node.children || node.children.length === 0) {
|
|
|
- node.pre_gather_qty = ZhCalc.add(node.pre_contract_qty, node.pre_qc_qty);
|
|
|
- node.gather_qty = ZhCalc.add(node.contract_qty, node.qc_qty);
|
|
|
- node.end_contract_qty = ZhCalc.add(node.pre_contract_qty, node.contract_qty);
|
|
|
- node.end_qc_qty = ZhCalc.add(node.pre_qc_qty, node.qc_qty);
|
|
|
- node.end_gather_qty = ZhCalc.add(node.pre_gather_qty, node.gather_qty);
|
|
|
- }
|
|
|
- node.pre_gather_tp = ZhCalc.add(node.pre_contract_tp, node.pre_qc_tp);
|
|
|
- node.gather_tp = ZhCalc.add(node.contract_tp, node.qc_tp);
|
|
|
- node.end_contract_tp = ZhCalc.add(node.pre_contract_tp, node.contract_tp);
|
|
|
- node.end_qc_tp = ZhCalc.add(node.pre_qc_tp, node.qc_tp);
|
|
|
- node.end_gather_tp = ZhCalc.add(node.pre_gather_tp, node.gather_tp);
|
|
|
- node.end_final_tp = ZhCalc.add(node.end_qc_tp, node.total_price);
|
|
|
- if (!node.children || node.children.length === 0) {
|
|
|
- if (node.end_contract_qty) {
|
|
|
- node.end_correct_tp = ZhCalc.add(node.end_qc_tp, ZhCalc.mul(node.end_contract_qty, node.unit_price, tenderInfo.decimal.tp));
|
|
|
- } else {
|
|
|
- node.end_correct_tp = node.end_gather_tp;
|
|
|
- }
|
|
|
- }
|
|
|
- node.end_gather_percent = ZhCalc.mul(ZhCalc.div(node.end_gather_tp, node.end_final_tp), 100, 2);
|
|
|
- node.end_correct_percent = ZhCalc.mul(ZhCalc.div(node.end_correct_tp, node.end_final_tp), 100, 2);
|
|
|
- node.final_dgn_price = ZhCalc.round(ZhCalc.div(node.end_gather_tp, ZhCalc.add(node.deal_dgn_qty1, node.c_dgn_qty1)), tenderInfo.decimal.up);
|
|
|
node.dgn_price = ZhCalc.round(ZhCalc.div(node.total_price, node.dgn_qty1), 2);
|
|
|
};
|
|
|
const baseLedgerTree = createNewPathTree('base', baseLedgerTreeSetting);
|
|
|
- const newLedgerList = setTpMonthToLedger(data.ledgerData, data.slmList, data.nextSlmList, data.endSlmList, data.yearSlmList, data.curYearStageData);
|
|
|
+ console.log(data.slmList);
|
|
|
+ const newLedgerList = setGclMonthToLedger(data.ledgerData, data.slmList, data.nextSlmList, data.endSlmList, data.yearSlmList);
|
|
|
baseLedgerTree.loadDatas(newLedgerList);
|
|
|
treeCalc.calculateAll(baseLedgerTree);
|
|
|
- const huizongTree = createNewPathTree('filter', huizongTreeSetting);
|
|
|
+ huizongTree = createNewPathTree('filter', huizongTreeSetting);
|
|
|
for (const d of baseLedgerTree.nodes) {
|
|
|
if (!d.b_code) {
|
|
|
const one = _.find(selectedLedgerList, function (item) {
|
|
@@ -474,26 +526,29 @@ $(function () {
|
|
|
treeCalc.calculateAll(huizongTree);
|
|
|
console.log(huizongTree);
|
|
|
SpreadJsObj.loadSheetData(huizongSpread.getActiveSheet(), SpreadJsObj.DataType.Tree, huizongTree);
|
|
|
+ // huizongSpread.refresh();
|
|
|
}, null, true);
|
|
|
},
|
|
|
dropDownHtml: function (order) {
|
|
|
let html = '';
|
|
|
- for (const ss of scheduleStage) {
|
|
|
- if (ss.order !== order) {
|
|
|
- html += '<a class="dropdown-item change-tp" data-order="'+ ss.order +'" href="javascript:void(0);">'+ ss.yearmonth.split('-')[0] + '年' + parseInt(ss.yearmonth.split('-')[1]) +'月(第'+ ss.order +'期)</a>';
|
|
|
+ for (const ss of gclScheduleMonth) {
|
|
|
+ if (ss.id !== order) {
|
|
|
+ html += '<a class="dropdown-item change-tp" data-order="'+ ss.id +'" href="javascript:void(0);">'+ ss.yearmonth.split('-')[0] + '年' + parseInt(ss.yearmonth.split('-')[1]) +'月</a>';
|
|
|
} else {
|
|
|
- $('#stageDropdownMenuButton').text(ss.yearmonth.split('-')[0] + '年' + parseInt(ss.yearmonth.split('-')[1]) +'月(第'+ ss.order +'期)');
|
|
|
+ $('#stageDropdownMenuButton').text(ss.yearmonth.split('-')[0] + '年' + parseInt(ss.yearmonth.split('-')[1]) +'月');
|
|
|
}
|
|
|
}
|
|
|
$('#stageDropdownMenu').html(html);
|
|
|
}
|
|
|
};
|
|
|
|
|
|
- if (curScheduleStage && curScheduleStage.order) {
|
|
|
- let order = parseInt(localStorage.getItem('tender_' + getTenderId() + '_schedule_tp_sjs') ? localStorage.getItem('tender_' + getTenderId() + '_schedule_tp_sjs') : curScheduleStage.order);
|
|
|
- const ssinfo = _.find(scheduleStage, { order });
|
|
|
+ if (curScheduleMonth && curScheduleMonth.id) {
|
|
|
+ let order = parseInt(localStorage.getItem('tender_' + getTenderId() + '_schedule_tp_sjs') ? localStorage.getItem('tender_' + getTenderId() + '_schedule_tp_sjs') : curScheduleMonth.id);
|
|
|
+ const ssinfo = _.find(gclScheduleMonth, { id: order });
|
|
|
if (!ssinfo) {
|
|
|
- order = curScheduleStage.order;
|
|
|
+ order = curScheduleMonth.id;
|
|
|
+ } else {
|
|
|
+ curScheduleMonth = ssinfo;
|
|
|
}
|
|
|
huizongObj.dropDownHtml(order);
|
|
|
huizongObj.setSjs(order);
|
|
@@ -505,6 +560,7 @@ $(function () {
|
|
|
huizongObj.dropDownHtml(order);
|
|
|
huizongObj.setSjs(order);
|
|
|
localStorage.setItem('tender_' + getTenderId() + '_schedule_tp_sjs', order);
|
|
|
+ curScheduleMonth = _.find(gclScheduleMonth, { id: order });
|
|
|
});
|
|
|
|
|
|
// 月份添加
|
|
@@ -616,13 +672,15 @@ function setMonthToLedger(ledgerList, slm) {
|
|
|
}
|
|
|
return ledgerList;
|
|
|
}
|
|
|
-function setTpMonthToLedger(ledgerList, slm, nextSlm, endSlm, yearSlm, yearLedgerData) {
|
|
|
+function setGclMonthToLedger(ledgerList, slm, nextSlm, endSlm, yearSlm) {
|
|
|
if (slm.length > 0) {
|
|
|
for(const s of slm) {
|
|
|
const index = _.findIndex(ledgerList, { 'ledger_id': s.lid });
|
|
|
if (index && index !== -1) {
|
|
|
ledgerList[index].plan_tp = s.plan_tp;
|
|
|
ledgerList[index].plan_gcl = s.plan_gcl;
|
|
|
+ ledgerList[index].sj_tp = s.sj_tp;
|
|
|
+ ledgerList[index].sj_gcl = s.sj_gcl;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -641,6 +699,8 @@ function setTpMonthToLedger(ledgerList, slm, nextSlm, endSlm, yearSlm, yearLedge
|
|
|
if (index && index !== -1) {
|
|
|
ledgerList[index].end_plan_tp = es.plan_tp;
|
|
|
ledgerList[index].end_plan_gcl = es.plan_gcl;
|
|
|
+ ledgerList[index].end_sj_tp = es.sj_tp;
|
|
|
+ ledgerList[index].end_sj_gcl = es.sj_gcl;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -650,15 +710,8 @@ function setTpMonthToLedger(ledgerList, slm, nextSlm, endSlm, yearSlm, yearLedge
|
|
|
if (index && index !== -1) {
|
|
|
ledgerList[index].year_plan_tp = ys.plan_tp;
|
|
|
ledgerList[index].year_plan_gcl = ys.plan_gcl;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if (yearLedgerData.length > 0) {
|
|
|
- for (const yl of yearLedgerData) {
|
|
|
- const index = _.findIndex(ledgerList, {'id': yl.lid});
|
|
|
- if (index && index !== -1) {
|
|
|
- ledgerList[index].year_contract_qty = ZhCalc.add(yl.contract_qty, yl.qc_qty);
|
|
|
- ledgerList[index].year_gather_tp = ZhCalc.add(yl.contract_tp, yl.qc_tp);
|
|
|
+ ledgerList[index].year_sj_tp = ys.sj_tp;
|
|
|
+ ledgerList[index].year_sj_gcl = ys.sj_gcl;
|
|
|
}
|
|
|
}
|
|
|
}
|