var itemGridManager = null,fillinDate="";
$(function () {
    initItemGrid();
    bindEvent();
});

function bindEvent() {
    fillinDate = $("#fillinDate").val();
}

function initItemGrid() {
    var toolbarOptions = UICtrl.getDefaultToolbarOptions({
        addHandler: function(){
          /*  UICtrl.addGridRow(itemGridManager,{
                datab: $("#fillinDate").val()
            }); */
            UICtrl.showAjaxDialog({
                title: "添加采购信息记录",
                url: web_app.name + '/sapPurchaseInfoRecord/addSapPurchaseInfoRecordDetail.load',
                param: {
                    id:  $('#id').val
                },
                width:1200,
                height:860,
                init: initShowDialog,
                okVal: '确定',
                ok: doSaveDefine,
                close: onDialogCloseHandler
            });
        },
        deleteHandler: function (){
        // debugger
            var row = DataUtil.getSelectedRow(itemGridManager);
            for  (var r=0;r<row.length;r++) {
                if (itemGridManager.rows[u].id=="undefined")  {
                 itemGridManager.deleteRow(itemGridManager.rows[u]);
               }
            }
            var _grid = UICtrl.getGridManager('#maingrid');
            DataUtil.delSelectedRows({
                action: 'sapPurchaseInfoRecordItem/deleteSapPurchaseInfoRecordItem.ajax',
                param: {},
                gridManager: _grid,
                idFieldName: 'id',
                onSuccess: function () {
                    itemGridManager.loadData();
                    //reloadGrid();
                }
            });
        },
    });
        itemGridManager = UICtrl.grid('#maingrid', {
            columns: getGridColumns(),
            dataAction: 'server',
            _tableKey: 'sapPurchaseInfoRecordItem',
            _local: true,
            url: web_app.name + '/sapPurchaseInfoRecordItem/querySapPurchaseInfoRecordItems.ajax',
            parms:{sapPurchaseInfoRecordId:getId(),ids:$("#ids").val()},
            height: '94%',
            heightDiff: -4,
            sortName: 'id',
            sortOrder: 'asc',
            checkbox: true,
            usePager: true,
            rownumbers: true,
            enabledEdit: true,
            fixedCellHeight: true,
            selectRowButtonOnly: true,
            //autoApplyNextEditor:false,
            toolbar: toolbarOptions,
            onBeforeEdit: function (editParma) {
                /*if (Public.isNotBlank(editParma.record.matnr) && editParma.column.name=='matklName'){
                    return false;
                }
                if (Public.isNotBlank(editParma.record.matklName) && Public.isBlank(editParma.record.maktx) && editParma.column.name=='matnr'){
                    return false;
                }
                  return true;*/

            },onAfterEdit: function (editParma) {
               /* if (editParma.column.name=='matnr' ){
                    editParma.record.meinsName=editParma.record.bprmeName;
                    editParma.record.meins=editParma.record.bprme;
                } */
            },  onDblClickRow: function (data, rowindex, rowobj) {
                viewHandler(data);
            },
        }
    );
    UICtrl.setSearchAreaToggle(itemGridManager);
}

function getGridColumns() {
    var columns = [];
    columns = [
        // {display: "语言", name: "zyy", width: "80", align: "left", type: "string",
        //     editor: {required: false, type: "text"}
        // },
        {display: "id", name: "id", width: "100", align: "left", type: "string",hide:true},
        {display: "采购信息记录号", name: "infnr", width: "100", align: "left", type: "string"
           // ,editor: {required: false, type: "text"}
        },
        {display: "工厂", name: "werks", width: "10", align: "left", type: "string",hide:true},
        {display: "工厂", name: "werksName", width: "200", align: "left", type: "string"
          /*  ,editor: {
                required: true, type: "select",
                data: {
                    type: 'system',
                    name: "dictionary",
                    getParam: function (item) {
                        return {fieldName: "WERKS"}
                    },
                    back: {
                        WERKS: "werks",
                        NAME1: "werksName",
                    }
                },
            }*/
        },
        {display: "采购组织", name: "ekorg", width: "10", align: "left", type: "string",hide:true},
        {display: "采购组织", name: "ekorgName", width: "200", align: "left", type: "string"
           /*,editor: {
                required: true, type: "select",
                data: {
                    type: 'system',
                    name: "dictionary",
                    getParam: function (item) {
                        return {
                            fieldName: "EKORG",
                            filterValue:item.werks
                        }
                    },
                    back: {
                        EKORG: "ekorg",
                        EKOTX: "ekorgName",
                    }
                },
            } */
        },
        {display: "供应商编码", name: "lifnr", width: "100", align: "left", type: "string"
            /*,editor: {
                required: true, type: "select",
                data: {
                    type: 'suppliers',
                    name: "selectSuppliers",
                    getParam: function (item) {
                        //return {fieldName: "LIFNR"}
                    },
                    back: {
                        partner: "lifnr",
                        nameOrg1: "name1",
                    }
                },
            } */
        },
        {display: "供应商名称1", name: "name1", width: "200", align: "left", type: "string"
           // ,editor: {required: false, type: "text"}
        },
        {display: "供应商物料编码", name: "idnlf", width: "120", align: "left", type: "string"
          //  ,editor: {required: false, type: "text"}
        },
        {display: "物料编码", name: "matnr", width: "160", align: "left", type: "string",
            /*,editor: {
                required: true, type: "select",
                data: {
                    type: 'system',
                    name: "sapMaterialSelect",
                    getParam: function (item) {
                        return {
                            filterValue:item.werks
                        }
                    },
                    back: {
                        MATNR: "matnr",
                        MAKTX: "maktx",
                        MATKL: "matkl",
                        WGBEZ: "matklName",
                        EKGRP: "ekgrp",
                        EKNAM: "ekgrpName",
                        PEINH: "peinh",
                       // MEINS: "meins",
                       // MSEHL: "meinsName",
                        MEINS: "bprme",
                        MSEHL: "bprmeName",
                    },
                },
            }*/
        },
        {display: "物料描述", name: "maktx", width: "200", align: "left", type: "string",
           //,editor: {required: true, type: "text"}
        },
        {display: "物料组编号", name: "matkl", width: "10", align: "left", type: "string",hide:true},
        {display: "物料组", name: "matklName", width: "160", align: "left", type: "string"
            /*,editor: {
                required: true, type: "select",
                data: {
                    type: 'system',
                    name: "dictionary",
                    getParam: function (item) {
                        return {
                            fieldName: "MATKL"
                        }
                    },
                    back: {
                        MATKL: "matkl",
                        WGBEZ: "matklName",
                    }
                },
            }*/
        },
        {display: "采购信息记录分类编号", name: "esokz", width: "20", align: "left", type: "string",hide:true},
        {display: "采购信息记录分类", name: "esokzTextView", width: "140", align: "left", type: "string"
           /* ,editor: {
                type: 'dictionary',
                data: {name: 'esokz'},
                textField: 'esokzTextView',
                valueField: 'esokz',
                required: true,
                render: function (item) {
                    return item.esokzTextView;
                }
            },*/
        },
        {display: "采购组编号", name: "ekgrp", width: "20", align: "left", type: "string",hide:true},
        {display: "采购组", name: "ekgrpName", width: "200", align: "left", type: "string"
            /*,editor: {
                required: true, type: "select",
                data: {
                    type: 'system',
                    name: "dictionary",
                    getParam: function (item) {
                        return {fieldName: "EKGRP"}
                    },
                    back: {
                        EKGRP: "ekgrp",
                        EKNAM: "ekgrpName"
                    }
                },
            }*/
        },
        // {display: "生产版本", name: "verid", width: "200", align: "left", type: "string",
        //     editor: {required: false, type: "text"}
        // },
        {display: "净价", name: "netpr", width: "100", align: "left", type: "string"
          //,editor: {required: true,type: 'text', mask: '9999999.99'}
        },
        {display: "货币码编号", name: "waers", width: "20", align: "left", type: "string",hide:true},
        {display: "货币码", name: "waersTextView", width: "100", align: "left", type: "string"
            /*,editor: {
                type: 'dictionary',
                data: {name: 'waers'},
                textField: 'waersTextView',
                valueField: 'waers',
                required: true,
                render: function (item) {
                    return item.waersTextView;
                }
            },*/
        },
        {display: "价格单位", name: "peinh", width: "100", align: "left", type: "string"
            //,editor: {required: false, type: "text"}
        },
        {display: "订单价格单位编号", name: "bprme", width: "20", align: "left", type: "string",hide:true},
        {display: "订单价格单位(采购)", name: "bprmeName", width: "90", align: "left", type: "string"
           /*,editor: {
                required: false, type: "select",
                data: {
                    type: 'system',
                    name: "dictionary",
                    getParam: function (item) {
                        return {fieldName: "MEINS"}
                    },
                    back: {
                      //  MSEHI: "bprme",
                        MSEH3: "bprme",
                        MSEHL: "bprmeName",
                    }
                },
            }*/
        },
        {display: "标准采购订单数量", name: "norbm", width: "120", align: "left", type: "string"
           //,editor: {type: 'text', mask: '9999999.99'}
        },
        {display: "基本计量单位", name: "meinsName", width: "100", align: "left", type: "string"  },
        {display: "基本计量单位", name: "meins", width: "40", align: "left", type: "string",hide:"true" },

        {display: "单位转换分母", name: "umren", width: "100", align: "left", type: "string"
           // ,editor: {type: 'text', mask: '9999999.99'}
        },
        {display: "单位转换分子", name: "umrez", width: "100", align: "left", type: "string"
            //,editor: {type: 'text', mask: '9999999.99'}
        },

        {display: "销售/购买税代码", name: "mwskz", width: "40", align: "left", type: "string",hide:"true" },
        {display: "销售/购买税代码", name: "mwskzTextView", width: "150", align: "left", type: "string"
            /*,editor: {
                type: 'dictionary',
                data: {name: 'mwskz'},
                textField: 'mwskzTextView',
                valueField: 'mwskz',
                required: true,
                render: function (item) {
                    return item.mwskzTextView;
                }
            },*/
        },
        {display: "开始生效日期", name: "datab", width: "100", align: "left", type: "string"
            //,editor: {type: 'date'},
        },
        {display: "有效期至日期", name: "datbi", width: "100", align: "left", type: "string"
            //,editor: {type: 'date'},
        },
        {display: "销售员", name: "verkf", width: "100", align: "left", type: "string"
            //,editor: {required: false, type: "text"}
        },
        {display: "电话", name: "telf1", width: "100", align: "left", type: "string"
            //,editor: {required: false, type: "text"}
        },
        {display: "原产地国代码", name: "urzla", width: "40", align: "left", type: "string",hide:"true"},
        {display: "原产地国", name: "urzlaName", width: 150, minWidth: 60, type: "string", align: "center"
            /*,editor: {
                required: false, type: "select",
                data: {
                    type: 'system',
                    name: "dictionarySelect",
                    getParam: function (item) {
                        return {fieldName: "country",displayNames:"国家",displayLens:"180"}
                    },
                    back: {
                        value: "urzla",
                        name:"urzlaTextView"
                    }
                },
            }*/
        },
        {display: "地区", name: "regio", width: 10, minWidth: 60, type: "string", align: "center",hide:"true"},
        {display: "地区", name: "regioName", width: 150, minWidth: 60, type: "string", align: "center"
            /*,editor: {
                required: false, type: "select",
                data: {
                    type: 'system',
                    name: "getArea",
                    getParam: function (item) {
                        if (Public.isBlank(item.urzla)){
                            Public.tip("请先选择原产地国")
                            return false;
                        }
                        return {
                            LAND1: item.urzla
                        }
                    },
                    back: {
                        BLAND: "regio",
                        BEZEI: "regioName",
                    }
                },
            }*/
        },
        {display: "删除标志", name: "loekz", width: "40", align: "left", type: "string",hide:"true" },
        {display: "删除标志", name: "loekzTextView", width: 150, minWidth: 60, type: "string", align: "center"
           /* ,editor: {
                type: 'dictionary',
                data: {name: 'loekz'},
                textField: 'loekzTextView',
                valueField: 'loekz',
                required: false,
                render: function (item) {
                    return item.loekzTextView;
                }
            },*/
        },
        {display: "排序字段", name: "sortl", width: 150, minWidth: 60, type: "string", align: "center"
            //,editor: {required: false, type: "text"}
        },
        {display: "最小采购订单数量", name: "minbm", width: "120", align: "left", type: "string"
           //,editor: { required: true,type: 'text', mask: '9999999.99'}
        },
        {display: "计划交货时间(天)", name: "aplfz", width: "150", align: "left", type: "string"
            //,editor: {required: true,type: 'text', mask: '9999999.99'}
        },

        // {display: "业务标识", name: "zflag", width: 150, minWidth: 60, type: "string", align: "center",
        //     editor: {required: false, type: "text"}
        // },
        {display: "基于收货的发票验证", name: "webre", width: "40", align: "left", type: "string",hide:"true" },
        {display: '基于收货的发票验证', name: "webreTextView", width: "100", align: "left", type: "string"
            /*,editor: {
                type: 'dictionary',
                data: {name: 'webre'},
                textField: 'webreTextView',
                valueField: 'webre',
                required: true,
                render: function (item) {
                    return item.webreTextView;
                }
            },*/
        },
        // {display: "条件类型", name: "kschl", width: "100", align: "left", type: "string",
        //     editor: {type: 'text', required: false}
        // },
        {display: "价格有效至", name: "prdat", width: "100", align: "left", type: "string",hide:true,
            //editor: {type: 'date', required: false}
            render: function (item){
                return item.prdat = item.datbi
            }
        },
        // {display: "订单价格单位转换为订单单位的分母", name: "bpumn", width: "100", align: "left", type: "string",
        //     editor: {type: 'text', mask: '9999999.99'}
        // },
        // {display: "订单价格单位转换为订单单位的分子", name: "bpumz", width: "100", align: "left", type: "string",
        //     editor: {type: 'text', mask: '9999999.99'}
        // },
        {display: "等级类型", name: "stfkz", width: "40", align: "left", type: "string",hide:"true" },
        {display: "等级类型", name:"stfkzTextView", width: "200", align: "left", type: "string",
           /*, editor: {
                type: 'dictionary',
                data: {name: 'stfkz'},
                textField: 'stfkzTextView',
                valueField: 'stfkz',
                required: true,
                render: function (item) {
                    return item.stfkzTextView;
                }
            },*/
        },
        {display: "条件等级计量单位", name: "konms", width: "100", align: "left", type: "string"
            //editor: {type: 'text'},
           /* ,render: function (item){
                if (Public.isNotBlank(item.bprme)){
                    return item.konms = item.bprme
                }else {
                    return item.konms = item.meins
                }
            }*/
        },
        {display: "等级数量1", name: "kstbm", width: "100", align: "left", type: "string"
            //,editor: {type: 'text', mask: '9999999.99'}
        },
        {display: "等级金额1", name: "kbetr", width: "100", align: "left", type: "string"
            //,editor: {type: 'text', mask: '9999999.99'}
        },
        {display: "等级数量2", name: "kstbm2", width: "100", align: "left", type: "string"
            //,editor: {type: 'text', mask: '9999999.99'}
        },
        {display: "等级金额2", name: "kbetr2", width: "100", align: "left", type: "string"
            //,editor: {type: 'text', mask: '9999999.99'}
        },
        {display: "等级数量3", name: "kstbm3", width: "100", align: "left", type: "string"
            //,editor: {type: 'text', mask: '9999999.99'}
        },
        {display: "等级金额3", name: "kbetr3", width: "100", align: "left", type: "string"
            //,editor: {type: 'text', mask: '9999999.99'}
        },
        {display: "等级数量4", name: "kstbm4", width: "100", align: "left", type: "string"
        },
        {display: "等级金额4", name: "kbetr4", width: "100", align: "left", type: "string"
        },
        {display: "等级数量5", name: "kstbm5", width: "100", align: "left", type: "string"
        },
        {display: "等级金额5", name: "kbetr5", width: "100", align: "left", type: "string"
        },
        // {
        //     display: "传输日期", name: "sendTime", width: "100", align: "left", type: "string",
        //     editor: {type: 'date'}
        // }
    ]
    return columns;
}

//获取数据保存的参数
function getExtendedData(processAction) {
    //回退、打回、转交时，不需要验证必填项是否已经填写；
    if (processAction == ProcessAction.BACK
        || processAction == ProcessAction.REPLENISH
        || processAction == ProcessAction.TRANSMIT) {
        //不验证
        $('#submitForm').attr('check', false);
    }
    var extendedData = {};
    var _grid = UICtrl.getGridManager('#maingrid');
    if (_grid) {
        var datas = DataUtil.getGridData({
            gridManager: _grid,
            isAllData: true
        });
        if (!datas) {
            return false;
        }
        datas.forEach(data=>{
            if (Public.isNotBlank(data.bprme)
                && Public.isNotBlank(data.meins)
                && (Public.isBlank(data.umren) || Public.isBlank(data.umrez))){
                Public.tip("订单价格单位不为空，单位转换分子、分母必填")
                return false;
            }

        })
        extendedData.sapPurchaseInfoRecordItems = Public.encodeJSONURI(datas);
    }
    return extendedData;
}

function getId() {
    return $('#id').val();
}

function setId(value) {
    $("#id").val(value);
    var _grid=UICtrl.getGridManager('#maingrid');
    _grid.options.parms.sapPurchaseInfoRecordId = value;
}

function reloadGrid() {
    itemGridManager.loadData();
}

function getGridData(){
    var _grid = UICtrl.getGridManager('#maingrid');
    var datas = DataUtil.getGridData({
        gridManager: _grid,
        isAllData: true
    });
    return datas;
}

function initShowDialog() {
    // var mainFileTable = $('#compensateLibraryList').fileList();
    // mainFileTable.find('table').css({
    //     borderTopWidth: 0
    // });
}
function  doSaveDefine() {
    var _self = this;
   // debugger
   //  alert(  "id:==="+$("#id").val());
    //var ss=_self.getParam("partner");
    //var id = getId();
    var returnResult=checkInput();
    var row = itemGridManager.rows;
    var rId="";
    if ($("#matnr").val()==""&&$("#matklName").val()==""){
       Public.tip("物料编码与物料组必须填写一个！");
       return false;
    }
    if ($("#matnr").val()==""&&$("#maktx").val()==""){
        Public.tip("物料描述必须填写！");
        return false;
    }
   // if ($("#matnr").val()==""&&$("#sortl").val()==""){
    //    Public.tip("排序字段必须填写！");
    //    return false;
   // }
    if (MathUtil.compare($("#norbm").val(),$("#minbm").val())<0){
        Public.tip("标准采购订单数量必须大于最小采购订单量！");
        return false;
    }
    if  (returnResult) {
        if (row.length > 0) {
            for (var u = 0; u < row.length; u++) {
                rId = itemGridManager.rows[u].__id;
                if ($("#rowId").val() == rId) {
                    itemGridManager.deleteRow(itemGridManager.rows[u]);
                    break;
                }
            }
        }

        UICtrl.addGridRow(itemGridManager, {
            id: $("#id").val(),
            infnr: $("#infnr").val(),
            werks: $("#werks").val(),
            werksName: $("#werksName").val(),
            ekorg: $("#ekorg").val(),
            ekorgName: $("#ekorgName").val(),
            lifnr: $("#lifnr").val(),
            name1: $("#name1").val(),
            idnlf: $("#idnlf").val(),
            matnr: $("#matnr").val(),
            maktx: $("#maktx").val(),
            matkl: $("#matkl").val(),
            matklName: $("#matklName").val(),
            esokz: $("#esokz").val(),
            esokzTextView: $("#esokz").find("option:selected").text(),
            ekgrp: $("#ekgrp").val(),
            ekgrpName: $("#ekgrpName").val(),
            netpr: $("#netpr").val(),
            waers: $("#waers").val(),
            waersTextView: $("#waers").find("option:selected").text(),
            peinh: $("#peinh").val(),
            bprme: $("#bprme").val(),
            bprmeName: $("#bprmeName").val(),
            norbm: $("#norbm").val(),
            meins: $("#meins").val(),
            meinsName: $("#meinsName").val(),

            umren: $("#umren").val(),
            umrez: $("#umrez").val(),

            mwskz: $("#mwskz").val(),
            mwskzTextView: $("#mwskz").find("option:selected").text(),
            datab: $("#datab").val(),
            datbi: $("#datbi").val(),
            verkf: $("#verkf").val(),
            telf1: $("#telf1").val(),

            urzlaName: $("#urzlaName").val(),
            urzla: $("#urzla").val(),
            regioName: $("#regioName").val(),
            regio: $("#regio").val(),

            loekz: $("#loekz").val(),
            loekzTextView: $("#loekz").find("option:selected").text(),
            sortl: $("#sortl").val(),
            minbm: $("#minbm").val(),
            aplfz: $("#aplfz").val(),

            webre: $("#webre").val(),
            webreTextView: $("#webre").find("option:selected").text(),
            stfkz: $("#stfkz").val(),
            stfkzTextView: $("#stfkz").find("option:selected").text(),
            konms: $("#konms").val(),

            kstbm: $("#kstbm").val(),
            kbetr: $("#kbetr").val(),
            kstbm2: $("#kstbm2").val(),
            kbetr2: $("#kbetr2").val(),
            kstbm3: $("#kstbm3").val(),
            kbetr3: $("#kbetr3").val(),
        });

        this.close();
    }
   // var obj=$("#infoRecord[name='nameOrg1']");
  //  var url = "/sapPurchaseInfoRecord/saveSapPurchaseInfoRecordDetail.ajax";
   //if (id && id.length > 0)
   //     url = "/enterpriseInfo/saveSapPurchaseInfoRecordDetail.ajax";
  /*  $('#infoRecord').ajaxSubmit({
        url : web_app.name + (url),
        success : function(id) {
            //setId(id);
            parent.reloadGrid();
            //refreshFlag = true;
        }
    }); */
}
function  checkInput() {
    if ($("#werks").val()==""){
      Public.errorTip("工厂必输！");
      return false;
    }
    if ($("#ekorg").val()==""){
        Public.errorTip("采购组织必输！");
        return false;
    }
    if ($("#lifnr").val()==""){
        Public.errorTip("供应商必输！");
        return false;
    }
   /* if ($("#matnr").val()==""){
        Public.errorTip("物料编码必输！");
        return false;
    }*/
    if ($("#esokz").val()==""){
        Public.errorTip("记录分类必输！");
        return false;
    }
    if ($("#ekgrp").val()==""){
        Public.errorTip("采购组必输！");
        return false;
    }
    if ($("#netpr").val()==""){
        Public.errorTip("净价必输！");
        return false;
    }
    if ($("#waers").val()==""){
        Public.errorTip("货币码必输！");
        return false;
    }
    if ($("#mwskz").val()==""){
        Public.errorTip("销售/购买税代码必输！");
        return false;
    }
    if ($("#datab").val()==""){
        Public.errorTip("生效日期起必输！");
        return false;
    }
    if ($("#datbi").val()==""){
        Public.errorTip("生效日期止必输！");
        return false;
    }
    if ($("#norbm").val()==""){
        Public.errorTip("标准采购订单数量必输！");
        return false;
    }
    if ($("#minbm").val()==""){
        Public.errorTip("最小采购订单数量必输！");
        return false;
    }
    if ($("#aplfz").val()==""){
        Public.errorTip("计划交货时间必输！");
        return false;
    }
    if ($("#webre").val()==""){
        Public.errorTip("基于收货的发票验证必输！");
        return false;
    }
    if ($("#stfkz").val()==""){
        Public.errorTip("等级类型必输！");
        return false;
    }

    return true;
}
function  viewHandler(data){
    //alert($("#isReadOnly").val());
    // alert(data.id+"------"+data.infnr+"=="+data.werks+data.werksName);
     //debugger
    var param = JSON.stringify(data);
    var rowId=data.__id;
    var readwriteList = UICtrl.getUIElementPermissions(UIPO.READWRITE, UIPK.DETAIL);
   // alert($("#isReadOnly").val()); alert(readwriteList.length);
    if ($("#isReadOnly").val()=="true"||($("#statusId").val()==1&&readwriteList.length==0&&TaskKind.isReplenishTask(taskKindId)!=true)) {
      UICtrl.showAjaxDialog({
        title: "查看采购信息记录",
        url: web_app.name + '/sapPurchaseInfoRecord/addSapPurchaseInfoRecordDetail.load?id=' + data.id + '&rowId=' + rowId+'&isReadOnly=true',
        param: {
            param
        },
        width: 1200,
        height: 860,
        init: initShowDialog,
        ok:false,
        close: onDialogCloseHandler
      });
  } else {
        UICtrl.showAjaxDialog({
            title: "添加采购信息记录",
            url: web_app.name + '/sapPurchaseInfoRecord/addSapPurchaseInfoRecordDetail.load?id=' + data.id + '&rowId=' + rowId,
            param: {
                param
            },
            width: 1200,
            height: 860,
            init: initShowDialog,
            okVal: '确定',
            ok: doSaveDefine,
            close: onDialogCloseHandler
        });
    }
}
// 关闭对话框
function onDialogCloseHandler() {
    //if (refreshFlag) {
        parent.reloadGrid();
      //  refreshFlag = false;
   // }
}