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/TruckMng/Viewsjs/MsWlBs/MsWlBsNewEdit.js

1416 lines
52 KiB
JavaScript

//2013-03-15 删除固定费用
Ext.namespace('DsTruck');
DsTruck.MsWlBsNewEdit = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.DsTruck.MsWlBsNewEdit.superclass.constructor.call(this);
};
Ext.extend(DsTruck.MsWlBsNewEdit, Ext.Panel, {
ParentWin: null,
OpStatus: 'add',
StoreList: null,
EditRecord: null,
initUIComponents: function () {
this.ctnSerialNo = 0;
this.ctnBodyDel = [];
this.fixSerialNo = 0;
this.fixBodyDel = [];
this.feeSerialNo = 0;
this.feeBodyDel = [];
//#region 编辑Form
//枚举参照相关(编辑form)
this.storeBsType = Ext.create('DsExt.ux.RefEnumStore', {});
this.storeBsType.load({ params: { enumTypeId: 99025} });
this.comboxBsType = Ext.create('DsExt.ux.RefEnumCombox', {
fieldLabel: '托单类型',
store: this.storeBsType,
name: 'BsType'
});
this.storeBsStatus= Ext.create('DsExt.ux.RefEnumStore', {});
this.storeBsStatus.load({ params: { enumTypeId: 99029} });
this.comboxBsStatus = Ext.create('DsExt.ux.RefEnumCombox', {
fieldLabel: '托单状态',
store: this.storeBsStatus,
name: 'BsStatus'
});
//表参照相关(编辑form)
this.storeCustContact = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsTruckMng.ux.CustomContactRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetCustomContactList' }
});
this.comboxCustContact = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '客户联系人',
store: this.storeCustContact,
name: 'CustLikeManName',
valueField: 'Name',
displayField: 'Name',
listeners: {
scope: this,
'select': function (combo, records, eOpts) {
if (records.length > 0) {
var recs = DsStoreQueryBy(this.storeCustContact, 'Name', records[0].data.Name);
var custTel = this.formEdit.getForm().findField('CustTel');
if (recs.getCount() > 0) {
var data = recs.getAt(0).data;
custTel.setValue(data.Tel);
} else {
custTel.setValue('');
}
}
}
}
});
this.storeCustCode = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsTruckMng.ux.CustomRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetCustomRefList' }
});
this.storeCustCode.load({ params: { condition: "ISCONTROLLER='1'"} });
this.storeCustCode.on('beforeload', function (store) {
Ext.apply(store.proxy.extraParams, { condition: "ISCONTROLLER='1'" });
}, this);
this.comboxCustCode = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '委托单位代码',
typeAhead: true,
store: this.storeCustCode,
name: 'CustCode',
valueField: 'CustCode',
displayField: 'CodeAndName',
//queryMode: 'remote',
// displayTpl: Ext.create('Ext.XTemplate',
// '<tpl for=".">',
// '{CustCode}-{CustName}',
// '</tpl>'
// ),
// tpl: Ext.create('Ext.XTemplate',
// '<tpl for=".">',
// '<div class="x-boundlist-item">{CustCode} - {CustName}</div>',
// '</tpl>'
// ),
listeners: {
scope: this,
'select': function (combo, records, eOpts) {
if (records.length > 0) {
var recs = DsStoreQueryBy(this.storeCustCode, 'CustCode', records[0].data.CustCode);
var custname = this.formEdit.getForm().findField('CustName');
var custLikeManName = this.formEdit.getForm().findField('CustLikeManName');
var custTel = this.formEdit.getForm().findField('CustTel');
var billRises1 = this.formEdit.getForm().findField('BillRises1');
if (recs.getCount() > 0) {
var data = recs.getAt(0).data;
custname.setValue(data.CustName);
this.storeCustContact.load({
scope: this,
params: { custCode: data.CustCode },
callback: function (records, operation, success) {
if (success) {
if (records.length > 0) {
var recordData = records[0].data;
custLikeManName.setValue(recordData.Name);
custTel.setValue(recordData.Tel);
billRises1.setValue(recordData.BillRises1);
} else {
custLikeManName.setValue('');
custTel.setValue('');
billRises1.setValue('');
}
} else {
custLikeManName.setValue('');
custTel.setValue('');
}
}
});
}
else //if (recs.getCount() > 0)
{
custname.setValue('');
custLikeManName.setValue('');
custTel.setValue('');
}
}
}
}
});
this.storeVoyVeg = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsTruckMng.ux.VoyRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetVoyRefList' }
});
this.storeVoyVeg.load({ params: { condition: ""} });
this.comboxVoyVeg = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '船名航次',
store: this.storeVoyVeg,
name: 'VoyVeg',
valueField: 'VoyCode',
displayField: 'CodeAndName'
});
this.comboxVoyVegSe = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '二程船名航次',
store: this.storeVoyVeg,
name: 'VoyVegSe',
valueField: 'VoyCode',
displayField: 'CodeAndName'
});
this.storeSalesCode = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsTruckMng.ux.UserRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetUserRefList' }
});
this.storeSalesCode.load({ params: { condition: ""} });
this.comboxSalesCode = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '揽货人',
store: this.storeSalesCode,
name: 'SalesCode',
valueField: 'UserCode',
displayField: 'CodeAndName',
listeners: {
scope: this,
'select': function (combo, records, eOpts) {
if (records.length > 0) {
var recs = DsStoreQueryBy(this.storeSalesCode, 'UserCode', records[0].data.UserCode);
var custname = this.formEdit.getForm().findField('SalesName');
if (recs.getCount() > 0) {
var data = recs.getAt(0).data;
custname.setValue(data.UserName);
} else {
custname.setValue('');
}
}
}
}
});
this.storeDispatchCode = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsTruckMng.ux.UserRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetUserRefList' }
});
this.storeDispatchCode.load({ params: { condition: ""} });
this.comboxDispatchCode = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '调度员',
store: this.storeDispatchCode,
name: 'DispatchCode',
valueField: 'UserCode',
displayField: 'CodeAndName',
listeners: {
scope: this,
'select': function (combo, records, eOpts) {
if (records.length > 0) {
var recs = DsStoreQueryBy(this.storeDispatchCode, 'UserCode', records[0].data.UserCode);
var custname = this.formEdit.getForm().findField('DispatchName');
if (recs.getCount() > 0) {
var data = recs.getAt(0).data;
custname.setValue(data.UserName);
} else {
custname.setValue('');
}
}
}
}
});
this.storeSendYardCode = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsTruckMng.ux.CustomRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetCustomRefList' }
});
this.storeSendYardCode.load({ params: { condition: "ISYARD='1'"} });
this.comboxSendYardCode = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '拖箱场站',
store: this.storeSendYardCode,
name: 'SendYardCode',
valueField: 'CustCode',
displayField: 'CodeAndName',
listeners: {
scope: this,
'select': function (combo, records, eOpts) {
if (records.length > 0) {
var recs = DsStoreQueryBy(this.storeSendYardCode, 'CustCode', records[0].data.CustCode);
var custname = this.formEdit.getForm().findField('SendYardName');
if (recs.getCount() > 0) {
var data = recs.getAt(0).data;
custname.setValue(data.CustName);
} else {
custname.setValue('');
}
}
}
}
});
Ext.define('DsShipping.ux.CodePackageModel', {
extend: 'Ext.data.Model',
fields: [
{ name: 'PKGS', type: 'string' }
]
});
this.storeCodePackage = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CodePackageModel',
proxy: { url: '/CommMng/BasicDataRef/GetCodePackageList' }
});
this.storeCodePackage.load();
this.comboxKINDPKGS = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '包 装', //'包 装',
labelWidth: 35,
store: this.storeCodePackage,
padding: '0 0 0 10',
// forceSelection: true,
name: 'KINDPKGS',
valueField: 'PKGS',
displayField: 'PKGS'
});
this.storeRtnYardCode = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsTruckMng.ux.CustomRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetCustomRefList' }
});
this.storeRtnYardCode.load({ params: { condition: "ISYARD='1'"} });
this.comboxRtnYardCode = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '返箱场站',
store: this.storeRtnYardCode,
name: 'RtnYardCode',
valueField: 'CustCode',
displayField: 'CodeAndName'
});
Ext.define('MsCodeFactry', {
extend: 'Ext.data.Model',
idProperty: 'GID',
fields: [
{ name: 'GID', type: 'string' },
{ name: 'CODENAME', type: 'string' },
{ name: 'CUSTOMERNAME', type: 'string' },
{ name: 'FACTRYNAME', type: 'string' },
{ name: 'FACTRYADDR', type: 'string' },
{ name: 'FACTRYATTN', type: 'string' },
{ name: 'FACTRYTEL', type: 'string' },
{ name: 'CodeAndName', type: 'string' }
]
});
//客户加载_工厂
this.storeFactry = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsCodeFactry',
proxy: { url: '/MvcShipping/MsCodeFactry/GetDataList' }
});
this.storeFactry.load();
//工厂
this.comboxFactry = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '工厂',
flex: 2,
store: this.storeFactry,
name: 'FactoryAddr',
valueField: 'FACTRYNAME',
displayField: 'CodeAndName'
});
//编辑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: 90,
msgTarget: 'qtip'
},
items: [
{//fieldset 1
xtype: 'fieldset',
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '录入日期',
name: 'LrDate', flex: 0, hidden: true, margins: '0'
}, {
fieldLabel: '记账日期',
name: 'JzDate', flex: 0, hidden: true, margins: '0'
}, {
fieldLabel: '用户编码',
name: 'UserCode', flex: 0, hidden: true, margins: '0'
}, {
fieldLabel: '用户姓名',
name: 'UserName', flex: 0, hidden: true, margins: '0'
}, {
fieldLabel: '组织编码',
name: 'OrgCode', flex: 0, hidden: true, margins: '0'
}, {
fieldLabel: '组织名称',
name: 'OrgName', flex: 0, hidden: true, margins: '0'
}, {
fieldLabel: '委托单位',
name: 'CustName', flex: 0, hidden: true, margins: '0'
}, {
fieldLabel: '揽货人姓名',
name: 'SalesName', flex: 0, hidden: true, margins: '0'
}, {
fieldLabel: '调度员姓名',
name: 'DispatchName', flex: 0, hidden: true, margins: '0'
}, {
fieldLabel: '拖箱场站',
name: 'SendYardName', flex: 0, hidden: true, margins: '0'
}, {
fieldLabel: '返箱场站',
name: 'RtnYard', flex: 0, hidden: true, margins: '0'
}, {
fieldLabel: '单据锁定状态',
name: 'BillStatus', flex: 0, hidden: true, margins: '0'
}, {
fieldLabel: '费用锁定状态',
name: 'FeeStatus', flex: 0, hidden: true, margins: '0'
}, { fieldLabel: 'GId',
name: 'GId', flex: 0, hidden: true, margins: '0'
}, {
fieldLabel: '时间戳',
name: 'TimeMark', flex: 0, hidden: true, margins: '0'
}, {
fieldLabel: '发票抬头',
name: 'BillRises1', flex: 0, hidden: true, margins: '0'
}, {
fieldLabel: '物流号',
allowBlank: false,
disabled: true,
name: 'BillNo'
}, this.comboxBsType,this.comboxBsStatus
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [this.comboxCustCode,this.comboxCustContact, {
fieldLabel: '客户联系人电话',
name: 'CustTel'
}//, { xtype: 'hiddenfield' }
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '要求起运日期',
format: 'Y-m-d',
xtype: 'datefield',
name: 'NeadLoadDate'
}, {
fieldLabel: '要求到达日期',
format: 'Y-m-d',
xtype: 'datefield',
name: 'NeedArriveDate'
}, this.comboxSalesCode//{ xtype: 'hiddenfield' }
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '委托日期',
format: 'Y-m-d',
xtype: 'datefield',
name: 'CustDate'
}, {
fieldLabel: '截港日期',
format: 'Y-m-d',
xtype: 'datefield',
name: 'EndPortDate'
}, {
fieldLabel: '开船(到港)日期',
format: 'Y-m-d',
xtype: 'datefield',
name: 'EtDate'
}
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [this.comboxVoyVeg, {
fieldLabel: '提单号',
name: 'MblNo'
}, {
fieldLabel: '始发地',
name: 'LoadPlace'
}
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '目的地',
name: 'DstArea'
},this.comboxDispatchCode, this.comboxSendYardCode
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [this.comboxRtnYardCode, this.comboxFactry]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '工厂地址',
name: 'DetiNation'
}]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '工厂联系电话',
name: 'DetiLinkTel'
}, {
fieldLabel: '工厂联系人',
name: 'DetiLinkMan'
}
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '货名',
flex: 2,
name: 'GoodsName'
}, this.comboxKINDPKGS
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [ {
fieldLabel: '件数',
name: 'PKGS'
}, {
fieldLabel: '货重',
name: 'KGS'
}, {
fieldLabel: '尺码',
name: 'CBM'
}
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '已派件数',
readOnly: true,
name: 'PCPKGS'
}, {
fieldLabel: '已派货重',
readOnly: true,
name: 'PCKGS'
}, {
fieldLabel: '已派尺码',
readOnly: true,
name: 'PCCBM'
}
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '未派件数',
readOnly:true,
name: 'NPKGS'
}, {
fieldLabel: '未派货重',
readOnly: true,
name: 'NKGS'
}, {
fieldLabel: '未派尺码',
readOnly: true,
name: 'NCBM'
}
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textarea',
items: [{
fieldLabel: '备注',
name: 'Remark'
}
]
}
]//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: 'bsbtnSave',
text: "保存",
iconCls: "btnsave",
handler: function (button, event) {
this.Save('0');
},
scope: this
},
{
id: 'bsbtnSaveAndClose',
text: "保存并关闭",
handler: function (button, event) {
this.Save('1');
},
scope: this
},
'-',
{
id: 'bsbtnSaveAndNew',
text: "保存并新建",
handler: function (button, event) {
this.Save('2');
},
scope: this
},
// {
// text: "派车",
// handler: function (button, event) {
// this.DispatchTruck();
// },
// scope: this
// },
'-',
{
text: "关闭",
handler: function (button, event) {
window.close();
},
scope: this
},
{
id: 'bsbtnNew',
text: "新建",
handler: function (button, event) {
this.LoadData('add', '');
var basicForm = this.formEdit.getForm();
basicForm.findField('BillNo').setDisabled(false);
},
scope: this
},
'-',
{
text: "打印",
iconCls: "btnprint",
handler: function (button, event) {
this.Print();
},
scope: this
}
// , {xtype: 'label',
// text: '<span style="color:green;">' + '单据已锁定' + '</span>',
// style: {
// width: '95%',
// marginBottom: '10px'
// }
// }
// ,
// {
// text: "Test",
// handler: function (button, event) {
// for (var i = 0; i < this.storeBodyFix.getCount(); i += 1) {
// var member = this.storeBodyFix.getAt(i);
// member.set("BillNo", this.editRecord.get('BillNo'));
// member.commit();
// };
// var removeRecords = this.storeBodyFix.getRemovedRecords();
// for (var i = 0; i < removeRecords.length; i++) {
// var memberyf = removeRecords[i];
// };
// },
// scope: this
// }
]
}); //end 按钮Toolbar
//#endregion
//#region 集装箱部分
//明细表表格相关
this.storeContainerTypeRef = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsTruckMng.ux.CtnRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetCtnRefList' }
});
this.storeContainerTypeRef.load({ params: { condition: ""} });
this.comboxContainerTypeRef = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storeContainerTypeRef,
name: 'ContainerType',
valueField: 'CtnName',
displayField: 'CtnName'
});
this.storeBodyCtn = Ext.create('Ext.data.Store', {
model: 'MsWlBsCtn',
remoteSort: false,
proxy: {
type: 'ajax',
url: '/TruckMng/MsWlBs/GetCtnBodyList',
reader: {
id: 'BillNo,SerialNo',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.cellEditingCtn = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
this.gridListCtn = new Ext.grid.GridPanel({
title: '托单集装箱信息',
store: this.storeBodyCtn,
plugins: [this.cellEditingCtn],
enableHdMenu: false,
region: 'east',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
width: 220,
tbar: [{
text: '增加明细',
tooltip: '增加明细',
iconCls: "btnadddetail",
handler: function (button, event) {
this.onAddDetailClick(button, event, '0');
},
scope: this
}, '-', {
text: '删除明细',
tooltip: '删除明细',
iconCls: "btndeletedetail",
handler: function (button, event) {
this.onDelDetailClick(button, event, '0');
},
scope: this
}],
columns: [{
sortable: true,
dataIndex: 'BillNo',
header: '单据号',
hidden: true,
width: 120
}, {
dataIndex: "SerialNo",
header: "序号",
width: 40
}, {
sortable: true,
dataIndex: 'ContainerType',
header: '箱型',
// renderer: function (value, p, record) {
// if (value == null || value == '')
// return '';
// else
// return value + '-' + record.data.ContainerType_Ref;
// },
editor: this.comboxContainerTypeRef,
width: 60
}, {
sortable: true,
dataIndex: 'ContainerQty',
header: '箱量',
editor: {
xtype: 'numberfield',
allowBlank: false,
selectOnFocus: true
},
width: 40
}, {
sortable: true,
dataIndex: 'ContainerNo',
header: '箱号',
editor: {
xtype: 'textfield',
selectOnFocus: true
},
width: 80
}, {
sortable: true,
dataIndex: 'SealNo',
header: '封号',
editor: {
xtype: 'textfield',
selectOnFocus: true
},
width: 60
}
]
});
this.gridListCtn.on('edit', function (editor, e, eOpts) {
this.gridListCtnAfterEdit(editor, e, eOpts);
}, this);
//#endregion 集装箱部分定义
//#region 布局
Ext.apply(this, {
items: [this.panelBtn, this.formEdit, this.gridListCtn]
});
//#endregion
parentWin = window.parent.opener;
this.InitData();
}, //end initUIComponents
//#region 加载数据
InitData: function () {
this.opStatus = 'add';
var condition = '';
if (parentWin) {
var ret = parentWin.OprationSwap();
this.opStatus = ret[0];
this.StoreList = ret[1];
this.editRecord = ret[2];
}
if (this.opStatus == 'edit')
condition = " BillNo='" + this.editRecord.get('BillNo') + "'";
this.LoadData(this.opStatus, condition);
}, //end InitData
LoadData: function (opstatus, condition) {
this.ctnSerialNo = 0;
this.ctnBodyDel = [];
this.fixSerialNo = 0;
this.fixBodyDel = [];
this.feeSerialNo = 0;
this.feeBodyDel = [];
this.opStatus = opstatus;
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/TruckMng/MsWlBs/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;
var recordCustCode = Ext.create('DsTruckMng.ux.CustomRefModel', {
GId: NewGuid(),
CustCode: data.CustCode,
CustName: data.CustName,
CodeAndName: data.CustCode + '-' + data.CustName
});
this.storeCustCode.add(recordCustCode);
this.formEdit.getForm().reset();
this.formEdit.getForm().setValues(data);
if (data.BillStatus == '0') {
this.setSaveBtnStatus(true);
} else {
this.setSaveBtnStatus(false);
}
this.storeCustContact.load({ params: { custCode: data.CustCode} });
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
var billno = '*';
var gid = '*';
if (this.opStatus == 'edit') {
billno = this.editRecord.get('BillNo');
gid = this.editRecord.get('GId');
}
this.storeBodyCtn.load({ params: { billno: gid} });
}, // end LoadDate
//#endregion
Save: function (type) {
var basicForm = this.formEdit.getForm();
if (!basicForm.isValid()) {
return;
}
basicForm.findField('BillNo').setDisabled(false);
var data = basicForm.getValues();
basicForm.findField('BillNo').setDisabled(true);
var bodyCtnDatas = [];
var i;
for (i = 0; i < this.storeBodyCtn.getCount(); i += 1) {
var member = this.storeBodyCtn.getAt(i);
bodyCtnDatas.push(member);
};
var jsonCtnBody = ConvertRecordsToJson(bodyCtnDatas);
var jsonCtnDelBody = ConvertRecordsToJsonAll(this.ctnBodyDel);
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/TruckMng/MsWlBs/SaveNew',
scope: this,
params: {
opstatus: this.opStatus,
data: Ext.JSON.encode(data),
ctnbody: jsonCtnBody,
ctndelbody: jsonCtnDelBody
},
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 p = Ext.create('MsWlBsHead', returnData); // Ext.create('WlBsCardHead', data, NewGuid()); //或者new WlBsCardHead(data, NewGuid());
//var p=this.StoreList.add(returnData);
//parentWin.AddNewRecord(returnData);
//this.editRecord = p[0];
var arrNewRecords = this.StoreList.add(returnData);
this.editRecord = arrNewRecords[0];
}
else if (this.opStatus == 'edit') {
var editp = Ext.create('MsWlBsHead', 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('BillNo').setDisabled(true);
// for (var i = 0; i < this.storeBodyFix.getCount(); i += 1) {
// var member = this.storeBodyFix.getAt(i);
// member.set("BillNo", this.editRecord.get('BillNo'));
// member.commit();
// };
for (var i = 0; i < this.storeBodyCtn.getCount(); i += 1) {
var member = this.storeBodyCtn.getAt(i);
member.set("BillNo", this.editRecord.get('BillNo'));
member.commit();
};
} else if (type == '1') {
window.close();
} else {
this.LoadData('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
//#region 明细操作
onAddDetailClick: function (button, event, type) {
var allow = this.getAllowOperationDetail();
if (allow == false) {
return;
}
var store = null;
if (type == 0) {
store = this.storeBodyCtn;
} else if (type == 1) {
store = this.storeBodyFix;
} else if (type == 2) {
store = this.storeBodyChFee;
} else {
alert('函数(onAddDetailClick)的参数type类型设置的不对');
return;
}
var newSerialno = this.GetHandleSerialNo(store, type);
var record = null;
if (type == 0) {
record = Ext.create('MsWlBsCtn',
{
BillNo: '*',
SerialNo: newSerialno,
ContainerType: '',
ContainerQty: 0
}
);
} else if (type == 1) {
record = Ext.create('MsWlBsFixed', {
GId: NewGuid(),
BillNo: '*',
SerialNo: newSerialno,
FeeStatus: 1,
FeeStatus_Ref: '录入状态',
AuditStatus: 0,
CreditDebit: '2',
CreditDebit_Ref: '应付',
FeeTypeCode: '',
DistCount: 0,
Price: 0,
FsTotal: 0,
JsTotal: 0,
Remark: ''
});
} else if (type == 2) {
record = Ext.create('MsChFee', {
GId: NewGuid(),
BsNo: '*',
FeeStatus: 1,
FeeStatus_Ref: '录入状态',
FeeType: 1,
FeeType_Ref: '应收',
FeeName: '',
FeeName_Ref: '',
FeeDescription: '',
CustomerType: '',
CustomerName: this.getCustName(),
CustomerName_Ref: '',
Unit: '',
UnitPrice: 0,
Quantity: 1,
Amount: 0,
Currency: 'RMB',
ExChangerate: 1,
Reason: '',
Remark: '',
Commissionrate: 0,
Settlement: 0,
Invoice: 0,
OrderAmount: 0,
OrderInvoice: 0,
SubmitDate: null,
Auditoperator: '',
AuditDate: null,
EnteroPerator: GetCookie_UserId(),
EnterDate: null,
DebitNo: '',
IsDebit: "0",
IsOpen: "0",
IsAdvancedpay: "0",
Sort: "0",
IsInvoice: "0",
FeeFrt: '',
IsCrmOrderFee: "0",
AuditStatus: 0,
InvoiceNum: '',
ChequeNum: '',
WmsOutBsNo: ''
});
}
store.add(record);
var editColumnIndex = 0;
var cellediting = null;
if (type == 0) {
cellediting = this.cellEditingCtn;
editColumnIndex = 2;
} else if (type == 1) {
cellediting = this.cellEditingFix;
editColumnIndex = 2;
} else if (type == 2) {
cellediting = this.cellEditingChFee;
editColumnIndex = 4;
}
var n = store.getCount();
cellediting.startEditByPosition({ row: n - 1, column: editColumnIndex });
},
GetHandleSerialNo: function (store, type) {
var result = 0;
if (type == 0) {
result = this.ctnSerialNo;
} else if (type == 1) {
result = this.fixSerialNo;
} else if (type == 2) {
result = this.feeSerialNo;
}
if (result == 0) {
for (var i = 0; i < store.getCount(); i += 1) {
var member = store.getAt(i);
if (member.data.SerialNo > result) {
result = member.data.SerialNo;
}
}
}
result = result + 1;
if (type == 0) {
this.ctnSerialNo = result;
} else if (type == 1) {
this.fixSerialNo = result;
} else if (type == 2) {
this.feeSerialNo = result;
}
return result;
},
onDelDetailClick: function (button, event, type) {
var allow = this.getAllowOperationDetail();
if (allow == false) {
return;
}
var store = null;
if (type == 0) {
store = this.storeBodyCtn;
} else if (type == 1) {
store = this.storeBodyFix;
} else if (type == 2) {
store = this.storeBodyChFee;
} else {
alert('函数(onAddDetailClick)的参数type类型设置的不对');
return;
}
var result = 0;
if (type == '0') {
result = this.ctnSerialNo;
} else if (type == '1') {
result = this.fixSerialNo;
} else if (type == '2') {
result = this.feeSerialNo;
}
if (result == 0) {
for (var i = 0; i < store.getCount(); i += 1) {
var member = store.getAt(i);
if (member.data.SerialNo > this.giSerialNo) {
result = member.data.SerialNo;
}
}
}
if (type == '0') {
this.ctnSerialNo = result;
} else if (type == '1') {
this.fixSerialNo = result;
} else if (type == '2') {
this.feeSerialNo = result;
}
var selectedRecords = [];
if (type == '0') {
selectedRecords = this.gridListCtn.selModel.getSelection();
} else if (type == '1') {
selectedRecords = this.gridListFix.selModel.getSelection();
} else if (type == '2') {
selectedRecords = this.gridListChFee.selModel.getSelection();
var candelete = DsTruck.CheckChFeeDelete(selectedRecords);
if (candelete == false)
return;
}
if (selectedRecords.length > 0) {
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
if (rec.BillNo != "" || rec.BillNo != "*") //如果是新增但没有保存的数据,没有必要提交到后台
{
if (type == '0')
this.ctnBodyDel.push(rec);
else if (type == '1') {
this.fixBodyDel.push(rec);
} else if (type == '2') {
this.feeBodyDel.push(rec);
}
}
if (type == '0') {
this.storeBodyCtn.remove(selectedRecords[i]);
} else if (type == '1') {
this.storeBodyFix.remove(selectedRecords[i]);
} else if (type == '2') {
this.storeBodyChFee.remove(selectedRecords[i]);
}
}
}
},
getAllowOperationDetail: function () {
var feeStatus = this.getFeeStatus();
if (feeStatus == '0')
return true;
else {
Ext.Msg.show({ title: '错误', msg: "费用已锁定,不允许操作费用!", icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
return false;
}
},
//#endregion
//#region 表格的AfterEdit
gridListCtnAfterEdit: function (editor, e, eOpts) {
},
//#endregion
GetBillNo: function () {
if (this.editRecord == null)
return '*';
else {
return this.editRecord.get('BillNo');
}
},
cellEditingFixBeforeEdit: function (editor, e) {
var feeStatus = this.getFeeStatus();
var billStatus = this.getBillStatus();
var canedit = feeStatus == '0' && billStatus == '0';
return canedit;
},
cellEditingChFeeBeforeEdit: function (editor, e) {
var chfeefeeStatus = e.record.get('FeeStatus');
var canedit = chfeefeeStatus == 1 || chfeefeeStatus == 6;
if (canedit) {
var feeStatus = this.getFeeStatus();
var billStatus = this.getBillStatus();
canedit = feeStatus == '0' && billStatus == '0';
}
return canedit;
},
getCustName: function () {
var custName = this.formEdit.getForm().findField('CustName');
return custName.getValue();
},
onSubmitAuditClick: function (button, event) {
var records = this.feeGridCheckBoxModel.selected.items;
DsTruck.MsChFeeAudit(records, 2, '正在提交审核数据, 请稍侯..');
},
setSaveBtnStatus: function (enable) {
var bsbtnSave = Ext.getCmp('bsbtnSave');
var bsbtnSaveAndClose = Ext.getCmp('bsbtnSaveAndClose');
var bsbtnSaveAndNew = Ext.getCmp('bsbtnSaveAndNew');
if (enable) {
bsbtnSave.enable();
bsbtnSaveAndClose.enable();
bsbtnSaveAndNew.enable();
} else {
bsbtnSave.disable();
bsbtnSaveAndClose.disable();
bsbtnSaveAndNew.disable();
}
},
getFeeStatus: function () {
var basicForm = this.formEdit.getForm();
var feeStatus = basicForm.findField('FeeStatus').value;
return feeStatus;
}
,
getBillStatus: function () {
var basicForm = this.formEdit.getForm();
var billStatus = basicForm.findField('BillStatus').value;
return billStatus;
},
Print: function () {
var basicForm = this.formEdit.getForm();
var billNo = basicForm.findField('BillNo').value;
if (billNo == '*' || billNo == '') {
Ext.Msg.show({ title: '错误', msg: '单据还没有保存,请保存后再打印', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
return;
}
var gid = basicForm.findField('GId').value;
Ext.Ajax.request({
waitMsg: '正在查询数据...',
url: '/TruckMng/MsWlBs/GetIsPrint',
async: false,
params: {
billno: billNo,
Gid: gid
},
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 printType = 'MSWLBS';
var sql1 = "SET LANGUAGE 'us_english ' "
+ " select * from vMsWlBsHeadPrint WHERE BillNo = '" + billNo + "' order by BillNo";
var sql2 = "SET LANGUAGE 'us_english' SELECT * from ch_fee where BsNo='" + gid + "'";
//var sql3 = "SET LANGUAGE 'us_english' "
// + " select * from vMsWlPcHeadPrint where RefBillNo='" + billNo + "' order by RefBillNo";
//var sql4 = "SET LANGUAGE 'us_english' select * from ch_fee where BSNO in (select Gid from tMswlpcHead where RefBillNo='" + billNo + "') order by BsNo";
var sql3 = "SET LANGUAGE 'us_english' select A.*,B.* from vMsWlPcHeadPrint A, ch_fee B where A.Gid=B.BsNo and A.RefBillNo='" + billNo + "' order by A.RefBillNo";
//var sql4 = "SET LANGUAGE 'us_english' select * from tMsWlPcFixed where BillNo in (select Gid from tMswlpcHead where RefBillNo='" + billNo + "') order by BillNo";
var sql4 = "SET LANGUAGE 'us_english' select A.*,B.* from vMsWlPcHeadPrint A,tMsWlPcFixed B where A.Gid=B.BillNo and A.RefBillNo='" + billNo + "' order by A.RefBillNo";
var sql5 = "";
var sql6 = "";
PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6);
}
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
// var printType = 'MSWLBS';
// var sql1 = "SET LANGUAGE 'us_english ' "
// + " select * from vMsWlBsHeadPrint WHERE BillNo = '" + billNo + "' order by BillNo";
// var sql2 = "SET LANGUAGE 'us_english' SELECT * from ch_fee where BsNo='" + gid + "'";
// //var sql3 = "SET LANGUAGE 'us_english' "
// // + " select * from vMsWlPcHeadPrint where RefBillNo='" + billNo + "' order by RefBillNo";
// //var sql4 = "SET LANGUAGE 'us_english' select * from ch_fee where BSNO in (select Gid from tMswlpcHead where RefBillNo='" + billNo + "') order by BsNo";
// var sql3 = "SET LANGUAGE 'us_english' select A.*,B.* from vMsWlPcHeadPrint A, ch_fee B where A.Gid=B.BsNo and A.RefBillNo='" + billNo + "' order by A.RefBillNo";
// //var sql4 = "SET LANGUAGE 'us_english' select * from tMsWlPcFixed where BillNo in (select Gid from tMswlpcHead where RefBillNo='" + billNo + "') order by BillNo";
// var sql4 = "SET LANGUAGE 'us_english' select A.*,B.* from vMsWlPcHeadPrint A,tMsWlPcFixed B where A.Gid=B.BillNo and A.RefBillNo='" + billNo + "' order by A.RefBillNo";
// var sql5 = "";
// var sql6 = "";
// PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6);
},
DispatchTruck: function () {
},
setBtnOnlyQuery: function () {
var bsbtnSave = Ext.getCmp('bsbtnSave');
var bsbtnSaveAndClose = Ext.getCmp('bsbtnSaveAndClose');
var bsbtnSaveAndNew = Ext.getCmp('bsbtnSaveAndNew');
var bsbtnNew = Ext.getCmp('bsbtnNew');
bsbtnSave.setVisible(false);
bsbtnSaveAndClose.setVisible(false);
bsbtnSaveAndNew.setVisible(false);
bsbtnNew.setVisible(false);
}
});