Ext.namespace('Shipping');
Shipping.MsChFeeYsAutoDuiIndex = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.MsChFeeYsAutoDuiIndex.superclass.constructor.call(this);
};
var sqlParms = '';
var selCustName = '';
Ext.extend(Shipping.MsChFeeYsAutoDuiIndex, Ext.Panel, {
PageSize: 200,
OprationStatus: null, //仅当弹出界面时使用
SelectedRecord: null,
selectbsnostr: '',
selectfeestr: '',
sqlcontext: '',
_thisfee:null,
initUIComponents: function () {
this.formname = 'MsChFeeYsDuiIndex';
//#region 下载窗体
this.formDownloadShow = Ext.widget('form', {
frame: true,
region: 'center',
height: 150,
autoScroll: true,
bodyPadding: 5,
fieldDefaults: {
margins: '2 2 2 2',
labelAlign: 'right',
flex: 1,
labelWidth: 90,
msgTarget: 'qtip'
},
items: [{
xtype: 'container',
defaultType: 'textfield',
layout: 'anchor',
id: 'downloadfile',
defaults: {
anchor: '100%'
},
items: [{
xtype: 'label',
html: '',
width: 120,
text: ''
}]
}]
});
me = this;
this.winDownloadShow = Ext.create('Ext.window.Window', {
title: "下载文件",
width: 450,
height: 150,
//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.formDownloadShow],
buttons: [{
text: "关闭",
minWidth: 70,
handler: function () {
me.winDownloadShow.close();
}
}]
});
//#endregion
//定义数据集
this.storeList = Ext.create('Ext.data.Store', {
model: 'MsChFeeYsAutoDui',
pageSize: this.PageSize,
remoteSort: true,
proxy: {
type: 'ajax',
url: '/MvcShipping/MsChFeeYsAutoDui/GetDataList',
reader: {
id: 'DUINO',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.initgirdcolums = [
{
sortable: true,
dataIndex: 'DuiZhangBianHao',
header: '对账编号',
width: 120
},
{
sortable: true,
dataIndex: 'KeHuJianCheng',
header: '客户简称',
width: 160
}, {
sortable: true,
dataIndex: 'KeHuQuanCheng',
header: '客户全称',
width: 160
}, {
sortable: true,
dataIndex: 'LanHuoRen',
header: '揽货人',
width: 60
}, {
sortable: true,
dataIndex: 'YingShouRMB',
header: '应收RMB',
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: 'YingShouUSD',
header: '应收USD',
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: 'YingFuRMB',
header: '应付RMB',
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: 'YingFuUSD',
header: '应付USD',
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: 'DuiZhangLianXiRen',
header: '对账联系人',
width: 80
}, {
sortable: true,
dataIndex: 'DuiZhangLianXiYouXiang',
header: '对账联系邮箱',
width: 120
}, {
sortable: true,
dataIndex: 'DuiZhangLianXiDianHua',
header: '对账联系电话',
width: 120
}, {
sortable: true,
dataIndex: 'DuiZhangBeiZhu',
header: '对账备注',
width: 120
}, {
sortable: true,
dataIndex: 'DuiZhangRiQi',
header: '对账日期',
width: 120
},
{
sortable: true,
dataIndex: 'JieFeiLeiXing',
header: '结费类型',
width: 60
}
// , {
// sortable: true,
// dataIndex: 'YiJieSuan',
// header: '已结算',
// width: 80
// }, {
// sortable: true,
// dataIndex: 'ZhangQi',
// header: '账期',
// width: 80
// }, {
// sortable: true,
// dataIndex: 'YingJieRiQi',
// header: '应结日期',
// width: 120
// }
];
this.girdcolums = this.initgirdcolums;
this.GridCheckBoxModel = Ext.create('Ext.selection.CheckboxModel');
//定义Grid
this.Pagenum = Ext.create('Ext.form.field.Number', {
name: 'bottles',
fieldLabel: Zi.LAN.NumberOfpage, //每页记录数
labelAlign: 'right',
value: this.PageSize,
maxValue: 100000,
width: 180,
minValue: 0,
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
});
this.gridList = new Ext.grid.GridPanel({
store: this.storeList,
enableHdMenu: false,
region: 'center',
loadMask: { msg: Zi.LAN.LoadData }, //数据加载中,请稍等...
trackMouseOver: true,
disableSelection: false,
columns: this.girdcolums,
selModel: this.GridCheckBoxModel,
viewConfig: {
autoFill: true,
enableTextSelection: true, //允许复制数据
getRowClass: function (record, rowIndex, rowParams, store) {
var BILLSTATUSREF = record.get('BILLSTATUSREF');
if (BILLSTATUSREF == "锁定")
return 'feestatus_refer';
}
},
// paging bar on the bottom
bbar: [Ext.create('Ext.PagingToolbar', {
store: this.storeList,
displayInfo: true,
displayMsg: Zi.LAN.FenYe, //当前显示 {0} - {1}条记录 /共 {2}条记录
emptyMsg: Zi.LAN.Nodata//没有数据
}), this.Pagenum]
});
this.girdcolums = DsTruck.GetGridPanel(USERID, this.formname, this.girdcolums, 1); //使用者id,表名,中间column数组,跳过一开始的几列
this.gridList.reconfigure(this.storeList, this.girdcolums);
this.gridList.addListener('itemdblclick', function (dataview, record, item, index, e, b) {
this.SelectedRecord = record;
this.OprationStatus = 'edit';
sqlParms = this.getCondition('1');
selCustName = record.data.KeHuJianCheng;
DsOpenEditWin('/MvcShipping/MsChFeeYsAutoDui/Edit', "自动对账明细");
}, this);
//#region formSearch
//客户加载_委托单位
this.storeCustCode = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CustomRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetCustomRefListRm' }
});
// this.storeCustCode.load({ params: { condition: ""} });
//委托单位
this.comboxDuiZhangKeHu = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: Zi.LAN.duizkehu, //对账客户
store: this.storeCustCode,
forceSelection: true,
name: 'DuiZhangKeHu',
queryMode: 'remote',
minChars: 0,
queryParam: 'CODENAME',
valueField: 'CustName',
displayField: 'CodeAndName',
enableKeyEvents: true,
listeners: {
//specialkey: function (field, e) {
keyup: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
});
//#endregion
//#region 收付方向
this.storeShouFuFangXiang = Ext.create('Ext.data.Store', {
fields: ['DC', 'NAME']
});
this.storeShouFuFangXiang.add({ "DC": "", "NAME": "全部" });
this.storeShouFuFangXiang.add({ "DC": "1", "NAME": "应收" });
this.storeShouFuFangXiang.add({ "DC": "2", "NAME": "应付" });
this.comboxShouFuFangXiang = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: "收付方向",
store: this.storeShouFuFangXiang,
valueField: 'DC',
displayField: 'NAME',
flex: 0.6,
forceSelection: true,
name: 'DC'
});
//#endregion
//#region 结费类型
this.storeJieFeiLeiXing = Ext.create('Ext.data.Store', {
fields: ['DC', 'NAME']
});
this.storeJieFeiLeiXing.add({ "DC": "", "NAME": "全部" });
this.storeJieFeiLeiXing.add({ "DC": "1", "NAME": "月结" });
this.storeJieFeiLeiXing.add({ "DC": "2", "NAME": "票结" });
this.comboxJieFeiLeiXing = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: "结费类型",
store: this.storeJieFeiLeiXing,
valueField: 'NAME',
displayField: 'NAME',
flex: 0.6,
forceSelection: true,
name: 'JF'
});
//#endregion
//#region 是否已开票
this.storeKaiPiao = Ext.create('Ext.data.Store', {
fields: ['DC', 'NAME']
});
this.storeKaiPiao.add({ "DC": "", "NAME": "全部" });
this.storeKaiPiao.add({ "DC": "1", "NAME": "是" });
this.storeKaiPiao.add({ "DC": "2", "NAME": "否" });
this.comboxKaiPiao = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: "是否已开票",
store: this.storeKaiPiao,
valueField: 'DC',
displayField: 'NAME',
flex: 0.6,
forceSelection: true,
name: 'KP'
});
//#endregion
_this = this;
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: [{
fieldLabel: '开船日(从)', //到对账日期
format: 'Y-m-d',
xtype: 'datefield',
name: 'ETDFROM'
}, {
fieldLabel: '开船日(到)', //到对账日期
format: 'Y-m-d',
xtype: 'datefield',
name: 'ETDTO'
}, this.comboxDuiZhangKeHu, this.comboxShouFuFangXiang, this.comboxJieFeiLeiXing, this.comboxKaiPiao, {
xtype: 'button',
text: '生成预对账单', //执行查询
iconCls: "btnrefresh",
handler: function (button, event) {
this.onCreateDui(button, event);
},
scope: this
}
, {
xtype: 'button',
text: '发送对账单', //执行查询
iconCls: "btnrefresh",
handler: function (button, event) {
this.onSendDui(button, event);
},
scope: this
}, {
xtype: 'button',
text: '导出对账单', //执行查询
iconCls: "btnrefresh",
handler: function (button, event) {
this.onExportDui(button, event);
},
scope: this
}
]
}
]//end items(fieldset 1)
}//end fieldset 1
]//end root items
});
//#endregion formSearch
//查询工具条
_this = this;
this.panelBtn = new Ext.Panel({
region: "north",
tbar: [
{
text: Zi.LAN.ExecuteQuery, //执行查询
iconCls: "btnrefresh",
handler: function (button, event) {
this.onRefreshClick(button, event);
},
scope: this
},
{
text: Zi.LAN.ResetCondition, //重置条件
iconCls: "btnreset",
handler: function (button, event) {
this.onClearSql(button, event);
},
scope: this
},
{
text: '发送',
id: 'btnSend',
handler: function (button, event) {
alert('fasong');
},
scope: this
}, '-', {
text: Zi.LAN.Saveliststyle, //保存列表样式
id: "btntest",
menu: [
{ text: Zi.LAN.Save, //保存
handler: function (button, event) {
this.girdcolums = DsTruck.SaveGridPanel(USERID, _this.formname, _this.gridList.columns, _this.girdcolums, 1, true);
}
}, { text: Zi.LAN.Initialization,
handler: function (menu, event) {
_this.InitGrid(_this.initgirdcolums);
_this.girdcolums = DsTruck.SaveGridPanel(USERID, _this.formname, _this.gridList.columns, _this.initgirdcolums, 1, true);
}
}],
scope: this
}
]
});
this.panelTop = new Ext.Panel({
layout: "border",
region: "north",
height: 100,
items: [this.formSearch, this.panelBtn]
});
Ext.apply(this, {
items: [this.panelTop, this.gridList]
});
this.storeList.on('beforeload', function (store) {
var sql = this.sqlcontext;
Ext.apply(store.proxy.extraParams, { condition: sql });
}, this);
}, //end initUIComponents
InitGrid: function (grid) {
var agirdcolums = grid;
this.gridList.reconfigure(this.storeList, agirdcolums);
},
onClearSql: function () {
var form = this.formSearch.getForm();
form.reset();
}, //onDeleteClick
onRefreshClick: function (button, event) {
var sql = this.getCondition();
this.sqlcontext = sql;
this.PageSize = this.Pagenum.getValue();
this.storeList.pageSize = this.PageSize;
this.storeList.load({
params: { start: 0, limit: this.PageSize, sort: '', condition: sql },
waitMsg: Zi.LAN.NowSelect, //正在查询数据...
scope: this
});
},
onCreateDui: function (button, event) {
var sql = this.getCondition('1');
this.sqlcontext = sql;
this.PageSize = this.Pagenum.getValue();
this.storeList.pageSize = this.PageSize;
this.storeList.load({
params: { start: 0, limit: this.PageSize, sort: '', condition: sql },
waitMsg: Zi.LAN.NowSelect, //正在查询数据...
scope: this
});
},
onSendDui: 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 selectedRecords = [];
selectedRecords = this.gridList.selModel.getSelection();
var selectStores = [];
for (var i = 0; i < selectedRecords.length; i++) {
selectStores.push(selectedRecords[i].data);
}
var sql = this.getCondition('2');
Ext.MessageBox.confirm('提示', '确定发送对账单吗?', function (btn) {
if (btn == 'yes') {
Ext.Msg.wait('正在发送...');
Ext.Ajax.request({
waitMsg: '正在发送...',
url: '/MvcShipping/MsChFeeYsAutoDui/SendExcel',
params: {
data: Ext.JSON.encode(selectStores),
condition: sql
},
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
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);
//InitData();
},
onExportDui: 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 selectedRecords = [];
selectedRecords = this.gridList.selModel.getSelection();
var selectStores = [];
for (var i = 0; i < selectedRecords.length; i++) {
selectStores.push(selectedRecords[i].data);
}
var sql = this.getCondition('2');
Ext.MessageBox.confirm('提示', '确定导出数据?', function (btn) {
if (btn == 'yes') {
Ext.Msg.wait('正在生成...');
Ext.Ajax.request({
waitMsg: '正在生成...',
url: '/MvcShipping/MsChFeeYsAutoDui/GetExcel',
params: {
data: Ext.JSON.encode(selectStores),
condition: sql
},
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
var downloadfile = Ext.getCmp('downloadfile');
var children = downloadfile.items;
if (children) {
for (var i = 0, len = children.length; i < len; i++) {
downloadfile.remove(children.items[i], true);
}
}
var downloadfiles = jsonresult.data;
var htmla = Ext.widget('label', { html: downloadfiles, width: 120, text: '' });
downloadfile.items.add(htmla);
this.winDownloadShow.show();
//
Ext.Msg.hide();
}
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);
//InitData();
},
getCondition: function (type) {
//生成对账单
if (type == '1') {
var form = this.formSearch.getForm();
var sql = " and C.ISDEBIT = 0";
var DuiZhangKeHu = form.findField('DuiZhangKeHu').getValue();
if (DuiZhangKeHu != "" && DuiZhangKeHu != null) {
sql = sql + getAndConSql(sql, DuiZhangKeHu, "C.CUSTOMERNAME = '" + DuiZhangKeHu + "'");
}
var ETDFROM = form.findField('ETDFROM').getRawValue();
if (ETDFROM != "" && ETDFROM != null) {
sql = sql + getAndConSql(sql, ETDFROM, "ETD >='" + ETDFROM + "'");
}
var ETDTO = form.findField('ETDTO').getRawValue();
if (ETDTO != "" && ETDTO != null) {
sql = sql + getAndConSql(sql, ETDTO, "ETD <='" + ETDTO + "'");
}
var SHOUFU = form.findField('DC').getValue();
if (SHOUFU != "" && SHOUFU != null) {
sql = sql + getAndConSql(sql, SHOUFU, "C.FEETYPE = " + SHOUFU + "");
}
var JIEFEI = form.findField('JF').getValue();
if (JIEFEI != "全部" && JIEFEI != "" && JIEFEI != null) {
sql = sql + getAndConSql(sql, JIEFEI, "ICA.ACCTYPE = '" + JIEFEI + "'");
}
var KP = form.findField('KP').getValue();
if (KP != "全部" && KP != "" && KP != null) {
if (KP == "1") {
sql = sql + getAndConSql(sql, KP, " (C.INVOICE <> 0 or C.ORDERINVOICE <>0)");
} else if (KP == "2") {
sql = sql + getAndConSql(sql, KP, " (C.INVOICE = 0 and C.ORDERINVOICE =0)");
}
}
return sql;
}
//发送excel
if (type == '2') {
var form = this.formSearch.getForm();
var sql = " and C.ISDEBIT = 0";
var ETDFROM = form.findField('ETDFROM').getRawValue();
if (ETDFROM != "" && ETDFROM != null) {
sql = sql + getAndConSql(sql, ETDFROM, "ETD >='" + ETDFROM + "'");
}
var ETDTO = form.findField('ETDTO').getRawValue();
if (ETDTO != "" && ETDTO != null) {
sql = sql + getAndConSql(sql, ETDTO, "ETD <='" + ETDTO + "'");
}
var SHOUFU = form.findField('DC').getValue();
if (SHOUFU != "" && SHOUFU != null) {
sql = sql + getAndConSql(sql, SHOUFU, "C.FEETYPE = " + SHOUFU + "");
}
var JIEFEI = form.findField('JF').getValue();
if (JIEFEI != "全部" && JIEFEI != "" && JIEFEI != null) {
sql = sql + getAndConSql(sql, JIEFEI, "ICA.ACCTYPE = '" + JIEFEI + "'");
}
var KP = form.findField('KP').getValue();
if (KP != "全部" && KP != "" && KP != null) {
if (KP == "1") {
sql = sql + getAndConSql(sql, KP, " (C.INVOICE <> 0 or C.ORDERINVOICE <>0)");
} else if (KP == "2") {
sql = sql + getAndConSql(sql, KP, " (C.INVOICE = 0 and C.ORDERINVOICE =0)");
}
}
return sql;
}
},
OprationSwap: function () {
var ret = new Array();
ret[0] = this.OprationStatus;
ret[1] = this.storeList;
ret[2] = this.SelectedRecord;
ret[3] = this.SelectedRecord;
ret[4] = this.selectbsnostr;
ret[5] = this.selectfeestr;
return ret;
}
});