Ext.namespace('Shipping');

String.prototype.trim = function () { return this.replace(/(^\s*)|(\s*$)/g, ""); }

//#region 当前日期格式
Date.prototype.format = function (format) {
    var o = {
        "M+": this.getMonth() + 1, //month
        "d+": this.getDate(), //day
        "h+": this.getHours(), //hour
        "m+": this.getMinutes(), //minute
        "s+": this.getSeconds(), //cond
        "q+": Math.floor((this.getMonth() + 3) / 3), //quarter
        "S": this.getMilliseconds() //millisecond
    }
    if (/(y+)/.test(format)) format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
    for (var k in o) if (new RegExp("(" + k + ")").test(format))
        format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));
    return format;
}
//#endregion

//#region 获取 YYYY-mm-dd 格式的日期
var xhr = new XMLHttpRequest();
var currdate = new Date();
xhr.open("HEAD", location.href, true);
xhr.onreadystatechange = function () {
    if (xhr.readyState == 4 && xhr.status == 200) {
        var datestr = xhr.getResponseHeader("Date");
        currdate = new Date(datestr);
    }
}
xhr.send(null);
//#endregion

//#region 关闭窗口前的判断
function getSaved() {
    var changelines = panelEdit.storeDetailList.getModifiedRecords();
    var changecount = changelines.length;
    var AllDirty = true;
    if (changecount == 0) { return false; }    
    if (panelEdit.formHead.getForm().isDirty() == true || AllDirty == true) { return true; }
    else { return false };
}
//#endregion

Shipping.WMSOUT_GuiGeEdit = function (config) {
    Ext.applyIf(this, config);
    this.initUIComponents();
    window.Shipping.WMSOUT_GuiGeEdit.superclass.constructor.call(this);
};

var FEECONFIG = '0';

Ext.extend(Shipping.WMSOUT_GuiGeEdit, Ext.Panel, {
    parentWin: null,
    opStatus: 'add',
    EditRecord: null,
    btnRefresh: null,
    stockType: null,
    stockType2: false,
    blISLOCK: false,
    blEIP: false,
    blDESTOCK:false,
    sqlcontext: '',
    OPLBNAME :'WMSMAIN',
    mainWin: null,

    Goodsrecords:null,

    initUIComponents: function () {
        _this = this;
        this.formname = "formWMSOUT_GuiGeEdit"; //出库单
        this.pcnostr = "";
        this.cntrstr = "";
        this.MsPeriod = null;
        this.storeDefValue = Ext.create('Ext.data.Store', {
            model: 'DsShipping.ux.OpDefValue',
            remoteSort: true,
            proxy: {
                type: 'ajax',
                url: '/MvcShipping/MsCodeOpDef/GetDataList',
                reader: {
                    id: 'GID',
                    root: 'data',
                    totalProperty: 'totalCount'
                }
            }
        });
        this.storeMustBe = Ext.create('Ext.data.Store', {
            model: 'DsShipping.ux.OpDefValue',
            remoteSort: true,
            proxy: {
                type: 'ajax',
                url: '/MvcShipping/MsCodeOpMustField/GetDataList',
                reader: {
                    id: 'GID',
                    root: 'data',
                    totalProperty: 'totalCount'
                }
            }
        });

        //#region 页面加载

        //委托单位
        this.storeCustCode = Ext.create('DsExt.ux.RefTableStore', {
            model: 'DsShipping.ux.CustomRefModel',
            proxy: { url: '/CommMng/BasicDataRef/GetCustomRefList' }
        });
        //转移对象,需求编号:SR2017073000001
        this.storeCLIENTNAMEOLD = Ext.create('DsExt.ux.RefTableStore', {
            model: 'DsShipping.ux.CustomRefModel',
            proxy: { url: '/CommMng/BasicDataRef/GetCustomRefList' }
        });
        //应收仓储客户,需求编号:SR2017073000001
        this.storeARCLIENTWMSOUT = Ext.create('DsExt.ux.RefTableStore', {
            model: 'DsShipping.ux.CustomRefModel',
            proxy: { url: '/CommMng/BasicDataRef/GetCustomRefList' }
        });
        //应收出库客户,需求编号:SR2017073000001
        this.storeARCLIENT = Ext.create('DsExt.ux.RefTableStore', {
            model: 'DsShipping.ux.CustomRefModel',
            proxy: { url: '/CommMng/BasicDataRef/GetCustomRefList' }
        });
        //应付客户,需求编号:SR2017073000001
        this.storeTRUCKNAME = Ext.create('DsExt.ux.RefTableStore', {
            model: 'DsShipping.ux.CustomRefModel',
            proxy: { url: '/CommMng/BasicDataRef/GetCustomRefList' }
        });

        this.opStatus = 'add';
        parentWin = window.parent.opener;
        if (parentWin) {
            var ret = parentWin.OprationSwap();
            this.opStatus = ret[0];
            this.EditRecord = ret[1];
            this.btnRefresh = ret[2];
            this.stockType = ret[3];
            this.changeType = ret[4];
            this.blEIP = ret[5];
            this.OPLBNAME = ret[6];
            this.parentRecord = ret[7];
            this.stockType2 = ret[8];
            if (ret[4] === '0') {
                if (ret[3] == 'StockOut' ) {
                    this.stockTypeName = "整体出库";
                }
                else if (ret[3] == 'StockOutDetail') {
                    this.stockTypeName = "明细出库";

                }

            }
            else if (ret[4] === '1') {
                if (ret[3] === 'StockOut' ) {
                    this.stockTypeName = "货权转移-整体出库";
                }
                else if (ret[3] === 'StockOutDetail') {
                    this.stockTypeName = "货权转移-明细出库";

                }

            }
            if (this.OPLBNAME == "WMSMAIN") {
                //如果是出库管理处双击打开
                this.mainWin = getMainForm(parentWin);
                var _storecustcode = ret[9];
                this.storeCustCode.loadData(_storecustcode.data.items);
                this.storeCLIENTNAMEOLD.loadData(_storecustcode.data.items);
                this.storeARCLIENTWMSOUT.loadData(_storecustcode.data.items);
                this.storeARCLIENT.loadData(_storecustcode.data.items);
                this.storeTRUCKNAME.loadData(_storecustcode.data.items);

            } else {
                //如果是海运进口处双击打开
                this.mainWin = getMainForm_Opener(parentWin);

                this.storeTRUCKNAME.load(
                    {
                    callback: function (options, success, response) {
                        if (success) {
                            var _storecustcode = _this.storeTRUCKNAME;
                            this.storeCustCode.loadData(_storecustcode.data.items);
                            this.storeCLIENTNAMEOLD.loadData(_storecustcode.data.items);
                            this.storeARCLIENTWMSOUT.loadData(_storecustcode.data.items);
                            this.storeARCLIENT.loadData(_storecustcode.data.items);
                        }
                        else {

                        }
                    }
                }
                );
            }
        }
        //#endregion

        //region 查询是否需要清库配置信息
        Ext.Ajax.request({
            waitMsg: '正在查询清库信息...',
            url: '/MvcShipping/WMSOUT_GUIGE/GetSysDeStockConfig',
            params: {
                userid: USERID
            },
            callback: function (options, success, response) {
                if (success) {
                    var result = Ext.JSON.decode(response.responseText);
                    this.blDESTOCK = result.data;
                }
                else {
                    Ext.MessageBox.alert('获取清库信息失败', response.responseText);
                    return;
                }

            },
            scope: this
        });
        //endregion


        //#region formSearch 下拉框信息加载


//        this.storeCustCode.loadData(this.mainWin.GetPubStore("INFOCLIENT_ALL").data.items);
        //this.storeCustCode.load();
        this.comboxCustCode = Ext.create('DsExt.ux.RefTableCombox', {
            fieldLabel: '客户名称', //需求编号:SR2017071300002-2
            store: this.storeCustCode,
            flex:1,
            forceSelection: true,
            name: 'CUSTOMERNAME',
            valueField: 'CustName',
            displayField: 'CodeAndName',
            listeners: {
                specialkey: function (field, e) {
                    if (e.getKey() == e.ENTER) {
                        _this.onRefreshClick("");
                    }
                }
            }
        });


        //this.storeCLIENTNAMEOLD.load();
        //this.storeCLIENTNAMEOLD.loadData(this.mainWin.GetPubStore("OPSEAE_CUST_ISCONTROLLER").data.items);
        this.comboxCLIENTNAMEOLD = Ext.create('DsExt.ux.RefTableCombox', {
            fieldLabel: '转移对象',
            store: this.storeCLIENTNAMEOLD,
            //forceSelection: true,
            id: 'CLIENTNAMEOLD',
            name: 'CLIENTNAMEOLD',
            valueField: 'CustName',
            displayField: 'CodeAndName'
        });


        //this.storeARCLIENTWMSOUT.load();
        //this.storeARCLIENTWMSOUT.loadData(this.mainWin.GetPubStore("OPSEAE_CUST_ISCONTROLLER").data.items);
        this.comboxARCLIENTWMSOUT = Ext.create('DsExt.ux.RefTableCombox', {
            fieldLabel: '应收仓储客户',
            store: this.storeARCLIENTWMSOUT,
            //forceSelection: true,
            name: 'ARCLIENTWMSOUT',
            valueField: 'CustName',
            displayField: 'CodeAndName'
        });

        //this.storeARCLIENT.load();
        //this.storeARCLIENT.loadData(this.mainWin.GetPubStore("OPSEAE_CUST_ISCONTROLLER").data.items);
        this.comboxARCLIENT = Ext.create('DsExt.ux.RefTableCombox', {
            fieldLabel: '应收出库客户',
            store: this.storeARCLIENT,
            //forceSelection: true,
            id: 'ARCLIENT',
            name: 'ARCLIENT',
            valueField: 'CustName',
            displayField: 'CodeAndName'
        });


        //this.storeTRUCKNAME.load();
        //this.storeTRUCKNAME.loadData(this.mainWin.GetPubStore("OPSEAE_CUST_ISCONTROLLER").data.items);
        this.comboxTRUCKNAME = Ext.create('DsExt.ux.RefTableCombox', {
            fieldLabel: '应付客户',
            store: this.storeTRUCKNAME,
            //forceSelection: true,
            name: 'TRUCKNAME_OUT',
            valueField: 'CustName',
            displayField: 'CodeAndName'
        });

        //所属仓库
        this.storeSTORAGENAME = Ext.create('DsExt.ux.RefTableStore', {
            model: 'DsShipping.ux.CustomRefModel',
            proxy: { url: '/CommMng/BasicDataRef/GetCustomRefList' }
        });
        this.storeSTORAGENAME.load({ params: { condition: " ISWAREHOUSE=1 "} });
        this.comboxSTORAGENAME = Ext.create('DsExt.ux.RefTableCombox', {
            fieldLabel: '仓库名称',
            store: this.storeSTORAGENAME,
            flex: 1,
            forceSelection: true,
            name: 'STORAGENAME',
            valueField: 'CustName',
            displayField: 'CodeAndName',
            listeners: {
                specialkey: function (field, e) {
                    if (e.getKey() == e.ENTER) {
                        _this.onRefreshClick("");
                    }
                }
            }
        });

        //品名
        this.storeCodeGoodsList = Ext.create('DsExt.ux.RefTableStore', {
            model: 'DsShipping.ux.CodeGoodsModel',
            proxy: { url: '/CommMng/BasicDataRef/GetCodeGoodsList' }
        });
        this.storeCodeGoodsList.load();
        this.comboxGOODSNAME = Ext.create('DsExt.ux.RefTableCombox', {
            fieldLabel: '品名',
            flex: 1,
            store: this.storeCodeGoodsList,
            forceSelection: true,
            name: 'GOODSNAME',
            valueField: 'GOODNAME',
            displayField: 'CodeAndName',
            listeners: {
                specialkey: function (field, e) {
                    if (e.getKey() == e.ENTER) {
                        _this.onRefreshClick("");
                    }
                }
            }
        });

        //品名明细表_规格
        this.storeCodeGoodsDetailList = Ext.create('DsExt.ux.RefTableStore', {
            model: 'DsShipping.ux.CodeGoodsDetailModel',
            proxy: { url: '/CommMng/BasicDataRef/GetCodeGoodsDetailList' }
        });
        this.storeCodeGoodsDetailList.load();
        this.comboxCodeGoodsDetail = Ext.create('DsExt.ux.RefTableCombox', {
            fieldLabel: '单位', //品牌
            store: this.storeCodeGoodsDetailList,
            flex:1,
            forceSelection: true,
            name: 'GOODSDETAILNAME',
            valueField: 'GOODSDETAILNAME',
            displayField: 'GOODSDETAILNAME',
            listeners: {
                specialkey: function (field, e) {
                    if (e.getKey() == e.ENTER) {
                        _this.onRefreshClick("");
                    }
                }
            }
        });

        //枚举维护表tSysEnumValue_车辆类型99019//需求编号:SR2017073000001
        this.storeTSysEnumValueCode = Ext.create('DsExt.ux.RefTableStore', {
            model: 'DsShipping.ux.TSysEnumValueDataModel',
            proxy: { url: '/CommMng/BasicDataRef/GetTSysEnumValueList' }
        });
        this.storeTSysEnumValueCode.load({ params: { condition: " and EnumTypeID=99019"} }); //车辆类型
        this.comboxTRUCKTYPE = Ext.create('DsExt.ux.RefTableCombox', {
            //fieldLabel: '车辆类型',
            store: this.storeTSysEnumValueCode,
            forceSelection: true,
            name: 'TRUCKTYPE',
            valueField: 'EnumValueName',
            displayField: 'EnumValueName'
        });

        //装卸工下拉框
        Ext.regModel('ZHUANGXIEGONGMODEL', {
            fields: [{ name: 'GID' }, { name: 'NAME' }, { name: 'CODE' }, { name: 'CODENAME' }]
        });
        this.storeZhuangXieGong = Ext.create('DsExt.ux.RefTableStore', {
            model: 'ZHUANGXIEGONGMODEL',
            proxy: { url: '/MvcShipping/WMSNew/GetZhuangXieGongList' }
        });

        this.comboxZhuangXieGong = Ext.create('DsExt.ux.RefTableCombox', {
            store: this.storeZhuangXieGong,
            id: 'ZHUANGXIEGONGID_OUT',
            name: 'ZHUANGXIEGONGID_OUT',
            forceSelection: true,
            valueField: 'GID',
            displayField: 'CODENAME',
            labelWidth: 100
        });
        this.storeZhuangXieGong.load();



        //装卸费计费标准
        Ext.define('ZhuangXieFeiTypemb', {
            extend: 'Ext.data.Model',
            fields: [
                { name: 'type', type: 'string' }
            ]
        });
        var ZhuangXieFeiData = [
            { "type": "件数" }, { "type": "吨" }];
        this.storeZhuangXieFeiType = Ext.create('Ext.data.Store', {
            model: 'ZhuangXieFeiTypemb',
            data: ZhuangXieFeiData
        });
        this.comboxZhuangXieFeiType = Ext.create('DsExt.ux.RefEnumCombox',
            {
                forceSelection: true,
                store: this.storeZhuangXieFeiType,
                name: 'ZhuangXieFeeType',
                allowBlank: false,
                valueField: 'type',
                displayField: 'type'
            });

        //#region 进口国
        Ext.define('ConutryRef', {
            extend: 'Ext.data.Model',
            fields: [
              { name: 'countryid', type: 'string' },
              { name: 'country', type: 'string' },
              { name: 'country_idandname', type: 'string' }
            ]
        });
        this.storeCountry = Ext.create('DsExt.ux.RefTableStore', {
            model: 'ConutryRef',
            proxy: { url: '/CommMng/BasicDataRef/GetCountryRefList' }
        });
        this.storeCountry.load({ params: { condition: ""} });
        this.comboxCountry = Ext.create('DsExt.ux.RefTableCombox', {
            fieldLabel: '进口国',
            flex: 1,
            forceSelection: true,
            store: this.storeCountry,
            name: 'COUNTRYID',
            valueField: 'countryid',
            displayField: 'country_idandname',
            listeners: {
                specialkey: function (field, e) {
                    if (e.getKey() == e.ENTER) {
                        _this.onRefreshClick("");
                    }
                }
            }
        });
        //#endregion
        //#endregion
        

        //#region formSearch 查询面板
        this.formSearch = Ext.widget('form', {
            title: '查询信息',
            frame: true,
            //collapsible: true, //将激活折叠功能
            region: 'north',
            border: false,
            fieldDefaults: {
                margins: '2 2 2 2',
                labelAlign: 'right',
                flex: 1,
                labelWidth: 60,
                msgTarget: 'qtip'
            },

            items: [{ //fieldset 1
                xtype: 'container',
                defaultType: 'textfield',
                layout: 'anchor',
                defaults: {
                    anchor: '100%'
                },
                items: [{
                    xtype: 'container',
                    layout: 'hbox',
                    defaultType: 'textfield',
                    items: [{   fieldLabel: '单号',
                            name: 'BLNO',
                            flex: 1,
                            enableKeyEvents: true, //激活键盘事件
                            listeners: {
                                scope: this,
                                'keyup': {
                                    fn: function(_field, e) {
                                        if (e.getKey() == 13) {
                                            this.onRefreshClick("");
                                        }
                                    },
                                    scope: this
                                }
                          
                            }
                        }, {
                            fieldLabel: '入库单号',
                            name: 'WMSNO',
                            flex: 1,
                            editable: false,
                            enableKeyEvents: true, //激活键盘事件
                            listeners: {
                                scope: this,
                                'keyup': {
                                    fn: function(_field, e) {
                                        if (e.getKey() == 13) {
                                            this.onRefreshClick("");
                                        }
                                    },
                                    scope: this
                                }
                              
                            }
                        }, this.comboxCustCode, this.comboxSTORAGENAME, this.comboxGOODSNAME, this.comboxCodeGoodsDetail, {
                            xtype: 'button',
                            width: 80,
                            
                            text: "执行查询",
                            iconCls: "btnrefresh",
                            handler: function(button, event) {
                                this.onRefreshClick(button, event);
                            },
                            scope: this
                        }, {
                            fieldLabel: '追加',
                            inputValue: true,
                            flex: 0.4,
                            labelWidth: 40,
                            labelAlign: 'right',
                            xtype: 'checkboxfield',
                            name: 'ISADD'
                        }
                    ]
                }, {
                    xtype: 'container',
                    layout: 'hbox',
                    defaultType: 'textfield',
                    items: [{
                            fieldLabel: '批次号',
                            name: 'PICIHAO',
                            flex: 1,
                            editable: false,
                            enableKeyEvents: true, //激活键盘事件
                            listeners: {
                                scope: this,
                                'keyup': {
                                    fn: function(_field, e) {
                                        if (e.getKey() == 13) {
                                            this.onRefreshClick("");
                                            this.formSearch.getForm().findField('PICIHAO').emptyText = this.pcnostr;
                                        }
                                    },
                                    scope: this
                                }
                            }
                        }, {
                            fieldLabel: '箱号',
                            name: 'CNTRNO',
                            editable: false,
                            flex: 1,
                            enableKeyEvents: true, //激活键盘事件
                            listeners: {
                                scope: this,
                                'keyup': {
                                    fn: function(_field, e) {
                                        if (e.getKey() == 13) {
                                            this.onRefreshClick("");
                                            this.formSearch.getForm().findField('CNTRNO').emptyText = this.cntrstr;
                                        }
                                    },
                                    scope: this
                                }
                            }
                        },
                        this.comboxCountry, {
                            xtype: 'hiddenfield',
                            flex: 1
                        },
                        {
                            xtype: 'hiddenfield',
                            flex: 1
                        },
                        {
                            xtype: 'hiddenfield',
                            flex: 1
                        },{
                            xtype: 'button',
                            width: 80,
                            text: "重置条件",
                           
                            iconCls: "btnreset",
                            handler: function (button, event) {
                                this.onClearSql(button, event);
                                this.pcnostr = "";
                                this.cntrstr = "";

                            },
                            scope: this
                        }, {
                            xtype: 'hiddenfield',
                            flex: 0.4
                        }]
                    }
                ]//end items(fieldset 1)
            }]//end root items
        });
        //#endregion formSearch

        //#region 快递公司Combox
        this.storeExpress = Ext.create('DsExt.ux.RefTableStore', {
            model: 'DsShipping.ux.CustomRefModel',
            proxy: { url: '/CommMng/BasicDataRef/GetCustomRefList' }
        });
        this.storeExpress.load({ params: { condition: "ISEXPRESS='1'" } });
        
        this.comboxEXPRESS = Ext.create('DsExt.ux.RefTableCombox', {
            fieldLabel: '快递公司',
            store: this.storeExpress,
            forceSelection: true,
            name: 'EXPRESSCORP',
            valueField: 'CustName',
            displayField: 'CodeAndName'
        });
        //#endregion
        

        //#region 编辑formHead 基本信息
        this.formHead = Ext.widget('form', {
            title: this.stockTypeName, //'出库信息',
            frame: true,
            region: 'north',
            border: false,
            fieldDefaults: {
                margins: '2 2 2 2',
                labelAlign: 'right',
                flex: 1,
                labelWidth: 90,
                msgTarget: 'qtip'
            },

            items: [{//fieldset 1
                xtype: 'container',
                defaultType: 'textfield',
                layout: 'anchor',
                defaults: {
                    anchor: '100%'
                },
                items: [{
                    xtype: 'container',
                    layout: 'hbox',
                    defaultType: 'textfield',
                    items: [{
                            fieldLabel: '出库主表GID',
                            name: 'OUTGID',
                            hidden: true
                        }, {
                            fieldLabel: '出库单号',
                            name: 'OUTBSNO_OUT',
                            editable: true,
    //                        readOnly: true,
                            disabled: false
                        }, {
                            fieldLabel: '出库日期',
                            name: 'DODATE_OUT',
                            xtype: 'datefield',
                            format: 'Y-m-d',
                            value: currdate.format('yyyy-MM-dd'),
                            editable: false,
                            allowBlank: false,
                            listeners: {
                                select: function (dfield, records, eOpts) {
                                    var sDODATE_OUT = dfield.rawValue;
                                    Ext.getCmp('OLDCUSTFEEDATE').setValue(sDODATE_OUT);
                                }
                            }
                        }, {
                            fieldLabel: '结束计费日期', //需求编号:SR2017073000001
                            id: 'OLDCUSTFEEDATE',
                            name: 'OLDCUSTFEEDATE',
                            xtype: 'datefield',
                            format: 'Y-m-d',
                            value: currdate.format('yyyy-MM-dd'),
                            editable: false,
                            allowBlank: false
                        }, this.comboxCLIENTNAMEOLD, this.comboxARCLIENTWMSOUT, this.comboxARCLIENT //需求编号:SR2017073000001
                        ]
                    }, {
                        xtype: 'container',
                        layout: 'hbox',
                        defaultType: 'textfield',
                        items: [{
                            fieldLabel: '费用状态',
                            readOnly: true,
                            disabled: true,
                            name: 'FEESTATUSREF_OUT'
                        }, {
                            fieldLabel: '会计期间',
                            name: 'ACCDATE_OUT',
                            xtype: 'monthfield',
                            format: 'Y-m',
                            value: currdate.format('yyyy-MM'),
                            editable: false,
                            allowBlank: false
                        }, this.comboxTRUCKNAME //需求编号:SR2017073000001
                        , this.comboxEXPRESS, {
                                fieldLabel: '快递单号',
                            name: 'EXPRESSEXNO'
                            }, {
                                xtype: "checkbox",          //checkbox控件
                                id: "cbCCF",
                                name: "cbCCF",
                                boxLabel: "",
                                fieldLabel: "是否生成仓储费",
                                inputValue: "true",         //选中的值
                                uncheckedValue: "false",     //未选中的值
                                checked: true             //绘制时的选中状态
                            }]
                    }, {
                        xtype: 'container',
                        layout: 'hbox',
                        defaultType: 'textfield',
                        items: [{
                                fieldLabel: '配额号',
                                name: 'QUOTANO'
                              },{
                                fieldLabel: '面积',
                                name: 'RENTAREA',
                                value:'0'
                            },{
                               fieldLabel: '备注2',
                               name: 'OUTREMARK2'
                           }, {
                            fieldLabel: '备注',
                            flex:3.03, //需求编号:SR2017073000001
                            name: 'OUTREMARK'
                        }]
                    }, {
                        //SR2020030900003
                        xtype: 'container',
                        layout: 'hbox',
                        defaultType: 'textfield',
                        items: [{
                            fieldLabel: '箱型箱量',
                            name: 'CNTRTOTAL',
                            flex:2.01
                        }, {
                                fieldLabel: '重量',
                                name: 'KGS_OUT',
                                xtype: 'numberfield',
                                allowDecimals: true, //允许输入小数
                                decimalPrecision: 4,
                                minValue: 0,//最小值
                                selectOnFocus: true,
                                mouseWheelEnabled: true,
                                enableKeyEvents: true,
                                nanText: '请输入有效数字',
                                value: '0'
                            }, {
                                fieldLabel: '件数',
                                name: 'PKGS_OUT',
                                xtype: 'numberfield',
                                allowDecimals: true, //允许输入小数
                                decimalPrecision: 4,
                                minValue: 0,//最小值
                                selectOnFocus: true,
                                mouseWheelEnabled: true,
                                enableKeyEvents: true,
                                nanText: '请输入有效数字',
                                value: '0'
                            }, {
                                fieldLabel: '尺码',
                                name: 'CBM_OUT',
                                xtype: 'numberfield',
                                allowDecimals: true, //允许输入小数
                                decimalPrecision: 4,
                                minValue: 0,//最小值
                                selectOnFocus: true,
                                mouseWheelEnabled: true,
                                enableKeyEvents: true,
                                nanText: '请输入有效数字',
                                value: '0'
                            }, {
                            xtype:'hiddenfield',
                            flex: 1
                        }]
                    }]//end items(fieldset 1)
            }]//end root items
        });
        //#endregion

        //#region 权限范围
        /*
        this.StoreOpRange = Ext.create('DsExt.ux.RefTableStore', {
        model: 'MsOP',
        //proxy: { url: '/MvcShipping/MsBaseInfo/GetOpRang' }
        proxy: { url: '/MvcShipping/MsBaseInfo/GetOpRang4' }
        });
        this.StoreOpRange.load({ params: { optype: "WMSOUT_GuiGeCHECKED"} });

        this.StoreOpRange2 = Ext.create('DsExt.ux.RefTableStore', {
        model: 'MsOP',
        //proxy: { url: '/MvcShipping/MsBaseInfo/GetOpRang' }
        proxy: { url: '/MvcShipping/MsBaseInfo/GetOpRang4' }
        });
        this.StoreOpRange2.load({ params: { optype: "WMSOUT_GuiGeNotCHECKED"} });
        */
        //#endregion

        //#region 出库明细列表

        //#region 定义数据集 出库单
        this.storeDetailList = Ext.create('Ext.data.Store', {
            model: 'VwWmsDetailModel',
            remoteSort: true,
            proxy: {
                type: 'ajax',
                url: '/MvcShipping/WMSOUT_GuiGe/GetDetailList',
                reader: {
                    id: 'NID',
                    root: 'data',
                    totalProperty: 'totalCount'
                }
            }
        });
        /*追加查询数据集*/
        this.storeDetailListAdd = Ext.create('Ext.data.Store', {
            model: 'VwWmsDetailModel',
            remoteSort: true,
            proxy: {
                type: 'ajax',
                url: '/MvcShipping/WMSOUT_GuiGe/GetDetailList',
                reader: {
                    id: 'NID',
                    root: 'data',
                    totalProperty: 'totalCount'
                }
            }
        });
        //#endregion



        //#region 列定义
        this.initgirdDrcolums = [
            {
            sortable: false,//1
            dataIndex: 'NID',
            header: '', //唯一编码
            hidden: true,
            width: 0
            },
            {
                sortable: false,//2
                dataIndex: 'ISDETAIL',
                header: '', //是否明细出库
                hidden: true,
                width: 0
            },
        {
            //需求编号:SR2017062600003
            sortable: false,//3
            dataIndex: 'ISBONDEDNAME',
            header: '是否保税业务',
            align: 'center',
            width: 80
        },
        {
            sortable: false,//4
            dataIndex: 'CUSTOMERNAME',
            header: '客户名称', //需求编号:SR2017071300002-2
            width: 120
        },
        {
            sortable: false,//5
            dataIndex: 'STORAGENAME',
            header: '所属仓库',
            width: 120
        },
        {
            sortable: false,//6
            dataIndex: 'BLNO',
            header: '提单号',
            width: 120
        }, {
            sortable: false,//7
            dataIndex: 'PICIHAO',
            header: '批次号',
            width: 120
         },
         {
            sortable: false,//8
            dataIndex: 'TRAYNO',
            header: '托号',
            width: 120
        },
        {
            sortable: false,//9
            dataIndex: 'CNTRNO',
            header: '箱号',
            width: 120,
            editor: {
                xtype: 'textfield',
                selectOnFocus: true,
                enableKeyEvents: true, //激活键盘事件
                listeners: {
                    scope: this,
                    keydown: function (textfield, e) {
                        if (e.getKey() == 40) {
                            _this.onNextKeyClick(9)
                        }
                    }

                }
            }
        },
        {
            sortable: false,//10
            dataIndex: 'SEALNO',
            header: '封号',
            width: 120,
            editor: {
                xtype: 'textfield',
                selectOnFocus: true,
                enableKeyEvents: true, //激活键盘事件
                listeners: {
                    scope: this,
                    keydown: function (textfield, e) {
                        if (e.getKey() == 40) {
                            _this.onNextKeyClick(10)
                        }
                    }

                }
            }
        },
        {
            sortable: false,//11
            dataIndex: 'WMSNO',
            header: '入库单号',
            width: 120
        },
        {
           sortable: false,//12
           dataIndex: 'CONTRACTNO',
           header: '合同号',
           width: 120
        },
        {
            sortable: false,//13
            dataIndex: 'MODEL',
            header: '牌号',
            width: 100
        },
        {
            sortable: false,//14
            dataIndex: 'WMSDATE',
            header: '入库时间',
            width: 80
        },
        {
            sortable: false,//15
            dataIndex: 'GOODSNAME',
            header: '品名',
            width: 120
        },
        {
            sortable: false,//16
            dataIndex: 'GOODSMODEL',
            header: '单位', //品牌,需求编号:SR2017061800001-12
            width: 60
        },
        {
            sortable: false,//17
            dataIndex: 'GOODSSTANDARD',
            header: '规格',
            align: 'right',
            width: 60
        },
        {
            sortable: false,//18
            dataIndex: 'GOODSPACKSTOCK',
            header: '剩余件数',
            align: 'right',
            width: 80,
            summaryType: 'sum',
            summaryRenderer: function (value) {
                return Ext.util.Format.number(value, '0.00');

            }
        },
        {
            //需求编号:SR2017062200002
            sortable: false,//19
            dataIndex: 'WeiWanShui',
            header: '未完税件数',
            align: 'right',
            width: 80
        },
        {
            sortable: false,//20
            dataIndex: 'GOODSNUM',
            header: '完税库存件数', //需求编号:SR2017062200002
            align: 'right',
            renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
                if (value < 0) { return 0; }
                else {
                    return value;
                }
            },
            width: 80
        },
        {
            sortable: false,//21
            dataIndex: 'GOODSPACKPFSL_OUT',
            header: '出库件数',
            align: 'right',
            width: 80,
            editor: {
                xtype: 'numberfield',
                allowBlank: false,
                selectOnFocus: true, //得到焦点时自动选择文本  
                allowDecimals: true, //允许输入小数  
                nanText: '请输入有效数值',
                value: 0,
                minValue: 0,
                //maxValue: 100000,
                keyNavEnabled: false, //键盘导航是否可用,启用后可以通过键盘的上下箭头调整数值
                hideTrigger: true, //是否隐藏上下调节按钮
                mouseWheelEnabled: false, //鼠标滚轮是否可用,启用后可以通过滚动鼠标滚轮调整数值
                //step: 2,//通过调节按钮、键盘、鼠标滚轮调节数值时的大小
                enableKeyEvents: true, //激活键盘事件
                listeners: {
                    scope: this,
                    keydown: function (textfield, e) {
                        if (e.getKey() == 40) {
                            _this.onNextKeyClick(21)
                        }
                    }
                    
                }
            },
            summaryType: 'sum',
            summaryRenderer: function (value) {
                return Ext.util.Format.number(value, '0.00');

            }
        },
        {
            //需求编号:SR2017061800001-7,SR2017071100001
            sortable: false,//22
            dataIndex: 'GOODSSLICE_OUT',
            header: '出库包装件数',
            align: 'right',
            width: 80
        }
        ,
        {
            sortable: false,//23
            dataIndex: 'GOODSSTOCK',
            header: '剩余库存',
            width: 80,
            summaryType: 'sum',
            summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
                value = usMoney(value, 4, '', true);
                return value;
            }
            },
            {
                sortable: false,//18
                dataIndex: 'GOODSCKQSTOCK',
                header: '出库前库存',
                width: 80
            }
        ,
        {
            sortable: false,//24
            dataIndex: 'GOODSPFSL_OUT',
            header: '出库量',
            align: 'right',
            width: 80,
            editor: {
                xtype: 'numberfield',
                allowBlank: false,
                selectOnFocus: true, //得到焦点时自动选择文本  
                allowDecimals: true, //允许输入小数  
                nanText: '请输入有效数值',
                value: 0,
                minValue: 0,
                decimalPrecision: 4,
                //maxValue: 100000,
                keyNavEnabled: false, //键盘导航是否可用,启用后可以通过键盘的上下箭头调整数值
                hideTrigger: true, //是否隐藏上下调节按钮
                mouseWheelEnabled: false, //鼠标滚轮是否可用,启用后可以通过滚动鼠标滚轮调整数值
                //step: 2,//通过调节按钮、键盘、鼠标滚轮调节数值时的大小
                enableKeyEvents: true, //激活键盘事件
                listeners: {
                    scope: this,
                    keydown: function (textfield, e) {
                        if (e.getKey() == 40) {
                            _this.onNextKeyClick(24)
                        }
                    }

                }
            },
            summaryType: 'sum',
            summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
                value = usMoney(value, 4, '', true);
                return value;
            }
        },
        {
            //需求编号:SR2017073000001
            sortable: false,//25
            dataIndex: 'QianFengNO',
            header: '铅封号',
            width: 100,
            editor: {
                xtype: 'textfield',
                selectOnFocus: true,
                enableKeyEvents: true, //激活键盘事件
                listeners: {
                    scope: this,
                    keydown: function (textfield, e) {
                        if (e.getKey() == 40) {
                            _this.onNextKeyClick(25)
                        }
                    }

                }
            }
        },
        {
            //需求编号:SR2017073000001
            sortable: false,//26
            dataIndex: 'TRUCKNO_OUT',
            header: '车号',
            width: 100,
            editor: {
                xtype: 'textfield',
                selectOnFocus: true,
                enableKeyEvents: true, //激活键盘事件
                listeners: {
                    scope: this,
                    keydown: function (textfield, e) {
                        if (e.getKey() == 40) {
                            _this.onNextKeyClick(26)
                        }
                    }

                }
            }
            },
            {
                //中棉需求,司机证件号码
                sortable: false,//27
                dataIndex: 'DRIVERIDCARD',
                header: '司机证件号码',
                width: 100,
                editor: {
                    xtype: 'textfield',
                    selectOnFocus: true,
                    enableKeyEvents: true, //激活键盘事件
                    listeners: {
                        scope: this,
                        keydown: function (textfield, e) {
                            if (e.getKey() == 40) {
                                _this.onNextKeyClick(27)
                            }
                        }

                    }
                }
            },{
            //需求编号:SR2017073000001
            sortable: false,//28//29
            dataIndex: 'TRUCKTYPE_OUT',
            header: '车辆类型',
            width: 100,
            editor: this.comboxTRUCKTYPE
            }, {
                hidden: false,
                dataIndex: 'ZHUANGXIEGONGID_OUT',
                header: '装卸工',
                width: 80,
                editor: this.comboxZhuangXieGong,
                renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {

                    return record.data.ZHUANGXIEGONG_OUT; 

                }
            },
            {
                hidden: false,//30
                dataIndex: 'ZhuangXieFeeType',
                header: '装卸计费标准',
                width: 80,
                editor: this.comboxZhuangXieFeiType
            }, {
                hidden: false,//31
                dataIndex: 'ZhuangXieFeiDanJiaTon',
                header: '装卸费单价(吨)',
                width: 80
            }, {
                hidden: false,//32
                dataIndex: 'ZhuangXieFeiDanJiaJian',
                header: '装卸费单价(件)',
                width: 80
            },
            {
                sortable: false,//33
                dataIndex: 'ZHUANGXIEFEI',
                header: '装卸费',
                align: 'right',
                width: 100,
                summaryType: 'sum',
                editor: {
                    xtype: 'numberfield',
                    allowBlank: false,
                    selectOnFocus: true, //得到焦点时自动选择文本  
                    allowDecimals: true, //允许输入小数  
                    nanText: '请输入有效小数',
                    minValue: -999999999.99,
                    maxValue: 999999999.99,
                    value: 0.00,
                    keyNavEnabled: false, //键盘导航是否可用,启用后可以通过键盘的上下箭头调整数值
                    hideTrigger: true, //是否隐藏上下调节按钮
                    mouseWheelEnabled: false //鼠标滚轮是否可用,启用后可以通过滚动鼠标滚轮调整数值
                    //step: 2,//通过调节按钮、键盘、鼠标滚轮调节数值时的大小
                },
                renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
                    value = usMoney(value, 2, '', true);
                    return value;
                },
                summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
                    value = usMoney(value, 2, '', true);
                    return value;
                }
            }, {
                sortable: false,//34
                dataIndex: 'LOADERFEE',
                header: '出库(装卸)费',
                align: 'right',
                width: 100,
                summaryType: 'sum',
                editor: {
                    xtype: 'numberfield',
                    allowBlank: false,
                    selectOnFocus: true, //得到焦点时自动选择文本  
                    allowDecimals: true, //允许输入小数  
                    nanText: '请输入有效小数',
                    minValue: -999999999.99,
                    maxValue: 999999999.99,
                    value: 0.00,
                    keyNavEnabled: false, //键盘导航是否可用,启用后可以通过键盘的上下箭头调整数值
                    hideTrigger: true, //是否隐藏上下调节按钮
                    mouseWheelEnabled: false //鼠标滚轮是否可用,启用后可以通过滚动鼠标滚轮调整数值
                    //step: 2,//通过调节按钮、键盘、鼠标滚轮调节数值时的大小
                },
                renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
                    value = usMoney(value, 2, '', true);
                    return value;
                },
                summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
                    value = usMoney(value, 2, '', true);
                    return value;
                }
            },{
            //需求编号:SR2017073000001
            sortable: false,//35
            dataIndex: 'TRUCKKGS_OUT',
            header: '平均重量',
            value: '0',
            width: 80
        },
        {
            //需求编号:SR2017073000001
            sortable: false,//36
            dataIndex: 'ARFEE_OUT',
            header: '铅封费',
            align: 'right',
            width: 100,
            summaryType: 'sum',
            editor: {
                xtype: 'numberfield',
                allowBlank: false,
                selectOnFocus: true, //得到焦点时自动选择文本  
                allowDecimals: true, //允许输入小数  
                nanText: '请输入有效小数',
                minValue: -999999999.99,
                maxValue: 999999999.99,
                value: 0.00,
                keyNavEnabled: false, //键盘导航是否可用,启用后可以通过键盘的上下箭头调整数值
                hideTrigger: true, //是否隐藏上下调节按钮
                mouseWheelEnabled: false //鼠标滚轮是否可用,启用后可以通过滚动鼠标滚轮调整数值
                //step: 2,//通过调节按钮、键盘、鼠标滚轮调节数值时的大小
            },
            renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
                value = usMoney(value, 2, '', true);
                return value;
            },
            summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
                value = usMoney(value, 2, '', true);
                return value;
            }
        },
        {
            //需求编号:SR2017073000001
            sortable: false,//37
            dataIndex: 'ARFEE_2_OUT',
            header: '过磅费',
            align: 'right',
            width: 100,
            summaryType: 'sum',
            editor: {
                xtype: 'numberfield',
                allowBlank: false,
                selectOnFocus: true, //得到焦点时自动选择文本  
                allowDecimals: true, //允许输入小数  
                nanText: '请输入有效小数',
                minValue: -999999999.99,
                maxValue: 999999999.99,
                value: 0.00,
                keyNavEnabled: false, //键盘导航是否可用,启用后可以通过键盘的上下箭头调整数值
                hideTrigger: true, //是否隐藏上下调节按钮
                mouseWheelEnabled: false //鼠标滚轮是否可用,启用后可以通过滚动鼠标滚轮调整数值
                //step: 2,//通过调节按钮、键盘、鼠标滚轮调节数值时的大小
            },
            renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
                value = usMoney(value, 2, '', true);
                return value;
            },
            summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
                value = usMoney(value, 2, '', true);
                return value;
            }
        },
        {
            //需求编号:SR2017073000001
            sortable: false,//38
            dataIndex: 'GOODSOUTFEE_OUT',
            header: '应收仓储费',
            align: 'right',
            width: 100,
            summaryType: 'sum',
            renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
                value = usMoney(value, 2, '', true);
                return value;
            },
            summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
                value = usMoney(value, 2, '', true);
                return value;
            }
        },
        {
            //需求编号:SR2017073000001
            sortable: false,//39
            dataIndex: 'GOODSOUTFEEAP_OUT',
            header: '应付仓储费',
            align: 'right',
            width: 100,
            summaryType: 'sum',
            renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
                value = usMoney(value, 2, '', true);
                return value;
            },
            summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
                value = usMoney(value, 2, '', true);
                return value;
            }
        }, {
            sortable: false,//40
            dataIndex: 'REMARK_OUT',
            header: '备注',
            width: 300,
            editor: {
                xtype: 'textfield',
                selectOnFocus: true,
                enableKeyEvents: true, //激活键盘事件
               
            }
        }, {
            sortable: false,//41
            dataIndex: 'CHIMA1',
            header: '尺码1',
            width: 120
        }, {
            sortable: false,//42
            dataIndex: 'CHIMA2',
            header: '尺码2',
            width: 120
        }, {
            sortable: false,//43
            dataIndex: 'GOODSKGS',
            header: '重量',
            width: 120,
            editor: {
                xtype: 'numberfield',
                allowBlank: false,
                selectOnFocus: true, //得到焦点时自动选择文本  
                allowDecimals: true, //允许输入小数  
                nanText: '请输入有效数值',
                value: 0,
                minValue: 0,
                decimalPrecision: 4,

                //maxValue: 100000,
                keyNavEnabled: false, //键盘导航是否可用,启用后可以通过键盘的上下箭头调整数值
                hideTrigger: true, //是否隐藏上下调节按钮
                mouseWheelEnabled: false, //鼠标滚轮是否可用,启用后可以通过滚动鼠标滚轮调整数值
                //step: 2,//通过调节按钮、键盘、鼠标滚轮调节数值时的大小
                enableKeyEvents: true, //激活键盘事件
                listeners: {
                    

                }
            },
            summaryType: 'sum',
            summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
                value = usMoney(value, 4, '', true);
                return value;
            }
        }, {
            sortable: false,//44
            dataIndex: 'ZHONGLIANG2',
            header: '重量2',
            width: 120,
            editor: {
                xtype: 'numberfield',
                allowBlank: false,
                selectOnFocus: true, //得到焦点时自动选择文本  
                allowDecimals: true, //允许输入小数  
                nanText: '请输入有效数值',
                value: 0,
                minValue: 0,
                decimalPrecision: 4,

                //maxValue: 100000,
                keyNavEnabled: false, //键盘导航是否可用,启用后可以通过键盘的上下箭头调整数值
                hideTrigger: true, //是否隐藏上下调节按钮
                mouseWheelEnabled: false, //鼠标滚轮是否可用,启用后可以通过滚动鼠标滚轮调整数值
                //step: 2,//通过调节按钮、键盘、鼠标滚轮调节数值时的大小
                enableKeyEvents: true, //激活键盘事件
                listeners: {
                   

                }
            },
            summaryType: 'sum',
            summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
                value = usMoney(value, 4, '', true);
                return value;
            }
        }, {
            sortable: false,//45
            dataIndex: 'WMSGID',
            header: '入库GID',
            hidden: true,
            width: 0
        }, {
            sortable: false,//46
            dataIndex: 'GID',
            header: '入库明细GID',
            hidden: true,
            width: 0
        }, {
            sortable: false,//47
            dataIndex: 'OUTGID',
            header: '出库GID',
            hidden: true,
            width: 0
        }, {
            sortable: false,//48
            dataIndex: 'GID_OUT',
            header: '出库明细GID',
            hidden: true,
            width: 0
        }, {
            sortable: false,//49
            dataIndex: 'BSNO_OUT',
            header: '出库明细单号',
            hidden: true,
            width: 0
        }, {
            sortable: false,//50
            dataIndex: 'ASSOCIATEDNO',
            header: '业务GID',
            hidden: true,
            width: 0
        }, {
            sortable: false,//51
            dataIndex: 'GOODSNAMEID',
            header: '品名gid',
            hidden: true,
            width: 0
        }, {
            sortable: false,//52
            dataIndex: 'WHS_CODE',
            header: '库别',
            hidden: true,
            width: 0
        }, {
            sortable: false,//53
            dataIndex: 'AREANAME',
            header: '储位',
            hidden: true,
            width: 0
        }, {
            sortable: false,//54
            dataIndex: 'BZTCHNO',
            header: '电子账册号',
            hidden: true,
            width: 0
        }, {
            sortable: false,//55
            dataIndex: 'CUSTOMNO',
            header: '报关单号',
            hidden: true,
            width: 0
        }, {
            //需求编号:SR2017061900001-1
            sortable: false,//56
            dataIndex: 'ISBONDED',
            header: '是否报税业务',
            hidden: true,
            width: 0
        },
        {
            sortable: false,//57
            dataIndex: 'GOODSPACKPFSL_OUT_2',
            header: '出库件数_用于判断',
            align: 'right',
            width: 0
        }, {
            //需求编号:SR2017073000001
            sortable: false,//58
            dataIndex: 'CHARGEUNIT',
            header: '入库计费单位',
            hidden: true,
            width: 0
        },
        {
            sortable: false,//59
            dataIndex: 'COUNTRY',
            header: '进口国',
            align: 'left',
            width: 120
            }, {
                sortable: true,//55
                dataIndex: 'Productiondate',
                header: '生产日期',
                width: 120
            }];

        this.initgirdDrcolumsChange = [
            {
                sortable: false,//1
                dataIndex: 'NID',
                header: '', //唯一编码
                hidden: true,
                width: 0
            },
            {
                sortable: false,//2
                dataIndex: 'ISDETAIL',
                header: '', //是否明细出库
                hidden: true,
                width: 0
            },
            {
                //需求编号:SR2017062600003
                sortable: false,//3
                dataIndex: 'ISBONDEDNAME',
                header: '是否保税业务',
                align: 'center',
                width: 80
            },
            {
                sortable: false,//4
                dataIndex: 'CUSTOMERNAME',
                header: '客户名称', //需求编号:SR2017071300002-2
                width: 120
            },
            {
                sortable: false,//5
                dataIndex: 'STORAGENAME',
                header: '所属仓库',
                width: 120
            },
            {
                sortable: false,//6
                dataIndex: 'BLNO',
                header: '提单号',
                width: 120
            }, {
                sortable: false,//7
                dataIndex: 'PICIHAO',
                header: '批次号',
                width: 120
            },
            {
                sortable: false,//8
                dataIndex: 'WMSNO',
                header: '入库单号',
                width: 120
            },
            {
                sortable: false,//9
                dataIndex: 'WMSDATE',
                header: '入库时间',
                width: 80
            },
            {
                sortable: false,//10
                dataIndex: 'GOODSNAME',
                header: '品名',
                width: 120
            },
            {
                sortable: false,//11
                dataIndex: 'GOODSMODEL',
                header: '单位', //品牌,需求编号:SR2017061800001-12
                width: 60
            },
            {
                sortable: false,//12
                dataIndex: 'GOODSSTANDARD',
                header: '规格',
                align: 'right',
                width: 60
            },
            {
                sortable: false,//13
                dataIndex: 'GOODSPACKSTOCK',
                header: '剩余件数',
                align: 'right',
                width: 80
            },
            {
                //需求编号:SR2017062200002
                sortable: false,//14
                dataIndex: 'WeiWanShui',
                header: '未完税件数',
                align: 'right',
                width: 80
            },
            {
                sortable: false,//15
                dataIndex: 'GOODSNUM',
                header: '完税库存件数', //需求编号:SR2017062200002
                align: 'right',
                renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
                    if (value < 0) { return 0; }
                    else {
                        return value;
                    }
                },
                width: 80
            },
            {
                sortable: false,//16
                dataIndex: 'GOODSPACKPFSL_OUT',
                header: '转移件数',
                align: 'right',
                width: 80,
                editor: {
                    xtype: 'numberfield',
                    allowBlank: false,
                    selectOnFocus: true, //得到焦点时自动选择文本  
                    allowDecimals: true, //允许输入小数  
                    nanText: '请输入有效数值',
                    value: 0,
                    minValue: 0,
                    //maxValue: 100000,
                    keyNavEnabled: false, //键盘导航是否可用,启用后可以通过键盘的上下箭头调整数值
                    hideTrigger: true, //是否隐藏上下调节按钮
                    mouseWheelEnabled: false, //鼠标滚轮是否可用,启用后可以通过滚动鼠标滚轮调整数值
                    //step: 2,//通过调节按钮、键盘、鼠标滚轮调节数值时的大小
                    enableKeyEvents: true, //激活键盘事件
                    listeners: {
                        scope: this,
                        keydown: function (textfield, e) {
                            if (e.getKey() == 40) {
                                _this.onNextKeyClick(16)
                            }
                        }

                    }
                }
            },
            {
                //需求编号:SR2017061800001-7,SR2017071100001
                sortable: false,//17
                dataIndex: 'GOODSSLICE_OUT',
                header: '出库包装件数',
                align: 'right',
                width: 80
            }
            ,
            {
                sortable: false,//18
                dataIndex: 'GOODSSTOCK',
                header: '剩余重量',
                width: 80,
                summaryType: 'sum',
                summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
                    value = usMoney(value, 2, '', true);
                    return value;
                }
            }
            ,
            {
                sortable: false,//19
                dataIndex: 'GOODSPFSL_OUT',
                header: '转移重量',
                align: 'right',
                width: 80,
                editor: {
                    xtype: 'numberfield',
                    allowBlank: false,
                    selectOnFocus: true, //得到焦点时自动选择文本  
                    allowDecimals: true, //允许输入小数  
                    nanText: '请输入有效数值',
                    value: 0,
                    minValue: 0,
                    decimalPrecision: 4,

                    //maxValue: 100000,
                    keyNavEnabled: false, //键盘导航是否可用,启用后可以通过键盘的上下箭头调整数值
                    hideTrigger: true, //是否隐藏上下调节按钮
                    mouseWheelEnabled: false, //鼠标滚轮是否可用,启用后可以通过滚动鼠标滚轮调整数值
                    //step: 2,//通过调节按钮、键盘、鼠标滚轮调节数值时的大小
                    enableKeyEvents: true, //激活键盘事件
                    listeners: {
                        scope: this,
                        keydown: function (textfield, e) {
                            if (e.getKey() == 40) {
                                _this.onNextKeyClick(19)
                            }
                        }

                    }
                },
                summaryType: 'sum',
                summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
                    value = usMoney(value, 2, '', true);
                    return value;
                }
            },
            {
                //需求编号:SR2017073000001
                sortable: false,//20
                dataIndex: 'QianFengNO',
                header: '铅封号',
                width: 100,
                editor: {
                    xtype: 'textfield',
                    selectOnFocus: true,
                    enableKeyEvents: true, //激活键盘事件
                    listeners: {
                        scope: this,
                        keydown: function (textfield, e) {
                            if (e.getKey() == 40) {
                                _this.onNextKeyClick(20)
                            }
                        }

                    }
                }
            },
            {
                //需求编号:SR2017073000001
                sortable: false,//21
                dataIndex: 'TRUCKNO_OUT',
                header: '车号',
                width: 100,
                editor: {
                    xtype: 'textfield',
                    selectOnFocus: true,
                    enableKeyEvents: true, //激活键盘事件
                    listeners: {
                        scope: this,
                        keydown: function (textfield, e) {
                            if (e.getKey() == 40) {
                                _this.onNextKeyClick(21)
                            }
                        }

                    }
                }
            },
            {
                //中棉需求,司机证件号码
                sortable: false,//22
                dataIndex: 'DRIVERIDCARD',
                header: '司机证件号码',
                width: 100,
                editor: {
                    xtype: 'textfield',
                    selectOnFocus: true,
                    enableKeyEvents: true, //激活键盘事件
                    listeners: {
                        scope: this,
                        keydown: function (textfield, e) {
                            if (e.getKey() == 40) {
                                _this.onNextKeyClick(22)
                            }
                        }

                    }
                }
            },{
                //需求编号:SR2017073000001
                sortable: false,//23
                dataIndex: 'TRUCKTYPE_OUT',
                header: '车辆类型',
                width: 100,
                editor: this.comboxTRUCKTYPE
            }, {
                //需求编号:SR2017073000001
                sortable: false,//24
                dataIndex: 'ZHUANGXIEGONGID_OUT',
                header: '装卸工',
                width: 100,
                editor: this.comboxZhuangXieGong,
                renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {

                    return record.data.ZHUANGXIEGONG_OUT;

                }
            }, {
                //需求编号:SR2017073000001
                sortable: false,//25
                dataIndex: 'TRUCKKGS_OUT',
                header: '平均重量',
                value: '0',
                width: 80
            },
            {
                //需求编号:SR2017073000001
                sortable: false,//26
                dataIndex: 'ARFEE_OUT',
                header: '铅封费',
                align: 'right',
                width: 100,
                summaryType: 'sum',
                editor: {
                    xtype: 'numberfield',
                    allowBlank: false,
                    selectOnFocus: true, //得到焦点时自动选择文本  
                    allowDecimals: true, //允许输入小数  
                    nanText: '请输入有效小数',
                    minValue: -999999999.99,
                    maxValue: 999999999.99,
                    value: 0.00,
                    keyNavEnabled: false, //键盘导航是否可用,启用后可以通过键盘的上下箭头调整数值
                    hideTrigger: true, //是否隐藏上下调节按钮
                    mouseWheelEnabled: false //鼠标滚轮是否可用,启用后可以通过滚动鼠标滚轮调整数值
                    //step: 2,//通过调节按钮、键盘、鼠标滚轮调节数值时的大小
                },
                renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
                    value = usMoney(value, 2, '', true);
                    return value;
                },
                summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
                    value = usMoney(value, 2, '', true);
                    return value;
                }
            },
            {
                //需求编号:SR2017073000001
                sortable: false,//27
                dataIndex: 'ARFEE_2_OUT',
                header: '过磅费',
                align: 'right',
                width: 100,
                summaryType: 'sum',
                editor: {
                    xtype: 'numberfield',
                    allowBlank: false,
                    selectOnFocus: true, //得到焦点时自动选择文本  
                    allowDecimals: true, //允许输入小数  
                    nanText: '请输入有效小数',
                    minValue: -999999999.99,
                    maxValue: 999999999.99,
                    value: 0.00,
                    keyNavEnabled: false, //键盘导航是否可用,启用后可以通过键盘的上下箭头调整数值
                    hideTrigger: true, //是否隐藏上下调节按钮
                    mouseWheelEnabled: false //鼠标滚轮是否可用,启用后可以通过滚动鼠标滚轮调整数值
                    //step: 2,//通过调节按钮、键盘、鼠标滚轮调节数值时的大小
                },
                renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
                    value = usMoney(value, 2, '', true);
                    return value;
                },
                summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
                    value = usMoney(value, 2, '', true);
                    return value;
                }
            },
            {
                //需求编号:SR2017073000001
                sortable: false,//28
                dataIndex: 'GOODSOUTFEE_OUT',
                header: '应收仓储费',
                align: 'right',
                width: 100,
                summaryType: 'sum',
                renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
                    value = usMoney(value, 2, '', true);
                    return value;
                },
                summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
                    value = usMoney(value, 2, '', true);
                    return value;
                }
            },
            {
                //需求编号:SR2017073000001
                sortable: false,//29
                dataIndex: 'GOODSOUTFEEAP_OUT',
                header: '应付仓储费',
                align: 'right',
                width: 100,
                summaryType: 'sum',
                renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
                    value = usMoney(value, 2, '', true);
                    return value;
                },
                summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
                    value = usMoney(value, 2, '', true);
                    return value;
                }
            }, {
                sortable: false,//30
                dataIndex: 'REMARK_OUT',
                header: '备注',
                width: 300,
                editor: {
                    xtype: 'textfield',
                    selectOnFocus: true,
                    enableKeyEvents: true, //激活键盘事件
                    listeners: {
                        scope: this,
                        'keyup': {
                            fn: function (_field, e) {
                                if (e.getKey() == 13) {
                                    this.onNextKeyClick(15);
                                }
                            },
                            scope: this
                        }
                    }
                }
            }, {
                sortable: false,//31
                dataIndex: 'CHIMA1',
                header: '尺码1',
                width: 120
            }, {
                sortable: false,//32
                dataIndex: 'CHIMA2',
                header: '尺码2',
                width: 120
            }, {
                sortable: false,//33
                dataIndex: 'GOODSKGS',
                header: '重量',
                width: 120,
                editor: {
                    xtype: 'numberfield',
                    allowBlank: false,
                    selectOnFocus: true, //得到焦点时自动选择文本  
                    allowDecimals: true, //允许输入小数  
                    nanText: '请输入有效数值',
                    value: 0,
                    minValue: 0,
                    decimalPrecision: 4,

                    //maxValue: 100000,
                    keyNavEnabled: false, //键盘导航是否可用,启用后可以通过键盘的上下箭头调整数值
                    hideTrigger: true, //是否隐藏上下调节按钮
                    mouseWheelEnabled: false, //鼠标滚轮是否可用,启用后可以通过滚动鼠标滚轮调整数值
                    //step: 2,//通过调节按钮、键盘、鼠标滚轮调节数值时的大小
                    enableKeyEvents: true, //激活键盘事件
                    listeners: {
                        scope: this,
                        keydown: function (textfield, e) {
                            if (e.getKey() == 40) {
                                _this.onNextKeyClick(33)
                            }
                        }

                    }
                },
                summaryType: 'sum',
                summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
                    value = usMoney(value, 4, '', true);
                    return value;
                }
            }, {
                sortable: false,//34
                dataIndex: 'ZHONGLIANG2',
                header: '重量2',
                width: 120,
                editor: {
                    xtype: 'numberfield',
                    allowBlank: false,
                    selectOnFocus: true, //得到焦点时自动选择文本  
                    allowDecimals: true, //允许输入小数  
                    nanText: '请输入有效数值',
                    value: 0,
                    minValue: 0,
                    decimalPrecision: 4,

                    //maxValue: 100000,
                    keyNavEnabled: false, //键盘导航是否可用,启用后可以通过键盘的上下箭头调整数值
                    hideTrigger: true, //是否隐藏上下调节按钮
                    mouseWheelEnabled: false, //鼠标滚轮是否可用,启用后可以通过滚动鼠标滚轮调整数值
                    //step: 2,//通过调节按钮、键盘、鼠标滚轮调节数值时的大小
                    enableKeyEvents: true, //激活键盘事件
                    listeners: {
                        scope: this,
                        keydown: function (textfield, e) {
                            if (e.getKey() == 40) {
                                _this.onNextKeyClick(34)
                            }
                        }

                    }
                },
                summaryType: 'sum',
                summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
                    value = usMoney(value, 4, '', true);
                    return value;
                }
            }, {
                sortable: false,//35
                dataIndex: 'WMSGID',
                header: '入库GID',
                hidden: true,
                width: 0
            }, {
                sortable: false,//36
                dataIndex: 'GID',
                header: '入库明细GID',
                hidden: true,
                width: 0
            }, {
                sortable: false,//37
                dataIndex: 'OUTGID',
                header: '出库GID',
                hidden: true,
                width: 0
            }, {
                sortable: false,//38
                dataIndex: 'GID_OUT',
                header: '出库明细GID',
                hidden: true,
                width: 0
            }, {
                sortable: false,//39
                dataIndex: 'BSNO_OUT',
                header: '出库明细单号',
                hidden: true,
                width: 0
            }, {
                sortable: false,//40
                dataIndex: 'ASSOCIATEDNO',
                header: '业务GID',
                hidden: true,
                width: 0
            }, {
                sortable: false,//41
                dataIndex: 'GOODSNAMEID',
                header: '品名gid',
                hidden: true,
                width: 0
            }, {
                sortable: false,//42
                dataIndex: 'WHS_CODE',
                header: '库别',
                hidden: true,
                width: 0
            }, {
                sortable: false,//43
                dataIndex: 'AREANAME',
                header: '储位',
                hidden: true,
                width: 0
            }, {
                sortable: false,//44
                dataIndex: 'BZTCHNO',
                header: '电子账册号',
                hidden: true,
                width: 0
            }, {
                sortable: false,//45
                dataIndex: 'CUSTOMNO',
                header: '报关单号',
                hidden: true,
                width: 0
            }, {
                //需求编号:SR2017061900001-1
                sortable: false,//46
                dataIndex: 'ISBONDED',
                header: '是否报税业务',
                hidden: true,
                width: 0
            },
            {
                sortable: false,//47
                dataIndex: 'GOODSPACKPFSL_OUT_2',
                header: '出库件数_用于判断',
                align: 'right',
                width: 0
            }, {
                //需求编号:SR2017073000001
                sortable: false,//48
                dataIndex: 'CHARGEUNIT',
                header: '入库计费单位',
                hidden: true,
                width: 0
            },
            {
                sortable: false,//49
                dataIndex: 'COUNTRY',
                header: '进口国',
                align: 'left',
                width: 120
            }
            , {
                sortable: true,//55
                dataIndex: 'Productiondate',
                header: '生产日期',
                width: 120
            }
        ];

        if (this.changeType === '0') {
            this.girdcolums = this.initgirdDrcolums;

        }
        else if (this.changeType === '1') {
            this.girdcolums = this.initgirdDrcolumsChange;
        }


        
        this.girdcolums = DsTruck.GetGridPanel(GID, this.formname, this.girdcolums, 0); //使用者id,表名,中间column数组,跳过一开始的几列
        //#endregion

        //#region gridList列表显示信息
        this.gridListCellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
            clicksToEdit: 1 //1单击,2双击
        });

        this.gridList = new Ext.grid.GridPanel({
            region: 'center',
            store: this.storeDetailList,
            enableHdMenu: false, //是否显示表格列的菜单
            hideHeaders: false, //是否隐藏表头
            enableColumnHide: true, ///隐藏表头列
            sortableColumns: false, ///隐藏表头排序
            //disableSelection: false, //是否禁止选择表格行或列,默认为false
            //trackMouseOver: true, //高亮显示鼠标所在的行,默认为true,
            //stripeRows: true, //斑马线效果
            rowLines: true,
            columnLines: true,
            loadMask: { msg: "数据加载中,请稍等..." },
            plugins: [this.gridListCellEditing],
            selType: 'cellmodel',
            columns: this.girdcolums,
            features: [{
                ftype: 'summary'//Ext.grid.feature.Summary表格汇总特性
            }],
            listeners: {
                scope: this,
                'edit': function (editor, e, eOpts) {
                    if (e.value == e.originalValue) { return; }
                    if (e.field == "GOODSPACKPFSL_OUT") {
                        //需求编号:SR2017073000001
                        var dlOriginalValue = e.originalValue;
                        if (this.opStatus == 'edit') {
                            dlOriginalValue = e.record.data['GOODSPACKPFSL_OUT_2']; //需求编号:SR2017073000001
                        }
                        //
                        var dlGOODSPACKPFSL_OUT = e.value; //出库件数
                        var blISBONDED = e.record.data['ISBONDED'].toString(); //是否报税业务//需求编号:SR2017061900001-1
                        if (blISBONDED == "true") {
                            //需求编号:SR2017073000001
                            var dlGOODSNUM = e.record.data['GOODSNUM'].toString(); //完税件数
                            if (this.opStatus == 'edit') {
                                dlGOODSNUM = e.record.data['GOODSNUM'] + dlOriginalValue; //完税件数
                            }
                            if (dlGOODSPACKPFSL_OUT > dlGOODSNUM) {
                                e.record.set('GOODSPACKPFSL_OUT', dlOriginalValue);
                                Ext.Msg.show({ title: '警告', msg: '注意:出库件数不能大于完税件数!', icon: Ext.Msg.WARNING, buttons: Ext.Msg.OK });
                            }
                        }
                        //需求编号:SR2017073000001
                        var dlGOODSPACKSTOCK = e.record.data['GOODSPACKSTOCK'].toString(); //剩余件数
                        if (this.opStatus == 'edit') {
                            dlGOODSPACKSTOCK = e.record.data['GOODSPACKSTOCK'] + dlOriginalValue; //剩余件数
                        }
                        if (dlGOODSPACKPFSL_OUT > dlGOODSPACKSTOCK) {
                            e.record.set('GOODSPACKPFSL_OUT', dlOriginalValue);
                            Ext.Msg.show({ title: '警告', msg: '注意:出库件数不能大于剩余件数!', icon: Ext.Msg.WARNING, buttons: Ext.Msg.OK });
                        }
                        

                        //需求编号:SR2017073000001
                        var rqWMSDATE = e.record.data['WMSDATE']; //入库日期
                        var rqDODATE_OUT = this.formHead.getForm().findField('DODATE_OUT').getRawValue(); //出库日期
                        if (rqWMSDATE > rqDODATE_OUT) {
                            e.record.set('GOODSPACKPFSL_OUT', dlOriginalValue);
                            Ext.Msg.show({ title: '警告', msg: '注意:出库日期不能小于入库日期!', icon: Ext.Msg.WARNING, buttons: Ext.Msg.OK });
                        }
                        //
                        if (this.formHead.getForm().findField('CLIENTNAMEOLD').getValue() == undefined || this.formHead.getForm().findField('CLIENTNAMEOLD').getValue().toString().trim() == "") {
                            this.formHead.getForm().findField('CLIENTNAMEOLD').setValue(e.record.data['CUSTOMERNAME'].toString()); //转移对象
                        }
                        if (this.formHead.getForm().findField('ARCLIENTWMSOUT').getValue() == undefined || this.formHead.getForm().findField('ARCLIENTWMSOUT').getValue().toString().trim() == "") {
                            this.formHead.getForm().findField('ARCLIENTWMSOUT').setValue(e.record.data['CUSTOMERNAME'].toString()); //应收仓储客户
                        }
                        if (this.formHead.getForm().findField('ARCLIENT').getValue() == undefined || this.formHead.getForm().findField('ARCLIENT').getValue().toString().trim() == "") {
                            this.formHead.getForm().findField('ARCLIENT').setValue(e.record.data['CUSTOMERNAME'].toString()); //应收出库客户
                        }
                    }
                    else if (e.field == "GOODSPFSL_OUT") {//需求编号:SR2017073000001
                        var dlGOODSPFSL_OUT = e.value; //出库量
                        var dlGOODSPACKPFSL_OUT = e.record.data['GOODSPACKPFSL_OUT'].toString(); //出库件数

                        //  added by xxq 20181213
                       
                        var dlGOODSSTOCK = e.record.data['GOODSSTOCK'].toString();
                        if ((dlGOODSPFSL_OUT > dlGOODSSTOCK) && (!this.blDESTOCK)) {
                            e.record.set('GOODSPFSL_OUT', dlOriginalValue);
                            e.record.set('GOODSSTOCK', dlOriginalValue);
                            Ext.Msg.show({ title: '警告', msg: '注意:出库量不能大于库存量!', icon: Ext.Msg.WARNING, buttons: Ext.Msg.OK });
                        }

                        if (dlGOODSPACKPFSL_OUT == 0) {
                            e.record.set('TRUCKKGS_OUT', 0);
                        }
                        else {
                            var dlTRUCKKGS_OUT = parseFloat(dlGOODSPFSL_OUT / dlGOODSPACKPFSL_OUT).toFixed(4);
                            e.record.set('TRUCKKGS_OUT', dlTRUCKKGS_OUT);
                        }
                        //
                        if (this.formHead.getForm().findField('CLIENTNAMEOLD').getValue() == undefined || this.formHead.getForm().findField('CLIENTNAMEOLD').getValue().toString().trim() == "") {
                            this.formHead.getForm().findField('CLIENTNAMEOLD').setValue(e.record.data['CUSTOMERNAME'].toString()); //转移对象
                        }
                        if (this.formHead.getForm().findField('ARCLIENTWMSOUT').getValue() == undefined || this.formHead.getForm().findField('ARCLIENTWMSOUT').getValue().toString().trim() == "") {
                            this.formHead.getForm().findField('ARCLIENTWMSOUT').setValue(e.record.data['CUSTOMERNAME'].toString()); //应收仓储客户
                        }
                        if (this.formHead.getForm().findField('ARCLIENT').getValue() == undefined || this.formHead.getForm().findField('ARCLIENT').getValue().toString().trim() == "") {
                            this.formHead.getForm().findField('ARCLIENT').setValue(e.record.data['CUSTOMERNAME'].toString()); //应收出库客户
                        }
                    }
                }
            }
        });

        this.gridList.addListener('itemclick', function (dataview, record, item, index, e, b) {
            var condition2 = "WMSOUTGID='" + record.data.OUTGID + "' and ASSOCIATEDNO='" + record.data.GID_OUT + "'";
            this.storeWmsRateDetailList.load({
                params: { condition: condition2 },
                waitMsg: "正在刷新数据...",
                timeout: 6000000, //60秒
                scope: this
            });
        }, this);
        //#endregion

        //#endregion

        //#region 仓储费列表//需求编号:SR2017073000001

        //#region 定义数据集
        this.storeWmsRateDetailList = Ext.create('Ext.data.Store', {
            model: 'WmsRateDetailModel',
            remoteSort: true,
            proxy: {
                type: 'ajax',
                url: '/MvcShipping/WMSOUT_GuiGe/GetWmsRateDetailList',
                reader: {
                    id: 'GID',
                    root: 'data',
                    totalProperty: 'totalCount'
                }
            }
        });
        //#endregion

        //#region 列定义
        this.girdcolumsWmsRateDetail = [
        
        {
            sortable: false,
            dataIndex: 'GID',
            header: '', //唯一编码
            hidden: true,
            width: 0
        },
        {
            sortable: false,
            dataIndex: 'FEETYPENAME',
            header: '费用类别',
            align: 'center',
            width: 60
        },
        {
            sortable: false,
            dataIndex: 'FEEGRADE',
            header: '计费等级',
            align: 'center',
            width: 60
        },
        {
            sortable: false,
            dataIndex: 'STARTBILLINGDATE',
            header: '开始计费日期',
            renderer: Ext.util.Format.dateRenderer('Y-m-d'),
            align: 'center',
            width: 100
        },
        {
            sortable: false,
            dataIndex: 'ENDBILLINGDATE',
            header: '结束计费日期',
            renderer: Ext.util.Format.dateRenderer('Y-m-d'),
            align: 'center',
            width: 100
        },
        {
            sortable: false,
            dataIndex: 'FEESCALE',
            header: '计费区间',
            align: 'center',
            width: 60
        }
        //        ,
        //        {
        //            sortable: false,
        //            dataIndex: 'FEEUNIT',
        //            header: '计费单位',
        //            align: 'center',
        //            width: 60
        //        }
        ,
        {
            sortable: false,
            dataIndex: 'FEEPRICE',
            header: '计费单价',
            align: 'right',
            width: 80,
            renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
                value = usMoney(value, 2, '', true);
                return value;
            }
        },
        {
            sortable: false,
            dataIndex: 'GOODSPFSL',
            header: '出库量',
            align: 'center',
            width: 80
        },
        {
            sortable: false,
            dataIndex: 'OUTFEE',
            header: '仓储费',
            align: 'right',
            width: 80,
            renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
                value = usMoney(value, 2, '', true);
                return value;
            }
        },
        {
            sortable: false,
            dataIndex: 'WMSOUTGID',
            header: 'WMSOUTGID',
            hidden: true,
            align: 'center',
            width: 0
        },
        {
            sortable: false,
            dataIndex: 'ASSOCIATEDNO',
            header: '关联号',
            hidden: true,
            align: 'center',
            width: 0
        }];
        //#endregion

        //#region gridList列表显示信息
        this.gridListWmsRateDetail = new Ext.grid.GridPanel({
            title: "仓储费用明细",
            region: 'south',
            store: this.storeWmsRateDetailList,
            enableHdMenu: false, //是否显示表格列的菜单
            hideHeaders: false, //是否隐藏表头
            enableColumnHide: false, ///隐藏表头列
            sortableColumns: false, ///隐藏表头排序
            //disableSelection: false, //是否禁止选择表格行或列,默认为false
            //trackMouseOver: true, //高亮显示鼠标所在的行,默认为true,
            //stripeRows: true, //斑马线效果
            rowLines: true,
            columnLines: true,
            loadMask: { msg: "数据加载中,请稍等..." },
            selType: 'cellmodel',
            height: 200,
            columns: this.girdcolumsWmsRateDetail
        });
        //#endregion

        //#endregion

        //#region panelFee 费用信息

        this.panelFee = new Shipping.FeeEditGrid({
            border: false,
            //title: '费用信息',
            region: 'center', //south
            layout: 'border'
            //height: 400
            //collapsible: true //将激活折叠功能
        });

        



        if (this.opStatus == 'edit') {
            this.panelFee.EditRecord = this.EditRecord;
            if (FEECONFIG == '1') {
                this.panelFee.stroplb = 'op_Seai';
                this.panelFee.strBSNO = this.EditRecord.data.ASSOCIATEDNO;
                this.panelFee.WMSOUTBSNO = this.EditRecord.data.GID;
            } else {
                this.panelFee.stroplb = 'op_other';
                this.panelFee.strBSNO = this.EditRecord.data.GID;
                this.panelFee.WMSOUTBSNO = this.EditRecord.data.GID;
                this.panelFee.strMBLNO = this.EditRecord.data.MBLNO;
            }

            //废弃。。。。。根本没关联海运进口
            /*
            this.panelFee.stroplb = 'op_other'; //需求编号:SR2017061800001-7
            this.panelFee.strBSNO = this.EditRecord.data.GID;
            this.panelFee.strMBLNO = this.EditRecord.data.BSNO;
            */
        }
        //#endregion

        _this = this;
        //#region 按钮Toolbar/框架/加载
        this.panelBtn = new Ext.Panel({
            border: false,
            region: "north",
            tbar: [{
                text: '新建',
                tooltip: '新建',
                id: "btnAdd",
                iconCls: "btnadd",
                handler: function (button, event) {
                    this.onAddClick();
                },
                scope: this
            }, '-', {
                id: 'btnSave',
                text: "保存",
                iconCls: "btnsave",
                handler: function (button, event) {
                    this.Save();
                },
                scope: this
            }, {
                text: "关闭",
                handler: function (button, event) {
                    window.close();
                },
                scope: this
            }, '-', {
                id: 'btnStock1',
                text: "已备货",
                handler: function (button, event) {
                    this.setStock('3');

                },
                    scope: this
             }, {
                id: 'btnStock2',
                text: "已装箱",
                 handler: function (button, event) {
                    this.setStock('4');

                    },
                    scope: this
                }, {
                    id: 'btnGetOpApply',
                    text: "查找出区报关单",
                    handler: function (button, event) {

                        DsOpenEditWin('/MvcShipping/MsOpApply/ChuQu', "查找出区报关单");

                    },
                    scope: this
                }, '-', {
                id: 'btnClearStock',
                text: "清库",
                handler: function (button, event) {
                    this.clearStock();

                },
                scope: this
                }, '-',{
                text: '打印',
                tooltip: '打印',
                iconCls: "btnprint",
                handler: function (button, event) {
                    this.Print(button, event);
                },
                scope: this
            }, '-', {
                text: "保存列表样式",
                menu: [{ text: "保存",
                    handler: function (button, event) {
                        //_thisfee.girdDrcolums = DsTruck.SaveGridPanel(GID, 'FEEDRGRID', _thisfee.gridDrChFee.columns, _thisfee.girdDrcolums, 0, true);
                        _this.girdcolums = DsTruck.SaveGridPanel(GID, _this.formname, _this.gridList.columns, _this.girdcolums, 0, true); //使用者id,表名,中间column数组,跳过一开始的几列

                    }
                }, { text: "初始化",
                    handler: function (menu, event) {
                        //_thisfee.gridDrChFee.reconfigure(this.storeList, _thisfee.initgirdDrcolums);
                        //_thisfee.girdDrcolums = DsTruck.SaveGridPanel(GID, 'FEEDRGRID', _thisfee.gridDrChFee.columns, _thisfee.initgirdDrcolums, 0, true);
                        _this.gridList.reconfigure(_this.storeDetailList, _this.initgirdDrcolums);
                        _this.girdcolums = DsTruck.SaveGridPanel(GID, _this.formname, _this.gridList.columns, _this.initgirdDrcolums, 0, true); //使用者id,表名,中间column数组,跳过一开始的几列
                    }
                }],
                scope: this
            }, '-', {
                text: '生成费用', id: "createcost",
                tooltip: '生成费用',
                handler: function (button, event) {
                    this.onCreateCostClick(button, event);
                },
                scope: this
            },{
                text: "费用入账",
                id: "btIslock",
                iconCls: "btislock",
                handler: function (button, event) {
                    this.setislock(button, event);
                },
                scope: this
            }, {
                text: "取消入账",
                id: "btNotIslock",
                iconCls: "btnotislock",
                handler: function (button, event) {
                    this.setnotlock(button, event);
                },
                scope: this
            }]
        }); //end 按钮Toolbar

        this.panelTop = new Ext.Panel({
            border: false,
            layout: "border",
            region: "north",
            height: 250,
            items: [this.panelBtn, this.formSearch, this.formHead]
        });

        this.page_1 = new Ext.Panel({
            border: false,
            id: "page_1",
            title: "出库明细",
            layout: "border",
            region: 'center',
            items: [this.gridList, this.gridListWmsRateDetail]
        });
        this.page_2 = new Ext.Panel({
            border: false,
            id: "page_2",
            autoScroll: true,
            title: "出库相关应收应付费用",
            layout: "border",
            region: 'center',
            items: [this.panelFee]
        });

        this.MainTab = new Ext.tab.Panel({
            border: false,
            layout: "border",
            region: "center", split: true,
            items: [this.page_1, this.page_2]
        });

        Ext.apply(this, {
            border: false,
            items: [this.panelTop, this.MainTab]
        });
        //#endregion

        //#region 页面加载

        this.setChange(this.changeType);
        if (this.blEIP) {
            this.setEIPBtn();
            var sBSNO = this.EditRecord.data.BSNO;
            this.LoadData("OUTBSNO_OUT='" + sBSNO + "'");
        }
        else if (this.opStatus == 'edit') {
            var sBSNO = this.EditRecord.data.BSNO;
            this.onRefreshClick("");
            //this.InitData(sBSNO);
            this.blISLOCK = this.EditRecord.data.ISLOCK;
            this.blEIP = this.EditRecord.data.EIP;
            this.setBtn();
           
            this.LoadData("OUTBSNO_OUT='" + sBSNO + "'");
            this.InitData(sBSNO);
        }
        else if (this.opStatus == 'add' && this.OPLBNAME == 'op_seai') {
            this.setBtn();
            this.SetOpseaiData();
            this.LoadPeriod(this.opStatus);
        }
        else {
            this.setEIPBtn();
            this.onRefreshClick(" 1<0");
            this.LoadPeriod(this.opStatus);
        }
        //#endregion
        this.gridList.on('edit', function (editor, e, eOpts) {
            this.gridListAfterEdit(editor, e, eOpts);
        }, this);


    }, //end initUIComponents

    //#region 加载事件
    InitData: function (sBSNO) {
        this.panelFee.StoreCustType.add({ "SCUSTTYPE": "WTDW-委托单位", "CUSTTYPE": "委托单位", "CUSTNAME": "CUSTOMERNAME" });
        this.panelFee.StoreCustType.add({ "SCUSTTYPE": "BGH-报关行", "CUSTTYPE": "报关行", "CUSTNAME": "CUSTOMSER" });
        this.panelFee.StoreCustType.add({ "SCUSTTYPE": "HG-海关", "CUSTTYPE": "海关", "CUSTNAME": "BYCUSTOM" });
        this.panelFee.StoreCustType.add({ "SCUSTTYPE": "DCDL-订舱代理", "CUSTTYPE": "订舱代理", "CUSTNAME": "FORWARDER" });
        this.panelFee.StoreCustType.add({ "SCUSTTYPE": "DL-代理", "CUSTTYPE": "代理", "CUSTNAME": "AGENTID" });
        this.panelFee.StoreCustType.add({ "SCUSTTYPE": "CZ-场站", "CUSTTYPE": "场站", "CUSTNAME": "YARD" });
        this.panelFee.StoreCustType.add({ "SCUSTTYPE": "CGS-船公司", "CUSTTYPE": "船公司", "CUSTNAME": "CARRIER" });
        this.panelFee.StoreCustType.add({ "SCUSTTYPE": "CD-车队", "CUSTTYPE": "车队", "CUSTNAME": "TRUCKER" });

        this.panelFee.DR_condition = "((WMSOUTBSNO in (select gid from wms_out where bsno = '" + sBSNO + "')  and feetype=1) or ( BSNO in (select gid from wms_out where bsno = '" + sBSNO + "')  and feetype=1)) ";
        this.panelFee.CR_condition = "((WMSOUTBSNO in (select gid from wms_out where bsno = '" + sBSNO + "')  and feetype=2) or ( BSNO in (select gid from wms_out where bsno = '" + sBSNO + "')  and feetype=2))";


        //费用关联海运进口
        if (FEECONFIG == '1') {
            this.panelFee.stroplb = 'op_Seai';
       
            this.panelFee.StoreDrOpRange.load({ params: { optype: "modSeaiRecvFeeManagement" } });
            this.panelFee.StoreCrOpRange.load({ params: { optype: "modSeaiPayFeeManagement" } });
            this.panelFee.StoreUnit.load({ params: { bsno: this.panelFee.strBSNO, bstype: "op_Seai" } });
            this.panelFee.storeFeeNameRef.load({ params: { condition: "" } });
            this.panelFee.StoreDateCurr.load({ params: { optype: "op_Seai", bsno: this.panelFee.strBSNO } });
          
            this.panelFee.storeDrChFee.load({ params: { billno: this.panelFee.strBSNO, type: 1, optype: "op_Seai", condition: "(( WMSOUTBSNO in (select gid from wms_out where bsno = '" + sBSNO + "')  and feetype=1) or ( BSNO in (select gid from wms_out where bsno = '" + sBSNO + "') and feetype=1) )"} });
            this.panelFee.storeCrChFee.load({ params: { billno: this.panelFee.strBSNO, type: 2, optype: "op_Seai", condition: "(( WMSOUTBSNO in (select gid from wms_out where bsno = '" + sBSNO + "')  and feetype=2) or ( BSNO in (select gid from wms_out where bsno = '" + sBSNO + "') and feetype=2) )"} });
           

           
           
        } else {
            //费用关联出库单


            this.panelFee.StoreDrOpRange.load({ params: { optype: "modOtherRecvFeeManagement" } }); 
            this.panelFee.StoreCrOpRange.load({ params: { optype: "modOtherPayFeeManagement" } }); 
            this.panelFee.StoreUnit.load({ params: { bsno: this.panelFee.strBSNO, bstype: "WMSOUT" } });

            this.panelFee.storeFeeNameRef.load({ params: { condition: "" } });
            this.panelFee.StoreDateCurr.load({ params: { optype: "op_other", bsno: this.panelFee.strBSNO } }); 

            this.panelFee.storeDrChFee.load({ params: { billno: this.panelFee.strBSNO, type: 1, optype: "op_other", condition: "(( WMSOUTBSNO in (select gid from wms_out where bsno = '" + sBSNO + "')  and feetype=1) or ( BSNO in (select gid from wms_out where bsno = '" + sBSNO + "')  and feetype=1))" } }); 
            this.panelFee.storeCrChFee.load({ params: { billno: this.panelFee.strBSNO, type: 2, optype: "op_other", condition: "(( WMSOUTBSNO in (select gid from wms_out where bsno = '" + sBSNO + "') and feetype=2) or  ( BSNO in (select gid from wms_out where bsno = '" + sBSNO + "') and feetype=2)) " } }); 

            this.panelFee.storeBodySum.load({
                params: { bsno: this.panelFee.strBSNO, optype: "op_other" }, //需求编号:SR2017061800001-7
                callback: function (r, options, success) {
                    if (success) {
                        _thisfee.setTotalHead();
                    }
                }
            });
            this.panelFee.storeChFeeGain.load({ params: { bsno: this.panelFee.strBSNO, optype: "op_other" } }); //需求编号:SR2017061800001-7
        }
        this.panelFee.storeBodyList_GuDingFeeWeiHu.load();

        //#region 废弃 只考虑进口贸易没有考虑海运进口 20190415 BY BALINGXU
        /*
        this.panelFee.StoreDrOpRange.load({ params: { optype: "modOtherRecvFeeManagement"} }); //需求编号:SR2017061800001-7
        this.panelFee.StoreCrOpRange.load({ params: { optype: "modOtherPayFeeManagement"} }); //需求编号:SR2017061800001-7
        this.panelFee.StoreUnit.load({ params: { bsno: this.panelFee.strBSNO, bstype: "op_other"} }); //需求编号:SR2017061800001-7

        this.panelFee.storeFeeNameRef.load({ params: { condition: ""} });
        this.panelFee.StoreDateCurr.load({ params: { optype: "op_other", bsno: this.panelFee.strBSNO} }); //需求编号:SR2017061800001-7

        this.panelFee.storeDrChFee.load({ params: { billno: this.panelFee.strBSNO, type: 1, optype: "op_other"} }); //需求编号:SR2017061800001-7
        this.panelFee.storeCrChFee.load({ params: { billno: this.panelFee.strBSNO, type: 2, optype: "op_other"} }); //需求编号:SR2017061800001-7

        this.panelFee.storeBodySum.load({ params: { bsno: this.panelFee.strBSNO, optype: "op_other" }, //需求编号:SR2017061800001-7
            callback: function (r, options, success) {
                if (success) {
                    _thisfee.setTotalHead();
                }
            }
        });
        this.panelFee.storeChFeeGain.load({ params: { bsno: this.panelFee.strBSNO, optype: "op_other"} }); //需求编号:SR2017061800001-7
        */
        //#endregion
    }, //end InitData

    LoadData: function (condition) {

    

        //#region 获取系统参数(用于判断费用关联到海运进口还是入库单)
        // 20190415 ADD BY BALINGXU
        //原来出库费用没有关联海运进口,都是进口贸易!!!!
        Ext.Ajax.request({
            waitMsg: '正在查询用户权限...',
            url: '/MvcShipping/WMSNew/GetSysFeeConfig',
            params: {
                userid: USERID
            },
            async: false,
            callback: function (options, success, response) {
                if (success) {
                    var result = Ext.JSON.decode(response.responseText);
                    FEECONFIG = result.data;
                }
                else {
                    Ext.MessageBox.alert('获取费用配置信息失败', response.responseText);
                    return;
                }

            },
            scope: this
        });



        //this.panelFee.storeFeeNameRef.load({ params: { condition: "" } });
        //#endregion

        this.serialNo = 0;
        Ext.Ajax.request({
            waitMsg: '正在查询数据...',
            url: '/MvcShipping/WMSOUT_GuiGe/GetDataEdit',
            params: { condition: condition },
            callback: function (options, success, response) {
                if (success) {
                    var result = Ext.JSON.decode(response.responseText);
                    if (!result.Success) {
                        Ext.Msg.show({ title: '提示', msg: result.Message, icon: Ext.MessageBox.INFO, buttons: Ext.Msg.OK });
                        return;
                    }
                    //
                    data = result.data;
                    this.formHead.getForm().findField('OUTGID').setDisabled(false);
                    this.formHead.getForm().reset();
                    this.formHead.getForm().setValues(data);
                    this.formHead.getForm().findField('OLDCUSTFEEDATE').setValue(data.OLDCUSTFEEDATE.toString().substring(0, 10));
                    this.formHead.getForm().findField('OUTGID').setDisabled(true);
                    //
                    this.LoadPeriod(this.opStatus);
                    var condition2 = "WMSOUTGID='" + data.OUTGID + "'";
                    this.storeWmsRateDetailList.load({
                        params: { condition: condition2 },
                        waitMsg: "正在刷新数据...",
                        timeout: 6000000, //60秒
                        scope: this
                    });
                } else {
                    Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
                }
            },
            scope: this
        });
        //this.GetEditStatus();
    }, // end LoadDate
    //#endregion

    LoadPeriod: function (opstatus) {
        Ext.Ajax.request({
            waitMsg: '正在查询主表数据...',
            url: '/Account/ChMonthClose/GetNowPeriod',
            params: {
                condition: ''
            },
            callback: function (options, success, response) {
                if (success) {
                    var result = Ext.JSON.decode(response.responseText);
                    if (!result.Success) {
                        return;
                    }
                    data = result.data;
                    this.MsPeriod = data;
                    this.LoadPeriodStatus(opstatus);

                } else {
                    Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
                }
            },
            scope: this
        });
    },

    LoadPeriodStatus: function (opstatus) {

        var ACCDATE = this.formHead.getForm().findField('ACCDATE_OUT').getValue();

        var oDate1 = new Date(ACCDATE + '-01');
        var oDate2 = new Date(this.MsPeriod.PERIOD + '-01');
        if (oDate1.getTime() >= oDate2.getTime()) {
            this.formHead.getForm().findField('ACCDATE_OUT').setMinValue(this.MsPeriod.PERIOD);
            this.formHead.getForm().findField('ACCDATE_OUT').setReadOnly(false);
        } else {
            if (opstatus == 'add' || opstatus == 'copyadd') {
                this.formHead.getForm().findField('ACCDATE_OUT').setMinValue(this.MsPeriod.PERIOD);
                this.formHead.getForm().findField('ACCDATE_OUT').setValue(this.MsPeriod.PERIOD);
                this.formHead.getForm().findField('ACCDATE_OUT').setReadOnly(false);
            }
            else {
                this.formHead.getForm().findField('ACCDATE_OUT').setMinValue('');
                this.formHead.getForm().findField('ACCDATE_OUT').setReadOnly(true);
            }
        }
    },


    //#region 查询
    onRefreshClick: function (sCondition) {
        var sql = this.getCondition();
        if (sCondition.toString().trim() != "" && sCondition.toString().trim() != "[object Object]") {
            sql += sCondition;
        }
        this.sqlcontext = sql;
        if (sql == '1<0') return;
        var isFit = true;
       
        if (this.opStatus == "add" &&  sql != '1<0') {

            Ext.Ajax.request({
                url: '/MvcShipping/WMSOUT_GuiGe/JudgeOutType',
                params: {
                    condition: sql,
                    outType: this.stockType
                },
                async: false,
                callback: function (options, success, response) {
                    if (success) {
                        var result = Ext.JSON.decode(response.responseText);
                        if (result.data != '0') {
                            isFit = false;
                            if (this.stockType == "StockOut") {
                                Ext.Msg.show({ title: '提示', msg: '对不起,该入库单已经明细出库,只能明细出库', icon: Ext.Msg.WARNING, buttons: Ext.Msg.OK });

                            }
                            if (this.stockType == "StockOutDetail") {
                                Ext.Msg.show({ title: '提示', msg: '对不起,该入库单已经整体出库,只能整体出库', icon: Ext.Msg.WARNING, buttons: Ext.Msg.OK });

                            }
                            this.storeDetailList.removeAll();
                            return;


                        }
                    }
                    

                },
                scope: this
            });

        }
        if (!isFit) return;
        
        var ISADD = this.formSearch.getForm().findField('ISADD').getValue();
        _this = this;
        
        if (ISADD) {
            this.OnAddDetailSearch(sql);
            //this.storeDetailListAdd.load({
            //    params: { start: 0, limit: this.PageSize, sort: '', opStatus: this.opStatus, condition: sql, outType: this.stockType},
            //    waitMsg: "正在刷新数据...",
            //    timeout: 6000000, //30秒
            //    callback: function (r, options, success) {
            //        if (success) {
                       
            //            if (this.storeDetailListAdd.getCount() > 0) {
            //                for (var j = 0; j < this.storeDetailListAdd.getCount(); j += 1) {
            //                   var member = this.storeDetailListAdd.getAt(j);
            //                   var records = DsStoreQueryBy(_this.storeDetailList, 'NID', member.data.NID);
            //                    if ((records.getCount() <=0)) _this.storeDetailList.add(member);


            //                }
            //            } //else { }
            //        }
            //    },
            //    scope: this
            //});
        } else {
            this.storeDetailList.load({
               // params: { start: 0, limit: this.PageSize, sort: '', opStatus: this.opStatus, condition: sql },
                params: { start: 0, limit: 30, sort: '', opStatus: this.opStatus,condition: sql ,outType:this.stockType},
                waitMsg: "正在刷新数据...",
                timeout: 6000000, //30秒
                add:false,
                callback: function (r, option, success) {
                    if (success) {
                        if (this.opStatus == "add") {
                            
                            for (var i = 0; i < this.storeDetailList.getCount(); i += 1) {
                                this.formHead.getForm().findField('TRUCKNAME_OUT').setValue(this.storeDetailList.getAt(i).get("TRUCKNAME_OUT"));
                                //var oldType = this.storeDetailList.getAt(i).get("ISDETAIL");
                                var goodsStock = this.storeDetailList.getAt(i).get("GOODSSTOCK");
                                var goodsPackStock = this.storeDetailList.getAt(i).get("GOODSPACKSTOCK");

                                if ((goodsStock === 0) && (goodsPackStock === 0) ) {
                                   // Ext.Msg.show({ title: '提示', msg: '对不起,该入库单已经全部出库', icon: Ext.Msg.WARNING, buttons: Ext.Msg.OK });
                                   // this.storeDetailList.remove(this.storeDetailList.getAt(i));
                                    continue;
                                }

                                if (!isFit) this.storeDetailList.removeAll();

                               
                                /*
                                if ((this.stockType == "StockOut") && (oldType == "1")) {
                                    Ext.Msg.show({ title: '提示', msg: '对不起,该入库单已经明细出库,只能明细出库', icon: Ext.Msg.WARNING, buttons: Ext.Msg.OK });
                                    this.storeDetailList.removeAll();
                                    return;
                                }
                                else if ((this.stockType == "StockOutDetail") && (oldType == "0")) {
                                    Ext.Msg.show({ title: '提示', msg: '对不起,该入库单已经整体出库,只能整体出库', icon: Ext.Msg.WARNING, buttons: Ext.Msg.OK });
                                    this.storeDetailList.removeAll();
                                    return;

                                }
                                */
                            }

                            cellediting = this.gridListCellEditing;
                            cellediting.startEditByPosition({ row: 0, column: 11 });
                            
                        }
                       


                    }

                },
                scope: this
            });
        }
        


        //this.panelFee.hide(); //隐藏按钮
        if (this.opStatus == 'edit') {
            //this.panelFee.show(); //显示按钮
            var sBSNO = this.EditRecord.data.BSNO;
            this.LoadData("OUTBSNO_OUT='" + sBSNO + "'");
        }
    },

    getCondition: function () {
        var sql = '';

        if (this.opStatus == 'edit') {
            var sBSNO = this.EditRecord.data.BSNO;
            sql = sql + getAndConSql(sql, sBSNO, "OUTBSNO_OUT='" + sBSNO + "'");
        }
        else {
            var dl = 0;
            // sql += "(GOODSPACKSTOCK<>" + dl + ")"; // or GOODSSTOCK<>" + dl + "
        }

        //提单号
        var sBLNO = this.formSearch.getForm().findField('BLNO').getValue();
        if (sBLNO != null) {
            if (sBLNO != "") {
                sql = sql + getAndConSql(sql, sBLNO, " (BLNO like '%" + sBLNO.toString().trim() + "%' OR CONTRACTNO like '%" + sBLNO.toString().trim() + "%' OR CNTRNO like '%" + sBLNO.toString().trim() + "%') ");
            }
        }

        //入库单号
        var sWMSNO = this.formSearch.getForm().findField('WMSNO').getValue();
        if (sWMSNO != null) {
            if (sWMSNO != "") {
                sql = sql + getAndConSql(sql, sWMSNO, "WMSNO like '%" + sWMSNO.toString().trim() + "%'");
            }
        }

        //委托单位
        var sCUSTOMERNAME = this.formSearch.getForm().findField('CUSTOMERNAME').getValue();
        if (sCUSTOMERNAME != null) {
            if (sCUSTOMERNAME != "") {
                sql = sql + getAndConSql(sql, sCUSTOMERNAME, "CUSTOMERNAME='" + sCUSTOMERNAME.toString().trim() + "'");
            }
        }

        //所属仓库
        var sSTORAGENAME = this.formSearch.getForm().findField('STORAGENAME').getValue();
        if (sSTORAGENAME != null) {
            if (sSTORAGENAME != "") {
                sql = sql + getAndConSql(sql, sSTORAGENAME, "STORAGENAME='" + sSTORAGENAME.toString().trim() + "'");
            }
        }

        //品名
        var sGOODSNAME = this.formSearch.getForm().findField('GOODSNAME').getValue();
        if (sGOODSNAME != null) {
            if (sGOODSNAME != "") {
                sql = sql + getAndConSql(sql, sGOODSNAME, "GOODSNAME='" + sGOODSNAME.toString().trim() + "'");
            }
        }

        //品名明细表_规格
        var sGOODSDETAILNAME = this.formSearch.getForm().findField('GOODSDETAILNAME').getValue();
        if (sGOODSDETAILNAME != null) {
            if (sGOODSDETAILNAME != "") {
                sql = sql + getAndConSql(sql, sGOODSDETAILNAME, "GOODSMODEL='" + sGOODSDETAILNAME.toString().trim() + "'");
            }
        }

        //批次号
                var PICIHAO = this.formSearch.getForm().findField('PICIHAO').getValue();
                if (PICIHAO != null) {
                    if (PICIHAO != "") {
                        sql = sql + getAndConSql(sql, PICIHAO, "PICIHAO like '%" + PICIHAO.toString().trim() + "%'");
                    }
                        }

        //进口国
        var COUNTRYID = this.comboxCountry.getValue();
        if (COUNTRYID != '' && COUNTRYID != null) {
            sql = sql + getAndConSql(sql, COUNTRYID, " countryid='" + COUNTRYID + "' ");
        }


        //箱号
        var CNTRNO = this.formSearch.getForm().findField('CNTRNO').getValue();
        if (CNTRNO != null) {
            if (CNTRNO != "") {
                sql = sql + getAndConSql(sql, CNTRNO, "CNTRNO like '%" + CNTRNO.toString().trim() + "%'");
            }
        }

//        if (this.pcnostr != "") {
//            sql = sql + getAndConSql(sql, this.pcnostr, "PICIHAO IN (" + this.pcnostr + ") ");
//        }



        return sql;
    },

    onClearSql: function () {
        var form = this.formSearch.getForm();
        form.reset();
    },
    //#endregion

    //#region 按键事件
    onNextKeyClick: function (col) {
        var rows = this.gridList.getSelectionModel().getSelection();
        var row = rows[rows.length - 1];
        //if (col == 15) {
        //    row = rows[rows.length];
        //    col == 11;
       // }
        var s = this.gridList.getStore();
        var number = s.indexOf(row);
        this.gridListCellEditing.startEditByPosition({ row: number, column: col });
    },
    //#endregion    

    //#region 新建
    onAddClick: function () {
        this.opStatus = 'add';
        this.pcnostr = "";
        this.cntrstr = "";
        this.onClearSql();
        this.formHead.getForm().findField('OUTGID').setDisabled(false);
        this.formHead.getForm().reset();
        this.formHead.getForm().findField('OUTGID').setDisabled(true);

        this.storeDetailList.load({
            params: { start: 0, limit: this.PageSize, sort: '', opStatus: this.opStatus, condition: "1<0" ,outType:this.stockType},
            waitMsg: "正在刷新数据...",
            timeout: 6000000, //60秒
            scope: this
        });

        this.storeWmsRateDetailList.load({
            params: { condition: "1<0" },
            waitMsg: "正在刷新数据...",
            timeout: 6000000, //60秒
            scope: this
        });
    },
    //#endregion    

    //#region 保存
    Save: function (type) {
        this.formHead.getForm().findField('OUTGID').setDisabled(false);
        var data = this.formHead.getForm().getValues(false, false, false);
        this.formHead.getForm().findField('OUTGID').setDisabled(true);
        var tmpAssno = '';
        //
        if (this.changeType == "1") {
            var sCLIENTNAMEOLD = Ext.getCmp('CLIENTNAMEOLD').getValue();
            if (sCLIENTNAMEOLD == null) {
                Ext.Msg.show({ title: '提示', msg: '货权转移对象不能为空!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
                return;
            }
            else {
                if (sCLIENTNAMEOLD == "") {
                    Ext.Msg.show({ title: '提示', msg: '货权转移对象不能为空!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
                    return;
                }
            }
        }
        //
        var bodydatas = [];
        for (var i = 0; i < this.storeDetailList.getCount(); i += 1) {
            tmpAssno = this.storeDetailList.getAt(i).get("ASSOCIATEDNO");//海运进口BSNO
            var dlGOODSPACKPFSL_OUT = this.storeDetailList.getAt(i).get("GOODSPACKPFSL_OUT"); //出库件数
            var dlGOODSPFSL_OUT = this.storeDetailList.getAt(i).get("GOODSPFSL_OUT"); //出库量
            var dlGOODSNUM = this.storeDetailList.getAt(i).get("GOODSNUM"); //完税件数
            var dlGOODSSTOCK = this.storeDetailList.getAt(i).get("GOODSSTOCK"); //剩余库存
            var dlGOODSPACKSTOCK = this.storeDetailList.getAt(i).get("GOODSPACKSTOCK"); //剩余件数
            if (this.opStatus == 'edit') {
                dlGOODSNUM = this.storeDetailList.getAt(i).get("GOODSNUM") + dlGOODSPACKPFSL_OUT; //完税件数
                dlGOODSPACKSTOCK = this.storeDetailList.getAt(i).get("GOODSPACKSTOCK") + dlGOODSPACKPFSL_OUT; //剩余件数
            }
            
            if (dlGOODSPACKPFSL_OUT != 0 || dlGOODSPFSL_OUT != 0) // && dlGOODSPFSL_OUT != 0
            {
                var member = this.storeDetailList.getAt(i);

                //20200617 用于虎鲸 如是来自于出区报关的货转 则不需要判断完税数量
                if (this.stockType2 != true) {
                    var blISBONDED = this.storeDetailList.getAt(i).get("ISBONDED").toString(); //是否报税业务//需求编号:SR2017061900001-1
                    if (blISBONDED == "true") {
                        if (dlGOODSPACKPFSL_OUT > dlGOODSNUM) {
                            continue;
                        }
                    }      
                }
                if (dlGOODSPACKPFSL_OUT > dlGOODSPACKSTOCK) {
                    continue;
                }
                //出库量大于剩余库存,提示用户
                if (dlGOODSPFSL_OUT > dlGOODSSTOCK) {
                    Ext.Msg.show({ title: '提示', msg: '当前出库量大于库存', icon: Ext.Msg.WARNING, buttons: Ext.Msg.OK });
                }
                //出库日期不能小于入库日期//需求编号:SR2017073000001
                var rqWMSDATE = member.data.WMSDATE; //入库日期
                var rqDODATE_OUT = this.formHead.getForm().findField('DODATE_OUT').getRawValue(); //出库日期
                if (rqWMSDATE > rqDODATE_OUT) {
                    continue;
                }
                /*
                //需求编号:SR2017073000001
                var sZHUANGXIEGONGID_OUT = member.data.ZHUANGXIEGONGID_OUT.toString();
                var comboxList = DsStoreQueryBy(this.storeZhuangXieGong, 'NAME', sZHUANGXIEGONGID_OUT);
                if (comboxList.length > 0) {
                    var comboxRaw = comboxList.getAt(0).raw;
                    member.set("ZHUANGXIEGONGID_OUT", comboxRaw.GID.toString());
                }
                */
                member.data.ISLOCK = member.data.ISLOCK == true ? 1 : 0;
                member.data.ISLOCK2 = member.data.ISLOCK2 == true ? 1 : 0;
                member.data.ISBONDED = member.data.ISBONDED == true ? 1 : 0;
                member.data.ISDELETE = member.data.ISDELETE == true ? 1 : 0;
                member.data.EIP = member.data.EIP == true ? 1 : 0;
                bodydatas.push(member);
            }
        }
        if (bodydatas.length > 0) {
            var jsonBody = ConvertRecordsToJsonAll(bodydatas);
            Ext.Msg.wait('正在保存数据, 请稍侯..');
            Ext.Ajax.request({
                waitMsg: '正在保存数据...',
                url: '/MvcShipping/WMSOUT_GuiGe/SaveEdit',
                params: { opStatus: this.opStatus, data: Ext.JSON.encode(data), body: jsonBody, outType: this.stockType, changeType: this.changeType, bEIP: this.blEIP, stockType2: this.stockType2 },
                callback: function (options, success, response) {
                    if (success) {
                        Ext.MessageBox.hide();
                        var jsonresult = Ext.JSON.decode(response.responseText);
                        if (jsonresult.Success) {
                            if (this.opStatus == 'add') {
                                this.opStatus = 'edit';
                            }
                            var returnData = jsonresult.Data;
                            var editp = Ext.create('VwWmsDetailModel', returnData);
                            this.panelFee.EditRecord = editp;
                            this.panelFee.WMSOUTBSNO = returnData.OUTGID;
                            this.panelFee.strBSNO = returnData.OUTGID;
                            if (FEECONFIG == '1')
                                this.panelFee.strBSNO = tmpAssno;
                            this.panelFee.DR_condition = "((WMSOUTBSNO in (select gid from wms_out where bsno = '" + returnData.OUTBSNO_OUT + "')  and feetype=1) or ((BSNO in (select gid from wms_out where bsno = '" + returnData.OUTBSNO_OUT + "')  and feetype=1)) ";
                            this.panelFee.CR_condition = "((WMSOUTBSNO in (select gid from wms_out where bsno = '" + returnData.OUTBSNO_OUT + "') and feetype=2) or (BSNO in (select gid from wms_out where bsno = '" + returnData.OUTBSNO_OUT + "') and feetype=2))";
                           
                            this.InitData(returnData.OUTBSNO_OUT);
                            this.formHead.getForm().findField('OUTGID').setDisabled(false);
                            this.formHead.getForm().findField('OUTGID').setValue(returnData.OUTGID);
                            this.formHead.getForm().findField('OUTBSNO_OUT').setValue(returnData.OUTBSNO_OUT);
                            this.formHead.getForm().findField('OLDCUSTFEEDATE').setValue(returnData.OLDCUSTFEEDATE.toString().substring(0, 10));
                            this.formHead.getForm().findField('OUTGID').setDisabled(true);
                            //
                            var condition = "OUTBSNO_OUT='" + returnData.OUTBSNO_OUT + "'";
                            this.storeDetailList.load({
                                params: { start: 0, limit: this.PageSize, sort: '', opStatus: this.opStatus, condition: condition ,outType:this.stockType},
                                waitMsg: "正在刷新数据...",
                                timeout: 6000000, //60秒
                                scope: this
                            });
                            //
                            var condition2 = "WMSOUTGID='" + returnData.OUTGID + "'";
                            this.storeWmsRateDetailList.load({
                                params: { condition: condition2 },
                                waitMsg: "正在刷新数据...",
                                timeout: 6000000, //60秒
                                scope: this
                            });
                            //this.panelFee.show(); //显示按钮
                            //
                            if (this.btnRefresh == null) {
                            }
                            else {
                                var btn = opener.document.getElementById(this.btnRefresh.id);
                                btn.click();
                            }
                        } else {
                            Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
                        }
                    } else {
                        Ext.Msg.show({ title: '警告', msg: '服务器响应出错', icon: Ext.Msg.WARNING, buttons: Ext.Msg.OK });
                    }
                },
                scope: this
            });
        } else {
            Ext.Msg.show({ title: '错误', msg: '请先确定出库数据是否正确,再重试!', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
        }
    }, //end save
    //#endregion    

    //#region 费用入账//需求编号:SR2017073000001
    setislock: function (button, event) {
        if (this.opStatus == "add") {
            Ext.Msg.show({ title: '提示', msg: '请先保存单据!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
            return;
        }
        //
        //var sBSNO = this.EditRecord.data.BSNO;
        //this.LoadData("OUTBSNO_OUT='" + sBSNO + "'");
        var sOUTGID = this.formHead.getForm().findField('OUTGID').getValue();
        var sOUTBSNO_OUT = this.formHead.getForm().findField('OUTBSNO_OUT').getValue();
        Ext.MessageBox.confirm('提示', '确定入账该记录吗?', function (btn) {
            if (btn == 'yes') {
                Ext.Msg.wait('正在入账数据...');
                Ext.Ajax.request({
                    waitMsg: '正在入账数据...',
                    url: '/MvcShipping/WMSOUT_GuiGe/setislock',
                    params: {
                        sOUTGID: sOUTGID,
                        EIP: this.blEIP,
                        outType: this.stockType
                    },
                    callback: function (options, success, response) {
                        if (success) {
                            var jsonresult = Ext.JSON.decode(response.responseText);
                            if (jsonresult.Success) {
                                //费用关联海运进口
                                if (FEECONFIG == '1') {
                                    this.panelFee.storeDrChFee.load({ params: { billno: this.panelFee.strBSNO, type: 1, optype: "op_Seai", condition: "(( WMSOUTBSNO in (select gid from wms_out where bsno = '" + sOUTBSNO_OUT + "')  and feetype=1) or ( BSNO in (select gid from wms_out where bsno = '" + sOUTBSNO_OUT + "')  and feetype=1))" } });
                                    this.panelFee.storeCrChFee.load({ params: { billno: this.panelFee.strBSNO, type: 2, optype: "op_Seai", condition: "(( WMSOUTBSNO in (select gid from wms_out where bsno = '" + sOUTBSNO_OUT + "') and feetype=2) or (  BSNO in (select gid from wms_out where bsno = '" + sOUTBSNO_OUT + "') and feetype=2))" } });

                                } else {
                                    //费用关联出库单
                                    this.panelFee.storeDrChFee.load({ params: { billno: this.panelFee.strBSNO, type: 1, optype: "op_other", condition: "(( WMSOUTBSNO in (select gid from wms_out where bsno = '" + sOUTBSNO_OUT + "')  and feetype=1) or ( BSNO in (select gid from wms_out where bsno = '" + sOUTBSNO_OUT + "')  and feetype=1))" } });
                                    this.panelFee.storeCrChFee.load({ params: { billno: this.panelFee.strBSNO, type: 2, optype: "op_other", condition: "(( WMSOUTBSNO in (select gid from wms_out where bsno = '" + sOUTBSNO_OUT + "') and feetype=2) or ( BSNO in (select gid from wms_out where bsno = '" + sOUTBSNO_OUT + "') and feetype=2))" } });

                                }
                                this.blISLOCK = true;
                                this.setBtn();
                                //
                                if (this.btnRefresh == null) {
                                }
                                else {
                                    var btn = opener.document.getElementById(this.btnRefresh.id);
                                    btn.click();
                                }
                                //
                                Ext.Msg.show({ title: '提示', msg: '入账成功!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
                            }
                            else {
                                Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
                            }
                        }
                    },
                    failure: function (response, options) {
                        Ext.Msg.show({ title: '警告', msg: '服务器响应出错,请重试', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
                    },
                    scope: this
                });
            }
        }, this);
    },
    //#endregion    

    //#region 取消入账//需求编号:SR2017073000001
    setnotlock: function (button, event) {
        if (this.opStatus == "add") {
            Ext.Msg.show({ title: '提示', msg: '请先保存单据!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
            return;
        }
        var sOUTGID = this.formHead.getForm().findField('OUTGID').getValue();
        //
        Ext.MessageBox.confirm('提示', '确定取消入账吗?', function (btn) {
            if (btn == 'yes') {
                Ext.Msg.wait('正在取消入账数据...');
                Ext.Ajax.request({
                    waitMsg: '正在取消入账数据...',
                    url: '/MvcShipping/WMSOUT_GuiGe/setnotlock',
                    params: {
                        sOUTGID: sOUTGID,
                        EIP: this.blEIP
                    },
                    callback: function (options, success, response) {
                        if (success) {
                            var jsonresult = Ext.JSON.decode(response.responseText);
                            if (jsonresult.Success) {
                                this.panelFee.LoadDrChFee2("bsno='" + sOUTGID + "' and feetype=1");
                                this.panelFee.LoadCrChFee2("bsno='" + sOUTGID + "' and feetype=2");
                                this.blISLOCK = false;
                                this.setBtn();
                                //
                                if (this.btnRefresh == null) {
                                }
                                else {
                                    var btn = opener.document.getElementById(this.btnRefresh.id);
                                    btn.click();
                                }
                                //
                                Ext.Msg.show({ title: '提示', msg: '取消入账成功!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
                            }
                            else {
                                Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
                            }
                        }
                    },
                    failure: function (response, options) {
                        Ext.Msg.show({ title: '警告', msg: '服务器响应出错,请重试', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
                    },
                    success: function (response, options) {
                    },
                    scope: this
                });
            }
        }, this);
    },
    //#endregion    

    //#region EIP备货单状态

    setStock: function (stockState) {
        var sOUTGID = this.formHead.getForm().findField('OUTGID').getValue();
        Ext.MessageBox.confirm('提示', '确定提交状态?', function (btn) {
            if (btn == 'yes') {
                Ext.Msg.wait('正在提交数据...');
                Ext.Ajax.request({
                    waitMsg: '正在提交数据...',
                    url: '/MvcShipping/WMSStock/SetStock',
                    params: {
                        gid: sOUTGID,
                        state: stockState
                    },
                    callback: function (options, success, response) {
                        if (success) {
                            var jsonresult = Ext.JSON.decode(response.responseText);
                            if (jsonresult.Success) {
                                if(stockState == '3')
                                    Ext.Msg.show({ title: '提示', msg: '备货状态更新成功!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
                                else if (stockState == '4')
                                    Ext.Msg.show({ title: '提示', msg: '装箱状态更新成功!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
                            }
                            else {
                                Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
                            }
                        }
                    },
                    failure: function (response, options) {
                        Ext.Msg.show({ title: '警告', msg: '服务器响应出错,请重试', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
                    },
                    success: function (response, options) {
                    },
                    scope: this
                });
            }
        }, this);

    },

    //#endregion

    //#region 清库

    clearStock: function () {
        var sOUTGID = this.formHead.getForm().findField('OUTGID').getValue();
        if (sOUTGID == '') {
            Ext.Msg.show({ title: '提示', msg: '请先出库!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
        }
        var bodydatas = [];
        for (var i = 0; i < this.storeDetailList.getCount(); i += 1) {
            var dlGOODSPACKPFSL_OUT = this.storeDetailList.getAt(i).get("GOODSPACKPFSL_OUT"); //出库件数
            var dlGOODSPFSL_OUT = this.storeDetailList.getAt(i).get("GOODSPFSL_OUT"); //出库立方
            var dlGOODSNUM = this.storeDetailList.getAt(i).get("GOODSNUM"); //完税件数
            var dlGOODSPACKSTOCK = this.storeDetailList.getAt(i).get("GOODSPACKSTOCK"); //剩余件数
            
            if (dlGOODSPACKPFSL_OUT != 0 || dlGOODSPFSL_OUT != 0) // && dlGOODSPFSL_OUT != 0
            {
                var member = this.storeDetailList.getAt(i);
                var blISBONDED = this.storeDetailList.getAt(i).get("ISBONDED").toString(); //是否报税业务//需求编号:SR2017061900001-1
                if (blISBONDED == "true") {
                    if (dlGOODSPACKPFSL_OUT > dlGOODSNUM) {
                        continue;
                    }
                }

                //出库日期不能小于入库日期//需求编号:SR2017073000001
                var rqWMSDATE = member.data.WMSDATE; //入库日期
                var rqDODATE_OUT = this.formHead.getForm().findField('DODATE_OUT').getRawValue(); //出库日期
                if (rqWMSDATE > rqDODATE_OUT) {
                    continue;
                }

                member.data.ISLOCK = member.data.ISLOCK == true ? 1 : 0;
                member.data.ISLOCK2 = member.data.ISLOCK2 == true ? 1 : 0;
                member.data.ISBONDED = member.data.ISBONDED == true ? 1 : 0;
                member.data.ISDELETE = member.data.ISDELETE == true ? 1 : 0;
                member.data.EIP = member.data.EIP == true ? 1 : 0;
                bodydatas.push(member);
            }
        }
        if (bodydatas.length > 0) {
            var jsonBody = ConvertRecordsToJsonAll(bodydatas);
            Ext.MessageBox.confirm('提示', '确定清库,所有库存即将清零?', function (btn) {
                if (btn == 'yes') {
                    Ext.Msg.wait('正在清库...');
                    Ext.Ajax.request({
                        waitMsg: '正在清库...',
                        url: '/MvcShipping/WMSOUT_GuiGe/ClearStock',
                        params: {
                            data:jsonBody
                        },
                        callback: function (options, success, response) {
                            if (success) {
                                var jsonresult = Ext.JSON.decode(response.responseText);
                                if (jsonresult.Success) {
                                    Ext.Msg.show({ title: '提示', msg: '清库成功!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
                                    var condition = "OUTGID='" + sOUTGID + "'";
                                    this.storeDetailList.load({
                                        params: { start: 0, limit: this.PageSize, sort: '', opStatus:'edit', condition: condition, outType: this.stockType },
                                        waitMsg: "正在刷新数据...",
                                        timeout: 6000000, //60秒
                                        scope: this
                                    });
                                    
                                }
                                else {
                                    Ext.Msg.show({ title: '错误', msg: '清库出现错误!', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
                                }
                            }
                        },
                        failure: function (response, options) {
                            Ext.Msg.show({ title: '警告', msg: '服务器响应出错,请重试', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
                        },
                        success: function (response, options) {
                        },
                        scope: this
                    });
                }
            }, this);
           
        } 

    },

    //#endregion

    LoadDefValue: function () {
        this.storeDefValue.load({
            params: { condition: "BSTYPE='仓储出库'" },
            callback: function (r, options, success) {
                if (success) {
                    if (this.storeDefValue.getCount() > 0) {
                        for (var j = 0; j < this.storeDefValue.getCount() ; j += 1) {
                            var member = this.storeDefValue.getAt(j);
                            var fieldname = member.data.FIELDNAME;

                            var headfield = this.formHead.getForm().findField(fieldname);
                            if (headfield != NaN && headfield != null)
                                headfield.setValue(member.data.DEFVALUE);


                        };


                    } else {

                    }
                }
            },
            scope: this
        });


    },

    LoadMustBe: function () {
        this.storeMustBe.load({
            params: { condition: "BSTYPE='仓储出库'" },
            callback: function (r, options, success) {
                if (success) {
                    if (this.storeMustBe.getCount() > 0) {
                        for (var j = 0; j < this.storeMustBe.getCount() ; j += 1) {
                            var member = this.storeMustBe.getAt(j);
                            var fieldname = member.data.FIELDNAME;

                            var headfield = this.formHead.getForm().findField(member.data.FIELDNAME);
                            if (headfield != NaN && headfield != null) {
                                if (member.data.ISMUST == "1")
                                    headfield.allowBlank = false;
                                if (member.data.ISCOLOR == "1")
                                    headfield.setFieldStyle({ background: '#ffc' });
                                if (member.data.ISREADONLY == "1")
                                    headfield.setReadOnly(true);

                            }


                        };


                    } else {

                    }
                }
            },
            scope: this
        });

    },


    //#region 按钮是否显示
    setBtn: function () {
        if (this.blISLOCK) {
            Ext.getCmp('btnAdd').setVisible(false);
            Ext.getCmp('btnSave').setVisible(false);
            Ext.getCmp('btIslock').setVisible(false);
            Ext.getCmp('btNotIslock').setVisible(true);
        }
        else {
            Ext.getCmp('btnAdd').setVisible(true);
            Ext.getCmp('btnSave').setVisible(true);
            Ext.getCmp('btIslock').setVisible(true);
            Ext.getCmp('btNotIslock').setVisible(false);
        };

        if (this.blEIP) {
            Ext.getCmp('btnStock1').setVisible(true);
            Ext.getCmp('btnStock2').setVisible(true);
        }
        else {
            Ext.getCmp('btnStock1').setVisible(false);
            Ext.getCmp('btnStock2').setVisible(false);
        }
        if (this.blDESTOCK) {
            Ext.getCmp('btnClearStock').setVisible(true);
        } else {
            Ext.getCmp('btnClearStock').setVisible(false);
        }

        if (this.stockType2 == '') {
            Ext.getCmp('btnGetOpApply').setVisible(true);
        } else {
            Ext.getCmp('btnGetOpApply').setVisible(false);
        }
    },
    setEIPBtn: function () {

        if (this.blEIP) {
            Ext.getCmp('btnStock1').setVisible(true);
            Ext.getCmp('btnStock2').setVisible(true);
        }
        else {
            Ext.getCmp('btnStock1').setVisible(false);
            Ext.getCmp('btnStock2').setVisible(false);
        }
    },

    setChange: function(changeType) {
        if (changeType === '0') {
            Ext.getCmp('CLIENTNAMEOLD').disabled = true;
            Ext.getCmp('ARCLIENT').disabled = true;
        }

    },
    //#endregion 

    //#region 打印
    Print: function (button, event) {
        if (this.opStatus == "edit") {
            var sOUTBSNO_OUT = this.formHead.getForm().findField('OUTBSNO_OUT').getValue();
            var condition = "OUTBSNO_OUT='" + sOUTBSNO_OUT + "'";
            Ext.Ajax.request({
                waitMsg: '正在组织数据, 请稍侯...',
                url: '/MvcShipping/WMSOUT_GuiGe/GetDataListStr',
                params: { condition: condition },
                callback: function (options, success, response) {
                    if (success) {
                        if (Ext.MessageBox.isVisible()) { Ext.MessageBox.hide(); }
                        var jsonresult = Ext.JSON.decode(response.responseText);
                        if (jsonresult.Success) {
                            var returnStr = jsonresult.data;
                            var printType = 'WMSOUT_GuiGeEdit';
                            var sql1 = returnStr;
                            var sql2 = "";
                            var sql3 = "";
                            var sql4 = "";
                            var sql5 = "";
                            var sql6 = "";
                            PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6);
                        } else {
                            Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
                        }
                    } else {
                        Ext.Msg.show({ title: '请重试', msg: '服务器响应出错', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
                    }
                },
                scope: this
            });
        }
    },
    //#endregion 

    //#region  出库编辑
    gridListAfterEdit: function (editor, e, eOpts) {

        //选择装卸工,带出装卸费
        if (e.field == 'ZHUANGXIEGONGID_OUT') {
            var zxgcodename = this.comboxZhuangXieGong.rawValue;
            e.record.set('ZHUANGXIEGONG_OUT', zxgcodename);
            var feeType = e.record.data.ZhuangXieFeeType;
            var ton = e.record.data.SHIJIZHONGLIANG;
            var jian = e.record.data.GOODSPACK;
            var jianOrTon = 0;
            if (feeType == '件数') {
                jianOrTon = jian;
            } else {
                jianOrTon = ton;
            }
            var zhuangxiegongid = e.record.data.ZHUANGXIEGONGID_OUT;
           

            var temp = "";
            Ext.Ajax.request({
                waitMsg: '正在查询主表数据...',
                url: '/MvcShipping/WMSNew/GetZhuangXieFeiWithZhuangXieGongID',
                params: {
                    gid: zhuangxiegongid
                },
                callback: function (options, success, response) {
                    if (success) {
                        var jsonresult = Ext.JSON.decode(response.responseText);
                        var feeJian = jsonresult.data1;
                        var feeTon = jsonresult.data2;
                        e.record.set('ZhuangXieFeiDanJiaTon', feeTon);
                        e.record.set('ZhuangXieFeiDanJiaJian', feeJian);
                        if (feeType == '件数') {
                            e.record.set('ZHUANGXIEFEI', feeJian * jianOrTon);
                        } else if (feeType == '') {
                            e.record.set('ZHUANGXIEFEI', 0);
                        } else {
                            e.record.set('ZHUANGXIEFEI', feeTon * jianOrTon);
                        }

                    }
                },
                scope: this
            }); //request over

        }
        //选择装卸计费标准计算装卸费ZhuangXieFeeType
        if (e.field == 'ZhuangXieFeeType' || e.field == 'GOODSPFSL_OUT' || e.field == 'GOODSPACKPFSL_OUT') {
            var feeType = e.record.data.ZhuangXieFeeType;
            var ton = e.record.data.GOODSPFSL_OUT;
            var jian = e.record.data.GOODSPACKPFSL_OUT;
            var feeJian = e.record.data.ZhuangXieFeiDanJiaJian;
         
            var feeTon = e.record.data.ZhuangXieFeiDanJiaTon;
           
            var jianOrTon = 0;
            if (feeType == '件数') {
                jianOrTon = jian;
            } else {
                jianOrTon = ton;
            }
            if (feeType == '件数') {
                e.record.set('ZHUANGXIEFEI', feeJian * jianOrTon);
            } else if (feeType == '吨') {
                e.record.set('ZHUANGXIEFEI', feeTon * jianOrTon);
            }

            //计算出库装卸费
            pimingid = e.record.get('GOODSNAMEID');
            //ARCLIENT = Ext.getCmp("ARCLIENTWMSOUT").getValue();
            //dodate = Ext.getCmp("DODATE_OUT").getValue();
            dodate = this.formHead.getForm().findField('DODATE_OUT').getValue();
            ARCLIENT = this.formHead.getForm().findField('ARCLIENTWMSOUT').getValue();
            STORAGENAME = e.record.data.STORAGENAME;
            Ext.Ajax.request({//
                waitMsg: '正在处理数据...',
                url: '/MvcShipping/WMSNew/GetLoaderFeeModel',
                params: {
                    custname: ARCLIENT,
                    goodnameid: pimingid,
                    wmsdate: dodate,
                    feetype: '2',
                    storagename:STORAGENAME
                },
                callback: function (options, success, response) {
                    var jsonresult = Ext.JSON.decode(response.responseText);
                    if (jsonresult.Success) {
                        if (jsonresult.data.length > 0) {
                            var feedata = jsonresult.data[0];
                            var unit = feedata.FEEUNIT;
                            var price = feedata.FEEPRICE;
                            var num = e.record.get('GOODSPFSL_OUT');
                            e.record.set('LOADERFEE', num * price);
                            //if (unit == "CBM") {
                            // e.record.set('LOADERFEE', feeTon * price);
                            //} else {
                            // e.record.set('LOADERFEE', feeTon * price);
                            //}
                        }

                    } else {
                        alert(jsonresult.Message);
                    }


                },
                scope: this
            }); //request over
        }

    },
    //#endregion

    //#region 新增关联海运进口
    SetOpseaiData: function () {
        var ret1 = window.parent.opener.OprationSwap();
        var blno = ret1[7].data.MBLNO
        var curSql = '';
        curSql = getAndConSql(curSql, blno, " (BLNO like '%" + blno.toString().trim() + "%' ) ");
        this.storeDetailList.load({
            params: { start: 0, limit: 30, sort: '', opStatus: this.opStatus, condition: curSql, outType: this.stockType },
            waitMsg: "正在刷新数据...",
            timeout: 6000000, //30秒
            add: false,
            callback: function (r, option, success) {
                if (success) {
                    if (this.opStatus == "add") {
                        for (var i = 0; i < this.storeDetailList.getCount(); i += 1) {
                            this.formHead.getForm().findField('TRUCKNAME_OUT').setValue(this.storeDetailList.getAt(i).get("TRUCKNAME_OUT"));
                            var goodsStock = this.storeDetailList.getAt(i).get("GOODSSTOCK");
                            var goodsPackStock = this.storeDetailList.getAt(i).get("GOODSPACKSTOCK");
                            if ((goodsStock === 0) && (goodsPackStock === 0)) {
                                //Ext.Msg.show({ title: '提示', msg: '对不起,该入库单已经全部出库', icon: Ext.Msg.WARNING, buttons: Ext.Msg.OK });
                                this.storeDetailList.remove(this.storeDetailList.getAt(i));
                                continue;
                            }

                            var oldType = this.storeDetailList.getAt(i).get("ISDETAIL");

                            if ((this.stockType === "StockOut") && (oldType === "1")) {
                                Ext.Msg.show({ title: '提示', msg: '对不起,该入库单已经明细出库,只能明细出库', icon: Ext.Msg.WARNING, buttons: Ext.Msg.OK });
                                this.storeDetailList.removeAll();
                                return;
                            }
                            else if ((this.stockType === "StockOutDetail") && (oldType === "0")) {
                                Ext.Msg.show({ title: '提示', msg: '对不起,该入库单已经整体出库,只能整体出库', icon: Ext.Msg.WARNING, buttons: Ext.Msg.OK });
                                this.storeDetailList.removeAll();
                                return;

                            }
                        }
                    }



                }

            },
            scope: this
        });

    },
    //#endregion

    //#region  生成费用
    onCreateCostClick: function () {
        if (this.blISLOCK == false) {
            Ext.MessageBox.alert('提示', '未入账不允许生成费用');
            return;
        }
        var sOUTBSNO_OUT = this.formHead.getForm().findField('OUTBSNO_OUT').getValue();
        Ext.Ajax.request({
            waitMsg: '正在生成费用...',
            url: '/MvcShipping/WMSOUT_GuiGe/CreateCost',
            params: {
                OutBsno: sOUTBSNO_OUT,
                OutType: this.stockType
            },
            callback: function (options, success, response) {
                if (success) {
                    var result = Ext.JSON.decode(response.responseText);
                    if (result.Success == true) {
                        Ext.MessageBox.alert('提示', result.Message);
                        //费用关联海运进口
                        if (FEECONFIG == '1') {
                            this.panelFee.storeDrChFee.load({ params: { billno: this.panelFee.strBSNO, type: 1, optype: "op_Seai", condition: "((WMSOUTBSNO in (select gid from wms_out where bsno = '" + sOUTBSNO_OUT + "')  and feetype=1) or (BSNO in (select gid from wms_out where bsno = '" + sOUTBSNO_OUT + "')  and feetype=1))" } });
                            this.panelFee.storeCrChFee.load({ params: { billno: this.panelFee.strBSNO, type: 2, optype: "op_Seai", condition: "((WMSOUTBSNO in (select gid from wms_out where bsno = '" + sOUTBSNO_OUT + "') and feetype=2) or (BSNO in (select gid from wms_out where bsno = '" + sOUTBSNO_OUT + "') and feetype=2))" } });

                        } else {
                            //费用关联出库单
                            this.panelFee.storeDrChFee.load({ params: { billno: this.panelFee.strBSNO, type: 1, optype: "op_other", condition: "(( WMSOUTBSNO in (select gid from wms_out where bsno = '" + sOUTBSNO_OUT + "')  and feetype=1) or ( BSNO in (select gid from wms_out where bsno = '" + sOUTBSNO_OUT + "')  and feetype=1))" } });
                            this.panelFee.storeCrChFee.load({ params: { billno: this.panelFee.strBSNO, type: 2, optype: "op_other", condition: "(( WMSOUTBSNO in (select gid from wms_out where bsno = '" + sOUTBSNO_OUT + "') and feetype=2)  or (  BSNO in (select gid from wms_out where bsno = '" + sOUTBSNO_OUT + "') and feetype=2)) " } });
                           
                        }
                    } else {
                        Ext.MessageBox.alert('提示', result.Message);
                        return;
                    }
                } else {
                    Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
                }
            },
            scope: this
        });
    }
    //#endregion

    //追加式查询 用于一个出库单出多个库存
    , OnAddDetailSearch: function (sqlcondition) {
        _this = this;
        this.storeDetailListAdd.load({
            params: { start: 0, limit: this.PageSize, sort: '', opStatus: this.opStatus, condition: sqlcondition, outType: this.stockType },
            waitMsg: "正在刷新数据...",
            timeout: 6000000, //30秒
            callback: function (r, options, success) {
                if (success) {

                    if (this.storeDetailListAdd.getCount() > 0) {
                        for (var j = 0; j < this.storeDetailListAdd.getCount(); j += 1) {
                            var member = this.storeDetailListAdd.getAt(j);
                            var records = DsStoreQueryBy(_this.storeDetailList, 'NID', member.data.NID);
                            if (records.getCount() <= 0) _this.storeDetailList.add(member);
                        }
                    } //else { }
                }
            },
            scope: this
        });
    }
    ,
    SetHeadValue: function (formname, value) {
        var form = this.formHead.getForm();
        var tempfield = form.findField(formname);
        tempfield.setValue(value);
    },

    Set_WMS_OUT_Value: function (OPAPPLYRECORD,storeApplyDetail) {
        //this.SetHeadValue("ASSOCIATEDNO", OPAPPLYRECORD.MASTERNO); //用 委托单位 填充 转移对象
        _this = this;
        this.SetHeadValue("CLIENTNAMEOLD", OPAPPLYRECORD.CUSTOMERNAME); //用 委托单位 填充 转移对象
        this.SetHeadValue("ARCLIENTWMSOUT", OPAPPLYRECORD.CUSTOMERNAME); //用 委托单位 填充 应收仓储客户
        //this.SetHeadValue("CUSTOMNO", OPAPPLYRECORD.CUSTOMNO); //报关单号

        var ISADD = this.formSearch.getForm().findField('ISADD').getValue();


        if (ISADD) {
            this.OnAddDetailSearch(" ASSOCIATEDNO='" + OPAPPLYRECORD.MASTERNO + "' ");
            
        } else {

            this.storeDetailList.load({
                params: { start: 0, limit: this.PageSize, sort: '', opStatus: this.opStatus, condition: " ASSOCIATEDNO='" + OPAPPLYRECORD.MASTERNO + "' ", outType: this.stockType },
                waitMsg: "正在刷新数据...",
                timeout: 6000000, //60秒
                callback: function (options, success, response) {
                    storeApplyDetail.each(function (apprec) {
                        _this.storeDetailList.each(function (wmsoutrec) {
                            if (apprec.data.GoodsName.indexOf(wmsoutrec.data.GOODSNAME) >= 0) {
                                wmsoutrec.set("GOODSPACKPFSL_OUT", apprec.data.Pkgs);
                                wmsoutrec.set("BSNO", "");
                            }
                        });
                    });
                },
                scope: this
            });
        }
    },

    SetGoodsInfo: function (goodrecords) {
        this.Goodsrecords = goodrecords;
    },

    SetDetailValue: function () {


        this.storeDetailList.each(function (record) {
            //var ln = _L + "";
            //_L = _L + 1;
            //if()
            record.set('SEQUENCE', ln);
        });  
    }
    
});