|  | @@ -82,12 +82,12 @@ var gljOprObj = {
 | 
	
		
			
				|  |  |          header: [
 | 
	
		
			
				|  |  |              {headerName: "选择", headerWidth: 40, dataCode: "select", hAlign: "center", vAlign: "center", cellType: "checkBox"},
 | 
	
		
			
				|  |  |              {headerName: "编码", headerWidth: 80, dataCode: "code", dataType: "String", formatter: "@", hAlign: "left", vAlign: "center"},
 | 
	
		
			
				|  |  | -            {headerName: "名称", headerWidth: 120, dataCode: "name", dataType: "String", hAlign: "left", vAlign: "center"},
 | 
	
		
			
				|  |  | -            {headerName: "规格型号", headerWidth: 80, dataCode: "specs", dataType: "String", hAlign: "center", vAlign: "center"},
 | 
	
		
			
				|  |  | +            {headerName: "名称", headerWidth: 240, dataCode: "name", dataType: "String", hAlign: "left", vAlign: "center"},
 | 
	
		
			
				|  |  | +            {headerName: "规格型号", headerWidth: 190, dataCode: "specs", dataType: "String", hAlign: "left", vAlign: "center"},
 | 
	
		
			
				|  |  |              {headerName: "单位", headerWidth: 40, dataCode: "unit", dataType: "String", hAlign: "center", vAlign: "center"},
 | 
	
		
			
				|  |  | -            {headerName: "单价", headerWidth: 80, dataCode: "basePrice", dataType: "Number", formatter: "0.00", hAlign: "right", vAlign: "center"},
 | 
	
		
			
				|  |  | -            {headerName: "类型", headerWidth: 80, dataCode: "gljType", dataType: "String", hAlign: "center", vAlign: "center"},
 | 
	
		
			
				|  |  | -            {headerName: "是否新增", headerWidth: 80, dataCode: "isComplementary", dataType: "String", hAlign: "center", vAlign: "center", cellType: "checkBox"}
 | 
	
		
			
				|  |  | +            {headerName: "单价", headerWidth: 55, dataCode: "basePrice", dataType: "Number", formatter: "0.00", hAlign: "right", vAlign: "center"},
 | 
	
		
			
				|  |  | +            {headerName: "类型", headerWidth: 60, dataCode: "gljType", dataType: "String", hAlign: "center", vAlign: "center"},
 | 
	
		
			
				|  |  | +            {headerName: "新增", headerWidth: 40, dataCode: "isComplementary", dataType: "String", hAlign: "center", vAlign: "center", cellType: "checkBox"}
 | 
	
		
			
				|  |  |          ],
 | 
	
		
			
				|  |  |          view: {
 | 
	
		
			
				|  |  |              lockColumns: [0, 1, 2, 3, 4, 5, 6]
 | 
	
	
		
			
				|  | @@ -114,6 +114,9 @@ var gljOprObj = {
 | 
	
		
			
				|  |  |          if(!projectReadOnly){
 | 
	
		
			
				|  |  |              gljContextMenu.loadGLJSpreadContextMenu();
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | +        sheet.bind(GC.Spread.Sheets.Events.SelectionChanged,function (sender,args) {
 | 
	
		
			
				|  |  | +            args.sheet.repaint();
 | 
	
		
			
				|  |  | +        });
 | 
	
		
			
				|  |  |      },
 | 
	
		
			
				|  |  |      initDetailSheet: function (sheet) {
 | 
	
		
			
				|  |  |          var me = this;
 | 
	
	
		
			
				|  | @@ -504,36 +507,49 @@ var gljOprObj = {
 | 
	
		
			
				|  |  |          let selected = this.sheet.getSelections();
 | 
	
		
			
				|  |  |          this.combineWithProjectGlj(this.sheetData);
 | 
	
		
			
				|  |  |          this.sheet.setRowCount(0);
 | 
	
		
			
				|  |  | -        //console.log(+new Date())
 | 
	
		
			
				|  |  | -        //this.sheet.getRange(0,-1,this.sheet.getRowCount(),-1).visible(true); //这个方法导致加载缓慢
 | 
	
		
			
				|  |  |          this.sheetData = sortRationGLJ(this.sheetData);
 | 
	
		
			
				|  |  |          this.sumQuantity();//计算总消耗量
 | 
	
		
			
				|  |  |          this.addMixRatioToShow();//显示组成物信息
 | 
	
		
			
				|  |  | -        this.initRationTree(init);
 | 
	
		
			
				|  |  | +        this.initRationTree(init,this.getUnitPriceCodeMap());
 | 
	
		
			
				|  |  |          sheetCommonObj.showData(this.sheet, this.setting, this.sheetData);
 | 
	
		
			
				|  |  |          if(selected){//定位光标到之前的位置
 | 
	
		
			
				|  |  |              this.sheet.setSelection(selected[0].row,selected[0].col,selected[0].rowCount,selected[0].colCount);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      },
 | 
	
		
			
				|  |  | -    initRationTree: function (init) {
 | 
	
		
			
				|  |  | -        this.sheet.getRange(-1, 0, -1, 1).cellType(this.getTreeNodeCellType(this.sheetData));
 | 
	
		
			
				|  |  | +    getUnitPriceCodeMap : function (sheetData) {//取单价文件中,编码前缀一样的映射表
 | 
	
		
			
				|  |  | +        let codeMap = {};
 | 
	
		
			
				|  |  | +        let priceMap = projectObj.project.projectGLJ.datas.unitPriceMap;
 | 
	
		
			
				|  |  | +        if(priceMap){
 | 
	
		
			
				|  |  | +            for(let connectKey in priceMap){
 | 
	
		
			
				|  |  | +                let code = priceMap[connectKey].code;
 | 
	
		
			
				|  |  | +                if(code){
 | 
	
		
			
				|  |  | +                   let preCode = code.split("-")[0];
 | 
	
		
			
				|  |  | +                   if(codeMap[preCode]) {
 | 
	
		
			
				|  |  | +                       codeMap[preCode].push({text:code,value:connectKey});
 | 
	
		
			
				|  |  | +                   }else {
 | 
	
		
			
				|  |  | +                       codeMap[preCode]=[{text:code,value:connectKey}];
 | 
	
		
			
				|  |  | +                   }
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        return codeMap;
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    initRationTree: function (init,codeMap) {
 | 
	
		
			
				|  |  | +        this.sheet.suspendPaint();
 | 
	
		
			
				|  |  | +        this.sheet.suspendEvent();
 | 
	
		
			
				|  |  | +        this.sheet.setRowCount(this.sheetData.length >30?this.sheetData.length:30);
 | 
	
		
			
				|  |  |          for (var i = 0; i < this.sheetData.length; i++) {
 | 
	
		
			
				|  |  | +            this.sheet.setCellType(i, 0,this.getTreeNodeCellType(this.sheetData,i,codeMap),GC.Spread.Sheets.SheetArea.viewport);
 | 
	
		
			
				|  |  |              if (this.sheetData[i].hasOwnProperty('subList')) {
 | 
	
		
			
				|  |  | -               /* var collapsed = false;
 | 
	
		
			
				|  |  | -                if (init) {
 | 
	
		
			
				|  |  | -                    this.sheetData[i].collapsed = true;
 | 
	
		
			
				|  |  | -                    collapsed = true;
 | 
	
		
			
				|  |  | -                } else {
 | 
	
		
			
				|  |  | -                    collapsed = this.sheetData[i].collapsed == undefined ? true : this.sheetData[i].collapsed;
 | 
	
		
			
				|  |  | -                }*/
 | 
	
		
			
				|  |  |                  var collapsed = this.sheetData[i].collapsed == undefined ? true : this.sheetData[i].collapsed;
 | 
	
		
			
				|  |  |                  if (collapsed == true) {
 | 
	
		
			
				|  |  |                      this.sheet.getRange(i + 1, -1, this.sheetData[i].subList.length, -1).visible(false);
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  | -                //this.sheet.getRange(i+1, -1, this.sheetData[i].subList.length, -1).visible(!collapsed);// this.sheet.getRange(i+1, -1, this.sheetData[i].subList.length, -1).locked(true);
 | 
	
		
			
				|  |  | -                //这个方法导致加载缓慢
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | +        this.sheet.resumeEvent();
 | 
	
		
			
				|  |  | +        this.sheet.resumePaint();
 | 
	
		
			
				|  |  |      },
 | 
	
		
			
				|  |  |      filterGljByRation: function (ration, datas) {
 | 
	
		
			
				|  |  |          var gljList = [];
 | 
	
	
		
			
				|  | @@ -752,6 +768,12 @@ var gljOprObj = {
 | 
	
		
			
				|  |  |                      return;
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | +            if(updateField == 'code'){
 | 
	
		
			
				|  |  | +                if (!gljUtil.isDef(args.editingText)||args.editingText==''||args.editingText.indexOf('|-|') === -1||this.isRationGLJExit(args.editingText)) {//说明是选中自已,或者是已存在的工料机
 | 
	
		
			
				|  |  | +                    me.sheet.getCell(args.row, args.col).value(recode[updateField]);
 | 
	
		
			
				|  |  | +                    return;
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  |              newval = args.editingText == null ? "" : args.editingText;
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          if (newval === recode[updateField]) {//如果值完全相等,则不需要更新
 | 
	
	
		
			
				|  | @@ -759,10 +781,23 @@ var gljOprObj = {
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          if (updateField == 'marketPrice' || updateField == 'basePrice') {
 | 
	
		
			
				|  |  |              projectObj.project.projectGLJ.updatePriceFromRG(recode, updateField, newval);
 | 
	
		
			
				|  |  | +        }else if(updateField == 'code'){//替换单价文件中已经有的工料机
 | 
	
		
			
				|  |  | +            projectObj.project.ration_glj.updateRationGLJByChangeCode(recode, updateField, newval);
 | 
	
		
			
				|  |  |          } else {
 | 
	
		
			
				|  |  |              projectObj.project.ration_glj.updateRationGLJByEdit(recode, updateField, newval);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      },
 | 
	
		
			
				|  |  | +    isRationGLJExit:function (connectKey) {
 | 
	
		
			
				|  |  | +        for(let rg of gljOprObj.sheetData){
 | 
	
		
			
				|  |  | +            if(rg.isMixRatio == true){
 | 
	
		
			
				|  |  | +                continue;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            if(gljOprObj.getIndex(rg, gljKeyArray) == connectKey){//存在一样的工料机
 | 
	
		
			
				|  |  | +                return true;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +       return false;
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  |      updateRationTypeGLJ: function (value, node, fieldName,editingText) {
 | 
	
		
			
				|  |  |          let newval;
 | 
	
		
			
				|  |  |          let updatePrice = false;
 | 
	
	
		
			
				|  | @@ -965,9 +1000,12 @@ var gljOprObj = {
 | 
	
		
			
				|  |  |          var project = projectObj.project;
 | 
	
		
			
				|  |  |          gljOprObj.GLJSelection = _.filter(gljOprObj.GLJSelection, function (n) {
 | 
	
		
			
				|  |  |              var rg = _.find(gljOprObj.sheetData, function (item) {
 | 
	
		
			
				|  |  | +                if(item.isMixRatio == true){
 | 
	
		
			
				|  |  | +                    return false;
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  |                  var i_key = gljOprObj.getIndex(item, gljKeyArray);
 | 
	
		
			
				|  |  |                  return n == i_key
 | 
	
		
			
				|  |  | -            })
 | 
	
		
			
				|  |  | +            });
 | 
	
		
			
				|  |  |              return rg ? false : true;
 | 
	
		
			
				|  |  |          })
 | 
	
		
			
				|  |  |          if (gljOprObj.GLJSelection.length > 0 && selected && selected.sourceType == ModuleNames.ration) {
 | 
	
	
		
			
				|  | @@ -1121,7 +1159,7 @@ var gljOprObj = {
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          return node;
 | 
	
		
			
				|  |  |      },
 | 
	
		
			
				|  |  | -    getTreeNodeCellType: function (data) {
 | 
	
		
			
				|  |  | +    getTreeNodeCellType: function (data,index,codeMap) {
 | 
	
		
			
				|  |  |          var ns = GC.Spread.Sheets;
 | 
	
		
			
				|  |  |          var rectW = 10;
 | 
	
		
			
				|  |  |          var rectH = 10;
 | 
	
	
		
			
				|  | @@ -1183,7 +1221,7 @@ var gljOprObj = {
 | 
	
		
			
				|  |  |              return offset;
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        TreeNodeCellType.prototype = new ns.CellTypes.Text();
 | 
	
		
			
				|  |  | +        TreeNodeCellType.prototype =  data[index]&&data[index].isMixRatio?new ns.CellTypes.Text(): sheetCommonObj.getDynamicCombo();//new ns.CellTypes.Text();
 | 
	
		
			
				|  |  |          TreeNodeCellType.prototype.paint = function (ctx, value, x, y, w, h, style, options) {
 | 
	
		
			
				|  |  |              if (value != null) {
 | 
	
		
			
				|  |  |                  var offset = margin + rectW + 6;
 | 
	
	
		
			
				|  | @@ -1203,17 +1241,21 @@ var gljOprObj = {
 | 
	
		
			
				|  |  |                  GC.Spread.Sheets.CellTypes.Text.prototype.paint.apply(this, arguments);
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          };
 | 
	
		
			
				|  |  | -        // override getHitInfo to allow cell type get mouse messages
 | 
	
		
			
				|  |  |          TreeNodeCellType.prototype.getHitInfo = function (x, y, cellStyle, cellRect, context) {
 | 
	
		
			
				|  |  | -            return {
 | 
	
		
			
				|  |  | -                x: x,
 | 
	
		
			
				|  |  | -                y: y,
 | 
	
		
			
				|  |  | -                row: context.row,
 | 
	
		
			
				|  |  | -                col: context.col,
 | 
	
		
			
				|  |  | -                cellStyle: cellStyle,
 | 
	
		
			
				|  |  | -                cellRect: cellRect,
 | 
	
		
			
				|  |  | -                sheetArea: context.sheetArea
 | 
	
		
			
				|  |  | -            };
 | 
	
		
			
				|  |  | +            if(x < cellRect.x+cellRect.width -15){
 | 
	
		
			
				|  |  | +                return {
 | 
	
		
			
				|  |  | +                    x: x,
 | 
	
		
			
				|  |  | +                    y: y,
 | 
	
		
			
				|  |  | +                    row: context.row,
 | 
	
		
			
				|  |  | +                    col: context.col,
 | 
	
		
			
				|  |  | +                    cellStyle: cellStyle,
 | 
	
		
			
				|  |  | +                    cellRect: cellRect,
 | 
	
		
			
				|  |  | +                    sheetArea: context.sheetArea
 | 
	
		
			
				|  |  | +                };
 | 
	
		
			
				|  |  | +            }else {
 | 
	
		
			
				|  |  | +                return GC.Spread.Sheets.CellTypes.ComboBox.prototype.getHitInfo.apply(this, arguments);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |          };
 | 
	
		
			
				|  |  |          TreeNodeCellType.prototype.processMouseDown = function (hitinfo) {
 | 
	
		
			
				|  |  |              var recode = data[hitinfo.row];
 | 
	
	
		
			
				|  | @@ -1227,10 +1269,26 @@ var gljOprObj = {
 | 
	
		
			
				|  |  |                      hitinfo.sheet.getRange(hitinfo.row + 1, -1, recode.subList.length, -1).visible(!collapsed);
 | 
	
		
			
				|  |  |                      hitinfo.sheet.invalidateLayout();
 | 
	
		
			
				|  |  |                      hitinfo.sheet.repaint();
 | 
	
		
			
				|  |  | +                    return;
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | +            GC.Spread.Sheets.CellTypes.ComboBox.prototype.processMouseDown.apply(this, arguments);
 | 
	
		
			
				|  |  | +           // GC.Spread.Sheets.CellTypes.Text.prototype.paint.apply(this, arguments);
 | 
	
		
			
				|  |  |          };
 | 
	
		
			
				|  |  | -        return new TreeNodeCellType()
 | 
	
		
			
				|  |  | +        let cellType = new TreeNodeCellType();
 | 
	
		
			
				|  |  | +        let options = [];
 | 
	
		
			
				|  |  | +        if(!(data[index]&&data[index].isMixRatio)){
 | 
	
		
			
				|  |  | +            let code = data[index].code;
 | 
	
		
			
				|  |  | +            if(code) {
 | 
	
		
			
				|  |  | +                let preCode = code.split("-")[0];
 | 
	
		
			
				|  |  | +                if( codeMap[preCode]) options = codeMap[preCode];
 | 
	
		
			
				|  |  | +                if(options.length>0) _.remove(options,{'value':gljOprObj.getIndex(data[index], gljKeyArray)})//去掉本身
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            cellType.editorValueType(GC.Spread.Sheets.CellTypes.EditorValueType.value);
 | 
	
		
			
				|  |  | +            cellType.itemHeight(options.length).items(options);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        return cellType;
 | 
	
		
			
				|  |  |      },
 | 
	
		
			
				|  |  |      marketPriceReadOnly: function (node) {
 | 
	
		
			
				|  |  |          let hasCom = false;
 | 
	
	
		
			
				|  | @@ -1260,6 +1318,7 @@ $(function () {
 | 
	
		
			
				|  |  |              gljOprObj.gljLibSpresd = sheetCommonObj.buildSheet($('#gljLibSheet')[0], gljOprObj.gljLibSheetSetting, gljOprObj.stdGLJ.length + gljOprObj.complementaryGLJs.length);
 | 
	
		
			
				|  |  |              gljOprObj.gljLibSpresd.bind(GC.Spread.Sheets.Events.ButtonClicked, gljOprObj.onButtonClick);
 | 
	
		
			
				|  |  |              gljOprObj.gljLibSheet = gljOprObj.gljLibSpresd.getSheet(0);
 | 
	
		
			
				|  |  | +            gljOprObj.gljLibSheet.setColumnWidth(0, 20, GC.Spread.Sheets.SheetArea.rowHeader);
 | 
	
		
			
				|  |  |              gljOprObj.gljLibSheet.options.isProtected = true;
 | 
	
		
			
				|  |  |              gljOprObj.gljLibSheet.name('glj_lib');
 | 
	
		
			
				|  |  |          }
 |