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.

286 lines
8.5 KiB
JavaScript

///<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.JinKouSuYuanEdit = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.JinKouSuYuanEdit.superclass.constructor.call(this);
};
var GID = '';
Ext.extend(Shipping.JinKouSuYuanEdit, Ext.Panel, {
parentWin: null,
OpStatus: 'add',
StoreList: null,
EditRecord: null,
parentRecord: null,
PageSize: 30,
initUIComponents: function () {
this.formname = 'JinKouSuYuanEdit';
this.formnamerate = 'WMSNewINEditRate';
//#region form定义
//编辑form:formEdit
this.formEdit = Ext.widget('form', {
// layout: "border",
region: 'north',
height: 145,
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: 'GID',
hidden: true,
name: 'GID'
}, {
fieldLabel: '商品代码',
name: 'GOODCODE',
id: 'GOODCODE',
flex:1
},
{
fieldLabel: '商品名称',
name: 'GOODSNAME',
flex: 1
}, {
fieldLabel: '商品全称',
name: 'GOODSFULLNAME',
flex: 2
}
]
}//container_1 end
,
{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [
{
fieldLabel: '规格',
flex: 1,
name: 'GOODSMODEL'
}, {
fieldLabel: '原产国',
flex: 1,
name: 'GOODCOUNTRY'
}, {
fieldLabel: '描述',
flex: 2,
name: 'DESCRIP'
}]
},
{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [
{
fieldLabel: '图片',
name: 'IMGPATH',
id: "IMGPATH"
}
]
}
]
}
]
});
//#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.OPLBNAME = ret[4];
}
this.panelTop = new Ext.Panel({
region: "north",
height: 145,
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/JinKouSuYuan_ShangPin/GetData_CodeGoods',
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
Save: function (type) {
var basicForm = this.formEdit.getForm();
if (!basicForm.isValid()) {
return;
}
var data = this.formEdit.getForm().getValues();
var _this = this;
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/MvcShipping/JinKouSuYuan_ShangPin/Save',
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 data = jsonresult.Data;
Ext.Msg.show({ title: '保存成功', msg: jsonresult.Message, icon: Ext.Msg.OK, buttons: Ext.Msg.OK });
var condition = " GID='" + data + "'";
_this.LoadData("edit", condition);
} 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
});
}
}
});
}
//end save
});