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.

345 lines
11 KiB
JavaScript

11 months ago
///<reference path="../../../../Views/../TruckMng/Scripts/vswd-ext_2.0.2.js" />
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.MsOpSeaeEdiTemplateEdit = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.MsOpSeaeEdiTemplateEdit.superclass.constructor.call(this);
};
var GID = '';
Ext.extend(Shipping.MsOpSeaeEdiTemplateEdit, Ext.Panel, {
parentWin: null,
OpStatus: 'add',
StoreList: null,
EditRecord: null,
parentRecord: null,
PageSize: 30,
initUIComponents: function () {
this.formname = 'MsOpSeaeEdiTemplateEdit';
var _this = this;
//#region 国家
this.storeCountry = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CangDanCountry',
proxy: { url: '/CommMng/BasicDataRef/GetCountryList' }
});
this.storeCountry.load({ params: { condition: ""} });
this.comboxCountry = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '国家',
store: this.storeCountry,
queryParam: 'CodeName',
queryMode: 'remote',
width: 180,
name: 'COUNTRY',
valueField: 'CountryCode',
forceSelection: true,
displayField: 'CodeAndName',
listeners: {
beforequery: function (e) {
var combo = e.combo;
if (!e.forceAll) {
var value = e.query;
combo.store.filterBy(function (record, id) {
var text = record.get(combo.displayField);
return (text.indexOf(value) != -1);
});
combo.expand();
return false;
}
},
select: function (combo, records, eOpts) {
if (records.length > 0) {
_this.comboxLeiXing.setValue('');
var code = records[0].data.CountryCode;
_this.storeLeiXing.load({ params: { condition: "CountryCode = '" + code + "'"} });
}
}
}
});
//#endregion
//#region 类型
this.storeLeiXing = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CangDanCountry',
proxy: { url: '/CommMng/BasicDataRef/GetCountryTypeList' }
});
//this.storeLeiXingFa.load({ params: { condition: "CountryCode = 'CN'"} });
this.comboxLeiXing = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '类型',
store: this.storeLeiXing,
minChars: 0,
width: 180,
name: 'CODETYPE',
valueField: 'CompanyCodeType',
displayField: 'CompanyCodeType'
});
//#endregion
//#region 收发通类型
this.StoreSFT = Ext.create('Ext.data.Store', {
fields: ['ID', 'NAME']
});
this.StoreSFT.add({ "ID": "S", "NAME": "收货人" });
this.StoreSFT.add({ "ID": "F", "NAME": "发货人" });
this.StoreSFT.add({ "ID": "T", "NAME": "通知人" });
this.comboxSFT = Ext.create('DsExt.ux.RefTableCombox', {
store: this.StoreSFT,
fieldLabel: '类型',
forceSelection: true,
name: 'TYPE',
valueField: 'ID',
displayField: 'NAME'
});
//#endregion
//#region form定义
//编辑form:formEdit
this.formEdit = Ext.widget('form', {
// layout: "border",
region: 'west',
height: 500,
width: 650,
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: [{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: 'GID',
hidden: true,
name: 'gid'
}, {
fieldLabel: '模板名称',
name: 'TEMPLATENAME',
id: 'TEMPLATENAME',
flex: 2
}, this.comboxSFT, {
id: 'data',
hidden: true,
name: 'data'
}
]
}
,
{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '名称',
name: 'NAME',
flex: 1
}]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [
{
fieldLabel: '地址',
flex: 1,
name: 'ADDRESS'
}]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [this.comboxCountry, {
fieldLabel: '电话',
flex: 2,
name: 'TEL'
}]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [this.comboxLeiXing, {
fieldLabel: '代码',
flex: 2,
name: 'CODE'
}]
}
]
}
]
});
//#endregion
//公共按钮Toolbar:panelBtn
this.panelBtn = new Ext.Panel({
region: "north",
tbar: [
{
// id: "saveandclose",
text: "保存",
iconCls: "btnsave",
handler: function (button, event) {
this.Submit('0');
},
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.OPLBNAME = ret[4];
}
this.panelTop = new Ext.Panel({
region: "north",
layout: "border",
height: 350,
items: [this.panelBtn, this.formEdit]
});
Ext.apply(this, {
items: [this.panelTop]
});
this.InitData();
//#endregion
}, //end initUIComponents
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];
this.OPLBNAME = ret[4];
}
if (this.OpStatus == 'edit') {
GID = this.EditRecord.get('gid');
condition = " gid='" + GID + "'";
this.LoadData(this.OpStatus, condition);
}
else {
this.LoadData(this.OpStatus, condition);
}
}, //end InitData
//载入数据
LoadData: function (OpStatus, condition) {
this.OpStatus = OpStatus;
var _this = this;
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/MvcShipping/MsOpSeaeEdiTemplate/GetData',
params: {
OpStatus: 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;
} else {
var data = result.data;
this.formEdit.getForm().setValues(data);
}
}
},
scope: this
}); //request over
}, // end LoadDate
Submit: function (type) {
var _this = this;
var data = this.formEdit.getForm().getValues();
var datastr = Ext.JSON.encode(data);
this.formEdit.getForm().findField('data').setValue(datastr);
var basicForm = this.formEdit.getForm();
if (!basicForm.isValid()) {
return;
}
var frm = this.formEdit.getForm();
frm.submit({
waitMsg: '正在提交数据',
waitTitle: '提示',
url: '/MvcShipping/MsOpSeaeEdiTemplate/Submit?OpStatus=' + this.OpStatus,
method: 'POST',
success: function (form, action) {
Ext.Msg.alert('提示', '保存成功');
var jsonresult = Ext.JSON.decode(action.response.responseText);
var data = jsonresult.Data;
var condition = " GID='" + data + "'";
_this.LoadData("edit", condition);
},
failure: function (form, action) {
Ext.Msg.alert('提示', '保存出错');
}
});
}
//end save
});