Ext.namespace('Shipping'); Shipping.MsOpSeaeRunBillIndex = function (config) { Ext.applyIf(this, config); this.initUIComponents(); window.Shipping.MsOpSeaeRunBillIndex.superclass.constructor.call(this); }; Ext.extend(Shipping.MsOpSeaeRunBillIndex, Ext.Panel, { PageSize: 50, SelectedRecord: null, initUIComponents: function () { this.formname = "MsOpSeaeRunBillIndex"; //页面名称 this.storeList = Ext.create('Ext.data.Store', { pageSize: this.PageSize, model: 'MsOpSeaeRunBillModel', remoteSort: true, proxy: { type: 'ajax', url: '/MvcShipping/MsOpSeaeRunBill/GetDataList', reader: { id: 'GID', root: 'data', totalProperty: 'totalCount' } } }); //跑单人 this.storeOpCode = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.UserRefModel', proxy: { url: '/CommMng/BasicDataRef/GetUserLinkRefListRm' } }); this.storeOpCode.load(); _this = this; this.Pagenum = Ext.create('Ext.form.field.Number', { name: 'bottles', fieldLabel: Zi.LAN.bottles, //'每页记录数', labelAlign: 'right', value: this.PageSize, maxValue: 100000, width: 180, minValue: 0, listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }); Ext.grid.RowNumberer = Ext.extend(Ext.grid.RowNumberer, { width: 40 }); this.initgirdcolums = [{ sortable: true, id: '', dataIndex: '', header: '', width: 0 }, { sortable: true, id: '', dataIndex: 'GID', header: 'GID', //'业务编号', width: 0 }, { sortable: true, id: '', dataIndex: 'BillNO', header: Zi.LAN.BillNO, //'跑单编号', width: 120 }, { sortable: true, id: '', dataIndex: 'CUSTOMERNAME', header: Zi.LAN.CUSTOMERNAME, //'客户名称', width: 120 }, { sortable: true, id: '', dataIndex: 'CHIEF', header: Zi.LAN.CHIEF, //'', width: 120 }, { sortable: true, id: '', dataIndex: 'ADDR', header: Zi.LAN.ADDR, //'', width: 120 }, { sortable: true, id: '', dataIndex: 'TEL', header: Zi.LAN.TEL, //'', width: 120 }, { sortable: true, id: '', dataIndex: 'REASON', header: Zi.LAN.REASON, //'', width: 120 }, { sortable: true, id: '', dataIndex: 'USERNAME', header: Zi.LAN.USERNAME, //'', width: 120 }, { sortable: true, id: '', dataIndex: 'RUNTIME', header: Zi.LAN.RUNTIME, //'', width: 120 }, { sortable: true, id: '', dataIndex: 'COMPLETETIME', header: Zi.LAN.CompleteTime, //'', renderer: Ext.util.Format.dateRenderer('Y-m-d H:i:s'), width: 120 }, { sortable: true, id: '', dataIndex: 'TimeSpan', header: Zi.LAN.TimeSpan, //'', width: 80 }, { sortable: true, id: '', dataIndex: 'CARRIER', header:'船公司', //'', width: 120 }, { sortable: true, id: '', dataIndex: 'FORWARDER', header:'订舱代理', //'', width: 120 }, { sortable: true, id: '', dataIndex: 'STATUS', header: Zi.LAN.STATUS, //'', width: 120 }, { sortable: true, id: '', dataIndex: 'CREATEUSERNAME', header: Zi.LAN.CREATEUSER, //'', width: 120 }, { sortable: true, id: '', dataIndex: 'CREATETIME', header: Zi.LAN.CREATETIME, //'', width: 120 }]; this.girdcolums = this.initgirdcolums; this.GridCheckBoxModel = Ext.create('Ext.selection.CheckboxModel'); //定义Grid this.gridList = new Ext.grid.GridPanel({ store: this.storeList, enableHdMenu: false, region: 'center', id: 'gridlist', loadMask: { msg: Zi.LAN.ShuJuJiaZaiZhongQingShaoDeng //"数据加载中,请稍等..." }, trackMouseOver: true, disableSelection: false, //features: [this.filters], selModel: this.GridCheckBoxModel, viewConfig: { enableTextSelection: true, //允许复制数据 autoFill: true }, listeners: { cellclick: function (thisTab, record, item, index, e, eOpts) { //var _status = record.innerText; //_status = _status.substring(0, _status.length - 1); //if (dicStatus.containsValue(_status)) { // steplay.fnLoad(index.data.MBLNO, index.data.BSNO); //} } }, columns: this.girdcolums, // paging bar on the bottom bbar: [Ext.create('Ext.PagingToolbar', { store: this.storeList, displayInfo: true, displayMsg: Zi.LAN.displayMsg, //'当前显示 {0} - {1}条记录 /共 {2}条记录', emptyMsg: Zi.LAN.emptyMsg//'没有数据' }), this.Pagenum] }); this.gridList.addListener('itemdblclick', function (dataview, record, item, index, e, b) { this.SelectedRecord = record; this.openEdit(record.data.GID); }, this); /////////////以下部分为获取存储的gridpanel显示样式 this.girdcolums = DsTruck.GetGridPanel(USERID, this.formname, this.girdcolums, 1); //使用者id,表名,中间column数组,跳过一开始的几列 this.girdcolums.unshift(new Ext.grid.RowNumberer()); this.gridList.reconfigure(this.storeList, this.girdcolums); //////////////////////////// //创建人 this.comboxOP = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: Zi.LAN.CREATEUSER, //'创建人', store: this.storeOpCode, queryMode: 'remote', minChars: 0, queryParam: 'CODENAME', labelWidth: 60, forceSelection: true, name: 'CreateUser', flex: 1, valueField: 'UserName', displayField: 'CodeAndName', enableKeyEvents: true, listeners: { keyup: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }); //跑单人 this.comboxRunBillUser = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: Zi.LAN.USERNAME, //'跑单人', store: this.storeOpCode, queryMode: 'remote', minChars: 0, queryParam: 'CODENAME', labelWidth: 60, forceSelection: true, name: 'RunBillUser', flex: 1, valueField: 'UserName', displayField: 'CodeAndName', enableKeyEvents: true, listeners: { keyup: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }); //上午/下午store this.storeTimeSpan = new Ext.data.ArrayStore({ data: [{ title: '全部' }, { title: '上午' }, { title: '下午' }], fields: [{ name: 'title', mapping: 'title' }] }); //上午/下午 this.comboxTimeSpan = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: Zi.LAN.TimeSpan, //'上午/下午', store: this.storeTimeSpan, name: 'TimeSpan', flex: 0.5, valueField: 'title', displayField: 'title', listeners: { scope: this, 'select': function (combo, records, eOpts) { if (records.length > 0) { } } }, allowBlank: true }); 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: [{ xtype: 'container', defaultType: 'textfield', layout: 'anchor', defaults: { anchor: '100%' }, items: [{ xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: Zi.LAN.CREATETIME, //'创建时间', labelWidth: 60, flex: 1, format: 'Y-m-d', xtype: 'datefield', name: 'createTimeBGN', enableKeyEvents: true, listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }, { fieldLabel: Zi.LAN.To, //'到', labelWidth: 20, flex: 1, format: 'Y-m-d', xtype: 'datefield', name: 'createTimeEND', enableKeyEvents: true, listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }, { fieldLabel: Zi.LAN.RunBillTime, //'跑单时间', labelWidth: 60, flex: 1, format: 'Y-m-d', xtype: 'datefield', name: 'runTimeBGN', enableKeyEvents: true, listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }, { fieldLabel: Zi.LAN.To, //'到', labelWidth: 20, flex: 1, format: 'Y-m-d', xtype: 'datefield', name: 'runTimeEND', enableKeyEvents: true, listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }, this.comboxTimeSpan,{ xtype: 'button', flex:0.5, text: Zi.LAN.btnrefresh, //"执行查询", iconCls: "btnrefresh", handler: function (button, event) { this.onRefreshClick(button, event); }, scope: this }] } ] }, { xtype: 'container', defaultType: 'textfield', layout: 'anchor', defaults: { anchor: '100%' }, items: [{ xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [ { fieldLabel: Zi.LAN.CompleteTime, //'完成时间', labelWidth: 60, flex: 1, format: 'Y-m-d', xtype: 'datefield', name: 'CompleteTimeBGN', enableKeyEvents: true, listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }, { fieldLabel: Zi.LAN.To, //'到', labelWidth: 20, flex: 1, format: 'Y-m-d', xtype: 'datefield', name: 'CompleteTimeEND', enableKeyEvents: true, listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } },{ fieldLabel: Zi.LAN.BillNO, //'跑单编号', labelWidth: 60, flex: 1, name: 'runBillNO', enableKeyEvents: true, listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }, this.comboxRunBillUser,this.comboxOP ] } ] }] }); _this = this; //#region 按钮Toolbar this.panelBtn = new Ext.Panel({ region: "north", tbar: [{ id: 'btnOpen', text: Zi.LAN.Open, //"打开", iconCls: "btnedit", handler: function (button, event) { var selections = this.gridList.getSelectionModel().getSelection(); if (selections.length == 0) { Ext.Msg.show({ title: Zi.LAN.TiShi, msg: Zi.LAN.QingXianXuanZeJiLu, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } var record = selections[0]; this.SelectedRecord = record; this.openEdit(record.data.GID); }, scope: this }, { id: 'btnDispatch', text: Zi.LAN.Dispatch, //"派单", handler: function (button, event) { this.dispatchBill(); }, scope: this }, { id: 'btnDispatchChange', text: Zi.LAN.DispatchChange, //"转单", handler: function (button, event) { this.dispatchChange(); }, scope: this }, { text: Zi.LAN.Print, //"打印", iconCls: "btnprint", menu: [ { text: Zi.LAN.PrintAll, //"全部", handler: function (menu, event) { _this.Print(); } }, { text: Zi.LAN.PrintSelect, //"选择打印", handler: function (menu, event) { _this.PrintSelect(); } }], scope: this }, '-', { text: "保存列表样式", id: "btntest", menu: [ { text: "保存", handler: function (button, event) { this.girdcolums = DsTruck.SaveGridPanel(USERID, _this.formname, _this.gridList.columns, _this.girdcolums, 1, true); } }, { text: "初始化", handler: function (menu, event) { _this.gridList.reconfigure(this.storeDrChFee, _this.initgirdcolums); _this.girdcolums = DsTruck.SaveGridPanel(USERID, _this.formname, _this.gridList.columns, _this.initgirdcolums, 1, true); } }], scope: this }, { text: "删除", id: "btndelete", iconCls: "btndelete", handler: function (button, event) { this.onDeleteClick(button, event); }, scope: this }, { xtype: 'button', text: Zi.LAN.btnreset, //"重置条件", iconCls: "btnreset", handler: function (button, event) { this.onClearSql(button, event); }, scope: this }] }); //#endregion this.panelTop = new Ext.Panel({ layout: "border", region: "north", height: 100, items: [this.panelBtn, this.formSearch] }); Ext.apply(this, { items: [this.panelTop, this.gridList] }); _this = this; this.storeList.on('beforeload', function (store) { var sql = this.getCondition(); Ext.apply(store.proxy.extraParams, { condition: sql, pageSize: _this.PageSize }); }, this); this.storeList.load({ params: { start: 0, limit: _this.PageSize, sort: '' }, waitMsg: Zi.LAN.ZhengZaiChaXunShuJu, //"正在查询数据...", scope: this }); //this.InitData(); //#endregion }, //end initUIComponents openEdit: function (gid) { var left = (window.outerWidth - 600) / 2; var top = (window.outerHeight - 600) / 2; DsOpenEditWin('/MvcShipping/MsOpSeaeRunBill/Edit?gid=' + gid, '编辑跑单', 600, 600, top, left); }, dispatchChange: function () { var _this = this; var selRunBillPerson = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: Zi.LAN.RunBillPerson, //'跑单人', store: this.storeOpCode, id: 'disChgPerson', name: 'USERNAME', width: 280, valueField: 'UserName', displayField: 'CodeAndName', allowBlank: false, listeners: { scope: this, 'select': function (combo, records, eOpts) { if (records.length > 0) { var userGID = records[0].data.GID; Ext.getCmp('disChgUserId').setValue(userGID); } } } }); var imgform = new Ext.FormPanel({ region: 'center', labelWidth: 20, frame: true, autoScroll: false, border: false, fileUpload: true, items: [{ xtype: 'hiddenfield', name: 'USERID', id: 'disChgUserId' }, selRunBillPerson], buttons: [{ text: Zi.LAN.DispatchChange, //'转单', type: 'submit', handler: function () { var selectedRecords = _this.GridCheckBoxModel.selected.items; var strGid = ''; for (var idx = 0; idx < selectedRecords.length; idx++) { if (strGid.length > 0) { strGid += ',' } strGid += selectedRecords[idx].data.GID; } if (selectedRecords.length == 0) { Ext.Msg.show({ title: Zi.LAN.TiShi, msg: Zi.LAN.QingXianXuanZeJiLu, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } var disChgUserId = Ext.getCmp('disChgUserId').getValue(); var disChgUserName = Ext.getCmp('disChgPerson').getValue(); Ext.Ajax.request({ waitMsg: '', url: '/MvcShipping/MsOpSeaeRunBill/ChangeDispatch', params: { strGID: strGid, userid: disChgUserId, username: disChgUserName }, callback: function (options, success, response) { if (success) { var result = Ext.JSON.decode(response.responseText); if (result.Success) { Ext.Msg.show({ title: Zi.LAN.TiShi, msg: result.Message, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); _this.storeList.load({ params: { start: 0, limit: _this.PageSize, pageSize: _this.PageSize, sort: '' }, waitMsg: Zi.LAN.ZhengZaiChaXunShuJu, //"正在查询数据...", scope: this }); } else { Ext.Msg.show({ title: Zi.LAN.CuoWu, msg: result.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } } win.close(this); }, scope: this }); } }, { text: Zi.LAN.GuanBi, //'关闭', type: 'submit', handler: function () { win.close(this); } }] }); var win = new Ext.Window({ title: Zi.LAN.DispatchChange, //"转单", width: 380, height: 120, modal: true, resizable: false, border: false, items: imgform }); win.show(); }, dispatchBill: function () { var _this = this; var selectedRecords = _this.GridCheckBoxModel.selected.items; var strGid = ''; for (var idx = 0; idx < selectedRecords.length; idx++) { if (strGid.length > 0) { strGid += ',' } strGid += selectedRecords[idx].data.GID; } if (selectedRecords.length == 0) { Ext.Msg.show({ title: Zi.LAN.TiShi, msg: Zi.LAN.QingXianXuanZeJiLu, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } Ext.Ajax.request({ waitMsg: '', url: '/MvcShipping/MsOpSeaeRunBill/DispatchBill', params: { strGID: strGid }, callback: function (options, success, response) { if (success) { var result = Ext.JSON.decode(response.responseText); if (result.Success) { Ext.Msg.show({ title: Zi.LAN.TiShi, msg: result.Message, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); _this.storeList.load({ params: { start: 0, limit: _this.PageSize, pageSize: _this.PageSize, sort: '' }, waitMsg: Zi.LAN.ZhengZaiChaXunShuJu, //"正在查询数据...", scope: this }); } else { Ext.Msg.show({ title: Zi.LAN.CuoWu, msg: result.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } } }, scope: this }); }, Print: function () { var printType = 'MSOPSEAERUNBILLLIST'; var sql1 = "SET LANGUAGE 'us_english' select * from op_seae_run_bill"; var sql2 = "SET LANGUAGE 'us_english' select * from op_seae_run_bill_item"; var sql3 = ""; var sql4 = ""; var sql5 = ""; var sql6 = ""; PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6); }, PrintSelect: function () { var selectedRecords = this.GridCheckBoxModel.selected.items; if (selectedRecords.length == 0) { Ext.Msg.show({ title: Zi.LAN.TiShi, msg: Zi.LAN.QingXianXuanZeJiLu, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } var gidStr = ''; for (var i = 0; i < selectedRecords.length; i++) { var record = selectedRecords[i]; var gid = "'" + record.get('GID') + "'"; if (gidStr == '') { gidStr = gid; } else { gidStr = gidStr + "," + gid; } }; var printType = 'MSOPSEAERUNBILLLIST'; var sql1 = "SET LANGUAGE 'us_english' select * from op_seae_run_bill where gid in (" + gidStr + ")"; var sql2 = "SET LANGUAGE 'us_english' select * from op_seae_run_bill_item where parentid in (" + gidStr + ")"; var sql3 = ""; var sql4 = ""; var sql5 = ""; var sql6 = ""; PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6); }, onDeleteClick: function (button, event) { var selections = this.gridList.getSelectionModel().getSelection(); if (selections.length == 0) { Ext.Msg.show({ title: '提示', msg: '请先选择单据!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } var record = selections[0]; var deldata = record.data; deldata.SFDJ = false; Ext.MessageBox.confirm('提示', '确定删除该记录吗?', function (btn) { if (btn == 'yes') { Ext.Msg.wait('正在删除数据...'); Ext.Ajax.request({ waitMsg: '正在删除数据...', url: '/MvcShipping/MsOpseaeRunBill/Delete', params: { data: Ext.JSON.encode(deldata) }, callback: function (options, success, response) { if (success) { var jsonresult = Ext.JSON.decode(response.responseText); if (jsonresult.Success) { this.storeList.remove(record); Ext.Msg.show({ title: '提示', msg: jsonresult.Message, 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 }); //end Ext.Ajax.request } }, this); }, //onDeleteClick onRefreshClick: function (button, event) { var sql = this.getCondition(); this.sqlcontext = sql; this.PageSize = this.Pagenum.getValue(); this.storeList.pageSize = this.PageSize; this.storeList.currentPage = 1; this.storeList.load({ params: { start: 0, limit: _this.PageSize, pageSize: _this.PageSize, sort: '', condition: sql }, waitMsg: Zi.LAN.ZhengZaiChaXunShuJu, //"正在查询数据...", scope: this }); }, getCondition: function () { var form = this.formSearch.getForm(); // var form2 = this.formSearch2.getForm(); if (!form.isValid()) { Ext.Msg.alert(Zi.LAN.TiShi, '查询条件赋值错误,请检查。'); return ''; } // var sql = '1=1'; //#region formSearch 查询面板 //创建时间 var createTimeBGN = form.findField('createTimeBGN').getRawValue(); sql = sql + getAndConSql(sql, createTimeBGN, "CreateTime >='" + createTimeBGN + "'"); var createTimeEND = form.findField('createTimeEND').getRawValue(); sql = sql + getAndConSql(sql, createTimeEND, "CreateTime <='" + createTimeEND + "'"); //跑单时间 var runTimeBGN = form.findField('runTimeBGN').getRawValue(); sql = sql + getAndConSql(sql, runTimeBGN, "runTime >='" + runTimeBGN + "'"); var runTimeEND = form.findField('runTimeEND').getRawValue(); sql = sql + getAndConSql(sql, runTimeEND, "runTime <='" + runTimeEND + "'"); //完成时间 var CompleteTimeBGN = form.findField('CompleteTimeBGN').getRawValue(); sql = sql + getAndConSql(sql, CompleteTimeBGN, "CompleteTime >='" + CompleteTimeBGN + "'"); var CompleteTimeEND = form.findField('CompleteTimeEND').getRawValue(); sql = sql + getAndConSql(sql, CompleteTimeEND, "CompleteTime <='" + CompleteTimeEND + "'"); //时间范围 var timeSpan = form.findField('TimeSpan').getValue(); if (timeSpan != null && timeSpan != '全部') { sql = sql + getAndConSql(sql, timeSpan, "TimeSpan ='" + timeSpan + "'"); } //创建人 var createUser = form.findField('CreateUser').getValue(); sql = sql + getAndConSql(sql, createUser, "CreateUserName='" + createUser + "'"); //跑单人 var runBillUser = form.findField('RunBillUser').getValue(); sql = sql + getAndConSql(sql, runBillUser, "UserName='" + runBillUser + "'"); //跑单编号 var runBillNO = form.findField('runBillNO').getValue(); sql = sql + getAndConSql(sql, runBillNO, "billno='" + runBillNO + "'"); return sql; }, onClearSql: function () { var form = this.formSearch.getForm(); form.reset(); } });