|  | @@ -289,6 +289,149 @@ $(function () {
 | 
	
		
			
				|  |  |      SpreadJsObj.addDeleteBind(ledgerSpread, ledgerSpreadObj.deletePress);
 | 
	
		
			
				|  |  |      ledgerSpread.bind(spreadNS.Events.ClipboardPasted, ledgerSpreadObj.clipboardPasted);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    // 下方金额模式的sjs
 | 
	
		
			
				|  |  | +    const huizongSpread = SpreadJsObj.createNewSpread($('#huizong-spread')[0]);
 | 
	
		
			
				|  |  | +    const huizongTreeSetting = {
 | 
	
		
			
				|  |  | +        id: 'ledger_id',
 | 
	
		
			
				|  |  | +        pid: 'ledger_pid',
 | 
	
		
			
				|  |  | +        order: 'order',
 | 
	
		
			
				|  |  | +        level: 'level',
 | 
	
		
			
				|  |  | +        rootId: -1,
 | 
	
		
			
				|  |  | +        fullPath: 'full_path',
 | 
	
		
			
				|  |  | +        calcFields: ['plan_gcl', 'plan_tp', 'next_plan_gcl', 'next_plan_tp', 'end_plan_gcl', 'end_plan_tp', 'year_plan_gcl', 'year_plan_tp'],
 | 
	
		
			
				|  |  | +    };
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    const huizong_static_cols = [
 | 
	
		
			
				|  |  | +        {title: '编号', colSpan: '1', rowSpan: '2', field: 'code', hAlign: 0, width: 145, formatter: '@', readOnly: true, cellType: 'tree'},
 | 
	
		
			
				|  |  | +        {title: '名称', colSpan: '1', rowSpan: '2', field: 'name', hAlign: 0, width: 185, formatter: '@', readOnly: true},
 | 
	
		
			
				|  |  | +        {title: '单位', colSpan: '1', rowSpan: '2', field: 'unit', hAlign: 1, width: 50, formatter: '@', readOnly: true},
 | 
	
		
			
				|  |  | +        {title: '经济指标', colSpan: '1', rowSpan: '2', field: 'dgn_price', hAlign: 2, width: 60, type: 'Number', readOnly: true},
 | 
	
		
			
				|  |  | +        {title: '总设计|工程量', colSpan: '2|1', rowSpan: '1|1', field: 'dgn_qty1', hAlign: 2, width: 70, type: 'Number', readOnly: true},
 | 
	
		
			
				|  |  | +        {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: '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: '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: '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},
 | 
	
		
			
				|  |  | +    ];
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    const huizongSpreadSetting = {
 | 
	
		
			
				|  |  | +        emptyRows: 0,
 | 
	
		
			
				|  |  | +        headRows: 2,
 | 
	
		
			
				|  |  | +        headRowHeight: [25, 25],
 | 
	
		
			
				|  |  | +        defaultRowHeight: 21,
 | 
	
		
			
				|  |  | +        headerFont: '12px 微软雅黑',
 | 
	
		
			
				|  |  | +        font: '12px 微软雅黑',
 | 
	
		
			
				|  |  | +        // readOnly: true,
 | 
	
		
			
				|  |  | +        localCache: {
 | 
	
		
			
				|  |  | +            key: 'ledger-bills',
 | 
	
		
			
				|  |  | +            colWidth: true,
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    };
 | 
	
		
			
				|  |  | +    huizongSpreadSetting.cols = huizong_static_cols;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    sjsSettingObj.setFxTreeStyle(huizongSpreadSetting, sjsSettingObj.FxTreeStyle.jz);
 | 
	
		
			
				|  |  | +    if (thousandth) sjsSettingObj.setTpThousandthFormat(huizongSpreadSetting);
 | 
	
		
			
				|  |  | +    SpreadJsObj.initSheet(huizongSpread.getActiveSheet(), huizongSpreadSetting);
 | 
	
		
			
				|  |  | +    SpreadJsObj.selChangedRefreshBackColor(huizongSpread.getActiveSheet());
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    const huizongObj = {
 | 
	
		
			
				|  |  | +        setSjs: function (order) {
 | 
	
		
			
				|  |  | +            postData('/tender/' + getTenderId() + '/measure/stage/' + order + '/load', { filter: 'ledger' }, function (data) {
 | 
	
		
			
				|  |  | +                postData('/tender/' + getTenderId() + '/schedule/stage/' + order + '/load', {}, function (data2) {
 | 
	
		
			
				|  |  | +                    const calcList = ['year_contract_qty', 'year_gather_tp',
 | 
	
		
			
				|  |  | +                        'contract_qty', 'end_gather_qty', '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'];
 | 
	
		
			
				|  |  | +                    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'];
 | 
	
		
			
				|  |  | +                    const baseLedgerTreeSetting = {
 | 
	
		
			
				|  |  | +                        id: 'ledger_id',
 | 
	
		
			
				|  |  | +                        pid: 'ledger_pid',
 | 
	
		
			
				|  |  | +                        order: 'order',
 | 
	
		
			
				|  |  | +                        level: 'level',
 | 
	
		
			
				|  |  | +                        rootId: -1,
 | 
	
		
			
				|  |  | +                        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.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, data2.slmList, data2.nextSlmList, data2.endSlmList, data2.yearSlmList, data2.curYearStageData);
 | 
	
		
			
				|  |  | +                    baseLedgerTree.loadDatas(newLedgerList);
 | 
	
		
			
				|  |  | +                    treeCalc.calculateAll(baseLedgerTree);
 | 
	
		
			
				|  |  | +                    const huizongTree = createNewPathTree('filter', huizongTreeSetting);
 | 
	
		
			
				|  |  | +                    for (const d of baseLedgerTree.nodes) {
 | 
	
		
			
				|  |  | +                        if (!d.b_code) {
 | 
	
		
			
				|  |  | +                            const one = _.find(selectedLedgerList, function (item) {
 | 
	
		
			
				|  |  | +                                return item === d.ledger_id;
 | 
	
		
			
				|  |  | +                            });
 | 
	
		
			
				|  |  | +                            if (one) {
 | 
	
		
			
				|  |  | +                                huizongTree.addData(d, showList);
 | 
	
		
			
				|  |  | +                            }
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                    huizongTree.sortTreeNode(true);
 | 
	
		
			
				|  |  | +                    treeCalc.calculateAll(huizongTree);
 | 
	
		
			
				|  |  | +                    console.log(huizongTree);
 | 
	
		
			
				|  |  | +                    SpreadJsObj.loadSheetData(huizongSpread.getActiveSheet(), SpreadJsObj.DataType.Tree, huizongTree);
 | 
	
		
			
				|  |  | +                }, null, true);
 | 
	
		
			
				|  |  | +            }, null, true);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    };
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    if (curScheduleStage && curScheduleStage.order) {
 | 
	
		
			
				|  |  | +        huizongObj.setSjs(curScheduleStage.order);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    // 汇总切换
 | 
	
		
			
				|  |  | +    $('body').on('click', '.change-tp', function () {
 | 
	
		
			
				|  |  | +        const order = parseInt($(this).data('order'));
 | 
	
		
			
				|  |  | +        $('#dropdownMenuButton').text($(this).text());
 | 
	
		
			
				|  |  | +        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>';
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        $('.dropdown-menu').html(html);
 | 
	
		
			
				|  |  | +        huizongObj.setSjs(order);
 | 
	
		
			
				|  |  | +    });
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      // 月份添加
 | 
	
		
			
				|  |  |      $('#add-month').click(function () {
 | 
	
		
			
				|  |  |          const id = parseInt($('#month-select').val());
 | 
	
	
		
			
				|  | @@ -354,8 +497,9 @@ $(function () {
 | 
	
		
			
				|  |  |                  $('.panel-title').removeClass('fluid');
 | 
	
		
			
				|  |  |                  $('#sub-menu').addClass('panel-sidebar');
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | -            ledgerSpread.refresh();
 | 
	
		
			
				|  |  |              autoFlashHeight();
 | 
	
		
			
				|  |  | +            ledgerSpread.refresh();
 | 
	
		
			
				|  |  | +            huizongSpread.refresh();
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      });
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -364,8 +508,9 @@ $(function () {
 | 
	
		
			
				|  |  |          callback: function () {
 | 
	
		
			
				|  |  |              ledgerSpread.refresh();
 | 
	
		
			
				|  |  |              let bcontent = $(".bcontent-wrap") ? $(".bcontent-wrap").height() : 0;
 | 
	
		
			
				|  |  | -            $(".tab-content").height(bcontent-30);
 | 
	
		
			
				|  |  | -            // posSpread.refresh();
 | 
	
		
			
				|  |  | +            $(".sp-wrap").height(bcontent-30);
 | 
	
		
			
				|  |  | +            huizongSpread.refresh();
 | 
	
		
			
				|  |  | +            window.getSelection ? window.getSelection().removeAllRanges() : document.selection.empty();
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      });
 | 
	
		
			
				|  |  |  });
 | 
	
	
		
			
				|  | @@ -396,6 +541,54 @@ function setMonthToLedger(ledgerList, slm) {
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |      return ledgerList;
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  | +function setTpMonthToLedger(ledgerList, slm, nextSlm, endSlm, yearSlm, yearLedgerData) {
 | 
	
		
			
				|  |  | +    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;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    if (nextSlm.length > 0) {
 | 
	
		
			
				|  |  | +        for (const ns of nextSlm) {
 | 
	
		
			
				|  |  | +            const index = _.findIndex(ledgerList, {'ledger_id': ns.lid});
 | 
	
		
			
				|  |  | +            if (index && index !== -1) {
 | 
	
		
			
				|  |  | +                ledgerList[index].next_plan_tp = ns.plan_tp;
 | 
	
		
			
				|  |  | +                ledgerList[index].next_plan_gcl = ns.plan_gcl;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    if (endSlm.length > 0) {
 | 
	
		
			
				|  |  | +        for (const es of endSlm) {
 | 
	
		
			
				|  |  | +            const index = _.findIndex(ledgerList, {'ledger_id': es.lid});
 | 
	
		
			
				|  |  | +            if (index && index !== -1) {
 | 
	
		
			
				|  |  | +                ledgerList[index].end_plan_tp = es.plan_tp;
 | 
	
		
			
				|  |  | +                ledgerList[index].end_plan_gcl = es.plan_gcl;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    if (yearSlm.length > 0) {
 | 
	
		
			
				|  |  | +        for (const ys of yearSlm) {
 | 
	
		
			
				|  |  | +            const index = _.findIndex(ledgerList, {'ledger_id': ys.lid});
 | 
	
		
			
				|  |  | +            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);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    return ledgerList;
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  |  const is_numeric = (value) => {
 | 
	
		
			
				|  |  |      if (typeof(value) === 'object') {
 | 
	
		
			
				|  |  |          return false;
 |