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/MvcContainer/Viewsjs/MsOpCtnr/MsCodeCtnrEdit.js

793 lines
26 KiB
JavaScript

Ext.namespace('Shipping');
Shipping.MsCodeCtnrEdit = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.MsCodeCtnrEdit.superclass.constructor.call(this);
};
Ext.extend(Shipping.MsCodeCtnrEdit, Ext.Panel, {
parentWin: null,
OpStatus: 'add',
StoreList: null,
EditRecord: null,
parentRecord: null,
initUIComponents: function () {
this.formname = 'MsCodeCtnrEdit';
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'
});
Ext.regModel('CTNALLMODEL',
{
fields: [{ name: 'CTN' }]
});
this.storeCodeCtn = Ext.create('DsExt.ux.RefTableStore', {
model: 'CTNALLMODEL',
proxy: { url: '/MvcContainer/MsOpCtnr/GetCodeCtnList' }
});
this.storeCodeCtn.load();
this.comboxCTNALL = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '箱型',
store: this.storeCodeCtn,
name: 'CTNALL',
valueField: 'CTN',
displayField: 'CTN'
});
//箱动态类型
//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'
//});
this.storeOWNERCTN = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CustomRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetCustomRefList' }
});
this.storeOWNERCTN.load({ params: { condition: "1=1" } });
this.comboxOWNERCTN = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '箱东',
store: this.storeOWNERCTN,
forceSelection: true,
name: 'OWNERCTN',
valueField: 'CustName',
displayField: 'CodeAndName'
});
this.storeNOTYPE = Ext.create('Ext.data.Store', {
fields: ['FType', 'NAME']
});
this.storeNOTYPE.add({ "FType": 'NEW', "NAME": "NEW" });
this.storeNOTYPE.add({ "FType": 'USED', "NAME": "USED" });
this.comboxNOTYPE = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: 'NEW/USED',
store: this.storeNOTYPE,
valueField: 'FType',
displayField: 'NAME',
forceSelection: true,
name: 'NOTYPE'
});
this.storeISLOCKBOX = Ext.create('Ext.data.Store', {
fields: ['FType', 'NAME']
});
this.storeISLOCKBOX.add({ "FType": '1', "NAME": "是" });
this.storeISLOCKBOX.add({ "FType": '0', "NAME": "否" });
this.comboxISLOCKBOX = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '是否有锁盒',
store: this.storeISLOCKBOX,
valueField: 'FType',
displayField: 'NAME',
forceSelection: true,
name: 'ISLOCKBOX'
});
this.storeISSLOT = Ext.create('Ext.data.Store', {
fields: ['FType', 'NAME']
});
this.storeISSLOT.add({ "FType": '1', "NAME": "是" });
this.storeISSLOT.add({ "FType": '0', "NAME": "否" });
this.comboxISSLOT = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storeISSLOT,
fieldLabel: '否有叉车槽',
valueField: 'FType',
displayField: 'NAME',
forceSelection: true,
name: 'ISSLOT'
});
this.storeISSTOP = Ext.create('Ext.data.Store', {
fields: ['FType', 'NAME']
});
this.storeISSTOP.add({ "FType": true, "NAME": "是" });
this.storeISSTOP.add({ "FType": false, "NAME": "否" });
this.comboxISSTOP = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storeISSTOP,
fieldLabel: '否有停用',
valueField: 'FType',
displayField: 'NAME',
forceSelection: true,
name: 'ISSTOP'
});
this.StoreCTNSTATUS = Ext.create('Ext.data.Store', {
fields: ['CTNSTATUS']
});
this.StoreCTNSTATUS.add({ "CTNSTATUS": "可用" });
this.StoreCTNSTATUS.add({ "CTNSTATUS": "不可用" });
this.comboxCTNSTATUS = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '箱状态',
store: this.StoreCTNSTATUS,
forceSelection: true,
name: 'CTNSTATUS',
valueField: 'CTNSTATUS',
displayField: 'CTNSTATUS'
});
this.storeCNTRSOURCE = Ext.create('DsExt.ux.RefEnumStore', {});
this.storeCNTRSOURCE.load({ params: { enumTypeId: 97015 } });
this.comboxCNTRSOURCE = Ext.create('DsExt.ux.RefEnumCombox', {
store: this.storeCNTRSOURCE,
fieldLabel: '箱源',
name: 'CNTRSOURCE',
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: 80,
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'
}, this.comboxCTNALL, this.comboxCNTRSOURCE,this.comboxCTNSTATUS,
this.comboxOWNERCTN,
this.comboxCTNEF
]
}
, {//container_1
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [this.comboxNOTYPE,{
fieldLabel: '颜色',
flex: 2,
name: 'CTNCOLOR'
}, this.comboxISLOCKBOX,
this.comboxISSLOT,
this.comboxISSTOP
]
}
,
{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [
{
fieldLabel: '当前动态', flex: 1,
readOnly:true,
name: 'CURSTATUS'
},
{
fieldLabel: '动态日期',
name: 'CTNSTATUSTIME',
format: 'Y-m-d',
labelWidth: 90,
readOnly: true,
xtype: 'datefield',
enableKeyEvents: true
}, {
fieldLabel: '提单号', flex: 1,
readOnly: true,
name: 'MBLNO'
}, {
fieldLabel: '所在港口', flex: 1,
readOnly: true,
name: 'PORT'
}, {
fieldLabel: '所在场站', flex: 1,
readOnly: true,
name: 'YARD'
}
]
},
{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [
{
fieldLabel: '备注', flex: 1,
name: 'REMARK'
}
]
}
]
}
]
});
//#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
//#region 还箱维护
this.storeCodeDisport = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CodeDisportModel',
proxy: { url: '/CommMng/BasicDataRef/GetCodeDisportListRm' }
});
this.comboxPORT = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storeCodeDisport,
queryMode: 'remote',
minChars: 2,
queryParam: 'PORT',
name: 'PREPARDAT',
valueField: 'PORT',
displayField: 'PORT'
});
this.storeYARDRETURN = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CustomRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetCustomRefListYARD' }
});
this.storeYARDRETURN.load();
//
this.comboxYARDRETURN = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storeYARDRETURN,
queryMode: 'remote',
minChars: 0,
queryParam: 'CODENAME',
name: 'YARD',
valueField: 'CustName',
displayField: 'CodeAndName'
});
this.storeCustomerNameRef = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CustomRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetCustomRefListRm' }
});
this.comboxCustomerNameRef = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storeCustomerNameRef,
forceSelection: true,
queryMode: 'remote',
minChars: 1,
queryParam: 'CODENAME',
lazyRender: false,
name: 'CustomerName',
valueField: 'CustName',
displayField: 'CodeAndName',
listeners: {
scope: this,
'focus': function (_this, eOpts) {
var selections = this.gridListCtnReturn.getSelectionModel().getSelection(); //获得选中的项
var strCustomerName = selections[0].get('AGENT');
var recordCustCode = Ext.create('DsShipping.ux.CustomRefModel', {
GId: NewGuid(),
CustCode: strCustomerName,
CustName: strCustomerName,
CodeAndName: strCustomerName,
DESCRIPTION: strCustomerName
});
this.storeCustomerNameRef.add(recordCustCode);
}
}
});
this.storeCtnReturnList = Ext.create('Ext.data.Store', {
model: 'CtnrReturn',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/MvcContainer/MsOpCtnr/GetCtnReturnList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
//明细表表格
this.gridListCtnReturnCellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
this.CheckBoxCtnReturnModel = Ext.create('Ext.selection.CheckboxModel');
this.gridListCtnReturn = new Ext.grid.GridPanel({
store: this.storeCtnReturnList,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
plugins: [this.gridListCtnReturnCellEditing],
selModel: this.CheckBoxCtnReturnModel,
selType: 'cellmodel',
tbar: [{
text: '增加明细',
tooltip: '增加明细',
id: "btnaddreturndetail",
iconCls: "btnadddetail",
handler: function (button, event) {
this.addReturnDetail();
},
scope: this
}, '-', {
text: '删除明细',
tooltip: '删除明细',
id: "btndelreturndetail",
iconCls: "btndeletedetail",
handler: function (button, event) {
this.onDeleteReturnClick();
},
scope: this
}],
columns: [{
sortable: true,
dataIndex: 'GID',
header: '编号',
hidden: true,
width: 0
}, {
sortable: true,
dataIndex: 'BSNO',
header: '业务编号',
hidden: true,
width: 0
}, {
dataIndex: 'PORT',
header: '还箱港口',
width: 320,
editor: this.comboxPORT
}, {
dataIndex: 'YARD',
header: '还箱场站',
width: 120,
editor: this.comboxYARDRETURN
}, {
dataIndex: 'AGENT',
header: '还箱代理',
width: 120,
editor: this.comboxCustomerNameRef
}]
});
this.gridListCtnReturn.on('edit', function (editor, e, eOpts) {
this.gridListAfterEdit(editor, e, eOpts);
}, this);
this.panelCtnReturn = new Ext.Panel({
title: '还箱信息维护',
layout: "border",
region: 'center',
animate: true,
frame: false,
items: [this.gridListCtnReturn]
});
//#endregion
this.panelTop = new Ext.Panel({
region: "north",
height: 160,
items: [this.panelBtn, this.formEdit]
});
//#region//布局
parentWin = window.parent.opener;
Ext.apply(this, {
items: [this.panelTop, this.panelCtnReturn]
});
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];
}
if (this.OpStatus == 'edit')
condition = " c.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;
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/MvcContainer/MsOpCtnr/GetCtnr',
params: {
handle: OpStatus,
condition: condition
},
callback: function (options, success, response) {
if (success) {
var result = Ext.JSON.decode(response.responseText);
if (!result.Success) {
Ext.Msg.show({
title: '提示',
msg: result.Message,
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.OK
});
return;
}
var data = result.data;
this.formEdit.getForm().reset();
this.formEdit.getForm().setValues(data);
if (this.OpStatus == 'edit') {
this.storeCtnReturnList.load({
params: { start: 0, limit: this.PageSize, sort: '', condition: " BSNO='" + data.CTNGID + "'" },
waitMsg: "正在查询数据...",
scope: this
});
}
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
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 CtnReturndatas = [];
for (var i = 0; i < this.storeCtnReturnList.getCount(); i += 1) {
var member = this.storeCtnReturnList.getAt(i);
CtnReturndatas.push(member);
}
var CtnReturnBody = ConvertRecordsToJsonAll(CtnReturndatas);
var _this = this;
Ext.Msg.wait('正在更新动态数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在更新动态数据...',
url: '/MvcContainer/MsOpCtnr/SaveCtn',
scope: this,
async: false,
params: {
OpStatus: this.OpStatus,
data: Ext.JSON.encode(data),
body: CtnReturnBody
},
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.formEdit.getForm().setValues(returnData);
if (this.OpStatus == 'add') {
var arrNewRecords = this.StoreList.add(returnData);
this.EditRecord = arrNewRecords[0];
}
else if (this.OpStatus == 'edit') {
var editp = Ext.create('MsOpCtnrDetail', returnData);
this.EditRecord.fields.each(function (field) {
if (field.persist) {
name = field.name;
if (name != 'id')
this.EditRecord.set(name, editp.get(name));
}
}, this);
this.EditRecord.commit();
}
if (type == '0') {
this.OpStatus = 'edit';
var CTNGID = _this.EditRecord.get('CTNGID');
} 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
addReturnDetail: function (button, event) {
var store = null;
var record = null;
var newid = NewGuid();
record = Ext.create('CtnrReturn', {
BSNO: '*',
GID: newid,
PORT: '',
YARD: '',
AGENT: '',
REMARK: ''
});
this.storeCtnReturnList.add(record);
var n = this.storeCtnReturnList.getCount();
this.gridListCtnReturnCellEditing.startEditByPosition({ row: n - 1, column: 2 });
},
onDeleteReturnClick: function (button, event, type) {
var bsno = this.formEdit.getForm().findField('BSNO').getValue();
var selectedRecords = [];
selectedRecords = this.CheckBoxCtnReturnModel.selected.items;
if (selectedRecords.length == 0) {
Ext.Msg.show({ title: '提示', msg: '请先选择要删除的还箱信息!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
Ext.MessageBox.confirm('提示', '确定要删除选中的还箱信息吗?', function (btn) {
if (btn == 'yes') {
if (selectedRecords.length > 0) {
var CtnrIndatas = [];
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
if (rec.data.BSNO == "" || rec.data.BSNO == "*")//如果是新增但没有保存的数据,没有必要提交到后台
{
this.storeCtnReturnList.remove(selectedRecords[i]);
} else {
CtnrIndatas.push(rec);
}
}
var CtnrInBody = ConvertRecordsToJsonAll(CtnrIndatas);
if (CtnrIndatas.length > 0) {
Ext.Msg.wait('正在删除...');
Ext.Ajax.request({
waitMsg: '正在删除...', //'正在删除数据...',
url: '/MvcContainer/MsOpCtnr/DeleteReturnDetail',
params: {
data: CtnrInBody,
bsno: bsno
},
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
this.storeCtnReturnList.reload();
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 });
},
scope: this
}); //end Ext.Ajax.request
}
}
}
}, this);
},
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
});