Ext.namespace('Shipping');
Shipping.SeaeQuery = function (config) {
	Ext.applyIf(this, config);
	this.initUIComponents();
	Shipping.SeaeQuery.superclass.constructor.call(this);
};
Ext.extend(Shipping.SeaeQuery, Ext.Window, {
    StoreList: null,
    initUIComponents: function () {
        //#region formSearch 下拉框信息加载
        //权限范围

        Ext.define('EditConditionModel', {
            extend: 'Ext.data.Model',
            fields: [
              { name: 'Name', type: 'string' }
            ]
        });
        var dataEditCondition = [{ "Name": "等于" }, { "Name": "不等于" }, { "Name": "模糊"}];
        var storeEditCondition = Ext.create('Ext.data.Store', {
            model: 'EditConditionModel',
            data: dataEditCondition
        });



        this.comboxCUSTNO = Ext.create('DsExt.ux.RefTableCombox', {
            fieldLabel: '委托编号',
            store: storeEditCondition,
            forceSelection: true,
            name: 'CUSTNOCONDIT',
            valueField: 'Name',
            displayField: 'Name'
        });

        this.comboxMBLNO= Ext.create('DsExt.ux.RefTableCombox', {
            fieldLabel: '主提单号',
            store: storeEditCondition,
            forceSelection: true,
            name: 'MBLNOCONDIT',
            valueField: 'Name',
            displayField: 'Name'
        });
        this.comboxHBLNO = Ext.create('DsExt.ux.RefTableCombox', {
            fieldLabel: '分提单号',
            store: storeEditCondition,
            forceSelection: true,
            name: 'HBLNOCONDIT',
            valueField: 'Name',
            displayField: 'Name'
        });
        this.comboxORDNO = Ext.create('DsExt.ux.RefTableCombox', {
            fieldLabel: '订舱编号',
            store: storeEditCondition,
            forceSelection: true,
            name: 'ORDNOCONDIT',
            valueField: 'Name',
            displayField: 'Name'
        });
        this.comboxCUSTNAME = Ext.create('DsExt.ux.RefTableCombox', {
            fieldLabel: '委托单位',
            store: storeEditCondition,
            forceSelection: true,
            name: 'CUSTNAMECONDIT',
            valueField: 'Name',
            displayField: 'Name'
        });
        this.comboxCARRIER = Ext.create('DsExt.ux.RefTableCombox', {
            fieldLabel: '船公司',
            store: storeEditCondition,
            forceSelection: true,
            name: 'CARRIERCONDIT',
            valueField: 'Name',
            displayField: 'Name'
        });
        this.comboxAGENT = Ext.create('DsExt.ux.RefTableCombox', {
            fieldLabel: '代理公司',
            store: storeEditCondition,
            forceSelection: true,
            name: 'AGENTCONDIT',
            valueField: 'Name',
            displayField: 'Name'
        });
        this.comboxYARD = Ext.create('DsExt.ux.RefTableCombox', {
            fieldLabel: '场  站',
            store: storeEditCondition,
            forceSelection: true,
            name: 'YARDCONDIT',
            valueField: 'Name',
            displayField: 'Name'
        });

        this.comboxCUSTOMSER = Ext.create('DsExt.ux.RefTableCombox', {
            fieldLabel: '报关公司',
            store: storeEditCondition,
            forceSelection: true,
            name: 'CUSTOMSERCONDIT',
            valueField: 'Name',
            displayField: 'Name'
        });
        this.comboxFORWARDER = Ext.create('DsExt.ux.RefTableCombox', {
            fieldLabel: '货代公司',
            store: storeEditCondition,
            forceSelection: true,
            name: 'FORWARDERCONDIT',
            valueField: 'Name',
            displayField: 'Name'
        }); this.comboxWAREHOUSE = Ext.create('DsExt.ux.RefTableCombox', {
            fieldLabel: '仓  库',
            store: storeEditCondition,
            forceSelection: true,
            name: 'WAREHOUSECONDIT',
            valueField: 'Name',
            displayField: 'Name'
        }); 
        this.comboxTRUCKER = Ext.create('DsExt.ux.RefTableCombox', {
            fieldLabel: '车  队',
            store: storeEditCondition,
            forceSelection: true,
            name: 'TRUCKERCONDIT',
            valueField: 'Name',
            displayField: 'Name'
        });

        Ext.define('DateConditionModel', {
            extend: 'Ext.data.Model',
            fields: [
              { name: 'Name', type: 'string' }
            ]
        });
        var dataDateCondition = [{ "Name": "等于" }, { "Name": "不等于" }, { "Name": "大于" }, { "Name": "小于"}];
        var storeDateCondition = Ext.create('Ext.data.Store', {
            model: 'DateConditionModel',
            data: dataDateCondition
        });


        this.StoreOpRange = Ext.create('DsExt.ux.RefTableStore', {
            model: 'MsOP',
            proxy: { url: '/MvcShipping/MsBaseInfo/GetOpRang' }
        });
        this.StoreOpRange.load({ params: { optype: "modImport"} });

        //人员信息加载
        this.storeOpCode = Ext.create('DsExt.ux.RefTableStore', {
            model: 'DsShipping.ux.UserRefModel',
            proxy: { url: '/CommMng/BasicDataRef/GetUserRefList' }
        });
        this.storeOpCode.load();
        //客服
        this.comboxCUSTSERVICE = Ext.create('DsExt.ux.RefTableCombox', {
            fieldLabel: '客服',
            store: this.storeOpCode,
            forceSelection: true,
            name: 'CUSTSERVICE',
            valueField: 'UserName',
            displayField: 'CodeAndName'
        });
        //揽货人
        this.comboxSALE = Ext.create('DsExt.ux.RefTableCombox', {
            fieldLabel: '揽货人',
            store: this.storeOpCode,
            forceSelection: true,
            name: 'SALE',
            valueField: 'UserName',
            displayField: 'CodeAndName'
        });
        //操 作
        this.comboxOP = Ext.create('DsExt.ux.RefTableCombox', {
            fieldLabel: '操 作',
            store: this.storeOpCode,
            forceSelection: true,
            name: 'OP',
            valueField: 'UserName',
            displayField: 'CodeAndName'
        });
        //录入人
        this.comboxINPUTBY = Ext.create('DsExt.ux.RefTableCombox', {
            fieldLabel: '录入人',
            store: this.storeOpCode,
            forceSelection: true,
            name: 'INPUTBY',
            valueField: 'UserName',
            displayField: 'CodeAndName'
        });

        //客户加载_委托单位
        this.storeCustCode = Ext.create('DsExt.ux.RefTableStore', {
            model: 'DsShipping.ux.CustomRefModel',
            proxy: { url: '/CommMng/BasicDataRef/GetCustomRefList' }
        });
        this.storeCustCode.load({ params: { condition: "ISCONTROLLER='1'"} });
        //委托单位
        this.comboxCustCode = Ext.create('DsExt.ux.RefTableCombox', {
            fieldLabel: '委托单位',
            store: this.storeCustCode,
            forceSelection: true,
            name: 'CUSTOMERNAME',
            valueField: 'CustName',
            displayField: 'CodeAndName'
        });


        //客户加载_船公司
        this.storeCARRIER = Ext.create('DsExt.ux.RefTableStore', {
            model: 'DsShipping.ux.CustomRefModel',
            proxy: { url: '/CommMng/BasicDataRef/GetCustomRefList' }
        });
        this.storeCARRIER.load({ params: { condition: "ISCARRIER='1'"} });
        //船公司
        this.comboxCARRIER = Ext.create('DsExt.ux.RefTableCombox', {
            fieldLabel: '船公司',
            store: this.storeCARRIER,
            forceSelection: true,
            name: 'CARRIER',
            valueField: 'CustName',
            displayField: 'CodeAndName'
        });

        //客户加载_车队
        this.storeTRUCKER = Ext.create('DsExt.ux.RefTableStore', {
            model: 'DsShipping.ux.CustomRefModel',
            proxy: { url: '/CommMng/BasicDataRef/GetCustomRefList' }
        });
        this.storeTRUCKER.load({ params: { condition: "ISTRUCK='1'"} });
        //车队
        this.comboxTRUCKER = Ext.create('DsExt.ux.RefTableCombox', {
            fieldLabel: '车队',
            store: this.storeTRUCKER,
            forceSelection: true,
            name: 'TRUCKER',
            valueField: 'CustName',
            displayField: 'CodeAndName'
        });

        //客户加载_报关报检
        this.storeCUSTOMSER = Ext.create('DsExt.ux.RefTableStore', {
            model: 'DsShipping.ux.CustomRefModel',
            proxy: { url: '/CommMng/BasicDataRef/GetCustomRefList' }
        });
        this.storeCUSTOMSER.load({ params: { condition: "ISCUSTOM='1'"} });
        //报关行
        this.comboxCUSTOMSER = Ext.create('DsExt.ux.RefTableCombox', {
            fieldLabel: '报关行',
            store: this.storeCUSTOMSER,
            forceSelection: true,
            name: 'CUSTOMSER',
            valueField: 'CustName',
            displayField: 'CodeAndName'
        });




        //键值维护表_委托单类型
        this.StoreBLTYPE = Ext.create('Ext.data.Store', {
            fields: ['BLTYPE']
        });
        this.StoreBLTYPE.add({ "BLTYPE": "整箱" });
        this.StoreBLTYPE.add({ "BLTYPE": "拼箱主票" });
        this.StoreBLTYPE.add({ "BLTYPE": "拼箱分票" });
        this.StoreBLTYPE.add({ "BLTYPE": "拼箱单票" });


        this.comboxBLTYPE = Ext.create('DsExt.ux.RefTableCombox', {
            fieldLabel: '装运方式',
            store: this.StoreBLTYPE,
            forceSelection: true,
            name: 'BLTYPE',
            valueField: 'BLTYPE',
            displayField: 'BLTYPE'
        });

        //品名
        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: '品名',
            store: this.storeCodeGoodsList,
            forceSelection: true,
            name: 'GOODSNAME',
            valueField: 'GOODNAME',
            displayField: 'CodeAndName'
        });

        //业务来源
        this.storeSource = Ext.create('DsExt.ux.RefTableStore', {
            model: 'DsShipping.ux.SourceModel',
            proxy: { url: '/CommMng/BasicDataRef/GetSource' }
        });
        this.storeSource.load();
        this.storeSourceDetail = Ext.create('DsExt.ux.RefTableStore', {
            model: 'DsShipping.ux.SourceDetailModel',
            proxy: { url: '/CommMng/BasicDataRef/GetSourceDetail2' }
        });
        this.comboxBSSOURCE = Ext.create('DsExt.ux.RefTableCombox', {
            fieldLabel: '业务来源',
            store: this.storeSource,
            forceSelection: true,
            name: 'BSSOURCE',
            valueField: 'SourceName',
            displayField: 'SourceName',
            listeners: {
                scope: this,
                'select': function (combo, records, eOpts) {
                    if (records.length > 0) {
                        var recs = DsStoreQueryBy(this.storeSource, 'SourceID', records[0].data.SourceID);
                        if (recs.getCount() > 0) {
                            var data = recs.getAt(0).data;
                            var s = "SOURCEID='" + data.SourceID + "'";
                            this.storeSourceDetail.load({ params: { condition: s} });
                        } else {
                            var BSSOURCEDETAIL = this.formHead.getForm().findField('BSSOURCEDETAIL');
                            BSSOURCEDETAIL.setValue('');
                        }
                    }
                }
            }
        });
        this.comboxBSSOURCEDETAIL = Ext.create('DsExt.ux.RefTableCombox', {
            fieldLabel: '贸易条款',
            store: this.storeSourceDetail,
            forceSelection: true,
            name: 'BSSOURCEDETAIL',
            valueField: 'SourceDetail',
            displayField: 'SourceDetail'
        });

        //状态_业务状态
        Ext.define('BSSTATUSModel', {
            extend: 'Ext.data.Model',
            fields: [
              { name: 'Name', type: 'string' }
            ]
        });
        var dataBSSTATUS = [{ "Name": "未锁定" }, { "Name": "锁定" }, { "Name": ""}];
        var storeBSSTATUS = Ext.create('Ext.data.Store', {
            model: 'BSSTATUSModel',
            data: dataBSSTATUS
        });
        //业务状态
        this.comboxBSSTATUS = Ext.create('DsExt.ux.RefTableCombox', {
            fieldLabel: '',
            forceSelection: true,
            store: storeBSSTATUS,
            name: 'BSSTATUS',
            valueField: 'Name',
            displayField: 'Name'
        });
        //费用状态
        this.comboxFEESTATUS = Ext.create('DsExt.ux.RefTableCombox', {
            fieldLabel: '',
            forceSelection: true,
            store: storeBSSTATUS,
            name: 'FEESTATUS',
            valueField: 'Name',
            displayField: 'Name'
        });

        //所属部门
        this.storeDept = Ext.create('DsExt.ux.RefTableStore', {
            model: 'DsShipping.ux.DeptModel',
            proxy: { url: '/CommMng/BasicDataRef/GetDeptList_All_Group' }//proxy: { url: '/CommMng/BasicDataRef/GetDeptList' }
        });
        this.storeDept.load();
        this.comboxDept = Ext.create('DsExt.ux.RefTableCombox', {
            fieldLabel: '所属部门',
            store: this.storeDept,
            forceSelection: true,
            name: 'SALEDEPT',
            valueField: 'DeptName',
            displayField: 'DeptName'
            //,hidden: true
        });

        //国际港口(进口装货港、出口卸货港)
        this.storeCodeDisport = Ext.create('DsExt.ux.RefTableStore', {
            model: 'DsShipping.ux.CodeDisportModel',
            proxy: { url: '/CommMng/BasicDataRef/GetCodeDisportList' }
        });
        this.storeCodeDisport.load();
        this.comboxPORTLOAD = Ext.create('DsExt.ux.RefTableCombox', {
            fieldLabel: '装货港',
            store: this.storeCodeDisport,
            forceSelection: true,
            name: 'PORTLOAD',
            valueField: 'CNAME',
            displayField: 'CodeAndName'
        });

        //国内港口(出口装货港、进口卸货港)
        this.storeCodeLoadport = Ext.create('DsExt.ux.RefTableStore', {
            model: 'DsShipping.ux.CodeLoadportModel',
            proxy: { url: '/CommMng/BasicDataRef/GetCodeLoadportList' }
        });
        this.storeCodeLoadport.load();
        this.comboxPORTDISCHARGE = Ext.create('DsExt.ux.RefTableCombox', {
            fieldLabel: '卸货港',
            store: this.storeCodeLoadport,
            forceSelection: true,
            name: 'PORTDISCHARGE',
            valueField: 'CNAME',
            displayField: 'CodeAndName'
        });


        //#endregion
        this.formSearch = Ext.widget('form', {
            frame: true,
            region: 'center',
            bodyPadding: 5,
            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: [this.comboxCUSTNO,{
                        name: 'CUSTNO'
                    }, this.comboxMBLNO, {
                        name: 'MBLNO'
                    }]
                }, {
                    xtype: 'container',
                    layout: 'hbox',
                    defaultType: 'textfield',
                    items: [this.comboxHBLNO, {
                        name: 'HBLNO'
                    }, this.comboxORDNO, {
                        name: 'ORDNO'
                    }]
                }, {
                    xtype: 'container',
                    layout: 'hbox',
                    defaultType: 'textfield',
                    items: [this.comboxHBLNO, {
                        name: 'HBLNO'
                    }, this.comboxORDNO, {
                        name: 'ORDNO'
                    }]
                }, {
                    xtype: 'container',
                    layout: 'hbox',
                    defaultType: 'textfield',
                    items: [this.comboxHBLNO, {
                        name: 'HBLNO'
                    }, this.comboxORDNO, {
                        name: 'ORDNO'
                    }]
                }, {
                    xtype: 'container',
                    layout: 'hbox',
                    defaultType: 'textfield',
                    items: [this.comboxHBLNO, {
                        name: 'HBLNO'
                    }, this.comboxORDNO, {
                        name: 'ORDNO'
                    }]
                }]//end items(fieldset 1)
            }]//end root items
        });

        me = this;
        this.winQuery = Ext.create('Ext.window.Window', {
            title: "高级查询",
            width: 450,
            height: 600,
            //plain : true,
            iconCls: "addicon",
            resizable: false,
            // 是否可以拖动
            // draggable:false,
            collapsible: true, // 允许缩放条
            closeAction: 'close',
            closable: true,
            modal: 'true',
            buttonAlign: "center",
            bodyStyle: "padding:0 0 0 0",
            items: [this.formSearch],
            buttons: [{
                text: "查询",
                minWidth: 70,
                handler: function () {
                    me.winQuery.close();
                }
            },{
                text: "关闭",
                minWidth: 70,
                handler: function () {
                    me.winQuery.close();
                }
            }]
        });




        Ext.apply(this, this.winQuery);
       
    }
});