//集运管理-路单查询 Ext.namespace('DsTruck'); DsTruck.ChfeeListIndex = function (config) { Ext.applyIf(this, config); this.initUIComponents(); window.DsTruck.ChfeeListIndex.superclass.constructor.call(this); }; //201403060002 //13号 Ext.extend(DsTruck.ChfeeListIndex, Ext.Panel, { PageSize: 500, OprationStatus: null, //仅当弹出界面时使用 SelectedRecord: null, initUIComponents: function () { //定义数据集 this.storeList = Ext.create('Ext.data.Store', { pageSize: this.PageSize, idProperty: 'GId', fields: [ { name: 'GId', type: 'string' }, { name: 'BSNO', type: 'string' }, { name: 'FeeStatus', type: 'string' }, { name: 'FeeStatus_Ref', type: 'string' }, { name: 'FeeName_Ref', type: 'string' }, { name: 'FeeType_Ref', type: 'string' }, { name: 'BXGID', type: 'string' }, { name: 'EnterDate', type: 'string' }, { name: 'CustomerName_Ref', type: 'string' }, { name: 'Unit', type: 'string' }, { name: 'UnitPrice', type: 'string' }, { name: 'Quantity', type: 'string' }, { name: 'Amount_YS', type: 'string' }, { name: 'Amount_YF', type: 'string' }, { name: 'Amount_RMBYS', type: 'string' }, { name: 'Amount_RMBYF', type: 'string' }, { name: 'Currency', type: 'string' }, { name: 'ExChangerate', type: 'string' }, { name: 'Remark', type: 'string' }, { name: 'MBLNO', type: 'string' }, { name: 'buyer', type: 'string' }, { name: 'Vessel', type: 'string' }, { name: 'Voyage', type: 'string' }, { name: 'CreateUser', type: 'string' }, { name: 'AC', type: 'string' }, { name: 'AD', type: 'string' }, { name: 'CR', type: 'string' }, { name: 'DR', type: 'string' }, { name: 'ACCDATE', type: 'string' }, { name: 'ISVOU', type: 'string' }, { name: 'VOUCHERNO', type: 'string' }, { name: 'VOUNO', type: 'string' }, { name: 'AUDITOPERATOR', type: 'string' }, { name: 'AUDITDATE', type: 'string' } ], remoteSort: false, proxy: { type: 'ajax', url: '/OA/ChfeeList/GetDataList', reader: { id: 'Id', root: 'data', totalProperty: 'totalCount' } } }); Ext.define('Tradermb', { extend: 'Ext.data.Model', idProperty: 'gid', fields: [ { name: 'gid', type: 'string' }, { name: 'name', type: 'string' }, { name: 'codename', type: 'string' } ] }); this.formname = "ChfeeList"; this.storeMainstate = Ext.create('DsExt.ux.RefEnumStore', {}); this.storeMainstate.load({ params: { enumTypeId: 3} }); this.comboxMainstate = Ext.create('DsExt.ux.RefEnumCombox', { fieldLabel: '合同状态', store: this.storeMainstate, name: 'Mainstate' }); this.storeFeetype = Ext.create('DsExt.ux.RefEnumStore', {}); this.storeFeetype.load({ params: { enumTypeId: 22} }); this.comboxFeetype = Ext.create('DsExt.ux.RefEnumCombox', { fieldLabel: '收付方向', store: this.storeFeetype, name: 'Feetype' }); this.storeFeeName = Ext.create('DsExt.ux.RefTableStore', { model: 'DsTruckMng.ux.FeeTypeRefModel', proxy: { url: '/CommMng/BasicDataRef/GetFeeTypeRefList' } }); this.storeFeeName.load({ params: { condition: ""} }); this.comboxFeeName = Ext.create('Ext.ux.form.field.BoxSelect', { fieldLabel: '费用名称', //renderTo: 'basicBoxselect',height:60,pinList: false, //autoHeight:true,width: 500,stacked: true, autosize: true, bodyPadding: 7, flex: 1, labelWidth: 90, store: this.storeFeeName, queryMode: 'local', triggerOnClick: false, valueField: 'Name', displayField: 'CodeAndName' }); this.storeFeestatus = Ext.create('DsExt.ux.RefEnumStore', {}); this.storeFeestatus.load({ params: { enumTypeId: 99024} }); this.comboxFeestatus = Ext.create('Ext.ux.form.field.BoxSelect', { fieldLabel: '费用状态', autosize: true, bodyPadding: 7, flex: 1, labelWidth: 90, store: this.storeFeestatus, queryMode: 'local', triggerOnClick: false, valueField: 'EnumValueId', displayField: 'EnumValueName' }); this.storeCustomer = Ext.create('DsExt.ux.RefTableStore', { model: 'Tradermb', proxy: { url: '/CommMng/BasicDataRef/GetTrader' } }); this.storeCustomer.load({ params: { condition: " 1=1 "} }); this.comboxCustomer = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '结算对象', store: this.storeCustomer, name: 'Customer', valueField: 'name', displayField: 'codename', flex: 1 }); this.column = [{ sortable: true, dataIndex: '', header: '', width: 120 },{ sortable: true, dataIndex: 'GId', header: 'GId', width: 80 }, { sortable: true, dataIndex: 'BSNO', header: 'BSNO', width: 80 }, { sortable: true, dataIndex: 'FeeStatus', header: 'FeeStatus', width: 80 }, { sortable: true, dataIndex: 'FeeStatus_Ref', header: '费用状态', width: 80 }, { sortable: true, dataIndex: 'FeeName_Ref', header: '费用名称', width: 80 }, { sortable: true, dataIndex: 'FeeType_Ref', header: '收付类型', width: 80 }, { sortable: true, dataIndex: 'BXGID', header: '报销单号', width: 80 }, { sortable: true, dataIndex: 'EnterDate', header: '录入时间', width: 80 }, { sortable: true, dataIndex: 'CustomerName_Ref', header: '结算对象', width: 80 }, { sortable: true, dataIndex: 'Unit', header: '单位', width: 80 }, { sortable: true, dataIndex: 'UnitPrice', header: '单价', width: 80, 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; } }, { sortable: true, dataIndex: 'Quantity', header: '数量', width: 80 }, { sortable: true, dataIndex: 'Amount_YS', header: '应收', width: 80, 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; } }, { sortable: true, dataIndex: 'Amount_YF', header: '应付', width: 80, 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; } }, { sortable: true, dataIndex: 'Amount_RMBYS', header: 'RMB应收', width: 80, 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; } }, { sortable: true, dataIndex: 'Amount_RMBYF', header: 'RMB应付', width: 80, 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; } }, { sortable: true, dataIndex: 'Currency', header: '币别', width: 80 }, { sortable: true, dataIndex: 'ExChangerate', header: '汇率', width: 80 }, { sortable: true, dataIndex: 'Remark', header: '备注', width: 80 }, { sortable: true, dataIndex: 'MBLNO', header: '主提单号', width: 80 }, { sortable: true, dataIndex: 'buyer', header: '客户', width: 80 }, { sortable: true, dataIndex: 'Vessel', header: '船名', width: 80 }, { sortable: true, dataIndex: 'Voyage', header: '航次', width: 80 }, { sortable: true, dataIndex: 'CreateUser', header: '录入人', width: 80 }, { sortable: true, dataIndex: 'AC', header: '付费申请', width: 80, 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; } }, { sortable: true, dataIndex: 'AD', header: '收费申请', width: 80, 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; } }, { sortable: true, dataIndex: 'CR', header: '付费结算', width: 80, 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; } }, { sortable: true, dataIndex: 'DR', header: '收费结算', width: 80, 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; } }, { sortable: true, dataIndex: 'ACCDATE', header: '会计期间', width: 80 }, { sortable: true, dataIndex: 'ISVOU', header: '是否已生成凭证', width: 80 }, { sortable: true, dataIndex: 'VOUCHERNO', header: '应收应付凭证号', width: 80 }, { sortable: true, dataIndex: 'VOUNO', header: '结算凭证号', width: 80 }, { sortable: true, dataIndex: 'AUDITOPERATOR', header: '审核人', width: 80 }, { sortable: true, dataIndex: 'AUDITDATE', header: '审核时间', width: 80 }]; this.FeeCBModel = Ext.create('Ext.selection.CheckboxModel', { checkOnly: true }); //定义Grid this.gridList = new Ext.grid.GridPanel({ store: this.storeList, enableHdMenu: false, region: 'center', loadMask: { msg: "数据加载中,请稍等..." }, trackMouseOver: true, disableSelection: false, stripeRows: true, viewConfig: { enableTextSelection: true, autoFill: true, getRowClass: function (record, rowIndex, rowParams, store) { var feeStatus = record.get('FeeStatus'); return DsTruck.MsChFeeGetRowClass(feeStatus); } }, stateful: false, selModel: this.FeeCBModel, columns: [new Ext.grid.RowNumberer()], // paging bar on the bottom bbar: Ext.create('Ext.PagingToolbar', { store: this.storeList, displayInfo: true, displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录', emptyMsg: "没有数据" }) }); /////////////以下部分为获取存储的gridpanel显示样式 this.column = DsTruck.GetGridPanel(GID, this.formname, this.column, 1); //使用者id,表名 ,中间column数组,跳过一开始的几列 this.gridList.reconfigure(this.storeList, this.column); this.gridList.columns[0] = new Ext.grid.RowNumberer(); //////////////////////////// //#region formSearch //#region formSearch枚举参照相关 //#endregion this.storeBuyer = Ext.create('DsExt.ux.RefTableStore', { model: 'Tradermb', proxy: { url: '/CommMng/BasicDataRef/GetTrader' } }); this.storeBuyer.load({ params: { condition: " isagentcn=1 "} }); this.comboxBuyer = Ext.create('Ext.ux.form.field.BoxSelect', { fieldLabel: '客户', //renderTo: 'basicBoxselect',height:60,pinList: false, //autoHeight:true,width: 500,stacked: true, autosize: true, bodyPadding: 7, flex: 2, labelWidth: 90, store: this.storeBuyer, queryMode: 'local', triggerOnClick: false, valueField: 'name', displayField: 'codename' }); this.storeUser = Ext.create('DsExt.ux.RefTableStore', { model: 'DsTruckMng.ux.UserRefModel', proxy: { url: '/CommMng/BasicDataRef/GetUserRefList' } }); this.storeUser.load({ params: { condition: ""} }); this.comboxOP = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '操作人', //forceSelection: true, store: this.storeUser, name: 'OP', valueField: 'UserName', displayField: 'CodeAndName' }); this.formSearch = Ext.widget('form', { frame: true, region: 'center', bodyPadding: 5, 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: [this.comboxport, this.comboxFeetype, this.comboxOP, { fieldLabel: '从费用日期', format: 'Y-m-d', xtype: 'datefield', name: 'EnterDate_min' }, { fieldLabel: '到费用日期', format: 'Y-m-d', xtype: 'datefield', name: 'EnterDate_max' } ] } ]//end items(fieldset 1) }, //end fieldset 1 {//fieldset 2 xtype: 'container', defaultType: 'textfield', layout: 'anchor', defaults: { anchor: '100%' }, items: [{ xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [this.comboxCustomer, this.comboxFeeName, { fieldLabel: '合同号', name: 'HTH', flex: 1 }, { fieldLabel: '备注中包含', name: 'ReMark', flex: 2 } ] } ]//end items(fieldset 2) }//end fieldset 2 , {//----------- xtype: 'container', defaultType: 'textfield', layout: 'anchor', defaults: { anchor: '100%' }, items: [{ xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: '申请单号/结算单号', name: 'DH', flex: 2 }, { fieldLabel: '应收应付凭证号', name: 'VOUCHERNO', flex: 2 }, { fieldLabel: '结算凭证号', name: 'VOUNO', flex: 2 } ] } ]//end items(fieldset 2) }//--------------------- , {//fieldset 2 xtype: 'container', defaultType: 'textfield', layout: 'anchor', defaults: { anchor: '100%' }, items: [{ xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [this.comboxBuyer ] } ]//end items(fieldset 2) }//end fieldset 2 , {//----------- xtype: 'container', defaultType: 'textfield', layout: 'anchor', defaults: { anchor: '100%' }, items: [{ xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [this.comboxFeestatus ] } ]//end items(fieldset 2) }//--------------------- ]//end root items }); //#endregion formSearch var menu1 = new Ext.menu.Menu({ id: 'basicMenu', items: [{ text: '收款通知单', handler: clickHandler_SK }, { text: '付款通知单', handler: clickHandler_FK }] }); function clickHandler_SK() { window.pnlRptImportFeedetailIndex.Print_SK(); }; function clickHandler_FK() { window.pnlRptImportFeedetailIndex.Print_FK(); }; //查询工具条 this.panelBtn = new Ext.Panel({ region: "north", tbar: [ { text: "执行查询", iconCls: "btnrefresh", handler: function (button, event) { this.onRefreshClick(button, event); }, scope: this }, { text: "导出Excel", id: "btnExportExcel", iconCls: 'btnexportexcel', handler: function (button, event) { this.onExportClick(button, event); }, scope: this }, { text: "保存列表样式", id: "btntest", handler: function (button, event) { this.column = DsTruck.SaveGridPanel(GID, this.formname, this.gridList.columns, this.column, 1, true); //alert(this.column[0].id); }, scope: this }, { text: "打印报表", menu: menu1, scope: this } ] }); this.panelTop = new Ext.Panel({ layout: "border", region: "north", height: 185, items: [this.formSearch, this.panelBtn] }); Ext.apply(this, { items: [this.panelTop, this.gridList] }); this.storeList.on('beforeload', function (store) { if (!this.checkSearchCondition()) return; var sql = this.getCondition(); if (sql != "false") { Ext.apply(store.proxy.extraParams, { condition: sql }); } }, this); }, //end initUIComponents onRefreshClick: function (button, event) { if (!this.checkSearchCondition()) return; var sql = this.getCondition(); if (sql != "false") { this.storeList.load({ params: { start: 0, limit: this.PageSize, condition: sql }, waitMsg: "正在查询数据...", scope: this }); } }, getCondition: function () { var form = this.formSearch.getForm(); if (!form.isValid()) { Ext.Msg.alert('提示', '查询条件赋值错误,请检查。'); return ''; } var sql = ''; var Customer = form.findField('Customer').getValue(); sql = sql + getAndConSql(sql, Customer, "f.CustomerName like '%" + Customer + "%'"); var Feetype = form.findField('Feetype').getValue(); sql = sql + getAndConSql(sql, Feetype, "f.Feetype = " + Feetype); //var port = form.findField('port').getValue(); //sql = sql + getAndConSql(sql, port, "M.port = " + port); var EnterDate_min = form.findField('EnterDate_min').getRawValue(); sql = sql + getAndConSql(sql, EnterDate_min, "f.EnterDate >= '" + EnterDate_min + "'"); var EnterDate_max = form.findField('EnterDate_max').getRawValue(); sql = sql + getAndConSql(sql, EnterDate_max, "f.EnterDate <= '" + EnterDate_max + " 23:59:59'"); //var HTH = form.findField('HTH').getValue(); //sql = sql + getAndConSql(sql, HTH, "M.HTH like '%" + HTH + "%'"); /* var FeeType = form.findField('FeeType').getValue(); sql = sql + getAndConSql(sql, FeeType, "f.FeeType = " + FeeType); */ var FeeName = this.getStrValue(this.comboxFeeName.getValue()); sql = sql + getAndConSql(sql, FeeName, "f.FeeName in (" + FeeName + ")"); var FeeStatus = this.getStrValue(this.comboxFeestatus.getValue()); sql = sql + getAndConSql(sql, FeeStatus, "f.FeeStatus in (" + FeeStatus + ")"); //var OP = form.findField('OP').getValue(); //sql = sql + getAndConSql(sql, OP, "M.OP = '" + OP + "'"); var DH = form.findField('DH').getValue();//结算单号/申请单号 sql = sql + getAndConSql(sql, DH, "f.gid in ( select distinct feeid from ch_fee_do where billno like '%" + DH + "%')"); var VOUCHERNO = form.findField('VOUCHERNO').getValue(); //应收应付凭证 sql = sql + getAndConSql(sql, VOUCHERNO, "f.voucherno like '%" + VOUCHERNO + "%'"); var VOUNO = form.findField('VOUNO').getValue(); //结算凭证 sql = sql + getAndConSql(sql, VOUNO, "f.gid in ( select feeid from ch_fee_do where billno in( select billno from ch_fee_settlement where VOUNO like '%" + VOUNO + "%') )"); if (sql == '') { alert("无限定条件的查询会等待超长时间并返回大量结果。请至少设定一个条件。"); return "false"; }; return sql; }, checkSearchCondition: function () { var form = this.formSearch.getForm(); if (!form.isValid()) { Ext.Msg.alert('提示', '查询条件赋值错误,请检查。'); return false; } return true; }, onExportClick: function (button, event) { GridExportExcelPage(this.gridList); }, getStrValue: function (list) { var _list = []; for (var _i = 0; _i < list.length; _i++) { _list.push("'" + list[_i] + "'"); } return _list; }, Print_SK: function () { //alert("print"); var selectedRecords = this.gridList.selModel.getSelection(); var FEEGID = ""; var CUSTOMERNAME = []; for (var i = 0; i < selectedRecords.length; i++) { var rec = selectedRecords[i]; if (rec.get('FeeType_Ref') == "应收" && rec.get('FeeStatus') == '0') { if (FEEGID == "") { FEEGID = FEEGID + "'" + rec.get('GId') + "'"; } else { FEEGID = FEEGID + ",'" + rec.get('GId') + "'"; } if (CUSTOMERNAME[0] != rec.get('CustomerName_Ref')) { CUSTOMERNAME.push(rec.get('CustomerName_Ref')); } } } /* if (CUSTOMERNAME.length > 1) { alert("") }*/ function GetDateStr(AddDayCount) { var dd = new Date(); dd.setDate(dd.getDate() + AddDayCount); //获取AddDayCount天后的日期 var y = dd.getFullYear(); var m = dd.getMonth() + 1; //获取当前月份的日期 var d = dd.getDate(); return y + "-" + m + "-" + d; } //alert(GetDateStr(+5)); var madedate = GetDateStr(0); var printType = 'RptFee_TZD_SK'; //收款通知单 var sql1 = " select m.hth,m.billno,cf.feename,cf.amount,cf.currency from ch_fee cf "; var sql1 = sql1 + " left join import_main m on m.contractno=cf.bsno "; var sql1 = sql1 + " where cf.gid in( " + FEEGID + ")"; //var sql1 = sql1 + T; //var sql1 = sql1 + " go "; var sql2 = ""; var sql3 = "select '" + madedate + "' as madedate,'" + CUSTOMERNAME[0] + "' as CUSTOMERNAME,'" + SHOWNAME + "' as SHOWNAME"; var sql4 = ""; var sql5 = ""; var sql6 = ""; PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6); }, Print_FK: function () { //alert("print"); var selectedRecords = this.gridList.selModel.getSelection(); var FEEGID = ""; var CUSTOMERNAME = []; for (var i = 0; i < selectedRecords.length; i++) { var rec = selectedRecords[i]; if (rec.get('FeeType_Ref') == "应付" && rec.get('FeeStatus') == '2') { if (FEEGID == "") { FEEGID = FEEGID + "'" + rec.get('GId') + "'"; } else { FEEGID = FEEGID + ",'" + rec.get('GId') + "'"; } if (CUSTOMERNAME[0] != rec.get('CustomerName_Ref')) { CUSTOMERNAME.push(rec.get('CustomerName_Ref')); } } } if (CUSTOMERNAME.length > 1) { alert("只能有一个结算对象"); return; } function GetDateStr(AddDayCount) { var dd = new Date(); dd.setDate(dd.getDate() + AddDayCount); //获取AddDayCount天后的日期 var y = dd.getFullYear(); var m = dd.getMonth() + 1; //获取当前月份的日期 var d = dd.getDate(); return y + "-" + m + "-" + d; } //alert(GetDateStr(+5)); var madedate = GetDateStr(0); var printType = 'RptFee_TZD_FK'; //付款通知单 var sql1 = " select m.hth,m.billno,cf.feename,cf.amount,cf.currency,m.buyer,(select name from company c where c.gid=m.company) company from ch_fee cf "; var sql1 = sql1 + " left join import_main m on m.contractno=cf.bsno "; var sql1 = sql1 + " where cf.gid in( " + FEEGID + " )"; //var sql1 = sql1 + T; //var sql1 = sql1 + " go "; var sql2 = ""; var sql3 = "select '" + madedate + "' as madedate,'" + CUSTOMERNAME[0] + "' as CUSTOMERNAME,'" + SHOWNAME + "' as SHOWNAME"; var sql4 = ""; var sql5 = ""; var sql6 = ""; PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6); } });