/**
 * Created by zhang on 2018/7/3.
 */
let gljCol = {
    ration_glj_setting: {
        header: [
            {headerName: "编码", headerWidth: 110, dataCode: "code", dataType: "String", formatter: "@"},
            {headerName: "名称", headerWidth: 160, dataCode: "name", dataType: "String",cellType:'tipsCell'},
            {headerName: "规格型号", headerWidth: 120, dataCode: "specs", dataType: "String", hAlign: "left",cellType:'tipsCell'},
            {headerName: "单位", headerWidth: 45, dataCode: "unit", dataType: "String", hAlign: "center"},
            {headerName: "市场价", headerWidth: 65, dataCode: "marketPrice", dataType: "Number", hAlign: "right"},//, decimalField: "glj.unitPrice"
            {headerName: "调整价", headerWidth: 65, dataCode: "adjustPrice", dataType: "Number", hAlign: "right"},//, decimalField: "glj.unitPrice"1
            {headerName: "自定消耗", headerWidth: 65, dataCode: "customQuantity", dataType: "Number", hAlign: "right", decimalField: "glj.quantity"},
            {headerName: "消耗量", headerWidth: 65, dataCode: "quantity", dataType: "Number", hAlign: "right", decimalField: "glj.quantity"},
            {headerName: "定额价", headerWidth: 65, dataCode: "basePrice", dataType: "Number", hAlign: "right"},//, decimalField: "glj.unitPrice"
            {headerName: "定额消耗", headerWidth: 65, dataCode: "rationItemQuantity", dataType: "Number", hAlign: "right", decimalField: "glj.quantity"},   // dataType: "Number", formatter: "0.00"
            {headerName: "总消耗量", headerWidth: 80, dataCode: "totalQuantity", dataType: "Number", hAlign: "right", decimalField: "glj.quantity"},
            {headerName: "暂估", headerWidth: 45, dataCode: "isEstimate", dataType: "String", hAlign: "center", vAlign: "center", cellType: "checkBox"}
        ],
        view: {
            lockColumns: [ "adjustPrice", "rationItemQuantity", "quantity", "totalQuantity", "isEstimate"],//这里以后改成dataCode好一点
            rowHeaderWidth:25
        },
        getStyle:function (data) {
            if(data&&data.type == gljType.MAIN_MATERIAL){//是主材的话字体蓝色显示
                return {foreColor:"#4D7BFF"};
            }
            return null;
        },
        navigationRightCol:['name','specs','unit'],//选中这几列时，按enter键跳到右边一列
        // 工料机类型是混凝土、砂浆、配合比、机械台班时，价格不可编辑。
        editedTyep:[GLJTypeConst.MAIN_MATERIAL,GLJTypeConst.EQUIPMENT]//主材设备
    },
    project_glj_setting:{
        header: [
            {headerName: "编码", headerWidth: 80, dataCode: "code", dataType: "String"},
            {headerName: "名称", headerWidth: 160, dataCode: "name", dataType: "String",cellType:'tipsCell'},
            {headerName: "规格型号", headerWidth: 120, dataCode: "specs", hAlign: "left", dataType: "String",cellType:'tipsCell'},
            {headerName: "单位", headerWidth: 45, dataCode: "unit", hAlign: "center", dataType: "String"},
            {headerName: "类型", headerWidth: 45, dataCode: "short_name", hAlign: "center", dataType: "String"},
            {headerName: "市场价", headerWidth: 70, dataCode: "marketPrice", hAlign: "right", dataType: "Number",validator:"number"},//,decimalField:"glj.unitPrice"
            {headerName: "调整价", headerWidth: 70, dataCode: "adjustPrice", hAlign: "right", dataType: "Number"},//,decimalField:"glj.unitPrice"
            {headerName: "定额价", headerWidth: 70, dataCode: "basePrice", hAlign: "right", dataType: "Number",validator:"number"},//decimalField:'glj.unitPrice',
            {headerName: "总消耗量", headerWidth: 90, dataCode: "quantity", hAlign: "right", dataType: "Number",decimalField:'glj.quantity'},
            {headerName: "暂估", headerWidth: 45, dataCode: "is_evaluate", hAlign: "center", dataType: "String",cellType:'checkBox'},
            {headerName: "主要\n材料", headerWidth: 45, dataCode: "is_main_material", hAlign: "center", dataType: "String",cellType:'checkBox'},
            {headerName: "不调价", headerWidth: 55, dataCode: "is_adjust_price", dataType: "String",cellType: "checkBox"},
            {headerName: "供货方式", headerWidth: 70, dataCode: "supply", hAlign: "center", dataType: "String",cellType:'comboBox',editorValueType:true,options:supplyComboMap},
            {headerName: "甲供数量", headerWidth: 90, dataCode: "supply_quantity", hAlign: "right", dataType: "Number",validator:"number",decimalField:'glj.quantity'},
            {headerName: "三材类别", headerWidth: 70, dataCode: "materialType", hAlign: "center", dataType: "String",cellType:'comboBox',editorValueType:true,options:materialComboMap},
            {headerName: "三材系数", headerWidth: 70, dataCode: "materialCoe", hAlign: "right", dataType: "Number",validator:"number"},//,decimalField:'material'
            {headerName: "交货方式", headerWidth: 70, dataCode: "delivery", hAlign: "left", dataType: "String"},
            {headerName: "送达地点", headerWidth: 70, dataCode: "delivery_address", hAlign: "left", dataType: "String"},
            {headerName: "备注", headerWidth: 100, dataCode: "remark", hAlign: "left", dataType: "String"}
        ],
        view: {
            lockColumns: [0,1,2,3,4,6,8]
        },
        frozenCols:4
    },
    mixRatio_Setting:{
        header:[
            {headerName: "编码", headerWidth: 80, dataCode: "code", dataType: "String"},
            {headerName: "名称", headerWidth: 240, dataCode: "name", dataType: "String"},
            {headerName: "规格型号", headerWidth: 190, dataCode: "specs", dataType: "String"},
            {headerName: "单位", headerWidth: 45, dataCode: "unit", hAlign: "center", dataType: "String"},
            {headerName: "类型", headerWidth: 45, dataCode: "short_name", hAlign: "center", dataType: "String"},
            {headerName: "定额价", headerWidth: 80, dataCode: "basePrice", hAlign: "right", dataType: "Number",validator:"number"},//,decimalField:'glj.unitPrice'
            {headerName: "调整价", headerWidth: 80, dataCode: "adjustPrice", hAlign: "right", dataType: "Number"},//,decimalField:"glj.unitPrice"
            {headerName: "市场价", headerWidth: 80, dataCode: "marketPrice", hAlign: "right", dataType: "Number",validator:"number"},//,decimalField:"glj.unitPrice"
            {headerName: "消耗量", headerWidth: 80, dataCode: "consumption", hAlign: "right", dataType: "Number",decimalField:"glj.quantity",validator:"number"}
        ],
        view: {
            lockColumns: [0,1,2,3,4,5,6,7]
        }
    },
    removeCol:function (dataCode,setting) {
        let colIndex = _.findIndex(setting.header,{'dataCode':dataCode});
        if(colIndex != -1){
            setting.header.splice(colIndex,1);//去掉列;
            let newArray = [];
            for(let l of setting.view.lockColumns){
                if(_.isString(l)) return;//如果是用dataCode表示的,不用处理
                if(l == colIndex)  continue;
                if(l > colIndex)  l = l -1;
                newArray.push(l);
            }
            setting.view.lockColumns = newArray;
        }
    },
    initGljCol:function (showAdjustPrice) {
        let me = gljCol;
        if(showAdjustPrice !== true){
            me.removeCol('adjustPrice',me.ration_glj_setting);
            me.removeCol('adjustPrice',me.project_glj_setting);
            me.removeCol('adjustPrice',me.mixRatio_Setting);
        }
        gljOprObj.setting = me.ration_glj_setting;
        projectGljObject.projectGljSetting = me.project_glj_setting;
        projectGljObject.mixRatioSetting = me.mixRatio_Setting;
    }

};
/*
$(function () {
    $('#fullpath').click(function () {
        checkfeeRate();

    });

})

async function checkfeeRate() {
    let result = await ajaxPost('/feeRates/checkFeeRateName', data = {name: '编辑工程量表达式', rootProjectID: 3163});
    console.log(result);
}*/
