//集运管理-路单查询 Ext.namespace('Shipping'); Shipping.MsRptDsSaleJieSuanTiChengIndex = function (config) { Ext.applyIf(this, config); this.initUIComponents(); window.Shipping.MsRptDsSaleJieSuanTiChengIndex.superclass.constructor.call(this); }; //需求编号:SR2017072100012 Ext.extend(Shipping.MsRptDsSaleJieSuanTiChengIndex, Ext.Panel, { PageSize: 1000, OprationStatus: null, //仅当弹出界面时使用 SelectedRecord: null, sqlcontext: '1=2', bslistsortfield: '', bslistsortdire: '', initUIComponents: function () { this.formname = 'MsRptDsSaleJieSuanTiChengIndex'; Ext.Ajax.timeout = 12000000; //#region 主列表 //#region 定义数据集 this.storeList = Ext.create('Ext.data.Store', { pageSize: this.PageSize, fields: [ { name: 'BSNO', type: 'string' }, { name: 'MBLNO', type: 'string' }, { name: 'BILLNO', type: 'string' }, { name: 'SETTLETIME', type: 'string' }, { name: 'CUSTOMERNAME', type: 'string' }, { name: 'CUSTNO', type: 'string' }, { name: 'BSSOURCE', type: 'string' }, { name: 'BSSOURCEDETAIL', type: 'string' }, { name: 'OPDATE', type: 'string' }, { name: 'SALE', type: 'string' }, { name: 'CUSTSERVICE', type: 'string' }, { name: 'STLDATE', type: 'string' }, { name: 'STLAMOUNT', type: 'number' }, { name: 'TTLDR', type: 'number' }, { name: 'TTLCR', type: 'number' }, { name: 'TTLPROFIT', type: 'number' }, { name: 'TTLNODR', type: 'number' } ], remoteSort: true, timeout: 60000000, //60秒 proxy: { type: 'ajax', timeout: 60000000, //60秒 url: '/MvcShipping/MsRptSaleJieSuanTiCheng/GetDsDataList', reader: { id: '', root: 'data', totalProperty: 'totalCount' } } }); //#endregion this.Pagenum = Ext.create('Ext.form.field.Number', { name: 'bottles', fieldLabel: '每页记录数', labelAlign: 'right', value: this.PageSize, maxValue: 100000, width: 180, minValue: 0, listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }); //#region 定义Grid列名 this.initgirdcolums = [{ sortable: true, dataIndex: 'BSNO', header: '编号', hidden: true, width: 130 }, { sortable: true, dataIndex: 'BILLNO', header: '结算单号', width: 120 }, { sortable: true, dataIndex: 'MBLNO', header: '主提单号', width: 120 }, { sortable: true, dataIndex: 'SETTLETIME', header: '结算时间', width: 120 }, { sortable: true, dataIndex: 'CUSTOMERNAME', header: '委托单位', width: 120 }, { sortable: true, dataIndex: 'BSSOURCE', header: '业务来源', width: 120 }, { sortable: true, dataIndex: 'BSSOURCEDETAIL', header: '贸易条款', width: 120 }, { sortable: true, dataIndex: 'SALE', header: '业务员', width: 80 }, { sortable: true, dataIndex: 'CUSTSERVICE', header: '客服', width: 80 }, { sortable: true, dataIndex: 'OPDATE', header: '业务日期', width: 86 }, { sortable: true, dataIndex: 'STLAMOUNT', header: '结算金额', renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { try { var lsValue = usMoney(value, 2, '', false); if (lsValue != "NaN") { value = lsValue; if (parseFloat(lsValue) < 0) { return '' + lsValue + ''; } } else { return value; } } catch (e) { return value; } return value; }, align: 'right', summaryType: 'sum', summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { value = usMoney(value, 2, '', true); return value; }, width: 80 }, { sortable: true, dataIndex: 'TTLDR', header: '合计应收', renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { try { var lsValue = usMoney(value, 2, '', false); if (lsValue != "NaN") { value = lsValue; if (parseFloat(lsValue) < 0) { return '' + lsValue + ''; } } else { return value; } } catch (e) { return value; } return value; }, align: 'right', summaryType: 'sum', summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { value = usMoney(value, 2, '', true); return value; }, width: 80 }, { sortable: true, dataIndex: 'TTLCR', header: '合计应付', renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { try { var lsValue = usMoney(value, 2, '', false); if (lsValue != "NaN") { value = lsValue; if (parseFloat(lsValue) < 0) { return '' + lsValue + ''; } } else { return value; } } catch (e) { return value; } return value; }, align: 'right', summaryType: 'sum', summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { value = usMoney(value, 2, '', true); return value; }, width: 80 }, { sortable: true, dataIndex: 'TTLPROFIT', header: '合计利润', renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { try { var lsValue = usMoney(value, 2, '', false); if (lsValue != "NaN") { value = lsValue; if (parseFloat(lsValue) < 0) { return '' + lsValue + ''; } } else { return value; } } catch (e) { return value; } return value; }, align: 'right', summaryType: 'sum', summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { value = usMoney(value, 2, '', true); return value; }, width: 80 }, { sortable: true, dataIndex: 'TTLNODR', header: '合计未收', renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { try { var lsValue = usMoney(value, 2, '', false); if (lsValue != "NaN") { value = lsValue; if (parseFloat(lsValue) < 0) { return '' + lsValue + ''; } } else { return value; } } catch (e) { return value; } return value; }, align: 'right', summaryType: 'sum', summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { value = usMoney(value, 2, '', true); return value; }, width: 80 }, { sortable: true, dataIndex: 'STLDATE', header: '账期', width: 80 }]; this.girdcolums = DsTruck.GetGridPanel(USERID, this.formname + 'bs', this.initgirdcolums, 1); //#endregion //#region 定义Grid this.GridCheckBoxModel = Ext.create('Ext.selection.CheckboxModel'); this.gridList = new Ext.grid.GridPanel({ border: false, store: this.storeList, enableHdMenu: false, region: 'center', loadMask: { msg: "数据加载中,请稍等..." }, trackMouseOver: true, selModel: this.GridCheckBoxModel, disableSelection: false, columns: this.girdcolums, features: [{ ftype: 'summary' }], viewConfig: { autoFill: true, getRowClass: function (record, rowIndex, rowParams, store) { var BILLSTATUSREF = record.get('ISSALEFEE'); if (BILLSTATUSREF == "已发放") return 'feestatus_pass'; } }, bbar: [Ext.create('Ext.PagingToolbar', { store: this.storeList, displayInfo: true, displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录', emptyMsg: "没有数据" }), this.Pagenum] }); //#endregion //#region Grid事件 this.gridList.addListener('itemdblclick', function (dataview, record, item, index, e, b) { this.SelectedRecord = record; var openSet = "height=700, width=1024, toolbar=no, menubar=no,scrollbars=1, resizable=1,location=no, status=no,Top= " + (screen.height - 750) / 2 + ",Left= " + (screen.width - 1100) / 2 var openType = "_blank"; var openUrl = ""; if (record.data.OPLBNAME == "报关业务") { openUrl = "../MvcShipping/MsOpApply/ApplyFeeView?handle=check&bsno=" + record.data.BSNO; } else { openUrl = "../MvcShipping/MsOpBill/MsOpFeeView?handle=check&bsno=" + record.data.BSNO; } window.open(openUrl, openType, openSet); }, this); this.gridList.addListener('sortchange', function (ct, column, direction, eOpts) { this.bslistsortfield = column.dataIndex; this.bslistsortdire = direction; }, this); //#endregion //#endregion //#region 合计列表 //#endregion //#region 加载下拉框 _this = this; this.storeSalesCode = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.UserRefModel', proxy: { url: '/CommMng/BasicDataRef/GetUserRefList' } }); this.storeSalesCode.load(); this.comboxSalesCode = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '揽货人', store: this.storeSalesCode, forceSelection: true, name: 'PS_SALE', valueField: 'UserName', displayField: 'CodeAndName', enableKeyEvents: true, listeners: { keyup: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }); this.comboxCUSTSERVER= Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '客 服', store: this.storeSalesCode, forceSelection: true, name: 'PS_CUSTSERVICE', valueField: 'UserName', displayField: 'CodeAndName', enableKeyEvents: true, listeners: { keyup: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }); 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, name: 'PS_CUSTOMERNAME', valueField: 'CustName', displayField: 'CodeAndName', enableKeyEvents: true, listeners: { keyup: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }); //业务来源 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.formSearch.getForm().findField('BSSOURCEDETAIL'); BSSOURCEDETAIL.setValue(''); } } } } }); this.storeSourceDetail.load(); this.comboxBSSOURCEDETAIL = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '贸易条款', store: this.storeSourceDetail, forceSelection: true, name: 'BSSOURCEDETAIL', valueField: 'SourceDetail', displayField: 'SourceDetail', enableKeyEvents: true, listeners: { keyup: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }); //#endregion //#region formSearch this.formSearch = Ext.widget('form', { border: false, frame: true, region: 'center', bodyPadding: 5, fieldDefaults: { margins: '2 2 2 2', labelAlign: 'right', flex: 1, labelWidth: 90, msgTarget: 'qtip' }, items: [{ xtype: 'container', defaultType: 'textfield', layout: 'anchor', defaults: { anchor: '100%' }, items: [{ xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [ this.comboxSalesCode, this.comboxCustCode, { fieldLabel: '从业务日期', format: 'Y-m-d', xtype: 'datefield', name: 'PS_EXPDATEBGN', enableKeyEvents: true, listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }, { fieldLabel: '到业务日期', format: 'Y-m-d', xtype: 'datefield', name: 'PS_EXPDATEEND', enableKeyEvents: true, listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }, { fieldLabel: '编号', name: 'PS_MBLNO', enableKeyEvents: true, listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } } ] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [this.comboxBSSOURCE, this.comboxCUSTSERVER, { fieldLabel: '从结算日期', format: 'Y-m-d', xtype: 'datefield', name: 'PS_STLDATEBGN', enableKeyEvents: true, listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }, { fieldLabel: '到结算日期', format: 'Y-m-d', xtype: 'datefield', name: 'PS_STLDATEEND', enableKeyEvents: true, listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }, { xtype: 'hiddenfield' }] }] }] }); //#endregion //#region 查询工具条 this.CheckSaveQuery = new Ext.form.Checkbox({ fieldLabel: '记忆查询条件', checked: true, width: 120 }); _this = this; this.SearchBtn = new Ext.Button({ text: '隐藏查询', handler: function () { if (_this.SearchBtn.text == '隐藏查询') { _this.panelSearch.hide(); _this.SearchBtn.setText("显示查询"); } else { _this.panelSearch.show(); _this.SearchBtn.setText("隐藏查询"); } } }); this.panelBtn = new Ext.Panel({ border: false, region: "north", tbar: [ { text: "执行查询", iconCls: "btnrefresh", handler: function (button, event) { this.onRefreshClick(button, event); var isvisible = true; var issavevalue = false; if (_this.SearchBtn.text == '隐藏查询') isvisible = true else isvisible = false; if (this.CheckSaveQuery.checked) issavevalue = true saveQuerySetting(this.formname, this.formSearch, isvisible, issavevalue); }, scope: this }, { text: "导出Excel", id: "btnExportExcel", iconCls: 'btnexportexcel', handler: function (button, event) { this.onExportClick(button, event); }, scope: this }, '-', { text: "打印", iconCls: 'btnprint', handler: function (button, event) { this.Print(); }, scope: this }, '-', this.SearchBtn, { xtype: 'button', width: 90, text: "清空条件", iconCls: "btnreset", handler: function (button, event) { this.onClearSql(button, event); }, scope: this }, this.CheckSaveQuery, '-', { text: "保存列表样式", id: "btntest", menu: [ { text: "保存列表", handler: function (button, event) { _this.onSaveGridClick(button, event); } }, { text: "列表初始化", handler: function (button, event) { _this.oninitGridClick(button, event); } }], scope: this } ] }); //#endregion //#region 页面布局 this.panelTop = new Ext.Panel({ border: false, layout: "border", region: "north", height: 100, items: [this.panelBtn, this.formSearch] }); Ext.apply(this, { border: false, items: [this.panelTop, this.gridList] }); //#endregion //提取查询条件记忆 LoadQueryData(this.formname, this.formSearch, this.CheckSaveQuery); }, //end initUIComponents //#region 查询 onRefreshClick: function (button, event) { if (!this.checkSearchCondition()) return; Ext.Ajax.timeout = 60000000; var sql = this.getCondition(); this.PageSize = this.Pagenum.getValue(); this.storeList.pageSize = this.PageSize; this.sqlcontext = sql; this.storeList.load({ params: { start: 0, limit: this.PageSize, condition: sql}, waitMsg: "正在查询数据...", timeout: 60000000, scope: this }); this.storeList.on('beforeload', function (store) { Ext.apply(store.proxy.extraParams, { condition: sql }); }, this); }, getCondition: function () { var form = this.formSearch.getForm(); var sql = ''; var mblNo = form.findField('PS_MBLNO').getValue(); sql = sql + getAndConSql(sql, mblNo, " (B.CUSTNO like '%" + mblNo + "%' or B.MBLNO like '%" + mblNo + "%' or B.HBLNO like '%" + mblNo + "%' or B.CUSTOMNO like '%" + mblNo + "%') ");// or B.ORDERNO like '%" + mblNo + "%' var expDate_Min = form.findField('PS_EXPDATEBGN').getRawValue(); sql = sql + getAndConSql(sql, expDate_Min, " B.OPDATE>='" + expDate_Min + "'"); var expDate_Max = form.findField('PS_EXPDATEEND').getRawValue(); sql = sql + getAndConSql(sql, expDate_Max, " B.OPDATE<='" + expDate_Max + " 23:59:59'"); var CUSTOMERNAME = form.findField('PS_CUSTOMERNAME').getValue(); sql = sql + getAndConSql(sql, CUSTOMERNAME, "B.CUSTOMERNAME='" + CUSTOMERNAME + "'"); var SALE = form.findField('PS_SALE').getValue(); sql = sql + getAndConSql(sql, SALE, "B.SALE='" + SALE + "'"); var CUSTSERVICE = form.findField('PS_CUSTSERVICE').getValue(); sql = sql + getAndConSql(sql, CUSTSERVICE, "B.CUSTSERVICE='" + CUSTSERVICE + "'"); var BSSOURCE = form.findField('BSSOURCE').getValue(); sql = sql + getAndConSql(sql, BSSOURCE, "B.BSSOURCE='" + BSSOURCE + "'"); var expDate_Min = form.findField('PS_STLDATEBGN').getRawValue(); sql = sql + getAndConSql(sql, expDate_Min, " S.SETTLETIME>='" + expDate_Min + "'"); var expDate_Max = form.findField('PS_STLDATEEND').getRawValue(); sql = sql + getAndConSql(sql, expDate_Max, " S.SETTLETIME<='" + expDate_Max + " 23:59:59'"); return sql; }, getstlCondition: function () { var form = this.formSearch.getForm(); var sql = ''; return sql; }, getDCondition: function () { var form = this.formSearch.getForm(); var sql = ''; return sql; }, checkSearchCondition: function () { var form = this.formSearch.getForm(); if (!form.isValid()) { Ext.Msg.alert('提示', '查询条件赋值错误,请检查。'); return false; } return true; }, onClearSql: function () { var form = this.formSearch.getForm(); form.reset(); }, //#endregion //#region 保存列表 onSaveGridClick: function (button, event) { this.girdcolums = DsTruck.SaveGridPanel(USERID, this.formname + 'bs', this.gridList.columns, this.girdcolums, 1, true); }, //#endregion //#region 列表初始化 oninitGridClick: function (button, event) { var agirdcolums = this.initgirdcolums; this.gridList.reconfigure(this.storeList, agirdcolums); this.girdcolums = DsTruck.SaveGridPanel(USERID, this.formname + 'bs', this.gridList.columns, this.initgirdcolums, 1, true); }, //#endregion //#region 导出 onExportClick: function (button, event) { GridExportExcelPage(this.gridList); }, //#endregion //#region 打印 Print: function () { _this = this; if (this.storeList.getCount() == 0) { return; } // var sql = this.sqlcontext // var sortstr = ' B.BSNO DESC'; if (this.bslistsortfield != '' && this.bslistsortdire != '') { sortstr = this.bslistsortfield + ' ' + this.bslistsortdire; } // Ext.Msg.wait('正在组织数据, 请稍侯..'); Ext.Ajax.request({ waitMsg: '正在组织数据...', url: '/MvcShipping/MsRptSaleJieSuanTiCheng/GetDsDataList', scope: this, params: { start: 0, limit: this.PageSize, condition: sql, sortstr: sortstr, printstr: 'true' }, callback: function (options, success, response) { if (success) { Ext.MessageBox.hide(); var jsonresult = Ext.JSON.decode(response.responseText); if (jsonresult.Success) { var returnstr = jsonresult.data; var printType = 'MsRptDsSaleJieSuanTiChengList'; 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 }); } } }); }, //#endregion OprationSwap: function () { var ret = new Array(); ret[0] = this.OprationStatus; ret[1] = this.storeList; ret[2] = this.SelectedRecord; ret[3] = this.SelectedRecord.data.BSNO; ret[4] = "MsRptOpProfitIndex"; return ret; } });