|  | @@ -20,6 +20,7 @@ $(function () {
 | 
	
		
			
				|  |  |          level: 'level',
 | 
	
		
			
				|  |  |          rootId: -1,
 | 
	
		
			
				|  |  |          fullPath: 'full_path',
 | 
	
		
			
				|  |  | +        calcFields: ['can_select'],
 | 
	
		
			
				|  |  |          //treeCacheKey: 'ledger_bills_fold' + '_' + getTenderId(),
 | 
	
		
			
				|  |  |          // markFoldKey: 'bills-fold',
 | 
	
		
			
				|  |  |          // markFoldSubKey: window.location.pathname.split('/')[2],
 | 
	
	
		
			
				|  | @@ -28,7 +29,7 @@ $(function () {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      const ledgerSpreadSetting = {
 | 
	
		
			
				|  |  |          cols: [
 | 
	
		
			
				|  |  | -            {title: '', colSpan: '1', rowSpan: '2', field: 'is_select', hAlign: 1, width: 40, formatter: '@', cellType: 'checkbox'},
 | 
	
		
			
				|  |  | +            {title: '', colSpan: '1', rowSpan: '2', field: 'is_select', hAlign: 1, width: 40, formatter: '@', cellType: 'checkbox', readOnly: 'readOnly.can_select'},
 | 
	
		
			
				|  |  |              {title: '编号', colSpan: '1', rowSpan: '2', field: 'code', hAlign: 0, width: 185, formatter: '@', readOnly: true, cellType: 'tree'},
 | 
	
		
			
				|  |  |              {title: '名称', colSpan: '1', rowSpan: '2', field: 'name', hAlign: 0, width: 205, formatter: '@', readOnly: true},
 | 
	
		
			
				|  |  |              {title: '单位', colSpan: '1', rowSpan: '2', field: 'unit', hAlign: 1, width: 100, formatter: '@', readOnly: true},
 | 
	
	
		
			
				|  | @@ -49,8 +50,17 @@ $(function () {
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      };
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    const ledgerCol = {
 | 
	
		
			
				|  |  | +        readOnly: {
 | 
	
		
			
				|  |  | +            can_select: function (data) {
 | 
	
		
			
				|  |  | +                return !data.can_select;
 | 
	
		
			
				|  |  | +            },
 | 
	
		
			
				|  |  | +        },
 | 
	
		
			
				|  |  | +    };
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      sjsSettingObj.setFxTreeStyle(ledgerSpreadSetting, sjsSettingObj.FxTreeStyle.jz);
 | 
	
		
			
				|  |  |      if (thousandth) sjsSettingObj.setTpThousandthFormat(ledgerSpreadSetting);
 | 
	
		
			
				|  |  | +    SpreadJsObj.initSpreadSettingEvents(ledgerSpreadSetting, ledgerCol);
 | 
	
		
			
				|  |  |      SpreadJsObj.initSheet(ledgerSpread.getActiveSheet(), ledgerSpreadSetting);
 | 
	
		
			
				|  |  |      SpreadJsObj.selChangedRefreshBackColor(ledgerSpread.getActiveSheet());
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -72,10 +82,11 @@ $(function () {
 | 
	
		
			
				|  |  |          treeCalc.calculateAll(baseLedgerTree);
 | 
	
		
			
				|  |  |          for (const d of baseLedgerTree.nodes) {
 | 
	
		
			
				|  |  |              if (!d.b_code)
 | 
	
		
			
				|  |  | -                ledgerTree.addData(d, ['is_select', 'ledger_id', 'ledger_pid', 'order', 'level', 'tender_id', 'full_path',
 | 
	
		
			
				|  |  | +                ledgerTree.addData(d, ['is_select', 'can_select', 'ledger_id', 'ledger_pid', 'order', 'level', 'tender_id', 'full_path',
 | 
	
		
			
				|  |  |                      'code', 'name', 'unit', 'dgn_qty1', 'dgn_qty2', 'dgn_price', 'quantity', 'total_price']);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          ledgerTree.sortTreeNode(true);
 | 
	
		
			
				|  |  | +        console.log(ledgerTree);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          SpreadJsObj.loadSheetData(ledgerSpread.getActiveSheet(), SpreadJsObj.DataType.Tree, ledgerTree);
 | 
	
		
			
				|  |  |      }, null, true);
 | 
	
	
		
			
				|  | @@ -144,7 +155,7 @@ $(function () {
 | 
	
		
			
				|  |  |                  // if (materialCol.readOnly.isEdit(select)) {
 | 
	
		
			
				|  |  |                  //     return;
 | 
	
		
			
				|  |  |                  // }
 | 
	
		
			
				|  |  | -                if (col.field === 'is_select') {
 | 
	
		
			
				|  |  | +                if (col.field === 'is_select' && select.can_select) {
 | 
	
		
			
				|  |  |                      if (info.sheet.isEditing()) {
 | 
	
		
			
				|  |  |                          info.sheet.endEdit(true);
 | 
	
		
			
				|  |  |                      }
 | 
	
	
		
			
				|  | @@ -251,15 +262,37 @@ function addIsSelect(datas) {
 | 
	
		
			
				|  |  |      for (const d of datas) {
 | 
	
		
			
				|  |  |          if (!d.b_code) {
 | 
	
		
			
				|  |  |              d.is_select = selectedLedgerList.length === 0 ? 1: selectedLedgerList.indexOf(d.ledger_id) !== -1 ? 1 : 0;
 | 
	
		
			
				|  |  | -            // newDatas.push(d);
 | 
	
		
			
				|  |  | +            if (!d.is_leaf) {
 | 
	
		
			
				|  |  | +                d.can_select = hadDataLidList.length === 0 ? true : hadDataLidList.indexOf(d.ledger_id) !== -1 ? false : true;
 | 
	
		
			
				|  |  | +                // console.log(d.can_select);
 | 
	
		
			
				|  |  | +            } else if(d.can_select === undefined) {
 | 
	
		
			
				|  |  | +                d.can_select = true;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    for (const d2 of datas) {
 | 
	
		
			
				|  |  | +        if (!d2.b_code && !d2.can_select) {
 | 
	
		
			
				|  |  | +            updateParentCanSelect(datas, d2.ledger_pid);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |      return datas;
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +function updateParentCanSelect(datas, ledger_pid) {
 | 
	
		
			
				|  |  | +    if (ledger_pid !== 0) {
 | 
	
		
			
				|  |  | +        const info = _.find(datas, { ledger_id: ledger_pid});
 | 
	
		
			
				|  |  | +        if (info) {
 | 
	
		
			
				|  |  | +            info.can_select = false;
 | 
	
		
			
				|  |  | +            updateParentCanSelect(datas, info.ledger_pid);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  function updateChildrenSelect(datas, is_select) {
 | 
	
		
			
				|  |  |      for (const data of datas) {
 | 
	
		
			
				|  |  | -        data.is_select = is_select;
 | 
	
		
			
				|  |  | +        if (data.can_select) {
 | 
	
		
			
				|  |  | +            data.is_select = is_select;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  |          if(data.children && data.children.length > 0) {
 | 
	
		
			
				|  |  |              updateChildrenSelect(data.children, is_select);
 | 
	
		
			
				|  |  |          }
 | 
	
	
		
			
				|  | @@ -271,7 +304,10 @@ function updateSiblingsSelect(tree, pid, is_select, select_msg) {
 | 
	
		
			
				|  |  |      const parent = pid !== -1 ? _.find(tree.nodes, { 'ledger_id': pid }) : tree;
 | 
	
		
			
				|  |  |      if (parent) {
 | 
	
		
			
				|  |  |          for(const d of parent.children) {
 | 
	
		
			
				|  |  | -            d.is_select = is_select;
 | 
	
		
			
				|  |  | +            if (d.can_select) {
 | 
	
		
			
				|  |  | +                d.is_select = is_select;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            // d.is_select = is_select;
 | 
	
		
			
				|  |  |              if (select_msg.select_children || is_select === 0) {
 | 
	
		
			
				|  |  |                  updateChildrenSelect(d.children, is_select);
 | 
	
		
			
				|  |  |              }
 | 
	
	
		
			
				|  | @@ -293,7 +329,9 @@ function updateOtherSiblingsSelect(tree, pid, is_select, select_msg) {
 | 
	
		
			
				|  |  |                      let p = false;
 | 
	
		
			
				|  |  |                      if(d.children && d.children.length > 0) {
 | 
	
		
			
				|  |  |                          for (const dd of d.children) {
 | 
	
		
			
				|  |  | -                            dd.is_select = is_select;
 | 
	
		
			
				|  |  | +                            if (dd.can_select) {
 | 
	
		
			
				|  |  | +                                dd.is_select = is_select;
 | 
	
		
			
				|  |  | +                            }
 | 
	
		
			
				|  |  |                              p = true;
 | 
	
		
			
				|  |  |                              if (select_msg.select_children || is_select === 0) {
 | 
	
		
			
				|  |  |                                  updateChildrenSelect(dd.children, is_select);
 | 
	
	
		
			
				|  | @@ -302,7 +340,9 @@ function updateOtherSiblingsSelect(tree, pid, is_select, select_msg) {
 | 
	
		
			
				|  |  |                          }
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  |                      if(p) {
 | 
	
		
			
				|  |  | -                        d.is_select = is_select;
 | 
	
		
			
				|  |  | +                        if(d.can_select) {
 | 
	
		
			
				|  |  | +                            d.is_select = is_select;
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  |                          selects.push(d);
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  |                  }
 |