You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
DS7/DSWeb/Areas/MvcShipping/Viewsjs/MsOpExpress/MsOpExpressIndex.js

622 lines
22 KiB
JavaScript

2 years ago
Ext.namespace('Shipping');
Shipping.MsOpExpressIndex = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.MsOpExpressIndex.superclass.constructor.call(this);
};
Ext.extend(Shipping.MsOpExpressIndex, Ext.Panel, {
PageSize: 100,
OprationStatus: null, //仅当弹出界面时使用
SelectedRecord: null,
initUIComponents: function () {
//定义数据集
this.storeList = Ext.create('Ext.data.Store', {
pageSize: this.PageSize,
model: 'MsOpExpress',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/MvcShipping/MsOpExpress/GetDataList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.GridCheckBoxModel = Ext.create('Ext.selection.CheckboxModel');
2 years ago
this.girdcolums = [{
sortable: true,
dataIndex: 'GID',
header: 'GID',
hidden: true,
width: 160
}, {
sortable: true,
dataIndex: 'EXNO',
header: '快递号',
width: 120
}, {
sortable: true,
dataIndex: 'BILLDATE',
header: '快递日期',
width: 120
}, {
sortable: true,
dataIndex: 'BILLSTATUS',
header: '快递状态',
width: 120
}, {
sortable: true,
dataIndex: 'EXPRESSCORP',
header: '快递公司',
width: 100
}, {
sortable: true,
dataIndex: 'RECEIVECUST',
header: '收件公司',
width: 160
}, {
sortable: true,
dataIndex: 'RECEIVECITY',
header: '所在城市',
width: 100
}, {
sortable: true,
dataIndex: 'RECEIVE',
header: '收件公司名称',
width: 160
}, {
sortable: true,
dataIndex: 'GOODSNAME',
header: '品名',
width: 180
}, {
sortable: true,
dataIndex: 'BILLFEE',
header: '快递费',
width: 180
}, {
sortable: true,
dataIndex: 'REMARKS',
header: '备注',
width: 200
}, {
sortable: true,
dataIndex: 'CREATEUSERREF',
header: '录入人',
width: 100
}, {
sortable: true,
dataIndex: 'CREATETIME',
header: '录入时间',
width: 120
}
];
2 years ago
2 years ago
this.girdcolums.unshift(new Ext.grid.RowNumberer());
2 years ago
//定义Grid
this.gridList = new Ext.grid.GridPanel({
store: this.storeList,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
viewConfig: {
enableTextSelection: true
},
selModel: this.GridCheckBoxModel,
2 years ago
columns: this.girdcolums ,
2 years ago
bbar: Ext.create('Ext.PagingToolbar', {
store: this.storeList,
displayInfo: true,
displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录',
emptyMsg: "没有数据"
})
});
this.gridList.addListener('itemdblclick', function (dataview, record, item, index, e, b) {
this.SelectedRecord = record;
this.OprationStatus = 'edit';
DsOpenEditWin('/MvcShipping/MsOpExpress/Edit');
// window.open('/MvcShipping/MsOpExpress/Edit', "OPEXPRESS", 'width=800,height=650,top=0,left=0,resizable=yes,status=yes,menubar=no,scrollbars=yes');
}, this);
//#region formSearch
//#region formSearch枚举参照相关
this.StoreExpStatus = Ext.create('Ext.data.Store', {
fields: ['OpLb']
});
this.StoreExpStatus.add({ "OpLb": "" });
this.StoreExpStatus.add({ "OpLb": "新建" });
this.StoreExpStatus.add({ "OpLb": "已下单" });
this.StoreExpStatus.add({ "OpLb": "已发件" });
this.StoreExpStatus.add({ "OpLb": "已收件" });
this.comboxExpressStatus = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '快件状态',
store: this.StoreExpStatus,
forceSelection: true,
name: 'EXPSTATUS',
valueField: 'OpLb',
displayField: 'OpLb',
enableKeyEvents: true,
listeners: {
keyup: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
});
//#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: '快递号',
name: 'PORTID',
enableKeyEvents: true,
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
}, {
fieldLabel: '编号',
name: 'BLNO',
enableKeyEvents: true,
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
},this.comboxExpressStatus,{
fieldLabel: '收件客户',
name: 'PORTENAME',
enableKeyEvents: true,
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
}, {
fieldLabel: '快递日期',
format: 'Y-m-d',
xtype: 'datefield',
name: 'ETDbgn',
enableKeyEvents: true,
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
}, {
fieldLabel: '到',
format: 'Y-m-d',
xtype: 'datefield',
name: 'ETDend',
enableKeyEvents: true,
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
}
]
}
]//end items(fieldset 1)
}//end fieldset 1
]//end root items
});
//#endregion formSearch
_this = this;
//查询工具条
this.panelBtn = new Ext.Panel({
region: "north",
tbar: [
{
text: "新建",
iconCls: "btnadd",
handler: function (button, event) {
this.OprationStatus = 'add';
DsOpenEditWin('/MvcShipping/MsOpExpress/Edit');
// window.open('/MvcShipping/MsOpExpress/Edit', "OPEXPRESS", 'width=800,height=650,top=0,left=0,resizable=yes,status=yes,menubar=no,scrollbars=yes');
},
scope: this
},
{
text: "删除",
iconCls: "btndelete",
handler: function (button, event) {
this.onDeleteClick(button, event);
},
scope: this
},
'-',
{
text: "执行查询",
iconCls: "btnrefresh",
handler: function (button, event) {
this.onRefreshClick(button, event);
},
scope: this
},
{
text: "重置条件",
iconCls: "btnreset",
handler: function (button, event) {
},
scope: this
}, '-', {
text: "状态",
menu: [
{ text: "更新为已发件",
handler: function (menu, event) {
_this.onExpressRefreshStatusClick('已发件');
}
}, { text: "更新为已收件",
handler: function (menu, event) {
_this.onExpressRefreshStatusClick('已收件');
}
}, { text: "查看动态",
handler: function (menu, event) {
_this.onExpressStatusClick();
}
}],
scope: this
}, '-' ,{
text: "打印",
iconCls: "btnprint",
handler: function (button, event) {
_this.Print();
},
scope: this
}
]
});
this.panelTop = new Ext.Panel({
layout: "border",
region: "north",
height: 80,
items: [this.formSearch, this.panelBtn]
});
Ext.apply(this, {
items: [this.panelTop, this.gridList]
});
this.storeList.on('beforeload', function (store) {
var sql = this.getCondition();
Ext.apply(store.proxy.extraParams, { condition: sql });
}, this);
thisport = this;
var sql =" BILLSTATUS='新建' OR BILLSTATUS='已发件' ";
this.storeList.load({
params: { start: 0, limit: this.PageSize, sort: '', condition: sql },
waitMsg: "正在查询数据...",
scope: this
});
this.storeExpressCorp = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsInfoClientModel',
proxy: { url: '/MvcShipping/MsInfoClient/GetDataListAll' }
});
this.storeExpressCorp.load({ params: { condition: "ISEXPRESS='1'"} });
}, //end initUIComponents
onRefreshClick: function (button, event) {
var sql = this.getCondition();
this.storeList.load({
params: { start: 0, limit: this.PageSize, sort: '', condition: sql },
waitMsg: "正在查询数据...",
scope: this
});
},
onExpressRefreshStatusClick: function (expstatus) {
var GidStr = '';
var records = this.GridCheckBoxModel.selected.items;
if (records.length == 0) {
Ext.Msg.show({ title: '提示', msg: '请先选择要刷新的业务!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
var bodyAddDatas = [];
for (var i = 0; i < records.length; i++) {
var rec = records[i];
if (rec.data.MANIFESTSTATUS != expstatus) {
bodyAddDatas.push(rec);
}
}
_this = this;
if (bodyAddDatas.length == 0) {
Ext.Msg.show({ title: '提示', msg: '没有要刷新的业务!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
} else {
Ext.Msg.wait('正在更新数据...');
var jsonbodyAddDatas = ConvertRecordsToJsonAll(bodyAddDatas);
Ext.Ajax.request({
waitMsg: '正在锁定...',
url: '/MvcShipping/MsOpExpress/RefreshExpressSTATUSList',
params: {
data: jsonbodyAddDatas,
status: expstatus
},
callback: function (options, success, response) {
if (success) {
var result = Ext.JSON.decode(response.responseText);
if (!result.Success) {
Ext.Msg.show({
title: '提示',
msg: result.Message,
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.OK
});
return;
} else {
Ext.Msg.show({ title: '提示', msg: result.Message, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
_this.onRefreshClick();
}
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
}
},
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];
Ext.MessageBox.confirm('提示', '确定删除该记录吗?', function (btn) {
if (btn == 'yes') {
Ext.Msg.wait('正在删除数据...');
Ext.Ajax.request({
waitMsg: '正在删除数据...',
url: '/MvcShipping/MsOpExpress/Delete',
params: {
data: Ext.JSON.encode(record.data)
},
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
//#region 快递动态
onExpressStatusClick: 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 expno = record.data.EXNO;
var expid = record.data.GID;
var expcorpid = '';
var CORP = record.data.EXPRESSCORP;
if (expno == "" || CORP == "") {
Ext.Msg.show({ title: '提示', msg: '快递单号和快递公司不能为空!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
} else {
var Cargoinforecords = DsStoreQueryBy(this.storeExpressCorp, 'SHORTNAME', CORP);
if (Cargoinforecords.getCount() > 0) {
var Cargoinfodata = Cargoinforecords.getAt(0).data;
expcorpid = Cargoinfodata.EDICODE;
}
if (expcorpid == "") {
Ext.Msg.show({ title: '提示', msg: '快递公司的EDI代码不能为空!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
// if (CORP.indexOf("中通") >= 0)
// expcorpid = 'zhongtong';
// else if (CORP.indexOf("圆通") >= 0)
// expcorpid = 'yuantong';
// else if (CORP.indexOf("申通") >= 0)
// expcorpid = 'shentong';
// else if (CORP.indexOf("韵达") >= 0)
// expcorpid = 'yunda';
// else if (CORP.indexOf("EMS") >= 0)
// expcorpid = 'ems';
// else if (CORP.indexOf("百世") >= 0 || CORP.indexOf("汇通") >= 0)
// expcorpid = 'huitongkuaidi';
var ExpressStatusView = new Shipping.ExpressStatusView({
});
ExpressStatusView.expno = expno;
ExpressStatusView.expcorpid = expcorpid;
ExpressStatusView.expid = expid;
ExpressStatusView.EditRecord = record;
ExpressStatusView.show();
return;
}
},
//#endregion
Print: function () {
_this = this;
if (this.storeList.getCount() == 0) {
return;
}
var selectedRecords = [];
selectedRecords = this.GridCheckBoxModel.selected.items;
if (selectedRecords.length == 0) {
Ext.Msg.show({ title: Zi.LAN.TiShi, msg: Zi.LAN.QingXianXuanZeYeWu, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); //'提示', '请先选择要打印的业务!'
return;
}
var gidSql = '';
for (var i = 0; i < selectedRecords.length; i++) {
var record = selectedRecords[i];
var sfGId = "'" + record.get('GID') + "'";
if (gidSql == '') {
gidSql = sfGId;
} else {
gidSql = gidSql + "," + sfGId;
}
};
var printType = 'MSOPEXPRESS';
var sql1 =
"SET LANGUAGE 'us_english' select e.*,s.origincode,s.destcode,s.proCode,s.destRouteLabel,s.destTeamCode,s.codingMapping, s.codingMappingOut, s.twoDimensionCode, s.abFlag from op_express e left join op_express_sfprint s on e.EXNO = s.mailno WHERE e.GID IN (" + gidSql + ")";
//sql1 += "s.codingMapping, s.codingMappingOut, s.twoDimensionCode, s.abFlag ";
//sql1 += " from op_express e inner join op_express_sfprint s on e.EXNO = s.mailno WHERE e.GID IN (" + gidSql + ")";
var sql2 = "";
var sql3 = "";
var sql4 = "";
var sql5 = "";
var sql6 = "";
PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6);
},
getCondition: function () {
var form = this.formSearch.getForm();
if (!form.isValid()) {
Ext.Msg.alert('提示', '查询条件赋值错误,请检查。');
return '';
}
var sql = '';
var PORTID = form.findField('PORTID').getValue();
sql = sql + getAndConSql(sql, PORTID, "EXNO like '%" + PORTID + "%'");
var BLNO = form.findField('BLNO').getValue();
sql = sql + getAndConSql(sql, BLNO, "and gid in (select EXPID from op_express_doc e left join op_receipt d on(d.GID = e.DOCID) inner join v_op_bs b on(b.BSNO = d.BSNO) and (b.MBLNO like '%" + BLNO + "%' or b.CUSTNO like '%" + BLNO + "%'))");
var EXPSTATUS = form.findField('EXPSTATUS').getValue();
sql = sql + getAndConSql(sql, EXPSTATUS, " BILLSTATUS='" + EXPSTATUS + "'");
var PORTENAME = form.findField('PORTENAME').getValue();
sql = sql + getAndConSql(sql, PORTENAME, "RECEIVE like '%" + PORTENAME + "%'");
var ETDbgn = form.findField('ETDbgn').getRawValue();
sql = sql + getAndConSql(sql, ETDbgn, "BILLDATE >='" + ETDbgn + "'");
var ETDend = form.findField('ETDend').getRawValue();
sql = sql + getAndConSql(sql, ETDend, "BILLDATE <='" + ETDend + "'");
return sql;
},
OprationSwap: function () {
var ret = new Array();
ret[0] = this.OprationStatus;
ret[1] = this.storeList;
ret[2] = this.SelectedRecord;
return ret;
}
});