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/MsOpCtnr/MsOpCtnrDynaEdit.js

637 lines
19 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');
//#region 获取 YYYY-mm-dd 格式的日期
//var xhr = new XMLHttpRequest();
//var currdate = new Date();
//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);
// }
//}
//xhr.send(null);
//#endregion
Shipping.MsOpCtnrDynaEdit = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.MsOpCtnrDynaEdit.superclass.constructor.call(this);
};
Ext.extend(Shipping.MsOpCtnrDynaEdit, Ext.Panel, {
parentWin: null,
OpStatus: 'add',
StoreList: null,
EditRecord: null,
parentRecord: null,
initUIComponents: function () {
this.formname = 'MsCtnrDynaEdit';
this.CtnrDynaBodyDel = [];
//#region 数据集定义
//空重
this.storeCTNEF = Ext.create('Ext.data.Store', {
fields: ['FType', 'NAME']
});
this.storeCTNEF.add({ "FType": 'E', "NAME": "空" });
this.storeCTNEF.add({ "FType": 'F', "NAME": "重" });
this.comboxCTNEF = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storeCTNEF,
fieldLabel: '空重',
valueField: 'FType',
displayField: 'NAME',
forceSelection: true,
name: 'CTNEF'
});
this.storeCodeLoadport = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CodeLoadportModel',
proxy: { url: '/CommMng/BasicDataRef/GetCodeLoadportList' }
});
this.storeCodeLoadport.load();
this.comboxPORT = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '所在港口',
store: this.storeCodeLoadport,
//forceSelection: true,
id: 'PORT',
name: 'PORT',
valueField: 'PORT',
displayField: 'CodeAndName',
matchFieldWidth: false //下拉款自适应宽度
//
});
//场站
this.storeYARD = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CustomRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetCustomRefListYARD' }
});
this.storeYARD.load();
//
this.comboxYARD = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '场站',
store: this.storeYARD,
forceSelection: true,
queryMode: 'remote',
minChars: 0,
queryParam: 'CODENAME',
name: 'YARD',
valueField: 'CustName',
displayField: 'CodeAndName'
});
//人员信息加载
this.storeOpCode = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.UserRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetUserRefList' }
});
this.storeOpCode.load();
//操 作
this.comboxOP = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '操作',
store: this.storeOpCode,
forceSelection: true,
name: 'OP',
valueField: 'UserName',
displayField: 'CodeAndName',
enableKeyEvents: true
});
//箱动态类型
this.storeCTNSTATUS = Ext.create('DsExt.ux.RefEnumStore', {});
this.storeCTNSTATUS.load({ params: { enumTypeId: 99060 } });
this.comboxCTNSTATUS = Ext.create('DsExt.ux.RefEnumCombox', {
store: this.storeCTNSTATUS,
fieldLabel: '箱动态',
name: 'CTNSTATUS',
valueField: 'EnumValueName',
displayField: 'EnumValueName'
});
//#endregion
//#region form定义
//编辑form:formEdit
this.formEdit = Ext.widget('form', {
// layout: "border",
region: 'north',
height: 170,
frame: true,
bodyPadding: 1,
trackResetOnLoad: true,
fieldDefaults: {
margins: '1 1 1 1',
labelAlign: 'right',
flex: 1,
labelWidth: 64,
msgTarget: 'qtip'
//,split:true
},
items: [
{//fieldset 1
xtype: 'fieldset',
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [{//container_1
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: 'CTNGID',
hidden: true,
name: 'CTNGID'
}, {
fieldLabel: '箱号', flex: 1,
name: 'CNTRNO',
id: 'CNTRNO',
readOnly:true
},this.comboxPORT,
this.comboxYARD,
this.comboxCTNSTATUS,
this.comboxCTNEF
]
}//container_1 end
,
{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [
{
fieldLabel: '主提单号', flex: 1,
name: 'MBLNO',
id: 'MBLNO'
},
{
fieldLabel: '动态日期',
name: 'CTNSTATUSTIME',
format: 'Y-m-d',
labelWidth: 90,
xtype: 'datefield',
enableKeyEvents: true
},
{
fieldLabel: '箱型', flex: 1,
name: 'CTNALL',
id: 'CTNALL',
xtype: 'hidden'
},
{
fieldLabel: '箱源', flex: 1,
name: 'CNTRSOURCE',
id: 'CNTRSOURCE',
xtype: 'hidden'
},
{ xtype: 'hidden' }
]
}
]
}
]
});
//#endregion
//#region 编辑
//数据集
this.storeCtnrDyna = Ext.create('Ext.data.Store', {
model: 'MsOpCtnrDetail',
pageSize: this.PageSize,
remoteSort: false,
pruneModifiedRecords: true,
proxy: {
type: 'ajax',
url: '/MvcShipping/MsOpCtnr/GetDynaList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
var _this = this;
this.columns = [
{
sortable: true, //1
dataIndex: 'GID',
header: '惟一编号',
width: 80, hidden: true
}, {
sortable: true, //1
dataIndex: 'CTNGID',
header: '箱号',
width: 80, hidden: true
}, {
sortable: true, //1
dataIndex: 'CNTRNO',
header: '箱号',
width: 80, hidden: false, editor: {
xtype: 'textfield'
}
},
{
sortable: true,
dataIndex: 'CTNEF',
header: '空重',
width: 80,
editor: this.comboxCTNEF
},{
sortable: true,
dataIndex: 'CTNSTATUS',
header: '当前箱动态',
width: 80,
editor: this.comboxCTNSTATUS
},
{
sortable: true,
dataIndex: 'CTNSTATUSTIME',
header: '箱动态时间',
width: 80,
editor: {
xtype: 'datefield',
format: 'Y-m-d',
selectOnFocus: true
},
renderer: Ext.util.Format.dateRenderer('Y-m-d')
},
{
sortable: true,
dataIndex: 'PORT',
header: '当前地点',
width: 80,
editor: this.comboxPORTDetail
},
{
sortable: true,
dataIndex: 'YARD',
header: '当前场站',
width: 80,
editor: this.comboxYARDDetail
},
{
sortable: true,
dataIndex: 'REMARK',
header: '备注',
width: 80,
editor: {
xtype: 'textfield'
}
}
];
this.girdcolums = this.columns;
this.girdcolums = DsTruck.GetGridPanel(USERID, this.formname, this.girdcolums, 1); //使用者id表名中间column数组跳过一开始的几列
this.cellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
this.CheckBoxModel = Ext.create('Ext.selection.CheckboxModel');
this.formCtnrInBody = new Ext.grid.GridPanel({
store: this.storeCtnrDyna,
enableHdMenu: false,
region: 'center',
columnLines: true,
//layout: "border",
//title: '费用明细',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
plugins: [this.cellEditing],
selModel: this.CheckBoxModel,
selType: 'cellmodel',
features: [{
ftype: 'summary'//Ext.grid.feature.Summary表格汇总特性
}],
tbar: [{ xtype: 'label', text: '集装箱信息',
style: 'font-size:18px',
labelColor: '#099',
//style:'background-color: #4b9bf5',
x: '5%',
y: '5%'
}, {
text: '增加', id: "add1",
tooltip: '增加',
iconCls: "btnadddetail",
handler: function (button, event) {
this.onAddCtnrInClick(button, event);
},
scope: this
}, {
text: '删除', id: "del1",
tooltip: '删除',
iconCls: "btndeletedetail",
handler: function (button, event) {
this.onDelCtnrInClick(button, event);
},
scope: this
}, '-', {
// id: "saveandclose",
text: "保存",
iconCls: "btnsave",
handler: function (button, event) {
this.Save('0');
},
scope: this
}, '-', {
text: "保存列表样式",
menu: [{ text: "保存",
handler: function (button, event) {
_this.girdcolums = DsTruck.SaveGridPanel(USERID, _this.formname, _this.formCtnrInBody.columns, _this.girdcolums, 0, true); //使用者id表名中间column数组跳过一开始的几列
}
}, { text: "初始化",
handler: function (menu, event) {
_this.formCtnrInBody.reconfigure(_this.storeCtnrDyna, _this.columns);
_this.girdcolums = DsTruck.SaveGridPanel(USERID, _this.formname, _this.formCtnrInBody.columns, _this.columns, 0, true); //使用者id表名中间column数组跳过一开始的几列
}
}],
scope: this
}],
columns: this.girdcolums,
listeners: {
'beforeedit': function (o) {
}
}
});
//////////////////////////////////////////////明细<<<< CtnrIn列表 >>>>结束
//#endregion
//公共按钮Toolbar:panelBtn
this.panelBtn = new Ext.Panel({
region: "north",
tbar: [
{
// id: "saveandclose",
text: "保存",
iconCls: "btnsave",
handler: function (button, event) {
this.Save('0');
},
scope: this
}, {
// id: "saveandclose",
text: "保存并关闭",
handler: function (button, event) {
this.Save('1');
},
scope: this
}, '-',
{
// id: "saveandclose",
text: "关闭",
handler: function (button, event) {
window.close();
},
scope: this
}
]
}); //end 按钮Toolbar
this.panelTop;
//#region//布局
parentWin = window.parent.opener;
if (parentWin) {
var ret = parentWin.OprationSwap();
this.OpStatus = ret[0]; //edit
this.StoreList = ret[1];
this.EditRecord = ret[2]; //SelectedRecord
this.parentRecord = ret[3];
}
this.panelTop = new Ext.Panel({
region: "north",
height: 120,
items: [this.panelBtn, this.formEdit]
});
this.panelDetail = new Ext.Panel({
layout: "border",
region: 'center',
items: [this.formCtnrInBody]
});
Ext.apply(this, {
items: [this.panelTop, this.panelDetail]
});
this.InitData();
//#endregion
//集中绑定事件
}, //end initUIComponents
parentfunction: function (button, event) {
var ret1 = window.parent.opener.OprationSwap();
ret1[3]();
},
getLinenum: function (button, event) {
var _L = 0;
for (var i = 0; i < this.storeCtnrDyna.getCount(); i++) {
var _t = parseInt(this.storeCtnrDyna.getAt(i).get("LINENUM"));
if (_t > _L) { _L = _t; }
}
_L++;
return _L;
},
InitData: function () {
this.OpStatus = 'add';
var condition = '';
if (parentWin) {
var ret = parentWin.OprationSwap();
this.OpStatus = ret[0]; //edit
this.StoreList = ret[1];
this.EditRecord = ret[2]; //SelectedRecord
this.parentRecord = ret[3];
}
condition = " CTNGID='" + this.EditRecord.get('CTNGID') + "'";
this.LoadData(this.OpStatus, condition);
//this.LoadMustBe();
}, //end InitData
//载入数据
LoadData: function (OpStatus, condition) {
if (COMPANYID == "" || DEPTGID == "") {
alert("登录信息不全,请退出重新登录");
return;
}
this.OpStatus = OpStatus;
var basicForm = this.formEdit.getForm();
basicForm.findField("CTNGID").setValue(this.EditRecord.get('CTNGID'));
basicForm.findField("CNTRNO").setValue(this.EditRecord.get('CNTRNO'));
basicForm.findField("PORT").setValue(this.EditRecord.get('PORT'));
basicForm.findField("YARD").setValue(this.EditRecord.get('YARD'));
basicForm.findField("CTNEF").setValue(this.EditRecord.get('CTNEF'));
basicForm.findField("CTNSTATUS").setValue(this.EditRecord.get('CTNSTATUS'));
basicForm.findField("CTNSTATUSTIME").setValue(this.EditRecord.get('CTNSTATUSTIME'));
basicForm.findField("MBLNO").setValue(this.EditRecord.get('MBLNO'));
basicForm.findField("CTNSTATUSTIME").setValue(this.EditRecord.get('CTNSTATUSTIME'));
basicForm.findField("CTNALL").setValue(this.EditRecord.get('CTNALL'));
basicForm.findField("CNTRSOURCE").setValue(this.EditRecord.get('CNTRSOURCE'));
var CTNGID = this.EditRecord.get('CTNGID');
this.storeCtnrDyna.load({
params: { start: 0, limit: this.PageSize, sort: '', condition: "CTNGID='" + CTNGID + "'" },
waitMsg: "正在查询数据...",
scope: this
});
}, // end LoadDate
Save: function (type) {
var basicForm = this.formEdit.getForm();
var CTNGID = basicForm.findField('CTNGID').value;
if (!basicForm.isValid()) {
return;
}
var data = this.formEdit.getForm().getValues();
if (COMPANYID == "" || DEPTGID == "") {
Ext.MessageBox.alert("提示", "登录信息不全,请退出重新登录");
return;
}
var _this = this;
Ext.Msg.wait('正在更新动态数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在更新动态数据...',
url: '/MvcShipping/MsOpCtnr/SaveDyna',
scope: this,
async: false,
params: {
OpStatus: this.OpStatus,
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) {
var returnData = jsonresult.Data;
this.storeCtnrDyna.commitChanges();
if (type == '0') {
this.OpStatus = 'edit';
var CTNGID = _this.EditRecord.get('CTNGID');
this.storeCtnrDyna.load({
params: { start: 0, limit: this.PageSize, sort: '', condition: " CTNGID='" + CTNGID + "'" },
waitMsg: "正在查询数据...",
scope: this
});
} else if (type == '1') {//保存并关闭
window.close();
}
} 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');
}
});
},
//end save
getLinenum: function (button, event) {
var _L = 0;
for (var i = 0; i < this.storeWMSIN.getCount(); i++) {
var _t = parseInt(this.storeWMSIN.getAt(i).get("LINENUM"));
if (_t > _L) { _L = _t; }
}
_L++;
return _L;
},
//#endregion
});