|  | @@ -0,0 +1,99 @@
 | 
	
		
			
				|  |  | +/**
 | 
	
		
			
				|  |  | + * Created by zhang on 2020/1/17.
 | 
	
		
			
				|  |  | + */
 | 
	
		
			
				|  |  | +let itemBaseOptions = ["人工费","材料费","机械费","人工费+材料费","人工费+机械费","人工费+材料费","材料费+机械费","人工费+材料费+机械费"];
 | 
	
		
			
				|  |  | +let itemIncreaseFeeObj = {
 | 
	
		
			
				|  |  | +    settingSpread:null,
 | 
	
		
			
				|  |  | +    itemSetting:{
 | 
	
		
			
				|  |  | +        header:[
 | 
	
		
			
				|  |  | +            {headerName: "名称", headerWidth: 270, dataCode: "name", dataType: "String"},
 | 
	
		
			
				|  |  | +            {headerName: "范围", headerWidth: 70, dataCode: "displayScope",hAlign: "center",dataType: "String"},
 | 
	
		
			
				|  |  | +            {headerName: "取费基数", headerWidth: 150, dataCode: "base",  hAlign: "center", dataType: "String",cellType:'comboBox',options:itemBaseOptions},
 | 
	
		
			
				|  |  | +            {headerName: "系数(%)", headerWidth: 55, dataCode: "coe", hAlign: "center", dataType: "Number",validator:"number"}
 | 
	
		
			
				|  |  | +        ],
 | 
	
		
			
				|  |  | +        view: {
 | 
	
		
			
				|  |  | +            lockColumns: ["code","specs"],
 | 
	
		
			
				|  |  | +            rowHeaderWidth:25,
 | 
	
		
			
				|  |  | +            colHeaderHeight:36
 | 
	
		
			
				|  |  | +        },
 | 
	
		
			
				|  |  | +        autoFit:true,
 | 
	
		
			
				|  |  | +        fitRow:['name']
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +    settingDatas:[],
 | 
	
		
			
				|  |  | +    initSpread:function () {
 | 
	
		
			
				|  |  | +        if(this.settingSpread) return this.settingSpread.refresh();
 | 
	
		
			
				|  |  | +        this.settingSpread = SheetDataHelper.createNewSpread($("#itemIncreaseFee_sheet")[0]);
 | 
	
		
			
				|  |  | +        sheetCommonObj.spreadDefaultStyle(this.settingSpread);
 | 
	
		
			
				|  |  | +        this.settingSheet = this.settingSpread.getSheet(0);
 | 
	
		
			
				|  |  | +        sheetCommonObj.initSheet(this.settingSheet, this.itemSetting, 4);
 | 
	
		
			
				|  |  | +        this.settingSheet.bind(GC.Spread.Sheets.Events.SelectionChanged,this.onItemSelectionChange);
 | 
	
		
			
				|  |  | +        this.settingSheet.bind(GC.Spread.Sheets.Events.ValueChanged, this.onItemValueChange);
 | 
	
		
			
				|  |  | +    /*   ;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        this.settingSheet.bind(GC.Spread.Sheets.Events.EditStarting,this.onElectrovalenceEditStarting);*/
 | 
	
		
			
				|  |  | +        /*
 | 
	
		
			
				|  |  | +         ;*/
 | 
	
		
			
				|  |  | +        this.settingSheet.name('itemIncreaseFee_sheet');
 | 
	
		
			
				|  |  | +        if(projectReadOnly){
 | 
	
		
			
				|  |  | +            disableSpread(this.settingSpread);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +    onItemSelectionChange:function (sender,args) {
 | 
	
		
			
				|  |  | +        args.sheet.repaint();
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +    showDatas:function(datas){
 | 
	
		
			
				|  |  | +        let sel = this.settingSheet.getSelections()[0];
 | 
	
		
			
				|  |  | +        let oldData = sel.row<this.settingDatas.length?this.settingDatas[sel.row]:"";
 | 
	
		
			
				|  |  | +        this.settingSheet.setRowCount(0);
 | 
	
		
			
				|  |  | +        this.settingDatas = datas?datas:this.getItemSettingDatas();
 | 
	
		
			
				|  |  | +        sheetCommonObj.showData(this.settingSheet, this.itemSetting,this.settingDatas);
 | 
	
		
			
				|  |  | +        this.settingSheet.setRowCount(this.settingDatas.length);
 | 
	
		
			
				|  |  | +        sel.row =  oldData?_.findIndex(this.settingDatas,{'name':oldData.name}):sel.row ;
 | 
	
		
			
				|  |  | +        this.settingSheet.setSelection(sel.row==-1?0:sel.row,sel.col,sel.rowCount,sel.colCount);
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +    getItemSettingDatas:function () {
 | 
	
		
			
				|  |  | +        let datas = [];
 | 
	
		
			
				|  |  | +        if(projectObj.project.property.itemIncreaseSetting){
 | 
	
		
			
				|  |  | +            for(let i of projectObj.project.property.itemIncreaseSetting){
 | 
	
		
			
				|  |  | +                let d = {name:i.name,displayScope:"范围",scope:i.scope,base:i.base,coe:i.coe};
 | 
	
		
			
				|  |  | +                if(_.isEmpty(d.scope)){
 | 
	
		
			
				|  |  | +                    d.foreColor = "#ff2a23";
 | 
	
		
			
				|  |  | +                    d.styleCol = 1;
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                datas.push(d);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        return datas;
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +    onItemValueChange:function (sender,args) {
 | 
	
		
			
				|  |  | +        let me = itemIncreaseFeeObj;
 | 
	
		
			
				|  |  | +        let dataCode = me.itemSetting.header[args.col].dataCode;
 | 
	
		
			
				|  |  | +        let value = args.newValue;
 | 
	
		
			
				|  |  | +        let tem = me.settingDatas[args.row];
 | 
	
		
			
				|  |  | +        if (value&&!sheetCommonObj.checkData(args.col,me.itemSetting,value)) {
 | 
	
		
			
				|  |  | +            alert('输入的数据类型不对,请重新输入!');
 | 
	
		
			
				|  |  | +            return  me.showDatas(me.settingDatas);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        if(dataCode == 'coe') {
 | 
	
		
			
				|  |  | +            if (value) value = scMathUtil.roundForObj(value, 2);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        tem[dataCode] = value;
 | 
	
		
			
				|  |  | +        me.showDatas(me.settingDatas);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +};
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +$(function () {
 | 
	
		
			
				|  |  | +   /* $("#areaIncreaseFeeConfirm").on("click",async function(e){
 | 
	
		
			
				|  |  | +        areaIncreaseFeeObj.confirmAreaIncreaseFeeSetting();
 | 
	
		
			
				|  |  | +    });*/
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    $('#itemIncreaseFeeDiv').on('shown.bs.modal', function (e) {
 | 
	
		
			
				|  |  | +        itemIncreaseFeeObj.initSpread();
 | 
	
		
			
				|  |  | +        itemIncreaseFeeObj.showDatas();
 | 
	
		
			
				|  |  | +    });
 | 
	
		
			
				|  |  | +});
 |