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/MvcShipping/Viewsjs/MsChDui/MsChDuiEdit.js

2311 lines
82 KiB
JavaScript

Ext.namespace('Shipping');
Shipping.MsChDuiEdit = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.MsChDuiEdit.superclass.constructor.call(this);
};
Ext.extend(Shipping.MsChDuiEdit, Ext.Panel, {
ParentWin: null,
OpStatus: 'add',
StoreList: null,
EditRecord: null,
initUIComponents: function () {
this.serialNo = 0;
this.workSerialNo = 0;
this.bodyDel = [];
this.FeeSql = '';
this.BillSql = '';
this.DuiBillSql = '';
this.IsDebit = '0';
this.FeeSqlStr = '';
//#region 编辑form
//枚举参照相关(编辑form)
this.formname = 'MsChDuiEdit';
//表参照相关(编辑form)
this.storeCustCode = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CustomRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetCustomRefList' }
});
this.storeCustCode.load({ params: { condition: ""} });
this.comboxCustCode = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: Zi.LAN.duizkehu, //对账客户
store: this.storeCustCode,
allowBlank: false,
forceSelection: true,
name: 'CUSTNAME',
valueField: 'CustName',
displayField: 'CodeAndName',
listeners: {
scope: this,
'select': function (combo, records, eOpts) {
if (records.length > 0) {
var CUSTOMERNAME = this.formEdit.getForm().findField('CUSTNAME').getValue();
if (CUSTOMERNAME == '') return;
var CUSTNAME = this.formSearch.getForm().findField('CUSTNAME');
var tmpcust = CUSTNAME.getValue();
if (tmpcust == '' || tmpcust == null || tmpcust == undefined) {
CUSTNAME.setValue(CUSTOMERNAME);
}
}
}
}
});
this.storeDuiTemplate = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsCodeDuiTemplate',
proxy: { url: '/MvcShipping/MsCodeDuiTemplate/GetDataList' }
});
this.storeDuiTemplate.load({ params: { condition: ""} });
this.comboxDuiTemplate = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: Zi.LAN.printmoban, //打印模板
store: this.storeDuiTemplate,
forceSelection: true,
name: 'DM_ID',
valueField: 'DM_ID',
displayField: 'NAME'
});
this.storeDCType = Ext.create('DsExt.ux.RefEnumStore', {});
this.storeDCType.load({ params: { enumTypeId: 96008} });
this.comboxDCType = Ext.create('DsExt.ux.RefEnumCombox', {
fieldLabel: Zi.LAN.zdantype, //账单类别
store: this.storeDCType,
forceSelection: true,
name: 'DC'
});
this.storeFeeType = Ext.create('DsExt.ux.RefEnumStore', {});
this.storeFeeType.load({ params: { enumTypeId: 96009} });
this.comboxFeeType = Ext.create('DsExt.ux.RefEnumCombox', {
fieldLabel: Zi.LAN.fyfanwei, //费用范围
store: this.storeFeeType,
forceSelection: true,
name: 'ISNOSTL'
});
//编辑form
this.formEdit = Ext.widget('form', {
region: 'center',
frame: true,
bodyPadding: 1,
autoScroll: true,
fieldDefaults: {
margins: '2 2 1 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: Zi.LAN.duiznum, //对账编号
name: 'OP', hidden: true
}, {
fieldLabel: Zi.LAN.duiznum, //对账编号
readOnly: true,
name: 'DUINO'
}, this.comboxCustCode, {
fieldLabel: Zi.LAN.zdshuoming, //账单说明
name: 'DUINAME'
}, {
fieldLabel: Zi.LAN.duizdate, //对账日期
readOnly: true,
name: 'DUIDATE'
}
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [this.comboxDuiTemplate, this.comboxDCType, this.comboxFeeType, {
fieldLabel: Zi.LAN.Remarks,
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: [
{
text: Zi.LAN.Save, //保存
iconCls: "btnsave",
handler: function (button, event) {
this.Save('0');
},
scope: this
}, '-',
{
text: Zi.LAN.biaozprint, //标准打印
handler: function (button, event) {
this.Print();
},
scope: this
},
'-',
{
text: Zi.LAN.mobprint, //模板打印
handler: function (button, event) {
this.ModulPrint();
},
scope: this
},
'-',
{
text: Zi.LAN.saveandclose, //保存并关闭
handler: function (button, event) {
this.Save('1');
},
scope: this
},
'-',
{
text: Zi.LAN.saveandnew, //保存并新建
handler: function (button, event) {
this.Save('2');
},
scope: this
}
]
}); //end 按钮Toolbar
//#endregion
//#region 明细表
//明细表表格相关
this.GridCheckBoxModel = Ext.create('Ext.selection.CheckboxModel');
//明细表-数据集
this.storeBodyList = Ext.create('Ext.data.Store', {
model: 'MsChDuiBill',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/MvcShipping/MsChDui/GetBillList',
reader: {
id: 'DUINO,BSNO',
root: 'data',
totalProperty: 'totalCount'
}
}
});
//明细表表格
this.gridListCellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
this.gridList = new Ext.grid.GridPanel({
store: this.storeBodyList,
enableHdMenu: false,
region: 'center',
loadMask: { msg: Zi.LAN.LoadData }, //数据加载中,请稍等...
trackMouseOver: true,
disableSelection: false,
selModel: this.GridCheckBoxModel,
features: [{
ftype: 'summary'//Ext.grid.feature.Summary表格汇总特性
}],
tbar: [{
text: Zi.LAN.sczdmingxi, //删除账单明细
tooltip: Zi.LAN.sczdmingxi, //删除账单明细
iconCls: "btndeletedetail",
handler: function (button, event) {
this.onDeleteClick(button, event, 1);
},
scope: this
}],
columns: [{
sortable: true,
dataIndex: 'DUINO',
header: 'DUINO',
hidden: true,
width: 100
}, {
sortable: true,
dataIndex: 'BSNO',
header: 'BSNO',
hidden: true,
width: 100
}, {
sortable: true,
dataIndex: 'CUSTNO',
header: Zi.LAN.DelegateNumber, //委托编号
summaryType: 'count',
width: 80
}, {
sortable: true,
dataIndex: 'MBLNO',
header: Zi.LAN.ZhuTDH, //主提单号
width: 90
}, {
sortable: true,
dataIndex: 'CUSTOMERNAME',
header: Zi.LAN.Requester, //委托单位
width: 100
}, {
sortable: true,
dataIndex: 'VESSEL',
header: Zi.LAN.chuanname, //船名
width: 150
}, {
sortable: true,
dataIndex: 'VOYNO',
header: Zi.LAN.vessel, //航次
width: 60
}, {
sortable: true,
dataIndex: 'ETD',
header: Zi.LAN.SailingDate, //开船日期
renderer: Ext.util.Format.dateRenderer('Y-m-d'),
width: 80
}, {
sortable: true,
dataIndex: 'ACCDATE',
header: Zi.LAN.AccountingPeriod, //会计期间
width: 80
}, {
sortable: true,
dataIndex: 'OP',
header: Zi.LAN.Operating, //操作
width: 80
}, {
sortable: true,
dataIndex: 'BSSOURCE',
header: Zi.LAN.BusinessSource, //业务来源
width: 80
}, {
sortable: true,
dataIndex: 'RMBDR',
header: Zi.LAN.yshouRmbi, //应收RMB
summaryType: 'sum',
summaryRenderer: Ext.util.Format.numberRenderer('00.00'),
width: 80
}, {
sortable: true,
dataIndex: 'BALRMBDR',
header: Zi.LAN.weishourmb, //未收RMB
summaryType: 'sum',
summaryRenderer: Ext.util.Format.numberRenderer('00.00'),
width: 80
}, {
sortable: true,
dataIndex: 'USDDR',
header: Zi.LAN.yingsUsd, //应收USD
summaryType: 'sum',
summaryRenderer: Ext.util.Format.numberRenderer('00.00'),
width: 80
}, {
sortable: true,
dataIndex: 'BALUSDDR',
header: Zi.LAN.wsUSD, //未收USD
summaryType: 'sum',
summaryRenderer: Ext.util.Format.numberRenderer('00.00'),
width: 80
}, {
sortable: true,
dataIndex: 'OTDR',
header:Zi.LAN.yingsOT, //应收OT
summaryType: 'sum',
summaryRenderer: Ext.util.Format.numberRenderer('00.00'),
width: 80
}, {
sortable: true,
dataIndex: 'BALOTDR',
header: Zi.LAN.weisOT , //未收OT
summaryType: 'sum',
summaryRenderer: Ext.util.Format.numberRenderer('00.00'),
width: 80
}, {
sortable: true,
dataIndex: 'RMBCR',
header: Zi.LAN.tingfRmbi, //应付RMB
summaryType: 'sum',
summaryRenderer: Ext.util.Format.numberRenderer('00.00'),
width: 80
}, {
sortable: true,
dataIndex: 'BALRMBCR',
header: Zi.LAN.weifuRmbi, //未付RMB
summaryType: 'sum',
summaryRenderer: Ext.util.Format.numberRenderer('00.00'),
width: 80
}, {
sortable: true,
dataIndex: 'USDCR',
header: Zi.LAN.yingfuusd , //应付USD
summaryType: 'sum',
summaryRenderer: Ext.util.Format.numberRenderer('00.00'),
width: 80
}, {
sortable: true,
dataIndex: 'BALUSDCR',
header: Zi.LAN.weifuusd, //未付USD
summaryType: 'sum',
summaryRenderer: Ext.util.Format.numberRenderer('00.00'),
width: 80
}, {
sortable: true,
dataIndex: 'OTCR',
header: Zi.LAN.yingfuot, //应付OT
summaryType: 'sum',
summaryRenderer: Ext.util.Format.numberRenderer('00.00'),
width: 80
}, {
sortable: true,
dataIndex: 'BALOTCR',
header: Zi.LAN.weifuot, //未付OT
summaryType: 'sum',
summaryRenderer: Ext.util.Format.numberRenderer('00.00'),
width: 80
}, {
sortable: true,
dataIndex: 'SALE',
header: Zi.LAN.LanhuoPeople, //揽货人
width: 80
}
]
});
this.storeFeeList = Ext.create('Ext.data.Store', {
model: 'MsChDuiDetail',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/MvcShipping/MsChDui/GetDetailList',
reader: {
id: 'DUINO,BSNO',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.FeeGridCheckBoxModel = Ext.create('Ext.selection.CheckboxModel');
this.gridFeeList = new Ext.grid.GridPanel({
store: this.storeFeeList,
enableHdMenu: false,
region: 'center',
loadMask: { msg: Zi.LAN.LoadData }, //数据加载中,请稍等...
trackMouseOver: true,
disableSelection: false,
selModel: this.FeeGridCheckBoxModel,
tbar: [{
text: Zi.LAN.deletezdfy, //删除账单费用明细
tooltip: Zi.LAN.deletezdfy,
iconCls: "btndeletedetail",
handler: function (button, event) {
this.onDelDetailClick(button, event, 2);
},
scope: this
}],
columns: [{
sortable: true,
dataIndex: 'CH_ID',
header: 'CH_ID',
hidden: true,
width: 100
}, {
sortable: true,
dataIndex: 'CustomerName',
header: Zi.LAN.kehname, //客户名称
width: 90
}, {
sortable: true,
dataIndex: 'FeeType_Ref',
header: Zi.LAN.PayReceive, //收付
width: 40
}, {
sortable: true,
dataIndex: 'FeeName',
header: Zi.LAN.CostName, //费用名称
width: 90
}, {
sortable: true,
dataIndex: 'Amount',
header: Zi.LAN.AmountOfMoney, //金额
width: 70,
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;
}
}, {
sortable: true,
dataIndex: 'Currency',
header: Zi.LAN.Currency, //币别
width: 40
}, {
sortable: true,
dataIndex: 'BalAmount',
header: Zi.LAN.wjmoney, //未结金额
width: 70,
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;
}
}, {
sortable: true,
dataIndex: 'ExChangerate',
header: Zi.LAN.huilv, //汇率
width: 60
}]
});
this.storeBodyAddList = Ext.create('Ext.data.Store', {
model: 'MsDuiBill',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/MvcShipping/MsChDui/GetBLListData',
reader: {
id: 'BSNO,DUINO',
root: 'data',
totalProperty: 'totalCount'
}
}
});
//明细表表格
this.AddGridCheckBoxModel = Ext.create('Ext.selection.CheckboxModel');
this.gridAddList = new Ext.grid.GridPanel({
store: this.storeBodyAddList,
enableHdMenu: false,
region: 'center',
loadMask: { msg: Zi.LAN.LoadData }, //数据加载中,请稍等...
trackMouseOver: true,
disableSelection: false,
selModel: this.AddGridCheckBoxModel,
tbar: [{
text: Zi.LAN.addzdmingxi, //添加账单明细
tooltip: Zi.LAN.addzdmingxi,
iconCls: "btnadddetail",
handler: function (button, event) {
this.onAddClick(button, event);
},
scope: this
}],
columns: [{
sortable: true,
dataIndex: 'BSNO',
header: 'BSNO',
hidden: true,
width: 100
}, {
sortable: true,
dataIndex: 'OPLBNAME',
header: Zi.LAN.yewutype, //业务类别
width: 80
}, {
sortable: true,
dataIndex: 'ISDEBIT',
header: Zi.LAN.isduizhang, //是否对账
width: 80
}, {
sortable: true,
dataIndex: 'DUINO',
header: Zi.LAN.duiznum, //对账编号
width: 80
}, {
sortable: true,
dataIndex: 'CUSTNO',
header: Zi.LAN.DelegateNumber, //委托编号
width: 108
}, {
sortable: true,
dataIndex: 'MBLNO',
header: Zi.LAN.ZhuTDH, //主提单号
width: 108
}, {
sortable: true,
dataIndex: 'CUSTOMERNAME',
header: Zi.LAN.Requester, //委托单位
width: 100
}, {
sortable: true,
dataIndex: 'ETD',
header: Zi.LAN.SailingDate, //开船日期
renderer: Ext.util.Format.dateRenderer('Y-m-d'),
width: 100
}, {
sortable: true,
dataIndex: 'SALE',
header: Zi.LAN.LanhuoPeople, //揽货人
width: 80
}, {
sortable: true,
dataIndex: 'ACCDATE',
header: Zi.LAN.AccountingPeriod, //会计期间
width: 80
}, {
sortable: true,
dataIndex: 'OP',
header: Zi.LAN.Operating, //操作
width: 80
}, {
sortable: true,
dataIndex: 'INPUTBY',
header: Zi.LAN.lurmen, //录入人
width: 80
}, {
sortable: true,
dataIndex: 'PORTLOAD',
header:Zi.LAN.qiyunport, //起运港
width: 120
}, {
sortable: true,
dataIndex: 'PORTDISCHARGE',
header: Zi.LAN.mudport, //目的港
width: 120
}, {
sortable: true,
dataIndex: 'VESSEL',
header: Zi.LAN.chuanname, //船名
width: 150
}, {
sortable: true,
dataIndex: 'VOYNO',
header: Zi.LAN.vessel, //航次
width: 60
}
]
});
this.storeAddFeeList = Ext.create('Ext.data.Store', {
model: 'MsChDuiDetail',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/MvcShipping/MsChDui/GetFeeDetailList',
reader: {
id: 'BSNO',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.AddFeeGridCheckBoxModel = Ext.create('Ext.selection.CheckboxModel');
this.gridAddFeeList = new Ext.grid.GridPanel({
store: this.storeAddFeeList,
enableHdMenu: false,
anchor: '100% 50%',
loadMask: { msg: Zi.LAN.LoadData }, //数据加载中,请稍等...
trackMouseOver: true,
disableSelection: false,
selModel: this.AddFeeGridCheckBoxModel,
tbar: [{
text: Zi.LAN.addfymingxi, //添加账单费用明细
tooltip: Zi.LAN.addfymingxi,
iconCls: "btnadddetail",
handler: function (button, event) {
this.onAddDetailClick(button, event);
},
scope: this
}],
columns: [{
sortable: true,
dataIndex: 'CH_ID',
header: 'CH_ID',
hidden: true,
width: 100
}, {
sortable: true,
dataIndex: 'BSNO',
header: 'BSNO',
hidden: true,
width: 100
}, {
sortable: true,
dataIndex: 'CustomerName',
header: Zi.LAN.kehname, //客户名称
width: 90
}, {
sortable: true,
dataIndex: 'FeeType_Ref',
header: Zi.LAN.PayReceive, //收付
width: 40
}, {
sortable: true,
dataIndex: 'FeeName',
header: Zi.LAN.CostName, //费用名称
width: 90
}, {
sortable: true,
dataIndex: 'Amount',
header: Zi.LAN.AmountOfMoney, //金额
width: 70,
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;
}
}, {
sortable: true,
dataIndex: 'Currency',
header: Zi.LAN.Currency, //币别
width: 40
}, {
sortable: true,
dataIndex: 'BalAmount',
header: Zi.LAN.wjmoney, //未结金额
width: 70,
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;
}
}, {
sortable: true,
dataIndex: 'ExChangerate',
header: Zi.LAN.huilv, //汇率
width: 60
}
]
});
this.storeCustCodeFee = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CustomRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetCustomRefList' }
});
this.storeCustCodeFee.load({ params: { condition: ""} });
this.comboxAddCustCode = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: Zi.LAN.fyduixiang, //费用对象
store: this.storeCustCodeFee,
forceSelection: true,
name: 'CUSTNAME',
valueField: 'CustName',
displayField: 'CodeAndName'
});
this.StoreOpLb = Ext.create('Ext.data.Store', {
fields: ['OPLBNAME']
});
this.StoreOpLb.add({ "OPLBNAME": "海运出口" });
this.StoreOpLb.add({ "OPLBNAME": "海运进口" });
this.StoreOpLb.add({ "OPLBNAME": "报关业务" });
this.StoreOpLb.add({ "OPLBNAME": "进口贸易" });
this.StoreOpLb.add({ "OPLBNAME": "大宗散货" });
this.StoreOpLb.add({ "OPLBNAME": "综合业务" });
this.comboxOpLb = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: Zi.LAN.yewutype, //业务类别
store: this.StoreOpLb,
valueField: 'OPLBNAME',
displayField: 'OPLBNAME',
forceSelection: true,
name: 'OPLBNAME'
});
this.storeAddDCType = Ext.create('Ext.data.Store', {
fields: ['DC', 'NAME']
});
this.storeAddDCType.add({ "DC": "", "NAME": "全部" });
this.storeAddDCType.add({ "DC": "1", "NAME": "应收" });
this.storeAddDCType.add({ "DC": "2", "NAME": "应付" });
this.comboxaddDCType = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: Zi.LAN.PayReceive, //收付
store: this.storeAddDCType,
valueField: 'DC',
displayField: 'NAME',
forceSelection: true,
name: 'DC'
});
this.storeIsDebit = Ext.create('Ext.data.Store', {
fields: ['DC', 'NAME']
});
this.storeIsDebit.add({ "DC": "1", "NAME": "是" });
this.storeIsDebit.add({ "DC": "2", "NAME": "否" });
this.comboxIsDebit = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: Zi.LAN.bdyidaozhang, //包含已对账
store: this.storeIsDebit,
valueField: 'DC',
displayField: 'NAME',
forceSelection: true,
name: 'ISDEBIT'
});
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', {
fieldLabel: Zi.LAN.Currency, //币别
store: this.StoreCurr,
forceSelection: true,
name: 'Currency',
valueField: 'CURR',
displayField: 'CURR'
});
this.storeFeeNameRef = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.FeeTypeRefModel',
proxy: { url: '/MvcShipping/MsChFee/GetFeeTypeRefList' }
});
this.comboxFeeNameRef = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: Zi.LAN.CostName, //费用名称
store: this.storeFeeNameRef,
forceSelection: true,
name: 'FeeName',
valueField: 'Name',
displayField: 'CodeAndName'
});
this.storeFeeNameRef.load({ params: { condition: ""} });
this.comboxaddFeeType = Ext.create('DsExt.ux.RefEnumCombox', {
fieldLabel: Zi.LAN.fyfanwei, //费用范围
store: this.storeFeeType,
forceSelection: true,
name: 'FEERANGE'
});
this.storePort = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.PortRefModel',
proxy: { url: '/MvcShipping/MsBaseInfo/GetPortRefList' }
});
this.storePort.load();
this.comboxPortRef = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: Zi.LAN.portwai, //港口(国外)
store: this.storePort,
name: 'Port',
valueField: 'PORT',
displayField: 'PORTANDNAME'
});
this.storeOurPort = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.PortRefModel',
proxy: { url: '/MvcShipping/MsBaseInfo/GetOurPortRefList' }
});
this.storeOurPort.load();
this.comboxOurPortRef = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: Zi.LAN.portnei, //港口(国内)
store: this.storeOurPort,
name: 'OurPort',
valueField: 'PORT',
displayField: 'PORTANDNAME'
});
this.storeBsType = Ext.create('DsExt.ux.RefEnumStore', {});
this.storeBsType.load({ params: { enumTypeId: 96004} });
this.comboxBsType = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: Zi.LAN.yunstype, //运输类型
store: this.storeBsType,
name: 'BSTYPE',
valueField: 'EnumValueName',
displayField: 'EnumValueName'
});
this.storeVoyVeg = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.VesselModel',
proxy: { url: '/CommMng/BasicDataRef/GetVesselList' }
});
this.storeVoyVeg.load({ params: { condition: ""} });
this.comboxVoyVeg = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: Zi.LAN.chuanname, //船 名
store: this.storeVoyVeg,
name: 'VESSEL',
valueField: 'VESSEL',
flex: 1,
displayField: 'VESSEL'
});
this.CheckSaveQuery = new Ext.form.Checkbox({
fieldLabel: Zi.LAN.jixiselect, //记忆查询条件
checked: true,
flex: 0.5,
width: 90
});
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: Zi.LAN.Requester, //委托单位
store: this.storeCustCode,
forceSelection: true,
name: 'PS_CUSTOMERNAME',
valueField: 'CustName',
displayField: 'CodeAndName',
enableKeyEvents: true,
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
});
_this = this;
this.formSearch = Ext.widget('form', {
frame: true,
region: 'north',
bodyPadding: 5,
fieldDefaults: {
margins: '2 2 2 2',
labelAlign: 'right',
flex: 1,
labelWidth: 90,
msgTarget: 'qtip'
},
items: [
{//fieldset 1
xtype: 'container',
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: 'PARAMVALUE',
name: 'PARAMVALUE', value: '否', hidden: true
}, this.comboxAddCustCode, this.comboxOpLb, {
fieldLabel: Zi.LAN.selectnum, //编号检索
name: 'CustomNo',
enableKeyEvents: true,
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
}, {
fieldLabel: Zi.LAN.cyewudate, //从业务日期
format: 'Y-m-d',
xtype: 'datefield',
name: 'ExpDateBgn',
enableKeyEvents: true,
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
}, {
fieldLabel: Zi.LAN.dyewudate, //到业务日期
format: 'Y-m-d',
xtype: 'datefield',
name: 'ExpDateEnd',
enableKeyEvents: true,
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
}, {
xtype: 'button',
flex: 0.5,
width: 90,
text: Zi.LAN.ResetCondition, //重置条件
iconCls: "btnreset",
handler: function (button, event) {
this.onClearSql(button, event);
},
scope: this
}
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [this.comboxaddDCType, this.comboxCurr, this.comboxFeeNameRef, this.comboxIsDebit, this.comboxaddFeeType, {
xtype: 'button',
width: 90,
flex: 0.5,
text: Zi.LAN.ExecuteQuery, //执行查询
iconCls: "btnrefresh",
handler: function (button, event) {
this.onRefreshClick(button, event);
var issavevalue = false;
var isvisible = true;
if (this.CheckSaveQuery.checked)
issavevalue = true
saveQuerySetting(this.formname, this.formSearch, isvisible, issavevalue);
},
scope: this
}
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: Zi.LAN.AccountingPeriod, //会计期间
xtype: 'monthfield',
name: 'ACCDATEFR',
enableKeyEvents: true,
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
}, {
fieldLabel: Zi.LAN.AccountingPeriod, //会计期间
xtype: 'monthfield',
name: 'ACCDATETO',
enableKeyEvents: true,
listeners: {
specialkey: function (field, e){
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
}, this.comboxPortRef, this.comboxOurPortRef, this.comboxBsType,
this.CheckSaveQuery
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [this.comboxVoyVeg,{
fieldLabel: Zi.LAN.vessel, //航次
name: 'VOYNO'
}, this.comboxCustCode, { xtype: 'hiddenfield', flex: 1 }, { xtype: 'hiddenfield', flex: 1 }, { xtype: 'hiddenfield', width: 90, flex: 0.5 }
]
}
]//end items(fieldset 1)
}//end fieldset 1
]//end root items
});
//#endregion 明细表
//#region 选择合计
this.storeSelectSum = Ext.create('Ext.data.Store', {
pageSize: 10,
fields: [
{ name: 'CURRENCY', type: 'string' },
{ name: 'DR', type: 'number' },
{ name: 'NODR', type: 'number' },
{ name: 'CR', type: 'number' },
{ name: 'NOCR', type: 'number' }
],
remoteSort: true,
proxy: {
type: 'ajax',
url: '/MvcShipping/MsChDui/GetSelectSum',
reader: {
id: '',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.gridSelectSum = new Ext.grid.GridPanel({
store: this.storeSelectSum,
enableHdMenu: false,
anchor: '100% 50%',
// region: 'south',
loadMask: { msg: Zi.LAN.LoadData }, //数据加载中,请稍等...
trackMouseOver: true,
disableSelection: false,
tbar: [{
xtype: 'label',
width: 160,
id: 'SelectGrid',
height: 22,
text: Zi.LAN.countfyong//所选费用合计
}],
columns: [{
sortable: true,
dataIndex: 'CURRENCY',
header: Zi.LAN.Currency , //币 别
width: 80
}, {
sortable: true,
dataIndex: 'DR',
header: Zi.LAN.YingShou, //应收
width: 80
}, {
sortable: true,
dataIndex: 'NODR',
header: Zi.LAN.weishou, //未收
width: 80
}, {
sortable: true,
dataIndex: 'CR',
header: Zi.LAN.YingFu, //应付
width: 80
}, {
sortable: true,
dataIndex: 'NOCR',
header: Zi.LAN.weifu, //未付
width: 80
}
]
});
//#endregion
//#region 布局
//控件布局
this.panelService = new Ext.Panel({
layout: "border",
region: 'center',
margin: '2 2',
items: [this.gridList]//账单明细左边的业务列表
});
this.panelfee = new Ext.Panel({
layout: "border",
region: 'east',
width: 400,
split: true,
margin: '2 2',
items: [this.gridFeeList]//账单明细右边的费用列表
});
this.paneldetail = new Ext.Panel({
title:Zi.LAN.zdmingx, //账单明细
layout: "border",
region: "center",
items: [
this.panelService, this.panelfee
]
});
this.panelAddService = new Ext.Panel({
layout: "border",
region: 'center',
margin: '2 2',
items: [this.gridAddList]
});
this.panelAddfee = new Ext.Panel({
layout: "anchor",
region: 'east',
width: 400,
split: true,
margin: '2 2',
items: [this.gridAddFeeList, this.gridSelectSum]
});
this.paneladddetail = new Ext.Panel({
layout: "border",
region: 'center',
items: [this.panelAddService, this.panelAddfee
]
});
this.paneladd = new Ext.Panel({
title: Zi.LAN.addzdmingxi, //添加账单明细
layout: "border",
region: 'south',
split: true,
height: 390,
items: [
this.formSearch, this.paneladddetail
]
});
this.panelTop = new Ext.Panel({
layout: "border",
region: "north",
height: 100,
items: [this.panelBtn, this.formEdit]
});
Ext.apply(this, {
items: [this.panelTop, this.paneldetail, this.paneladd]
});
//#endregion
//绑定查询窗体
this.ParentWin = window.parent.opener;
//初始化数据
this.InitData();
//绑定事件
var billno = '*';
if (this.opStatus == 'edit') {
billno = this.editRecord.get('DUINO');
};
// billno = this.formEdit.getForm().findField('DUINO').getValue();
this.storeBodyList.load({ params: { condition: " DUINO='" + billno + "'"} });
this.storeBodyList.on('beforeload', function (store) {
var sql = " DUINO='" + billno + "'";
Ext.apply(store.proxy.extraParams, { condition: sql });
}, this);
this.storeBodyList.on('load', function (store, records) {
if (store.getCount() > 0) {
this.gridList.getSelectionModel().select(0);
}
}, this);
this.gridList.getSelectionModel().on('select', function (model, record, index) {
var duino = record.data.DUINO;
var bsno = record.data.BSNO;
var sql = " DUINO='" + duino + "' and BSNO='" + bsno + "'";
this.storeFeeList.load({ params: { condition: sql} });
}, this);
this.storeBodyAddList.on('beforeload', function (store) {
var sql = this.getCondition();
var duisql = this.getduiCondition();
var form = this.formSearch.getForm();
var isdebit = form.findField('ISDEBIT').getValue();
this.IsDebit = isdebit;
Ext.apply(store.proxy.extraParams, { condition: this.BillSql, duicondition: this.DuiBillSql, isdebit: this.IsDebit });
}, this);
this.storeBodyAddList.on('load', function (store, records) {
if (store.getCount() > 0) {
this.gridAddList.getSelectionModel().select(0);
}
}, this);
this.gridAddList.getSelectionModel().on('select', function (model, record, index) {
var Duino = this.formEdit.getForm().findField('DUINO').getValue();
var bsno = record.data.BSNO;
var isdebit = record.data.ISDEBIT;
var sql = "";
var duino = record.data.DUINO;
if (isdebit == '是') {
sql = " DUINO='" + duino + "' AND BSNO='" + bsno + "' and GID NOT IN (SELECT GID from v_dui_fee where duino='" + Duino + "')";
} else {
sql = " (ISDEBIT=0 or ISDEBIT IS NULL) AND BSNO='" + bsno + "'";
};
sql = sql + getAndConSql(sql, this.FeeSqlStr, this.FeeSqlStr);
this.storeAddFeeList.load({ params: { condition: sql, isdebit: isdebit} });
}, this);
_this = this;
this.gridAddList.on({
selectionchange: function (sm, selections) {
var SelectGridtext = Ext.getCmp('SelectGrid');
if (selections.length == 0) {
_this.storeSelectSum.removeAll();
SelectGridtext.setText(Zi.LAN.countfyong); //所选费用合计
return;
}
var Duino = _this.formEdit.getForm().findField('DUINO').getValue();
var feeBSNOSql = '';
var feeDUIBSNOSql = '';
var sql = '';
var duisql = '';
var j = selections.length;
for (var i = 0; i < selections.length; i++) {
var rec = selections[i];
if (rec.data.ISDEBIT == '是') {
if (feeDUIBSNOSql == '') {
feeDUIBSNOSql = " (DUINO='" + rec.data.DUINO + "' AND BSNO='" + rec.data.BSNO + "') ";
} else {
feeDUIBSNOSql = feeDUIBSNOSql + " AND " + " (DUINO='" + rec.data.DUINO + "' AND BSNO='" + rec.data.BSNO + "') ";
}
}
else {
var feeBSNO = "'" + rec.data.BSNO + "'";
if (feeBSNOSql == '') {
feeBSNOSql = feeBSNO;
} else {
feeBSNOSql = feeBSNOSql + "," + feeBSNO;
}
}
}
if (feeBSNOSql == '') {
sql = " 1=2 ";
}
else {
sql = " BSNO IN (" + feeBSNOSql + ")";
sql = sql + getAndConSql(sql, _this.FeeSqlStr, _this.FeeSqlStr);
}
if (feeDUIBSNOSql == '') {
duisql = " 1=2 ";
}
else {
duisql = duisql + getAndConSql(duisql, _this.FeeSqlStr, _this.FeeSqlStr);
}
SelectGridtext.setText(Zi.LAN.selectxuanzhong + j + Zi.LAN.pyewu);
_this.storeSelectSum.load({
params: { start: 0, limit: 10, duino: Duino, duistr: duisql,
feesql: sql
},
waitMsg: Zi.LAN.NowSelect, //正在查询数据...
scope: this
});
}
});
LoadQueryData(this.formname, this.formSearch, this.CheckSaveQuery);
}, //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 = " DUINO='" + this.editRecord.get('DUINO') + "'";
this.LoadData(this.opStatus, condition);
}, //end InitData
LoadData: function (opstatus, condition) {
this.serialNo = 0;
this.workSerialNo = 0;
this.bodyDel = [];
this.opStatus = opstatus;
Ext.Ajax.request({
waitMsg: Zi.LAN.onselect, //正在查询主表数据...
url: '/MvcShipping/MsChDui/GetData',
params: {
handle: opstatus,
condition: condition
},
callback: function (options, success, response) {
if (success) {
var result = Ext.JSON.decode(response.responseText);
if (!result.Success) {
Ext.Msg.show({
title: Zi.LAN.Prompt, //提示
msg: result.Message,
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.OK
});
return;
}
var data = result.data;
this.formEdit.getForm().reset();
this.formEdit.getForm().setValues(data);
} else {//请求出现错误,请重试
Ext.MessageBox.alert(Zi.LAN.qqerror, response.responseText);
}
},
scope: this
});
Ext.Ajax.request({
waitMsg: Zi.LAN.onselect, //正在查询主表数据...
url: '/MvcShipping/MsSysParamSet/GetData',
params: {
handle: 'edit',
condition: "PARAMNAME='ISSUBMITFEE'"
},
callback: function (options, success, response) {
if (success) {
var result = Ext.JSON.decode(response.responseText);
if (!result.Success) {
Ext.Msg.show({
title: Zi.LAN.Prompt, //提示
msg: result.Message,
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.OK
});
return;
}
var data = result.data;
this.formSearch.getForm().reset();
this.formSearch.getForm().setValues(data);
} else {//请求出现错误,请重试
Ext.MessageBox.alert(Zi.LAN.qqerror, response.responseText);
}
},
scope: this
});
if (opstatus == "add") {
this.storeBodyList.removeAll();
this.storeFeeList.removeAll();
}
// this.storeFeeList.load({ params: { condition: " DUINO='" + billno + "'"} });
}, // end LoadDate
Save: function (type) {
var basicForm = this.formEdit.getForm();
if (!basicForm.isValid()) {
return;
}
var data = basicForm.getValues();
//正在保存数据, 请稍侯..
Ext.Msg.wait(Zi.LAN.nowsave );
Ext.Ajax.request({
waitMsg: Zi.LAN.baocunshujunow ,
url: '/MvcShipping/MsChDui/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.commit();
}
if (type == '0') {
this.opStatus = 'edit';
} else if (type == '1') {
window.close();
} else {
this.LoadData('add', '');
}
} else {//错误
Ext.Msg.show({ title: Zi.LAN.Error, msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
}
} else {//请重试
Ext.Msg.show({ title: Zi.LAN.qagin,
msg: Zi.LAN.FuWuQiError, //服务器响应出错
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
}
}
});
}, //end save
onAddDetailClick: function (button, event) {
this.addDetail();
}, //end onAddDetailClick
onDelDetailClick: function (button, event, type) {
this.deleteDetail();
}, //onDelDetailClick
onAddClick: function (button, event) {
this.addBill();
}, //end onAddDetailClick
onDeleteClick: function (button, event) {
this.deleteBill();
}, //end onAddDetailClick
gridAfterEdit: function (editor, e, eOpts) {
//需要自己实现里面的事件
},
addDetail: function () {
var basicForm = this.formEdit.getForm();
var Duino = this.formEdit.getForm().findField('DUINO').getValue();
if (Duino == '*' || basicForm.isDirty()) {
var CUSTNAME = this.formEdit.getForm().findField('CUSTNAME').getValue();
if (CUSTNAME == null || CUSTNAME == "") {
var selectedRecords = this.gridAddFeeList.selModel.getSelection();
if (selectedRecords.length > 0) {
var rec = selectedRecords[0];
var cust = rec.data.CustomerName;
if ((CUSTNAME == '') || (CUSTNAME == null))
this.formEdit.getForm().findField('CUSTNAME').setValue(cust);
} else {
//対帐客户不能为空
Ext.Msg.show({ title: Zi.LAN.Prompt, msg: Zi.LAN.duiznotnull, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
//
//
// Ext.Msg.show({ title: Zi.LAN.Prompt, msg: '対帐客户不能为空!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
// return;
}
_this = this;
var data = basicForm.getValues();
//正在保存数据, 请稍侯..
Ext.Msg.wait(Zi.LAN.nowsave );
Ext.Ajax.request({
waitMsg: Zi.LAN.baocunshujunow ,
url: '/MvcShipping/MsChDui/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.commit();
}
this.opStatus = 'edit';
_this.addDetailfn();
} else {//错误
Ext.Msg.show({ title: Zi.LAN.Error, msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
}
} else {//请重试
Ext.Msg.show({ title: Zi.LAN.qagin,
msg: Zi.LAN.FuWuQiError, //服务器响应出错
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
}
}
});
} else {
this.addDetailfn();
};
}, //end save
addDetailfn: function () {
var Duino = this.formEdit.getForm().findField('DUINO').getValue();
var duicust = this.editRecord.data.CUSTNAME;
var duino = this.editRecord.data.DUINO;
var selections = this.gridAddList.getSelectionModel().getSelection();
var record = selections[0];
var billduino = record.data.DUINO;
var isdebit = record.data.ISDEBIT;
var selectedRecords = this.gridAddFeeList.selModel.getSelection();
var bodyAddDatas = [];
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
var cust = rec.data.CustomerName;
var bsno = rec.data.BSNO;
if (cust == duicust) {
bodyAddDatas.push(rec);
}
}
if (bodyAddDatas.length == 0) {//提示', msg: '没有要添加的费用明细!
Ext.Msg.show({ title: Zi.LAN.Prompt, msg: Zi.LAN.notaddmingxi, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
};
var jsonbodyAddDatas = ConvertRecordsToJsonAll(bodyAddDatas);
Ext.Ajax.request({//正在添加数据
waitMsg: Zi.LAN.addnumnow,
url: '/MvcShipping/MsChDui/AddDetail',
params: {
duino: duino,
data: jsonbodyAddDatas,
isdebit: isdebit
},
callback: function (options, success, response) {
if (success) {
var result = Ext.JSON.decode(response.responseText);
if (!result.Success) {
Ext.Msg.show({
title: Zi.LAN.Prompt, //提示
msg: result.Message,
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.OK
});
return;
} else {
var sql = "";
if (isdebit == '是') {
sql = " DUINO='" + billduino + "' AND BSNO='" + bsno + "' and GID NOT IN (SELECT GID FROM V_DUI_FEE WHERE DUINO='" + Duino + "')";
} else {
sql = " (ISDEBIT=0 or ISDEBIT IS NULL) AND BSNO='" + bsno + "'";
};
var feesqlstr = this.getFeeCondition();
sql = sql + getAndConSql(sql, feesqlstr, feesqlstr);
this.storeAddFeeList.load({ params: { condition: sql, isdebit: isdebit} });
this.storeBodyList.load({ params: { condition: " DUINO='" + duino + "'"} });
}
} else {//请求出现错误,请重试
Ext.MessageBox.alert(Zi.LAN.qqerror, response.responseText);
}
},
scope: this
});
},
addBill: function () {
var basicForm = this.formEdit.getForm();
var Duino = this.formEdit.getForm().findField('DUINO').getValue();
if (Duino == '*' || basicForm.isDirty()) {
var CUSTNAME = this.formEdit.getForm().findField('CUSTNAME').getValue();
if (CUSTNAME == null || CUSTNAME == "") {
if (this.storeAddFeeList.getCount() > 0) {
var rec = this.storeAddFeeList.getAt(0);
var cust = rec.data.CustomerName;
if ((CUSTNAME == '') || (CUSTNAME == null))
this.formEdit.getForm().findField('CUSTNAME').setValue(cust);
} else {
//提示', msg: '对账客户不能为空!
Ext.Msg.show({ title: Zi.LAN.Prompt, msg: Zi.LAN.duiznotnull, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
}
_this = this;
var data = basicForm.getValues();
//正在保存数据, 请稍侯..
Ext.Msg.wait(Zi.LAN.nowsave );
Ext.Ajax.request({
waitMsg: Zi.LAN.baocunshujunow ,
url: '/MvcShipping/MsChDui/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.commit();
}
this.opStatus = 'edit';
_this.addBillfn();
} else {//错误
Ext.Msg.show({ title: Zi.LAN.Error, msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
}
} else {//请重试
Ext.Msg.show({ title: Zi.LAN.qagin,
msg: Zi.LAN.FuWuQiError, //服务器响应出错
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
}
}
});
} else {
this.addBillfn();
};
}, //end save
addBillfn: function () {
var Duino = this.formEdit.getForm().findField('DUINO').getValue();
var duicust = this.editRecord.data.CUSTNAME;
var duino = this.editRecord.data.DUINO;
var feeBSNOSql = '';
var sql = '';
var selectedRecords = this.gridAddList.selModel.getSelection();
if (selectedRecords.length == 0) {//提示', msg: '没有选择要添加的费用!
Ext.Msg.show({ title: Zi.LAN.Prompt, msg: Zi.LAN.notselectaddfy, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
};
var bodyAddDatas = [];
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
if (rec.data.ISDEBIT == '是') {
bodyAddDatas.push(rec);
}
else {
var feeBSNO = "'" + rec.data.BSNO + "'";
if (feeBSNOSql == '') {
feeBSNOSql = feeBSNO;
} else {
feeBSNOSql = feeBSNOSql + "," + feeBSNO;
}
}
}
if (feeBSNOSql == '') {
sql = "";
}
else {
sql = " BSNO IN (" + feeBSNOSql + ")";
sql = sql + getAndConSql(sql, this.FeeSqlStr, this.FeeSqlStr);
}
var jsonbodyAddDatas = ConvertRecordsToJsonAll(bodyAddDatas);
Ext.Ajax.request({
waitMsg: Zi.LAN.addnumnow, //正在添加数据...
url: '/MvcShipping/MsChDui/AddBill',
params: {
duino: duino,
duicust: duicust,
data: jsonbodyAddDatas,
feesql: sql
},
callback: function (options, success, response) {
if (success) {
var result = Ext.JSON.decode(response.responseText);
if (!result.Success) {
Ext.Msg.show({
title: Zi.LAN.Prompt, //提示
msg: result.Message,
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.OK
});
return;
} else {
this.storeBodyAddList.load({ params: { condition: this.BillSql, duicondition: this.DuiBillSql, isdebit: this.IsDebit} });
this.storeBodyList.load({ params: { condition: " DUINO='" + duino + "'"} });
}
} else {//请求出现错误,请重试
Ext.MessageBox.alert(Zi.LAN.qqerror, response.responseText);
}
},
scope: this
});
},
deleteDetail: function (type) {
var selectedRecords = this.gridFeeList.selModel.getSelection();
if (selectedRecords.length == 0) {//提示', msg: '没有要删除的费用明细!
Ext.Msg.show({ title: Zi.LAN.Prompt, msg:Zi.LAN.addnumnow, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
};
var duino = this.editRecord.data.DUINO;
var feeCH_IDSql = '';
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
var feeCH_ID = "'" + rec.data.CH_ID + "'";
if (feeCH_IDSql == '') {
feeCH_IDSql = feeCH_ID;
} else {
feeCH_IDSql = feeCH_IDSql + "," + feeCH_ID;
}
}
var sql = " DEBITNO='" + duino + "' AND GID IN (" + feeCH_IDSql + ")";
var duisql = " CH_ID IN (" + feeCH_IDSql + ")";
Ext.Ajax.request({
waitMsg: Zi.LAN.nowdelete, //正在删除数据...
url: '/MvcShipping/MsChDui/DelDetail',
params: {
feesql: sql,
duisql: duisql
},
callback: function (options, success, response) {
if (success) {
var result = Ext.JSON.decode(response.responseText);
if (!result.Success) {
Ext.Msg.show({
title: Zi.LAN.Prompt, //提示
msg: result.Message,
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.OK
});
return;
} else {
var selectedRecords = this.gridFeeList.selModel.getSelection();
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
this.storeFeeList.remove(rec);
}
}
} else {//请求出现错误,请重试
Ext.MessageBox.alert(Zi.LAN.qqerror, response.responseText);
}
},
scope: this
});
},
deleteBill: function (type) {
var selectedRecords = this.gridList.selModel.getSelection();
if (selectedRecords.length == 0) {//没有要删除明细!
Ext.Msg.show({ title: Zi.LAN.Prompt, msg: Zi.LAN.nodeletemx, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
};
var duino = this.editRecord.data.DUINO;
var feeBSNOSql = '';
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
var feeBSNO = "'" + rec.data.BSNO + "'";
if (feeBSNOSql == '') {
feeBSNOSql = feeBSNO;
} else {
feeBSNOSql = feeBSNOSql + "," + feeBSNO;
}
}
var sql = " BSNO IN (" + feeBSNOSql + ")";
Ext.Ajax.request({
waitMsg: Zi.LAN.nowdelete, //正在删除数据...
url: '/MvcShipping/MsChDui/DelBill',
params: {
duino: duino,
feesql: sql
},
callback: function (options, success, response) {
if (success) {
var result = Ext.JSON.decode(response.responseText);
if (!result.Success) {
Ext.Msg.show({
title: Zi.LAN.Prompt,
msg: result.Message,
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.OK
});
return;
} else {
this.storeBodyList.load({ params: { condition: " DUINO='" + duino + "'" }, callback: function (r, options, success) {
if (success) {
if (r.length == 0) {
var sql = " BSNO='11111111' ";
this.storeFeeList.load({ params: { condition: sql} });
}
}
},
scope: this
});
}
} else {//请求出现错误,请重试
Ext.MessageBox.alert(Zi.LAN.qqerror, response.responseText);
}
},
scope: this
});
},
onRefreshClick: function (button, event) {
var sql = this.getCondition();
var duisql = this.getduiCondition();
var form = this.formSearch.getForm();
var isdebit = form.findField('ISDEBIT').getValue();
this.IsDebit = isdebit;
this.storeBodyAddList.load({
params: { start: 0, limit: 500, sort: '', condition: this.BillSql, duicondition: this.DuiBillSql, isdebit: this.IsDebit },
waitMsg: Zi.LAN.NowSelect, //正在查询数据
callback: function (r, options, success) {
if (success) {
if (r.length == 0) {
var sql = " BSNO='11111111' ";
this.storeAddFeeList.load({ params: { condition: sql, isdebit: '否'} });
}
}
},
scope: this
});
},
onClearSql: function () {
var form = this.formSearch.getForm();
form.reset();
},
getduiCondition: function () {
var form = this.formSearch.getForm();
if (!form.isValid()) {
Ext.Msg.alert(Zi.LAN.Prompt, Zi.LAN.SelectError); //提示', '查询条件赋值错误,请检查。
return '';
}
var Duino = this.formEdit.getForm().findField('DUINO').getValue();
var sql = "";
var customNo = form.findField('CustomNo').getValue();
sql = sql + getAndConSql(sql, customNo, " (CUSTNO like '%" + customNo + "%' or MBLNO like '%" + customNo + "%' or HBLNO like '%" + customNo + "%')");
var OPLBNAME = form.findField('OPLBNAME').getValue();
sql = sql + getAndConSql(sql, OPLBNAME, "OPLBNAME='" + OPLBNAME + "'");
var BSTYPE = form.findField('BSTYPE').getValue();
sql = sql + getAndConSql(sql, BSTYPE, "BSTYPE='" + BSTYPE + "'");
var VESSEL = form.findField('VESSEL').getValue();
sql = sql + getAndConSql(sql, VESSEL, "VESSEL='" + VESSEL + "'");
var VOYNO = form.findField('VOYNO').getValue();
sql = sql + getAndConSql(sql, VOYNO, "VOYNO like '%" + VOYNO + "%'");
var PORT = form.findField('Port').getValue();
sql = sql + getAndConSql(sql, PORT, " (PORTLOAD like '%" + PORT + "%' or PORTDISCHARGE like '%" + PORT + "%') ");
var OURPORT = form.findField('OurPort').getValue();
sql = sql + getAndConSql(sql, OURPORT, " (PORTLOAD like '%" + OURPORT + "%' or PORTDISCHARGE like '%" + OURPORT + "%') ");
var expDateBgn = form.findField('ExpDateBgn').getRawValue();
sql = sql + getAndConSql(sql, expDateBgn, "ETD >='" + expDateBgn + "'");
var expDateEnd = form.findField('ExpDateEnd').getRawValue();
sql = sql + getAndConSql(sql, expDateEnd, "ETD <='" + expDateEnd + "'");
var ACCDATE = form.findField('ACCDATEFR').getRawValue();
sql = sql + getAndConSql(sql, ACCDATE, "ACCDATE>='" + ACCDATE + "'");
var ACCDATETO = form.findField('ACCDATETO').getRawValue();
sql = sql + getAndConSql(sql, ACCDATETO, "ACCDATE<='" + ACCDATETO + "'");
var CUSTOMERNAME = form.findField('PS_CUSTOMERNAME').getValue();
sql = sql + getAndConSql(sql, CUSTOMERNAME, " CUSTOMERNAME='" + CUSTOMERNAME + "'");
var feesql = " DUINO<>'" + Duino + "' AND EXISTS (select 1 from v_dui_fee where v_dui_opbill.BSNO=v_dui_fee.BSNO and v_dui_fee.GID not in (select GID from v_dui_fee where DUINO='" + Duino + "') ";
FeeSqlStr = this.getFeeCondition();
feesql = feesql + getAndConSql(feesql, FeeSqlStr, FeeSqlStr);
feesql = feesql + ')';
sql = sql + getAndConSql(sql, feesql, feesql);
this.DuiBillSql = sql;
return sql;
},
getCondition: function () {
var form = this.formSearch.getForm();
if (!form.isValid()) {
Ext.Msg.alert(Zi.LAN.Prompt, Zi.LAN.SelectError); //提示', '查询条件赋值错误,请检查。
return '';
}
var sql = '';
var customNo = form.findField('CustomNo').getValue();
sql = sql + getAndConSql(sql, customNo, " (CUSTNO like '%" + customNo + "%' or MBLNO like '%" + customNo + "%' or HBLNO like '%" + customNo + "%')");
var PORT = form.findField('Port').getValue();
sql = sql + getAndConSql(sql, PORT, " (PORTLOAD like '%" + PORT + "%' or PORTDISCHARGE like '%" + PORT + "%') ");
var OURPORT = form.findField('OurPort').getValue();
sql = sql + getAndConSql(sql, OURPORT, " (PORTLOAD like '%" + OURPORT + "%' or PORTDISCHARGE like '%" + OURPORT + "%') ");
var OPLBNAME = form.findField('OPLBNAME').getValue();
sql = sql + getAndConSql(sql, OPLBNAME, "OPLBNAME='" + OPLBNAME + "'");
var BSTYPE = form.findField('BSTYPE').getValue();
sql = sql + getAndConSql(sql, BSTYPE, "BSTYPE='" + BSTYPE + "'");
var VESSEL = form.findField('VESSEL').getValue();
sql = sql + getAndConSql(sql, VESSEL, "VESSEL='" + VESSEL + "'");
var VOYNO = form.findField('VOYNO').getValue();
sql = sql + getAndConSql(sql, VOYNO, "VOYNO like '%" + VOYNO + "%'");
var expDateBgn = form.findField('ExpDateBgn').getRawValue();
sql = sql + getAndConSql(sql, expDateBgn, "ETD >='" + expDateBgn + "'");
var expDateEnd = form.findField('ExpDateEnd').getRawValue();
sql = sql + getAndConSql(sql, expDateEnd, "ETD <='" + expDateEnd + "'");
var ACCDATE = form.findField('ACCDATEFR').getRawValue();
sql = sql + getAndConSql(sql, ACCDATE, "ACCDATE>='" + ACCDATE + "'");
var ACCDATETO = form.findField('ACCDATETO').getRawValue();
sql = sql + getAndConSql(sql, ACCDATETO, "ACCDATE<='" + ACCDATETO + "'");
var feesql = ' EXISTS (select 1 from ch_fee where v_op_bill.BSNO=ch_fee.BSNO and (ISDEBIT=0 or ISDEBIT IS NULL) ';
this.FeeSqlStr = this.getFeeCondition();
feesql = feesql + getAndConSql(feesql, this.FeeSqlStr, this.FeeSqlStr);
feesql = feesql + ')';
sql = sql + getAndConSql(sql, feesql, feesql);
this.BillSql = sql;
return sql;
},
getFeeCondition: function () {
var form = this.formSearch.getForm();
var feesql = '';
var CUSTNAME = form.findField('CUSTNAME').getValue();
feesql = feesql + getAndConSql(feesql, CUSTNAME, "CUSTOMERNAME='" + CUSTNAME + "'");
var DC = form.findField('DC').getValue();
feesql = feesql + getAndConSql(feesql, DC, "FEETYPE=" + DC);
var Currency = form.findField('Currency').getValue();
feesql = feesql + getAndConSql(feesql, Currency, "Currency='" + Currency + "'");
var FeeName = form.findField('FeeName').getValue();
feesql = feesql + getAndConSql(feesql, FeeName, "FeeName='" + FeeName + "'");
var FEERANGE = form.findField('FEERANGE').getValue();
if (FEERANGE == '' || FEERANGE == null || FEERANGE == undefined) {
}
else {
if (feesql == '') {
if (FEERANGE == 'B') {
feesql = 'AMOUNT<>SETTLEMENT'
}
}
else {
if (FEERANGE == 'B') {
feesql = feesql + 'and AMOUNT<>SETTLEMENT'
}
}
}
var PARAMVALUE = form.findField('PARAMVALUE').getValue();
if (PARAMVALUE == '' || PARAMVALUE == null || PARAMVALUE == undefined) {
}
else {
if (feesql == '') {
if (PARAMVALUE == '是') {
feesql = ' FEESTATUS<>1'
}
}
else {
if (PARAMVALUE == '是') {
feesql = feesql + 'and FEESTATUS<>1'
}
}
}
return feesql;
},
Print: function () {
var basicForm = this.formEdit.getForm();
var billNo = basicForm.findField('DUINO').value;
if (billNo == '*' || billNo == '') {//错误', msg: '单据还没有保存,请保存后再打印
Ext.Msg.show({ title: Zi.LAN.Error, msg: Zi.LAN.djnotsave, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
return;
}
var printType = 'MSCHDUI';
var sql1 = "SELECT * FROM CH_DUI WHERE DUINO='" + billNo + "'";
var sql2 = "SELECT d.DB_ID,d.DUINO,d.BSNO,b.MBLNO,b.CUSTNO,b.CUSTOMERNAME,b.VESSEL,b.VOYNO,b.ETD,b.ACCDATE,b.SALE,f.RMBDR,f.RMBCR,f.RMBDR-f.STLRMBDR AS BALRMBDR,f.RMBCR-f.STLRMBCR AS BALRMBCR,f.USDDR,f.USDCR ";
sql2 = sql2 + " ,f.USDDR-f.STLUSDDR AS BALUSDDR,f.USDCR-f.STLUSDCR AS BALUSDCR,f.OTDR,f.OTCR,f.OTDR-f.STLOTDR AS BALOTDR,f.OTCR-f.STLOTCR as BALOTCR ";
sql2 = sql2 + " from ch_dui_bill d left join v_op_bill b on (b.BSNO=d.BSNO) left join v_dui_allfee_sum f on (f.BSNO=d.BSNO and f.DEBITNO=d.DUINO) ";
sql2 = sql2 + " where d.DUINO='" + billNo + "'";
var sql3 = "SELECT f.DUINO,f.BSNO,f.GID AS CH_ID,(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=99020 and EnumValueID=f.FeeType) as FeeType_Ref ";
sql3 = sql3 + ",f.feeName,f.customerName,f.amount,f.amount-f.Settlement as balamount,f.currency,f.exChangerate from v_dui_fee f where f.DUINO='" + billNo + "'";
var sql4 = "";
var sql5 = "";
var sql6 = "";
PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6);
},
ModulPrint: function () {
var basicForm = this.formEdit.getForm();
var billNo = basicForm.findField('DUINO').value;
if (billNo == '*' || billNo == '') {//'错误', msg: '单据还没有保存,请保存后再打印
Ext.Msg.show({ title: Zi.LAN.Error, msg: Zi.LAN.djnotsave, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
return;
}
var DMID = basicForm.findField('DM_ID').value;
if (DMID == '*' || DMID == '') {
Ext.Msg.show({ title: Zi.LAN.Error, msg: Zi.LAN.savethree, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
return;
}
var data = basicForm.getValues();
Ext.Msg.wait(Zi.LAN.zhuzhidata); //正在组织数据, 请稍侯.
Ext.Ajax.request({
waitMsg: Zi.LAN.zhuzhidatanow,
url: '/MvcShipping/MsChDui/GetPrintStr',
scope: this,
params: {
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 returnstr = jsonresult.Data;
var printType = 'MSCHDUIMODULE';
var sql1 = "SELECT * FROM CH_DUI WHERE DUINO='" + billNo + "'";
var sql2 = returnstr;
var sql3 = "SELECT f.DUINO,f.BSNO,f.GID AS CH_ID,(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=99020 and EnumValueID=f.FeeType) as FeeType_Ref ";
sql3 = sql3 + ",f.feeName,f.customerName,f.amount,f.amount-f.Settlement as balamount,f.currency,f.exChangerate from v_dui_fee f where f.DUINO='" + billNo + "'";
var sql4 = "";
var sql5 = "";
var sql6 = "";
PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6);
} else {//错误
Ext.Msg.show({ title: Zi.LAN.Error, msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
}
} else {
Ext.Msg.show({ title: Zi.LAN.qagin,
msg: Zi.LAN.FuWuQiError, //服务器响应出错
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
}
}
});
}
});