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_RECEIPTWMS/MsOpAirn_RECEIPTWMSIndex.js

733 lines
24 KiB
JavaScript

2 years ago
//集运管理-路单查询
Ext.namespace('DsTruck');
DsTruck.MsOpAirn_RECEIPTWMSIndex = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.DsTruck.MsOpAirn_RECEIPTWMSIndex.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_RECEIPTWMSIndex, Ext.Panel, {
PageSize: 100,
OprationStatus: null, //仅当弹出界面时使用
SelectedRecord: null,
initUIComponents: function () {
//定义数据集
this.storeList = Ext.create('Ext.data.Store', {
pageSize: this.PageSize,
model: 'op_airn_RECEIPTWMSmb',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/MvcShipping/MsOpAirn_RECEIPTWMS/GetDataList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.formname = "Airn_RECEIPTWMS";
//#region 表参照
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'
});
//#endregion
this.column = [
{
sortable: true,hidden:true,
dataIndex: 'GID',
header: 'GID',
width: 80
},
{
sortable: true,
dataIndex: 'CUSTCODE',
header: '承运人缩写',
width: 80
},
{
sortable: true,
dataIndex: 'CUSTOMERNAME',
header: '承运人',
width: 80
},
{
sortable: true,
dataIndex: 'RTYPE',
header: '单据样式',
width: 80
},
{
sortable: true,
dataIndex: 'FIRSTCODE',
header: '前缀',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'STARTNO',
header: 'STARTNO',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'ENDNO',
header: 'ENDNO',
width: 80
},
{
sortable: true,
dataIndex: 'RCOUNT',
header: '总数量',
width: 80
},
{
sortable: true,
dataIndex: 'KC',
header: '库存',
width: 80
},
{
sortable: true,
dataIndex: 'QY',
header: '取用',
width: 80
},
{
sortable: true,
dataIndex: 'TD',
header: '退单',
width: 80
},
{
sortable: true,
dataIndex: 'ISBAOCANG',
header: '是否包仓',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'DEPTGID',
header: 'DEPTGID',
width: 80
},
{
sortable: true,
dataIndex: 'OP',
header: '最后操作人',
width: 80
},
{
sortable: true,
dataIndex: 'OPDATE',
header: '最后操作时间',
width: 80
},
{
sortable: true,
dataIndex: 'REMARK',
header: '备注',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'STATUS',
header: 'STATUS',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'TimeMark',
header: 'TimeMark',
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_RECEIPTWMS/Edit', "费用方案明细");
}, this);
//#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: 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();
}
}
}
}, { xtype: 'hiddenfield', flex: 2 }
]
}, {
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_RECEIPTWMS/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: "导出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, " OPDATE>='" + ETDbgn + "'");
var ETDend = form.findField('ETDend').getRawValue();
sql = sql + getAndConSql(sql, ETDend, " OPDATE<='" + ETDend + " 23:59:59'");
/*var billNo = form.findField('PS_REFBILLNO').getValue();
sql = sql + getAndConSql(sql, billNo, " A.RefBillNo like '%" + billNo + "%'");
var expDate_Min = form.findField('PS_EXPDATEBGN').getRawValue();
sql = sql + getAndConSql(sql, expDate_Min, " A.ExpDate>='" + expDate_Min + "'");
var expDate_Max = form.findField('PS_EXPDATEEND').getRawValue();
sql = sql + getAndConSql(sql, expDate_Max, " A.ExpDate<='" + expDate_Max + " 23:59:59'");
var orgCode = form.findField('OrgCode').getValue();
sql = sql + getAndConSql(sql, orgCode, "OrgCode like '%" + orgCode + "%'");
*/
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_RECEIPTWMS/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
});
}
}
});
}
}
}
});