|
@@ -151,66 +151,6 @@ $(document).ready(() => {
|
|
|
compareSpread.refresh();
|
|
|
}
|
|
|
});
|
|
|
-
|
|
|
- $('#sf-select-all').click(function() {
|
|
|
- $('[name=sf-tender]').prop("checked", this.checked);
|
|
|
- });
|
|
|
- $('#select-final-ok').click(() => {
|
|
|
- const rela = [];
|
|
|
- const select = $('[name=sf-tender]:checked');
|
|
|
- for (const s of select) {
|
|
|
- rela.push(parseInt(s.getAttribute('tid')));
|
|
|
- }
|
|
|
- if (rela.length === 0) return;
|
|
|
- postData(window.location.pathname + '/final', {id: rela}, function(result) {
|
|
|
- if (spreadSetting.cols.length < 13) {
|
|
|
- spreadSetting.cols.push(...[
|
|
|
- {title: '台账|数量1/数量2', colSpan: '3|1', rowSpan: '1|1', field: 'dgn_qty', hAlign: 2, width: 80},
|
|
|
- {title: '|经济指标', colSpan: '|1', rowSpan: '|1', field: 'dgn_price', hAlign: 2, width: 80, type: 'Number'},
|
|
|
- {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'total_price', hAlign: 2, width: 80, type: 'Number'},
|
|
|
- {title: '决算|数量1/数量2', colSpan: '3|1', rowSpan: '1|1', field: 'final_dgn_qty', hAlign: 2, width: 80},
|
|
|
- {title: '|经济指标', colSpan: '|1', rowSpan: '|1', field: 'final_dgn_price', hAlign: 2, width: 80, type: 'Number'},
|
|
|
- {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'final_tp', hAlign: 2, width: 80, type: 'Number'},
|
|
|
- {title: '增幅%|数量1/数量2', colSpan: '2|1', rowSpan: '1|1', field: 'grow_dgn_qty', hAlign: 2, width: 80},
|
|
|
- {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'grow_tp', hAlign: 2, width: 80, type: 'Number'},
|
|
|
- ]);
|
|
|
- }
|
|
|
- const setting = { id: 'ledger_id', pid: 'ledger_pid', order: 'order', level: 'level', rootId: -1, calcFields: ['total_price', 'end_gather_tp'] };
|
|
|
- compareTree.clearFinal();
|
|
|
- for (const r of result) {
|
|
|
- const tree = createNewPathTree('ledger', setting);
|
|
|
- tree.loadDatas(r);
|
|
|
- treeCalc.calculateAll(tree);
|
|
|
- compareTree.loadTree(tree, function (cur, source) {
|
|
|
- cur.total_price = ZhCalc.add(cur.total_price, source.total_price);
|
|
|
- cur.dgn_qty1 = ZhCalc.add(cur.dgn_qty1, source.dgn_qty1);
|
|
|
- cur.dgn_qty2 = ZhCalc.add(cur.dgn_qty2, source.dgn_qty2);
|
|
|
- cur.final_dgn_qty1 = ZhCalc.sum([cur.final_dgn_qty1, source.deal_dgn_qty1, source.c_dgn_qty1]);
|
|
|
- cur.final_dgn_qty2 = ZhCalc.sum([cur.final_dgn_qty2, source.deal_dgn_qty2, source.c_dgn_qty2]);
|
|
|
- cur.final_tp = ZhCalc.add(cur.final_tp, source.end_gather_tp);
|
|
|
- });
|
|
|
- }
|
|
|
- compareTree.afterLoad(node => {
|
|
|
- node.dgn_price = ZhCalc.div(node.total_price, node.dgn_qty1, 2);
|
|
|
- node.dgn_qty = node.dgn_qty1
|
|
|
- ? (node.dgn_qty2 ? node.dgn_qty1 + '/' + node.dgn_qty2 : node.dgn_qty1)
|
|
|
- : (node.dgn_qty2 ? '/' + node.dgn_qty2 : '');
|
|
|
- node.final_dgn_price = ZhCalc.div(node.final_tp, node.final_dgn_qty1, 2);
|
|
|
- node.final_dgn_qty = node.final_dgn_qty1
|
|
|
- ? (node.final_dgn_qty2 ? node.final_dgn_qty1 + '/' + node.final_dgn_qty2 : node.final_dgn_qty1)
|
|
|
- : (node.final_dgn_qty2 ? '/' + node.final_dgn_qty2 : '');
|
|
|
- node.grow_dgn_qty1 = ZhCalc.mul(ZhCalc.div(ZhCalc.sub(node.final_dgn_qty1, node.gai_dgn_qty1), node.gai_dgn_qty1, 4), 100);
|
|
|
- node.grow_dgn_qty2 = ZhCalc.mul(ZhCalc.div(ZhCalc.sub(node.final_dgn_qty2, node.gai_dgn_qty2), node.gai_dgn_qty2, 4), 100);
|
|
|
- node.grow_dgn_qty = node.grow_dgn_qty1
|
|
|
- ? (node.grow_dgn_qty2 ? node.grow_dgn_qty1 + '/' + node.grow_dgn_qty2 : node.grow_dgn_qty1)
|
|
|
- : (node.grow_dgn_qty2 ? '/' + node.grow_dgn_qty2 : '');
|
|
|
- node.grow_tp = ZhCalc.mul(ZhCalc.div(ZhCalc.sub(node.final_tp, node.gai_tp), node.gai_tp, 4), 100);
|
|
|
- });
|
|
|
- SpreadJsObj.reLoadSheetHeader(compareSheet);
|
|
|
- SpreadJsObj.reLoadSheetData(compareSheet);
|
|
|
- $('#select-final').modal('hide');
|
|
|
- });
|
|
|
- });
|
|
|
// 显示层次
|
|
|
(function (select, sheet) {
|
|
|
$(select).click(function () {
|
|
@@ -239,21 +179,124 @@ $(document).ready(() => {
|
|
|
})('a[name=showLevel]', compareSheet);
|
|
|
|
|
|
|
|
|
- $('#valid-tender-list').html((function() {
|
|
|
- const html = [];
|
|
|
- const tree = Tender2Tree.convert(category, tenderList, null, null, function (node, source) {
|
|
|
- node.lastStageOrder = source.lastStageOrder;
|
|
|
- node.lastStageStatus = source.lastStageStatus;
|
|
|
- });
|
|
|
+ class sfObject {
|
|
|
+ constructor() {
|
|
|
+ const self = this;
|
|
|
+ this.selectTree = Tender2Tree.convert(category, tenderList, null, null, function (node, source) {
|
|
|
+ node.lastStageOrder =`第${source.lastStageOrder}期`;
|
|
|
+ node.lastStageStatus = source.lastStageStatus;
|
|
|
+ });
|
|
|
+ const sfSpreadSetting = {
|
|
|
+ cols: [
|
|
|
+ {title: '选择', field: 'selected', hAlign: 1, width: 40, formatter: '@', cellType: 'checkbox'},
|
|
|
+ {title: '名称', field: 'name', hAlign: 0, width: 180, formatter: '@', cellType: 'tree'},
|
|
|
+ {title: '期数', field: 'lastStageOrder', hAlign: 1, width: 60, formatter: '@'},
|
|
|
+ {title: '审批状态', field: 'lastStageStatus', hAlign: 1, width: 60, formatter: '@'},
|
|
|
+ ],
|
|
|
+ emptyRows: 0,
|
|
|
+ headRows: 1,
|
|
|
+ headRowHeight: [32],
|
|
|
+ defaultRowHeight: 21,
|
|
|
+ headerFont: '12px 微软雅黑',
|
|
|
+ font: '12px 微软雅黑',
|
|
|
+ headColWidth: [30],
|
|
|
+ selectedBackColor: '#fffacd',
|
|
|
+ readOnly: true,
|
|
|
+ };
|
|
|
+ this.spread = SpreadJsObj.createNewSpread($('#sf-spread')[0]);
|
|
|
+ this.sheet = this.spread.getActiveSheet();
|
|
|
+ SpreadJsObj.initSheet(this.sheet, sfSpreadSetting);
|
|
|
+ SpreadJsObj.loadSheetData(this.sheet, SpreadJsObj.DataType.Tree, this.selectTree);
|
|
|
+
|
|
|
+ this.spread.bind(spreadNS.Events.ButtonClicked, function (e, info) {
|
|
|
+ if (!info.sheet.zh_setting) return;
|
|
|
+
|
|
|
+ const col = info.sheet.zh_setting.cols[info.col];
|
|
|
+ if (col.field !== 'selected') return;
|
|
|
|
|
|
- for (const t of tree.nodes) {
|
|
|
- if (t.cid) {
|
|
|
- html.push(`<tr><td></td><td class="in-${t.level}"><i class="fa fa-folder-o"></i> ${t.name}</td><td></td><td></td></tr>`);
|
|
|
- } else if (t.tid) {
|
|
|
- const icon = tree.isLastSibling(t) ? '└' : '├';
|
|
|
- html.push(`<tr><td class="text-center"><input type="checkbox" name="sf-tender" tid="${t.tid}"></td><td class="in-${t.level}">${icon} ${t.name}</td><td>第${t.lastStageOrder}期</td><td>${t.lastStageStatus}</td></tr>`);
|
|
|
+ const node = SpreadJsObj.getSelectObject(info.sheet);
|
|
|
+ self.selectNode(node, !node[col.field]);
|
|
|
+ SpreadJsObj.reloadColData(info.sheet, 0);
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ $('#sf-select-all').click(function() {
|
|
|
+ for (const n of self.selectTree.nodes) {
|
|
|
+ n.selected = this.checked;
|
|
|
+ }
|
|
|
+ SpreadJsObj.reloadColData(self.sheet, 0);
|
|
|
+ });
|
|
|
+ $('#select-final-ok').click(() => {
|
|
|
+ const rela = self.getSelects();
|
|
|
+ if (rela.length === 0) return;
|
|
|
+ postData(window.location.pathname + '/final', {id: rela}, function(result) {
|
|
|
+ if (spreadSetting.cols.length < 13) {
|
|
|
+ spreadSetting.cols.push(...[
|
|
|
+ {title: '台账|数量1/数量2', colSpan: '3|1', rowSpan: '1|1', field: 'dgn_qty', hAlign: 2, width: 80},
|
|
|
+ {title: '|经济指标', colSpan: '|1', rowSpan: '|1', field: 'dgn_price', hAlign: 2, width: 80, type: 'Number'},
|
|
|
+ {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'total_price', hAlign: 2, width: 80, type: 'Number'},
|
|
|
+ {title: '决算|数量1/数量2', colSpan: '3|1', rowSpan: '1|1', field: 'final_dgn_qty', hAlign: 2, width: 80},
|
|
|
+ {title: '|经济指标', colSpan: '|1', rowSpan: '|1', field: 'final_dgn_price', hAlign: 2, width: 80, type: 'Number'},
|
|
|
+ {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'final_tp', hAlign: 2, width: 80, type: 'Number'},
|
|
|
+ {title: '增幅%|数量1/数量2', colSpan: '2|1', rowSpan: '1|1', field: 'grow_dgn_qty', hAlign: 2, width: 80},
|
|
|
+ {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'grow_tp', hAlign: 2, width: 80, type: 'Number'},
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+ const setting = { id: 'ledger_id', pid: 'ledger_pid', order: 'order', level: 'level', rootId: -1, calcFields: ['total_price', 'end_gather_tp'] };
|
|
|
+ compareTree.clearFinal();
|
|
|
+ for (const r of result) {
|
|
|
+ const tree = createNewPathTree('ledger', setting);
|
|
|
+ tree.loadDatas(r);
|
|
|
+ treeCalc.calculateAll(tree);
|
|
|
+ compareTree.loadTree(tree, function (cur, source) {
|
|
|
+ cur.total_price = ZhCalc.add(cur.total_price, source.total_price);
|
|
|
+ cur.dgn_qty1 = ZhCalc.add(cur.dgn_qty1, source.dgn_qty1);
|
|
|
+ cur.dgn_qty2 = ZhCalc.add(cur.dgn_qty2, source.dgn_qty2);
|
|
|
+ cur.final_dgn_qty1 = ZhCalc.sum([cur.final_dgn_qty1, source.deal_dgn_qty1, source.c_dgn_qty1]);
|
|
|
+ cur.final_dgn_qty2 = ZhCalc.sum([cur.final_dgn_qty2, source.deal_dgn_qty2, source.c_dgn_qty2]);
|
|
|
+ cur.final_tp = ZhCalc.add(cur.final_tp, source.end_gather_tp);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ compareTree.afterLoad(node => {
|
|
|
+ node.dgn_price = ZhCalc.div(node.total_price, node.dgn_qty1, 2);
|
|
|
+ node.dgn_qty = node.dgn_qty1
|
|
|
+ ? (node.dgn_qty2 ? node.dgn_qty1 + '/' + node.dgn_qty2 : node.dgn_qty1)
|
|
|
+ : (node.dgn_qty2 ? '/' + node.dgn_qty2 : '');
|
|
|
+ node.final_dgn_price = ZhCalc.div(node.final_tp, node.final_dgn_qty1, 2);
|
|
|
+ node.final_dgn_qty = node.final_dgn_qty1
|
|
|
+ ? (node.final_dgn_qty2 ? node.final_dgn_qty1 + '/' + node.final_dgn_qty2 : node.final_dgn_qty1)
|
|
|
+ : (node.final_dgn_qty2 ? '/' + node.final_dgn_qty2 : '');
|
|
|
+ node.grow_dgn_qty1 = ZhCalc.mul(ZhCalc.div(ZhCalc.sub(node.final_dgn_qty1, node.gai_dgn_qty1), node.gai_dgn_qty1, 4), 100);
|
|
|
+ node.grow_dgn_qty2 = ZhCalc.mul(ZhCalc.div(ZhCalc.sub(node.final_dgn_qty2, node.gai_dgn_qty2), node.gai_dgn_qty2, 4), 100);
|
|
|
+ node.grow_dgn_qty = node.grow_dgn_qty1
|
|
|
+ ? (node.grow_dgn_qty2 ? node.grow_dgn_qty1 + '/' + node.grow_dgn_qty2 : node.grow_dgn_qty1)
|
|
|
+ : (node.grow_dgn_qty2 ? '/' + node.grow_dgn_qty2 : '');
|
|
|
+ node.grow_tp = ZhCalc.mul(ZhCalc.div(ZhCalc.sub(node.final_tp, node.gai_tp), node.gai_tp, 4), 100);
|
|
|
+ });
|
|
|
+ SpreadJsObj.reLoadSheetHeader(compareSheet);
|
|
|
+ SpreadJsObj.reLoadSheetData(compareSheet);
|
|
|
+ $('#select-final').modal('hide');
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+ selectNode(node, select) {
|
|
|
+ const posterity = this.selectTree.getPosterity(node);
|
|
|
+ posterity.unshift(node);
|
|
|
+ for (const p of posterity) {
|
|
|
+ p.selected = select;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ getSelects() {
|
|
|
+ const select = [];
|
|
|
+ for (const n of this.selectTree.nodes) {
|
|
|
+ if ((!n.children || n.children.length === 0) && n.selected) select.push(n.tid);
|
|
|
}
|
|
|
+ return select;
|
|
|
}
|
|
|
- return html.join('');
|
|
|
- })());
|
|
|
+ }
|
|
|
+
|
|
|
+ let sfSelect;
|
|
|
+ $('#select-final').on('shown.bs.modal', () => {
|
|
|
+ if (!sfSelect) sfSelect = new sfObject();
|
|
|
+ });
|
|
|
});
|