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/WlBsCard/WlPcEdit.js

1122 lines
38 KiB
JavaScript

3 years ago
Ext.namespace('DsTruck');
DsTruck.WlPcEdit = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.DsTruck.WlPcEdit.superclass.constructor.call(this);
};
Ext.extend(DsTruck.WlPcEdit, Ext.Panel, {
ParentPanel: null,
OpStatus: 'add',
StoreList: null,
EditRecord: null,
RefBillNo: '*',
initUIComponents: function () {
this.ysSerialNo = 0;
this.ysBodyDel = [];
this.yfSerialNo = 0;
this.yfBodyDel = [];
//枚举参照相关
//表参照相关
this.storeUserCode = Ext.create('DsExt.ux.RefTableStore', {
model: 'TruckUser',
proxy: { url: '/TruckMng/WlBsCard/GetUserCodeList' }
});
this.storeUserCode.load();
this.comboxUserCode = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '用户编码',
store: this.storeUserCode,
name: 'UserCode',
valueField: 'CODENAME',
displayField: 'SHOWNAME'
});
this.storeOrgCode = Ext.create('DsExt.ux.RefTableStore', {
model: 'BmOrg',
proxy: { url: '/TruckMng/WlBsCard/GetOrgCodeList' }
});
this.storeOrgCode.load();
this.comboxOrgCode = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '组织编码',
store: this.storeOrgCode,
name: 'OrgCode',
valueField: 'OrgCode',
displayField: 'OrgName'
});
this.storeContainerType = Ext.create('DsExt.ux.RefTableStore', {
model: 'ode_ctn_type',
proxy: { url: '/TruckMng/WlBsCard/GetContainerTypeList' }
});
this.storeContainerType.load();
this.comboxContainerType = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '箱型',
store: this.storeContainerType,
name: 'ContainerType',
valueField: 'CTNTYPEID',
displayField: 'CTNTYPE'
});
this.storeVoyVeg = Ext.create('DsExt.ux.RefTableStore', {
model: 'TruckVoyInfo',
proxy: { url: '/TruckMng/WlBsCard/GetVoyVegList' }
});
this.storeVoyVeg.load();
this.comboxVoyVeg = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '船名航次',
store: this.storeVoyVeg,
name: 'VoyVeg',
valueField: 'VOID',
displayField: 'VESSELVOYNO'
});
this.storeSendYard = Ext.create('DsExt.ux.RefTableStore', {
model: 'TruckClient',
proxy: { url: '/TruckMng/WlBsCard/GetSendYardList' }
});
this.storeSendYard.load();
this.comboxSendYard = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '拖箱场站',
store: this.storeSendYard,
name: 'SendYard',
valueField: 'CODENAME',
displayField: 'SHORTNAME'
});
this.storeRtnYard = Ext.create('DsExt.ux.RefTableStore', {
model: 'TruckClient',
proxy: { url: '/TruckMng/WlBsCard/GetRtnYardList' }
});
this.storeRtnYard.load();
this.comboxRtnYard = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '返箱场站',
store: this.storeRtnYard,
name: 'RtnYard',
valueField: 'CODENAME',
displayField: 'SHORTNAME'
});
this.storeVoyVegSe = Ext.create('DsExt.ux.RefTableStore', {
model: 'TruckVoyInfo',
proxy: { url: '/TruckMng/WlBsCard/GetVoyVegSeList' }
});
this.storeVoyVegSe.load();
this.comboxVoyVegSe = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '船名航次2',
store: this.storeVoyVegSe,
name: 'VoyVegSe',
valueField: 'VOID',
displayField: 'VESSELVOYNO'
});
this.storeSendYardSe = Ext.create('DsExt.ux.RefTableStore', {
model: 'TruckClient',
proxy: { url: '/TruckMng/WlBsCard/GetSendYardSeList' }
});
this.storeSendYardSe.load();
this.comboxSendYardSe = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '拖箱场站2',
store: this.storeSendYardSe,
name: 'SendYardSe',
valueField: 'CODENAME',
displayField: 'SHORTNAME'
});
this.storeRtnYardSe = Ext.create('DsExt.ux.RefTableStore', {
model: 'TruckClient',
proxy: { url: '/TruckMng/WlBsCard/GetRtnYardSeList' }
});
this.storeRtnYardSe.load();
this.comboxRtnYardSe = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '返箱场站2',
store: this.storeRtnYardSe,
name: 'RtnYardSe',
valueField: 'CODENAME',
displayField: 'SHORTNAME'
});
this.storeDdCode = Ext.create('DsExt.ux.RefTableStore', {
model: 'TruckUser',
proxy: { url: '/TruckMng/WlBsCard/GetDdCodeList' }
});
this.storeDdCode.load();
this.comboxDdCode = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '调度员编码',
store: this.storeDdCode,
name: 'DdCode',
valueField: 'CODENAME',
displayField: 'SHOWNAME'
});
this.storeContainerTypeSe = Ext.create('DsExt.ux.RefTableStore', {
model: 'ode_ctn_type',
proxy: { url: '/TruckMng/WlBsCard/GetContainerTypeSeList' }
});
this.storeContainerTypeSe.load();
this.comboxContainerTypeSe = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '箱型2',
store: this.storeContainerTypeSe,
name: 'ContainerTypeSe',
valueField: 'CTNTYPEID',
displayField: 'CTNTYPE'
});
//编辑form
this.formEdit = Ext.widget('form', {
//title: '车辆信息维护',
region: 'center',
autoScroll: true,
frame: true,
bodyPadding: 5,
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: 'LrTime',
flex: 0,
hidden: true,
margins: '0'
}, {
fieldLabel: '入账日期',
name: 'RzDate',
flex: 0,
hidden: true,
margins: '0'
}, {
fieldLabel: '入账时间',
name: 'RzTime',
flex: 0,
hidden: true,
margins: '0'
}, {
fieldLabel: '结账日期',
name: 'JzDate',
flex: 0,
hidden: true,
margins: '0'
}, {
fieldLabel: '用户姓名',
name: 'UserName',
flex: 0,
hidden: true,
margins: '0'
}, {
fieldLabel: '组织名称',
name: 'OrgName',
flex: 0,
hidden: true,
margins: '0'
}, {
fieldLabel: '到厂日期',
name: 'ArriveDate',
flex: 0,
hidden: true,
margins: '0'
}, {
fieldLabel: '到厂时间',
name: 'ArriveTime',
flex: 0,
hidden: true,
margins: '0'
}, {
fieldLabel: '调度员姓名',
name: 'DdName',
flex: 0,
hidden: true,
margins: '0'
}, {
fieldLabel: '返回日期',
name: 'ReturnDate',
flex: 0,
hidden: true,
margins: '0'
}, {
fieldLabel: '返回时间',
name: 'ReturnTime',
flex: 0,
hidden: true,
margins: '0'
}, {
fieldLabel: '汇总日期',
name: 'HzDate',
flex: 0,
hidden: true,
margins: '0'
}, {
fieldLabel: '相关单据类型',
name: 'RefBillType',
flex: 0,
hidden: true,
margins: '0'
}, {
fieldLabel: '相关单据号',
name: 'RefBillNo',
flex: 0,
hidden: true,
margins: '0'
}, {
fieldLabel: '相关单据号2',
name: 'RefBillNoSe',
flex: 0,
hidden: true,
margins: '0'
}, {
fieldLabel: '单据号',
allowBlank: false,
name: 'BillNo'
}, {
fieldLabel: '录入日期',
name: 'LrDate'
}, this.comboxUserCode
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [this.comboxOrgCode, {
fieldLabel: '车牌号',
name: 'TruckNo'
}, {
fieldLabel: '司机姓名',
name: 'DrvName'
}
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '司机手机',
name: 'Mobile'
}, {
fieldLabel: '派车日期',
name: 'ExpDate'
}, {
fieldLabel: '派车时间',
name: 'ExpTime'
}
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [this.comboxContainerType, {
fieldLabel: '箱量',
xtype: 'numberfield',
allowBlank: false,
name: 'ContainerQty'
}, {
fieldLabel: '箱号封号',
name: 'ContainerNa'
}
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '是否双背',
allowBlank: false,
name: 'IsDouble'
}, this.comboxVoyVeg, {
fieldLabel: '开船日期',
name: 'EtDate'
}, {
fieldLabel: '截港日期',
name: 'EndPortDate'
}
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '提单号',
name: 'MblNo'
}, this.comboxSendYard
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [this.comboxRtnYard, {
fieldLabel: '目的地',
name: 'DstArea'
}, {
fieldLabel: '工厂地址',
name: 'DetiNation'
}
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '拖货地址',
name: 'FactoryAddr'
}, {
fieldLabel: '联系电话',
name: 'LinkTel'
}, {
fieldLabel: '联系人',
name: 'LinkMan'
}
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [this.comboxVoyVegSe, {
fieldLabel: '开船日期2',
name: 'EtDateSe'
}, {
fieldLabel: '截港日期2',
name: 'EndPortDateSe'
}
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '提单号2',
name: 'MblNoSe'
}, this.comboxSendYardSe, this.comboxRtnYardSe
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '目的地2',
name: 'DstAreaSe'
}, {
fieldLabel: '工厂地址2',
name: 'DetiNationSe'
}, {
fieldLabel: '拖货地址2',
name: 'FactoryAddrSe'
}
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '联系电话2',
name: 'LinkTelSe'
}, {
fieldLabel: '联系人2',
name: 'LinkManSe'
}, {
fieldLabel: '额定里程',
xtype: 'numberfield',
allowBlank: false,
name: 'RatedMil'
}
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '额定油耗',
xtype: 'numberfield',
allowBlank: false,
name: 'RatedFuel'
}, {
fieldLabel: '本次加油量',
xtype: 'numberfield',
allowBlank: false,
name: 'FuelQty'
}, {
fieldLabel: '实际里程',
xtype: 'numberfield',
allowBlank: false,
name: 'RealMil'
}
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '实际油耗',
xtype: 'numberfield',
allowBlank: false,
name: 'RealFuel'
}, {
fieldLabel: '空箱里程',
xtype: 'numberfield',
allowBlank: false,
name: 'NoLoadMil'
}, {
fieldLabel: '重箱里程',
xtype: 'numberfield',
allowBlank: false,
name: 'OverLoadMil'
}
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '运量',
xtype: 'numberfield',
allowBlank: false,
name: 'Ton'
}, {
fieldLabel: '周转量',
xtype: 'numberfield',
allowBlank: false,
name: 'AroundTon'
}, {
fieldLabel: '运输次数',
xtype: 'numberfield',
allowBlank: false,
name: 'LoadCount'
}
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [this.comboxDdCode, {
fieldLabel: '备注',
name: 'Remark'
}, this.comboxContainerTypeSe
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '箱量2',
xtype: 'numberfield',
allowBlank: false,
name: 'ContainerQtySe'
}
]
}
]//end items(fieldset 1)
}//end fieldset 1
]//end root items
}); //end this.formEdit
//按钮Toolbar
this.panelBtn = new Ext.Panel({
region: "north",
tbar: [
{
text: "保存",
iconCls: "btnsave",
handler: function(button, event) {
this.Save('0');
},
scope: this
}
]
}); //end 按钮Toolbar
this.storeFeeType = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsTruckMng.ux.FeeTypeRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetFeeTypeRefList' }
});
this.storeFeeType.load();
//*****************************Renderer函数******************************************
var storeFeeType = this.storeFeeType;
function renderFeeType(value) {
var records = storeFeeType.queryBy(function(rec) {
if (rec.data.FeeCode == value) {
return true;
} else {
return false;
}
});
if (records.getCount() > 0) {
return records.getAt(0).data.CodeAndName;
} else {
return '';
}
}
//定义Grid
var cellEditingYs = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
//定义数据集
this.storeFeeYs = Ext.create('Ext.data.Store', {
model: 'WlBsCardFixed',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/TruckMng/WlBsCard/GetPcFeeBodyList',
reader: {
id: 'BillNo,CreditDebit,SerialNo',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.comboxFeeTypeYs = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storeFeeType,
valueField: 'FeeCode',
displayField: 'CodeAndName'
});
this.gridFeeYs = new Ext.grid.GridPanel({
store: this.storeFeeYs,
enableHdMenu: false,
plugins: [cellEditingYs],
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
selType: 'cellmodel',
tbar: [{
text: '增加明细',
tooltip: '增加明细',
iconCls: "btnadddetail",
handler: function (button, event) {
this.onAddDetailClick(button, event, this.storeFeeYs, '0', cellEditingYs);
},
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: 'CreditDebit',
header: '费用类型',
hidden: true,
width: 20
}, {
sortable: true,
dataIndex: 'FeeTypeCode',
header: '费用编码',
editor: this.comboxFeeTypeYs,
renderer: renderFeeType,
width: 120
}, {
sortable: true,
dataIndex: 'DistCount',
header: '计费里程',
hidden: true,
width: 160
}, {
sortable: true,
dataIndex: 'Price',
header: '费用单价',
hidden: true,
width: 160
}, {
sortable: true,
dataIndex: 'FsTotal',
header: '发生金额',
editor: {
xtype: 'numberfield',
allowBlank: false
},
width: 160
}, {
sortable: true,
dataIndex: 'JsTotal',
header: '实际金额',
hidden: true,
width: 160
}, {
sortable: true,
dataIndex: 'Remark',
header: '备注',
editor: {
xtype: 'textfield'
},
width: 200
}
]
});
//定义数据集
this.storeFeeYf = Ext.create('Ext.data.Store', {
model: 'WlBsCardFixed',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/TruckMng/WlBsCard/GetPcFeeBodyList',
reader: {
id: 'BillNo,CreditDebit,SerialNo',
root: 'data',
totalProperty: 'totalCount'
}
}
});
//定义Grid
var cellEditingYf = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
this.gridFeeYf = new Ext.grid.GridPanel({
store: this.storeFeeYf,
plugins: [cellEditingYf],
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
tbar: [{
text: '增加明细',
tooltip: '增加明细',
iconCls: "btnadddetail",
handler: function (button, event) {
this.onAddDetailClick(button, event, this.storeFeeYf, '1', cellEditingYs);
},
scope: this
}, '-', {
text: '删除明细',
tooltip: '删除明细',
iconCls: "btndeletedetail",
handler: function (button, event) {
this.onDelDetailClick(button, event, '1');
},
scope: this
}],
columns: [{
sortable: true,
dataIndex: 'BillNo',
header: '单据号',
hidden: true,
width: 120
}, {
dataIndex: "SerialNo",
header: "序号",
width: 40
}, {
sortable: true,
dataIndex: 'CreditDebit',
header: '费用类型',
hidden: true,
width: 20
}, {
sortable: true,
dataIndex: 'FeeTypeCode',
header: '费用编码',
editor: this.comboxFeeTypeYs,
renderer: renderFeeType,
width: 120
}, {
sortable: true,
dataIndex: 'DistCount',
header: '计费里程',
hidden: true,
width: 160
}, {
sortable: true,
dataIndex: 'Price',
header: '费用单价',
hidden: true,
width: 160
}, {
sortable: true,
dataIndex: 'FsTotal',
header: '发生金额',
editor: {
xtype: 'numberfield',
allowBlank: false
},
width: 160
}, {
sortable: true,
dataIndex: 'JsTotal',
header: '实际金额',
hidden: true,
width: 160
}, {
sortable: true,
dataIndex: 'Remark',
header: '备注',
width: 200
}
]
});
this.panelTop = new Ext.Panel({
layout: "border",
region: "north",
height: 350,
items: [this.panelBtn, this.formEdit]
});
this.panelFeeYs = new Ext.Panel({
title: '应收费用',
layout: "border",
region: 'west',
width: 400,
margin: '5 10',
items: [this.gridFeeYs]
});
this.panelFeeYf = new Ext.Panel({
title: '应付费用',
layout: "border",
region: 'center',
margin: '5 10',
items: [this.gridFeeYf]
});
this.panelFee = new Ext.Panel({
layout: "border",
region: "center",
items: [
this.panelFeeYs, this.panelFeeYf
]
});
Ext.apply(this, {
items: [this.panelTop, this.panelFee]
});
}, //end initUIComponents
InitData: function () {
this.opStatus = 'add';
var condition = '';
if (this.ParentPanel) {
var ret = this.ParentPanel.OprationSwap();
this.opStatus = ret[0];
this.storeList = ret[1];
this.editRecord = ret[2];
this.RefBillNo = ret[3];
}
if (this.opStatus == 'add') {
condition = " BillNo='*'";
}
else if (this.opStatus == 'edit')
condition = " BillNo='" + this.editRecord.get('BillNo') + "'";
this.LoadData(this.opStatus, condition);
}, //end InitData
LoadData: function (opstatus, condition) {
this.ysSerialNo = 0;
this.ysBodyDel = [];
this.yfSerialNo = 0;
this.yfBodyDel = [];
this.opStatus = opstatus;
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/TruckMng/WlBsCard/GetPcData',
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;
if (this.opStatus == 'add') {
data.RefBillNo = this.RefBillNo;
}
this.formEdit.getForm().reset();
this.formEdit.getForm().setValues(data);
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
var billno = '*';
if (this.opStatus == 'edit') {
billno = this.editRecord.get('BillNo');
this.formEdit.getForm().findField('BillNo').setDisabled(false);
}
this.storeFeeYs.load({ params: { billno: billno, creditdebit: '0'} });
this.storeFeeYf.load({ params: { billno: billno, creditdebit: '1'} });
}, // end LoadDate
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 bodydatas = [];
for (var i = 0; i < this.storeFeeYs.getCount(); i += 1) {
var member = this.storeFeeYs.getAt(i);
bodydatas.push(member);
};
var jsonYsBody = ConvertRecordsToJson(bodydatas);
var jsonYsDelBody = ConvertRecordsToJsonAll(this.ysBodyDel);
var bodyyfdatas = [];
for (i = 0; i < this.storeFeeYf.getCount(); i += 1) {
var memberyf = this.storeFeeYf.getAt(i);
bodyyfdatas.push(memberyf);
};
var jsonYfBody = ConvertRecordsToJson(bodyyfdatas);
var jsonYfDelBody = ConvertRecordsToJsonAll(this.yfBodyDel);
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/TruckMng/WlBsCard/PcSave',
scope: this,
params: {
opstatus: this.opStatus,
data: Ext.JSON.encode(data),
ysbody: jsonYsBody,
ysdelbody: jsonYsDelBody,
yfbody: jsonYfBody,
yfdelbody: jsonYfDelBody
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
if (this.opStatus == 'add') {
var p = Ext.create('WlPcHead', data); // Ext.create('WlPcHead', data, NewGuid()); //或者new WlPcHead(data, NewGuid());
this.storeList.add(p);
this.editRecord = p;
}
else if (this.opStatus == 'edit') {
var editp = Ext.create('WlPcHead', data);
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.storeFeeYs.getCount(); i += 1) {
var member = this.storeFeeYs.getAt(i);
member.set("BillNo", this.editRecord.get('BillNo'));
member.commit();
};
for (var i = 0; i < this.storeFeeYf.getCount(); i += 1) {
var member = this.storeFeeYf.getAt(i);
member.set("BillNo", this.editRecord.get('BillNo'));
member.commit();
};
} else if (type == '1') {
window.close();
} else {
this.LoadData('add', '');
basicForm.findField('BillNo').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
onAddDetailClick: function (button, event, store, creditdebit, cellediting) {
var newSerialno = this.GetHandleSerialNo(store, creditdebit);
var record = Ext.create('WlBsCardFixed', {
BillNo: '*', SerialNo: newSerialno, CreditDebit: creditdebit, FeeTypeCode: '', DistCount: 0, Price: 0, FsTotal: 0, JsTotal: 0, Remark: ''
});
store.add(record);
var n = store.getCount();
cellediting.startEditByPosition({ row: n - 1, column: 0 });
},
GetHandleSerialNo: function (store, creditdebit) {
var result = 0;
if (creditdebit == '0') {
result = this.ysSerialNo;
} else {
result = this.yfSerialNo;
}
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 (creditdebit == '0') {
this.ysSerialNo = result;
} else {
this.yfSerialNo = result;
}
return result;
},
onDelDetailClick: function (button, event, creditdebit) {
var store = null;
if (creditdebit == '0') {
store = this.storeFeeYs;
} else {
store = this.storeFeeYf;
}
var result = 0;
if (creditdebit == '0') {
result = this.ysSerialNo;
} else {
result = this.yfSerialNo;
}
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 (creditdebit == '0') {
this.ysSerialNo = result;
} else {
this.yfSerialNo = result;
}
var selectedRecords = [];
if (creditdebit == '0') {
selectedRecords = this.gridFeeYs.selModel.getSelection();
} else {
selectedRecords = this.gridFeeYf.selModel.getSelection();
}
if (selectedRecords.length > 0) {
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
if (rec.BillNo != "" || rec.BillNo != "*") //如果是新增但没有保存的数据,没有必要提交到后台
{
if (creditdebit == '0')
this.ysBodyDel.push(rec);
else {
this.yfBodyDel.push(rec);
}
}
if (creditdebit == '0') {
this.storeFeeYs.remove(selectedRecords[i]);
} else {
this.storeFeeYf.remove(selectedRecords[i]);
}
}
}
}
});