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.

574 lines
20 KiB
JavaScript

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

Ext.namespace('DsTruck');
DsTruck.MsCustTruckFeeTemplateIndex = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.DsTruck.MsCustTruckFeeTemplateIndex.superclass.constructor.call(this);
};
Ext.extend(DsTruck.MsCustTruckFeeTemplateIndex, Ext.Panel, {
OprationStatus: null, //仅当弹出界面时使用
SelectedRecord: null,
//需求编号SR2017061200005-3
initUIComponents: function () {
this.AuditEdit = false;
_this = this;
//定义数据集
this.storeList = Ext.create('Ext.data.Store', {
model: 'MsCustTruckFeeTemplate',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/TruckMng/MsCustTruckFeeTemplate/GetDataList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
//定义Grid
this.gridList = new Ext.grid.GridPanel({
store: this.storeList,
enableHdMenu: false,
region: 'center',
loadMask: { msg: Zi.LAN.ShuJuJiaZaiZhong },
trackMouseOver: true,
disableSelection: false,
columns: [{
sortable: true,
dataIndex: 'GID',
header: Zi.LAN.GID, //'GID',
hidden: true,
width: 120
}, {
sortable: true,
dataIndex: 'TEMPLATENAME',
header: '计费方案名称', //'模板名称',
width: 160
}, {
sortable: true,
dataIndex: 'CUSTOMERNAME',
header: '客户名称', //'模板名称',
width: 160
}, {
sortable: true,
dataIndex: 'CONTRACTNO',
header: '合同号', //'业务种类',
width: 160
}, {
sortable: true,
dataIndex: 'GOODNAME',
header: '商品名称', //'费用类别',
width: 160
}, {
sortable: true,
dataIndex: 'TRANTYPE',
header: '运输方式', //'费用类别',
width: 160
}, {
sortable: true,
dataIndex: 'BSSTATUS',
header: '模板状态', //'费用类别',
width: 160
}, {
sortable: true,
dataIndex: 'DC',
header: '收付', //'费用类别',
width: 100,
renderer: function (value, p, record) {
if (value =="1")
return "收";
else if (value == "2") return "付";
}
}, {
sortable: true,
dataIndex: 'CREATEUSERREF',
header: Zi.LAN.CREATEUSERREF, //'录入人',
width: 100
}, {
sortable: true,
dataIndex: 'CREATETIME',
header: Zi.LAN.CREATETIME, //'录入日期',
width: 100
}, {
sortable: true,
dataIndex: 'REMARK',
header: Zi.LAN.REMARK, //'说明',
width: 160
}
]
});
this.gridList.addListener('itemdblclick', function (dataview, record, item, index, e, b) {
this.SelectedRecord = record;
this.OprationStatus = 'edit';
DsOpenEditWin('/TruckMng/MsCustTruckFeeTemplate/Edit');
}, this);
//#region formSearch
this.storeCustomerNameRef = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CustomRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetCustomRefListRm' }
});
this.storeCustomerNameRef.load();
this.comboxCustomerNameRef = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storeCustomerNameRef,
fieldLabel: '客户名称', //'费用类型',
forceSelection: true,
queryMode: 'remote',
minChars: 1,
queryParam: 'CODENAME',
lazyRender: false,
name: 'CUSTOMERNAME',
valueField: 'CustName',
displayField: 'CodeAndName',
enableKeyEvents: true,
listeners: {
keyup: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
});
this.storeListGoodName = Ext.create('Ext.data.Store', {
fields: [
{ name: 'GID', type: 'string' },
{ name: 'GOODCODE', type: 'string' },
{ name: 'GOODNAME', type: 'string' },
{ name: 'GOODNO', type: 'string' },
{ name: 'DESCRIP', type: 'string' },
{ name: 'CODEANDNAME', type: 'string' },
{ name: 'GOODSTYPEGID', type: 'string' },
{ name: 'GOODSTYPE', type: 'string' },
{ name: 'CORPID', type: 'string' },
{ name: 'ISSTOP', type: 'string' }
],
pageSize: 5000,
remoteSort: true,
proxy: {
type: 'ajax',
url: '/MvcShipping/MsCodeGoods/GetDataList',
reader: {
id: '',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.storeListGoodName.load({
params: { start: 0, limit: 5000, sort: '', condition: '' },
waitMsg: "正在查询数据...",
scope: this
});
this.comboxGoodCode = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storeListGoodName,
forceSelection: true,
fieldLabel: '商品名称', //'费用类型',
valueField: 'GOODNAME',
displayField: 'CODEANDNAME',
name: 'GOODNAME',
enableKeyEvents: true,
listeners: {
keyup: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
});
this.storeTransType = Ext.create('Ext.data.Store', {
fields: ['DC', 'NAME']
});
this.storeTransType.add({ "DC": "普货", "NAME": "普货" });
this.storeTransType.add({ "DC": "集装箱", "NAME": "集装箱" });
this.comboxTransType = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '运输类型', //'费用类型',
store: this.storeTransType,
valueField: 'DC',
displayField: 'NAME',
forceSelection: true,
name: 'TRANTYPE',
enableKeyEvents: true,
listeners: {
keyup: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
});
this.storeTransStatus = Ext.create('Ext.data.Store', {
fields: ['DC', 'NAME']
});
this.storeTransStatus.add({ "DC": "新增", "NAME": "新增" });
this.storeTransStatus.add({ "DC": "提交审核", "NAME": "提交审核" });
this.storeTransStatus.add({ "DC": "审核通过", "NAME": "审核通过" });
this.comboxTransStatus = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '状态', //'费用类型',
store: this.storeTransStatus,
valueField: 'DC',
displayField: 'NAME',
forceSelection: true,
name: 'BSSTATUS',
enableKeyEvents: true,
listeners: {
keyup: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
});
this.storeListTruckLoadPort = Ext.create('Ext.data.Store', {
fields: [
{ name: 'PORTID', type: 'string' },
{ name: 'PORTCODE', type: 'string' },
{ name: 'PORT', type: 'string' },
{ name: 'CODEANDNAME', type: 'string' },
{ name: 'PROVINCE', type: 'string' }
],
pageSize: 5000,
remoteSort: true,
proxy: {
type: 'ajax',
url: '/TruckMng/MsCodeTruckPort/GetDataList',
reader: {
id: '',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.storeListTruckLoadPort.load();
this.comboxLoadPort = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '启运地',
store: this.storeListTruckLoadPort,
valueField: 'PORT',
displayField: 'CODEANDNAME',
forceSelection: true,
name: 'LOADPORT',
enableKeyEvents: true,
listeners: {
keyup: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
});
this.storeListTruckDistPort = Ext.create('Ext.data.Store', {
fields: [
{ name: 'PORTID', type: 'string' },
{ name: 'PORTCODE', type: 'string' },
{ name: 'PORT', type: 'string' },
{ name: 'CODEANDNAME', type: 'string' },
{ name: 'PROVINCE', type: 'string' }
],
pageSize: 5000,
remoteSort: true,
proxy: {
type: 'ajax',
url: '/TruckMng/MsCodeTruckPort/GetDataList',
reader: {
id: '',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.storeListTruckDistPort.load();
this.comboxDistPort = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '目的地',
store: this.storeListTruckDistPort,
valueField: 'PORT',
displayField: 'CODEANDNAME',
forceSelection: true,
name: 'DISTPORT',
enableKeyEvents: true,
listeners: {
keyup: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
});
this.formSearch = Ext.widget('form', {
frame: true,
region: 'center',
bodyPadding: 5,
fieldDefaults: {
margins: '2 2 2 2',
labelAlign: 'right',
flex: 1,
labelWidth: 70,
msgTarget: 'qtip'
},
items: [
{//fieldset 1
xtype: 'container',
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [ {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [this.comboxTransStatus,{
fieldLabel: '计费方案名称', //'模板名称',
labelWidth: 80,
name: 'TEMPLATENAME',
enableKeyEvents: true,
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
},this.comboxCustomerNameRef, this.comboxGoodCode,this.comboxTransType
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '合同号', //'模板名称',
name: 'CONTRACTNO',
enableKeyEvents: true,
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
}, this.comboxLoadPort, this.comboxDistPort, { xtype: 'hiddenfield' }, { xtype: 'hiddenfield' }
]
}
]//end items(fieldset 1)
}//end fieldset 1
]//end root items
});
//#endregion formSearch
//查询工具条
this.panelBtn = new Ext.Panel({
region: "north",
tbar: [
{
text: Zi.LAN.btnAdd, //"新建",
iconCls: "btnadd",
handler: function (button, event) {
this.OprationStatus = 'add';
DsOpenEditWin('/TruckMng/MsCustTruckFeeTemplate/Edit');
},
scope: this
},
{
text: Zi.LAN.btnDelete, //"删除",
iconCls: "btndelete",
handler: function (button, event) {
this.onDeleteClick(button, event);
},
scope: this
},
'-',
{
text: Zi.LAN.btnRefresh, //"执行查询",
iconCls: "btnrefresh",
handler: function (button, event) {
this.onRefreshClick(button, event);
},
scope: this
},
{
text: Zi.LAN.btnReset, //"重置条件",
iconCls: "btnreset",
handler: function (button, event) {
this.onClearSql(button, event);
},
scope: this
}, {
text: "导出Excel",
id: "btnExportExcel",
iconCls: 'btnexportexcel',
handler: function (button, event) {
this.onExportClick(button, event);
},
scope: this
}
]
});
this.panelTop = new Ext.Panel({
layout: "border",
region: "north",
height: 110,
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);
this.onRefreshClick();
}, //end initUIComponents
onRefreshClick: function (button, event) {
var sql = this.getCondition();
this.storeList.load({
params: { start: 0, limit: 500, sort: '', condition: sql },
waitMsg: Zi.LAN.ZhengZaiChaXunShuJu, //"正在查询数据...",
scope: this
});
},
onDeleteClick: function (button, event) {
var selections = this.gridList.getSelectionModel().getSelection();
if (selections.length == 0) {
Ext.Msg.show({ title: Zi.LAN.TiShi, msg: Zi.LAN.QingXianXuanZeXinXi, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
var record = selections[0];
if (record.data.BSSTATUS != '新增') {
Ext.Msg.show({ title: '警告', msg: '当前状态不允许删除!', icon: Ext.Msg.WARNING, buttons: Ext.Msg.OK });
return;
}
Ext.MessageBox.confirm(Zi.LAN.TiShi, Zi.LAN.QueDingShanChuGaiJiLuMa, function (btn) {
if (btn == 'yes') {
Ext.Msg.wait(Zi.LAN.ZhengZaiCaoZuoShuJu);
Ext.Ajax.request({
waitMsg: Zi.LAN.ZhengZaiCaoZuoShuJu, //'正在删除数据...',
url: '/TruckMng/MsCustTruckFeeTemplate/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: Zi.LAN.TiShi, msg: jsonresult.Message, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
}
else {
Ext.Msg.show({ title: Zi.LAN.CuoWu, msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
}
}
},
failure: function (response, options) {
Ext.Msg.show({ title: Zi.LAN.JingGao, msg: Zi.LAN.FuWuQiXiangYingChuCuo, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
},
success: function (response, options) {
},
scope: this
}); //end Ext.Ajax.request
}
}, this);
}, //onDeleteClick
getCondition: function () {
var form = this.formSearch.getForm();
if (!form.isValid()) {
Ext.Msg.alert(Zi.LAN.TiShi, Zi.LAN.ChaXunTiaoJianFuZhiCuoWu);
return '';
}
var sql = '';
var CONTRACTNO = form.findField('CONTRACTNO').getValue();
sql = sql + getAndConSql(sql, CONTRACTNO, "CONTRACTNO like '%" + CONTRACTNO + "%'");
var TRANTYPE = form.findField('TRANTYPE').getValue();
sql = sql + getAndConSql(sql, TRANTYPE, "TRANTYPE='" + TRANTYPE + "'");
var BSSTATUS = form.findField('BSSTATUS').getValue();
sql = sql + getAndConSql(sql, BSSTATUS, "BSSTATUS='" + BSSTATUS + "'");
var CUSTOMERNAME = form.findField('CUSTOMERNAME').getValue();
sql = sql + getAndConSql(sql, CUSTOMERNAME, "CUSTOMERNAME='" + CUSTOMERNAME + "'");
var GOODNAME = form.findField('GOODNAME').getValue();
sql = sql + getAndConSql(sql, GOODNAME, "GOODNAME='" + GOODNAME + "'");
var TEMPLATENAME = form.findField('TEMPLATENAME').getValue();
sql = sql + getAndConSql(sql, TEMPLATENAME, "TEMPLATENAME like '%" + TEMPLATENAME + "%'");
var LOADPORT = form.findField('LOADPORT').getValue();
var DISTPORT = form.findField('DISTPORT').getValue();
var deltailsql = '';
if (LOADPORT != '' || DISTPORT != '') {
deltailsql = deltailsql + getAndConSql(deltailsql, LOADPORT, "LOADPORT='" + LOADPORT + "'");``
deltailsql = deltailsql + getAndConSql(deltailsql, DISTPORT, "DISTPORT='" + DISTPORT + "'");
}
if (deltailsql != '') {
sql = sql + getAndConSql(sql, deltailsql, " GID IN (SELECT TEMPLATEID FROM WHERE " + deltailsql+" )");
}
return sql;
},
onClearSql: function () {
var form = this.formSearch.getForm();
form.reset();
}, //onDeleteClick
onExportClick: function (button, event) {
GridExportExcelPage(this.gridList);
},
OprationSwap: function () {
var ret = new Array();
ret[0] = this.OprationStatus;
ret[1] = this.storeList;
ret[2] = this.SelectedRecord;
ret[3] = this.AuditEdit;
return ret;
}
});