|  | @@ -1284,6 +1284,75 @@ $(document).ready(() => {
 | 
	
		
			
				|  |  |      SpreadJsObj.initSheet(materialSourceSpread.getActiveSheet(), materialSourceSpreadSetting);
 | 
	
		
			
				|  |  |      SpreadJsObj.loadSheetData(materialSourceSpread.getActiveSheet(), SpreadJsObj.DataType.Data, []);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    // 项目节汇总sjs
 | 
	
		
			
				|  |  | +    const material_xmj_gather_cols = [
 | 
	
		
			
				|  |  | +        {title: '单位工程', colSpan: '1', rowSpan: '2', field: 'dwgc', hAlign: 0, width: 80, formatter: '@', visible: false},
 | 
	
		
			
				|  |  | +        {title: '分部工程', colSpan: '1', rowSpan: '2', field: 'fbgc', hAlign: 0, width: 80, formatter: '@', visible: false},
 | 
	
		
			
				|  |  | +        {title: '分项工程', colSpan: '1', rowSpan: '2', field: 'fxgc', hAlign: 0, width: 80, formatter: '@', visible: false},
 | 
	
		
			
				|  |  | +        {title: '细目', colSpan: '1', rowSpan: '2', field: 'jldy', hAlign: 0, width: 80, formatter: '@', visible: false},
 | 
	
		
			
				|  |  | +        {title: '计量单元', colSpan: '1', rowSpan: '2', field: 'bwmx', hAlign: 0, width: 80, formatter: '@'},
 | 
	
		
			
				|  |  | +        {title: '本期应耗数量', colSpan: '1', rowSpan: '2', field: 'quantity', hAlign: 2, width: 100, type: 'Number'},
 | 
	
		
			
				|  |  | +        {title: '本期调差金额', colSpan: '1', rowSpan: '2', field: 'm_tp', hAlign: 2, width: 100, type: 'Number'},
 | 
	
		
			
				|  |  | +    ];
 | 
	
		
			
				|  |  | +    const materialXmjGatherSpread = SpreadJsObj.createNewSpread($('#material-xmj-gather-spread')[0]);
 | 
	
		
			
				|  |  | +    const materialXmjGatherSpreadSetting = {
 | 
	
		
			
				|  |  | +        cols: material_xmj_gather_cols,
 | 
	
		
			
				|  |  | +        emptyRows: 0,
 | 
	
		
			
				|  |  | +        headRows: 1,
 | 
	
		
			
				|  |  | +        headRowHeight: [32],
 | 
	
		
			
				|  |  | +        defaultRowHeight: 21,
 | 
	
		
			
				|  |  | +        headerFont: '12px 微软雅黑',
 | 
	
		
			
				|  |  | +        font: '12px 微软雅黑',
 | 
	
		
			
				|  |  | +        readOnly: true,
 | 
	
		
			
				|  |  | +        localCache: {
 | 
	
		
			
				|  |  | +            key: 'material-gather-gatherLeafXmj',
 | 
	
		
			
				|  |  | +            colWidth: true,
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    };
 | 
	
		
			
				|  |  | +    if (thousandth) sjsSettingObj.setTpThousandthFormat(materialXmjGatherSpreadSetting);
 | 
	
		
			
				|  |  | +    const materialXmjGatherSheet = materialXmjGatherSpread.getActiveSheet();
 | 
	
		
			
				|  |  | +    SpreadJsObj.initSheet(materialXmjGatherSheet, materialXmjGatherSpreadSetting);
 | 
	
		
			
				|  |  | +    // SpreadJsObj.loadSheetData(materialXmjGatherSpread.getActiveSheet(), SpreadJsObj.DataType.Data, []);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    // 下部设置显示相关
 | 
	
		
			
				|  |  | +    $('a', '[id=material-bills-tab]').click(function() {
 | 
	
		
			
				|  |  | +        const relaTab = this.getAttribute('href');
 | 
	
		
			
				|  |  | +        const optionTab = $('#optionTab').children();
 | 
	
		
			
				|  |  | +        for (const ot of optionTab) {
 | 
	
		
			
				|  |  | +            if (ot.getAttribute('rela-tab') === relaTab) {
 | 
	
		
			
				|  |  | +                $(ot).show();
 | 
	
		
			
				|  |  | +            } else {
 | 
	
		
			
				|  |  | +                $(ot).hide();
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        setTimeout(refreshRelaSpread, 100);
 | 
	
		
			
				|  |  | +    });
 | 
	
		
			
				|  |  | +    $('[name=gather-xmj]').change(function() {
 | 
	
		
			
				|  |  | +        const checkOption = $('[name=gather-xmj]:checked');
 | 
	
		
			
				|  |  | +        if (checkOption.length === 0) {
 | 
	
		
			
				|  |  | +            toastr.warning('请至少选择一个汇总条件');
 | 
	
		
			
				|  |  | +            $(this).prop('checked', true);
 | 
	
		
			
				|  |  | +            return;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        const fields = [];
 | 
	
		
			
				|  |  | +        for (const co of checkOption) {
 | 
	
		
			
				|  |  | +            fields.push(co.value);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        for (const col of materialXmjGatherSpreadSetting.cols) {
 | 
	
		
			
				|  |  | +            col.visible = col.type === 'Number' || fields.indexOf(col.field) >= 0;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        gatherFields = fields;
 | 
	
		
			
				|  |  | +        SpreadJsObj.refreshColumnVisible(materialXmjGatherSheet);
 | 
	
		
			
				|  |  | +        const data = SpreadJsObj.getSelectObject(materialSpread.getActiveSheet());
 | 
	
		
			
				|  |  | +        setCurBillSourceList(data ? (data.mb_id || data.id) : null, $('#myTab').find('.active').data('msid') || null, fields);
 | 
	
		
			
				|  |  | +    });
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    function refreshRelaSpread() {
 | 
	
		
			
				|  |  | +        materialSourceSpread.refresh();
 | 
	
		
			
				|  |  | +        materialXmjGatherSpread.refresh();
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      let first = true;
 | 
	
		
			
				|  |  |      function setListsData(sid = null, ms_id = null) {
 | 
	
		
			
				|  |  |          if (first) {
 | 
	
	
		
			
				|  | @@ -1460,8 +1529,9 @@ $(document).ready(() => {
 | 
	
		
			
				|  |  |          }, 1000);
 | 
	
		
			
				|  |  |      });
 | 
	
		
			
				|  |  |      // 本条工料应耗来源数据信息
 | 
	
		
			
				|  |  | -    function setCurBillSourceList(mb_id, ms_id = null) {
 | 
	
		
			
				|  |  | +    function setCurBillSourceList(mb_id, ms_id = null, fields = gatherFields) {
 | 
	
		
			
				|  |  |          const showSourceList = [];
 | 
	
		
			
				|  |  | +        const showXmjList = [];
 | 
	
		
			
				|  |  |          if (mb_id) {
 | 
	
		
			
				|  |  |              const list = _.filter(materialListData2, function (item) {
 | 
	
		
			
				|  |  |                  return item.mb_id === mb_id && item.ms_id === ms_id && (item.is_join === 1 || item.is_join === 2);
 | 
	
	
		
			
				|  | @@ -1484,12 +1554,36 @@ $(document).ready(() => {
 | 
	
		
			
				|  |  |                          } else {
 | 
	
		
			
				|  |  |                              showSourceList[index].quantity = ZhCalc.add(showSourceList[index].quantity, ZhCalc.mul(calcQty(l), l.quantity));
 | 
	
		
			
				|  |  |                          }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                        // const indexXmj = _.findIndex(showXmjList, { gcl_id: l.gcl_id, xmj_id: l.xmj_id, mx_id: l.mx_id });
 | 
	
		
			
				|  |  | +                        const xmj = _.find(gcl.leafXmjs, { gcl_id: l.gcl_id, id: l.xmj_id, mx_id: l.mx_id });
 | 
	
		
			
				|  |  | +                        if (xmj) {
 | 
	
		
			
				|  |  | +                            const condition = {};
 | 
	
		
			
				|  |  | +                            for (const f of fields) {
 | 
	
		
			
				|  |  | +                                condition[f] = xmj[f];
 | 
	
		
			
				|  |  | +                            }
 | 
	
		
			
				|  |  | +                            let glx = _.find(showXmjList, condition);
 | 
	
		
			
				|  |  | +                            if (!glx) {
 | 
	
		
			
				|  |  | +                                const newGcl = _.cloneDeep(xmj);
 | 
	
		
			
				|  |  | +                                newGcl.quantity = ZhCalc.mul(calcQty(l), l.quantity);
 | 
	
		
			
				|  |  | +                                showXmjList.push(newGcl);
 | 
	
		
			
				|  |  | +                            } else {
 | 
	
		
			
				|  |  | +                                glx.quantity = ZhCalc.add(glx.quantity, ZhCalc.mul(calcQty(l), l.quantity));
 | 
	
		
			
				|  |  | +                            }
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | +            const data = SpreadJsObj.getSelectObject(materialSpread.getActiveSheet());
 | 
	
		
			
				|  |  | +            for (const xmj of showXmjList) {
 | 
	
		
			
				|  |  | +                const m_spread = data ? (data.m_spread || data.spread) : 0;
 | 
	
		
			
				|  |  | +                xmj.m_tp = ZhCalc.mul(m_spread, xmj.quantity);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          // 按清单编号排序
 | 
	
		
			
				|  |  |          SpreadJsObj.loadSheetData(materialSourceSpread.getActiveSheet(), SpreadJsObj.DataType.Data, showSourceList.sort(sortByCode));
 | 
	
		
			
				|  |  | +        console.log(showXmjList);
 | 
	
		
			
				|  |  | +        SpreadJsObj.loadSheetData(materialXmjGatherSheet, SpreadJsObj.DataType.Data, showXmjList);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      function calcQty(info) {
 |