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/MsOpPrice/MsOpPriceSeaeEdit.js

1395 lines
48 KiB
JavaScript

2 years ago
Ext.namespace('Shipping');
Shipping.MsOpPriceSeaeEdit = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.MsOpPriceSeaeEdit.superclass.constructor.call(this);
};
Ext.extend(Shipping.MsOpPriceSeaeEdit, Ext.Panel, {
ParentWin: null,
OpStatus: 'add',
StoreList: null,
editRecord: null,
editFactryRecord: null,
FactryStatus: 'add',
thispricetype: '',
initUIComponents: function () {
this.serialNo = 0;
this.workSerialNo = 0;
this.bodyDel = [];
//#region 编辑form
//枚举参照相关(编辑form)
//权限范围
this.storeLANE = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.Lane',
proxy: { url: '/CommMng/BasicDataRef/GetCodeLaneList' }
});
this.storeLANE.load();
this.comboxLANE = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '航线',
store: this.storeLANE,
name: 'LINE',
valueField: 'LANE',
displayField: 'LANE'
});
this.storeCodeDisport = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CodeDisportModel',
autoLoad: true,
proxy: { url: '/CommMng/BasicDataRef/GetCodeDisportList' }
});
this.storeCodeDisport.load();
this.comboxPORTDISCHARGE = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '目的港',
store: this.storeCodeDisport,
name: 'PORTDISCHARGE',
valueField: 'PORT',
displayField: 'PORT'
});
this.storePORTLOAD = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CodeDisportModel',
autoLoad: true,
proxy: { url: '/CommMng/BasicDataRef/GetCodeDisportList' }
});
this.storePORTLOAD.load();
this.comboxPORTLOAD = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '起运港',
store: this.storePORTLOAD,
name: 'PORTLOAD',
valueField: 'PORT',
displayField: 'PORT'
});
this.comboxTRANSPORT = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '中转港',
store: this.storeCodeDisport,
name: 'TRANSPORT',
valueField: 'PORT',
displayField: 'PORT'
});
//客户加载_船公司
this.storeCARRIER = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CustomRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetCustomRefList' }
});
this.storeCARRIER.load({ params: { condition: "ISCARRIER='1'"} });
//船公司
this.comboxCARRIER = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '船公司',
store: this.storeCARRIER,
forceSelection: true,
name: 'CARRIER',
valueField: 'CustName',
displayField: 'CodeAndName'
});
this.storeCountry = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsCodeCountry',
proxy: { url: '/MvcShipping/MsCodeCountry/GetDataList' }
});
this.storeCountry.load({ params: { condition: ""} });
this.comboxCountry = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '国家',
store: this.storeCountry,
name: 'COUNTRY',
valueField: 'COUNTRY',
displayField: 'COUNTRY'
});
this.StoreCTNSTATUS = Ext.create('DsExt.ux.RefEnumStore', {});
this.StoreCTNSTATUS.load({ params: { enumTypeId: 97029} });
this.comboxCTNSTATUS = Ext.create('DsExt.ux.RefTableCombox', {
store: this.StoreCTNSTATUS,
fieldLabel: '箱状态',
forceSelection: true,
name: 'CTNSTATUS',
valueField: 'EnumValueName',
displayField: 'EnumValueName'
});
//运输条款
this.storeSERVICE = Ext.create('DsExt.ux.RefTableStore', {
model: 'CODE_SERVICE',
proxy: { url: '/CommMng/BasicDataRef/GetCodeServiceList' }
});
this.storeSERVICE.load({ params: { condition: ""} });
this.comboxSERVICE = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '运输条款',
store: this.storeSERVICE,
forceSelection: true,
name: 'SERVICE',
valueField: 'SERVICE',
displayField: 'SERVICE'
});
this.StoreWEEKETD = Ext.create('Ext.data.Store', {
fields: ['ID', 'NAME']
});
this.StoreWEEKETD.add({ "ID": "周一", "NAME": "周一" });
this.StoreWEEKETD.add({ "ID": "周二", "NAME": "周二" });
this.StoreWEEKETD.add({ "ID": "周三", "NAME": "周三" });
this.StoreWEEKETD.add({ "ID": "周四", "NAME": "周四" });
this.StoreWEEKETD.add({ "ID": "周五", "NAME": "周五" });
this.StoreWEEKETD.add({ "ID": "周六", "NAME": "周六" });
this.StoreWEEKETD.add({ "ID": "周日", "NAME": "周日" });
this.comboxWEEKETD = Ext.create('Ext.ux.form.field.BoxSelect', {
fieldLabel: '船期',
autosize: true,
bodyPadding: 7,
name: 'WEEKETDAA',
flex: 2,
labelWidth: 90,
store: this.StoreWEEKETD,
queryMode: 'local',
triggerOnClick: false,
valueField: 'ID',
displayField: 'NAME'
});
//表参照相关(编辑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: 'OP',
name: 'OP', flex: 0, hidden: true, margins: '0'
}, {
fieldLabel: 'PRICETYPE',
name: 'PRICETYPE', flex: 0, hidden: true, margins: '0'
}, this.comboxLANE, this.comboxCountry, this.comboxPORTLOAD, this.comboxPORTDISCHARGE]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [this.comboxTRANSPORT, this.comboxSERVICE, this.comboxCTNSTATUS, {
fieldLabel: '航程',
name: 'VOYAGE'
}
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [this.comboxCARRIER, {
fieldLabel: '船期',
name: 'WEEKETD'
}, {
fieldLabel: '有效日期',
format: 'Y-m-d',
flex: 1,
xtype: 'datefield',
name: 'VALIDETD'
}, {
fieldLabel: '报价日期',
format: 'Y-m-d',
flex: 1,
xtype: 'datefield',
name: 'PRICEDATE'
}]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '录入人',
readOnly: true,
disabled: true,
name: 'INPUTBYREF'
}, {
fieldLabel: '录入日期',
readOnly: true,
disabled: true,
name: 'INPUTTIME'
}, {
fieldLabel: '备注',
flex: 2,
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: [{
id: 'btnEPrev',
text: "上一票",
// iconCls: "btnsave",
handler: function (button, event) {
this.PrevRecord();
},
scope: this
}, {
id: 'btnENext',
text: "下一票",
// iconCls: "btnsave",
handler: function (button, event) {
this.NextRecord();
},
scope: this
},
{
text: "保存",
iconCls: "btnsave",
id: 'btnsave',
handler: function (button, event) {
this.Save('0');
},
scope: this
},
{
text: "保存并关闭",
id: 'btnsaveandclose',
handler: function (button, event) {
this.Save('1');
},
scope: this
},
'-',
{
text: "保存并新建",
id: 'btnsaveandnew',
handler: function (button, event) {
this.Save('2');
},
scope: this
},
'-',
{
text: "复制并新建",
id: 'btncopyandsave',
handler: function (button, event) {
var basicForm = this.formEdit.getForm();
this.opStatus = 'add';
basicForm.findField('GID').setDisabled(false);
var field = basicForm.findField('GID');
var BSNO = NewGuid();
field.setValue(BSNO);
basicForm.findField('GID').setDisabled(true);
var field = basicForm.findField('INPUTBYREF');
field.setValue('');
var field = basicForm.findField('INPUTTIME');
field.setValue('');
for (var j = 0; j < this.storeBodyList.getCount(); j += 1) {
var memberbody = this.storeBodyList.getAt(j);
memberbody.set("LINKGID", '*');
memberbody.set("GID", NewGuid());
};
},
scope: this
}
]
}); //end 按钮Toolbar
//#endregion
this.thispricetype = PRICETYPE;
//#region 费用信息
this.storeBodyList = Ext.create('Ext.data.Store', {
model: 'MsOpPriceItems',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/MvcContainer/MsOpPrice/GetPriceItemsList',
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: 'GOODNAME'
});
this.storeFeeNameRef = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.FeeTypeRefModel',
proxy: { url: '/MvcShipping/MsChFee/GetFeeTypeRefList' }
});
this.storeFeeNameRef.load({ params: { condition: ""} });
this.comboxFeeNameRef = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storeFeeNameRef,
forceSelection: true,
name: 'FEENAME',
valueField: 'Name',
displayField: 'CodeAndName'
});
this.StoreCurr = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsFeeCurr',
proxy: { url: '/MvcShipping/MsChFee/GetFeeCurrList' }
});
this.StoreCurr.load({ params: { condition: ""} });
this.comboxCurr = Ext.create('DsExt.ux.RefTableCombox', {
store: this.StoreCurr,
forceSelection: true,
name: 'CURRENCY',
valueField: 'CURR',
displayField: 'CURR'
});
this.storeFeeUnit = Ext.create('DsExt.ux.RefTableStore', {
fields: ['UNIT'],
proxy: { url: '/MvcShipping/MsCodeFeeTemplate/GetFeeUnit' }
});
this.storeFeeUnit.load({ params: { condition: ""} });
this.comboxFeeUnit = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storeFeeUnit,
forceSelection: true,
name: 'UNIT',
valueField: 'UNIT',
displayField: 'UNIT'
});
this.storeCustomerNameRef = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CustomRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetCustomRefList' }
});
this.storeCustomerNameRef.load({ params: { condition: ""} });
this.comboxCustomerNameRef = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storeCustomerNameRef,
forceSelection: true,
name: 'CUSTOMERNAME',
valueField: 'CustName',
displayField: 'CodeAndName'
});
//明细表表格
this.gridListCellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
this.gridListBody = 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: '删除明细',
id: "btndeldetail",
iconCls: "btndeletedetail",
handler: function (button, event) {
this.onDeletePriceItemsClick();
},
scope: this
}, '-', {
text: '引入费用',
tooltip: '引入费用',
menu:
[
{ text: "历史引入",
handler: function (menu, event) {
_this.onHistryAddDetailClick(menu, event);
}
}
]
}],
columns: [{
sortable: true,
dataIndex: 'GID',
header: '编号',
hidden: true,
width: 0
}, {
sortable: true,
dataIndex: 'LINKGID',
header: '业务编号',
hidden: true,
width: 0
}, {
sortable: true,
dataIndex: 'ITEMSNO',
header: '序号',
editor: {
xtype: 'numberfield',
keyNavEnabled: false,
selectOnFocus: true,
hideTrigger: true,
mouseWheelEnabled: false,
enableKeyEvents: true
},
renderer: Ext.util.Format.numberRenderer('00'),
align: 'right',
width: 60
}, {
sortable: true,
dataIndex: 'CUSTOMERNAME',
header: '付款方',
editor: this.comboxCustomerNameRef,
width: 110
}, {
sortable: true,
dataIndex: 'FEENAME',
header: '费用名称',
editor: this.comboxFeeNameRef,
width: 140
}, {
sortable: true,
dataIndex: 'UNIT',
header: '标准',
editor: this.comboxFeeUnit,
width: 100
}, {
sortable: true,
dataIndex: 'CURRENCY',
header: '币别',
editor: this.comboxCurr,
width: 100
}, {
sortable: true,
dataIndex: 'UNITPRICE',
header: '单价',
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: 110
}, {
sortable: true,
dataIndex: 'REMARKS',
header: '备注',
editor: {
xtype: 'textfield',
selectOnFocus: true,
enableKeyEvents: true
},
width: 250
}]
});
this.gridListBody.on('edit', function (editor, e, eOpts) {
this.gridListAfterEdit(editor, e, eOpts);
}, this);
this.panelBody = new Ext.Panel({
title: '运价详细信息',
layout: "border",
region: 'center',
animate: true,
// autoScroll: true,
// containerScroll: true,
frame: false,
items: [this.gridListBody]
});
//#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",
id: 'btnEDelDoc',
handler: function (button, event) {
this.onDelFileClick(button, event);
},
scope: this
}, '-', {
text: '上传附件',
tooltip: '上传附件',
iconCls: "btnadddetail",
id: 'btnEAddDoc',
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
}, {
xtype: 'actioncolumn',
width: 50,
text: '图片预览', //操作
items: [{
icon: '/images/icons/btnSearch.gif', // Use a URL in the icon config
tooltip: '预览',
handler: function (grid, rowIndex, colIndex) {
var rec = grid.getStore().getAt(rowIndex);
var filePath = rec.get('Driect_URL') + '?a=' + Math.random();
var imgView = new Shipping.FileView({ filePath: filePath });
imgView.show();
}
}]
},
{
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: "north",
height: 150,
flex: 1.5,
title: '上传附件', //autoScroll: true,
frame: false,
split: true,
items: [this.gridDocList]
});
//#endregion
this.MainTab = new Ext.tab.Panel({
layout: "border",
region: "center", split: true,
items: [
this.panelBody
, this.panelDoc
]
});
//#region 布局
//控件布局
this.panelTop = new Ext.Panel({
layout: "border",
region: "north",
height: 190,
items: [this.panelBtn, this.formEdit]
});
Ext.apply(this, {
items: [this.panelTop, this.MainTab]
});
//#endregion
//绑定查询窗体
this.storeBodyList.on('beforeload', function (store) {
var acondition = " LINKGID='" + 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';
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/MsOpPrice/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);
this.formEdit.getForm().findField('PRICETYPE').setValue(PRICETYPE);
var acondition = "";
if (this.opStatus == 'edit')
acondition = " LINKGID='" + this.editRecord.get('GID') + "'";
else
acondition = " LINKGID='11111'";
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;
}
});
this.GetEditStatus();
} 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();
}
var j = 0;
var bodydatas = [];
for (var i = 0; i < this.storeBodyList.getCount(); i += 1) {
var member = this.storeBodyList.getAt(i);
j = j + 1;
bodydatas.push(member);
}
if (j == 0) {
Ext.Msg.show({ title: '提示', msg: '费用信息不能为空,请先录入费用信息!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
//
var jsonBody = ConvertRecordsToJsonAll(bodydatas);
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/MvcContainer/MsOpPrice/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('MsOpPrice', 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("LINKGID", this.editRecord.get('GID'));
memberbody.commit();
};
} else if (type == '1') {
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("LINKGID", this.editRecord.get('GID'));
memberbody.commit();
};
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
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 SerialNo = this.GetHandleSerialNo(this.storeBodyList);
//var newSerialno = DsGetNewSerialNo(this.storeBodyList, this.serialNo);
var record = Ext.create('MsOpPriceItems', {
GID: NewGuid(),
LINKGID: '*',
ITEMSNO: SerialNo,
FEENAME: '',
UNIT: '',
UNITPRICE: 0,
CURRENCY: '',
CHANGERATE: 0,
GOODSNAME: '',
REMARKS: ''
});
this.storeBodyList.add(record);
var n = this.storeBodyList.getCount();
this.gridListCellEditing.startEditByPosition({ row: n - 1, column: 1 });
},
GetHandleSerialNo: function (store) {
var result = 0;
if (result == 0) {
for (var i = 0; i < store.getCount(); i += 1) {
var member = store.getAt(i);
if (parseInt(member.data.ITEMSNO) > parseInt(result)) {
result = member.data.ITEMSNO;
}
}
}
result = parseInt(result) + 1;
return result;
},
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.GOODNAME);
} else {
e.record.set('GOODNAME', '');
}
}
},
onHistryAddDetailClick: function (menu, event, type) {
DsOpenEditWin("/MvcContainer/MsOpPrice/HistryFeeIndex", "历史引入费用");
},
onDeletePriceItemsClick: function () {
var selections = this.gridListBody.getSelectionModel().getSelection();
if (selections.length == 0) {
Ext.Msg.show({ title: '提示', msg: '请先选择要删除的费用信息!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
var bodyAddDatas = [];
for (var i = 0; i < selections.length; i++) {
var rec = selections[i];
if (rec.data.LINKGID == "*" || rec.data.LINKGID == "") {
this.storeBodyList.remove(selections[i]);
} else {
bodyAddDatas.push(rec);
}
}
if (bodyAddDatas.length == 0) return;
var record = selections[0];
Ext.MessageBox.confirm('提示', '确定删除该记录吗?', function (btn) {
if (btn == 'yes') {
var jsonbodyAddDatas = ConvertRecordsToJsonAll(bodyAddDatas);
Ext.Msg.wait('正在删除数据...');
Ext.Ajax.request({
waitMsg: '正在删除数据...',
url: '/MvcContainer/MsOpPrice/DeletePriceItems',
params: {
data: jsonbodyAddDatas
},
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
var acondition = " LINKGID='" + 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.formEdit.getForm().findField('GID').getValue();
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
PrevRecord: function () {
var modifystr = this.getIsModify();
if (modifystr != "") {
Ext.Msg.show({ title: '警告', msg: modifystr + '未保存,如果离开此页,将丢失未保存的更改 ', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
return;
}
var j = this.StoreList.indexOf(this.editRecord);
if (j == 0) {
Ext.Msg.show({ title: '警告', msg: '已是最前一票', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
return;
}
if (j == this.StoreList.count) {
Ext.Msg.show({ title: '警告', msg: '已是最后一票', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
return;
}
var condition = '';
j = j - 1;
this.editRecord = this.StoreList.getAt(j);
if (this.opStatus == 'edit') {
condition = "GID='" + this.editRecord.get('GID') + "'";
//this.storeBodyList.load({ params: { condition: condition} });
}
this.LoadData(this.opStatus, condition);
},
//#region 编辑时按钮等的状态
GetEditStatus: function () {
var canedit = false;
var op = this.formEdit.getForm().findField('OP').getValue();
var modustr = "";
if (PRICETYPE == "1") {
modustr = "modPriceSeae";
}
else if (PRICETYPE == "2") {
modustr = "modPriceSeai";
}
else if (PRICETYPE == "3") {
modustr = "modPriceAgent";
}
else if (PRICETYPE == "4") {
modustr = "modPriceYard";
}
this.StoreOpRange = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsOP',
proxy: { url: '/MvcShipping/MsBaseInfo/GetOpIDRang' }
});
_this = this;
this.StoreOpRange.load({ params: { optype: modustr },
callback: function (r, options, success) {
if (success) {
if (r.length != 0) {
var records = DsStoreQueryBy(_this.StoreOpRange, 'OPID', op);
if (records.getCount() > 0) {
canedit = true;
} else {
canedit = false;
}
} else { canedit = false; }
_this.setSaveBtnStatus(canedit);
}
}
});
},
setSaveBtnStatus: function (enable) {
var btnESave = Ext.getCmp('btnsave');
var btnESaveAndClose = Ext.getCmp('btnsaveandclose');
var btnESaveAndNew = Ext.getCmp('btnsaveandnew');
var btnECopyAndNew = Ext.getCmp('btncopyandsave');
if (enable) {
btnESave.enable();
btnESaveAndClose.enable();
btnESaveAndNew.enable();
btnECopyAndNew.enable();
} else {
btnESave.disable();
btnESaveAndClose.disable();
btnESaveAndNew.disable();
btnECopyAndNew.disable();
}
},
//#endregion
NextRecord: function () {
var modifystr = this.getIsModify();
if (modifystr != "") {
Ext.Msg.show({ title: '警告', msg: modifystr + '未保存,如果离开此页,将丢失未保存的更改 ', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
return;
}
var j = this.StoreList.indexOf(this.editRecord);
if (j == (this.StoreList.data.length - 1)) {
Ext.Msg.show({ title: '警告', msg: '已是最后一票', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
return;
}
var condition = '';
j = j + 1;
this.editRecord = this.StoreList.getAt(j);
if (this.opStatus == 'edit') {
condition = "GID='" + this.editRecord.get('GID') + "'";
//this.storeBodyList.load({ params: { condition: condition} });
}
this.LoadData(this.opStatus, condition);
},
getIsModify: function () {
var drmodify = this.storeBodyList.getModifiedRecords();
if (drmodify.length != 0)
return '运价详细信息';
if (panelEdit.formEdit.getForm().isDirty() == true)
return '运价信息';
else return '';
} //
});