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

1742 lines
62 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('DsTruck');
DsTruck.FinanceAppEdit = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.DsTruck.FinanceAppEdit.superclass.constructor.call(this);
};
Ext.extend(DsTruck.FinanceAppEdit, Ext.Panel, {
ParentWin: null,
OpStatus: 'add',
StoreList: null,
editRecord: null,
addstore: false,
PageSize: 30,
sqlcontext: '',
initUIComponents: function () {
this.serialNo = 0;
this.workSerialNo = 0;
this.bodyDel = [];
this.FeeSql = '';
this.BillSql = '';
this.DuiBillSql = '';
this.IsDebit = '0';
//#region 编辑form
//枚举参照相关(编辑form)
//表参照相关(编辑form)
this.formname = "formFinanceAppEdit"; //页面名称
this.StoreOpRange = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsOP',
proxy: { url: '/MvcShipping/MsBaseInfo/GetOpRang' }
});
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'
});
//编辑form
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: '融资业务编号',
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: '融资时间',
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 ENDDATE = getNewDay(STARTDATE, newValue);
basicForm.findField('ENDDATE').setValue(ENDDATE);
var BANKENDDATE = getNewDay(STARTDATE, 90);
basicForm.findField('BANKENDDATE').setValue(BANKENDDATE);
}
}
}, {
fieldLabel: '融资天数',
name: 'DAYS',xtype:'numberfield', 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 ENDDATE = getNewDay(STARTDATE, newValue);
basicForm.findField('ENDDATE').setValue(ENDDATE);
},
scope: this
}
},
{
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 () {
}
}
}]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '融资状态',
name: 'F_STATUS', readOnly: true, hidden: false
}, {
fieldLabel: '操作人',
readOnly: true, flex: 1,
name: 'OPREF'
}, {
fieldLabel: '备注', flex:2,
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
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
}
]
}); //end 按钮Toolbar
//#endregion
//#region 明细表
//明细表表格相关
this.GridCheckBoxModel = Ext.create('Ext.selection.CheckboxModel');
//明细表-数据集
this.storeBodyList = Ext.create('Ext.data.Store', {
model: 'FinanceTradeBody',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/Import/Finance/GetBodyList',
reader: {
id: 'GID',
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: '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: 'CURR',
header: '币别',
width: 80
}, {
sortable: true,
dataIndex: 'R_AMOUNT',
header: '申请金额',
width: 80
}
]
});
//#region 添加业务列表
this.storeBodyAddList = Ext.create('Ext.data.Store', {
pageSize: this.PageSize,
model: 'FinanceTradeBody',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/Import/Finance/GetBodyAddList',
reader: {
id: 'BSNO',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.AddGridCheckBoxModel = Ext.create('Ext.selection.CheckboxModel');
this.gridAddList = new Ext.grid.GridPanel({
store: this.storeBodyAddList,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
selModel: this.AddGridCheckBoxModel,
tbar: [{
text: '添加融资申请',
tooltip: '添加融资申请',
id: 'btnadddetail',
iconCls: "btnadddetail",
handler: function (button, event) {
this.onAddClick(button, event);
},
scope: this
}],
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: 'CUSTOMER',
header: '费用客户',
width: 80
}, {
sortable: true,
dataIndex: 'CURR',
header: '币别',
width: 80
}, {
sortable: true,
dataIndex: 'W_AMOUNT',
header: '申请金额',
width: 80
}, {
sortable: false,
dataIndex: 'R_AMOUNT',
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(9)
} else if (e.getKey() == 38) {
_this.onUpKeyClick(9)
}
}
}
},
width: 70
}
],
// paging bar on the bottom
bbar: Ext.create('Ext.PagingToolbar', {
store: this.storeBodyAddList,
displayInfo: true,
displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录',
emptyMsg: "没有数据"
})
});
_this = this;
this.storeCompany = Ext.create('DsExt.ux.RefTableStore', {
model: 'companymb',
proxy: { url: '/CommMng/BasicDataRef/GetcompanyList' }
});
this.storeCompany.load({ params: { condition: ""} });
this.comboxCompany = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '用证公司',
store: this.storeCompany,
name: 'company',
valueField: 'gid',
displayField: 'name'
});
this.storeBuyer = Ext.create('DsExt.ux.RefTableStore', {
model: 'Tradermb',
proxy: { url: '/CommMng/BasicDataRef/GetTrader' }
});
this.storeBuyer.load({ params: { condition: " isagentcn=1 "} });
this.comboxBuyer = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '客户',
store: this.storeBuyer,
name: 'Buyer',
valueField: 'name',
displayField: 'codename'
});
this.storeCust= Ext.create('DsExt.ux.RefTableStore', {
model: 'Tradermb',
proxy: { url: '/CommMng/BasicDataRef/GetTrader' }
});
this.storeCust.load({ params: { condition: " 1=1 "} });
this.comboxCust = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '申请客户',
store: this.storeCust,
name: 'Cust',
valueField: 'name',
displayField: 'codename'
});
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.comboxCust,this.comboxCompany, this.comboxBuyer, { fieldLabel: '贸易商',
name: 'seller'
}, {
fieldLabel: '合同序列号',
name: 'ContractNo',
enableKeyEvents: true,
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
}, {
fieldLabel: '合同号',
name: 'HTH',
enableKeyEvents: true,
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
}, {
fieldLabel: '提单号',
name: 'BillNo',
enableKeyEvents: true,
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
}, {
xtype: 'button',
width: 90,
text: "执行查询",
iconCls: "btnrefresh",
handler: function (button, event) {
this.onRefreshClick(button, event);
},
scope: this
}, {
xtype: 'button',
width: 30,
// text: "重置条件",
iconCls: "btnreset",
handler: function (button, event) {
this.onClearSql(button, event);
},
scope: this
}, {
xtype: 'button',
width: 30,
// text: "高级查询",
iconCls: "btnmore",
handler: function (button, event) {
var sql = this.getCondition();
var winAccess = new Shipping.DsQuery({
});
winAccess.StoreList = this.storeBodyAddList;
winAccess.formname = this.formname;
winAccess.condition = sql;
winAccess.show();
return;
},
scope: this
}
]
}
]//end items(fieldset 1)
}//end fieldset 1
]//end root items
});
this.paneldetail = new Ext.Panel({
title: '申请明细',
layout: "border",
height: 240,
region: "north",
split: true,
items: [
this.gridList
]
});
this.paneladddetail = new Ext.Panel({
layout: "border",
region: 'center',
height: 300,
items: [this.gridAddList
]
});
this.paneladd = new Ext.Panel({
title: '添加申请融资明细',
layout: "border",
// region: 'south',
region: "center",
// height: 420,
items: [
this.formSearch, this.paneladddetail
]
});
//#endregion 明细表
//#region 布局
//控件布局
this.panelTop = new Ext.Panel({
layout: "border",
region: "north",
height: 160,
items: [this.panelBtn, this.formEdit]
});
Ext.apply(this, {
items: [this.panelTop, this.paneldetail, this.paneladd]
});
//#endregion
//绑定查询窗体
this.ParentWin = window.parent.opener.panelIndex;
//初始化数据
this.InitData();
//绑定事件
var billno = '*';
if (this.opStatus == 'edit') {
billno = this.editRecord.get('F_NO');
};
this.storeBodyList.on('beforeload', function (store) {
var sql = " c.F_NO='" + billno + "'";
Ext.apply(store.proxy.extraParams, { condition: sql });
}, this);
this.storeBodyAddList.on('beforeload', function (store) {
Ext.apply(store.proxy.extraParams, { condition: this.sqlcontext });
}, 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 = " F_NO='" + this.editRecord.get('F_NO') + "'";
this.LoadData(this.opStatus, condition);
}, //end InitData
LoadData: function (opstatus, condition) {
this.serialNo = 0;
this.workSerialNo = 0;
this.bodyDel = [];
this.opStatus = opstatus;
_this = this;
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/Import/Finance/GetData',
params: {
handle: opstatus,
condition: condition
},
callback: function (options, success, response) {
if (success) {
var result = Ext.JSON.decode(response.responseText);
if (!result.Success) {
Ext.Msg.show({
title: '提示',
msg: result.Message,
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.OK
});
return;
}
var data = result.data;
//20190929 如果融资时间为空则填入当前日期
//并同时填写 融资天数1天。银行日期+90天
if (data.STARTDATE === "") {
var newday = currdate.format('yyyy-MM-dd');
data.STARTDATE = newday;
data.DAYS = 0;
var ENDDATE = getNewDay(newday, 0);
data.ENDDATE = ENDDATE;
var BANKENDDATE = getNewDay(newday, 90);
data.BANKENDDATE = BANKENDDATE;
}
_this.formEdit.getForm().reset();
_this.formEdit.getForm().setValues(data);
_this.GetEditStatus();
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
var billno = '*';
if (this.opStatus == 'edit') {
billno = this.editRecord.get('F_NO');
};
this.storeBodyList.load({ params: { condition: " c.F_NO='" + billno + "'" },
callback: function (r, options, success) {
if (success) {
if (this.storeBodyList.getCount() > 0) {
// this.comboxCurr.setReadOnly(true);
this.comboxBuyer_F.setReadOnly(true);
}
else {
// this.comboxCurr.setReadOnly(false);
this.comboxBuyer_F.setReadOnly(false);
}
}
},
scope: this
});
}, // end LoadDate
Save: function (type) {
var basicForm = this.formEdit.getForm();
if (!basicForm.isValid()) {
return;
}
var data = basicForm.getValues();
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/Import/Finance/Save',
scope: this,
params: {
opstatus: this.opStatus,
data: Ext.JSON.encode(data)
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
var returnData = jsonresult.Data;
this.formEdit.getForm().setValues(returnData);
if (this.opStatus == 'add') {
var arrNewRecords = this.StoreList.insert(0, returnData);
this.editRecord = this.StoreList.getAt(0);
}
else if (this.opStatus == 'edit') {
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();
}
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
onAddBillClick: function (button, event) {
this.addBill();
}, //end onAddDetailClick
onDelDetailClick: function (button, event, type) {
this.deleteDetail();
}, //onDelDetailClick
onAddClick: function (button, event) {
this.addBill();
}, //end onAddDetailClick
onDeleteClick: function (button, event) {
this.deleteBill();
}, //end onAddDetailClick
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 });
},
addBill: function () {
var basicForm = this.formEdit.getForm();
var Duino = this.formEdit.getForm().findField('F_NO').getValue();
_this = this;
if ((Duino == '*') || (Duino == '') || basicForm.isDirty()) {
var CUSTOMERNAME = this.formEdit.getForm().findField('CUSTOMER').getValue();
var CURR = this.formEdit.getForm().findField('F_CURRENCY').getValue();
if ((CUSTOMERNAME == '') || (CUSTOMERNAME == null)) {
var selectedRecords = this.gridAddList.selModel.getSelection();
if (selectedRecords.length > 0) {
var rec = selectedRecords[0];
var cust = rec.data.CUSTOMER;
var curr = rec.data.CURR;
if ((CUSTOMERNAME == '') || (CUSTOMERNAME == null))
this.formEdit.getForm().findField('CUSTOMER').setValue(cust);
if ((CURR == '') || (CURR == null))
this.formEdit.getForm().findField('F_CURRENCY').setValue(curr);
}
}
if (!basicForm.isValid()) {
return;
}
var type = 0;
var data = basicForm.getValues();
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/Import/Finance/Save',
scope: this,
params: {
opstatus: this.opStatus,
data: Ext.JSON.encode(data)
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
var returnData = jsonresult.Data;
this.formEdit.getForm().setValues(returnData);
if (this.opStatus == 'add') {
var arrNewRecords = this.StoreList.insert(0, returnData);
this.editRecord = this.StoreList.getAt(0);
}
else if (this.opStatus == 'edit') {
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';
_this.addBillfn();
} 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.addBillfn();
}
}, //end save
addBillfn: function () {
var billstatus = this.formEdit.getForm().findField('F_STATUS').getValue();
if ((billstatus !='新建融资') ) {
Ext.Msg.show({ title: '提示', msg: '当前状态无法添加融资明细!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
var billno = this.editRecord.get('F_NO');
var billcust = this.editRecord.get('CUSTOMER');
var billcurr = this.editRecord.get('F_CURRENCY');
var feeBSNOSql = '';
var sql = '';
var selectedRecords = this.gridAddList.selModel.getSelection();
if (selectedRecords.length == 0) {
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];
var cust = rec.data.CUSTOMER;
var curr = rec.data.CURR;
if ((cust == billcust)&&(curr==billcurr)) {
bodyAddDatas.push(rec);
} else {
// Ext.Msg.show({ title: '提示', msg: '费用对象与收费申请客户不一致,不能添加此申请!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
alert('费用对象与申请客户或申请币别不一致,不能添加此费用明细!');
}
}
_this = this;
var AddBody = ConvertRecordsToJsonAll(bodyAddDatas);
Ext.Ajax.request({
waitMsg: '正在添加数据...',
url: '/Import/Finance/AddBill',
params: {
billno: billno,
addbody: AddBody
},
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.sqlcontext;
this.storeBodyAddList.load({ params: { start: 0, limit: _this.PageSize, sort: '', condition: sql} });
_this.storeBodyList.load({ params: { condition: " c.F_NO='" + billno + "'" },
callback: function (r, options, success) {
if (success) {
if (_this.storeBodyList.getCount() > 0) {
// _this.comboxCurr.setReadOnly(true);
_this.comboxBuyer_F.setReadOnly(true);
}
else {
// _this.comboxCurr.setReadOnly(false);
_this.comboxBuyer_F.setReadOnly(false);
}
}
},
scope: this
});
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/Import/Finance/GetData',
params: {
handle: 'edit',
condition: " F_NO='" + 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;
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();
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
} else {
return;
}
}
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
},
deleteBill: function (type) {
var billno = this.formEdit.getForm().findField('F_NO').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('F_STATUS').getValue();
if (billstatus !='新建融资') {
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.sqlcontext;
_this = this;
Ext.Ajax.request({
waitMsg: '正在删除数据...',
url: '/Import/Finance/DelBill',
params: {
data: jsonbodyAddDatas,
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;
} else {
var sql = this.sqlcontext;
this.storeBodyAddList.load({ params: { start: 0, limit: _this.PageSize, sort: '', condition: sql} });
_this.storeBodyList.load({ params: { condition: " c.F_NO='" + billno + "'" },
callback: function (r, options, success) {
if (success) {
if (_this.storeBodyList.getCount() > 0) {
// _this.comboxCurr.setReadOnly(true);
_this.comboxBuyer_F.setReadOnly(true);
}
else {
// _this.comboxCurr.setReadOnly(false);
_this.comboxBuyer_F.setReadOnly(false);
}
}
},
scope: this
});
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/Import/Finance/GetData',
params: {
handle: 'edit',
condition: " F_NO='" + 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;
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();
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
}
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
},
onSubmitAuditClick: function () {
var Duino = this.formEdit.getForm().findField('F_NO').getValue();
var billstatus = this.formEdit.getForm().findField('F_STATUS').getValue();
if (Duino == '*') {
Ext.Msg.show({ title: '提示', msg: '请先保存付费申请,然后才能提交审核!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
};
if (billstatus !='新建融资') {
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: '/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
});
},
onSubmitAuditBackClick: function () {
var Duino = this.formEdit.getForm().findField('F_NO').getValue();
var billstatus = this.formEdit.getForm().findField('F_STATUS').getValue();
if (Duino == '*') {
Ext.Msg.show({ title: '提示', msg: '请先保存融资申请,然后才能提交融资!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
};
if (billstatus !='提交融资') {
Ext.Msg.show({ title: '提示', msg: '当前状态无法撤销提交!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
_this = this;
Ext.Ajax.request({
waitMsg: '正在添加数据...',
url: '/Import/Finance/SubmitAuditBack',
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
});
},
onRefreshClick: function (button, event) {
var sql = this.getCondition();
this.sqlcontext = sql;
this.storeBodyAddList.load({ params: { start: 0, limit: this.PageSize, sort: '', condition: sql} });
},
onDsQuery: function () {
//var girdcolums = this.gridList.getColumnMode();
var sql = this.sqlcontext;
this.storeBodyAddList.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 ContractNo = form.findField('ContractNo').getValue();
sql = sql + getAndConSql(sql, ContractNo, " (M.ContractNo like '%" + ContractNo + "%' or M.DeclareNumber like '%" + ContractNo + "%' or M.inspection_no like '%" + ContractNo + "%') ");
var HTH = form.findField('HTH').getValue();
sql = sql + getAndConSql(sql, HTH, "M.HTH like '%" + HTH + "%'");
var company = form.findField('company').getValue();
sql = sql + getAndConSql(sql, company, "M.company = '" + company + "'");
var buyer = form.findField('Buyer').getValue();
sql = sql + getAndConSql(sql, buyer, "M.buyer = '" + buyer + "'");
var seller = form.findField('seller').getRawValue();
sql = sql + getAndConSql(sql, seller, "M.seller like '%" + seller + "%'");
var BillNo = form.findField('BillNo').getRawValue();
sql = sql + getAndConSql(sql, BillNo, "m.BillNo like '%" + BillNo + "%'");
var Cust = form.findField('Cust').getValue();
sql = sql + getAndConSql(sql, Cust, "c.CUSTOMERNAME = '" + Cust + "'");
return sql;
},
// #region 根据权限和状态判断是否允许修改
GetEditStatus: function () {
var canedit = false;
var btnESubmitAudit = Ext.getCmp('btnSubmitAudit');
var btnESubmitAuditBack = Ext.getCmp('btnSubmitAuditBack');
var bsStatus = this.formEdit.getForm().findField('F_STATUS').getValue();
var op = this.formEdit.getForm().findField('OPREF').getValue();
_this = this;
this.StoreOpRange.load({ params: { optype: "modFinanceAppList" },
callback: function (r, options, success) {
if (success) {
if (r.length != 0) {
var records = DsStoreQueryBy(_this.StoreOpRange, 'OPID', op);
if (records.getCount() > 0) {
canedit = true;
if (bsStatus =='新建融资')
btnESubmitAudit.enable();
else
btnESubmitAudit.disable();
if (bsStatus =='提交融资')
btnESubmitAuditBack.enable();
else
btnESubmitAuditBack.disable();
} else {
canedit = false;
btnESubmitAudit.disable();
btnESubmitAuditBack.disable();
}
if (bsStatus != '新建融资') {
_this.setSaveBtnStatus(false);
} else {
_this.setSaveBtnStatus(canedit);
}
}
}
}
});
},
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('F_NO').value;
if (billNo == '*' || billNo == '') {
Ext.Msg.show({ title: '错误', msg: '单据还没有保存,请保存后再打印', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
return;
}
var printType = 'MSFINANCEAPP';
var sql1 = "SELECT * FROM IMPORT_FINANCE WHERE F_NO='" + billNo + "'";
var sql2 = "SELECT c.GID,c.F_NO,c.ContractNo,c.AMOUNT ";
sql2 = sql2 + ",b.HTH,b.billno,b.BUYER,b.seller, C.NAME COMPANYNAME";
sql2 = sql2 + ",(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=10 and EnumValueID=b.port) as portRef";
sql2 = sql2 + ",(select NAME from [COMPANY] where GID=b.COMPANY) as COMPANYNAME";
sql2 = sql2 + " FROM Import_Finance_do c left join Import_main b on (b.ContractNo=c.ContractNo)";
sql2 = sql2 + " WHERE C.F_NO='" + billNo + "' ORDER BY b.ContractNo,b.HTH";
var sql3 = "";
var sql4 = "";
var sql5 = "";
var sql6 = "";
PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6);
}
,onSelectFee: function (button, event) {
//Ext.getCmp("zongshu").setText("1234");
var selectedRecords = this.gridAddFeeList.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);
}
});