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.

576 lines
18 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('Shipping');
Shipping.LanesIndex = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.LanesIndex.superclass.constructor.call(this);
};
Date.prototype.format = function (format) {
var o = {
"M+": this.getMonth() + 1, //month
"d+": this.getDate(), //day
"h+": this.getHours(), //hour
"m+": this.getMinutes(), //minute
"s+": this.getSeconds(), //second
"q+": Math.floor((this.getMonth() + 3) / 3), //quarter
"S": this.getMilliseconds() //millisecond
}
if (/(y+)/.test(format)) format = format.replace(RegExp.$1,
(this.getFullYear() + "").substr(4 - RegExp.$1.length));
for (var k in o) if (new RegExp("(" + k + ")").test(format))
format = format.replace(RegExp.$1,
RegExp.$1.length == 1 ? o[k] :
("00" + o[k]).substr(("" + o[k]).length));
return format;
}
var xhr = new XMLHttpRequest();
var currdate = new Date();
if (!xhr) {
//...其他生成xmlhttprequest方法
}
xhr.open("HEAD", location.href, true);
xhr.onreadystatechange = function () {
if (xhr.readyState == 4 && xhr.status == 200) {
var datestr = xhr.getResponseHeader("Date");
currdate = new Date(datestr);
// alert(currdate.format('yyyy-MM-dd'));
}
}
xhr.send(null);
Ext.extend(Shipping.LanesIndex, Ext.Panel, {
PageSize: 500,
OprationStatus: null, //仅当弹出界面时使用
SelectedRecord: null,
initUIComponents: function () {
this.formname = "MsCodeLanesIndex";
//#region 定义数据集
//#endregion
/////////////////////////////////////////
//#region 主列表
this.storeOpCode = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.UserRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetUserLinkRefList' }
});
this.storeOpCode.load();
this.comboxOP = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storeOpCode,
forceSelection: true,
name: 'OP',
valueField: 'UserName',
displayField: 'CodeAndName'
});
this.storeOpCode2 = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.UserRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetUserLinkRefList' }
});
this.storeOpCode2.load();
this.comboxOP2 = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storeOpCode2,
forceSelection: true,
name: 'OP',
valueField: 'UserName',
displayField: 'CodeAndName'
});
this.storeOpCode3= Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.UserRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetUserLinkRefList' }
});
this.storeOpCode3.load();
this.comboxOP3 = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storeOpCode3,
forceSelection: true,
name: 'CUSTSERVICE',
valueField: 'UserName',
displayField: 'CodeAndName'
});
this.storeList = Ext.create('Ext.data.Store', {
pageSize: this.PageSize,
model: 'Code_lanesmb',
remoteSort: true,
//groupField: 'GroupDate',
proxy: {
type: 'ajax',
//url: '/TruckMng/MsRptPcHeadOperate/QryData_ADL',
url: '/MvcShipping/MsCodeAll/GetLanesList',
//this.storeList.proxy.url = '/TruckMng/MsRptPcHeadOperate/QryData_ADL';
reader: {
id: '',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.column = [
{
sortable: true,hidden:true,
dataIndex: 'GID',
header: 'GID',
width: 80
},
{
sortable: true,
dataIndex: 'LANEID',
header: Zi.LAN.LANEID,
width: 80,
editor: {
xtype: 'textfield', //numberfield textfield
selectOnFocus: true
}
},
{
sortable: true,
dataIndex: 'LANE',
header: Zi.LAN.LANE,
width: 160,
editor: {
xtype: 'textfield', //numberfield textfield
selectOnFocus: true
}
},
{
sortable: true,
dataIndex: 'LANEEN',
header: Zi.LAN.LANEEN,
width: 160,
editor: {
xtype: 'textfield', //numberfield textfield
selectOnFocus: true
}
},
{
sortable: true,
dataIndex: 'EDICODE',
header: Zi.LAN.EDICODE,
width: 120,
editor: {
xtype: 'textfield', //numberfield textfield
selectOnFocus: true
}
},
{
sortable: true,
dataIndex: 'OP',
header: Zi.LAN.OP ,
width: 120,
editor: this.comboxOP
},
{
sortable: true,
dataIndex: 'DOC',
header: Zi.LAN.DOC,
width: 120,
editor: this.comboxOP2
},
{
sortable: true,
dataIndex: 'CUSTSERVICE',
header: Zi.LAN.CUSTSERVICE,
width: 120,
editor: this.comboxOP3
}
];
this.cellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
this.MainCB = Ext.create('Ext.selection.CheckboxModel'
, {
checkOnly: false
, singleSelect: true
,
listeners: {
click: {
element: 'el', //bind to the underlying el property on the panel
fn: function () { gridList.getSelectionModel().clearSelections(); }
}
}
});
Ext.grid.RowNumberer = Ext.extend(Ext.grid.RowNumberer, {
width: 40
});
this.gridList = new Ext.grid.GridPanel({
store: this.storeList,
enableHdMenu: false,
region: 'center',
loadMask: { msg: Zi.LAN.LoadData},
trackMouseOver: true,
disableSelection: false,
//selModel: this.MainCB,
columns: this.column,
plugins: [
this.cellEditing
],
/*features: [{
id: 'group',
ftype: 'grouping',
groupHeaderTpl: '{name}',
hideGroupedHeader: true,
enableGroupingMenu: true
}],*/
viewConfig: {
enableTextSelection: true, //允许复制数据
autoFill: true
},
bbar: Ext.create('Ext.PagingToolbar', {
store: this.storeList,
displayInfo: true,
displayMsg: Zi.LAN.FenYe,
emptyMsg: Zi.LAN.Nodata
})
});
/////////////以下部分为获取存储的gridpanel显示样式
//this.column = DsTruck.GetGridPanel(USERID, this.formname, this.column);
//使用者id表名 中间column数组
this.column.unshift(new Ext.grid.RowNumberer());
this.gridList.reconfigure(this.storeList, this.column);
////////////////////////////
//#endregion
//////////////////////////////////////////////////////////////
//#region formSearch
//#region formSearch枚举参照相关
//#endregion
this.formSearch = Ext.widget('form', {
frame: true,
region: 'center',
bodyPadding: 5,
fieldDefaults: {
margins: '2 2 2 2',
labelAlign: 'right',
flex: 1,
labelWidth: 85,
msgTarget: 'qtip'
},
items: [
{//fieldset 1
xtype: 'container',
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: Zi.LAN.LANE,
name: 'LANE'
}, {
fieldLabel: Zi.LAN.LANEEN,
name: 'LANEEN'
}, {
//fieldLabel: '从开船日期',
//format: 'Y-m-d',
xtype: 'hiddenfield',
flex:3
}]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [
//, this.comboxFeeNameRef
//, { xtype: 'hiddenfield', flex: 2 }
]
}
]//end items(fieldset 1)
}//end fieldset 1
]//end root items
});
//#endregion formSearch
this.panelBtn = new Ext.Panel({
region: "north",
tbar: [
{
text: Zi.LAN.xnew, id: "btnadd", //hidden: true,
iconCls: "btnadd",
handler: function (button, event) {
//this.OprationStatus = 'add';
//DsOpenEditWin("/TruckMng/MsWlPc/Edit_ADL", "", "700", "1000");
this.onAddPCClick();
},
scope: this
}, {
text: Zi.LAN.delete1, id: "btndelete",
iconCls: "btndelete",
handler: function (button, event) {
this.onDeleteClick(button, event);
},
scope: this
}, {
text: Zi.LAN.Save, id: "SaveBtn",
iconCls: "btnsave",
handler: function (button, event) {
this.onSaveClick(button, event);
},
scope: this
}, '-', '-', {
text: Zi.LAN.ExecuteQuery,
iconCls: "btnrefresh",
handler: function (button, event) {
this.onRefreshClick(button, event);
},
scope: this
}, '-', {
text: Zi.LAN.ExportExcel ,
id: "btnExportExcel",
iconCls: 'btnexportexcel',
handler: function (button, event) {
this.onExportClick(button, event);
},
scope: this
}
//,this.CB_EditMode
]
});
//布局
this.panelTop = new Ext.Panel({
layout: "border",
region: "north",
height: 75,
items: [this.formSearch, this.panelBtn]
});
this.panelContract = new Ext.Panel({
//title: '',
layout: "border",
region: 'center',
height: 800,
margin: '1 2',
split: true,
items: [this.gridList]
});
Ext.apply(this, {
items: [this.panelTop, this.panelContract]
});
///以下集中绑定事件
this.storeList.on('beforeload', function (store) {
if (!this.checkSearchCondition())
return;
var sql = this.getCondition();
Ext.apply(store.proxy.extraParams, { condition: sql });
}, this);
this.gridList.on('edit', function (editor, e, eOpts) {
this.PCAfterEdit(editor, e, eOpts);
}, this);
/*
this.cellEditing.on('beforeedit', function (editor, e) {
//alert("beforeedit");
return this.PCBeforeEdit(editor, e);
}, this);
*/
this.LoadInitData();
}, //end initUIComponents
LoadInitData: function () {
//this.storeTruckNo.load({ params: { condition: " A.truckno not in (select DISTINCT truckno from tMsWlPcHead where isnull(isend,0)=0 ) "} });
},
onAuditRefuseClick: function (button, event) {
var sql = " A.GID in (select bsno from ch_fee where FEESTATUS=6)";
this.storeList.load({
params: { start: 0, limit: this.PageSize, condition: sql },
waitMsg: Zi.LAN.NowSelect,
scope: this
});
},
onRefreshClick: function (button, event) {
if (!this.checkSearchCondition())
return;
var sql = this.getCondition();
this.storeList.load({
params: { start: 0, limit: this.PageSize, condition: sql },
waitMsg: Zi.LAN.NowSelect,
scope: this
});
//}
},
getCondition: function () {
var form = this.formSearch.getForm();
var sql = '';
var LANE = form.findField('LANE').getValue();
sql = sql + getAndConSql(sql, LANE, " LANE like '%" + LANE + "%' ");
var LANEEN = form.findField('LANEEN').getValue();
sql = sql + getAndConSql(sql, LANEEN, " LANEEN like '%" + LANEEN + "%' ");
return sql;
},
checkSearchCondition: function () {
var form = this.formSearch.getForm();
if (!form.isValid()) {
Ext.Msg.alert('提示', '查询条件赋值错误,请检查。');
return false;
}
return true;
},
OprationSwap: function () {
var ret = new Array();
ret[0] = this.OprationStatus;
ret[1] = this.storeList;
ret[2] = this.SelectedRecord;
if (this.OprationStatus == "add") {
ret[3] = "";
} else {
ret[3] = this.SelectedRecord.data.REFBILLNO;
}
ret[4] = "MsRptPcHeadQryIndex";
ret[5] = formtype;
return ret;
},
onExportClick: function (button, event) {
GridExportExcelPage(this.gridList);
},
onSaveClick: function () {
var bodyList = [];
for (i = 0; i < this.storeList.getCount(); i += 1) {
var member = this.storeList.getAt(i);
bodyList.push(member);
};
var jsonBody = ConvertRecordsToJson(bodyList);
if (jsonBody == '') {
return;
}
Ext.Msg.wait(Zi.LAN.Msg_SavingAndWait);
Ext.Ajax.request({
waitMsg: Zi.LAN.Msg_SavingAndWait,
url: '/MvcShipping/MsCodeAll/SaveLanesList',
scope: this,
params: {
data: jsonBody
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
this.storeList.reload();
//this.onRefreshClick();
} else {
Ext.Msg.show({ title: Zi.LAN.Error, msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
}
} else {
Ext.Msg.show({ title: '请重试',
msg: Zi.LAN.FuWuQiError,
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
}
//alert('03');
}
});
}
,
onDeleteClick: function (button, event) {
var selections = this.gridList.getSelectionModel().getSelection();
if (selections.length == 0) {
Ext.Msg.show({ title: Zi.LAN.Prompt, msg: Zi.LAN.SelectDanju, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
var record = selections[0];
Ext.MessageBox.confirm(Zi.LAN.Prompt, Zi.LAN.suredelete, function (btn) {
if (btn == 'yes') {
Ext.Msg.wait(Zi.LAN.nowdelete);
Ext.Ajax.request({
waitMsg: Zi.LAN.nowdelete,
url: '/MvcShipping/MsCodeAll/DeleteLanes',
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.Prompt , msg: jsonresult.Message, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
}
else {
Ext.Msg.show({ title: Zi.LAN.Error, msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
}
}
},
failure: function (response, options) {
Ext.Msg.show({ title: Zi.LAN.Caveat, msg: Zi.LAN.FuWuQiError, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
},
success: function (response, options) {
},
scope: this
}); //end Ext.Ajax.request
}
}, this);
}, //onDeleteClick
onAddPCClick: function (button, event) {
var record = Ext.create('Code_lanesmb', {
'GID': '',
'LANEID': '',
'LANE': '',
'LANEEN': '',
'EDICODE': '',
'OP': '',
'DOC': ''
});
this.storeList.add(record);
var n = this.storeList.getCount();
this.cellEditing.startEditByPosition({ row: n - 1, column: 1 });
//this.storeTruckNo.load({ params: { condition: " A.truckno not in (select DISTINCT truckno from tMsWlPcHead where isnull(isend,0)=0 ) "} });
}
});