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/MsOpAirn_Freight/MsOpAirn_FreightIndex.js

742 lines
25 KiB
JavaScript

2 years ago
//集运管理-路单查询
Ext.namespace('DsTruck');
DsTruck.MsOpAirn_FreightIndex = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.DsTruck.MsOpAirn_FreightIndex.superclass.constructor.call(this);
};
//#region 当前时间
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);
//#endregion
Ext.extend(DsTruck.MsOpAirn_FreightIndex, Ext.Panel, {
PageSize: 100,
OprationStatus: null, //仅当弹出界面时使用
SelectedRecord: null,
initUIComponents: function () {
//定义数据集
this.storeList = Ext.create('Ext.data.Store', {
pageSize: this.PageSize,
model: 'FreightPLANmb',
remoteSort: false,
proxy: {
type: 'ajax',
url: '/MvcShipping/MsOpAirn_Freight/GetDataList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.formname = "Airn_Freight";
//#region 表参照
//#endregion
this.column = [
{
sortable: true, hidden: true,
dataIndex: 'GID',
header: 'GID',
width: 80
},
{
sortable: true,
dataIndex: 'DESCRIPTION',
header: '方案信息',
width: 80
},
{
sortable: true,
dataIndex: 'CUSTCODE',
header: '承运人',
width: 80
},
{
sortable: true,
dataIndex: 'CUSTOMERNAME',
header: '航空公司',
width: 80
},
{
sortable: true,
dataIndex: 'BLTYPE',
header: '运单类型',
width: 80
},
{
sortable: true,
dataIndex: 'AREA',
header: '区域',
width: 80
},
{
sortable: true,
dataIndex: 'STARTDATE',
header: '生效时间',
width: 110
},
{
sortable: true,
dataIndex: 'ENDDATE',
header: '失效时间',
width: 110
},
{
sortable: true,
dataIndex: 'ENTERDATE',
header: '录入时间',
width: 110
},
{
sortable: true,
dataIndex: 'ENTEROPERATOR',
header: '录入人',
width: 80
},
{
sortable: true,
dataIndex: 'INUSE',
header: '是否启用',
width: 80
}
];
this.cellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
this.PCCB = Ext.create('Ext.selection.CheckboxModel', { checkOnly: true });
Ext.grid.RowNumberer = Ext.extend(Ext.grid.RowNumberer, {
width: 45
});
//定义Grid
this.gridList = new Ext.grid.GridPanel({
store: this.storeList,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
/*features: [{
ftype: 'summary'//Ext.grid.feature.Summary表格汇总特性
}],*/
selModel: this.PCCB,
plugins: [this.cellEditing],
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);
this.column.unshift(new Ext.grid.RowNumberer());
this.gridList.reconfigure(this.storeList, this.column);
////////////////////////////
this.gridList.addListener('itemdblclick', function (dataview, record, item, index, e, b) {
this.SelectedRecord = record;
this.OprationStatus = 'edit';
DsOpenEditWin('/MvcShipping/MsOpAirn_Freight/Edit', "费用方案明细");
}, this);
//#region formSearch
//#region formSearch枚举参照相关
var _this = this;
this.storeAIRLINES = Ext.create('DsExt.ux.RefTableStore', {
model: 'Tradermb',
proxy: { url: '/CommMng/BasicDataRef/GetTrader' }
});
this.storeAIRLINES.load({ params: { condition: " isairlines=1"} });
this.comboxAIRLINES = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '航空公司',
forceSelection: true,
store: this.storeAIRLINES,
name: 'AIRLINES',
valueField: 'name',
displayField: 'codename',
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
});
//#endregion
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: [{
xtype: 'monthfield',
name: 'ACCDATE', hidden: true,
fieldLabel: '月份',
labelWidth: 80,
anchor: '100%'
}, this.comboxAIRLINES
, {
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();
}
}
}
}, { fieldLabel: '方案信息包含',
name: 'DESCRIPTION',
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
}, { xtype: 'hiddenfield', flex: 1 }
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [
]
}
]//end items(fieldset 1)
}//end fieldset 1
]//end root items
});
//#endregion formSearch
//菜单
var menu_SetFee = new Ext.menu.Menu({
id: 'PriceMenu',
items: [{
text: '设定超重费用',
handler: clickHandler_1
}, {
text: '超重费用取消',
handler: clickHandler_2
}, {
text: '设定重回额外费用',
handler: clickHandler_3
}, {
text: '重回额外费用取消',
handler: clickHandler_4
}]
});
me = this;
function clickHandler_1() {
me.SetFee("超重费", "150", "1");
};
function clickHandler_2() {
me.SetFee("超重费", "150", "0");
};
function clickHandler_3() {
me.SetFee("双背附加费", "600", "1");
};
function clickHandler_4() {
me.SetFee("双背附加费", "600", "0");
};
//查询工具条
this.panelBtn = new Ext.Panel({
region: "north",
tbar: [
{
text: "执行查询",
iconCls: "btnrefresh",
handler: function (button, event) {
this.onRefreshClick(button, event);
},
scope: this
}, '-', {
text: "新建",
iconCls: "btnadd",
handler: function (button, event) {
this.OprationStatus = 'add';
DsOpenEditWin("/MvcShipping/MsOpAirn_Freight/Edit", "费用方案明细");
},
scope: this
}, {
text: '删除',
tooltip: '删除',
iconCls: "btndeletedetail",
handler: function (button, event) {
this.onDelPCClick(button, event);
},
scope: this
}, {
text: "保存修改",
iconCls: "btnsave",
handler: function (button, event) {
this.onSaveClick(button, event);
},
scope: this
}, '-', {
text: '复制添加',
tooltip: '复制添加选中的方案',
iconCls: "btncopy",
handler: function (button, event) {
this.onCOPYNEW(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) {
DsTruck.SaveGridPanel(GID, this.formname, this.gridList.columns, this.column, 1, false);
},
scope: this
}
]
});
//#region 布局
this.panelTop = new Ext.Panel({
layout: "border",
region: "north",
height: 70,
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();
Ext.apply(store.proxy.extraParams, { condition: sql });
}, this);
//#endregion
}, //end initUIComponents
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, sort: "", condition: sql },
waitMsg: "正在查询数据...",
scope: this
});
},
onRefreshClick: function (button, event) {
if (!this.checkSearchCondition())
return;
var sql = this.getCondition();
this.storeList.load({
//GetDataList(int start, int limit, string sort, string condition)
params: { start: 0, limit: this.PageSize, sort: "", condition: sql },
waitMsg: "正在查询数据...",
scope: this
});
},
getCondition: function () {
var form = this.formSearch.getForm();
var sql = "";
var AIRLINES = form.findField('AIRLINES').getValue();
sql = sql + getAndConSql(sql, AIRLINES, " CUSTOMERNAME='" + AIRLINES + "'");
var ETDbgn = form.findField('ETDbgn').getRawValue();
sql = sql + getAndConSql(sql, ETDbgn, " ( StartDate>='" + ETDbgn + "' and EndDate<='" + ETDbgn + " 23:59:59')");
var ETDend = form.findField('ETDend').getRawValue();
sql = sql + getAndConSql(sql, ETDend, " ( StartDate>='" + ETDend + "' and EndDate<='" + ETDend + " 23:59:59')");
var DESCRIPTION = form.findField('DESCRIPTION').getValue();
sql = sql + getAndConSql(sql, DESCRIPTION, " DESCRIPTION like '%" + DESCRIPTION + "%'");
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;
//ret[3] = this.SelectedRecord.data.REFBILLNO;
//ret[4] = "MsRptPcHeadQryIndex";
return ret;
},
onExportClick: function (button, event) {
GridExportExcelPage(this.gridList);
},
SetFee: function (FeeName, Amount, Type) {
var _condition = this.getCondition();
var GIDList = [];
var selectedRecords = this.gridList.selModel.getSelection();
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
GIDList.push(rec.get('GID'));
}
var _GIDList = ConvertStringListToJson(GIDList);
Ext.Ajax.request({//
waitMsg: '正在初始化库存数据...',
url: '/TruckMng/MsRptPcHeadQry/SetFee',
params: {
GIDList: _GIDList,
FeeName: FeeName,
Amount: Amount,
Type: Type
},
callback: function (_count) {
//alert('初始化完成');
//重新load库存表的store
this.storeList.load({ params: { condition: _condition} });
},
scope: this
}); //request over
},
onAddPCClick: function (button, event, type) {
var store = null;
store = this.storeList;
//var truckno = Ext.getCmp('S_TRUCKNO').getValue();
record = Ext.create('PCmb', {
TRUCKNO: "",
DRVCODE: "",
DRVNAME: "",
GId: newGuid(),
BillNo: "",
DdCode: usercode,
DdCode_Ref: SHOWNAME,
DDNAME: "",
ArriveDate: currdate.format('yyyy-MM-dd'),
CustCode: "QDHE",
CustName: "海尔",
TRUCKNO: "",
MBLNO: "",
DRVNAME: "",
DRVNAME_REF: "",
MOBILE: "",
CONTAINERTYPE: "",
CONTAINERTYPE_REF: "",
CONTAINERQTY: "",
YARDCODE_REF: "",
VOYVEG_REF: "",
DSTAREA: "",
NOLOADMIL: "",
OVERLOADMIL: "",
RATEDFUEL: "",
REALFUEL: "",
LRDATE: "",
USERCODE: "",
USERNAME: "",
REFBILLNO: "",
DETINATION: "",
CONTAINERNO: "",
SEALNO: "",
Ton: "",
ActualWeight: "",
IsDoubleREF: "",
IsDoubleREF: "",
TimeMark: 0
});
var _this = this;
var data = record.data;
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/TruckMng/MsWl_Haier/CreatePC',
scope: this,
async: true,
params: {
data: Ext.JSON.encode(data)
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
record = jsonresult.Data;
store.add(record);
cellediting = this.cellEditing;
var n = store.getCount();
cellediting.startEditByPosition({ row: n - 1, column: 2 });
} else {
Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
}
} else {
Ext.Msg.show({ title: '请重试',
msg: '服务器响应出错',
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
}
//alert('03');
}
});
},
onDelPCClick: 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 candelete = DsTruck.CheckBaoxiaoDelete(selectedRecords);
if (candelete == false) {
return;
}*/
var record = selections[0];
Ext.MessageBox.confirm('提示', '确定删除该记录吗?', function (btn) {
if (btn == 'yes') {
Ext.Msg.wait('正在删除数据...');
Ext.Ajax.request({
waitMsg: '正在删除数据...',
url: '/MvcShipping/MsOpAirn_Freight/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);
//InitData();
} //onDeleteClick
,
onSaveClick: function (button, event) {
for (var i = 0; i < this.storeList.getCount(); i += 1) {
var record = this.storeList.getAt(i);
if (record.dirty) {
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/TruckMng/MsWl_Haier/SaveYDHZ',
scope: this,
async: false,
params: {
data: Ext.JSON.encode(record.data)
},
callback: function (options, success, response) {
if (success) {
//Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
var returnData = jsonresult.Data;
var editp = Ext.create('PCmb', returnData);
this.storeList.getAt(i).fields.each(function (field) {
if (field.persist) {
name = field.name;
//alert(name + ' -- ' + editp.get(name));
if (name != 'BillNo')
this.storeList.getAt(i).set(name, editp.get(name));
}
}, this);
this.storeList.getAt(i).commit();
} else {
Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
}
} else {
Ext.Msg.show({ title: '请重试',
msg: '服务器响应出错',
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
}
}
});
}
}
}
,
onCOPYNEW: 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 record = selections[0];
Ext.MessageBox.confirm('提示', "确定复制添加该记录吗? <" + record.data.DESCRIPTION+">" , function (btn) {
if (btn == 'yes') {
//Ext.Msg.wait('正在复制添加...');
Ext.Ajax.request({
waitMsg: '正在复制添加...',
url: '/MvcShipping/MsOpAirn_Freight/COPYNEW',
params: {
data: Ext.JSON.encode(record.data)
},
callback: function (options, success, response) {
this.onRefreshClick();
},
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);
}
});