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/Account/Viewsjs/Chfee_ForeignSettlement/ChPayAppBLsettlementEdit.js

5264 lines
208 KiB
JavaScript

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

Ext.namespace('Shipping');
//付费申请结算
Shipping.MsChPayAppSettlementEdit = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.MsChPayAppSettlementEdit.superclass.constructor.call(this);
};
Date.prototype.format = function (format) {
var o = {
"M+": this.getMonth() + 1, //month
"d+": this.getDate(), //day
"h+": this.getHours(), //hour
"m+": this.getMinutes(), //minute
"s+": this.getSeconds(), //second
"q+": Math.floor((this.getMonth() + 3) / 3), //quarter
"S": this.getMilliseconds() //millisecond
}
if (/(y+)/.test(format)) format = format.replace(RegExp.$1,
(this.getFullYear() + "").substr(4 - RegExp.$1.length));
for (var k in o) if (new RegExp("(" + k + ")").test(format))
format = format.replace(RegExp.$1,
RegExp.$1.length == 1 ? o[k] :
("00" + o[k]).substr(("" + o[k]).length));
return format;
}
var xhr = new XMLHttpRequest();
var currdate = new Date();
if (!xhr) {
//...其他生成xmlhttprequest方法
}
xhr.open("HEAD", location.href, true);
xhr.onreadystatechange = function () {
if (xhr.readyState == 4 && xhr.status == 200) {
var datestr = xhr.getResponseHeader("Date");
currdate = new Date(datestr);
// alert(currdate.format('yyyy-MM-dd'));
}
}
xhr.send(null);
Ext.extend(Shipping.MsChPayAppSettlementEdit, Ext.Panel, {
ParentWin: null,
OpStatus: 'add',
StoreList: null,
EditRecord: null,
sqlcontext: '',
getRecord: null,
addstore: false,
PageSize: 30,
initUIComponents: function () {
this.serialNo = 0;
this.workSerialNo = 0;
this.bodyDel = [];
this.FeeSql = '';
this.BillSql = '';
this.DuiBillSql = '';
this.IsDebit = '0';
this.ACCOUNT = "";
this.BSNO = "";
this.StoreLockOp = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsFeeOP',
proxy: { url: '/MvcShipping/MsBaseInfo/GetOpIDRang' }
});
this.StoreLockOp.load({ params: { optype: "modPayFeeSettlementLock"} });
this.StoreUnLockOp = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsFeeOP',
proxy: { url: '/MvcShipping/MsBaseInfo/GetOpIDRang' }
});
this.StoreUnLockOp.load({ params: { optype: "modPayFeeSettlementUnLock"} });
//#region 编辑form
this.storecustbank = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsInfoClientBankModel',
proxy: { url: '/MvcShipping/MsInfoClient/GetBankList' }
});
this.comboxCustBank = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '结算客户银行',
store: this.storecustbank,
forceSelection: true,
name: 'CUSTBANK',
valueField: 'GID',
displayField: 'ACCOUNTNAMEREF',
listeners: {
scope: this,
'select': function (combo, records, eOpts) {
if (records.length > 0) {
var CUSTACCOUNT = this.formEdit.getForm().findField('CUSTACCOUNT');
CUSTACCOUNT.setValue(records[0].data.ACCOUNT);
}
}
}
});
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: '结算单位',
store: this.storeCustCode,
allowBlank: false,
forceSelection: true,
name: 'CUSTOMERNAME',
valueField: 'CustName',
displayField: 'CodeAndName',
listeners: {
scope: this,
'select': function (combo, records, eOpts) {
if (records.length > 0) {
var CUSTOMERNAME = this.formEdit.getForm().findField('CUSTOMERNAME').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.storecustbank.load({ params: { condition: " LINKID=(SELECT TOP 1 GID FROM INFO_CLIENT WHERE SHORTNAME='" + CUSTOMERNAME + "')"} });
}
}
}
});
this.StoreOpRange = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsOP',
proxy: { url: '/MvcShipping/MsBaseInfo/GetOpRang' }
});
this.StoreCurr = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsFeeCurr',
proxy: { url: '/MvcShipping/MsChFee/GetFeeCurrList' }
});
this.StoreCurr.load({ params: { condition: ""} });
this.StoreDateCurr = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsFeeCurr',
proxy: { url: '/MvcShipping/MsChFee/GetFeeNowCurrList' }
});
this.StoreDateCurr.load({ params: { condition: ""} });
this.comboxCurr = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '币别',
store: this.StoreCurr,
forceSelection: true,
allowBlank: false,
name: 'CURR',
valueField: 'CURR',
displayField: 'CURR',
listeners: {
scope: this,
'select': function (combo, records, eOpts) {
if (records.length > 0) {
var CUST = this.formEdit.getForm().findField('CUSTOMERNAME').getValue();
var recs = DsStoreQueryBy(this.storeCustCode, 'CustName', CUST);
var CUSTBANK = this.formEdit.getForm().findField('CUSTBANK');
var CUSTACCOUNT = this.formEdit.getForm().findField('CUSTACCOUNT');
var CURR = this.formEdit.getForm().findField('CURR').getValue();
var curr = this.formACCOUNTS.getForm().findField('ACCOUNTS_CURRENCY');
curr.setValue(records[0].data.CURR);
var curr = this.formPREPAY.getForm().findField('PREPAY_CURRENCY');
curr.setValue(records[0].data.CURR);
var curr = this.formAHSR.getForm().findField('AHSR_CURRENCY');
curr.setValue(records[0].data.CURR);
var curr = this.formFINANCIAL.getForm().findField('FINANCIAL_CURRENCY');
curr.setValue(records[0].data.CURR);
var curr = this.formADVANCE.getForm().findField('ADVANCE_CURRENCY');
curr.setValue(records[0].data.CURR);
if (CURR == 'RMB') {
this.formEdit.getForm().findField('RATE').setValue(1);
} else {
var FFrecords = DsStoreQueryBy(this.StoreDateCurr, 'CURR', CURR);
if (FFrecords.getCount() > 0) {
var ffdata = FFrecords.getAt(0).data;
var DEFRATE = ffdata.DEFRATE;
this.formEdit.getForm().findField('RATE').setValue(DEFRATE);
} else {
var DFrecords = DsStoreQueryBy(this.StoreCurr, 'CURR', CURR);
if (DFrecords.getCount() > 0) {
var dfdata = DFrecords.getAt(0).data;
var DEFRATE = dfdata.DEFRATE;
this.formEdit.getForm().findField('RATE').setValue(DEFRATE);
} else {
this.formEdit.getForm().findField('RATE').setValue(1);
}
}
}
}
}
}
});
this.StoreStlMode = Ext.create('DsExt.ux.RefTableStore', {
model: 'STLMODE',
proxy: { url: '/MvcShipping/MsBaseInfo/GetStlModeList' }
});
this.StoreStlMode.load({ params: { condition: ""} });
this.comboxStlMode = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '结算方式',
store: this.StoreStlMode,
forceSelection: true,
name: 'SETTLETYPE',
valueField: 'STLCODE',
displayField: 'STLNAME'
});
this.StoreBANK = Ext.create('DsExt.ux.RefTableStore', {
model: 'BANK',
proxy: { url: '/MvcShipping/MsBaseInfo/GetBANKList' }
});
this.StoreBANK.load({ params: { condition: ""} });
var _this = this;
this.comboxBANK = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '银行账号',
store: this.StoreBANK,
forceSelection: true,
name: 'ACCOUNT',
valueField: 'GID',
displayField: 'BANKACCOUNT',
listeners: {
focus: function (field, newValue, oldValue) {
_this.ACCOUNT = field.value;
_this.StoreBANK.load({ params: { condition: " isnull(isstop,0)=0 "} });
},
blur: function (field, newValue, oldValue) {
_this.StoreBANK.load({ async: false, params: { condition: ""} });
if (field.value == "") {
field.value = _this.ACCOUNT;
}
if (field.displayTplData[0].ISSTOP == "True") {
alert("该往来单位已经停用");
}
},
scope: this
}
});
this.storeSTLCATEGROY = Ext.create('DsExt.ux.RefEnumStore', {});
this.storeSTLCATEGROY.load({ params: { enumTypeId: 97020} });
this.comboxSTLCATEGROY = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '业务类别',
name: 'STLCATEGROY',
store: this.storeSTLCATEGROY,
valueField: 'EnumValueName',
displayField: 'EnumValueName',
forceSelection: true
});
//编辑form
var _this = this;
this.formEdit = Ext.widget('form', {
region: 'center',
frame: true,
bodyPadding: 3,
trackResetOnLoad: true,
// 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: 'GID',
name: 'GID', flex: 0, hidden: true, margins: '0'
}, {
fieldLabel: 'BILLSTATUS',
name: 'BILLSTATUS', flex: 0, hidden: true, margins: '0'
}, {
fieldLabel: 'BILLDATE',
name: 'BILLDATE', flex: 0, hidden: true, margins: '0'
}, {
fieldLabel: 'SETTLEUSER',
name: 'SETTLEUSER', flex: 0, hidden: true, margins: '0'
}, {
fieldLabel: 'COMPANYID',
name: 'COMPANYID', flex: 0, hidden: true, margins: '0'
}, {
fieldLabel: 'SETTLEMODE',
name: 'SETTLEMODE', flex: 0, hidden: true, margins: '0'
}, {
fieldLabel: 'BILLTYPE',
name: 'BILLTYPE', flex: 0, hidden: true, margins: '0'
}, {
fieldLabel: 'ISEXPORT',
name: 'ISEXPORT', flex: 0, hidden: true, margins: '0'
},
{
fieldLabel: '结算单号',
readOnly: true,
name: 'BILLNO'
}, {
fieldLabel: '状态',
readOnly: true,
name: 'BILLSTATUSREF'
}, this.comboxCustCode, {
fieldLabel: '结算日期',
format: 'Y-m-d H:i:s',
id: "SETTLETIME",
xtype: 'datefield',
name: 'SETTLETIME',
allowBlank: false,
listeners: {
render: function (_field, eOpts) {//自定义函数,定义双击事件
_field.getEl().on('dblclick', function (e, t, eOpts) {
//DsOpenEditWin('/MvcShipping/MsCtExplan/Index', "摘要信息", "400", "616", (window.screen.availHeight / 2 - 200), (window.screen.availWidth / 2 - 400));
//alert("render");
var myDate = new Date();
Ext.getCmp("SETTLETIME").setValue(currdate.format('yyyy-MM-dd hh:mm:ss'));
});
}
}
}, {
fieldLabel: '结算人',
readOnly: true,
name: 'SETTLEUSERREF'
}
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [this.comboxCurr, {
fieldLabel: '金额',
readOnly: true,
name: 'AMOUNT'
}, this.comboxStlMode, this.comboxBANK, {
fieldLabel: '接口凭证号',
name: 'VOUNO',
id: 'VOUNO'
}]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [
this.comboxCustBank,
{
fieldLabel: '结算单位账户',
flex: 1,
name: 'CUSTACCOUNT'
}, this.comboxSTLCATEGROY,
{
fieldLabel: '备注',
name: 'REMARK'
}, {
fieldLabel: '总账凭证号',
id: 'VOUCHERNO',
name: 'VOUCHERNO'
}]
}
]//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: 'btnESave',
text: "保存",
iconCls: "btnsave",
handler: function (button, event) {
this.Save('0');
},
scope: this
}, '-',
{
text: "打印",
handler: function (button, event) {
this.Print();
},
scope: this
},
'-',
{
id: 'btnESaveAndClose',
text: "保存并关闭",
handler: function (button, event) {
this.Save('1');
},
scope: this
},
'-',
{
id: 'btnESaveAndNew',
text: "保存并新建",
handler: function (button, event) {
this.Save('2');
this.GetEditStatus();
},
scope: this
},
'-',
{
id: 'btnENew',
text: "新建",
handler: function (button, event) {
this.LoadData('add', '*');
},
scope: this
}, '-', {
id: 'btnSubmitAudit',
text: '锁定',
tooltip: '锁定',
handler: function (button, event) {
this.onSubmitAuditClick();
},
scope: this
}, '-', {
id: 'btnSubmitAuditBack',
text: '撤销锁定',
tooltip: '撤销锁定',
handler: function (button, event) {
this.onSubmitAuditBackClick();
},
scope: this
}, '-', {
text: "生成总账凭证",
id: "btnAddCwVouchers",
iconCls: "btnadd",
handler: function (button, event) {
this.onAddCwVouchers();
},
scope: this
}, {
text: "查看总账凭证",
id: "btnSelCwVouchers",
iconCls: "btnrefresh",
handler: function (button, event) {
this.onSelCwVouchers();
},
scope: this
}, '-', {
text: "生成接口凭证",
id: "btnAddCwVouchersJK",
iconCls: "btnadd",
handler: function (button, event) {
this.onAddCwVouchersJK();
},
scope: this
}, {
text: "查看接口凭证",
id: "btnSelCwVouchersJK",
iconCls: "btnrefresh",
handler: function (button, event) {
this.onSelCwVouchersJK();
},
scope: this
}
]
}); //end 按钮Toolbar
//#endregion
//#region 明细表
//明细表表格相关
this.GridCheckBoxModel = Ext.create('Ext.selection.CheckboxModel');
//明细表-数据集
this.storeBodyList = Ext.create('Ext.data.Store', {
model: 'Payapplication_do_detail',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/Account/Chfee_Foreignsettlement/GetPaydetailList',
reader: {
id: 'BILLNO',
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: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
selModel: this.GridCheckBoxModel,
tbar: [{
text: '删除申请明细',
tooltip: '删除申请明细',
id: 'btndeldetail',
iconCls: "btndeletedetail",
handler: function (button, event) {
this.onDeleteClick(button, event, 1);
},
scope: this
}],
columns: [{
sortable: true,
dataIndex: 'BILLNO',
header: '申请单号',
width: 100
}, {
sortable: true,
dataIndex: 'BILLSTATUSREF',
header: '状态',
width: 60
}, {
sortable: true,
dataIndex: 'DOAMOUNT',
header: '结算金额',
width: 80
}, {
sortable: true,
dataIndex: 'CURR',
header: '原始币别',
width: 80
}, {
sortable: true,
dataIndex: 'STLAMOUNT',
header: '原始金额',
width: 80
}, {
sortable: true,
dataIndex: 'AMOUNT',
header: 'RMB申请金额',
width: 80
}, {
sortable: true,
dataIndex: 'USDAMOUNT',
header: 'USD申请金额',
width: 80
}, {
sortable: true,
dataIndex: 'APPLYTIME',
header: '申请日期',
width: 80
}, {
sortable: true,
dataIndex: 'APPLICANTNAME',
header: '申请人',
width: 80
}, {
sortable: true,
dataIndex: 'PAYABLETIME',
header: '申请支付日期',
width: 80
}, {
sortable: true,
dataIndex: 'REMARK',
header: '备注',
width: 60
}
]
});
this.storeBodydetail = Ext.create('Ext.data.Store', {
model: 'Chfee_do_detail',
remoteSort: false,
proxy: {
type: 'ajax',
url: '/Account/Chfee_Foreignsettlement/GetAppBodyList',
reader: {
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.gridBodydetail = new Ext.grid.GridPanel({
store: this.storeBodydetail,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
tbar: [{
xtype: 'label',
width: 120,
height: 22,
text: '费用明细'
}],
columns: [{
sortable: true,
dataIndex: 'BILLNO',
header: 'BILL',
hidden: true,
width: 100
}, {
sortable: true,
dataIndex: 'BSNO',
header: 'BSNO',
hidden: true,
width: 100
}, {
sortable: true,
dataIndex: 'FEEDOID',
header: 'FEEDOID',
hidden: true,
width: 100
}, {
sortable: true,
dataIndex: 'CUSTNO',
header: '委托编号',
width: 120
}, {
sortable: true,
dataIndex: 'MBLNO',
header: '主提单号',
width: 120
}, {
sortable: true,
dataIndex: 'CUSTOMERNAME',
header: '委托单位',
width: 100
}, {
sortable: true,
dataIndex: 'ETD',
header: '开船日期',
renderer: Ext.util.Format.dateRenderer('Y-m-d'),
width: 100
}, {
sortable: true,
dataIndex: 'BSSOURCE',
header: '业务来源',
width: 80
}, {
sortable: true,
dataIndex: 'FEENAME',
header: '费用名称',
width: 80
}, {
sortable: true,
dataIndex: 'FEETYPEREF',
header: '收付',
width: 40
}, {
sortable: true,
dataIndex: 'AMOUNT',
header: '结算金额',
width: 80
}, {
sortable: true,
dataIndex: 'ORIGCURRENCY',
header: '原始币别',
width: 80
}, {
sortable: true,
dataIndex: 'ORIGAMOUNT',
header: '原始金额',
width: 80
}, {
sortable: true,
dataIndex: 'INVOICENO',
header: '发票号',
width: 80
}, {
sortable: true,
dataIndex: 'SALE',
header: '揽货人',
width: 80
}
]
});
//////
this.gridBodydetail.addListener('itemdblclick', function (dataview, record, item, index, e, b) {
this.SelectedRecord = record;
this.BSNO = record.data.BSNO;
this.OprationStatus = 'view';
DsOpenEditWin('/Import/PortOperate/Edit', this.BSNO, "750", "1000");
}, this);
//////
this.storeAddFeeList = Ext.create('Ext.data.Store', {
pageSize: this.PageSize,
model: 'Payapplication_do_detail',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/Account/Chfee_Foreignsettlement/GetPayDCList',
reader: {
id: 'BILLNO',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.AddFeeGridCheckBoxModel = Ext.create('Ext.selection.CheckboxModel');
this.cellEditingFee = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1,
listeners: {
'edit': function (editor, e) {
}
}
});
_this = this;
this.CurrGroup = new Ext.form.RadioGroup({
id: 'CurrGroup',
xtype: 'radiogroup',
fieldLabel: '折算币别',
columns: 2,
items: [
{ boxLabel: 'RMB', name: 'Curr', inputValue: 'RMB', checked: true },
{ boxLabel: 'USD', name: 'Curr', inputValue: 'USD' }
]
});
this.gridAddFeeList = new Ext.grid.GridPanel({
store: this.storeAddFeeList,
enableHdMenu: false,
region: 'west',
split: true,
width: 860,
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
plugins: [this.cellEditingFee],
selModel: this.AddFeeGridCheckBoxModel,
tbar: [{
text: "添加申请费用明细",
id: "btnadddetail",
iconCls: 'btnadddetail',
menu: [
{ text: "全部申请金额",
handler: function (menu, event) {
_this.onAddDetailClick(menu, event, '');
}
}, { text: "仅RMB申请金额",
handler: function (menu, event) {
_this.onAddDetailClick(menu, event, 'RMB');
}
}, { text: "仅外币申请金额",
handler: function (menu, event) {
_this.onAddDetailClick(menu, event, 'USD');
}
}],
scope: this
}],
columns: [{
sortable: true,
dataIndex: 'BILLNO',
header: '申请单号',
width: 120
}, {
sortable: true, hidden: true,
dataIndex: 'BILLSTATUSREF',
header: '状态',
width: 60
}, {
sortable: true,
dataIndex: 'CUSTOMERNAME',
header: '结算单位',
width: 80
}, {
sortable: true,
dataIndex: 'AMOUNT',
header: 'RMB申请金额',
width: 70,
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', false);
if (parseFloat(value) < 0) {
return '<SPAN style="COLOR: red">' + value + '</SPAN>';
}
return value;
}
}, {
sortable: true,
dataIndex: 'BALAMOUNT',
header: 'RMB未结金额',
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: 'STLAMOUNT',
header: 'RMB本次结算',
editor: {
xtype: 'numberfield',
keyNavEnabled: false,
allowDecimals: true,
decimalPrecision: 2,
selectOnFocus: true,
mouseWheelEnabled: false,
enableKeyEvents: true,
listeners: {
keydown: function (textfield, e) {
if (e.getKey() == 40) {
_this.onNextKeyClick(6)
} else if (e.getKey() == 38) {
_this.onUpKeyClick(6)
}
}
}
},
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;
},
width: 70
}, {
sortable: true,
dataIndex: 'CURR',
header: '外币币别',
width: 40
}, {
sortable: true,
dataIndex: 'USDAMOUNT',
header: '外币申请金额',
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: 'USDBALAMOUNT',
header: '外币未结金额',
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: 'USDSTLAMOUNT',
header: '外币本次结算',
editor: {
xtype: 'numberfield',
keyNavEnabled: false,
allowDecimals: true,
decimalPrecision: 2,
selectOnFocus: true,
mouseWheelEnabled: false,
enableKeyEvents: true,
listeners: {
keydown: function (textfield, e) {
if (e.getKey() == 40) {
_this.onNextKeyClick(8)
} else if (e.getKey() == 38) {
_this.onUpKeyClick(8)
}
}
}
},
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;
},
width: 70
}, {
sortable: true,
dataIndex: 'APPLYTIME',
header: '申请日期',
width: 70
}, {
sortable: true,
dataIndex: 'APPLICANTNAME',
header: '申请人',
width: 70
}, {
sortable: true,
dataIndex: 'PAYABLETIME',
header: '申请支付日期',
width: 70
}, {
sortable: true,
dataIndex: 'REMARK',
header: '备注',
width: 60
}
],
// paging bar on the bottom
bbar: Ext.create('Ext.PagingToolbar', {
store: this.storeAddFeeList,
displayInfo: true,
displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录',
emptyMsg: "没有数据"
})
});
this.gridAddFeeList.on('edit', function (editor, e, eOpts) {
this.gridAddFeeListAfterEdit(editor, e, eOpts);
}, this);
_this = this;
this.storeAddBodydetail = Ext.create('Ext.data.Store', {
model: 'Chfee_do_detail',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/Account/Chfee_payapplication/GetBillList',
reader: {
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.gridAddBodydetail = new Ext.grid.GridPanel({
store: this.storeAddBodydetail,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
tbar: [{
xtype: 'label',
width: 120,
height: 22,
text: '费用明细'
}],
columns: [{
sortable: true,
dataIndex: 'BILLNO',
header: 'BILL',
hidden: true,
width: 100
}, {
sortable: true,
dataIndex: 'BSNO',
header: 'BSNO',
hidden: true,
width: 100
}, {
sortable: true,
dataIndex: 'FEEDOID',
header: 'FEEDOID',
hidden: true,
width: 100
}, {
sortable: true,
dataIndex: 'CUSTNO',
header: '委托编号',
width: 120
}, {
sortable: true,
dataIndex: 'MBLNO',
header: '主提单号',
width: 120
}, {
sortable: true,
dataIndex: 'CUSTOMERNAME',
header: '委托单位',
width: 100
}, {
sortable: true,
dataIndex: 'ETD',
header: '开船日期',
renderer: Ext.util.Format.dateRenderer('Y-m-d'),
width: 100
}, {
sortable: true,
dataIndex: 'BSSOURCE',
header: '业务来源',
width: 80
}, {
sortable: true,
dataIndex: 'FEENAME',
header: '费用名称',
width: 80
}, {
sortable: true,
dataIndex: 'FEETYPEREF',
header: '收付',
width: 40
}, {
sortable: true,
dataIndex: 'AMOUNT',
header: '申请金额',
width: 80,
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: 'DOAMOUNT',
header: '结算金额',
width: 80,
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: '申请币别',
width: 80
}, {
sortable: true,
dataIndex: 'ORIGCURRENCY',
header: '原始币别',
width: 80
}, {
sortable: true,
dataIndex: 'ORIGAMOUNT',
header: '原始金额',
width: 80,
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: 'SALE',
header: '揽货人',
width: 80
}
]
});
////////////////
this.gridAddBodydetail.addListener('itemdblclick', function (dataview, record, item, index, e, b) {
this.SelectedRecord = record;
this.BSNO = record.data.BSNO;
this.OprationStatus = 'view';
DsOpenEditWin('/Import/PortOperate/Edit', this.BSNO, "750", "1000");
}, this);
////////////////
this.storeCustCodefee = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CustomInvRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetCustomInvRefList' }
});
this.storeCustCodefee.load({ params: { condition: ""} });
this.comboxAddCustCode = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '费用对象',
store: this.storeCustCodefee,
forceSelection: true,
name: 'CUSTNAME',
valueField: 'CustName',
displayField: 'CodeAndName',
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
});
this.comboxCurr2 = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '币别',
store: this.StoreCurr,
forceSelection: true,
flex: 0.5,
name: 'Currency',
valueField: 'CURR',
displayField: 'CURR',
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
});
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: '仅未结申请',
store: this.storeIsDebit,
valueField: 'DC',
displayField: 'NAME',
forceSelection: true,
value: "1",
name: 'ISDEBIT',
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
});
this.storeCurrExrate = Ext.create('Ext.data.Store', {
fields: ['CURR', 'EXRATE', 'DFEXRATE']
});
var _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: [this.comboxAddCustCode, {
fieldLabel: '申请单号',
name: 'CustomNo',
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
}, {
fieldLabel: '编号',
tooltip: '委托编号、主提单号、分提单号',
name: 'BH',
enableKeyEvents: true,
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
}, this.comboxCurr2, {
fieldLabel: '从申请日期',
format: 'Y-m-d',
xtype: 'datefield',
name: 'ExpDateBgn',
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
}, {
fieldLabel: '到申请日期',
format: 'Y-m-d',
xtype: 'datefield',
name: 'ExpDateEnd',
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
}, this.comboxIsDebit, {
xtype: 'button',
width: 90,
text: "检索",
iconCls: "btnrefresh",
handler: function (button, event) {
this.onRefreshClick();
},
scope: this
}
]
}
]//end items(fieldset 1)
}//end fieldset 1
]//end root items
});
this.panelService = new Ext.Panel({
layout: "border",
region: 'west',
split: true,
width: 860,
margin: '2 2',
items: [this.gridList]
});
this.panelBodydetail = new Ext.Panel({
layout: "border",
region: 'center',
margin: '2 2',
items: [this.gridBodydetail]
});
this.panelAddBodydetail = new Ext.Panel({
layout: "border",
region: 'center',
margin: '2 2',
items: [this.gridAddBodydetail]
});
this.paneldetail = new Ext.Panel({
// title: '结算明细',
layout: "border",
height: 260,
region: "north",
split: true,
items: [
this.panelService, this.panelBodydetail
]
});
this.panelAddService = new Ext.Panel({
layout: "border",
region: 'center',
margin: '2 2',
items: [this.gridAddFeeList, this.panelAddBodydetail]
});
this.paneladd = new Ext.Panel({
title: '添加支付结算明细',
layout: "border",
// region: 'south',
region: "center",
// height: 420,
items: [
this.formSearch, this.panelAddService
]
});
//#endregion 明细表
//#region 预收预付
//记账资料
this.formACCOUNTS = Ext.widget('form', {
anchor: '20% 100%',
columnWidth: .20,
frame: true,
trackResetOnLoad: true,
bodyPadding: 5,
title: '记账资料',
trackResetOnLoad: true,
fieldDefaults: {
margins: '2 2 2 2',
labelAlign: 'right',
flex: 1,
labelWidth: 40,
msgTarget: 'qtip'
},
items: [
{//fieldset 1
xtype: 'fieldset',
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel:'币别',
labelWidth: 40,
readOnly: true,
name: 'ACCOUNTS_CURRENCY'
}
]//end items(fieldset 1)
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '汇率',
labelWidth: 40,
name: 'ACCOUNTS_RATE'
}
]//end items(fieldset 1)
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '金额',
labelWidth: 40,
name: 'ACCOUNTS_MONEY',
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;
},
listeners: {
scope: this,
'blur': function (textfield, eOpts) {
var curr = this.formPREPAY.getForm().findField('PREPAY_MONEY');
var allamount = textfield.value;
var amount = this.formEdit.getForm().findField('AMOUNT').getValue();
var aftamount = parseFloat(allamount) - parseFloat(amount);
curr.setValue(aftamount);
this.formACCOUNTS.getForm().findField('ACCOUNTS_MONEY').setValue(amount);
var financialamount = this.formFINANCIAL.getForm().findField('FINANCIAL_MONEY').getValue();
var advanceamount = this.formADVANCE.getForm().findField('ADVANCE_MONEY').getValue();
amount = parseFloat(allamount).add(parseFloat(-advanceamount));
amount = parseFloat(amount).add(parseFloat(-financialamount));
this.formAHSR.getForm().findField('AHSR_MONEY').setValue(amount);
}
}
}
]//end items(fieldset 1)
}//end fieldset 1
]//end root items
}]
});
this.comboxCurrPREPAY = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '币别',
store: this.StoreCurr,
forceSelection: true,
name: 'PREPAY_CURRENCY',
valueField: 'CURR',
displayField: 'CURR'
});
//预付支资料
this.formPREPAY = Ext.widget('form', {
anchor: '20% 100%',
columnWidth: .20,
frame: true,
trackResetOnLoad: true,
bodyPadding: 5,
title: "+预付支资料",
trackResetOnLoad: true,
fieldDefaults: {
margins: '2 2 2 2',
labelAlign: 'right',
flex: 1,
labelWidth: 40,
msgTarget: 'qtip'
},
items: [
{//fieldset 1
xtype: 'fieldset',
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [this.comboxCurrPREPAY
]//end items(fieldset 1)
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '汇率',
labelWidth: 40,
name: 'PREPAY_RATE'
}
]//end items(fieldset 1)
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '金额',
labelWidth: 40,
name: 'PREPAY_MONEY',
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;
}
}, {
xtype: 'button',
width: 115,
text: "查看核销明细",
iconCls: "btnrefresh",
handler: function (button, event) {
if (_this.paneldetailacc2.isVisible())
_this.paneldetailacc2.hide();
else {
_this.paneldetailacc2.show();
var billno = _this.formEdit.getForm().findField('BILLNO').getValue();
_this.storeBodyListAcc2.load({ params: { condition: " BILLNO='" + billno + "'" } });
}
},
scope: this
}
]//end items(fieldset 1)
}//end fieldset 1
]//end root items
}]
});
this.comboxCurrAHSR = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '币别',
store: this.StoreCurr,
forceSelection: true,
name: 'AHSR_CURRENCY',
valueField: 'CURR',
displayField: 'CURR'
});
this.formAHSR = Ext.widget('form', {
anchor: '20% 100%',
columnWidth: .20,
frame: true,
trackResetOnLoad: true,
bodyPadding: 5,
title: "=实付支资料",
trackResetOnLoad: true,
fieldDefaults: {
margins: '2 2 2 2',
labelAlign: 'right',
flex: 1,
labelWidth: 40,
msgTarget: 'qtip'
},
items: [
{//fieldset 1
xtype: 'fieldset',
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [this.comboxCurrAHSR
]//end items(fieldset 1)
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '汇率',
name: 'AHSR_RATE'
}
]//end items(fieldset 1)
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '金额',
name: 'AHSR_MONEY',
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;
},
listeners: {
scope: this,
'blur': function (textfield, eOpts) {
var curr = this.formFINANCIAL.getForm().findField('FINANCIAL_MONEY');
var accamount = this.formACCOUNTS.getForm().findField('ACCOUNTS_MONEY').getValue();
var prepamount = this.formPREPAY.getForm().findField('PREPAY_MONEY').getValue();
var advanceamount = this.formADVANCE.getForm().findField('ADVANCE_MONEY').getValue();
var amount = parseFloat(accamount).add(parseFloat(prepamount));
amount = parseFloat(amount).add(parseFloat(-advanceamount));
amount = parseFloat(amount).add(parseFloat(-textfield.value));
curr.setValue(amount);
}
}
}
]//end items(fieldset 1)
}//end fieldset 1
]//end root items
}]
});
this.comboxCurrFINANCIAL = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '币别',
store: this.StoreCurr,
forceSelection: true,
name: 'FINANCIAL_CURRENCY',
valueField: 'CURR',
displayField: 'CURR',
enableKeyEvents: true, //激活键盘事件
listeners: {
scope: this,
'select': function blur(combo, eOpts) {
if (combo.value == 'RMB' || combo.value == '') {
this.formFINANCIAL.getForm().findField('FINANCIAL_RATE').setValue(1);
} else {
var FFrecords = DsStoreQueryBy(this.StoreDateCurr, 'CURR', combo.value);
if (FFrecords.getCount() > 0) {
var ffdata = FFrecords.getAt(0).data;
var DEFRATE = ffdata.DEFRATE;
this.formFINANCIAL.getForm().findField('FINANCIAL_RATE').setValue(DEFRATE);
} else {
var Duino = this.formEdit.getForm().findField('BILLNO').getValue();
Ext.Ajax.request({
waitMsg: '',
url: '/Account/Chfee_settlement/GetDefaulExrate',
params: {
billno: Duino,
curr: combo.value
},
callback: function (options, success, response) {
if (success) {
var result = Ext.JSON.decode(response.responseText);
if (result.Success != true) {
} else {
var data = result.Data;
this.formFINANCIAL.getForm().findField('FINANCIAL_RATE').setValue(data);
}
} else {
}
},
scope: this
});
}
}
}
}
});
this.formFINANCIAL = Ext.widget('form', {
anchor: '20% 100%',
columnWidth: .20,
frame: true,
trackResetOnLoad: true,
bodyPadding: 5,
title: "+财务费用",
trackResetOnLoad: true,
fieldDefaults: {
margins: '2 2 2 2',
labelAlign: 'right',
flex: 1,
labelWidth: 40,
msgTarget: 'qtip'
},
items: [
{//fieldset 1
xtype: 'fieldset',
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [this.comboxCurrFINANCIAL]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '汇率',
readOnly: true,
name: 'FINANCIAL_RATE'
}
]//end items(fieldset 1)
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '金额',
name: 'FINANCIAL_MONEY',
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;
},
listeners: {
scope: this,
'blur': function (textfield, eOpts) {
var curr = this.formAHSR.getForm().findField('AHSR_MONEY');
var accamount = this.formACCOUNTS.getForm().findField('ACCOUNTS_MONEY').getValue();
var prepamount = this.formPREPAY.getForm().findField('PREPAY_MONEY').getValue();
var advanceamount = this.formADVANCE.getForm().findField('ADVANCE_MONEY').getValue();
var amount = parseFloat(accamount).add(parseFloat(prepamount));
amount = parseFloat(amount).add(parseFloat(-advanceamount));
amount = parseFloat(amount).add(parseFloat(-textfield.value));
curr.setValue(amount);
}
}
}
]//end items(fieldset 1)
}//end fieldset 1
]//end root items
}]
});
this.comboxCurrADVANCE = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '币别',
store: this.StoreCurr,
forceSelection: true,
name: 'ADVANCE_CURRENCY',
valueField: 'CURR',
displayField: 'CURR'
});
_this = this;
this.formADVANCE = Ext.widget('form', {
anchor: '20% 100%',
columnWidth: .20,
frame: true,
trackResetOnLoad: true,
bodyPadding: 5,
title: "+预付支取用资料",
trackResetOnLoad: true,
fieldDefaults: {
margins: '2 2 2 2',
labelAlign: 'right',
flex: 1,
labelWidth: 40,
msgTarget: 'qtip'
},
items: [
{//fieldset 1
xtype: 'fieldset',
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [this.comboxCurrADVANCE
]//end items(fieldset 1)
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '汇率',
name: 'ADVANCE_RATE'
}
]//end items(fieldset 1)
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '金额',
readOnly: true,
name: 'ADVANCE_MONEY',
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;
}
}, {
xtype: 'button',
width: 90,
text: "取用/撤销",
iconCls: "btnrefresh",
handler: function (button, event) {
if (_this.panelaccdetail.isVisible())
_this.panelaccdetail.hide();
else {
_this.panelaccdetail.show();
var custome = _this.formEdit.getForm().findField('CUSTOMERNAME').getValue();
var billno = _this.formEdit.getForm().findField('BILLNO').getValue();
var curr = _this.formADVANCE.getForm().findField('ADVANCE_CURRENCY').getValue();
var sql = "CUSTOMERNAME='" + custome + "' and (ISFINISH=0 or ISFINISH IS NULL) AND FEETYPE=2 AND currency='" + curr + "' AND BILLNO<>'" + billno + "'";
_this.storeAccBodyList.load({ params: { start: 0, limit: _this.PageSize, sort: '', condition: sql } });
_this.storeBodyListAcc.load({
params: { condition: " SETTLEBILLNO='" + billno + "'" },
callback: function (r, options, success) {
if (success) {
if (_this.storeBodyListAcc.getCount() > 0) (this.comboxCurrADVANCE.readOnly = true)
}
},
scope: this
});
}
},
scope: this
}
]//end items(fieldset 1)
}//end fieldset 1
]//end root items
}]
});
//20150908 购汇RMB使用情况
var _this = this;
this.formPAYRMB = Ext.widget('form', {
anchor: '50% 100%',
columnWidth: .20,
frame: true,
trackResetOnLoad: true,
bodyPadding: 5,
title: "购汇RMB使用情况",
trackResetOnLoad: true,
fieldDefaults: {
margins: '2 2 2 2',
labelAlign: 'right',
flex: 1,
labelWidth: 40,
msgTarget: 'qtip'
},
items: [
{//fieldset 1
xtype: 'fieldset',
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [
]//end items(fieldset 1)
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
labelWidth: 80,
fieldLabel: '购汇RMB',
name: 'Amount',
values: '0',
selectOnFocus: true,
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.formPAYRMB.getForm().findField('SXF').focus(false, 100);
}
}
}
}
]//end items(fieldset 1)
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
labelWidth: 80,
fieldLabel: '手续费',
name: 'SXF',
values: '0',
selectOnFocus: true,
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.formPAYRMB.getForm().findField('DHF').focus(false, 100);
}
}
}
}
]//end items(fieldset 1)
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
labelWidth: 80, id: "PAYRMB_Amount",
fieldLabel: '电汇费',
name: 'DHF',
values: '0',
selectOnFocus: true
}
]//end items(fieldset 1)
}//end fieldset 1
]//end root items
}]
});
//#endregion
this.panelAcc = new Ext.Panel({
layout: "column",
region: "north",
height: 140,
items: [this.formACCOUNTS, this.formPREPAY, this.formAHSR, this.formFINANCIAL, this.formADVANCE]
});
//
this.panelPAYRMB = new Ext.Panel({
layout: "border",
region: "north",
height: 160,
items: [this.formPAYRMB]
});
//#region 预付取用
this.storePaymentList = Ext.create('Ext.data.Store', {
model: 'CWAdvancePaymentmb',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/Account/Chfee_Foreignsettlement/GetAdvancePayment',
reader: {
id: 'BILLNO',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.GridAccCheckBoxModel = Ext.create('Ext.selection.CheckboxModel');
//待取用的预收明细
this.storeAccBodyList = Ext.create('Ext.data.Store', {
model: 'CWAdvancePaymentmb',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/Account/Chfee_Foreignsettlement/GetAdvancePayment',
reader: {
id: 'BILLNO',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.gridListAccCellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
this.gridListAcc = new Ext.grid.GridPanel({
store: this.storeAccBodyList,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
plugins: [this.gridListAccCellEditing],
selModel: this.GridAccCheckBoxModel,
tbar: [{
text: '添加取用明细',
tooltip: '添加取用明细',
iconCls: "btnadddetail",
handler: function (button, event) {
this.onAddAPDetailClick(button, event);
},
scope: this
}],
columns: [{
sortable: true,
dataIndex: 'GID',
header: 'GID',
width: 80, hidden: true
},
{
sortable: true,
dataIndex: 'LINKGID',
header: 'LINKGID',
width: 80, hidden: true
},
{
sortable: true,
dataIndex: 'BILLNO',
header: '结算单号',
width: 120
},
{
sortable: true,
dataIndex: 'FEETYPEREF',
header: '收付',
width: 60
},
{
sortable: true,
dataIndex: 'CUSTOMERNAME',
header: '结算对象',
width: 100
},
{
sortable: true,
dataIndex: 'CURRENCY',
header: '币别',
width: 80
},
{
sortable: true,
dataIndex: 'AMOUNT',
header: '金额',
width: 80,
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: 'DOAMOUNT',
header: '已核销金额',
width: 80,
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: 'REMAIN',
header: '本次核销',
editor: {
xtype: 'numberfield',
keyNavEnabled: false,
allowDecimals: true,
decimalPrecision: 2,
selectOnFocus: true,
mouseWheelEnabled: false,
enableKeyEvents: true
},
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
try {
var lsValue = usMoney(value, 2, '', false);
if (lsValue != "NaN") {
value = lsValue; if (parseFloat(lsValue) < 0) {
return '<SPAN style="COLOR: red">' + lsValue + '</SPAN>';
}
}
else {
return value;
}
}
catch (e) {
return value;
}
return value;
},
width: 80
},
{
sortable: true,
dataIndex: 'CREATEUSERREF',
header: '录入人',
width: 80
},
{
sortable: true,
dataIndex: 'CREATETIME',
header: '录入时间',
width: 80
},
{
sortable: true,
dataIndex: 'REMARK',
header: '备注',
width: 120
}
]
});
//预收预付的使用明细
this.storeBodyListAcc = Ext.create('Ext.data.Store', {
model: 'CWAdvancePaymentBodymb',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/Account/Chfee_Foreignsettlement/GetAPBodyList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.GridBodyAccCheckBoxModel = Ext.create('Ext.selection.CheckboxModel');
this.gridBodyListAcc = new Ext.grid.GridPanel({
store: this.storeBodyListAcc,
enableHdMenu: false,
region: 'center',
//height: 600,
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
selModel: this.GridBodyAccCheckBoxModel,
viewConfig: {
autoFill: true,
enableTextSelection: true
},
tbar: [{
text: '删除取用明细',
tooltip: '删除取用明细',
iconCls: "btnadddetail",
handler: function (button, event) {
this.onDeleteApClick(button, event);
},
scope: this
}],
columns: [
{
sortable: true,
dataIndex: 'GID',
header: 'GID', hidden: true,
width: 80
},
{
sortable: true,
dataIndex: 'LINKGID',
header: 'LINKGID', hidden: true,
width: 80
},
{
sortable: true,
dataIndex: 'BILLNO',
header: '结算单号',
width: 120
},
{
sortable: true,
dataIndex: 'SETTLELINKGID',
header: 'SETTLELINKGID', hidden: true,
width: 80
},
{
sortable: true,
dataIndex: 'SETTLEBILLNO',
header: '核销使用单号',
width: 120
},
{
sortable: true,
dataIndex: 'FEETYPE',
header: 'FEETYPE',
width: 80
},
{
sortable: true,
dataIndex: 'CUSTOMERNAME',
header: '结算对象', hidden: true,
width: 100
},
{
sortable: true,
dataIndex: 'CURRENCY',
header: '币别',
width: 80
},
{
sortable: true,
dataIndex: 'DOAMOUNT',
header: '核销金额',
width: 80
},
{
sortable: true,
dataIndex: 'SETTLEUSERREF',
header: '核销人',
width: 80
},
{
sortable: true,
dataIndex: 'SETTLETIME',
header: '核销时间',
width: 80
},
{
sortable: true,
dataIndex: 'REMARK',
header: '备注',
width: 80
},
{
sortable: true,
dataIndex: 'VOUCHERNO',
header: '总账凭证号',
width: 80
}
]
});
this.storeBodyListAcc2 = Ext.create('Ext.data.Store', {
model: 'CWAdvancePaymentBodymb',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/Account/Chfee_Foreignsettlement/GetAPBodyList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.gridBodyListAcc2 = new Ext.grid.GridPanel({
store: this.storeBodyListAcc2,
enableHdMenu: false,
region: 'center',
//height: 600,
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
selType: 'cellmodel',
viewConfig: {
autoFill: true,
enableTextSelection: true
},
columns: [
{
sortable: true,
dataIndex: 'GID',
header: 'GID', hidden: true,
width: 80
},
{
sortable: true,
dataIndex: 'LINKGID',
header: 'LINKGID', hidden: true,
width: 80
},
{
sortable: true,
dataIndex: 'BILLNO',
header: '结算单号',
width: 80
},
{
sortable: true,
dataIndex: 'SETTLELINKGID',
header: 'SETTLELINKGID', hidden: true,
width: 80
},
{
sortable: true,
dataIndex: 'SETTLEBILLNO',
header: '核销使用单号',
width: 80
},
{
sortable: true,
dataIndex: 'FEETYPE',
header: 'FEETYPE',
width: 80
},
{
sortable: true,
dataIndex: 'CUSTOMERNAME',
header: '结算对象', hidden: true,
width: 80
},
{
sortable: true,
dataIndex: 'CURRENCY',
header: '币别',
width: 80
},
{
sortable: true,
dataIndex: 'DOAMOUNT',
header: '核销金额',
width: 80
},
{
sortable: true,
dataIndex: 'SETTLEUSER',
header: '核销人',
width: 80
},
{
sortable: true,
dataIndex: 'SETTLETIME',
header: '核销时间',
width: 80
},
{
sortable: true,
dataIndex: 'REMARK',
header: '备注',
width: 80
},
{
sortable: true,
dataIndex: 'VOUCHERNO',
header: '总账凭证号',
width: 80
}
]
});
this.paneldetailacc = new Ext.Panel({
// title: '结算明细',
layout: "border",
height: 160,
region: "north",
split: true,
items: [
this.gridBodyListAcc
]
});
this.panelAddacc = new Ext.Panel({
layout: "border",
height: 160,
region: "north",
margin: '2 2',
items: [this.gridListAcc]
});
this.paneldetailacc2 = new Ext.Panel({
title: '核销明细',
layout: "border",
height: 160,
region: "north",
hidden: true,
items: [
this.gridBodyListAcc2
]
});
this.panelaccdetail = new Ext.Panel({
title: '取用或撤销预付明细',
layout: "border",
hidden: true,
height: 360,
region: "north",
split: true,
items: [
this.paneldetailacc, this.panelAddacc
]
});
//#endregion
//#region 布局
//控件布局
this.panelTop = new Ext.Panel({
layout: "border",
region: "north",
height: 130,
items: [this.panelBtn, this.formEdit]
});
this.panelBody = new Ext.Panel({
title: "结算明细",
layout: "border",
region: "center",
items: [this.paneldetail, this.paneladd]
});
this.panelAccAll = new Ext.Panel({
title: "预收预付信息",
layout: "border",
region: "north",
height: 450,
items: [this.panelAcc, this.panelaccdetail, this.paneldetailacc2]
});
this.panelPAYRMBAll = new Ext.Panel({
title: "购汇RMB使用情况",
layout: "border",
region: "north",
height: 450,
items: [this.panelPAYRMB]
});
//var firstActive = true;
var _this = this;
this.tabpanel = new Ext.TabPanel
({
activeTab: 0,
autoWidth: true,
border: false,
frame: false,
region: 'center',
id: "TabPanelID",
enableTabScroll: true,
items:
[
this.panelBody,
this.panelAccAll,
this.panelPAYRMBAll
],
listeners: {
'tabchange': function () {
//if(firstActive){
//firstActive=false;
//}else{
//alert("123");
_this.formPAYRMB.getForm().findField('Amount').focus(false, 100);
//}
}
}
});
Ext.apply(this, {
items: [this.panelTop, this.tabpanel]
});
//#endregion
//绑定查询窗体
this.ParentWin = window.parent.opener;
//初始化数据
this.InitData();
//绑定事件
var billno = '*';
if (this.opStatus == 'edit') {
billno = this.editRecord.get('BILLNO');
};
this.storeBodyList.on('beforeload', function (store) {
Ext.apply(store.proxy.extraParams, { billno: billno });
}, this);
this.storeBodyList.on('load', function (store, records) {
if (store.getCount() > 0) {
this.gridList.getSelectionModel().select(0);
} else {
this.storeBodydetail.load({ params: { condition: " f.BILLNO='XX'"} });
}
}, this);
this.gridList.getSelectionModel().on('select', function (model, record, index) {
var billno = this.formEdit.getForm().findField('BILLNO').getValue();
var paybillno = record.data.BILLNO;
var sql = "";
sql = " f.BILLNO='" + billno + "' and f.PAYBILLNO='" + paybillno + "'";
this.storeBodydetail.load({ params: { condition: sql} });
}, this);
this.storeAddFeeList.on('beforeload', function (store) {
var sql = this.getCondition();
Ext.apply(store.proxy.extraParams, { condition: this.BillSql });
}, this);
this.storeAddBodydetail.on('beforeload', function (store) {
var selections = this.gridAddFeeList.getSelectionModel().getSelection();
if (selections.length == 0) {
var sql = " BILLNO='XX'";
Ext.apply(store.proxy.extraParams, { condition: sql });
return;
}
var record = selections[0];
var sql = " BILLNO='" + record.data.BILLNO + "'";
Ext.apply(store.proxy.extraParams, { condition: sql });
}, this);
this.storeAddFeeList.on('load', function (store, records) {
if (store.getCount() > 0) {
this.gridAddFeeList.getSelectionModel().select(0);
} else {
this.storeAddBodydetail.load({ params: { condition: " BILLNO='XX'"} });
}
}, this);
this.gridAddFeeList.getSelectionModel().on('select', function (model, record, index) {
var bsno = record.data.BILLNO;
var sql = "";
sql = " BILLNO='" + bsno + "'";
this.storeAddBodydetail.load({ params: { condition: sql} });
}, this);
}, //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 = " BILLNO='" + this.editRecord.get('BILLNO') + "'";
}
this.LoadData(this.opStatus, condition);
//
this.setBtnStatusDisable();
}, //end InitData
LoadData: function (opstatus, condition) {
this.serialNo = 0;
this.workSerialNo = 0;
this.bodyDel = [];
this.opStatus = opstatus;
var billno = '*';
if (this.opStatus == 'edit') {
billno = this.editRecord.get('BILLNO');
};
_this = this;
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/Account/Chfee_Foreignsettlement/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;
}
this.getRecord = result.data;
var data = result.data;
data.AMOUNT = usMoney(data.AMOUNT, 2, '', false);
_this.formEdit.getForm().findField('BILLSTATUS').setDisabled(false);
_this.formEdit.getForm().reset();
_this.formACCOUNTS.getForm().reset();
_this.formPREPAY.getForm().reset();
_this.formAHSR.getForm().reset();
_this.formFINANCIAL.getForm().reset();
_this.formADVANCE.getForm().reset();
//alert(data.VOUCHERNO);
_this.formEdit.getForm().setValues(data);
_this.formACCOUNTS.getForm().setValues(data);
_this.formPREPAY.getForm().setValues(data);
_this.formAHSR.getForm().setValues(data);
_this.formFINANCIAL.getForm().setValues(data);
_this.formADVANCE.getForm().setValues(data);
_this.formEdit.getForm().findField('BILLSTATUS').setDisabled(true);
_this.GetEditStatus();
_this.storeBodyList.load({ params: { billno: billno },
callback: function (r, options, success) {
if (success) {
if (_this.storeBodyList.getCount() > 0) {
_this.comboxCurr.setReadOnly(true);
_this.comboxCustCode.setReadOnly(true);
}
else {
_this.comboxCurr.setReadOnly(false);
_this.comboxCustCode.setReadOnly(false);
}
}
},
scope: this
});
if (this.opStatus == 'add') {
var date = new Date();
date.setMonth(date.getMonth())
var SETTLETIME = this.formEdit.getForm().findField('SETTLETIME');
SETTLETIME.setValue(date);
};
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
////////获取付汇记录
Ext.Ajax.request({
waitMsg: '正在查询付汇数据...',
url: '/Account/Chfee_Foreignsettlement/GetPAYRMBData',
params: {
handle: opstatus,
condition: condition
},
callback: function (options, success, response) {
if (success) {
var result = Ext.JSON.decode(response.responseText);
if (!result.Success) {
Ext.Msg.show({
title: '提示',
msg: result.Message,
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.OK
});
return;
}
var data = result.data;
_this.formPAYRMB.getForm().setValues(data);
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
this.onRefreshClick();
// this.storeBodySum.load({ params: { condition: " BILLNO='" + billno + "'"} });
// this.storePaymentList.load({ params: { start: 0, limit: this.PageSize, sort: '', condition: "BILLNO='" + billno + "'" },
// callback: function (r, options, success) {
// if (success) {
// if (this.storePaymentList.getCount() > 0) {
// var member = this.storePaymentList.getAt(0);
// if (member.data.ISVOU) {
// this.formACCOUNTS.getForm().findField('ACCOUNTS_MONEY').readOnly = true;
// this.formPREPAY.getForm().findField('PREPAY_MONEY').readOnly = true;
// }
// }
// }
// },
// scope: this
// });
}, // end LoadDate
Save: function (type) {
var basicForm = this.formEdit.getForm();
if (!basicForm.isValid()) {
return;
}
var ACCOUNT = basicForm.findField('ACCOUNT').getValue();
var _ACCOUNT = DsStoreQueryBy(this.StoreBANK, 'GID', ACCOUNT);
if (_ACCOUNT.getCount() > 0) {
var _ACCOUNTdata = _ACCOUNT.getAt(0).data;
if (_ACCOUNTdata.ISSTOP == "True") {
alert("你选择的银行帐户已经停用");
}
}
this.formEdit.getForm().findField('BILLSTATUS').setDisabled(false);
this.formEdit.getForm().findField('SETTLEUSER').setDisabled(false);
this.formEdit.getForm().findField('COMPANYID').setDisabled(false);
this.formEdit.getForm().findField('SETTLEMODE').setDisabled(false);
this.formEdit.getForm().findField('BILLTYPE').setDisabled(false);
var field = this.formEdit.getForm().findField('SETTLEMODE');
field.setValue(1);
var field = this.formEdit.getForm().findField('BILLTYPE');
field.setValue(2);
var data = basicForm.getValues();
var accountsdata = this.formACCOUNTS.getForm().getValues();
var prepaydata = this.formPREPAY.getForm().getValues();
var prepaychange = this.formPREPAY.getForm().findField('PREPAY_MONEY').isDirty();
var ahsrdata = this.formAHSR.getForm().getValues();
var financialdata = this.formFINANCIAL.getForm().getValues();
var advancedata = this.formADVANCE.getForm().getValues();
//
var payrmb = this.formPAYRMB.getForm().getValues();
var _this = this;
if (parseFloat(payrmb.Amount) + parseFloat(payrmb.SXF) + parseFloat(payrmb.DHF) == 0) {
_this.formEdit.getForm().findField('BILLSTATUS').setDisabled(true);
_this.formEdit.getForm().findField('SETTLEUSER').setDisabled(true);
_this.formEdit.getForm().findField('COMPANYID').setDisabled(true);
_this.formEdit.getForm().findField('SETTLEMODE').setDisabled(true);
_this.formEdit.getForm().findField('BILLTYPE').setDisabled(true);
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/Account/Chfee_Foreignsettlement/Save',
scope: _this,
params: {
opstatus: _this.opStatus,
data: Ext.JSON.encode(data),
accountsdata: Ext.JSON.encode(accountsdata),
prepaydata: Ext.JSON.encode(prepaydata),
ahsrdata: Ext.JSON.encode(ahsrdata),
financialdata: Ext.JSON.encode(financialdata),
advancedata: Ext.JSON.encode(advancedata),
billtype: 2,
prepaychange: prepaychange,
PAYRMB: Ext.JSON.encode(payrmb)
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
var returnData = jsonresult.Data;
condition = " BILLNO='" + returnData.BILLNO + "'";
_this.opStatus = 'edit';
_this.LoadData(this.opStatus, condition);
if (_this.opStatus == 'add') {
var arrNewRecords = _this.StoreList.add(returnData);
_this.editRecord = arrNewRecords[0];
}
else if (_this.opStatus == 'edit') {
/* var editp = Ext.create('MsChSettlement', 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';
} 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
});
}
}
});
/////////////////////////////////////////////////
}
if (parseFloat(payrmb.Amount) + parseFloat(payrmb.SXF) + parseFloat(payrmb.DHF) != 0) {
_this.formEdit.getForm().findField('BILLSTATUS').setDisabled(true);
_this.formEdit.getForm().findField('SETTLEUSER').setDisabled(true);
_this.formEdit.getForm().findField('COMPANYID').setDisabled(true);
_this.formEdit.getForm().findField('SETTLEMODE').setDisabled(true);
_this.formEdit.getForm().findField('BILLTYPE').setDisabled(true);
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/Account/Chfee_Foreignsettlement/Save',
scope: _this,
params: {
opstatus: _this.opStatus,
data: Ext.JSON.encode(data),
accountsdata: Ext.JSON.encode(accountsdata),
prepaydata: Ext.JSON.encode(prepaydata),
ahsrdata: Ext.JSON.encode(ahsrdata),
financialdata: Ext.JSON.encode(financialdata),
advancedata: Ext.JSON.encode(advancedata),
billtype: 2,
prepaychange: prepaychange,
PAYRMB: Ext.JSON.encode(payrmb)
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
var returnData = jsonresult.Data;
condition = " BILLNO='" + returnData.BILLNO + "'";
_this.opStatus = 'edit';
_this.LoadData(this.opStatus, condition);
_this.formEdit.getForm().setValues(returnData);
if (_this.opStatus == 'add') {
var arrNewRecords = _this.StoreList.add(returnData);
_this.editRecord = arrNewRecords[0];
}
else if (_this.opStatus == 'edit') {
var editp = Ext.create('MsChSettlement', 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';
} 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
OprationSwap: function () {
var ret = new Array();
ret[0] = 'blview';
ret[1] = this.BSNO;
//ret[2] = this.SelectedRecord;
return ret;
},
onAddDetailClick: function (button, event, curr) {
this.addstore = true;
this.addDetail(curr);
}, //end onAddDetailClick
onDelDetailClick: function (button, event, type) {
this.deleteDetail();
}, //onDelDetailClick
onAddClick: function (button, event) {
this.addstore = true;
this.addBill();
}, //end onAddDetailClick
onDeleteClick: function (button, event) {
this.deleteBill();
}, //end onAddDetailClick
gridAddFeeListAfterEdit: function (editor, e, eOpts) {
//需要自己实现里面的事件
if (e.value == e.originalValue) return;
if (e.field == 'STLAMOUNT') {
var BalAmount = e.record.data['BALAMOUNT'];
var StlAmount = e.record.data['STLAMOUNT'];
if (BalAmount >= 0) {
if (StlAmount > BalAmount) {
e.record.set('STLAMOUNT', BalAmount);
Ext.Msg.show({ title: '提示', msg: '结算金额不能大于未结金额!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
}
} else {
if (StlAmount < BalAmount) {
e.record.set('STLAMOUNT', BalAmount);
Ext.Msg.show({ title: '提示', msg: '结算金额不能大于未结金额!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
}
}
}
},
onNextKeyClick: function (col) {
var rows = this.gridAddFeeList.getSelectionModel().getSelection();
var row = rows[rows.length - 1];
var s = this.gridAddFeeList.getStore();
var number = s.indexOf(row) + 1;
this.cellEditingFee.startEditByPosition({ row: number, column: col });
},
onUpKeyClick: function (col) {
var rows = this.gridAddFeeList.getSelectionModel().getSelection();
var row = rows[rows.length - 1];
var s = this.gridAddFeeList.getStore();
var number = s.indexOf(row) - 1;
if (number < 0) number = 0;
this.cellEditingFee.startEditByPosition({ row: number, column: col });
},
addDetail: function (addcurr) {
var basicForm = this.formEdit.getForm();
var Duino = this.formEdit.getForm().findField('BILLNO').getValue();
_this = this;
if ((Duino == '*') || basicForm.isDirty()) {
var CUSTOMERNAME = this.formEdit.getForm().findField('CUSTOMERNAME').getValue();
var CURR = this.formEdit.getForm().findField('CURR').getValue();
if (addcurr == '') {
if ((CURR == '') || (CURR == null))
this.formEdit.getForm().findField('CURR').setValue('RMB');
} else {
if ((CURR == '') || (CURR == null))
this.formEdit.getForm().findField('CURR').setValue(addcurr);
}
if ((CUSTOMERNAME == '') || (CUSTOMERNAME == null) || (CURR == '') || (CURR == null)) {
var selectedRecords = this.gridAddFeeList.selModel.getSelection();
if (selectedRecords.length > 0) {
var rec = selectedRecords[0];
var cust = rec.data.CUSTOMERNAME;
var curr = rec.data.CURR;
if ((CUSTOMERNAME == '') || (CUSTOMERNAME == null))
this.formEdit.getForm().findField('CUSTOMERNAME').setValue(cust);
if ((CURR == '') || (CURR == null))
this.formEdit.getForm().findField('CURR').setValue(addcurr);
}
var CUSTOMERNAME = _this.formEdit.getForm().findField('CUSTOMERNAME').getValue();
if (CUSTOMERNAME != '') {
_this.storecustbank.load({ params: { condition: "LINKID=(SELECT TOP 1 GID FROM INFO_CLIENT WHERE SHORTNAME='" + CUSTOMERNAME + "')" },
callback: function (r, options, success) {
if (success) {
if (_this.formEdit.getForm().findField('CUSTBANK').getValue() == '')
_this.formEdit.getForm().findField('CUSTBANK').setValue(data.CUSTBANK);
}
},
scope: this
});
}
}
if (!basicForm.isValid()) {
return;
}
var type = 0;
this.formEdit.getForm().findField('BILLSTATUS').setDisabled(false);
this.formEdit.getForm().findField('SETTLEUSER').setDisabled(false);
this.formEdit.getForm().findField('COMPANYID').setDisabled(false);
this.formEdit.getForm().findField('SETTLEMODE').setDisabled(false);
this.formEdit.getForm().findField('BILLTYPE').setDisabled(false);
var field = this.formEdit.getForm().findField('SETTLEMODE');
field.setValue(1);
var field = this.formEdit.getForm().findField('BILLTYPE');
field.setValue(2);
var _curr = this.formEdit.getForm().findField('CURR').getValue();
var curr = this.formACCOUNTS.getForm().findField('ACCOUNTS_CURRENCY');
curr.setValue(_curr);
var curr = this.formPREPAY.getForm().findField('PREPAY_CURRENCY');
curr.setValue(_curr);
var curr = this.formAHSR.getForm().findField('AHSR_CURRENCY');
curr.setValue(_curr);
var curr = this.formFINANCIAL.getForm().findField('FINANCIAL_CURRENCY');
curr.setValue("RMB");
var curr = this.formADVANCE.getForm().findField('ADVANCE_CURRENCY');
curr.setValue(_curr);
var data = basicForm.getValues();
var accountsdata = this.formACCOUNTS.getForm().getValues();
var prepaydata = this.formPREPAY.getForm().getValues();
var prepaychange = this.formPREPAY.getForm().findField('PREPAY_MONEY').isDirty();
var ahsrdata = this.formAHSR.getForm().getValues();
var financialdata = this.formFINANCIAL.getForm().getValues();
var advancedata = this.formADVANCE.getForm().getValues();
this.formEdit.getForm().findField('BILLSTATUS').setDisabled(true);
this.formEdit.getForm().findField('SETTLEUSER').setDisabled(true);
this.formEdit.getForm().findField('COMPANYID').setDisabled(true);
this.formEdit.getForm().findField('SETTLEMODE').setDisabled(true);
this.formEdit.getForm().findField('BILLTYPE').setDisabled(true);
var payrmb = this.formPAYRMB.getForm().getValues();
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/Account/Chfee_Foreignsettlement/Save',
scope: this,
params: {
opstatus: this.opStatus,
data: Ext.JSON.encode(data),
accountsdata: Ext.JSON.encode(accountsdata),
prepaydata: Ext.JSON.encode(prepaydata),
ahsrdata: Ext.JSON.encode(ahsrdata),
financialdata: Ext.JSON.encode(financialdata),
advancedata: Ext.JSON.encode(advancedata),
billtype: 2,
prepaychange: prepaychange,
PAYRMB: Ext.JSON.encode(payrmb)
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
var returnData = jsonresult.Data;
this.formEdit.getForm().setValues(returnData);
if (this.opStatus == 'add') {
var arrNewRecords = this.StoreList.add(returnData);
this.editRecord = arrNewRecords[0];
}
else if (this.opStatus == 'edit') {
var editp = Ext.create('MsChSettlement', 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();
}
this.opStatus = 'edit';
_this.addDetailfn(addcurr);
} 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
});
}
}
});
} else {
_this.addDetailfn(addcurr);
}
}, //end save
addDetailfn: function (addcurr) {
if (this.addstore) {
this.storeCurrExrate.removeAll();
this.addstore = false;
}
var Duino = this.formEdit.getForm().findField('BILLNO').getValue();
var billstatus = this.formEdit.getForm().findField('BILLSTATUS').getValue();
if (billstatus != 2) {
Ext.Msg.show({ title: '提示', msg: '当前状态无法添加付费结算明细!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
var basicForm = this.formEdit.getForm();
var billcust = this.editRecord.data.CUSTOMERNAME;
var billno = this.editRecord.data.BILLNO;
var billcurr = this.editRecord.data.CURR;
var selectedRecords = this.gridAddFeeList.selModel.getSelection();
var bodyAddDatas = [];
_this = this;
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
var cust = rec.data.CUSTOMERNAME;
var bsno = rec.data.BILLNO;
var curr = rec.data.CURR;
if (cust == billcust) {
bodyAddDatas.push(rec);
// if (billcurr == curr) {
// bodyAddDatas.push(rec);
// } else {
// Ext.Msg.show({ title: '提示', msg: '币别与付费结算币别不一致,不能添加此申请!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
// }
} else {
Ext.Msg.show({ title: '提示', msg: '费用对象与付费结算客户不一致,不能添加此费用明细!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
}
}
if (bodyAddDatas.length == 0) {
Ext.Msg.show({ title: '提示', msg: '没有要添加的费用明细!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
};
var jsonbodyAddDatas = ConvertRecordsToJsonAll(bodyAddDatas);
var bodydatas = [];
for (var i = 0; i < this.storeCurrExrate.getCount(); i += 1) {
var member = this.storeCurrExrate.getAt(i);
if (member.data.EXRATE == 0) {
_this.ExrateConversion(member.CURR, billcurr, 'bill', addcurr);
return;
}
bodydatas.push(member);
}
var currBody = ConvertRecordsToJsonAll(bodydatas);
Ext.Ajax.request({
waitMsg: '正在添加数据...',
url: '/Account/Chfee_Foreignsettlement/AddAppDCDetail',
params: {
bill: billno,
data: jsonbodyAddDatas,
curr: billcurr,
billtype: 2,
addcurr: addcurr,
storeCurrExrate: currBody
},
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 {
dataList = result.Data;
if (dataList == null) {
var sql = this.BillSql;
this.storeAddFeeList.load({ params: { start: 0, limit: _this.PageSize, sort: '', condition: sql} });
this.storeBodyList.load({ params: { billno: billno },
callback: function (r, options, success) {
if (success) {
if (_this.storeBodyList.getCount() > 0) {
_this.comboxCurr.setReadOnly(true);
_this.comboxCustCode.setReadOnly(true);
}
else {
_this.comboxCurr.setReadOnly(false);
_this.comboxCustCode.setReadOnly(false);
}
}
},
scope: this
});
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/Account/Chfee_Foreignsettlement/GetData',
params: {
handle: 'edit',
condition: " BILLNO='" + billno + "'"
},
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;
data.AMOUNT = usMoney(data.AMOUNT, 2, '', false);
_this.formEdit.getForm().reset();
_this.formACCOUNTS.getForm().reset();
_this.formPREPAY.getForm().reset();
_this.formAHSR.getForm().reset();
_this.formFINANCIAL.getForm().reset();
_this.formADVANCE.getForm().reset();
_this.formEdit.getForm().setValues(data);
_this.formACCOUNTS.getForm().setValues(data);
_this.formPREPAY.getForm().setValues(data);
_this.formAHSR.getForm().setValues(data);
_this.formFINANCIAL.getForm().setValues(data);
_this.formADVANCE.getForm().setValues(data);
var editp = Ext.create('MsChSettlement', 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();
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
} else {
for (var i = 0; i < dataList.length; i++) {
var record = dataList[i];
_this.storeCurrExrate.add(record);
}
_this.ExrateConversion(record.CURR, billcurr, 'detail', addcurr);
return;
}
}
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
},
deleteBill: function (type) {
var billno = this.formEdit.getForm().findField('BILLNO').getValue();
var selectedRecords = this.gridList.selModel.getSelection();
if (selectedRecords.length == 0) {
Ext.Msg.show({ title: '提示', msg: '没有要删除的费用明细!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
};
var billstatus = this.formEdit.getForm().findField('BILLSTATUS').getValue();
if (billstatus != 2) {
Ext.Msg.show({ title: '提示', msg: '当前状态无法删除付费结算明细!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
var bodyAddDatas = [];
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
bodyAddDatas.push(rec);
}
var jsonbodyAddDatas = ConvertRecordsToJsonAll(bodyAddDatas);
var sql = this.BillSql;
Ext.Ajax.request({
waitMsg: '正在删除数据...',
url: '/Account/Chfee_Foreignsettlement/DelAppBill',
params: {
data: jsonbodyAddDatas,
billno: billno,
billtype: 2
},
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 sql = this.BillSql;
this.storeAddFeeList.load({ params: { start: 0, limit: _this.PageSize, sort: '', condition: sql} });
this.storeBodyList.load({ params: { billno: billno },
callback: function (r, options, success) {
if (success) {
if (_this.storeBodyList.getCount() > 0) {
_this.comboxCurr.setReadOnly(true);
_this.comboxCustCode.setReadOnly(true);
}
else {
_this.comboxCurr.setReadOnly(false);
_this.comboxCustCode.setReadOnly(false);
}
}
},
scope: this
});
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/Account/Chfee_Foreignsettlement/GetData',
params: {
handle: 'edit',
condition: " BILLNO='" + billno + "'"
},
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;
data.AMOUNT = usMoney(data.AMOUNT, 2, '', false);
_this.formEdit.getForm().reset();
_this.formACCOUNTS.getForm().reset();
_this.formPREPAY.getForm().reset();
_this.formAHSR.getForm().reset();
_this.formFINANCIAL.getForm().reset();
_this.formADVANCE.getForm().reset();
_this.formEdit.getForm().setValues(data);
_this.formACCOUNTS.getForm().setValues(data);
_this.formPREPAY.getForm().setValues(data);
_this.formAHSR.getForm().setValues(data);
_this.formFINANCIAL.getForm().setValues(data);
_this.formADVANCE.getForm().setValues(data);
var editp = Ext.create('MsChSettlement', 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();
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
}
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
},
//#region 预收付操作
onAddAPDetailClick: function (button, event) {
var gid = this.formEdit.getForm().findField('GID').getValue();
var billno = this.formEdit.getForm().findField('BILLNO').getValue();
var billstatus = this.formEdit.getForm().findField('BILLSTATUS').getValue();
if (billstatus != 2) {
Ext.Msg.show({ title: '提示', msg: '当前状态无法添加明细!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
var basicForm = this.formEdit.getForm();
var basicForm1 = this.formACCOUNTS.getForm();
var basicForm2 = this.formPREPAY.getForm();
var basicForm3 = this.formAHSR.getForm();
var basicForm4 = this.formFINANCIAL.getForm();
var basicForm5 = this.formADVANCE.getForm();
if (basicForm.isDirty() || basicForm1.isDirty()
|| basicForm2.isDirty() || basicForm3.isDirty() || basicForm4.isDirty() || basicForm5.isDirty()) {
Ext.Msg.show({ title: '提示', msg: '请先保存付费结算单,然后才能添加明细!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
};
var selectedRecords = this.gridListAcc.selModel.getSelection();
var bodyAddDatas = [];
_this = this;
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
bodyAddDatas.push(rec);
}
if (bodyAddDatas.length == 0) {
Ext.Msg.show({ title: '提示', msg: '没有要添加的费用明细!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
};
var jsonbodyAddDatas = ConvertRecordsToJsonAll(bodyAddDatas);
_this = this;
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/Account/Chfee_Foreignsettlement/AddAPDetail',
scope: this,
params: {
billno: billno,
data: jsonbodyAddDatas,
stlnogid: gid,
feetype: 2
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
var custome = _this.formEdit.getForm().findField('CUSTOMERNAME').getValue();
var billno = _this.formEdit.getForm().findField('BILLNO').getValue();
var curr = _this.formADVANCE.getForm().findField('ADVANCE_CURRENCY').getValue();
var sql = "CUSTOMERNAME='" + custome + "' and (ISFINISH=0 or ISFINISH IS NULL) AND FEETYPE=2 AND currency='" + curr + "' AND BILLNO<>'" + billno + "' and Amount<>DoAmount ";
_this.storeAccBodyList.load({ params: { start: 0, limit: _this.PageSize, sort: '', condition: sql} });
// _this.storePaymentList.load({ params: { start: 0, limit: _this.PageSize, sort: '', condition: "BILLNO='" + billno + "'"} });
_this.storeBodyListAcc.load({ params: { condition: " SETTLEBILLNO='" + billno + "'" },
callback: function (r, options, success) {
if (success) {
if (_this.storeBodyListAcc.getCount() > 0) (this.comboxCurrADVANCE.readOnly = true)
}
},
scope: this
});
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/Account/Chfee_Foreignsettlement/GetData',
params: {
handle: 'edit',
condition: " BILLNO='" + billno + "'"
},
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;
data.AMOUNT = usMoney(data.AMOUNT, 2, '', false);
_this.formAHSR.getForm().reset();
_this.formADVANCE.getForm().reset();
_this.formAHSR.getForm().setValues(data);
_this.formADVANCE.getForm().setValues(data);
var editp = Ext.create('MsChSettlement', 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();
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
} 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
});
}
}
});
},
onDeleteApClick: function (button, event) {
var billno = this.formEdit.getForm().findField('BILLNO').getValue();
var billstatus = this.formEdit.getForm().findField('BILLSTATUS').getValue();
if (billstatus != 2) {
Ext.Msg.show({ title: '提示', msg: '当前状态无法删除明细!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
var selectedRecords = this.gridBodyListAcc.selModel.getSelection();
var bodyAddDatas = [];
_this = this;
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
var voucherno = rec.data.VOUCHERNO;
if (voucherno == '') {
bodyAddDatas.push(rec);
} else {
Ext.Msg.show({ title: '提示', msg: '已生成总账凭证不能删除!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
}
//
var sVOUNO = rec.data.VOUNO;
if (sVOUNO == '') {
bodyAddDatas.push(rec);
} else {
Ext.Msg.show({ title: '提示', msg: '已生成接口凭证不能删除!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
}
}
if (bodyAddDatas.length == 0) {
Ext.Msg.show({ title: '提示', msg: '没有要删除明细!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
};
var jsonbodyAddDatas = ConvertRecordsToJsonAll(bodyAddDatas);
_this = this;
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/Account/Chfee_Foreignsettlement/DelAPBill',
scope: this,
params: {
data: jsonbodyAddDatas
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
var custome = _this.formEdit.getForm().findField('CUSTOMERNAME').getValue();
var billno = _this.formEdit.getForm().findField('BILLNO').getValue();
var curr = _this.formADVANCE.getForm().findField('ADVANCE_CURRENCY').getValue();
var sql = "CUSTOMERNAME='" + custome + "' and (ISFINISH=0 or ISFINISH IS NULL) AND FEETYPE=2 AND currency='" + curr + "' AND BILLNO<>'" + billno + "'";
_this.storeAccBodyList.load({ params: { start: 0, limit: _this.PageSize, sort: '', condition: sql} });
// _this.storePaymentList.load({ params: { start: 0, limit: _this.PageSize, sort: '', condition: "BILLNO='" + billno + "'"} });
_this.storeBodyListAcc.load({ params: { condition: " SETTLEBILLNO='" + billno + "'" },
callback: function (r, options, success) {
if (success) {
if (_this.storeBodyListAcc.getCount() > 0) (this.comboxCurrADVANCE.readOnly = true)
}
},
scope: this
});
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/Account/Chfee_Foreignsettlement/GetData',
params: {
handle: 'edit',
condition: " BILLNO='" + billno + "'"
},
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;
data.AMOUNT = usMoney(data.AMOUNT, 2, '', false);
_this.formAHSR.getForm().reset();
_this.formADVANCE.getForm().reset();
_this.formAHSR.getForm().setValues(data);
_this.formADVANCE.getForm().setValues(data);
var editp = Ext.create('MsChSettlement', 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();
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
} 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
});
}
}
});
},
//#endregion
onSubmitAuditClick: function () {
var Duino = this.formEdit.getForm().findField('BILLNO').getValue();
var billstatus = this.formEdit.getForm().findField('BILLSTATUS').getValue();
var REMARK = this.formEdit.getForm().findField('REMARK').getValue();
if (Duino == '*') {
Ext.Msg.show({ title: '提示', msg: '请先保存付费结算,然后才能锁定!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
};
if ((billstatus != 2)) {
Ext.Msg.show({ title: '提示', msg: '当前状态无法锁定!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
if (this.storeBodyList.getCount() == 0) {
Ext.Msg.show({ title: '提示', msg: '没有付费明细,无法锁定!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
_this = this;
Ext.Ajax.request({
waitMsg: '正在添加数据...',
url: '/Account/Chfee_Foreignsettlement/Lock',
params: {
bill: Duino,
remark: REMARK
},
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 {
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/Account/Chfee_Foreignsettlement/GetData',
params: {
handle: 'edit',
condition: " BILLNO='" + Duino + "'"
},
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;
data.AMOUNT = usMoney(data.AMOUNT, 2, '', false);
_this.formEdit.getForm().findField('BILLSTATUS').setDisabled(false);
_this.formEdit.getForm().reset();
_this.formEdit.getForm().setValues(data);
_this.formEdit.getForm().findField('BILLSTATUS').setDisabled(true);
var editp = Ext.create('MsChSettlement', 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();
_this.GetEditStatus();
//
_this.setBtnStatusDisable();
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
}
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
},
onSubmitAuditBackClick: function () {
var Duino = this.formEdit.getForm().findField('BILLNO').getValue();
var billstatus = this.formEdit.getForm().findField('BILLSTATUS').getValue();
if (Duino == '*') {
Ext.Msg.show({ title: '提示', msg: '请先保存付费结算,然后才能撤销锁定!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
};
if (billstatus != 1) {
Ext.Msg.show({ title: '提示', msg: '当前状态无法撤销锁定!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
var isvou = this.formEdit.getForm().findField('ISEXPORT').getValue();
if (isvou == true) {
Ext.Msg.show({ title: '提示', msg: '此票结算已生成凭证无法撤消锁定!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
//
var sVOUCHERNO = this.formEdit.getForm().findField('VOUCHERNO').getValue();
if (sVOUCHERNO != "") {
Ext.Msg.show({ title: '提示', msg: '此票结算已生成总账凭证无法撤消锁定!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
//
var sVOUNO = this.formEdit.getForm().findField('VOUNO').getValue();
if (sVOUNO != "") {
Ext.Msg.show({ title: '提示', msg: '此票结算已生成接口凭证无法撤消锁定!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
_this = this;
Ext.Ajax.request({
waitMsg: '正在添加数据...',
url: '/Account/Chfee_Foreignsettlement/UnLock',
params: {
bill: Duino
},
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 {
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/Account/Chfee_Foreignsettlement/GetData',
params: {
handle: 'edit',
condition: " BILLNO='" + Duino + "'"
},
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;
data.AMOUNT = usMoney(data.AMOUNT, 2, '', false);
_this.formEdit.getForm().findField('BILLSTATUS').setDisabled(false);
_this.formEdit.getForm().reset();
_this.formEdit.getForm().setValues(data);
_this.formEdit.getForm().findField('BILLSTATUS').setDisabled(true);
var editp = Ext.create('MsChSettlement', 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();
_this.GetEditStatus();
//
_this.setBtnStatusDisable();
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
}
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
},
onRefreshClick: function (button, event) {
var sql = this.getCondition();
this.storeAddFeeList.load({ params: { start: 0, limit: this.PageSize, sort: '', condition: sql} });
},
onClearSql: function () {
var form = this.formSearch.getForm();
form.reset();
},
getCondition: function () {
var form = this.formSearch.getForm();
if (!form.isValid()) {
Ext.Msg.alert('提示', '查询条件赋值错误,请检查。');
return '';
}
var sql = '';
var customNo = form.findField('CustomNo').getValue();
sql = sql + getAndConSql(sql, customNo, " BILLNO like '%" + customNo + "%'");
var BH = form.findField('BH').getValue();
sql = sql + getAndConSql(sql, BH, " EXISTS(select 1 from ch_fee_do where BILLNO=cm.BILLNO and EXISTS(select 1 from v_op_bs where bsno=ch_fee_do.BSNO and (CUSTNO like '%" + BH + "%' or MBLNO like '%" + BH + "%' or HBLNO like '%" + BH + "%') ))");
var CUSTNAME = form.findField('CUSTNAME').getValue();
sql = sql + getAndConSql(sql, CUSTNAME, " CUSTOMERNAME='" + CUSTNAME + "'");
var Currency = form.findField('Currency').getValue();
sql = sql + getAndConSql(sql, Currency, "CURR='" + Currency + "'");
var expDateBgn = form.findField('ExpDateBgn').getRawValue();
sql = sql + getAndConSql(sql, expDateBgn, "APPLYTIME >='" + expDateBgn + "'");
var expDateEnd = form.findField('ExpDateEnd').getRawValue();
sql = sql + getAndConSql(sql, expDateEnd, "APPLYTIME <='" + expDateEnd + " 23:59:59'");
var DC = form.findField('ISDEBIT').getValue();
if (DC == '1')
sql = sql + getAndConSql(sql, DC, " (BILLSTATUS=0 OR BILLSTATUS=5) ");
// this.FeeSqlStr = this.getFeeCondition();
// feesql = feesql + getAndConSql(feesql, this.FeeSqlStr, this.FeeSqlStr);
// 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, "f.CUSTOMERNAME='" + CUSTNAME + "'");
var Currency = form.findField('Currency').getValue();
feesql = feesql + getAndConSql(feesql, Currency, "f.Currency='" + Currency + "'");
var FeeName = form.findField('FeeName').getValue();
feesql = feesql + getAndConSql(feesql, FeeName, "f.FeeName='" + FeeName + "'");
return feesql;
},
ExrateConversion: function (bfcurr, afcurr, fntype, addcurr) {
var EXRATE = 0;
var achange = true;
var bchange = true;
formExrateConversion = Ext.widget('form', {
frame: true,
region: 'center',
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: '1' + bfcurr + '=',
xtype: 'numberfield',
name: 'bfcurr',
decimalPrecision: 10,
value: 0,
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
try {
var lsValue = usMoney(value, 10, '', 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;
},
listeners: {
change: function () {
if (bchange) {
var bfcurr = formExrateConversion.getForm().findField('bfcurr').getValue();
var field = formExrateConversion.getForm().findField('afcurr');
if (bfcurr == 0) { field.setValue(0); } else {
var taxrate = (parseFloat(1).div(parseFloat(bfcurr))).toFixed(10);
achange = false;
field.setValue(taxrate);
}
}
achange = true;
}
}
}, {
xtype: 'label',
width: 120,
text: afcurr,
name: 'bfcurr2'
}
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '1' + afcurr + '=',
xtype: 'numberfield',
name: 'afcurr',
decimalPrecision: 10,
value: 0,
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
try {
var lsValue = usMoney(value, 10, '', 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;
},
listeners: {
change: function () {
if (achange) {
var afcurr = formExrateConversion.getForm().findField('afcurr').getValue();
var field = formExrateConversion.getForm().findField('bfcurr');
if (afcurr == 0) { field.setValue(0); } else {
var taxrate = (parseFloat(1).div(parseFloat(afcurr))).toFixed(10);
bchange = false;
field.setValue(taxrate);
}
}
bchange = true;
}
}
}, {
xtype: 'label',
width: 120,
text: bfcurr,
name: 'afcurr2'
}
]
}
]//end items(fieldset 1)
}//end fieldset 1
]//end root items
});
me = this;
winExrateShow = Ext.create('Ext.window.Window', {
title: "币别汇率折算",
width: 450,
//height : 120,
//plain : true,
iconCls: "addicon",
resizable: false,
// 是否可以拖动
// draggable:false,
collapsible: true, // 允许缩放条
closeAction: 'close',
closable: true,
modal: 'true',
buttonAlign: "center",
bodyStyle: "padding:0 0 0 0",
items: [formExrateConversion],
buttons: [{
text: "确定",
minWidth: 70,
handler: function () {
var form = formExrateConversion.getForm();
var UsdExrate = form.findField('bfcurr').getValue();
if (UsdExrate == '' || UsdExrate == null || UsdExrate == undefined) {
Ext.Msg.show({ title: '提示', msg: '必须填折算汇率!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
};
var recs = DsStoreQueryBy(me.storeCurrExrate, 'CURR', bfcurr);
if (recs.getCount() > 0) {
// var dfdata = DFrecords.getAt(0).data;
// dfdata.EXRATE = UsdExrate;
for (var i = 0; i < me.storeCurrExrate.getCount(); i += 1) {
var member = me.storeCurrExrate.getAt(i);
if (member.data.CURR == bfcurr) {
// member.EXRATE = UsdExrate;
member.set('EXRATE', UsdExrate);
member.commit();
}
}
} else {
me.storeCurrExrate.add({ "CURR": bfcurr, "EXRATE": UsdExrate })
}
winExrateShow.close();
if (fntype == 'detail') {
me.addDetailfn(addcurr);
}
return;
}
}, {
text: "关闭",
minWidth: 70,
handler: function () {
winExrateShow.close();
return;
}
}]
});
if (bfcurr == 'RMB') {
var DFrecords = DsStoreQueryBy(this.StoreCurr, 'CURR', afcurr);
if (DFrecords.getCount() > 0) {
var dfdata = DFrecords.getAt(0).data;
var DEFRATE = dfdata.DEFRATE;
} else {
var DEFRATE = 0;
}
var field = formExrateConversion.getForm().findField('afcurr');
achange = true;
field.setValue(DEFRATE);
} else {
var DFrecords = DsStoreQueryBy(this.StoreCurr, 'CURR', bfcurr);
if (DFrecords.getCount() > 0) {
var dfdata = DFrecords.getAt(0).data;
var DEFRATE = dfdata.DEFRATE;
} else {
var DEFRATE = 0;
}
var field = formExrateConversion.getForm().findField('bfcurr');
bchange = true;
field.setValue(DEFRATE);
}
winExrateShow.show();
// S=setInterval(function () {
// if (EXRATE != 0) {
// alert(EXRATE);
// clearInterval(S);
// }
// }, 500)
},
// #region 根据权限和状态判断是否允许修改
GetEditStatus: function () {
var canedit = false;
this.formEdit.getForm().findField('BILLSTATUS').setDisabled(false);
var bsStatus = this.formEdit.getForm().findField('BILLSTATUS').getValue();
var op = this.formEdit.getForm().findField('SETTLEUSERREF').getValue();
var opid = this.formEdit.getForm().findField('SETTLEUSER').getValue();
this.formEdit.getForm().findField('BILLSTATUS').setDisabled(true);
var btnESubmitAudit = Ext.getCmp('btnSubmitAudit');
var btnESubmitAuditBack = Ext.getCmp('btnSubmitAuditBack');
_this = this;
if (bsStatus != 2) {
canedit = false;
this.setSaveBtnStatus(canedit);
} else {
this.StoreOpRange.load({ params: { optype: "modPaySettlementList" },
callback: function (r, options, success) {
if (success) {
if (r.length != 0) {
var records = DsStoreQueryBy(_this.StoreOpRange, 'OPID', op);
if (records.getCount() > 0) {
canedit = true;
} else {
canedit = false;
}
_this.setSaveBtnStatus(canedit);
}
}
}
});
}
this.StoreLockOp.load({ params: { optype: "modPayFeeSettlementLock" },
callback: function (r, options, success) {
if (success) {
if (r.length != 0) {
var records = DsStoreQueryBy(_this.StoreLockOp, 'OPID', opid);
if (records.getCount() > 0) {
if (bsStatus == 1) {
btnESubmitAudit.disable();
} else {
btnESubmitAudit.enable();
}
} else {
btnESubmitAudit.disable();
}
}
}
}
});
this.StoreUnLockOp.load({ params: { optype: "modPayFeeSettlementUnLock" },
callback: function (r, options, success) {
if (success) {
if (r.length != 0) {
var records = DsStoreQueryBy(_this.StoreUnLockOp, 'OPID', opid);
if (records.getCount() > 0) {
if (bsStatus == 1) {
btnESubmitAuditBack.enable();
} else {
btnESubmitAuditBack.disable();
}
} else {
btnESubmitAuditBack.disable();
}
}
}
}
});
},
setSaveBtnStatus: function (enable) {
var btnESave = Ext.getCmp('btnESave');
var btnESaveAndClose = Ext.getCmp('btnESaveAndClose');
var btnESaveAndNew = Ext.getCmp('btnESaveAndNew');
var btnEAddDetail = Ext.getCmp('btnadddetail');
var btnEDeleteDetail = Ext.getCmp('btndeldetail');
if (enable) {
btnESave.enable();
btnESaveAndClose.enable();
btnESaveAndNew.enable();
btnEAddDetail.enable();
btnEDeleteDetail.enable();
} else {
btnESave.disable();
btnESaveAndClose.disable();
btnESaveAndNew.disable();
btnEAddDetail.disable();
btnEDeleteDetail.disable();
}
},
// #endregion
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 CUSTOMERNAME = basicForm.findField('CUSTOMERNAME').value;
var printType = 'MSCHFEEPAYSETTLEMENT';
/*SELECT s.ACCOUNTS_CURRENCY 币别,(select sum(amount) from ch_fee_do d where d.BILLNO=s.BILLNO) 金额,
(select ShowName from [user] where GID=s.SETTLEUSER) as SETTLEUSERREF ,s.ACCOUNTRMB 付款RMB账户
FROM ch_fee_settlement s WHERE BILLNO='CS2015092800001'
SELECT b.CUSTNO 合同号,c.GID,c.BSNO,c.FEEID,c.FEENAME,c.CURRENCY,c.AMOUNT,c.DOAMOUNT,c.ORIGCURRENCY
,c.ORIGAMOUNT,c.EXCHANGERATE,FEETYPE
,b.CUSTOMERNAME,b.VESSEL,b.VOYNO,b.ETD,b.PORTLOAD
,b.PORTDISCHARGE,b.INPUTBY,b.OP,b.CUSTSERVICE,b.DOC,b.SALE,b.MBLNO
FROM ch_fee_do c left join v_op_bill b on (b.bsno=c.bsno)
WHERE C.BILLNO='CS2015092800001' ORDER BY b.VESSEL,b.VOYNO,b.MBLNO
select enname 公司英文名称,ENADDRESS 公司英文地址,ORGANIZATIONCODE 组织机构代码
,* from company where gid=(select top 1 companyid from ch_fee_do where BILLNO='CS2015092800001')
select EnFullName 收款公司名称,USDAccount 收款方外币账号,USDBank 收款方外币开户行,ADDR 收款方地址
,USDOnlineNO 银行帐号代码, * from info_client where gid=( select gid from info_client where SHORTNAME='CAMPOFRIO')*/
var sql1 = " SELECT s.*,s.ACCOUNTS_CURRENCY 币别,(select sum(amount) from ch_fee_do d where d.BILLNO=s.BILLNO) 金额, ";
sql1 = sql1 + " (select ShowName from [user] where GID=s.SETTLEUSER) as SETTLEUSERREF ";
sql1 = sql1 + " ,(select ACCOUNT from sys_bank where gid =s.ACCOUNTRMB) 付款RMB账户 ";
sql1 = sql1 + " ,(select ACCOUNT from sys_bank where gid =s.ACCOUNTUSD) 付款外币账户 ";
sql1 = sql1 + " FROM ch_fee_settlement s WHERE BILLNO='" + billNo + "' ";
var sql2 = "SELECT c.GID,c.BSNO,c.FEEID,c.FEENAME,c.CURRENCY,c.AMOUNT,c.DOAMOUNT,c.ORIGCURRENCY,c.ORIGAMOUNT,c.EXCHANGERATE,FEETYPE ";
sql2 = sql2 + ",b.CUSTOMERNAME,b.VESSEL,b.VOYNO,b.ETD,b.PORTLOAD";
sql2 = sql2 + " ,b.PORTDISCHARGE,b.INPUTBY,b.OP,b.CUSTSERVICE,b.DOC,b.SALE,b.MBLNO,b.CUSTNO 合同号";
sql2 = sql2 + " FROM ch_fee_do c left join v_op_bill b on (b.bsno=c.bsno)";
sql2 = sql2 + " WHERE C.BILLNO='" + billNo + "' ORDER BY b.VESSEL,b.VOYNO,b.MBLNO";
var sql3 = " select enname 公司英文名称,ENADDRESS 公司英文地址,ORGANIZATIONCODE 组织机构代码 ";
sql3 = sql3 + " ,* from company where gid=(select CORPID from v_op_bs where bsno= (select top 1 bsno from ch_fee_do where BILLNO='" + billNo + "')) ";
var sql4 = " select EnFullName 收款公司名称,USDAccount 收款方外币账号,USDBank 收款方外币开户行,ADDR 收款方地址 ";
sql4 = sql4 + " ,USDOnlineNO 银行帐号代码, * from info_client where gid=( select gid from info_client where SHORTNAME='" + CUSTOMERNAME + "') ";
var sql5 = "";
var sql6 = "";
PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6);
},
//#region 总账凭证
//#region 查看总账凭证
onSelCwVouchers: function (button, event) {
var billNo = this.formEdit.getForm().findField('BILLNO').value;
if (billNo == '*' || billNo == '') {
Ext.Msg.show({ title: '提示', msg: '请先保存单据!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
var sVOUCHERNO = this.formEdit.getForm().findField('VOUCHERNO').value;
if (sVOUCHERNO == '') {
Ext.Msg.show({ title: '提示', msg: '请先生成总账凭证!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
this.sqlcontext = sVOUCHERNO;
this.OprationStatus = 'sel';
DsOpenEditWin('/MvcShipping/MsCwVouchersGl/Edit', "总账凭证录入", "500", "940", "10", "10");
},
//#endregion
//#region 生成总账凭证
onAddCwVouchers: function (button, event) {
var billNo = this.formEdit.getForm().findField('BILLNO').value;
if (billNo == '*' || billNo == '') {
Ext.Msg.show({ title: '提示', msg: '请先保存单据!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
Ext.Ajax.request({
waitMsg: '正在预读数据,请稍候...',
url: '/Account/Chfee_settlement/GetIsVoucher',
params: {
strGids: this.editRecord.data.GID.toString()
},
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;
}
//this.storeListCw.load({ params: { strGids: this.editRecord.data.GID.toString() }, waitMsg: "正在刷新数据...", scope: this });
this.showContactForm(false, this.editRecord.data.GID.toString(), this);
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
},
//#endregion
//#region 总账层_显示信息
showContactForm: function (win, strGids, _this) {
var required = '<span style="color:red;font-weight:bold;" data-qtip="Required">*</span>';
if (!win) {
//#region formDiv 下拉框信息加载
//制单人
this.storePREPAREDCode = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.UserRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetUserRefList' }
});
this.storePREPAREDCode.load();
this.comboxPREPARED = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '制单人',
store: this.storePREPAREDCode,
forceSelection: true,
//id: 'PREPARED',
name: 'PREPARED',
valueField: 'UserName',
displayField: 'CodeAndName',
value: SHOWNAME
});
//#endregion
//#region 生成凭证_汇率列表
//#region 定义数据集
this.storeListCw = Ext.create('Ext.data.Store', {
pageSize: this.PageSize,
model: 'MsCodeCurrencyList',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/Account/Chfee_settlement/GetCodeCurrencyList',
reader: {
id: 'CURR',
root: 'data',
totalProperty: 'totalCount'
}
}
});
//#endregion
//#region 列定义
this.girdcolums = [{
sortable: false,
text: '币别',
dataIndex: 'CURR',
width: 100,
align: 'center'
}, {
sortable: false,
text: '调整汇率',
dataIndex: 'FCYEXRATE',
width: 118,
align: 'right',
editor: {
xtype: 'numberfield',
selectOnFocus: true, //得到焦点时自动选择文本
allowDecimals: true, //允许输入小数
decimalPrecision: 5, //允许保留的小数位数,并四舍五入
nanText: '请输入有效数值',
hideTrigger: true //是否隐藏上下调节按钮
},
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
try {
var lsValue = usMoney(value, 5, '', 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;
}
}];
//#endregion
//#region gridList列表显示信息
this.gridListCellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1 //1单击2双击
});
this.gridListCw = new Ext.grid.GridPanel({
region: 'center',
width: 220,
store: this.storeListCw,
enableHdMenu: false, //是否显示表格列的菜单
hideHeaders: false, //是否隐藏表头
rowLines: true,
columnLines: true,
loadMask: { msg: "数据加载中,请稍等..." },
plugins: [this.gridListCellEditing],
selType: 'cellmodel',
columns: this.girdcolums
});
//#endregion
//#endregion
//#region 编辑formDiv 基本信息
var formDiv = Ext.widget('form', {
border: false,
bodyPadding: 10,
fieldDefaults: {
labelAlign: 'right',
labelWidth: 60,
labelStyle: 'font-weight:bold'
},
items: [this.comboxPREPARED, {
fieldLabel: '记账日期',
format: 'Y-m-d',
xtype: 'datefield',
allowBlank: false,
name: 'VOUDATE',
value: Ext.util.Format.date(Ext.Date.add(new Date(), Ext.Date.MONTH - 1, 1), "Y-m-d")
}, {
xtype: "checkbox", //checkbox控件
name: "ButtSettlement",
boxLabel: "对抵结算是否生成银行账款",
width: 200,
inputValue: "true", //选中的值
uncheckedValue: "false" //未选中的值
}, {
xtype: "checkbox", //checkbox控件
name: "ISRATE",
boxLabel: "是否按照系统录入汇率",
width: 200,
inputValue: "true", //选中的值
uncheckedValue: "false", //未选中的值
checked: true, //绘制时的选中状态,
listeners: {
'change': function (field, newValue, oldValue, eOpts) {
if (field.checked.toString() == "false") {
this.gridListCw.show();
}
else {
this.gridListCw.hide();
}
},
scope: this
}
}, this.gridListCw
],
buttons: [{
text: '生成凭证',
handler: function (options, success, response) {
if (!this.up('form').getForm().isValid()) {
return;
}
var dataDiv = this.up('form').getForm().getValues(false, false, false);
//
var j = 0;
var bodydatas = [];
for (var i = 0; i < _this.storeListCw.getCount(); i += 1) {
var member = _this.storeListCw.getAt(i);
bodydatas.push(member);
}
var jsonBody;
if (bodydatas.length > 0) {
jsonBody = ConvertRecordsToJsonAll(bodydatas);
}
//
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/Account/Chfee_settlement/onAddCwVouchers',
scope: this,
params: {
strGids: strGids,
dataDiv: Ext.JSON.encode(dataDiv),
jsonBody: jsonBody
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
Ext.Msg.show({ title: '提示', msg: jsonresult.Message, icon: Ext.MessageBox.INFO, buttons: Ext.Msg.OK });
//刷新页面
var billno = _this.formEdit.getForm().findField('BILLNO').getValue();
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/Account/Chfee_settlement/GetData',
params: {
handle: 'edit',
condition: " BILLNO='" + billno + "'"
},
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;
data.AMOUNT = usMoney(data.AMOUNT, 2, '', false);
_this.formEdit.getForm().findField('BILLSTATUS').setDisabled(false);
_this.formEdit.getForm().reset();
_this.formEdit.getForm().setValues(data);
_this.formEdit.getForm().findField('BILLSTATUS').setDisabled(true);
var editp = Ext.create('MsChSettlement', 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();
_this.GetEditStatus();
//
_this.setBtnStatusDisable();
//是否自动弹出结算凭证
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/Account/Chfee_settlement/onIsSettlementsopen',
scope: this,
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
_this.onSelCwVouchers(sData.toString());
}
}
}
});
//
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
//Ext.getCmp('btnAddCwVouchers').setText("撤销凭证");
return;
} 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 });
}
}
});
//
this.up('form').getForm().reset();
this.up('window').close();
}
}, {
text: '取消',
handler: function () {
this.up('form').getForm().reset();
this.up('window').close();
}
}],
listeners: {
scope: this,
'render': function (thisDiv, thisExtend) {
this.gridListCw.hide();
//
Ext.Ajax.request({
waitMsg: '正在查询委托编号状态...',
url: '/MvcShipping/MsBaseInfo/GetCwVOUNO',
params: {
VKNO: "记"
},
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.INFO, buttons: Ext.Msg.OK });
return;
}
//
data = result.data;
var arrayList = new Array();
arrayList = data.split("~");
var strY = arrayList[0].toString();
var strM = arrayList[1].toString();
var sVOUNO = arrayList[2].toString();
var strVOUNO = arrayList[3].toString();
var strVOUDATE = arrayList[4].toString();
var strACCDATE = arrayList[5].toString();
//
thisDiv.form.findField('VOUDATE').setValue(strVOUDATE);
thisDiv.form.findField('VOUDATE').setMinValue(strACCDATE + "-01");
//Ext.getCmp('VOUDATE').setValue(strVOUDATE);
//Ext.getCmp('VOUDATE').setMinValue(strACCDATE + "-01");
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
}
}
});
//#endregion
win = Ext.widget('window', {
title: '生成总账凭证',
closeAction: 'destroy', //hide,
width: 250,
height: 250,
layout: 'fit',
closable: false, //为false时tab上不显示叉号
resizable: true,
modal: true,
items: formDiv
});
}
win.show();
},
//#endregion
//#endregion
//#region 接口凭证
//#region 查看接口凭证
onSelCwVouchersJK: function (button, event) {
var billNo = this.formEdit.getForm().findField('BILLNO').value;
if (billNo == '*' || billNo == '') {
Ext.Msg.show({ title: '提示', msg: '请先保存单据!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
var sVOUNO = this.formEdit.getForm().findField('VOUNO').value;
if (sVOUNO == '') {
Ext.Msg.show({ title: '提示', msg: '请先生成接口凭证!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
this.sqlcontext = sVOUNO;
this.OprationStatus = 'sel';
DsOpenEditWin('/MvcShipping/MsCwVouchers/Edit', "接口凭证录入", "500", "940", "10", "10");
},
//#endregion
//#region 生成接口凭证
onAddCwVouchersJK: function (button, event) {
var billNo = this.formEdit.getForm().findField('BILLNO').value;
if (billNo == '*' || billNo == '') {
Ext.Msg.show({ title: '提示', msg: '请先保存单据!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
Ext.Ajax.request({
waitMsg: '正在预读数据,请稍候...',
url: '/Account/Chfee_settlement/GetIsVoucherJK',
params: {
strGids: this.editRecord.data.GID.toString()
},
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;
}
//
this.showContactFormJK(false, this.editRecord.data.GID.toString(), this);
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
},
//#endregion
//#region 接口层_显示信息
showContactFormJK: function (win, strGids, _this) {
var required = '<span style="color:red;font-weight:bold;" data-qtip="Required">*</span>';
if (!win) {
//#region formDiv 下拉框信息加载
//制单人
this.storePREPAREDCode = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.UserRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetUserRefList' }
});
this.storePREPAREDCode.load();
this.comboxPREPARED = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '制单人',
store: this.storePREPAREDCode,
forceSelection: true,
id: 'PREPARED',
name: 'PREPARED',
valueField: 'UserName',
displayField: 'CodeAndName',
value: SHOWNAME
});
//#endregion
//#region 编辑formDiv 基本信息
var formDiv = Ext.widget('form', {
border: false,
bodyPadding: 10,
fieldDefaults: {
labelAlign: 'right',
labelWidth: 60,
labelStyle: 'font-weight:bold'
},
items: [this.comboxPREPARED, {
fieldLabel: '记账日期',
format: 'Y-m-d',
xtype: 'datefield',
allowBlank: false,
name: 'VOUDATE',
value: Ext.util.Format.date(Ext.Date.add(new Date(), Ext.Date.MONTH - 1, 1), "Y-m-d"),
listeners: {
'blur': function (field, The, eOpts) {
this.GetCodeCurrencyListJK(Ext.getCmp('VOUDATE').getRawValue());
},
scope: this
}
}, {
xtype: "checkbox", //checkbox控件
name: "ButtSettlement",
boxLabel: "对抵结算是否生成银行账款",
width: 200,
inputValue: "true", //选中的值
uncheckedValue: "false" //未选中的值
}, {
xtype: "checkbox", //checkbox控件
name: "ISRATE",
boxLabel: "是否按照系统录入汇率",
width: 200,
inputValue: "true", //选中的值
uncheckedValue: "false", //未选中的值
checked: true, //绘制时的选中状态,
listeners: {
'change': function (field, newValue, oldValue, eOpts) {
if (field.checked.toString() == "false") {
Ext.getCmp('RATE').show();
}
else {
Ext.getCmp('RATE').hide();
}
},
scope: this
}
}, {
fieldLabel: '美元汇率',
id: 'RATE',
name: 'RATE',
xtype: 'numberfield',
nanText: '请输入有效整数',
value: 1,
//labelAlign: 'right',
//labelWidth: 65,
//width: 163,
allowBlank: false
}],
buttons: [{
text: '生成凭证',
handler: function (options, success, response) {
if (!this.up('form').getForm().isValid()) {
return;
}
var dataDiv = this.up('form').getForm().getValues(false, false, false);
//
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/Account/Chfee_settlement/onAddCwVouchersJK',
scope: this,
params: {
strGids: strGids,
dataDiv: Ext.JSON.encode(dataDiv)
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
var sData = jsonresult.Data;
//Ext.Msg.show({ title: '提示', msg: jsonresult.Message, icon: Ext.MessageBox.INFO, buttons: Ext.Msg.OK });
//刷新页面
var billno = _this.formEdit.getForm().findField('BILLNO').getValue();
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/Account/Chfee_settlement/GetData',
params: {
handle: 'edit',
condition: " BILLNO='" + billno + "'"
},
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 returnData = result.data;
returnData.AMOUNT = usMoney(returnData.AMOUNT, 2, '', false);
_this.formEdit.getForm().setValues(returnData);
//
var editp = Ext.create('MsChSettlement', 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();
//
_this.setBtnStatusDisable();
//是否自动弹出结算凭证
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/Account/Chfee_settlement/onIsSettlementsopenJK',
scope: this,
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
_this.onSelCwVouchersJK(sData.toString());
}
}
}
});
//
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
//Ext.getCmp('btnAddCwVouchers').setText("撤销凭证");
return;
} 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 });
}
}
});
//
this.up('form').getForm().reset();
this.up('window').close();
}
}, {
text: '取消',
handler: function () {
this.up('form').getForm().reset();
this.up('window').close();
}
}],
listeners: {
scope: this,
'render': function (thisDiv, thisExtend) {
Ext.getCmp('RATE').hide();
}
}
});
//#endregion
win = Ext.widget('window', {
title: '生成接口凭证',
closeAction: 'destroy', //hide,
width: 250,
height: 250,
layout: 'fit',
closable: false, //为false时tab上不显示叉号
resizable: true,
modal: true,
items: formDiv
});
}
win.show();
},
//获取默认汇率
GetCodeCurrencyListJK: function (sVOUDATE) {
Ext.Ajax.request({
waitMsg: '正在添加数据...',
url: '/Account/Chfee_settlement/GetCodeCurrencyListJK',
params: {
sVOUDATE: sVOUDATE
},
callback: function (options, success, response) {
if (success) {
var result = Ext.JSON.decode(response.responseText);
if (!result.Success) {
Ext.getCmp('RATE').setValue("0");
//Ext.Msg.show({ title: '提示', msg: result.Message, icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK });
return;
} else {
Ext.getCmp('RATE').setValue(result.data[0].FCYEXRATE.toString());
}
} else {
Ext.getCmp('RATE').setValue("0");
//Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
},
//#endregion
//#endregion
//#region 凭证维护页面的传值及本页设置
setBtnStatusDisable: function () {
if (this.opStatus == 'edit') {
var sBILLSTATUSREF = this.formEdit.getForm().findField('BILLSTATUSREF').getValue();
if (sBILLSTATUSREF == "") {
sBILLSTATUSREF = this.editRecord.get('BILLSTATUSREF');
}
if (sBILLSTATUSREF == "锁定") {
var sVOUNO = this.formEdit.getForm().findField('VOUNO').getValue();
if (sVOUNO == "") {
sVOUNO = this.editRecord.get('VOUNO');
}
if (sVOUNO.toString().trim() == "") {
Ext.getCmp('btnAddCwVouchersJK').show();
Ext.getCmp('btnSelCwVouchersJK').hide();
}
else {
Ext.getCmp('btnAddCwVouchersJK').hide();
Ext.getCmp('btnSelCwVouchersJK').show();
}
//
var sVOUCHERNO = this.formEdit.getForm().findField('VOUCHERNO').getValue();
if (sVOUCHERNO == "") {
sVOUCHERNO = this.editRecord.get('VOUCHERNO');
}
if (sVOUCHERNO.toString().trim() == "") {
Ext.getCmp('btnAddCwVouchers').show();
Ext.getCmp('btnSelCwVouchers').hide();
}
else {
Ext.getCmp('btnAddCwVouchers').hide();
Ext.getCmp('btnSelCwVouchers').show();
}
}
else {
Ext.getCmp('btnAddCwVouchers').hide();
Ext.getCmp('btnSelCwVouchers').hide();
Ext.getCmp('btnAddCwVouchersJK').hide();
Ext.getCmp('btnSelCwVouchersJK').hide();
}
}
else {
Ext.getCmp('btnAddCwVouchers').hide();
Ext.getCmp('btnSelCwVouchers').hide();
Ext.getCmp('btnAddCwVouchersJK').hide();
Ext.getCmp('btnSelCwVouchersJK').hide();
}
},
OprationSwapJK: function () {
var ret = new Array();
ret[0] = this.OprationStatus;
ret[1] = this.storeList;
ret[2] = this.SelectedRecord;
ret[3] = this.sqlcontext;
ret[4] = null;
ret[5] = Ext.getCmp('VOUNO');
ret[6] = Ext.getCmp('btnAddCwVouchersJK');
ret[7] = Ext.getCmp('btnSelCwVouchersJK');
ret[8] = Ext.getCmp('VOUCHERNO');
ret[9] = Ext.getCmp('btnAddCwVouchers');
ret[10] = Ext.getCmp('btnSelCwVouchers');
return ret;
}
//#endregion
//
});