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.
611 lines
19 KiB
JavaScript
611 lines
19 KiB
JavaScript
Ext.namespace('Shipping');
|
|
|
|
Shipping.MsCodeGoodsEdit = function (config) {
|
|
Ext.applyIf(this, config);
|
|
this.initUIComponents();
|
|
window.Shipping.MsCodeGoodsEdit.superclass.constructor.call(this);
|
|
};
|
|
|
|
Ext.extend(Shipping.MsCodeGoodsEdit, Ext.Panel, {
|
|
|
|
ParentWin: null,
|
|
OpStatus: 'add',
|
|
StoreList: null,
|
|
EditRecord: null,
|
|
feeType: 0,
|
|
StoreFee: null,
|
|
|
|
initUIComponents: function () {
|
|
this.serialNo = 0;
|
|
this.workSerialNo = 0;
|
|
this.bodyDel = [];
|
|
|
|
this.CodeGoodsEdit = getUrlParam('CodeGoodsEdit');
|
|
|
|
|
|
//#region 编辑form
|
|
|
|
//枚举参照相关(编辑form)
|
|
|
|
this.StoreGoodsType = Ext.create('DsExt.ux.RefTableStore', {
|
|
model: 'MsCodeGoodsType',
|
|
proxy: { url: '/MvcShipping/MsCodeGoods/GetGoodsType' }
|
|
});
|
|
this.StoreGoodsType.load({ params: { condition: ""} });
|
|
|
|
|
|
this.comboxGoodsType = Ext.create('DsExt.ux.RefTableCombox', {
|
|
fieldLabel: Zi.LAN.GOODSTYPE,
|
|
store: this.StoreGoodsType,
|
|
forceSelection: true,
|
|
name: 'GOODSTYPEGID',
|
|
valueField: 'GID',
|
|
displayField: 'GOODSTYPECODENAME'
|
|
});
|
|
|
|
|
|
this.storeISSTOP = Ext.create('Ext.data.Store', {
|
|
fields: ['DC', 'NAME']
|
|
});
|
|
this.storeISSTOP.add({ "DC": "是", "NAME": Zi.LAN.Yes });
|
|
this.storeISSTOP.add({ "DC": "否", "NAME": Zi.LAN.No });
|
|
|
|
this.comboxISSTOP = Ext.create('DsExt.ux.RefTableCombox', {
|
|
fieldLabel: Zi.LAN.ISSTOP ,
|
|
store: this.storeISSTOP,
|
|
valueField: 'DC',
|
|
displayField: 'NAME',
|
|
name: 'ISSTOP'
|
|
});
|
|
|
|
|
|
//表参照相关(编辑form)
|
|
|
|
//编辑form
|
|
this.formEdit = Ext.widget('form', {
|
|
region: 'center',
|
|
frame: true,
|
|
bodyPadding: 5,
|
|
autoScroll: true,
|
|
fieldDefaults: {
|
|
margins: '2 2 2 2',
|
|
labelAlign: 'right',
|
|
flex: 1,
|
|
labelWidth: 70,
|
|
msgTarget: 'qtip'
|
|
},
|
|
|
|
items: [
|
|
{//fieldset 1
|
|
xtype: 'fieldset',
|
|
defaultType: 'textfield',
|
|
layout: 'anchor',
|
|
defaults: {
|
|
anchor: '100%'
|
|
},
|
|
items: [ {
|
|
xtype: 'container',
|
|
layout: 'hbox',
|
|
defaultType: 'textfield',
|
|
items: [{
|
|
fieldLabel: Zi.LAN.GOODCODE,
|
|
name: 'GOODCODE',
|
|
flex: 0.5,
|
|
allowBlank: false
|
|
}, {
|
|
fieldLabel: Zi.LAN.GOODNO ,
|
|
flex: 0.5, name: 'GOODNO'
|
|
}, {
|
|
fieldLabel: Zi.LAN.GOODNAME,
|
|
flex: 2, name: 'GOODNAME'
|
|
}, {
|
|
fieldLabel: Zi.LAN.ENAME,
|
|
flex: 1, name: 'ENAME'
|
|
}]
|
|
|
|
}, {
|
|
xtype: 'container',
|
|
layout: 'hbox',
|
|
defaultType: 'textfield',
|
|
items: [{
|
|
fieldLabel: Zi.LAN.ARRATE,
|
|
name: 'ARRATE'
|
|
}, {
|
|
fieldLabel: Zi.LAN.APRATE,
|
|
flex: 1, name: 'APRATE'
|
|
}, {
|
|
fieldLabel: Zi.LAN.AROUTRATE,
|
|
flex: 1, name: 'AROUTRATE'
|
|
}, {
|
|
fieldLabel: Zi.LAN.APOUTRATE,
|
|
flex: 1, name: 'APOUTRATE'
|
|
}]
|
|
|
|
},{
|
|
xtype: 'container',
|
|
layout: 'hbox',
|
|
defaultType: 'textfield',
|
|
items: [{
|
|
fieldLabel: 'GID',
|
|
name: 'GID', flex: 0, hidden: true, margins: '0'
|
|
}, {
|
|
fieldLabel: 'CORPID',
|
|
name: 'CORPID', flex: 0, hidden: true, margins: '0'
|
|
}, {
|
|
fieldLabel: 'CREATEUSER',
|
|
name: 'CREATEUSER', flex: 0, hidden: true, margins: '0'
|
|
} , {
|
|
fieldLabel: Zi.LAN.CREATEUSERREF,
|
|
readOnly: true,
|
|
name: 'CREATEUSERREF'
|
|
}, {
|
|
fieldLabel: Zi.LAN.CREATETIME,
|
|
readOnly: true,
|
|
name: 'CREATETIME'
|
|
}, this.comboxGoodsType, this.comboxISSTOP
|
|
]
|
|
}, {
|
|
xtype: 'container',
|
|
layout: 'hbox',
|
|
defaultType: 'textfield',
|
|
items: [{
|
|
fieldLabel: Zi.LAN.DESCRIP,
|
|
name: 'DESCRIP'
|
|
}]
|
|
|
|
}
|
|
]//end items(fieldset 1)
|
|
}//end fieldset 1
|
|
]//end root items
|
|
}); //end this.formEdit
|
|
|
|
//#endregion
|
|
|
|
//#region 按钮Toolbar
|
|
this.panelBtn = new Ext.Panel({
|
|
region: "north",
|
|
tbar: [
|
|
{
|
|
text: Zi.LAN.Save,
|
|
iconCls: "btnsave",
|
|
handler: function (button, event) {
|
|
this.Save('0');
|
|
},
|
|
scope: this
|
|
},
|
|
{
|
|
text: Zi.LAN.SaveClose ,
|
|
handler: function (button, event) {
|
|
this.Save('1');
|
|
},
|
|
scope: this
|
|
},
|
|
'-',
|
|
{
|
|
text: Zi.LAN.SaveNew,
|
|
handler: function (button, event) {
|
|
this.Save('2');
|
|
},
|
|
scope: this
|
|
},
|
|
'-',
|
|
{
|
|
text: Zi.LAN.CopyNew,
|
|
handler: function (button, event) {
|
|
|
|
var basicForm = this.formEdit.getForm();
|
|
this.opStatus = 'add';
|
|
basicForm.findField('GID').setDisabled(false);
|
|
var field = basicForm.findField('GID');
|
|
field.setValue(NewGuid());
|
|
basicForm.findField('GID').setDisabled(true);
|
|
field = basicForm.findField('CREATEUSERREF');
|
|
field.setValue('');
|
|
field = basicForm.findField('GOODNAME');
|
|
field.setValue('');
|
|
|
|
for (var j = 0; j < this.storeBodyList.getCount(); j += 1) {
|
|
var memberbody = this.storeBodyList.getAt(j);
|
|
memberbody.set("LINKGID", '*');
|
|
memberbody.commit();
|
|
};
|
|
},
|
|
scope: this
|
|
}
|
|
]
|
|
}); //end 按钮Toolbar
|
|
|
|
//#endregion
|
|
|
|
//#region 明细表
|
|
|
|
//明细表表格相关
|
|
|
|
|
|
//明细表-数据集
|
|
this.storeBodyList = Ext.create('Ext.data.Store', {
|
|
model: 'MsCodeGoodsDetail',
|
|
remoteSort: true,
|
|
proxy: {
|
|
type: 'ajax',
|
|
url: '/MvcShipping/MsCodeGoods/GetBodyList',
|
|
reader: {
|
|
root: 'data',
|
|
totalProperty: 'totalCount'
|
|
}
|
|
}
|
|
});
|
|
|
|
//明细表表格
|
|
this.gridListCellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
|
|
clicksToEdit: 1
|
|
});
|
|
|
|
|
|
this.gridList = new Ext.grid.GridPanel({
|
|
store: this.storeBodyList,
|
|
enableHdMenu: false,
|
|
region: 'center',
|
|
loadMask: { msg: Zi.LAN.LoadData },
|
|
trackMouseOver: true,
|
|
disableSelection: false,
|
|
plugins: [this.gridListCellEditing],
|
|
selType: 'cellmodel',
|
|
tbar: [{
|
|
text: Zi.LAN.adddetail,
|
|
tooltip: Zi.LAN.adddetail,
|
|
iconCls: "btnadddetail",
|
|
handler: function (button, event) {
|
|
this.onAddDetailClick(button, event, 1);
|
|
},
|
|
scope: this
|
|
}, '-', {
|
|
text: Zi.LAN.deldetail,
|
|
tooltip: Zi.LAN.deldetail,
|
|
iconCls: "btndeletedetail",
|
|
handler: function (button, event) {
|
|
this.onDelDetailClick(button, event, 1);
|
|
},
|
|
scope: this
|
|
}],
|
|
columns: [{
|
|
sortable: true,
|
|
dataIndex: 'GID',
|
|
header: 'GID',
|
|
hidden: true,
|
|
width: 100
|
|
}, {
|
|
sortable: true,
|
|
dataIndex: 'LINKGID',
|
|
header: 'LINKGID',
|
|
hidden: true,
|
|
width: 100
|
|
}, {
|
|
sortable: true,
|
|
dataIndex: 'GOODSDETAILNAME',
|
|
header: Zi.LAN.GOODSDETAILDESCRP,
|
|
editor: {
|
|
xtype: 'textfield',
|
|
selectOnFocus: true,
|
|
enableKeyEvents: true
|
|
|
|
},
|
|
width: 150
|
|
}, {
|
|
sortable: true,
|
|
dataIndex: 'GOODSDETAILPKGS',
|
|
header: Zi.LAN.GOODSDETAILPKGS,
|
|
editor: {
|
|
xtype: 'numberfield',
|
|
keyNavEnabled: false,
|
|
selectOnFocus: true,
|
|
hideTrigger: true,
|
|
mouseWheelEnabled: false,
|
|
enableKeyEvents: true
|
|
},
|
|
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
|
|
try {
|
|
var lsValue = usMoney(value, 2, '', false);
|
|
if (lsValue != "NaN") {
|
|
value = lsValue; if (parseFloat(lsValue) < 0) {
|
|
return '<SPAN style="COLOR: red">' + lsValue + '</SPAN>';
|
|
}
|
|
}
|
|
else {
|
|
return value;
|
|
}
|
|
}
|
|
catch (e) {
|
|
return value;
|
|
}
|
|
return value;
|
|
},
|
|
align: 'right',
|
|
width: 80
|
|
}, {
|
|
sortable: true,
|
|
dataIndex: 'REMARK',
|
|
header: Zi.LAN.REMARK ,
|
|
editor: {
|
|
xtype: 'textfield',
|
|
selectOnFocus: true,
|
|
enableKeyEvents: true
|
|
|
|
},
|
|
width: 150
|
|
}
|
|
]
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
this.panelService = new Ext.Panel({
|
|
title: Zi.LAN.GOODSDETAIL,
|
|
layout: "border",
|
|
region: 'center',
|
|
margin: '5 10',
|
|
|
|
items: [this.gridList]
|
|
});
|
|
|
|
|
|
this.paneldetail = new Ext.Panel({
|
|
layout: "border",
|
|
region: "center",
|
|
items: [
|
|
this.panelService
|
|
]
|
|
});
|
|
|
|
//#endregion 明细表
|
|
|
|
//#region 布局
|
|
//控件布局
|
|
this.panelTop = new Ext.Panel({
|
|
layout: "border",
|
|
region: "north",
|
|
height: 180,
|
|
items: [this.panelBtn, this.formEdit]
|
|
});
|
|
|
|
Ext.apply(this, {
|
|
items: [this.panelTop, this.paneldetail]
|
|
});
|
|
|
|
//#endregion
|
|
|
|
//绑定查询窗体
|
|
|
|
//初始化数据
|
|
|
|
|
|
this.ParentWin = window.parent.opener;
|
|
this.InitData();
|
|
|
|
|
|
//绑定事件
|
|
this.gridList.on('edit', function (editor, e, eOpts) {
|
|
this.gridAfterEdit(editor, e, eOpts);
|
|
}, this);
|
|
|
|
this.storeBodyList.on('beforeload', function (store) {
|
|
var cargoid = 0;
|
|
if (this.opStatus == 'edit') {
|
|
cargoid = this.editRecord.get('GID');
|
|
|
|
}
|
|
var sql = " LINKGID='" + cargoid + "'";
|
|
Ext.apply(store.proxy.extraParams, { condition: sql });
|
|
}, this);
|
|
|
|
|
|
}, //end initUIComponents
|
|
|
|
InitData: function () {
|
|
this.opStatus = 'add';
|
|
var condition = '';
|
|
if (this.ParentWin) {
|
|
var ret = this.ParentWin.OprationSwap();
|
|
this.opStatus = ret[0];
|
|
this.StoreList = ret[1];
|
|
this.editRecord = ret[2];
|
|
}
|
|
|
|
if (this.opStatus == 'edit')
|
|
condition = " GID='" + this.editRecord.get('GID') + "'";
|
|
|
|
this.LoadData(this.opStatus, condition);
|
|
|
|
}, //end InitData
|
|
|
|
LoadData: function (opstatus, condition) {
|
|
this.serialNo = 0;
|
|
this.workSerialNo = 0;
|
|
this.bodyDel = [];
|
|
|
|
this.opStatus = opstatus;
|
|
Ext.Ajax.request({
|
|
waitMsg: Zi.LAN.NowSelect,
|
|
url: '/MvcShipping/MsCodeGoods/GetData',
|
|
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: Zi.LAN.Prompt,
|
|
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);
|
|
|
|
} else {
|
|
Ext.MessageBox.alert(Zi.LAN.FuWuQiError, response.responseText);
|
|
}
|
|
},
|
|
scope: this
|
|
});
|
|
|
|
var billno = '*';
|
|
var cargoid = 0;
|
|
if (this.opStatus == 'edit') {
|
|
cargoid = this.editRecord.get('GID');
|
|
|
|
}
|
|
this.storeBodyList.load({ params: { condition: " LINKGID='" + cargoid + "'"} });
|
|
}, // end LoadDate
|
|
|
|
|
|
Save: function (type) {
|
|
var basicForm = this.formEdit.getForm();
|
|
|
|
if (!basicForm.isValid()) {
|
|
return;
|
|
}
|
|
|
|
//判断表格数据是否合法
|
|
if (!validateEditorGridPanel(this.gridList)) {
|
|
return;
|
|
}
|
|
|
|
basicForm.findField('GID').setDisabled(false);
|
|
var data = basicForm.getValues();
|
|
basicForm.findField('GID').setDisabled(true);
|
|
if (this.opStatus == 'add') {
|
|
data.DM_ID = NewGuid();
|
|
}
|
|
var bodydatas = [];
|
|
for (var i = 0; i < this.storeBodyList.getCount(); i += 1) {
|
|
var member = this.storeBodyList.getAt(i);
|
|
bodydatas.push(member);
|
|
}
|
|
|
|
var jsonBody = ConvertRecordsToJsonAll(bodydatas);
|
|
|
|
|
|
Ext.Msg.wait(Zi.LAN.Msg_Saving);
|
|
Ext.Ajax.request({
|
|
waitMsg: Zi.LAN.Msg_Saving,
|
|
url: '/MvcShipping/MsCodeGoods/Save',
|
|
scope: this,
|
|
params: {
|
|
opstatus: this.opStatus,
|
|
data: Ext.JSON.encode(data),
|
|
body: jsonBody
|
|
},
|
|
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('MsCodeGoods', 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';
|
|
|
|
basicForm.findField('GID').setDisabled(true);
|
|
|
|
for (var j = 0; j < this.storeBodyList.getCount(); j += 1) {
|
|
var memberbody = this.storeBodyList.getAt(j);
|
|
memberbody.set("GID", this.editRecord.get('GID'));
|
|
memberbody.commit();
|
|
};
|
|
|
|
} else if (type == '1') {
|
|
window.close();
|
|
} else {
|
|
this.LoadData('add', '');
|
|
basicForm.findField('GID').setDisabled(false);
|
|
}
|
|
} else {
|
|
Ext.Msg.show({ title: Zi.LAN.Error, msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
|
|
}
|
|
} else {
|
|
Ext.Msg.show({ title: '请重试',
|
|
msg: Zi.LAN.FuWuQiError,
|
|
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
|
|
});
|
|
}
|
|
}
|
|
});
|
|
}, //end save
|
|
|
|
onAddDetailClick: function (button, event, type) {
|
|
this.addDetail(type);
|
|
}, //end onAddDetailClick
|
|
|
|
onDelDetailClick: function (button, event, type) {
|
|
this.deleteDetail(type);
|
|
}, //onDelDetailClick
|
|
|
|
|
|
|
|
gridAfterEdit: function (editor, e, eOpts) {
|
|
|
|
},
|
|
|
|
addDetail: function (type) {
|
|
var newSerialno = 0;
|
|
|
|
store = this.storeBodyList;
|
|
|
|
var record = Ext.create('MsCodeGoodsDetail', {
|
|
GID: '',
|
|
LINKGID: '',
|
|
GOODSDETAILNAME: "",
|
|
GOODSDETAILPKGS: 0
|
|
|
|
});
|
|
|
|
store.add(record);
|
|
|
|
|
|
this.gridListCellEditing.startEditByPosition({ row: 2, column: 1 });
|
|
|
|
},
|
|
|
|
|
|
deleteDetail: function (type) {
|
|
|
|
var selectedRecords = this.gridList.selModel.getSelection();
|
|
|
|
for (var i = 0; i < selectedRecords.length; i++) {
|
|
var rec = selectedRecords[i];
|
|
|
|
this.storeBodyList.remove(rec);
|
|
}
|
|
|
|
|
|
}
|
|
});
|
|
|
|
|