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/MsCodeMsds/MsCodeMsdsEdit.js

1529 lines
53 KiB
JavaScript

Ext.namespace('Shipping');
Shipping.MsCodeMSDSEdit = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.MsCodeMSDSEdit.superclass.constructor.call(this);
};
Ext.extend(Shipping.MsCodeMSDSEdit, Ext.Panel, {
ParentWin: null,
OpStatus: 'add',
StoreList: null,
editRecord: null,
editFactryRecord: null,
FactryStatus: 'add',
initUIComponents: function () {
this.serialNo = 0;
this.workSerialNo = 0;
this.bodyDel = [];
//#region 编辑form
//枚举参照相关(编辑form)
this.storeDCLASS = Ext.create('DsExt.ux.RefEnumStore', {});
this.storeDCLASS.load({ params: { enumTypeId: 97027} });
this.comboxDCLASS = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storeDCLASS,
fieldLabel: '危险品等级',
name: 'DCLASS',
forceSelection: true,
valueField: 'EnumValueName',
displayField: 'EnumValueName'
});
this.comboxSDCLASS = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storeDCLASS,
fieldLabel: '副危险品等级',
name: 'SDCLASS',
forceSelection: true,
valueField: 'EnumValueName',
displayField: 'EnumValueName'
});
this.StorePACKINGGROUP = Ext.create('Ext.data.Store', {
fields: ['PACKINGGROUP']
});
this.StorePACKINGGROUP.add({ "PACKINGGROUP": "I" });
this.StorePACKINGGROUP.add({ "PACKINGGROUP": "II" });
this.StorePACKINGGROUP.add({ "PACKINGGROUP": "III" });
this.comboxPACKINGGROUP = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: 'PACKING GROUP',
store: this.StorePACKINGGROUP,
labelWidth: 100, forceSelection: true,
name: 'PACKINGGROUP',
valueField: 'PACKINGGROUP',
displayField: 'PACKINGGROUP'
});
this.storeIMDG = Ext.create('DsExt.ux.RefEnumStore', {});
this.storeIMDG.load({ params: { enumTypeId: 97026} });
this.comboxIMDG = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storeIMDG,
fieldLabel: 'IMDG',
name: 'IMDG',
valueField: 'EnumValueName',
displayField: 'EnumValueName'
});
//表参照相关(编辑form)
//编辑form
this.formEdit = Ext.widget('form', {
region: 'center',
frame: true,
bodyPadding: 5,
autoScroll: true,
trackResetOnLoad: true,
fieldDefaults: {
margins: '2 2 2 2',
labelAlign: 'right',
flex: 1,
labelWidth: 90,
msgTarget: 'qtip'
},
items: [
{//fieldset 1
xtype: 'fieldset',
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: 'GID',
name: 'GID', flex: 0, hidden: true, margins: '0'
}, {
fieldLabel: 'COMPANYID',
name: 'COMPANYID', flex: 0, hidden: true, margins: '0'
}, {
fieldLabel: '品名',
allowBlank: true,
flex: 1,
name: 'GOODNAME'
}, {
fieldLabel: '贸易品名',
name: 'TRADEGOODSNAME'
}, {
fieldLabel: '化学品名',
name: 'CHEMICALGOODSNAME'
}, {
fieldLabel: '化学品名(中文)',
name: 'CHEMICALCGOODSNAME'
}, {
fieldLabel: 'CAS NO',
flex: 1,
name: 'CASNO'
}]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: 'UN',
flex: 1,
name: 'UNNO'
}, this.comboxDCLASS, this.comboxSDCLASS, this.comboxPACKINGGROUP, {
fieldLabel: '是否海洋污染物',
flex: 0.5,
inputValue: true,
xtype: 'checkboxfield',
name: 'ISPOLLUTEOCEAN'
}, {
fieldLabel: '是否存在危险',
inputValue: true,
flex:0.5,
xtype: 'checkboxfield',
name: 'ISDANGEROUS'
}
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '熔点',
name: 'MELTINGPOINTB',
regex: /^(-?\d+)(\.\d+)?$/,
regexText: '请输入正确的数值!',
flex: 0.6
}, {
xtype: 'label',
text: '℃~'
// html: "℃~"
}, {
name: 'MELTINGPOINTE',
regex: /^(-?\d+)(\.\d+)?$/,
regexText: '请输入正确的数值!',
flex: 0.28
}, {
xtype: 'label',
text: '℃~'
// html: "℃"
}, {
fieldLabel: '沸点',
name: 'BOILINGPOINTB',
regex: /^(-?\d+)(\.\d+)?$/,
regexText: '请输入正确的数值!',
flex: 0.6
}, {
xtype: 'label',
html: "℃~"
}, {
name: 'BOILINGPOINTE',
regex: /^(-?\d+)(\.\d+)?$/,
regexText: '请输入正确的数值!',
flex: 0.28
}, {
xtype: 'label',
html: "℃"
}, {
fieldLabel: '闪点',
regex: /^(-?\d+)(\.\d+)?$/,
regexText: '请输入正确的数值!',
name: 'FLASHPOINTB',
flex: 0.6
}, {
xtype: 'label',
html: "℃~"
}, {
name: 'FLASHPOINTE',
regex: /^(-?\d+)(\.\d+)?$/,
regexText: '请输入正确的数值!',
flex: 0.28
}, {
xtype: 'label',
html: "℃"
}, {
fieldLabel: '密度',
name: 'DENSITY'
}, {
fieldLabel: 'PH',
name: 'PH'
}]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [this.comboxIMDG, {
fieldLabel: '稳定性',
name: 'STABILITY',
flex: 2
}, {
fieldLabel: '反应性',
name: 'REACTIVE',
flex: 2
}]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '备注',
name: 'REMARKS'
}]
}
]//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: "保存",
iconCls: "btnsave",
handler: function (button, event) {
this.Save('0');
},
scope: this
},
{
text: "保存并关闭",
handler: function (button, event) {
this.Save('1');
},
scope: this
},
'-',
{
text: "保存并新建",
handler: function (button, event) {
this.Save('2');
},
scope: this
}
]
}); //end 按钮Toolbar
//#endregion
this.storeListFactry = Ext.create('Ext.data.Store', {
model: 'MsCodeMSDSFactry',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/MvcContainer/MsCodeMSDS/GetFactryList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.girdcolums = [{
sortable: true, hidden: true,
dataIndex: 'GID',
header: 'GID',
width: 80
}, {
sortable: true, hidden: true,
dataIndex: 'MSDSID',
header: 'MSDSID',
width: 80
},
{
sortable: true,
dataIndex: 'FACTORYNAME',
header: '工厂名称',
width: 150
},
{
sortable: true,
dataIndex: 'CUSTOMERNAME',
header: '委托单位',
width: 150
},
{
sortable: true,
dataIndex: 'FACTORYADDR',
header: '工厂地址',
width: 150
},
{
sortable: true,
dataIndex: 'CONSIGNEE',
header: '收货人',
width: 150
},
{
sortable: true,
dataIndex: 'CONSIGNEEADDR',
header: '收货人地址',
width: 150
}
];
//定义Grid
this.gridListFactry = new Ext.grid.GridPanel({
store: this.storeListFactry,
enableHdMenu: false,
region: 'west',
width: 500,
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
columns: this.girdcolums,
bbar: Ext.create('Ext.PagingToolbar', {
store: this.storeListFactry,
displayInfo: true,
displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录',
emptyMsg: "没有数据"
})
});
_this = this;
this.gridListFactry.addListener('itemclick', function (dataview, record, item, index, e, b) {
_this.editFactryRecord = record;
_this.FactryStatus = 'edit';
_this.LoadFactryData("edit", "GID='" + record.data.GID + "'");
}, this);
//委托单位
this.storeCustCode = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CustomRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetCustomRefList' }
});
this.storeCustCode.load({ params: { condition: "ISCONTROLLER='1'"} });
this.comboxCustCode = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '委托单位',
store: this.storeCustCode,
forceSelection: true,
name: 'CUSTOMERNAME',
valueField: 'CustName',
displayField: 'CodeAndName'
});
//委托单位
this.storeCustCodeFactry = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CustomRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetCustomRefList' }
});
this.storeCustCodeFactry.load({ params: { condition: "ISCONTROLLER='1'"} });
this.comboxCustCodeFactry = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '工厂名称',
store: this.storeCustCodeFactry,
forceSelection: true,
name: 'FACTORYNAME',
valueField: 'CustName',
displayField: 'CodeAndName'
});
//人员信息加载
this.storeOpCode = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.UserRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetUserLinkRefList' }
});
this.storeOpCode.load();
//客服
this.comboxSALE = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '揽货人',
store: this.storeOpCode,
forceSelection: true,
name: 'SALE',
valueField: 'UserName',
displayField: 'CodeAndName'
});
//编辑form
this.formDetail = Ext.widget('form', {
region: 'center',
frame: true,
bodyPadding: 5,
autoScroll: true,
trackResetOnLoad: true,
fieldDefaults: {
margins: '2 2 2 2',
labelAlign: 'right',
flex: 1,
labelWidth: 90,
msgTarget: 'qtip'
},
items: [
{//fieldset 1
xtype: 'fieldset',
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: 'GID',
name: 'GID', flex: 0, hidden: true, margins: '0'
}, {
fieldLabel: 'MSDSID',
name: 'MSDSID', flex: 0, hidden: true, margins: '0'
}, this.comboxCustCodeFactry]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [this.comboxCustCode, {
fieldLabel: '联系方式',
name: 'LINKTEL'
}, this.comboxSALE]
}, {
xtype: 'textareafield',
grow: true,
fieldLabel: '工厂地址',
height: 50,
name: 'FACTORYADDR',
anchor: '100%'
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '收货人',
name: 'CONSIGNEE'
}]
}, {
xtype: 'textareafield',
grow: true,
fieldLabel: '收货人地址',
height: 50,
name: 'CONSIGNEEADDR',
anchor: '100%'
}, {
xtype: 'textareafield',
grow: true,
fieldLabel: '备注',
height: 50,
name: 'REMARKS',
anchor: '100%'
}
]//end items(fieldset 1)
}//end fieldset 1
]//end root items
}); //end this.formDetail
this.panelBtnDetail = new Ext.Panel({
region: "north",
tbar: [{
text: "新建",
handler: function (button, event) {
this.LoadFactryData('add', '');
},
scope: this
}, '-', {
id: 'btnESave',
text: "保存",
iconCls: "btnsave",
handler: function (button, event) {
this.SaveFactry('0');
},
scope: this
}, {
id: 'btnESaveAndNew',
text: "保存并新建",
handler: function (button, event) {
this.SaveFactry('2');
},
scope: this
}, '-',
{
text: "删除",
iconCls: "btndelete",
handler: function (button, event) {
this.onDeleteFactryClick(button, event);
},
scope: this
}]
}); //end 按钮Toolbar
//#endregion
this.panelfactry = new Ext.Panel({
title: '工厂详细信息',
layout: "border",
region: 'center',
animate: true,
autoScroll: true,
// containerScroll: true,
frame: false,
items: [this.panelBtnDetail, this.gridListFactry, this.formDetail]
});
//#region 互斥
this.storeBodyList = Ext.create('Ext.data.Store', {
model: 'MsCodeMSDSRejection',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/MvcContainer/MsCodeMSDS/GetRejectionList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.storeListGood = Ext.create('Ext.data.Store', {
model: 'MsCodeMSDS',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/MvcContainer/MsCodeMSDS/GetDataList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.storeListGood.load({ params: { condition: ""} });
this.comboxGoods = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storeListGood,
forceSelection: true,
name: 'REJECTID',
valueField: 'GID',
displayField: 'GOODNAMEANDCNAME'
});
//明细表表格
this.gridListCellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
this.gridListGoods = new Ext.grid.GridPanel({
store: this.storeBodyList,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
plugins: [this.gridListCellEditing],
selType: 'cellmodel',
tbar: [{
text: '增加明细',
tooltip: '增加明细',
id: "btnadddetail",
iconCls: "btnadddetail",
handler: function (button, event) {
this.addDetail();
},
scope: this
}, '-', {
text: '保存明细',
tooltip: '保存明细',
iconCls: "btnsave",
handler: function (button, event) {
this.onPostDetailClick();
},
scope: this
}, '-', {
text: '删除明细',
tooltip: '删除明细',
id: "btndeldetail",
iconCls: "btndeletedetail",
handler: function (button, event) {
this.onDeleteRejectionClick();
},
scope: this
}],
columns: [{
sortable: true,
dataIndex: 'GID',
header: '编号',
hidden: true,
width: 0
}, {
sortable: true,
dataIndex: 'MSDSID',
header: '业务编号',
hidden: true,
width: 0
}, {
dataIndex: 'REJECTID',
header: '品名',
width: 320,
editor: this.comboxGoods,
renderer: function (value, p, record) {
return record.data.GOODNAME;
}
}]
});
this.gridListGoods.on('edit', function (editor, e, eOpts) {
this.gridListAfterEdit(editor, e, eOpts);
}, this);
this.panelRejection = new Ext.Panel({
title: '互斥商品信息',
layout: "border",
region: 'west',
width:500,
animate: true,
// autoScroll: true,
// containerScroll: true,
frame: false,
items: [this.gridListGoods]
});
//#endregion
//#region 明细表-单据图片档案管理
_this = this;
this.storeDocList = Ext.create('Ext.data.Store', {
model: 'ReceiptDocmb',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/Import/ReceiptDoc/GetDocList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
//明细表表格
this.DocListCellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
this.DocCM = Ext.create('Ext.selection.CheckboxModel');
this.gridDocList = new Ext.grid.GridPanel({
store: this.storeDocList,
enableHdMenu: false,
region: 'center',
// width: 350,
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
plugins: [this.DocListCellEditing],
selModel: this.DocCM,
selType: 'cellmodel',
tbar: [{
text: '删除',
tooltip: '删除',
iconCls: "btndeletedetail",
handler: function (button, event) {
this.onDelFileClick(button, event);
},
scope: this
}, '-', {
text: '上传附件',
tooltip: '上传附件',
iconCls: "btnadddetail",
handler: function (button, event) {
this.onUpLoadFileClick(button, event);
},
scope: this
}],
columns: [{
sortable: true, hidden: true,
dataIndex: 'GID',
header: 'GID',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'R_GID',
header: 'R_GID',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'BSNO',
header: 'BSNO',
width: 80
},
{
sortable: true,
dataIndex: 'URL',
header: '文件名',
width: 140,
renderer: function (value, p, record) {
return '<a href="' + record.data.Driect_URL + '" style=' + '"text-decoration:none"' + '>' + value + '</a>';
}
},
{
sortable: true, hidden: true,
dataIndex: 'Driect_URL',
header: 'Driect_URL',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'MODIFIEDUSER',
header: 'MODIFIEDUSER',
width: 80
},
{
sortable: true,
dataIndex: 'MODIFIEDUSERRef',
header: '上传人',
width: 80
},
{
sortable: true,
dataIndex: 'MODIFIEDTIME',
header: '上传时间',
width: 135
}
]
});
this.panelDoc = new Ext.Panel({
id: "panelDoc",
layout: "border",
region: "center",
title: '相关图片', //autoScroll: true,
frame: false,
split: true,
items: [this.gridDocList]
});
//#endregion
this.panelDetail = new Ext.Panel({
layout: "border",
region: "center",
title: '图片及互斥',
frame: false,
split: true,
items: [this.panelRejection, this.panelDoc]
});
//#region 布局
//控件布局
this.panelTop = new Ext.Panel({
layout: "border",
region: "north",
height: 218,
items: [this.panelBtn, this.formEdit]
});
this.tabWTpanel = new Ext.TabPanel({
activeTab: 0,
autoWidth: true,
border: true,
frame: false,
region: 'center',
enableTabScroll: true,
items:
[
this.panelfactry,
this.panelDetail
]
});
Ext.apply(this, {
items: [this.panelTop, this.tabWTpanel]
});
//#endregion
this.storeListFactry.on('beforeload', function (store) {
var acondition = " MSDSID='" + this.editRecord.get('GID') + "'";
Ext.apply(store.proxy.extraParams, { condition: acondition });
}, this);
this.storeBodyList.on('beforeload', function (store) {
var acondition = " MSDSID='" + this.editRecord.get('GID') + "'";
Ext.apply(store.proxy.extraParams, { condition: acondition });
}, this);
this.storeDocList.on('beforeload', function (store) {
var xcondition = " BSNO='" + this.editRecord.get('GID') + "'";
Ext.apply(store.proxy.extraParams, { condition: xcondition });
}, this);
//绑定查询窗体
this.ParentWin = window.parent.opener;
//初始化数据
this.InitData();
//绑定事件
}, //end initUIComponents
InitData: function () {
this.opStatus = 'add';
this.FactryStatus = '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: '正在查询主表数据...',
url: '/MvcContainer/MsCodeMSDS/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: '提示',
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);
var acondition = " MSDSID='" + this.editRecord.get('GID') + "'";
this.storeListFactry.load({ params: { condition: acondition },
callback: function (r, options, success) {
if (success) {
if (this.storeListFactry.getCount() > 0) {
var member = this.storeListFactry.getAt(0);
this.LoadFactryData("edit", "GID='" + member.data.GID + "'");
} else {
this.LoadFactryData('add', '');
}
}
},
scope: this
});
this.storeBodyList.load({ params: { condition: acondition} });
var xcondition = " BSNO='" + this.editRecord.get('GID') + "'";
_this.Loading = true;
_this.storeDocList.load({
params: { condition: xcondition },
waitMsg: "正在查询数据...",
scope: this,
callback: function () {
_this.Loading = false;
}
});
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
}, // end LoadDate
Save: function (type) {
var basicForm = this.formEdit.getForm();
if (!basicForm.isValid()) {
return;
}
basicForm.findField('GID').setDisabled(false);
var data = basicForm.getValues();
basicForm.findField('GID').setDisabled(true);
if (this.opStatus == 'add') {
data.GID = NewGuid();
}
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/MvcContainer/MsCodeMSDS/Save',
scope: this,
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.formEdit.getForm().setValues(returnData);
if (this.opStatus == 'add') {
var arrNewRecords = this.StoreList.add(returnData);
this.editRecord = arrNewRecords[0];
}
else if (this.opStatus == 'edit') {
this.editRecord = returnData;
this.editRecord.commit();
}
if (type == '0') {
this.opStatus = 'edit';
basicForm.findField('GID').setDisabled(true);
} else if (type == '1') {
window.close();
} else {
this.LoadData('add', '');
basicForm.findField('GID').setDisabled(false);
}
} 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
LoadFactryData: function (opstatus, condition) {
this.serialNo = 0;
this.FactryStatus = opstatus;
if (this.opStatus == "add") {
Ext.Msg.show({ title: '提示', msg: '商品信息未保存,无法添加工厂信息!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
// if (this.FactryStatus == 'add') {
// var MSDSID = this.formEdit.getForm().findField('GID').getValue();
// this.formDetail.getForm().reset();
// this.formDetail.getForm().findField('MSDSID').setValue(MSDSID);
// } else {
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/MvcContainer/MsCodeMSDS/GetFactryData',
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;
}
data = result.data;
this.formDetail.getForm().reset();
this.formDetail.getForm().setValues(data);
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
// }
}, // end LoadDate
//#region 保存
SaveFactry: function (type) {
var basicForm = this.formDetail.getForm();
if (!basicForm.isValid()) {
return;
}
this.formDetail.getForm().findField('GID').setDisabled(false);
this.formDetail.getForm().findField('MSDSID').setDisabled(false);
var data = this.formDetail.getForm().getValues(false, false, false);
this.formDetail.getForm().findField('GID').setDisabled(true);
this.formDetail.getForm().findField('MSDSID').setDisabled(true);
var MSDSID = this.formEdit.getForm().findField('GID').getValue();
//
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/MvcContainer/MsCodeMSDS/SaveFactry',
scope: this,
params: {
opstatus: this.FactryStatus,
data: Ext.JSON.encode(data),
MSDSID: MSDSID
},
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.formDetail.getForm().reset();
this.formDetail.getForm().setValues(returnData);
//
if (this.FactryStatus == 'add') {
var arrNewRecords = this.storeListFactry.add(returnData);
this.editFactryRecord = arrNewRecords[0];
}
else if (this.FactryStatus == 'edit') {
var editp = Ext.create('MsCodeMSDSFactry', returnData);
this.editFactryRecord.fields.each(function (field) {
if (field.persist) {
name = field.name;
if (name != 'id')
this.editFactryRecord.set(name, editp.get(name));
}
}, this);
this.editFactryRecord.commit();
}
if (type == '0') {
this.FactryStatus = 'edit';
} else if (type == '2') {
this.LoadFactryData('add', '');
}
} 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
//#endregion
onDeleteFactryClick: function () {
var selections = this.gridListFactry.getSelectionModel().getSelection();
if (selections.length == 0) {
Ext.Msg.show({ title: '提示', msg: '请先选择要删除的工厂信息!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
var record = selections[0];
Ext.MessageBox.confirm('提示', '确定删除该记录吗?', function (btn) {
if (btn == 'yes') {
var bodyAddDatas = [];
for (var i = 0; i < selections.length; i++) {
var rec = selections[i];
bodyAddDatas.push(rec);
}
var jsonbodyAddDatas = ConvertRecordsToJsonAll(bodyAddDatas);
Ext.Msg.wait('正在删除数据...');
Ext.Ajax.request({
waitMsg: '正在删除数据...',
url: '/MvcContainer/MsCodeMSDS/Deletefactry',
params: {
data: jsonbodyAddDatas
},
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
var acondition = " MSDSID='" + this.editRecord.get('GID') + "'";
this.storeListFactry.load({ params: { condition: acondition} });
this.storeListFactry.remove(record);
if (this.storeListFactry.getCount() > 0) {
var member = this.storeListFactry.getAt(0);
this.editFactryRecord = member;
this.LoadFactryData("edit", "GID='" + member.data.GID + "'");
} else {
this.LoadFactryData('add', '');
}
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 });
},
success: function (response, options) {
},
scope: this
}); //end Ext.Ajax.request
}
}, this);
}, //
addDetail: function () {
if (this.opStatus == "add") {
Ext.Msg.show({ title: '提示', msg: '商品信息未保存,无法添加工厂信息!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
var MSDSID = this.formEdit.getForm().findField('GID').getValue();
//var newSerialno = DsGetNewSerialNo(this.storeBodyList, this.serialNo);
var record = Ext.create('MsCodeMSDSRejection', {
GID: '*',
MSDSID: MSDSID,
REJECTID: '',
GOODNAME: '',
REMARKS: ''
});
this.storeBodyList.add(record);
var n = this.storeBodyList.getCount();
this.gridListCellEditing.startEditByPosition({ row: n - 1, column: 1 });
},
onPostDetailClick: function (button, event) {
var bodyDrChFeeDatas = [];
var i;
var MSDSID = this.formEdit.getForm().findField('GID').getValue();
for (i = 0; i < this.storeBodyList.getCount(); i += 1) {
var memberyf = this.storeBodyList.getAt(i);
bodyDrChFeeDatas.push(memberyf);
};
var jsonChFeeBody = ConvertRecordsToJsonAll(bodyDrChFeeDatas);
_thisfee = this;
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/MvcContainer/MsCodeMSDS/SaveDetail',
scope: this,
params: {
body: jsonChFeeBody,
MSDSID: MSDSID
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
var acondition = " MSDSID='" + MSDSID + "'";
this.storeBodyList.load({ params: { condition: acondition} });
} 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
gridListAfterEdit: function (editor, e, eOpts) {
if (e.value == e.originalValue) return;
if (e.field == 'REJECTID') {
var selectrecords = DsStoreQueryBy(this.storeListGood, 'GID', e.value);
if (selectrecords.getCount() > 0) {
var selectdata = selectrecords.getAt(0).data;
e.record.set('GOODNAME', selectdata.GOODNAMEANDCNAME);
} else {
e.record.set('GOODNAME', '');
}
}
},
onDeleteRejectionClick: function () {
var selections = this.gridListGoods.getSelectionModel().getSelection();
if (selections.length == 0) {
Ext.Msg.show({ title: '提示', msg: '请先选择要删除的互斥信息!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
var record = selections[0];
Ext.MessageBox.confirm('提示', '确定删除该记录吗?', function (btn) {
if (btn == 'yes') {
var bodyAddDatas = [];
for (var i = 0; i < selections.length; i++) {
var rec = selections[i];
bodyAddDatas.push(rec);
}
var jsonbodyAddDatas = ConvertRecordsToJsonAll(bodyAddDatas);
Ext.Msg.wait('正在删除数据...');
Ext.Ajax.request({
waitMsg: '正在删除数据...',
url: '/MvcContainer/MsCodeMSDS/DeleteRejection',
params: {
data: jsonbodyAddDatas
},
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
var acondition = " MSDSID='" + this.editRecord.get('GID') + "'";
this.storeBodyList.load({ params: { condition: acondition} });
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 });
},
success: function (response, options) {
},
scope: this
}); //end Ext.Ajax.request
}
}, this);
},
//#region 上传图片
onDelFileClick: function (button, event) {
var feeGidSql = '';
var selectedRecords = [];
selectedRecords = this.DocCM.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) {
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
if (rec.data.GID == "*") //如果是新增但没有保存的数据,没有必要提交到后台
{
this.storeDocList.remove(selectedRecords[i]);
} else {
var feeGId = "'" + rec.data.GID + "'";
if (feeGidSql == '') {
feeGidSql = feeGId;
} else {
feeGidSql = feeGidSql + "," + feeGId;
}
}
}
}
_this = this;
Ext.Msg.wait('正在删除数据...');
if (feeGidSql != '') {
Ext.Ajax.request({
waitMsg: '正在删除数据...',
url: '/MvcShipping/MsOpReceipt/DeleteUploadFile',
params: {
data: feeGidSql
},
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
for (var i = 0; i < selectedRecords.length; i++) {
this.storeDocList.remove(selectedRecords[i]);
}
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 });
},
success: function (response, options) {
},
scope: this
}); //end Ext.Ajax.request
} else {
Ext.Msg.show({ title: '提示', msg: "删除成功!", icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
}
}
}, this);
}
, onUpLoadFileClick: function (button, event) {
var billno = this.editRecord.get("GID");
me = this;
var imgform = new Ext.FormPanel({
region: 'center',
labelWidth: 40,
frame: true,
bodyStyle: 'padding:5px 5px 0',
autoScroll: true,
border: false,
fileUpload: true,
items: [{
xtype: 'fileuploadfield',
id: 'LoadFile',
name: 'LoadFile',
emptyText: '请选择文件',
fieldLabel: '文件',
buttonText: '选择文件',
allowBlank: false,
buttonCfg:
{
iconCls: 'uploaddialog'
},
anchor: '98%'
}],
buttons: [{
text: '上传',
type: 'submit',
handler: function () {
var UserFilePath = Ext.getCmp('LoadFile').getValue();
// if (!CheckFileExt(UserFilePath, /.jpg|.gif|.png|.bmp|.pdf/i)) {
// Ext.Msg.show({ title: '错误', msg: '请确认你上传的文件为图片文件!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
// return;
// }
if (!imgform.form.isValid()) { return; }
imgform.form.submit({
url: '/MvcShipping/MsOpReceipt/UploadFile',
waitMsg: '正在上传',
method: 'POST',
submitEmptyText: false,
async: false,
params: {
CUSTNO: billno,
BSNO: billno
},
success: function (form, action) {
win.close(this);
Ext.Msg.show({ title: '提示', msg: '上传成功!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
var condition = billno;
var condition2 = " BSNO='" + condition + "' ";
me.Loading = true;
me.storeDocList.load({
params: { condition: condition2 },
waitMsg: "正在查询数据...",
scope: this,
callback: function () {
me.Loading = false;
}
});
},
failure: function (form, action) {
form.reset();
if (action.failureType == Ext.form.Action.SERVER_INVALID)
Ext.MessageBox.alert('警告', action.result.errors.msg);
}
});
}
}, {
text: '关闭',
type: 'submit',
handler: function () {
win.close(this);
}
}]
});
var win = new Ext.Window({
title: "上传文件",
width: 360,
height: 120,
modal: true,
resizable: false,
border: false,
items: imgform
});
win.show();
}
,
//#endregion
getIsModify: function () {
var drmodify = this.storeBodyList.getModifiedRecords();
if (drmodify.length != 0)
return '商品互斥信息';
if (panelEdit.formDetail.getForm().isDirty() == true)
return '工厂信息';
if (panelEdit.formEdit.getForm().isDirty() == true) {
return '商品信息';
}
else return '';
} //
});