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/Import/Viewsjs/Finance/FinanceEdit.js

4101 lines
138 KiB
JavaScript

3 years ago
Ext.namespace('DsTruck');
DsTruck.FinanceEdit = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.DsTruck.FinanceEdit.superclass.constructor.call(this);
};
Ext.extend(DsTruck.FinanceEdit, Ext.Panel, {
ParentWin: null,
OpStatus: 'add',
StoreList: null,
EditRecord: null,
initUIComponents: function () {
this.serialNo = 0;
this.FinanceFeeDel = [];
this.CONTRACTNO = "";
//#region 编辑form
this.storeBuyer_F = Ext.create('DsExt.ux.RefTableStore', {
model: 'Tradermb',
proxy: { url: '/CommMng/BasicDataRef/GetTrader' }
});
this.storeBuyer_F.load({ params: { condition: " 1=1 "} });
this.comboxBuyer_F = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '融资客户',
forceSelection: true,
store: this.storeBuyer_F,
name: 'CUSTOMER',
valueField: 'name',
displayField: 'codename',
listeners: {
change: function (obj, newValue, oldValue, eOpts) {
Ext.Ajax.request({
url: '/Import/Finance/GetRmModel',
params: {
name: newValue
},
callback: function (options, success, response) {
try {
var data = eval(response.responseText);
var arr = [];
for (var i = 0; i < data.length; i++) {
arr.push((i + 1) + "、超期天数:" + data[i].ExtendedDays + "天 日利率:" + data[i].Rate);
}
document.getElementById("CustStatus").innerText = "客户利率标准:" + (arr.length > 0 ? arr.join('') : "未配置");
} catch (e) { }
},
scope: this
});
}
}
});
Ext.define('MsFeeCurr', {
extend: 'Ext.data.Model',
idProperty: 'CURR',
fields: [
{ name: 'CURR', type: 'string' },
{ name: 'DEFRATE', type: 'number' }
]
});
this.StoreCurr = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsFeeCurr',
proxy: { url: '/MvcShipping/MsChFee/GetFeeCurrList' }
});
this.StoreCurr.load({ params: { condition: ""} });
this.comboxCurr = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '融资币别',
store: this.StoreCurr,
forceSelection: true,
allowBlank: false,
name: 'F_CURRENCY',
valueField: 'CURR',
displayField: 'CURR'
});
_this = this;
//编辑form
this.formEdit = Ext.widget('form', {
region: 'north',
//height:150,
frame: true,
bodyPadding: 5,
autoScroll: true,
fieldDefaults: {
margins: '2 2 2 2',
labelAlign: 'right',
flex: 1,
labelWidth: 90,
msgTarget: 'qtip'
},
items: [
{//fieldset 1
xtype: 'fieldset',
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [
{
fieldLabel: '融资业务编号',
name: 'F_NO', readOnly: true, hidden: false
}, {
fieldLabel: '业务编号',
name: 'MAINNO', readOnly: true, hidden: true
}, {
fieldLabel: '操作',
name: 'OP', readOnly: true, hidden: true
}, this.comboxBuyer_F, this.comboxCurr, {
fieldLabel: '融资金额',
name: 'F_AMOUNT', value: 0
}]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '融资汇率',
readOnly:true,
name: 'F_Rate'
}, {
fieldLabel: '折合人民币金额',
readOnly: true,
name: 'F_RMB'
},{
fieldLabel: '融资时间',
id: 'STARTDATE',
format: 'Y-m-d',
xtype: 'datefield',
renderer: Ext.util.Format.dateRenderer('Y-m-d'),
name: 'STARTDATE',
listeners: {
change: function () {
var basicForm = _this.formEdit.getForm();
var STARTDATE = basicForm.findField('STARTDATE').getRawValue();
var newValue = basicForm.findField('DAYS').getValue();
newValue = newValue - 1;
var ENDATE = getNewDay(STARTDATE, newValue);
basicForm.findField('ENDDATE').setValue(ENDATE);
var BANKENDATE = getNewDay(STARTDATE, 90);
basicForm.findField('BANKENDDATE').setValue(BANKENDATE);
}
}
}, {
fieldLabel: '融资天数',
name: 'DAYS', value: 0,
listeners: {
blur: function (field, eOpts) {
var basicForm = this.formEdit.getForm();
var STARTDATE = basicForm.findField('STARTDATE').getRawValue();
var newValue = field.value;
newValue = newValue - 1;
var ENDATE = getNewDay(STARTDATE, newValue);
basicForm.findField('ENDDATE').setValue(ENDATE);
},
scope: this
}
}]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [ {
fieldLabel: '客户还款日期',
id: 'ENDDATE',
format: 'Y-m-d',
xtype: 'datefield',
renderer: Ext.util.Format.dateRenderer('Y-m-d'),
name: 'ENDDATE',
listeners: {
change: function () {
}
}
},
{
fieldLabel: '银行还款日期',
id: 'BANKENDDATE',
format: 'Y-m-d',
xtype: 'datefield',
renderer: Ext.util.Format.dateRenderer('Y-m-d'),
name: 'BANKENDDATE',
listeners: {
change: function () {
}
}
},{
fieldLabel: '客户还款金额',
readOnly: true, flex: 1,
name: 'CUSTSTLAMOUNT'
}, {
fieldLabel: '客户未还金额',
readOnly: true, flex: 1,
name: 'CUSTBALAMOUNT'
}]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '银行还款金额',
readOnly: true, flex: 1,
name: 'BANKSTLAMOUNT'
}, {
fieldLabel: '银行未还金额',
readOnly: true, flex: 1,
name: 'BANKBALAMOUNT'
},{
fieldLabel: '融资状态',
name: 'F_STATUS', readOnly: true, hidden: false
}, {
fieldLabel: '操作人',
readOnly: true, flex: 1,
name: 'OPREF'
}]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '建立时间',
format: 'Y-m-d H:i:s',
xtype: 'datefield',
renderer: Ext.util.Format.dateRenderer('Y-m-d H:i:s'),
name: 'ENTERDATE'
}, {
fieldLabel: '备注', flex: 1,
name: 'REMARK'
}
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'label',
padding: '0 0 0 15',
items: [
{
text: '客户利率标准0.00',
id: 'CustStatus'
}
]
}
]//end items(fieldset 1)
}//end fieldset 1
]//end root items
}); //end this.formEdit
//#endregion
var menu1 = new Ext.menu.Menu({
id: 'basicMenu',
items: [{
text: "还款通知单",
handler: function (button, event) {
this.Print();
},
scope: this
}]
});
//#region 按钮Toolbar
this.panelBtn = new Ext.Panel({
region: "north",
tbar: [{
text: "确认融资",
iconCls: "btnadd",
id: "btnAudit",
handler: function (button, event) {
this.FinanceWin();
},
scope: this
}, {
text: "取消融资",
iconCls: "btnreset",
id: "btnCancelAudit",
handler: function (button, event) {
this.CancelFinancel();
},
scope: this
}, '-',
{
text: "保存",
iconCls: "btnsave",
id: "btnSave",
handler: function (button, event) {
this.Save('0');
},
scope: this
}, '-',
{
text: "保存并关闭",
id: "btnSaveClose",
handler: function (button, event) {
this.Save('1');
},
scope: this
}, '-',
{
text: "打印", menu: menu1, scope: this
}
]
}); //end 按钮Toolbar
//#endregion
//#region 明细表
//#region 银行列表
this.comboxBank = Ext.create('DsExt.ux.RefTableCombox', {
forceSelection: true,
store: this.storeBuyer_F,
valueField: 'name',
displayField: 'codename'
});
this.storeListBank = Ext.create('Ext.data.Store', {
model: 'FinanceBank',
remoteSort: false,
proxy: {
type: 'ajax',
url: '/Import/Finance/GetBankList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.cellEditingBank = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
this.BankGridCheckBoxModel = Ext.create('Ext.selection.CheckboxModel');
this.gridListBank = new Ext.grid.GridPanel({
store: this.storeListBank,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
plugins: [this.cellEditingBank],
selModel: this.BankGridCheckBoxModel,
tbar: [{
text: '添加融资银行',
tooltip: '添加融资银行',
iconCls: "btnadddetail",
id: "btnaddBank",
handler: function (button, event) {
this.onAddBankClick(button, event);
},
scope: this
}, '-', {
text: '删除融资银行',
tooltip: '删除融资银行',
id: "btndelBank",
iconCls: "btndeletedetail",
handler: function (button, event) {
this.onDelBankClick(button, event);
},
scope: this
}],
columns: [
{
sortable: true, hidden: true,
dataIndex: 'GID',
header: 'GID',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'F_NO',
header: 'F_NO',
width: 80
},
{
sortable: true,
dataIndex: 'BANK',
header: '融资银行',
editor: this.comboxBank,
width: 120
},
{
sortable: true,
dataIndex: 'AMOUNT',
header: '融资金额',
width: 80,
editor: {
xtype: 'numberfield',
keyNavEnabled: false,
selectOnFocus: true,
hideTrigger: true,
mouseWheelEnabled: false,
decimalPrecision: 4,
enableKeyEvents: true
}
},
{
sortable: true,
dataIndex: 'DOAMOUNT',
header: '还款金额',
width: 120
}]
});
//#endregion
//#region 融资明细
this.storeDetailList = Ext.create('Ext.data.Store', {
model: 'FinanceTradeBody',
remoteSort: false,
proxy: {
type: 'ajax',
url: '/Import/Finance/GetBodyList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.gridListDetail = new Ext.grid.GridPanel({
store: this.storeDetailList,
enableHdMenu: false,
autoScroll: true,
layout: 'border',
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
columns: [{
sortable: true,
dataIndex: 'F_NO',
header: 'F_NO',
hidden: true,
width: 100
}, {
sortable: true,
dataIndex: 'GID',
header: 'GID',
hidden: true,
width: 100
}, {
sortable: true,
dataIndex: 'CONTRACTNO',
header: '合同序号',
width: 120
}, {
sortable: true,
dataIndex: 'HTH',
header: '合同号',
width: 120
}, {
sortable: true,
dataIndex: 'BILLNO',
header: '提单号',
width: 120
}, {
sortable: true,
dataIndex: 'SELLER',
header: '贸易商',
width: 100
}, {
sortable: true,
dataIndex: 'BUYER',
header: '购货方',
width: 80
}, {
sortable: true,
dataIndex: 'COMPANYNAME',
header: '用证公司',
width: 80
}, {
sortable: true,
dataIndex: 'ARRIVALDATE',
header: '到港日期',
renderer: Ext.util.Format.dateRenderer('Y-m-d'),
width: 100
}, {
sortable: true,
dataIndex: 'PORTREF',
header: '目的港',
width: 80
}, {
sortable: true,
dataIndex: 'R_AMOUNT',
header: '申请金额',
width: 80
}
]
});
//#endregion
// #region 进行融资的业务还款
this.comboxCurrBody = Ext.create('DsExt.ux.RefTableCombox', {
store: this.StoreCurr,
forceSelection: true,
allowBlank: false,
valueField: 'CURR',
displayField: 'CURR'
});
this.comboxCust = Ext.create('DsExt.ux.RefTableCombox', {
forceSelection: true,
store: this.storeBuyer_F,
valueField: 'name',
displayField: 'codename'
});
this.comboxCustBank = Ext.create('DsExt.ux.RefTableCombox', {
forceSelection: true,
store: this.storeListBank,
valueField: 'BANK',
displayField: 'BANK'
});
this.storeBodyList = Ext.create('Ext.data.Store', {
model: 'FinanceBodymb',
remoteSort: false,
proxy: {
type: 'ajax',
url: '/Import/Finance/GetFinanceBody',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.BodyGridCheckBoxModel = Ext.create('Ext.selection.CheckboxModel');
this.cellEditingBodyGrid = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
this.fr_columns = [
{
sortable: true,
hidden: true,
dataIndex: 'GID',
header: 'GID',
width: 80
},
{
sortable: true,
hidden: true,
dataIndex: 'F_NO',
header: 'F_NO',
width: 80
},
{
sortable: true,
dataIndex: 'CUSTOMER',
header: '还款客户',
editor: this.comboxCust,
width: 100
},
{
sortable: true,
hidden: true,
dataIndex: 'BSNO',
header: 'BSNO',
editor: {
xtype: 'textfield',
selectOnFocus: true
},
width: 100
},
{
sortable: true,
dataIndex: 'CUSTNO',
header: '业务编号',
width: 100
},
{
sortable: true,
dataIndex: 'D_INTEREST_RATE',
header: '日利率',
hidden:true,
width: 80,
editor: {
xtype: 'numberfield',
keyNavEnabled: false,
selectOnFocus: true,
hideTrigger: true,
mouseWheelEnabled: false,
decimalPrecision: 4,
enableKeyEvents: true
}
},
{
sortable: true,
dataIndex: 'INTEREST_RATE',
header: '月利息',
width: 80,
editor: {
xtype: 'numberfield',
keyNavEnabled: false,
selectOnFocus: true,
hideTrigger: true,
mouseWheelEnabled: false,
decimalPrecision: 4,
enableKeyEvents: true
}
},
{
sortable: true,
dataIndex: 'Y_INTEREST_RATE',
header: '年利息',
width: 80,
editor: {
xtype: 'numberfield',
keyNavEnabled: false,
selectOnFocus: true,
hideTrigger: true,
mouseWheelEnabled: false,
decimalPrecision: 4,
enableKeyEvents: true
}
},
{
sortable: true,
dataIndex: 'F_CURRENCY',
header: '还款币别',
editor: this.comboxCurrBody,
width: 80
},
{
sortable: true,
dataIndex: 'ENDDATE',
header: '还款日期',
width: 90,
renderer: Ext.util.Format.dateRenderer('Y-m-d'),
editor: {
xtype: 'datefield',
selectOnFocus: true
}
},
{
sortable: true,
dataIndex: 'DAYS',
header: '计息天数',
width: 80,
editor: {
xtype: 'numberfield',
keyNavEnabled: false,
selectOnFocus: true,
hideTrigger: true,
mouseWheelEnabled: false,
decimalPrecision: 4,
enableKeyEvents: true
}
},
{
sortable: true,
dataIndex: 'F_AMOUNT',
header: '还款金额(原币)',
width: 80,
editor: {
xtype: 'numberfield',
keyNavEnabled: false,
selectOnFocus: true,
hideTrigger: true,
mouseWheelEnabled: false,
decimalPrecision: 4,
enableKeyEvents: true
}
},
{
sortable: true,
dataIndex: 'EXCHANGERATE',
header: '汇率',
width: 80,
editor: {
xtype: 'numberfield',
keyNavEnabled: false,
selectOnFocus: true,
hideTrigger: true,
mouseWheelEnabled: false,
decimalPrecision: 4,
enableKeyEvents: true
}
},
{
sortable: true,
dataIndex: 'RMBVALUE',
header: '还款货值RMB',
width: 80,
editor: {
xtype: 'numberfield',
keyNavEnabled: false,
selectOnFocus: true,
hideTrigger: true,
mouseWheelEnabled: false,
decimalPrecision: 4,
enableKeyEvents: true
}
},
{
sortable: true,
dataIndex: 'HANDFEE',
header: '手续费',
width: 80,
editor: {
xtype: 'numberfield',
keyNavEnabled: false,
selectOnFocus: true,
hideTrigger: true,
mouseWheelEnabled: false,
decimalPrecision: 4,
enableKeyEvents: true
}
},
{
sortable: true,
dataIndex: 'TELXFEE',
header: '电报费',
width: 80,
editor: {
xtype: 'numberfield',
keyNavEnabled: false,
selectOnFocus: true,
hideTrigger: true,
mouseWheelEnabled: false,
decimalPrecision: 4,
enableKeyEvents: true
}
},
{
sortable: true,
dataIndex: 'OTFEE',
header: '其他费',
width: 80,
editor: {
xtype: 'numberfield',
keyNavEnabled: false,
selectOnFocus: true,
hideTrigger: true,
mouseWheelEnabled: false,
decimalPrecision: 4,
enableKeyEvents: true
}
},
{
sortable: true,
dataIndex: 'RMBAMOUNT',
header: '本金RMB',
width: 80,
editor: {
xtype: 'numberfield',
keyNavEnabled: false,
selectOnFocus: true,
hideTrigger: true,
mouseWheelEnabled: false,
decimalPrecision: 4,
enableKeyEvents: true
}
},
{
sortable: true,
dataIndex: 'INTEREST',
header: '利息合计',
width: 80,
editor: {
xtype: 'numberfield',
keyNavEnabled: false,
selectOnFocus: true,
hideTrigger: true,
mouseWheelEnabled: false,
decimalPrecision: 4,
enableKeyEvents: true
}
},
{
sortable: true,
dataIndex: 'FINEFEE',
header: '罚息',
width: 80,
editor: {
xtype: 'numberfield',
keyNavEnabled: false,
selectOnFocus: true,
hideTrigger: true,
mouseWheelEnabled: false,
decimalPrecision: 4,
enableKeyEvents: true
}
},
{
sortable: true,
dataIndex: 'TTLAMOUNTRMB',
header: '还款合计',
width: 80,
editor: {
xtype: 'numberfield',
keyNavEnabled: false,
selectOnFocus: true,
hideTrigger: true,
mouseWheelEnabled: false,
decimalPrecision: 4,
enableKeyEvents: true
}
},
{
sortable: true,
dataIndex: 'REMARK',
header: '备注',
width: 80,
editor: {
xtype: 'textfield',
selectOnFocus: true,
enableKeyEvents: true
}
}
];
this.gridBodyList = new Ext.grid.GridPanel({
store: this.storeBodyList,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
plugins: [this.cellEditingBodyGrid],
disableSelection: false,
selModel: this.BodyGridCheckBoxModel,
viewConfig: {
autoFill: true,
enableTextSelection: true,
getRowClass: function (record, rowIndex, rowParams, store) {
var F_NO = record.get('F_NO');
if (F_NO != "") {
return DsTruck.FinanceGetRowClass(1);
}
}
},
tbar: [{
text: '添加还款记录',
tooltip: '添加还款记录',
iconCls: "btnadddetail",
handler: function (button, event) {
this.onAddBodyClick(button, event, 1);
},
scope: this
}, {
text: '保存还款记录',
tooltip: '保存还款记录',
iconCls: "btnsave",
handler: function (button, event) {
this.onPostBodyClick(button, event, 1);
},
scope: this
}, '-', {
text: '删除还款记录',
tooltip: '删除还款记录',
iconCls: "btndeletedetail",
handler: function (button, event) {
this.onDelBodyClick(button, event, 1);
},
scope: this
}, {
text: '生成费用',
tooltip: '生成费用',
handler: function (button, event) {
this.onCreateBodyFeeClick(button, event, 1);
},
scope: this
}, {
text: "保存列表样式",
id: "btnsavelist1",
handler: function (button, event) {
var tempcolumns = _this.gridBodyList.columns;
DsTruck.SaveGridPanel(USERID, "Import_Finance_Rate", tempcolumns);
},
scope: this
}],
columns: this.fr_columns
});
this.CargoColumns = DsTruck.GetGridPanel(USERID, "Import_Finance_Rate", this.fr_columns);
//使用者id表名 中间column数组跳过一开始的几列
this.gridBodyList.reconfigure(this.storeBodyList, this.CargoColumns);
this.storeBodyListBank = Ext.create('Ext.data.Store', {
model: 'FinanceBodymb',
remoteSort: false,
proxy: {
type: 'ajax',
url: '/Import/Finance/GetFinanceBody',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.cellEditingBodyGridBody = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
this.BodyBankGridCheckBoxModel = Ext.create('Ext.selection.CheckboxModel');
this.fr_columnsbank = [
{
sortable: true,
hidden: true,
dataIndex: 'GID',
header: 'GID',
width: 80
},
{
sortable: true,
hidden: true,
dataIndex: 'F_NO',
header: 'F_NO',
width: 80
},
{
sortable: true,
dataIndex: 'CUSTOMER',
header: '还款客户',
editor: this.comboxCustBank,
width: 100
},
{
sortable: true,
dataIndex: 'INTEREST_RATE',
header: '月利息',
width: 80,
editor: {
xtype: 'numberfield',
keyNavEnabled: false,
selectOnFocus: true,
hideTrigger: true,
mouseWheelEnabled: false,
decimalPrecision: 4,
enableKeyEvents: true
}
},
{
sortable: true,
dataIndex: 'Y_INTEREST_RATE',
header: '年利息',
width: 80,
editor: {
xtype: 'numberfield',
keyNavEnabled: false,
selectOnFocus: true,
hideTrigger: true,
mouseWheelEnabled: false,
decimalPrecision: 4,
enableKeyEvents: true
}
},
{
sortable: true,
dataIndex: 'F_CURRENCY',
header: '还款币别',
editor: this.comboxCurrBody,
width: 80
},
{
sortable: true,
dataIndex: 'ENDDATE',
header: '还款日期',
width: 100,
renderer: Ext.util.Format.dateRenderer('Y-m-d'),
editor: {
xtype: 'datefield',
selectOnFocus: true
}
},
{
sortable: true,
dataIndex: 'DAYS',
header: '计息天数',
width: 80,
editor: {
xtype: 'numberfield',
keyNavEnabled: false,
selectOnFocus: true,
hideTrigger: true,
mouseWheelEnabled: false,
decimalPrecision: 4,
enableKeyEvents: true
}
},
{
sortable: true,
dataIndex: 'F_AMOUNT',
header: '还款金额',
width: 80,
editor: {
xtype: 'numberfield',
keyNavEnabled: false,
selectOnFocus: true,
hideTrigger: true,
mouseWheelEnabled: false,
decimalPrecision: 4,
enableKeyEvents: true
}
},
{
sortable: true,
dataIndex: 'EXCHANGERATE',
header: '汇率',
width: 80,
editor: {
xtype: 'numberfield',
keyNavEnabled: false,
selectOnFocus: true,
hideTrigger: true,
mouseWheelEnabled: false,
decimalPrecision: 4,
enableKeyEvents: true
}
},
{
sortable: true,
dataIndex: 'RMBVALUE',
header: '还款货值RMB',
width: 80,
editor: {
xtype: 'numberfield',
keyNavEnabled: false,
selectOnFocus: true,
hideTrigger: true,
mouseWheelEnabled: false,
decimalPrecision: 4,
enableKeyEvents: true
}
},
{
sortable: true,
dataIndex: 'HANDFEE',
header: '手续费',
width: 80,
editor: {
xtype: 'numberfield',
keyNavEnabled: false,
selectOnFocus: true,
hideTrigger: true,
mouseWheelEnabled: false,
decimalPrecision: 4,
enableKeyEvents: true
}
},
{
sortable: true,
dataIndex: 'TELXFEE',
header: '电报费',
width: 80,
editor: {
xtype: 'numberfield',
keyNavEnabled: false,
selectOnFocus: true,
hideTrigger: true,
mouseWheelEnabled: false,
decimalPrecision: 4,
enableKeyEvents: true
}
},
{
sortable: true,
dataIndex: 'OTFEE',
header: '其他费',
width: 80,
editor: {
xtype: 'numberfield',
keyNavEnabled: false,
selectOnFocus: true,
hideTrigger: true,
mouseWheelEnabled: false,
decimalPrecision: 4,
enableKeyEvents: true
}
},
{
sortable: true,
dataIndex: 'RMBAMOUNT',
header: '本金RMB',
width: 80,
editor: {
xtype: 'numberfield',
keyNavEnabled: false,
selectOnFocus: true,
hideTrigger: true,
mouseWheelEnabled: false,
decimalPrecision: 4,
enableKeyEvents: true
}
},
{
sortable: true,
dataIndex: 'INTEREST',
header: '利息合计',
width: 80,
editor: {
xtype: 'numberfield',
keyNavEnabled: false,
selectOnFocus: true,
hideTrigger: true,
mouseWheelEnabled: false,
decimalPrecision: 4,
enableKeyEvents: true
}
},
{
sortable: true,
dataIndex: 'INTERESTUSD',
header: '美元利息',
width: 80,
editor: {
xtype: 'numberfield',
keyNavEnabled: false,
selectOnFocus: true,
hideTrigger: true,
mouseWheelEnabled: false,
decimalPrecision: 4,
enableKeyEvents: true
}
},
{
sortable: true,
dataIndex: 'FINEFEE',
header: '罚息',
width: 80,
editor: {
xtype: 'numberfield',
keyNavEnabled: false,
selectOnFocus: true,
hideTrigger: true,
mouseWheelEnabled: false,
decimalPrecision: 4,
enableKeyEvents: true
}
},
{
sortable: true,
dataIndex: 'TTLAMOUNTRMB',
header: '还款合计',
width: 80,
editor: {
xtype: 'numberfield',
keyNavEnabled: false,
selectOnFocus: true,
hideTrigger: true,
mouseWheelEnabled: false,
decimalPrecision: 4,
enableKeyEvents: true
}
},
{
sortable: true,
dataIndex: 'REMARK',
header: '备注',
width: 80,
editor: {
xtype: 'textfield',
selectOnFocus: true,
enableKeyEvents: true
}
}
];
this.gridBodyListBank = new Ext.grid.GridPanel({
store: this.storeBodyListBank,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
plugins: [this.cellEditingBodyGridBody],
selModel: this.BodyBankGridCheckBoxModel,
viewConfig: {
autoFill: true,
enableTextSelection: true,
getRowClass: function (record, rowIndex, rowParams, store) {
var F_NO = record.get('F_NO');
if (F_NO != "") {
return DsTruck.FinanceGetRowClass(1);
}
}
},
tbar: [{
text: '添加还款记录',
tooltip: '添加还款记录',
iconCls: "btnadddetail",
handler: function (button, event) {
this.onAddBodyClick(button, event, 2);
},
scope: this
}, {
text: '保存还款记录',
tooltip: '保存还款记录',
iconCls: "btnsave",
handler: function (button, event) {
this.onPostBodyClick(button, event, 2);
},
scope: this
}, '-', {
text: '删除还款记录',
tooltip: '删除还款记录',
iconCls: "btndeletedetail",
handler: function (button, event) {
this.onDelBodyClick(button, event, 2);
},
scope: this
}, {
text: '生成费用',
tooltip: '生成费用',
handler: function (button, event) {
this.onCreateBodyFeeClick(button, event, 2);
},
scope: this
}, {
text: "保存列表样式",
id: "btnsavelist",
handler: function (button, event) {
var tempcolumns = _this.gridBodyListBank.columns;
DsTruck.SaveGridPanel(USERID, "Import_Finance_Rate_Bank", tempcolumns);
},
scope: this
}],
columns: this.fr_columnsbank
});
this.CargoColumnsBank = DsTruck.GetGridPanel(USERID, "Import_Finance_Rate_Bank", this.fr_columnsbank);
//使用者id表名 中间column数组跳过一开始的几列
this.gridBodyListBank.reconfigure(this.storeBodyListBank, this.CargoColumnsBank);
this.gridBodyList.on('edit', function (editor, e, eOpts) {
this.gridListBodyAfterEdit(editor, e, eOpts);
}, this);
this.gridBodyListBank.on('edit', function (editor, e, eOpts) {
this.gridListBodyAfterEdit(editor, e, eOpts);
}, this);
this.panelBodyCust = new Ext.Panel({
title: '客户还款记录',
layout: "border",
region: "center",
anchor: '100% 50%',
height: 260,
split: true,
items: [this.gridBodyList]
});
this.panelBodyBank = new Ext.Panel({
title: '还款银行记录',
layout: "border",
region: "center",
anchor: '100% 50%',
height: 260,
split: true,
items: [this.gridBodyListBank]
});
this.panelBody = new Ext.Panel({
title: '还款记录',
layout: "anchor",
region: 'center',
items: [
this.panelBodyCust, this.panelBodyBank
]
});
this.panelBank = new Ext.Panel({
title: '融资银行',
layout: "anchor",
width: 360,
region: 'east',
items: [
this.gridListBank
]
});
/*
this.panelDetail = new Ext.Panel({
title: '融资明细',
layout: "border",
//height: 150,
region: 'center',
items: [
this.gridListDetail
]
});*/
//#endregion
//#endregion
//#endregion
//#endregion 明细表
//#region 费用列表
this.storeFeeTypeRef = Ext.create('DsExt.ux.RefEnumStore', {});
this.storeFeeTypeRef.load({ params: { enumTypeId: 99020} });
this.comboxFeeTypeRef = Ext.create('DsExt.ux.RefEnumCombox', {
store: this.storeFeeTypeRef,
name: 'FeeType'
});
this.storeFeeNameRef = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsTruckMng.ux.FeeTypeRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetFeeTypeRefList' }
});
this.storeFeeNameRef.load({ params: { condition: ""} });
this.comboxFeeNameRef = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storeFeeNameRef,
forceSelection: true,
name: 'FeeName',
valueField: 'Name',
displayField: 'CodeAndName'
});
this.storeCustomerNameRef = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsTruckMng.ux.CustomRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetCustomRefList' }
});
this.storeCustomerNameRef.load({ params: { condition: ""} });
this.comboxCustomerNameRef = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storeCustomerNameRef,
forceSelection: true,
allowBlank: false,
name: 'CustomerName',
valueField: 'CustName',
displayField: 'CodeAndName'
});
this.storecurr = Ext.create('DsExt.ux.RefTableStore', {
model: 'currRef',
proxy: { url: '/CommMng/BasicDataRef/GetcurrRefList' }
});
this.storecurr.load({ params: { condition: ""} });
this.comboxcurr_2 = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storecurr,
name: 'Currency',
valueField: 'codename',
displayField: 'codename'
//币别
});
//明细表-数据集
this.storeBodyChFee = Ext.create('Ext.data.Store', {
model: 'MsChFee',
remoteSort: false,
proxy: {
type: 'ajax',
url: '/Import/XXH/GetFeeList',
reader: {
id: 'GId',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.storeBodyChFee_YF = Ext.create('Ext.data.Store', {
model: 'MsChFee',
remoteSort: false,
proxy: {
type: 'ajax',
url: '/Import/XXH/GetFeeList',
reader: {
id: 'GId',
root: 'data',
totalProperty: 'totalCount'
}
}
});
//明细表表格
this.cellEditingChFee = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
this.feeGridCheckBoxModel = Ext.create('Ext.selection.CheckboxModel');
this.gridListChFee = new Ext.grid.GridPanel({
store: this.storeBodyChFee,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
plugins: [this.cellEditingChFee],
selModel: this.feeGridCheckBoxModel,
selType: 'cellmodel',
viewConfig: {
autoFill: true,
getRowClass: function (record, rowIndex, rowParams, store) {
var feeStatus = record.get('FeeStatus');
return DsTruck.MsChFeeGetRowClass(feeStatus);
}
},
tbar: [{ xtype: 'label', id: 'label1', text: "应收费用" }, '-', {
text: '增加明细',
tooltip: '增加明细', id: "addChfee",
iconCls: "btnadddetail",
handler: function (button, event) {
this.onAddDetailClick(button, event, '1');
},
scope: this
}, {
text: '删除明细',
tooltip: '删除明细', id: "delChfee",
iconCls: "btndeletedetail",
handler: function (button, event) {
this.onDelDetailClick(button, event, '1');
},
scope: this
}, '-', {
text: '提交审核',
tooltip: '提交审核',
iconCls: 'btnsubmitaudit',
handler: function (button, event) {
this.onSubmitAuditClick(button, event, "1");
},
scope: this
}, {
text: '撤回提交',
tooltip: '撤回提交',
iconCls: 'btncomm',
handler: function (button, event) {
this.onRetractClick(button, event, "1");
},
scope: this
}, {
text: "刷新",
iconCls: "btnrefresh",
handler: function (button, event) {
F_NO = this.EditRecord.get('F_NO');
this.storeBodyChFee.load({ params: { billno: F_NO, Feetype: '1'} });
},
scope: this
}, { xtype: "label", id: "zongshu", text: "",
handler: function () { ; }
}],
columns: [{
sortable: true,
dataIndex: 'GId',
header: '惟一编号',
hidden: true,
width: 160
}, {
sortable: true,
dataIndex: 'BsNo',
header: '业务编号',
hidden: true,
width: 200
}, {
sortable: true,
dataIndex: 'FeeStatus',
header: '费用状态',
renderer: function (value, p, record) {
return record.data.FeeStatus_Ref;
},
width: 66
}, {
sortable: true,
dataIndex: 'FeeName',
header: '费用名称',
editor: this.comboxFeeNameRef,
width: 80
}, /*{
sortable: true,hidden:true,
dataIndex: 'FeeType',
header: '收付方式',
renderer: function (value, p, record) {
if (value == null || value == '')
return '';
else
return value + '-' + record.data.FeeType_Ref;
},
editor: this.comboxFeeTypeRef,
width: 66
},*/{
sortable: true,
dataIndex: 'FeeDescription',
header: '费用英文名称',
hidden: true,
width: 200
}, {
sortable: true,
dataIndex: 'CustomerType',
header: '客户类别',
hidden: true,
width: 200
}, {
sortable: true,
dataIndex: 'CustomerName',
header: '结算对象',
editor: this.comboxCustomerNameRef,
width: 120
}, {
sortable: true,
dataIndex: 'Unit',
header: '单位标准',
hidden: true,
width: 200
}, {
sortable: true,
dataIndex: 'UnitPrice',
header: '单价',
editor: {
xtype: 'textfield', //numberfield
selectOnFocus: true
},
width: 120,
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: 'Quantity',
header: '数量',
editor: {
xtype: 'textfield',
selectOnFocus: true
},
width: 60
}, {
sortable: true,
dataIndex: 'Amount',
header: '金额',
width: 120,
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: '币别',
editor: this.comboxcurr_2,
width: 50
}, {
sortable: true,
dataIndex: 'ExChangerate',
header: '汇率',
//hidden: true,
editor: {
xtype: 'textfield',
selectOnFocus: true
},
width: 60
}, {
sortable: true,
dataIndex: 'EnterDate',
header: '时间',
width: 80,
renderer: Ext.util.Format.dateRenderer('Y-m-d'),
editor: {
format: 'Y-m-d',
xtype: 'datefield',
selectOnFocus: true
}
}, {
sortable: true,
dataIndex: 'Remark',
header: '备注',
editor: {
xtype: 'textfield',
selectOnFocus: true
},
width: 250
}
]
});
this.cellEditingChFee_YF = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
this.feeGridCheckBoxModel_YF = Ext.create('Ext.selection.CheckboxModel');
this.gridListChFee_YF = new Ext.grid.GridPanel({
store: this.storeBodyChFee_YF,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
plugins: [this.cellEditingChFee_YF],
selModel: this.feeGridCheckBoxModel_YF,
selType: 'cellmodel',
viewConfig: {
autoFill: true,
getRowClass: function (record, rowIndex, rowParams, store) {
var feeStatus = record.get('FeeStatus');
return DsTruck.MsChFeeGetRowClass(feeStatus);
}
},
tbar: [{ xtype: 'label', id: 'label2', text: "应付费用" }, '-', {
text: '增加明细',
tooltip: '增加明细', id: "addChfee_YF",
iconCls: "btnadddetail",
handler: function (button, event) {
this.onAddDetailClick(button, event, '2');
},
scope: this
}, '-', {
text: '删除明细',
tooltip: '删除明细', id: "delChfee_YF",
iconCls: "btndeletedetail",
handler: function (button, event) {
this.onDelDetailClick(button, event, '2');
},
scope: this
}, '-', {
text: '提交审核',
tooltip: '提交审核',
iconCls: 'btnsubmitaudit',
handler: function (button, event) {
this.onSubmitAuditClick(button, event, "2");
},
scope: this
}, {
text: '撤回提交',
tooltip: '撤回提交',
iconCls: 'btncomm',
handler: function (button, event) {
this.onRetractClick(button, event, "2");
},
scope: this
}, {
text: "刷新",
iconCls: "btnrefresh",
handler: function (button, event) {
F_NO = this.EditRecord.get('F_NO');
this.storeBodyChFee_YF.load({ params: { billno: F_NO, Feetype: '2'} });
},
scope: this
},
{ xtype: "label", id: "zongshu_YF", text: "",
handler: function () { ; }
}],
columns: [{
sortable: true,
dataIndex: 'GId',
header: '惟一编号',
hidden: true,
width: 160
}, {
sortable: true,
dataIndex: 'BsNo',
header: '业务编号',
hidden: true,
width: 200
}, {
sortable: true,
dataIndex: 'FeeStatus',
header: '费用状态',
renderer: function (value, p, record) {
return record.data.FeeStatus_Ref;
},
width: 66
}, {
sortable: true,
dataIndex: 'FeeName',
header: '费用名称',
editor: this.comboxFeeNameRef,
width: 80
}, /*{
sortable: true,
dataIndex: 'FeeType',
header: '收付方式',
renderer: function (value, p, record) {
if (value == null || value == '')
return '';
else
return value + '-' + record.data.FeeType_Ref;
},
editor: this.comboxFeeTypeRef,
width: 66
},*/{
sortable: true,
dataIndex: 'FeeDescription',
header: '费用英文名称',
hidden: true,
width: 200
}, {
sortable: true,
dataIndex: 'CustomerType',
header: '客户类别',
hidden: true,
width: 200
}, {
sortable: true,
dataIndex: 'CustomerName',
header: '结算对象',
editor: this.comboxCustomerNameRef,
width: 120
}, {
sortable: true,
dataIndex: 'Unit',
header: '单位标准',
hidden: true,
width: 200
}, {
sortable: true,
dataIndex: 'UnitPrice',
header: '单价',
editor: {
xtype: 'textfield', //xtype: 'numberfield',
selectOnFocus: true
},
width: 120,
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: 'Quantity',
header: '数量',
editor: {
xtype: 'textfield', //xtype: 'numberfield',
selectOnFocus: true
},
width: 60
}, {
sortable: true,
dataIndex: 'Amount',
header: '金额',
width: 120,
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: '币别',
editor: this.comboxcurr_2,
width: 50
}, {
sortable: true,
dataIndex: 'ExChangerate',
header: '汇率',
//hidden: true,
editor: {
xtype: 'textfield',
selectOnFocus: true
},
width: 60
}, {
sortable: true,
dataIndex: 'EnterDate',
header: '时间',
width: 80,
renderer: Ext.util.Format.dateRenderer('Y-m-d'),
editor: {
format: 'Y-m-d',
xtype: 'datefield',
selectOnFocus: true
}
}, {
sortable: true,
dataIndex: 'Remark',
header: '备注',
editor: {
xtype: 'textfield',
selectOnFocus: true
},
width: 250
}
]
});
//#endregion
//#region 毛利
this.formML = Ext.widget('form', { // layout: "border",
region: 'center',
frame: true,
bodyPadding: 2,
fieldDefaults: {
margins: '1 1 1 1',
labelAlign: 'right',
flex: 5,
//labelWidth: 90,//label标签宽度
msgTarget: 'qtip',
sourcelabelWidth: '100' //,split:true
},
items: [
{ //1
//container_1
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{//0
fieldLabel: '人民币应收',
// allowBlank: false,
readOnly: true,
name: 'RMBYS'
}, {
fieldLabel: '人民币应付',
// allowBlank: false,
readOnly: true,
name: 'RMBYF'
}, {
fieldLabel: '人民币毛利',
// allowBlank: false,
readOnly: true,
name: 'RMBML'
}]//0
},
{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '美元应收',
// allowBlank: false,
readOnly: true,
name: 'USDYS'
}, {
fieldLabel: '美元应付',
// allowBlank: false,
readOnly: true,
name: 'USDYF'
}, {
fieldLabel: '美元毛利',
// allowBlank: false,
readOnly: true,
name: 'USDML'
}]
},
{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '毛利',
// allowBlank: false,
readOnly: true,
name: 'ML'
}]
}]//container_1 //1
}//fieldset 1
); //end this.formEdit
//#endregion
//#region 框架
this.panelYS = new Ext.Panel({
layout: "border",
region: "center",
anchor: '100% 50%',
// height: 260,
split: true,
//autoScroll: true,
items: [this.gridListChFee]
});
this.panelYF = new Ext.Panel({
layout: "border",
region: "center",
anchor: '100% 50%',
//autoScroll: true,
split: true,
items: [this.gridListChFee_YF]
});
this.panelFEE = new Ext.Panel({
layout: "anchor",
region: "center",
autoScroll: true,
split: true,
items: [this.panelYS, this.panelYF]
});
this.panelML = new Ext.Panel({
layout: "border",
region: 'south',
height: 90,
margin: '1 2',
autoScroll: true,
split: true,
items: [this.formML]
});
this.page_4 = new Ext.Panel({
id: "page_4", split: true,
layout: "border",
title: "应收应付录入",
items: [this.panelFEE, this.panelML
]
});
this.MainTab = new Ext.tab.Panel({
layout: "border",
region: "center",
autoScroll: true,
split: true,
items: [this.panelBody, this.page_4//,this.page_5
]
});
this.panelEditDetail = new Ext.Panel({
layout: "border",
region: 'center',
//autoScroll: true,
split: true,
items: [
this.formEdit,
this.gridListDetail
]
});
this.panelTop = new Ext.Panel({
layout: "border",
region: "north",
height: 280,
autoScroll: true,
split: true,
items: [this.panelBtn, this.panelEditDetail, this.panelBank]
});
Ext.apply(this, {
items: [this.panelTop, this.MainTab]
});
//#endregion
//#endregion
//绑定查询窗体
this.ParentWin = window.parent.opener;
//初始化数据
this.InitData();
//#region 绑定事件
this.gridListChFee.on('edit', function (editor, e, eOpts) {
this.gridListChFeeAfterEdit(editor, e, eOpts);
}, this);
this.gridListChFee_YF.on('edit', function (editor, e, eOpts) {
this.gridListChFeeAfterEdit(editor, e, eOpts);
}, this);
this.cellEditingChFee.on('beforeedit', function (editor, e) {
return this.cellEditingChFeeBeforeEdit(editor, e);
}, this);
this.cellEditingChFee_YF.on('beforeedit', function (editor, e) {
return this.cellEditingChFeeBeforeEdit(editor, e);
}, this);
this.gridListChFee.getSelectionModel().on('select', function (button, event) {
//Ext.getCmp("zongshu").setText("1234");
this.onSelectFee(button, event);
}, this);
this.gridListChFee_YF.getSelectionModel().on('select', function (button, event) {
//Ext.getCmp("zongshu").setText("1234");
this.onSelectFee(button, event);
}, this);
this.gridListChFee.on('cellclick', function (button, event) {
//Ext.getCmp("zongshu").setText("1234");
this.onSelectFee(button, event);
}, this);
this.gridListChFee_YF.on('cellclick', function (button, event) {
//Ext.getCmp("zongshu").setText("1234");
this.onSelectFee(button, event);
}, this);
//#endregion
}, //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') {
var F_NO = this.EditRecord.get('F_NO');
condition = " F_NO='" + F_NO + "'";
this.LoadData(this.opStatus, condition);
}
}, //end InitData
LoadData: function (opstatus, condition) {
this.serialNo = 0;
this.workSerialNo = 0;
this.bodyDel = [];
this.opStatus = opstatus;
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/Import/Finance/GetData',
async: false,
params: {
handle: opstatus,
condition: condition
},
callback: function (options, success, response) {
if (success) {
var result = Ext.JSON.decode(response.responseText);
if (!result.Success) {
Ext.Msg.show({
title: '提示',
msg: result.Message,
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.OK
});
return;
}
var data = result.data;
this.formEdit.getForm().reset();
this.formEdit.getForm().setValues(data);
this.GetEditStatus();
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
//this.SetInterest();
var F_NO = '*';
if (this.opStatus == 'edit') {
var F_NO = this.EditRecord.get('F_NO');
this.storeBodyList.load({ params: { start: 0, limit: 100, condition: " F_NO='" + F_NO + "' and F_TYPE='1'"} });
this.storeBodyListBank.load({ params: { start: 0, limit: 100, condition: " F_NO='" + F_NO + "' and F_TYPE='2'"} });
this.storeListBank.load({ params: { condition: " F_NO='" + F_NO + "'"} });
this.storeDetailList.load({ params: { condition: " c.F_NO='" + F_NO + "'"} });
this.LoadFee();
};
}, // end LoadDate
LoadFee: function () {
var F_NO = '*';
F_NO = this.EditRecord.get('F_NO');
this.storeBodyChFee.load({ params: { billno: F_NO, Feetype: '1'} });
this.storeBodyChFee_YF.load({ params: { billno: F_NO, Feetype: '2'} });
Ext.Ajax.request({
waitMsg: '正在查询毛利数据...',
url: '/Import/XXH/GetML',
params: {
contractno: F_NO
},
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.formML.getForm().setValues(data);
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
}); //request over
}, // end LoadDate
LoadIniData: function (opstatus) {
var F_NO = this.EditRecord.get('F_NO');
var condition = " F_NO='" + F_NO + "'";
this.serialNo = 0;
this.workSerialNo = 0;
this.bodyDel = [];
this.opStatus = opstatus;
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/Import/Finance/GetData',
async: false,
params: {
handle: 'edit',
condition: condition
},
callback: function (options, success, response) {
if (success) {
var result = Ext.JSON.decode(response.responseText);
if (!result.Success) {
Ext.Msg.show({
title: '提示',
msg: result.Message,
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.OK
});
return;
}
var data = result.data;
this.formEdit.getForm().reset();
this.formEdit.getForm().setValues(data);
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
}, // end LoadDate
//#region 保存
Save: function (type) {
var basicForm = this.formEdit.getForm();
if (!basicForm.isValid()) {
return;
}
var data = basicForm.getValues();
var FinanceBank = [];
for (i = 0; i < this.storeListBank.getCount(); i += 1) {
var memberyf = this.storeListBank.getAt(i);
FinanceBank.push(memberyf);
var amount = memberyf.data.AMOUNT;
var CustomerName = memberyf.data.BANK;
if (amount == 0) {
Ext.Msg.show({ title: '警告',
msg: '融资银行的金额不允许为0请修改后再保存',
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
return;
}
if (CustomerName == '') {
Ext.Msg.show({ title: '警告',
msg: '融资银行不能为空,请修改后再保存',
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
return;
}
};
//费用///////////////
var FinanceFee = [];
for (i = 0; i < this.storeBodyChFee.getCount(); i += 1) {
var memberyf = this.storeBodyChFee.getAt(i);
FinanceFee.push(memberyf);
var amount = memberyf.data.Amount;
var CustomerName = memberyf.data.CustomerName;
if (amount == 0) {
Ext.Msg.show({ title: '警告',
msg: '费用的金额不允许为0请修改后再保存',
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
return;
}
if (CustomerName == '') {
Ext.Msg.show({ title: '警告',
msg: '结算对象不能为空,请修改后再保存',
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
return;
}
};
for (i = 0; i < this.storeBodyChFee_YF.getCount(); i += 1) {
var memberyf = this.storeBodyChFee_YF.getAt(i);
FinanceFee.push(memberyf);
var amount = memberyf.data.Amount;
var CustomerName = memberyf.data.CustomerName;
if (amount == 0) {
Ext.Msg.show({ title: '警告',
msg: '费用的金额不允许为0请修改后再保存',
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
return;
}
if (CustomerName == '') {
Ext.Msg.show({ title: '警告',
msg: '结算对象不能为空,请修改后再保存',
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
return;
}
};
var jsonFinanceFee = ConvertRecordsToJson(FinanceFee);
var jsonFinanceBank = ConvertRecordsToJsonAll(FinanceBank);
///////////////
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/Import/Finance/Save',
scope: this,
params: {
opstatus: this.opStatus,
data: Ext.JSON.encode(data),
FinanceFee: jsonFinanceFee,
FinanceBank: jsonFinanceBank
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
var returnData = jsonresult.Data;
this.formEdit.getForm().setValues(returnData);
if (this.opStatus == 'add') {
var arrNewRecords = this.StoreList.add(returnData);
this.EditRecord = arrNewRecords[0];
}
else if (this.opStatus == 'edit') {
this.EditRecord.commit();
}
if (type == '0') {
this.opStatus = 'edit';
for (var j = 0; j < this.storeListBank.getCount(); j += 1) {
var memberbody = this.storeListBank.getAt(j);
memberbody.set("F_NO", this.EditRecord.get('F_NO'));
memberbody.commit();
};
for (var j = 0; j < this.storeBodyChFee.getCount(); j += 1) {
var memberbody = this.storeBodyChFee.getAt(j);
memberbody.commit();
};
for (var j = 0; j < this.storeBodyChFee_YF.getCount(); j += 1) {
var memberbody = this.storeBodyChFee_YF.getAt(j);
memberbody.commit();
};
this.GetEditStatus();
} 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
//#endregion
FinanceWin: function () {
var upform = Ext.create('Ext.form.Panel', {
width: 500,
bodyPadding: '6 6 6 6',
id: "upform",
defaults: {
anchor: '100%',
allowBlank: false,
msgTarget: 'side',
labelWidth: 100
},
items: [{
fieldLabel: '融资汇率',
xtype: "numberfield",
name: 'F_Rate',
id:'F_Rate',
value: 0.00,
selectOnFocus: true,
allowDecimals: true,
decimalPrecision: 6,
listeners: {
blur: function (obj) {
var val = parseFloat(obj.value) * parseFloat(_this.formEdit.getForm().findField('F_AMOUNT').getValue());
Ext.getCmp("F_RMB").setValue(val);
_this.formEdit.getForm().findField('F_Rate').setValue(obj.value);
_this.formEdit.getForm().findField('F_RMB').setValue(val);
}
}
}, {
fieldLabel: '折合人民币金额',
xtype: "numberfield",
name: 'F_RMB',
id:'F_RMB',
value: 0.00,
selectOnFocus: true,
allowDecimals: true,
decimalPrecision: 2
}],
buttons: [{
text: '确定',
handler: function () {
_this.AuditFinancel();
Ext.getCmp("importWin").close();
}
}, {
text: '取消',
handler: function () {
Ext.getCmp("importWin").close();
}
}]
});
var win = Ext.create('Ext.window.Window',
{
title: '信息',
layout: 'fit',
id: 'importWin',
draggable: true, //拖动
x: event.clientX,
y: event.clientY,
resizable: false,
items: {
xtype: 'panel',
border: true,
items: [upform]
}
});
win.show();
},
//#region 确认融资
AuditFinancel: function () {
var basicForm = this.formEdit.getForm();
var F_STATUS = basicForm.findField('F_STATUS').getValue();
if (F_STATUS != '提交融资') {
Ext.Msg.show({ title: '警告', msg: '当前状态不允许确认融资!', icon: Ext.Msg.WARNING, buttons: Ext.Msg.OK });
return;
}
var CUSTOMER = basicForm.findField('CUSTOMER').getValue();
if (CUSTOMER == '') {
Ext.Msg.show({ title: '警告', msg: '融资客户不能为空!', icon: Ext.Msg.WARNING, buttons: Ext.Msg.OK });
return;
}
var F_CURRENCY = basicForm.findField('F_CURRENCY').getValue();
if (F_CURRENCY == '') {
Ext.Msg.show({ title: '警告', msg: '融资币别不能为空!', icon: Ext.Msg.WARNING, buttons: Ext.Msg.OK });
return;
}
var F_AMOUNT = basicForm.findField('F_AMOUNT').getValue();
if (F_AMOUNT == '' || F_AMOUNT == 0) {
Ext.Msg.show({ title: '警告', msg: '融资金额不能为0!', icon: Ext.Msg.WARNING, buttons: Ext.Msg.OK });
return;
}
if (!basicForm.isValid()) {
return;
}
var data = basicForm.getValues();
var FinanceBank = [];
for (i = 0; i < this.storeListBank.getCount(); i += 1) {
var memberyf = this.storeListBank.getAt(i);
FinanceBank.push(memberyf);
var amount = memberyf.data.AMOUNT;
var CustomerName = memberyf.data.BANK;
if (amount == 0) {
Ext.Msg.show({ title: '警告',
msg: '融资银行的金额不允许为0请修改后再保存',
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
return;
}
if (CustomerName == '') {
Ext.Msg.show({ title: '警告',
msg: '融资银行不能为空,请修改后再保存',
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
return;
}
};
//费用///////////////
var FinanceFee = [];
for (i = 0; i < this.storeBodyChFee.getCount(); i += 1) {
var memberyf = this.storeBodyChFee.getAt(i);
FinanceFee.push(memberyf);
var amount = memberyf.data.Amount;
var CustomerName = memberyf.data.CustomerName;
if (amount == 0) {
Ext.Msg.show({ title: '警告',
msg: '费用的金额不允许为0请修改后再保存',
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
return;
}
if (CustomerName == '') {
Ext.Msg.show({ title: '警告',
msg: '结算对象不能为空,请修改后再保存',
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
return;
}
};
for (i = 0; i < this.storeBodyChFee_YF.getCount(); i += 1) {
var memberyf = this.storeBodyChFee_YF.getAt(i);
FinanceFee.push(memberyf);
var amount = memberyf.data.Amount;
var CustomerName = memberyf.data.CustomerName;
if (amount == 0) {
Ext.Msg.show({ title: '警告',
msg: '费用的金额不允许为0请修改后再保存',
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
return;
}
if (CustomerName == '') {
Ext.Msg.show({ title: '警告',
msg: '结算对象不能为空,请修改后再保存',
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
return;
}
};
////将客户未还金额计算出来
////
var jsonFinanceFee = ConvertRecordsToJson(FinanceFee);
var jsonFinanceBank = ConvertRecordsToJsonAll(FinanceBank);
///////////////
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/Import/Finance/AuditSave',
scope: this,
params: {
opstatus: this.opStatus,
data: Ext.JSON.encode(data),
FinanceFee: jsonFinanceFee,
FinanceBank: jsonFinanceBank
},
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);
var editp = Ext.create('Financemb', 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';
F_NO = this.EditRecord.get('F_NO');
this.LoadFee();
this.GetEditStatus();
for (var j = 0; j < this.storeListBank.getCount(); j += 1) {
var memberbody = this.storeListBank.getAt(j);
memberbody.set("F_NO", this.EditRecord.get('F_NO'));
memberbody.commit();
};
for (var j = 0; j < this.storeBodyChFee.getCount(); j += 1) {
var memberbody = this.storeBodyChFee.getAt(j);
memberbody.commit();
};
for (var j = 0; j < this.storeBodyChFee_YF.getCount(); j += 1) {
var memberbody = this.storeBodyChFee_YF.getAt(j);
memberbody.commit();
};
} 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
//#endregion
//#region 取消融资
CancelFinancel: function () {
var basicForm = this.formEdit.getForm();
var F_STATUS = basicForm.findField('F_STATUS').getValue();
if (F_STATUS != '已融出') {
Ext.Msg.show({ title: '警告', msg: '当前状态不允许取消融资!', icon: Ext.Msg.WARNING, buttons: Ext.Msg.OK });
return;
}
var Duino = this.formEdit.getForm().findField('F_NO').getValue();
if (!basicForm.isValid()) {
return;
}
var data = basicForm.getValues();
Ext.Ajax.request({
waitMsg: '正在添加数据...',
url: '/Import/Finance/SubmitAudit',
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: '/Import/Finance/GetData',
params: {
handle: 'edit',
condition: " F_NO='" + 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;
_this.formEdit.getForm().reset();
_this.formEdit.getForm().setValues(data);
var editp = Ext.create('Financemb', 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();
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
}
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
}, //end save
//#endregion
//#region 银行操作
onAddBankClick: function (button, event) {
var basicForm = this.formEdit.getForm();
var F_STATUS = basicForm.findField('F_STATUS').getValue();
if (F_STATUS != '提交融资') {
Ext.Msg.show({ title: '警告', msg: '只有《提交融资》状态才能添加还款记录!', icon: Ext.Msg.WARNING, buttons: Ext.Msg.OK });
return;
}
var F_AMOUNT = basicForm.findField('F_AMOUNT').getValue();
var record = null;
record = Ext.create('FinanceBank', {
GID: NewGuid(),
F_NO: '*',
BANK: '',
AMOUNT: F_AMOUNT,
DOAMOUNT: 0
});
this.storeListBank.add(record);
var editColumnIndex = 0;
var cellediting = null;
cellediting = this.cellEditingBank;
editColumnIndex = 3;
var n = this.storeListBank.getCount();
cellediting.startEditByPosition({ row: n - 1, column: editColumnIndex });
},
onDelBankClick: function (button, event, type) {
var basicForm = this.formEdit.getForm();
var F_NO = basicForm.findField('F_NO').getValue();
var feeGidSql = '';
var selectedRecords = [];
selectedRecords = this.BankGridCheckBoxModel.selected.items;
if (selectedRecords.length == 0) {
Ext.Msg.show({ title: '提示', msg: '请先选择要删除的记录!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
Ext.MessageBox.confirm('提示', '确定要删除选中的记录吗?', function (btn) {
if (btn == 'yes') {
if (selectedRecords.length > 0) {
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
if (rec.data.F_NO == "*") //如果是新增但没有保存的数据,没有必要提交到后台
{
this.storeListBank.remove(selectedRecords[i]);
} else {
var feeGId = "'" + rec.data.GID + "'";
if (feeGidSql == '') {
feeGidSql = feeGId;
} else {
feeGidSql = feeGidSql + "," + feeGId;
}
}
}
}
_thisfee = this;
Ext.Msg.wait('正在删除数据...');
if (feeGidSql != '') {
Ext.Ajax.request({
waitMsg: '正在删除数据...',
url: '/Import/Finance/DeleteBank',
params: {
F_NO: F_NO,
data: feeGidSql
},
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
for (var i = 0; i < selectedRecords.length; i++) {
this.storeListBank.remove(selectedRecords[i]);
}
Ext.Msg.show({ title: '提示', msg: jsonresult.Message, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
}
else {
Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
}
}
},
failure: function (response, options) {
Ext.Msg.show({ title: '警告', msg: '服务器响应出错,请重试', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
},
success: function (response, options) {
},
scope: this
}); //end Ext.Ajax.request
} else {
Ext.Msg.show({ title: '提示', msg: "删除成功!", icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
}
}
}, this);
},
//#endregion
//#region 还款记录操作
onAddBodyClick: function (button, event, type) {
var basicForm = this.formEdit.getForm();
var F_STATUS = basicForm.findField('F_STATUS').getValue();
var F_NO = basicForm.findField('F_NO').getValue();
if (F_STATUS != '已融出') {
Ext.Msg.show({ title: '警告', msg: '只有《已融出》状态才能添加还款记录!', icon: Ext.Msg.WARNING, buttons: Ext.Msg.OK });
return;
}
var store = null;
if (type == 1) {
store = this.storeBodyList;
} else if (type == 2) {
store = this.storeBodyListBank;
} else {
alert('函数(onAddDetailClick)的参数type类型设置的不对');
return;
}
var custtype = '';
var CUSTOMER = '';
var BANKID = '';
var R_AMOUNT = 0;
var CUSTNO = '';
var BSNO = '';
var myDate = new Date();
var mydatestr = Ext.util.Format.date(myDate, 'Y-m-d');
if (type == 1) {
custtype = 'CUSTOMER'
CUSTOMER = basicForm.findField(custtype).getValue();
if (CUSTOMER == '') {
Ext.Msg.show({ title: '警告', msg: '融资客户不能为空!', icon: Ext.Msg.WARNING, buttons: Ext.Msg.OK });
return;
}
}
else {
if (this.storeListBank.getCount() > 0) {
var member = this.storeListBank.getAt(0);
CUSTOMER = member.data.BANK;
BANKID = member.data.GID;
R_AMOUNT = member.data.AMOUNT;
}
if (this.storeBodyList.getCount() > 0) {
var member = this.storeBodyList.getAt(0);
var ENDDATE = Ext.util.Format.date(member.data.ENDDATE, 'Y-m-d');
if (ENDDATE != '') {
mydatestr = ENDDATE;
}
}
custtype = 'FINANCE_BANK';
}
var F_CURRENCY = basicForm.findField('F_CURRENCY').getValue();
//var F_AMOUNT = basicForm.findField('F_AMOUNT').getValue();
var STARTDATE = basicForm.findField('STARTDATE').getRawValue();
//gridBodyList
// if (type == 1) {
var BodyRecords = this.gridListDetail.selModel.getSelection();
var rec = BodyRecords[0];
if (rec == null) {
Ext.Msg.show({ title: '提示', msg: '请先选择合同', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
R_AMOUNT = rec.data.R_AMOUNT;
CUSTNO = rec.data.HTH;
BSNO = rec.data.CONTRACTNO;
// }
var newSerialno = this.GetHandleSerialNo(store);
var newsort = store.getCount() + 1;
var days = Add(getDays(STARTDATE, mydatestr), 1, 0);
var record = null;
if (type == 1) {
record = Ext.create('FinanceBodymb', {
GID: NewGuid(),
F_NO: '*',
F_CURRENCY: F_CURRENCY,
ISFEE: '0',
F_TYPE: type,
CUSTOMER: CUSTOMER,
BANKID: BANKID,
F_AMOUNT: R_AMOUNT,
ENDDATE: mydatestr,
DAYS: days,
EXCHANGERATE: 1,
INTEREST_RATE: 0,
Y_INTEREST_RATE: 0,
INTEREST: 0,
INTERESTUSD: 0,
RMBVALUE: 0,
HANDFEE: 0,
TELXFEE: 0,
OTFEE: 0,
RMBAMOUNT: 0,
FINEFEE: 0,
TTLAMOUNTRMB: 0,
REMARK: '',
BSNO: BSNO,
CUSTNO: CUSTNO
});
} else {
record = Ext.create('FinanceBodymb', {
GID: NewGuid(),
F_NO: '*',
F_CURRENCY: F_CURRENCY,
ISFEE: '0',
F_TYPE: type,
CUSTOMER: CUSTOMER,
BANKID: BANKID,
F_AMOUNT: R_AMOUNT,
ENDDATE: mydatestr,
DAYS: days,
EXCHANGERATE: 1,
D_INTEREST_RATE: 0,
INTEREST_RATE: 0,
Y_INTEREST_RATE: 0,
INTEREST: 0,
INTERESTUSD: 0,
RMBVALUE: 0,
HANDFEE: 0,
TELXFEE: 0,
OTFEE: 0,
RMBAMOUNT: 0,
FINEFEE: 0,
TTLAMOUNTRMB: 0,
REMARK: '',
BSNO: BSNO,
CUSTNO: CUSTNO
});
}
//触发计算
var days = record.data['DAYS'];
var F_AMOUNT = record.data['F_AMOUNT'];
var INTEREST_RATE = record.data['INTEREST_RATE'];
var EXCHANGERATE = record.data['EXCHANGERATE'];
var D_INTEREST_RATE = record.data['D_INTEREST_RATE'];
var Y_INTEREST_RATE = record.data['Y_INTEREST_RATE'];
var rmbvalue = Mul(F_AMOUNT, EXCHANGERATE);
record.set('RMBVALUE', rmbvalue);
var handfee = record.data['HANDFEE'];
var texfee = record.data['TELXFEE'];
var otherfee = record.data['OTFEE'];
var rmbamount = 0;
if (rmbvalue != 0)
rmbamount = Add(rmbvalue, Add(handfee, Add(texfee, otherfee)));
record.set('RMBAMOUNT', rmbamount);
var INTEREST = 0;
if (INTEREST_RATE == 0 && Y_INTEREST_RATE == 0)//日利率不等于0
INTEREST = this.calcDINTEREST(rmbamount, days, D_INTEREST_RATE);
else if (INTEREST_RATE !== 0)//月利率不等于0
INTEREST = this.calcINTEREST(rmbamount, days, INTEREST_RATE);
else
INTEREST = this.calcYINTEREST(rmbamount, days, Y_INTEREST_RATE);
record.set('INTEREST', INTEREST);
var finefee = record.data['FINEFEE'];
var ttlamountrmb = Add(rmbamount, Add(INTEREST, finefee));
record.set('TTLAMOUNTRMB', ttlamountrmb);
var INTERESTUSD = this.calcINTEREST(F_AMOUNT, days, INTEREST_RATE);
record.set('INTERESTUSD', INTERESTUSD);
//end
store.add(record);
var editColumnIndex = 0;
var cellediting = null;
if (type == 1) {
cellediting = this.cellEditingBodyGrid;
editColumnIndex = 3;
} else if (type == 2) {
cellediting = this.cellEditingBodyGridBody;
editColumnIndex = 3;
}
var n = store.getCount();
cellediting.startEditByPosition({ row: n - 1, column: editColumnIndex });
},
onPostBodyClick: function (button, event, type) {
var basicForm = this.formEdit.getForm();
var F_NO = basicForm.findField('F_NO').getValue();
var bodyDrChFeeDatas = [];
var i;
if (type == '1') {
for (i = 0; i < this.storeBodyList.getCount(); i += 1) {
var memberyf = this.storeBodyList.getAt(i);
bodyDrChFeeDatas.push(memberyf);
};
var jsonChFeeBody = ConvertRecordsToJsonAll(bodyDrChFeeDatas);
} else if (type == '2') {
for (i = 0; i < this.storeBodyListBank.getCount(); i += 1) {
var memberyf = this.storeBodyListBank.getAt(i);
bodyDrChFeeDatas.push(memberyf);
};
var jsonChFeeBody = ConvertRecordsToJsonAll(bodyDrChFeeDatas);
};
_thisfee = this;
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/Import/Finance/SaveBody',
scope: this,
params: {
F_NO: F_NO,
body: jsonChFeeBody
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
if (type == '1') {
for (var i = 0; i < this.storeBodyList.getCount(); i += 1) {
var member = this.storeBodyList.getAt(i);
member.set("F_NO", F_NO);
member.commit();
}
} else if (type == '2') {
for (var i = 0; i < this.storeBodyListBank.getCount(); i += 1) {
var member = this.storeBodyListBank.getAt(i);
member.set("F_NO", F_NO);
member.commit();
}
}
this.LoadIniData(_thisfee.OpStatus);
this.storeListBank.load({ params: { condition: " F_NO='" + F_NO + "'" } });
} 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
onDelBodyClick: function (button, event, type) {
var basicForm = this.formEdit.getForm();
var F_NO = basicForm.findField('F_NO').getValue();
var feeGidSql = '';
var selectedRecords = [];
if (type == '1') {
selectedRecords = this.BodyGridCheckBoxModel.selected.items;
} else if (type == '2') {
selectedRecords = this.BodyBankGridCheckBoxModel.selected.items;
}
if (selectedRecords.length == 0) {
Ext.Msg.show({ title: '提示', msg: '请先选择要删除的记录!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
Ext.MessageBox.confirm('提示', '确定要删除选中的记录吗?', function (btn) {
if (btn == 'yes') {
if (selectedRecords.length > 0) {
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
if (rec.data.F_NO == "*") //如果是新增但没有保存的数据,没有必要提交到后台
{
if (type == '1') {
this.storeBodyList.remove(selectedRecords[i]);
} else if (type == '2') {
this.storeBodyListBank.remove(selectedRecords[i]);
}
} else {
var feeGId = "'" + rec.data.GID + "'";
if (feeGidSql == '') {
feeGidSql = feeGId;
} else {
feeGidSql = feeGidSql + "," + feeGId;
}
}
}
}
_thisfee = this;
Ext.Msg.wait('正在删除数据...');
if (feeGidSql != '') {
Ext.Ajax.request({
waitMsg: '正在删除数据...',
url: '/Import/Finance/DeleteBody',
params: {
F_NO: F_NO,
data: feeGidSql
},
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
for (var i = 0; i < selectedRecords.length; i++) {
if (type == '1') {
this.storeBodyList.remove(selectedRecords[i]);
} else if (type == '2') {
this.storeBodyListBank.remove(selectedRecords[i]);
}
}
this.LoadIniData(_thisfee.OpStatus);
Ext.Msg.show({ title: '提示', msg: jsonresult.Message, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
}
else {
Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
}
}
},
failure: function (response, options) {
Ext.Msg.show({ title: '警告', msg: '服务器响应出错,请重试', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
},
success: function (response, options) {
},
scope: this
}); //end Ext.Ajax.request
} else {
Ext.Msg.show({ title: '提示', msg: "删除成功!", icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
}
}
}, this);
},
onCreateBodyFeeClick: function (button, event, type) {
var basicForm = this.formEdit.getForm();
var F_NO = basicForm.findField('F_NO').getValue();
var bodyDrChFeeDatas = [];
var i;
var selectedRecords = [];
if (type == '1') {
selectedRecords =[].concat(this.BodyGridCheckBoxModel.selected.items);
} else if (type == '2') {
selectedRecords = [].concat(this.BodyBankGridCheckBoxModel.selected.items);
}
var basicForm = this.formEdit.getForm();
var startdate = basicForm.findField('STARTDATE').getRawValue();
for (i = 0; i < selectedRecords.length; i++) {
var memberyf = selectedRecords[i];
var enddate = Ext.util.Format.date(memberyf.data.ENDDATE, 'Y-m-d');
if (memberyf.data.ISFEE != "1") {
memberyf.data.REMARK =
"计息日期:" + startdate + " - " + enddate + ",计息天数: " + memberyf.data.DAYS;
bodyDrChFeeDatas.push(memberyf);
}
};
var jsonChFeeBody = ConvertRecordsToJsonAll(bodyDrChFeeDatas);
if (jsonChFeeBody == "") {
Ext.Msg.show({ title: '提示', msg: '没有要生成费用的记录!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
_thisfee = this;
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/Import/Finance/CreateBodyFee',
scope: this,
params: {
F_NO: F_NO,
body: jsonChFeeBody
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
this.LoadFee();
var F_NO = this.EditRecord.get('F_NO');
condition = " F_NO='" + F_NO + "'";
this.storeBodyList.load({ params: { start: 0, limit: 100, condition: " F_NO='" + F_NO + "' and F_TYPE='1'"} });
this.storeBodyListBank.load({ params: { start: 0, limit: 100, condition: " F_NO='" + F_NO + "' and F_TYPE='2'"} });
this.LoadIniData(_thisfee.OpStatus);
} 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
gridListBodyAfterEdit: function (editor, e, eOpts) {
if (e.value == e.originalValue) return;
//var BSNO = e.record.get('BSNO');
if (e.field == 'CUSTOMER') {
var F_TYPE = e.record.data['F_TYPE'];
if (F_TYPE == 2) {
var Cargoinforecords = DsStoreQueryBy(this.storeListBank, 'BANK', e.value);
if (Cargoinforecords.getCount() > 0) {
var Cargoinfodata = Cargoinforecords.getAt(0).data;
e.record.set('F_AMOUNT', Cargoinfodata.F_AMOUNT);
e.record.set('BANKID', Cargoinfodata.GID);
}
}
} else if (e.field == 'ENDDATE') {
var basicForm = this.formEdit.getForm();
var STARTDATE = basicForm.findField('STARTDATE').getRawValue();
if (e.value == "")
var days = 0;
else {
var _enddate = new Date(e.value);
var enddate = Ext.util.Format.date(_enddate, 'Y-m-d')
var days = Add(getDays(STARTDATE, enddate), 1, 0);
}
e.record.set('DAYS', days);
var F_AMOUNT = e.record.data['F_AMOUNT'];
var INTEREST_RATE = e.record.data['INTEREST_RATE'];
var D_INTEREST_RATE = e.record.data['D_INTEREST_RATE'];
var Y_INTEREST_RATE = e.record.data['Y_INTEREST_RATE'];
var EXCHANGERATE = e.record.data['EXCHANGERATE'];
var rmbvalue = Mul(F_AMOUNT, EXCHANGERATE);
e.record.set('RMBVALUE', rmbvalue);
var handfee = e.record.data['HANDFEE'];
var texfee = e.record.data['TELXFEE'];
var otherfee = e.record.data['OTFEE'];
var rmbamount = 0;
if (rmbvalue != 0)
rmbamount = Add(rmbvalue, Add(handfee, Add(texfee, otherfee)));
e.record.set('RMBAMOUNT', rmbamount);
var INTEREST = 0;
if (INTEREST_RATE == 0 && Y_INTEREST_RATE == 0)//日利率不等于0
INTEREST = this.calcDINTEREST(rmbamount, days, D_INTEREST_RATE);
else if(INTEREST_RATE !== 0)//月利率不等于0
INTEREST = this.calcINTEREST(rmbamount, days, INTEREST_RATE);
else
INTEREST = this.calcYINTEREST(rmbamount, days, Y_INTEREST_RATE);
e.record.set('INTEREST', INTEREST);
var finefee = e.record.data['FINEFEE'];
var ttlamountrmb = Add(rmbamount, Add(INTEREST, finefee));
e.record.set('TTLAMOUNTRMB', ttlamountrmb);
}
else if (e.field == 'F_AMOUNT' || e.field == 'INTEREST_RATE' || e.field == 'D_INTEREST_RATE' || e.field == 'Y_INTEREST_RATE' || e.field == 'DAYS' || e.field == 'EXCHANGERATE') {
var days = e.record.data['DAYS'];
var F_AMOUNT = e.record.data['F_AMOUNT'];
var INTEREST_RATE = e.record.data['INTEREST_RATE'];
var EXCHANGERATE = e.record.data['EXCHANGERATE'];
var D_INTEREST_RATE = e.record.data['D_INTEREST_RATE'];
var Y_INTEREST_RATE = e.record.data['Y_INTEREST_RATE'];
var rmbvalue = Mul(F_AMOUNT, EXCHANGERATE);
e.record.set('RMBVALUE', rmbvalue);
var handfee = e.record.data['HANDFEE'];
var texfee = e.record.data['TELXFEE'];
var otherfee = e.record.data['OTFEE'];
var rmbamount = 0;
if (rmbvalue != 0)
rmbamount = Add(rmbvalue, Add(handfee, Add(texfee, otherfee)));
e.record.set('RMBAMOUNT', rmbamount);
var INTEREST = 0;
if (INTEREST_RATE == 0 && Y_INTEREST_RATE == 0)//日利率不等于0
INTEREST = this.calcDINTEREST(rmbamount, days, D_INTEREST_RATE);
else if (INTEREST_RATE !== 0)//月利率不等于0
INTEREST = this.calcINTEREST(rmbamount, days, INTEREST_RATE);
else
INTEREST = this.calcYINTEREST(rmbamount, days, Y_INTEREST_RATE);
e.record.set('INTEREST', INTEREST);
var finefee = e.record.data['FINEFEE'];
var ttlamountrmb = Add(rmbamount, Add(INTEREST, finefee));
e.record.set('TTLAMOUNTRMB', ttlamountrmb);
var INTERESTUSD = this.calcINTEREST(F_AMOUNT, days, INTEREST_RATE);
e.record.set('INTERESTUSD', INTERESTUSD);
}
else if (e.field == 'HANDFEE' || e.field == 'OTFEE' || e.field == 'TELXFEE' || e.field == 'RMBVALUE') {
var days = e.record.data['DAYS'];
var F_AMOUNT = e.record.data['F_AMOUNT'];
var INTEREST_RATE = e.record.data['INTEREST_RATE'];
var D_INTEREST_RATE = e.record.data['D_INTEREST_RATE'];
var Y_INTEREST_RATE = e.record.data['Y_INTEREST_RATE'];
var rmbvalue = e.record.data['RMBVALUE'];
var texfee = e.record.data['TELXFEE'];
var handfee = e.record.data['HANDFEE'];
var otherfee = e.record.data['OTFEE'];
var rmbamount = 0;
if (rmbvalue != 0)
rmbamount = Add(rmbvalue, Add(handfee, Add(texfee, otherfee)));
e.record.set('RMBAMOUNT', rmbamount);
var INTEREST = 0;
if (INTEREST_RATE == 0 && Y_INTEREST_RATE == 0)//日利率不等于0
INTEREST = this.calcDINTEREST(rmbamount, days, D_INTEREST_RATE);
else if (INTEREST_RATE !== 0)//月利率不等于0
INTEREST = this.calcINTEREST(rmbamount, days, INTEREST_RATE);
else
INTEREST = this.calcYINTEREST(rmbamount, days, Y_INTEREST_RATE);
e.record.set('INTEREST', INTEREST);
var finefee = e.record.data['FINEFEE'];
var ttlamountrmb = Add(rmbamount, Add(INTEREST, finefee));
e.record.set('TTLAMOUNTRMB', ttlamountrmb);
} else if (e.field == 'RMBAMOUNT' || e.field == 'INTEREST' || e.field == 'FINEFEE') {
var rmbamount = e.record.data['RMBAMOUNT'];
var INTEREST = e.record.data['INTEREST'];
var finefee = e.record.data['FINEFEE'];
var ttlamountrmb = Add(rmbamount, Add(INTEREST, finefee));
e.record.set('TTLAMOUNTRMB', ttlamountrmb);
}
},
calcDINTEREST: function (amount, days, interrestrate) {//公式:日利率*还款金额/10000*天数
var BodyRecords = this.gridListDetail.selModel.getSelection();
var rec1 = BodyRecords[0];
if (rec1 == null) {
Ext.Msg.show({ title: '提示', msg: '请先选择合同', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
var result = 0;
Ext.Ajax.request({
url: '/Import/Finance/GetRmModel',
params: {
name: this.gridListDetail.selModel.getSelection()[0].data.BUYER
},
async: false,
callback: function (options, success, response) {
try {
var data = eval(response.responseText);
var rateDaysArr = [];
for (var i = 0; i < data.length; i++) {
if (data[i].ExtendedDays <= days) { //超期天数小于等于计息天数
if (rateDaysArr.length > 0)
rateDaysArr.push(data[i].ExtendedDays - data[i - 1].ExtendedDays);
else
rateDaysArr.push(data[i].ExtendedDays);
result += Div(Mul(Mul(amount, data[i].Rate), rateDaysArr[i]), 10000);
} else {//超期天数大于计息天数
if (rateDaysArr.length > 0)
rateDaysArr.push(days - data[i - 1].ExtendedDays);
else
rateDaysArr.push(days);
result += Div(Mul(Mul(amount, data[i].Rate), rateDaysArr[i]), 10000);
break;
}
}
rateDaysArr.forEach(function(item,index) {
days -= item;
});
if (days > 0)
result += Div(Mul(Mul(amount, interrestrate), days), 10000);
} catch (e) { }
},
scope: this
});
return result;
},
calcINTEREST: function (amount, days, interrestrate) {
var result = 0;
result = Mul(amount, interrestrate);
result = Mul(result, days);
result = Div(result, 30);
return result;
},
calcYINTEREST: function (amount, days, interrestrate) {
var result = 0;
result = Mul(amount, interrestrate);
result = Mul(result, days);
result = Div(result, 360);
return result;
},
//#endregion
// 明细表 <<<<<<<<<<<<<费用表相关方法
cellEditingChFeeBeforeEdit: function (editor, e) {
var chfeefeeStatus = e.record.get('FeeStatus');
var canedit = chfeefeeStatus == 1 || chfeefeeStatus == 6;
// if (canedit == true) {
// var type = e.record.get('FeeType');
// var op = e.record.get('EnteroPerator');
// var opname = e.record.get('OpName');
// if (type == 1) {
// var records = DsStoreQueryBy(this.StoreDrOpRange, 'OPID', op);
// if (records.getCount() > 0) {
// } else {
// Ext.Msg.show({ title: '提示', msg: '你没有权限修改' + opname + '录入的费用!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
// canedit = false;
// }
// } else if (type == 2) {
// var records = DsStoreQueryBy(this.StoreCrOpRange, 'OPID', op);
// if (records.getCount() > 0) {
// } else {
// Ext.Msg.show({ title: '提示', msg: '你没有权限修改' + opname + '录入的费用!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
// canedit = false;
// }
// }
// }
return canedit;
},
//#region 费用处理
onAddDetailClick: function (button, event, type) {
var allow = this.getAllowOperationDetail();
if (allow == false) {
return;
}
var store = null;
if (type == 1) {
store = this.storeBodyChFee;
} else if (type == 2) {
store = this.storeBodyChFee_YF;
} else {
alert('函数(onAddDetailClick)的参数type类型设置的不对');
return;
}
var newSerialno = this.GetHandleSerialNo(store, type);
var record = null;
function GetDateStr(AddDayCount) {
var dd = new Date();
dd.setDate(dd.getDate() + AddDayCount); //获取AddDayCount天后的日期
var y = dd.getFullYear();
var m = dd.getMonth() + 1; //获取当前月份的日期
var d = dd.getDate();
return y + "-" + m + "-" + d;
}
var EnterDate = GetDateStr(0);
record = Ext.create('MsChFee', {
GId: NewGuid(),
BsNo: '*',
FeeStatus: 1,
FeeStatus_Ref: '录入状态',
FeeType: type,
FeeType_Ref: '',
FeeName: '',
FeeName_Ref: '',
FeeDescription: '',
CustomerType: '',
CustomerName: this.getCustName(),
CustomerName_Ref: '',
Unit: '',
UnitPrice: 0,
Quantity: 1,
Amount: 0,
Currency: 'RMB',
ExChangerate: 1,
Reason: '',
Remark: '',
Commissionrate: 0,
Settlement: 0,
Invoice: 0,
OrderAmount: 0,
OrderInvoice: 0,
SubmitDate: null,
Auditoperator: '',
AuditDate: null,
EnteroPerator: USERID,
EnterDate: EnterDate,
DebitNo: '',
IsDebit: "0",
IsOpen: "0",
IsAdvancedpay: "0",
Sort: "0",
IsInvoice: "0",
FeeFrt: 'pp',
IsCrmOrderFee: "0",
AuditStatus: 0,
InvoiceNum: '',
ChequeNum: '',
WmsOutBsNo: ''
});
store.add(record);
var editColumnIndex = 0;
var cellediting = null;
if (type == 1) {
cellediting = this.cellEditingChFee;
editColumnIndex = 2;
} else if (type == 2) {
cellediting = this.cellEditingChFee_YF;
editColumnIndex = 4;
}
var n = store.getCount();
cellediting.startEditByPosition({ row: n - 1, column: editColumnIndex });
},
GetHandleSerialNo: function (store, type) {
var result = 0;
if (type == 1) {
result = this.fixSerialNo;
} else if (type == 2) {
result = this.feeSerialNo;
}
if (result == 0) {
for (var i = 0; i < store.getCount(); i += 1) {
var member = store.getAt(i);
if (member.data.SerialNo > result) {
result = member.data.SerialNo;
}
}
}
result = result + 1;
if (type == 1) {
this.fixSerialNo = result;
} else if (type == 2) {
this.feeSerialNo = result;
}
return result;
},
onDelDetailClick: function (button, event, type) {
var allow = this.getAllowOperationDetail();
if (allow == false) {
return;
}
var store = null;
if (type == 1) {
store = this.storeBodyChFee;
} else if (type == 2) {
store = this.storeBodyChFee_YF;
} else {
alert('函数(onAddDetailClick)的参数type类型设置的不对');
return;
}
var result = 0;
if (type == '1') {
result = this.feeSerialNo;
} else if (type == '2') {
result = this.feeSerialNo;
}
if (result == 0) {
for (var i = 0; i < store.getCount(); i += 1) {
var member = store.getAt(i);
if (member.data.SerialNo > this.giSerialNo) {
result = member.data.SerialNo;
}
}
}
if (type == '1') {
this.feeSerialNo = result;
} else if (type == '2') {
this.feeSerialNo = result;
}
var selectedRecords = [];
if (type == '1') {
selectedRecords = this.gridListChFee.selModel.getSelection();
var candelete = DsTruck.CheckChFeeDelete(selectedRecords, this.StoreDrOpRange);
if (candelete == false)
return;
} else if (type == '2') {
selectedRecords = this.gridListChFee_YF.selModel.getSelection();
var candelete = DsTruck.CheckChFeeDelete(selectedRecords, this.StoreCrOpRange);
if (candelete == false)
return;
}
var basicForm = this.formEdit.getForm();
var F_NO = basicForm.findField('F_NO').getValue();
Ext.MessageBox.confirm('提示', '确定要删除选中的费用吗?', function (btn) {
if (btn == 'yes') {
var feeGidSql = "";
if (selectedRecords.length > 0) {
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
if (rec.BsNo == "" || rec.BsNo == "*") //如果是新增但没有保存的数据,没有必要提交到后台
{
if (type == '1') {
this.storeBodyChFee.remove(selectedRecords[i]);
} else if (type == '2') {
this.storeBodyChFee_YF.remove(selectedRecords[i]);
}
} else {
var feeGId = "'" + rec.data.GId + "'";
if (feeGidSql == '') {
feeGidSql = feeGId;
} else {
feeGidSql = feeGidSql + "," + feeGId;
}
}
}
}
_thisfee = this;
Ext.Msg.wait('正在删除数据...');
if (feeGidSql != '') {
Ext.Ajax.request({
waitMsg: '正在删除数据...',
url: '/MvcShipping/MsChFee/Delete',
params: {
bsno: F_NO,
data: feeGidSql
},
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
for (var i = 0; i < selectedRecords.length; i++) {
if (type == '1') {
this.storeBodyChFee.remove(selectedRecords[i]);
} else if (type == '2') {
this.storeBodyChFee_YF.remove(selectedRecords[i]);
}
}
Ext.Msg.show({ title: '提示', msg: jsonresult.Message, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
}
else {
Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
}
}
},
failure: function (response, options) {
Ext.Msg.show({ title: '警告', msg: '服务器响应出错,请重试', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
},
success: function (response, options) {
},
scope: this
}); //end Ext.Ajax.request
} else {
Ext.Msg.show({ title: '提示', msg: "删除成功!", icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
}
}
}, this);
},
onSubmitAuditClick: function (button, event, type) {
if (type == '1') {
var records = this.feeGridCheckBoxModel.selected.items;
DsTruck.MsChFeeAudit(records, 2, '正在提交审核数据, 请稍侯..', USERID, "False");
} else if (type == '2') {
var selectedRecords = this.gridListChFee_YF.selModel.getSelection();
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
if ((rec.get('FeeName') == "预付款" || rec.get('FeeName') == "购货款" || rec.get('FeeName') == "尾款") && (rec.get('Currency') == "RMB")) {
if (!confirm("货款类费用币别为RMB确认吗")) {
//点击取消
return false;
}
}
}
var records = this.feeGridCheckBoxModel_YF.selected.items;
DsTruck.MsChFeeAudit(records, 2, '正在提交审核数据, 请稍侯..', USERID, "False");
}
},
onShenModifyClick: function (button, event, type) {
var allow = this.getAllowOperationDetail();
if (allow == false) {
return;
}
var selectedRecords = [];
if (type == '1') {
selectedRecords = this.feeGridCheckBoxModel.selected.items;
} else if (type == '2') {
selectedRecords = this.feeGridCheckBoxModel_YF.selected.items;
}
if (selectedRecords.count == 0) {
Ext.Msg.show({ title: '提示', msg: '没有选择要申请修改的业务!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
var rec = selectedRecords[0];
if (rec.data.FeeStatus != 0) {
Ext.Msg.show({ title: '提示', msg: '当前费用状态无法申请修改!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
if (rec.data.Settlement != 0) {
Ext.Msg.show({ title: '提示', msg: '当前费用已结算无法申请修改!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
if (rec.data.IsDebit == 'True') {
Ext.Msg.show({ title: '提示', msg: '当前费用已対帐无法申请修改!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
if (rec.data.Invoice != 0) {
Ext.Msg.show({ title: '提示', msg: '当前费用已开出发票无法申请修改!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
if (rec.data.OrderAmount != 0) {
Ext.Msg.show({ title: '提示', msg: '当前费用已申请费用无法申请修改!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
if (rec.data.OrderInvoice != 0) {
Ext.Msg.show({ title: '提示', msg: '当前费用已申请开票无法申请修改!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
this.DataLoading = true;
this.NewFeeEdit.getForm().loadRecord(rec);
this.OldFee.getForm().loadRecord(rec);
this.DataLoading = false;
this.winShenModifyShow.show();
},
onRetractClick: function (button, event, type) {
var records = [];
if (type == '1') {
var selectedRecords = this.feeGridCheckBoxModel.selected.items;
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
if (rec.get('FeeStatus') == "2" || rec.get('FeeStatus') == "0") {
if (rec.get('OrderAmount') > 0) {
alert(rec.get('FeeName') + "还未取消申请,请撤回申请或重新加载。");
return;
}
records.push(rec);
}
}
} else if (type == '2') {
var selectedRecords = this.feeGridCheckBoxModel_YF.selected.items;
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
if (rec.get('FeeStatus') == "2" || rec.get('FeeStatus') == "0") {
if (rec.get('OrderAmount') > 0) {
alert(rec.get('FeeName') + "还未取消申请,请撤回申请或重新加载。");
return;
}
records.push(rec);
}
}
}
if (records.length > 0) {
DsTruck.MsChFeeAudit(records, 6, '正在提交审核数据, 请稍侯..', "False");
}
},
getCustName: function () {
var custName = this.formEdit.getForm().findField('buyer');
return custName.getValue();
},
getSellerName: function () {
var custName = this.formEdit.getForm().findField('seller');
return custName.getValue();
},
getAllowOperationDetail: function () {
/* var feeStatus = this.getFeeStatus();
if (feeStatus == '0')
return true;
else {
Ext.Msg.show({ title: '错误', msg: "费用已锁定,不允许操作费用!", icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
return false;
}*/
//var data = this.formEdit.getForm().getValues();
//if data.ContractStatus=="1"
// return true;
},
/* getFeeStatus: function () {
//var basicForm = this.formEdit.getForm();
//var feeStatus = basicForm.findField('FeeStatus').value;
//return feeStatus;
return 0;
},
cellEditingChFeeBeforeEdit: function (editor, e) {
/*var chfeefeeStatus = e.record.get('FeeStatus');
var canedit = chfeefeeStatus == 1 || chfeefeeStatus == 6;
if (canedit) {
var feeStatus = this.getFeeStatus();
var billStatus = this.getBillStatus();
canedit = feeStatus == '0' && billStatus == '0';
}
return canedit;*/
// return true;
//},*/
gridListChFeeAfterEdit: function (editor, e, eOpts) {
if (e.field == 'FeeType') {
var records = DsStoreQueryBy(this.storeFeeTypeRef, 'EnumValueId', e.value);
if (records.getCount() > 0) {
var data = records.getAt(0).data;
e.record.set('FeeType_Ref', data.EnumValueName);
} else {
e.record.set('FeeType_Ref', '');
}
} else if (e.field == 'UnitPrice' || e.field == 'Quantity' || e.field == 'ExChangerate') {
var unitPrice = e.record.data['UnitPrice'];
var quantity = e.record.data['Quantity'];
//var ExChangerate= e.record.data['ExChangerate'];
e.record.set('Amount', (unitPrice * quantity).toFixed(2));
}
if (e.field == 'Currency') {
//var ExChangerate = parseFloat(e.record.get('ExChangerate'));
if (e.record.get('Currency') == 'RMB') {
e.record.set('ExChangerate', '1');
}
}
if (e.field == 'FeeName') {
var FeeName = e.record.get('FeeName');
if (FeeName == '购货款') {
e.record.set('Sort', '1');
} else
if (FeeName == '预付款') {
e.record.set('Sort', '2');
} else
if (FeeName == '尾款') {
e.record.set('Sort', '3');
} else
if (FeeName == '关税') {
e.record.set('Sort', '4');
} else
if (FeeName == '增值税') {
e.record.set('Sort', '5');
} else
if (FeeName == '电汇费') {
e.record.set('Sort', '6');
} else
if (FeeName == '手续费') {
e.record.set('Sort', '7');
} else
if (FeeName == '代理费') {
e.record.set('Sort', '8');
} else
if (FeeName == '拖车费') {
e.record.set('Sort', '9');
} else
if (FeeName == '商检验货费') {
e.record.set('Sort', '10');
} else
if (FeeName == '出入库费') {
e.record.set('Sort', '11');
} else
if (FeeName == '冷藏费') {
e.record.set('Sort', '12');
} else
if (FeeName == '超期制冷费') {
e.record.set('Sort', '13');
} else
if (FeeName == '看货费') {
e.record.set('Sort', '14');
} else {
e.record.set('Sort', '999');
}
}
},
//#endregion
onSelectFee: function (button, event) {
//Ext.getCmp("zongshu").setText("1234");
var selectedRecords = this.gridListChFee.selModel.getSelection();
var sum = 0;
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
sum = sum + rec.get("Amount");
}
sum = sum.toFixed(2);
Ext.getCmp("zongshu").setText(" 选中金额:" + sum);
var selectedRecords_YF = this.gridListChFee_YF.selModel.getSelection();
var sum_YF = 0;
for (var i = 0; i < selectedRecords_YF.length; i++) {
var rec = selectedRecords_YF[i];
sum_YF = sum_YF + rec.get("Amount");
}
sum_YF = sum_YF.toFixed(2);
Ext.getCmp("zongshu_YF").setText(" 选中金额:" + sum_YF);
},
// 明细表 费用表相关方法 end
//--------更改单相关方法
// #region 根据权限和状态判断是否允许修改
GetEditStatus: function () {
var canedit = false;
var bsStatus = this.formEdit.getForm().findField('F_STATUS').getValue();
if (bsStatus == '提交融资') {
this.setSaveBtnStatus(true);
} else {
this.setSaveBtnStatus(false);
}
},
setSaveBtnStatus: function (enable) {
var btnEAudit = Ext.getCmp('btnAudit');
var btnESave = Ext.getCmp('btnSave');
var btnESaveAndClose = Ext.getCmp('btnSaveClose');
var btnEAddDetail = Ext.getCmp('btnaddBank');
var btnEDeleteDetail = Ext.getCmp('btndelBank');
if (enable) {
btnEAudit.enable();
btnESave.enable();
btnESaveAndClose.enable();
btnEAddDetail.enable();
btnEDeleteDetail.enable();
} else {
btnEAudit.disable();
btnESave.disable();
btnESaveAndClose.disable();
btnEAddDetail.disable();
btnEDeleteDetail.disable();
}
},
// #endregion
getCondition: function () {
var editform = this.formEdit.getForm();
var CUSTOMER = editform.findField("CUSTOMER").getValue();
var form = this.formSearch.getForm();
if (!form.isValid()) {
Ext.Msg.alert('提示', '查询条件赋值错误,请检查。');
return '';
}
var sql = '';
//var customNo = form.findField('CustomNo').getValue();
sql = sql + getAndConSql(sql, CUSTOMER, " M.buyer='" + CUSTOMER + "'");
var FinanceStatus = form.findField('FinanceStatus').getValue();
sql = sql + getAndConSql(sql, FinanceStatus, " M.FinanceStatus=" + FinanceStatus + " ");
var PORT = form.findField('Port').getValue();
sql = sql + getAndConSql(sql, PORT, " M.Port=" + PORT);
var HTH = form.findField('HTH').getValue();
sql = sql + getAndConSql(sql, HTH, "(m.HTH like '%" + HTH + "%' or M.contractno like '%" + HTH + "%')");
var BillNo = form.findField('BillNo').getValue();
sql = sql + getAndConSql(sql, BillNo, "m.BillNo like '%" + BillNo + "%' ");
return sql;
},
getCustName: function () {
var custName = this.formEdit.getForm().findField('CUSTOMER');
return custName.getValue();
},
Print: function () {
var basicForm = this.formEdit.getForm();
var F_NO = basicForm.findField('F_NO').value;
if (F_NO == '*' || F_NO == '') {
Ext.Msg.show({ title: '错误', msg: '单据还没有保存,请保存后再打印', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
return;
}
var MainList = "";
var selectedRecords = [];
selectedRecords = this.gridBodyList.selModel.getSelection();
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
if (MainList == "") { MainList = "'" + rec.get('GID') + "'"; }
else {
MainList = MainList + ",'" + rec.get('GID') + "'";
}
}
if (MainList == "") {
return;
}
function GetDateStr(AddDayCount) {
var dd = new Date();
dd.setDate(dd.getDate() + AddDayCount); //获取AddDayCount天后的日期
var y = dd.getFullYear();
var m = dd.getMonth() + 1; //获取当前月份的日期
var d = dd.getDate();
return y + "-" + m + "-" + d;
}
//alert(GetDateStr(+5));
var madedate = GetDateStr(0);
//var CUSTOMERNAME = basicForm.findField('CUSTOMERNAME').value;
var printType = 'FinanceEdit_HKTZD'; //还款通知单
var sql1 = "SELECT *,dbo.f_financeBank(F_NO) BANKNAME FROM import_finance WHERE F_NO='" + F_NO + "'";
var sql2 = "SELECT b.* ";
//sql2 = sql2 + " ,substring(cc.country,0,(charindex('(',cc.country)) ) 进口国 ";
//sql2 = sql2 + " ,dbo.f_factoryno(M.contractno) 厂号,f_str(M.contractno) 产品名称,M.containerno 箱号 ";
sql2 = sql2 + " from import_finance_Body B ";
//sql2 = sql2 + " left join import_main M on M.Contractno=B.BSNO";
//sql2 = sql2 + " left join code_country cc on cc.countryid=m.countryid ";
sql2 = sql2 + " where GID in (" + MainList + ")";
// var sql3 = " select * from company where gid=(select top 1 companyid from ch_fee_do where BILLNO='" + billNo + "') ";
var sql3 = " select comp.FULLNAME ";
sql3 = sql3 + " ,(select top 1 REMARK from sys_bank where LINKID=M.company and bankname2 = '中国银行' and CURRENCY='RMB') bankname ";
sql3 = sql3 + " ,(select top 1 ACCOUNT from sys_bank where LINKID=M.company and bankname2 = '中国银行' and CURRENCY='RMB') ACCOUNT ";
sql3 = sql3 + " from Import_Finance_do c ";
sql3 = sql3 + " left join IMPORT_Main M ON M.contractno=c.contractno ";
sql3 = sql3 + " left join company comp ON comp.GID=M.company ";
sql3 = sql3 + " where c.F_NO='" + F_NO + "'";
var sql4 = "select '" + SHOWNAME + "' showname,'" + madedate + "' printdate";
var sql5 = "";
var sql6 = "";
PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6);
}
});