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.

657 lines
20 KiB
JavaScript

Ext.namespace('DsTruck');
DsTruck.FinanceAppIndex = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.DsTruck.FinanceAppIndex.superclass.constructor.call(this);
};
Ext.extend(DsTruck.FinanceAppIndex, Ext.Panel, {
PageSize: 30,
OprationStatus: null, //仅当弹出界面时使用
SelectedRecord: null,
initUIComponents: function () {
//定义数据集
this.StoreOpRange = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsOP',
proxy: { url: '/MvcShipping/MsBaseInfo/GetOpRang' }
});
this.StoreOpRange.load({ params: { optype: "modFinanceAppList"} });
this.storeList = Ext.create('Ext.data.Store', {
pageSize: this.PageSize,
model: 'Financemb',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/Import/Finance/GetDataList',
reader: {
id: 'F_NO',
root: 'data',
totalProperty: 'totalCount'
}
}
});
//定义Grid
var _this = this;
this.Pagenum = Ext.create('Ext.form.field.Number', {
name: 'bottles',
fieldLabel: '每页记录数',
labelAlign: 'right',
value: this.PageSize,
maxValue: 100000,
width: 180,
minValue: 0,
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
});
this.gridList = new Ext.grid.GridPanel({
store: this.storeList,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
columns: [{
sortable: true,
dataIndex: 'F_NO',
header: '融资单号',
width: 120
},
{
sortable: true,
dataIndex: 'CUSTOMER',
header: '客户名称',
width: 100
},
{
sortable: true,
dataIndex: 'F_CURRENCY',
header: '融资币别',
width: 80
},
{
sortable: true,
dataIndex: 'F_AMOUNT',
header: '融资金额',
width: 80
},
{
sortable: true,
dataIndex: 'F_STATUS',
header: '融资状态',
width: 80
},
{
sortable: true,
dataIndex: 'REMARK',
header: '备注',
width: 80
},
{
sortable: true,
dataIndex: 'STARTDATE',
header: '融资开始时间',
width: 100
},
{
sortable: true,
dataIndex: 'ENDDATE',
header: '预计还款时间',
width: 100
},
{
sortable: true,
dataIndex: 'OPREF',
header: '申请人',
width: 80
},
{
sortable: true,
dataIndex: 'ENTERDATE',
header: '申请时间',
width: 80
}
],
// paging bar on the bottom
bbar:[ Ext.create('Ext.PagingToolbar', {
store: this.storeList,
displayInfo: true,
displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录',
emptyMsg: "没有数据"
}), this.Pagenum]
});
this.gridList.addListener('itemdblclick', function (dataview, record, item, index, e, b) {
this.SelectedRecord = record;
this.OprationStatus = 'edit';
DsOpenEditWin('/Import/Finance/AppEdit');
}, this);
//#region formSearch
//#region formSearch枚举参照相关
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: '融资客户',
forceSelection: true,
store: this.storeBuyer,
name: 'CUSTOMER',
valueField: 'name',
displayField: 'codename'
});
this.storeFinance = Ext.create('DsExt.ux.RefEnumStore', {});
this.storeFinance.load({ params: { enumTypeId: 16} });
this.comboxFinance = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '融资状态',
store: this.storeFinance,
valueField: 'EnumValueName',
displayField: 'EnumValueName',
name: 'FinanceStatus'
});
//#endregion
this.formSearch = Ext.widget('form', {
frame: true,
region: 'center',
bodyPadding: 5,
fieldDefaults: {
margins: '2 2 2 2',
labelAlign: 'right',
flex: 1,
labelWidth: 90,
msgTarget: 'qtip'
},
items: [{
//fieldset 1
xtype: 'container',
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [
{
fieldLabel: '融资业务号',
name: 'F_NO',
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
},
{
fieldLabel: '合同号',
name: 'HTH',
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
},
this.comboxBuyer, this.comboxFinance,
{
fieldLabel: '备注中包含',
name: 'remark',
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
}
]
}]
},
//end items(fieldset 1)
{ //fieldset 2
xtype: 'container',
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [ //this.comboxCountry,
/*{
fieldLabel: '贸易商',
name: 'seller'
},
{
fieldLabel: '客户',
name: 'buyer'
}*/
]
}]
},
//end fieldset 2
{ //fieldset 5
xtype: 'container',
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [ //this.comboxport,
{
fieldLabel: '从..融资日期',
format: 'Y-m-d',
xtype: 'datefield',
name: 'STARTDATE_Min',
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
}, {
fieldLabel: '到..融资日期',
format: 'Y-m-d',
xtype: 'datefield',
name: 'STARTDATE_Max',
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
}, {
fieldLabel: '从..还款日期',
format: 'Y-m-d',
xtype: 'datefield',
name: 'ENDDATE_Min',
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
}, {
fieldLabel: '到..还款日期',
format: 'Y-m-d',
xtype: 'datefield',
name: 'ENDDATE_Max',
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
}, { xtype: 'hiddenfield'}]
}]
} //end items(fieldset 5)
] //end root items
});
//#endregion formSearch
//查询工具条
this.panelBtn = new Ext.Panel({
region: "north",
tbar: [
{
text: "新建",
iconCls: "btnadd",
handler: function (button, event) {
this.OprationStatus = 'add';
DsOpenEditWin('/Import/Finance/AppEdit');
},
scope: this
},
'-',
{
text: "执行查询",
iconCls: "btnrefresh",
handler: function (button, event) {
this.onRefreshClick(button, event);
},
scope: this
},
{
text: "重置条件",
iconCls: "btnreset",
handler: function (button, event) {
var form = this.formSearch.getForm();
form.reset();
},
scope: this
}, '-', {
text: '提交融资',
tooltip: '提交融资',
handler: function (button, event) {
this.onSubmitAuditClick();
},
scope: this
}, '-', {
text: '撤销提交',
tooltip: '撤销提交',
handler: function (button, event) {
this.onSubmitAuditBackClick();
},
scope: this
}, '-',
{
text: "删除",
id: 'btndelete',
iconCls: "btndelete",
handler: function (button, event) {
this.onDeleteClick(button, event);
},
scope: this
}
]
});
this.panelTop = new Ext.Panel({
layout: "border",
region: "north",
height: 100,
items: [this.formSearch, this.panelBtn]
});
Ext.apply(this, {
items: [this.panelTop, this.gridList]
});
this.storeList.on('beforeload', function (store) {
var sql = this.getCondition();
Ext.apply(store.proxy.extraParams, { condition: sql });
}, this);
this.onInitRefreshClick();
}, //end initUIComponents
onInitRefreshClick: function (button, event) {
var sql = " F_STATUS IN ('新建融资','提交融资') ";
this.storeList.load({
params: { start: 0, limit: this.PageSize, sort: '', condition: sql },
waitMsg: "正在查询数据...",
scope: this
});
},
onRefreshClick: function (button, event) {
var sql = this.getCondition();
this.PageSize = this.Pagenum.getValue();
this.storeList.pageSize = this.PageSize;
this.storeList.load({
params: { start: 0, limit: this.PageSize, sort: '', condition: sql },
waitMsg: "正在查询数据...",
scope: this
});
},
onDeleteClick: function (button, event) {
var selections = this.gridList.getSelectionModel().getSelection();
if (selections.length == 0) {
Ext.Msg.show({ title: '提示', msg: '请先选择单据!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
var record = selections[0];
var billstatus = record.data.F_STATUS;
if (billstatus != '新建融资' && billstatus != '驳回融资') {
Ext.Msg.show({ title: '提示', msg: '当前状态无法删除此单据!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
Ext.MessageBox.confirm('提示', '确定删除该记录吗?', function (btn) {
if (btn == 'yes') {
Ext.Msg.wait('正在删除数据...');
Ext.Ajax.request({
waitMsg: '正在删除数据...',
url: '/Import/Finance/Delete',
params: {
data: Ext.JSON.encode(record.data)
},
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
this.storeList.remove(record);
Ext.Msg.show({ title: '提示', msg: '删除成功!', 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
}
}, this);
}, //onDeleteClick
onSubmitAuditClick: function () {
var selections = this.gridList.getSelectionModel().getSelection();
if (selections.length == 0) {
Ext.Msg.show({ title: '提示', msg: '请先选择单据!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
var BILLNOStr = '';
for (var i = 0; i < selections.length; i++) {
var rec = selections[i];
var BILLNO = rec.data.F_NO;
if (rec.data.F_STATUS == '新建融资' || rec.data.F_STATUS == '驳回融资') {
if (BILLNOStr == '')
BILLNOStr = BILLNO;
else {
BILLNOStr = BILLNOStr + ',' + BILLNO;
}
}
}
_this = this;
if (BILLNOStr == '') {
} else {
Ext.Ajax.request({
waitMsg: '正在添加数据...',
url: '/Import/Finance/SubmitAuditList',
params: {
bills: BILLNOStr
},
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 {
_this.onRefreshClick();
}
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
}
},
onSubmitAuditBackClick: function () {
var selections = this.gridList.getSelectionModel().getSelection();
if (selections.length == 0) {
Ext.Msg.show({ title: '提示', msg: '请先选择单据!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
var BILLNOStr = '';
for (var i = 0; i < selections.length; i++) {
var rec = selections[i];
var BILLNO = rec.data.F_NO;
if (rec.data.F_STATUS == '提交融资') {
if (BILLNOStr == '')
BILLNOStr = BILLNO;
else {
BILLNOStr = BILLNOStr + ',' + BILLNO;
}
}
}
_this = this;
if (BILLNOStr == '') {
} else {
Ext.Ajax.request({
waitMsg: '正在添加数据...',
url: '/Import/Finance/SubmitAuditBackList',
params: {
bills: BILLNOStr
},
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 {
_this.onRefreshClick();
}
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
};
},
getCondition: function () {
var form = this.formSearch.getForm();
if (!form.isValid()) {
Ext.Msg.alert('提示', '查询条件赋值错误,请检查。');
return '';
}
var sql = '';
var F_NO = form.findField('F_NO').getValue();
sql = sql + getAndConSql(sql, F_NO, "f.F_NO like '%" + F_NO + "%'");
var HTH = form.findField('HTH').getValue();
sql = sql + getAndConSql(sql, HTH, " f.F_NO in (select c.F_NO from Import_Finance_do c left join IMPORT_Main M ON M.contractno=c.contractno WHERE M.HTH like '%" + HTH + "%')");
var CUSTOMER = form.findField('CUSTOMER').getValue();
sql = sql + getAndConSql(sql, CUSTOMER, "f.CUSTOMER = '" + CUSTOMER + "'");
var FinanceStatus = form.findField('FinanceStatus').getValue();
sql = sql + getAndConSql(sql, FinanceStatus, "f.F_STATUS = '" + FinanceStatus + "'");
var remark = form.findField('remark').getValue();
sql = sql + getAndConSql(sql, remark, "f.REMARK like '%" + remark + "%'");
var STARTDATE_Min = form.findField('STARTDATE_Min').getRawValue();
sql = sql + getAndConSql(sql, STARTDATE_Min, "f.STARTDATE >= '" + STARTDATE_Min + "'");
var STARTDATE_Max = form.findField('STARTDATE_Max').getRawValue();
sql = sql + getAndConSql(sql, STARTDATE_Max, "f.STARTDATE <= '" + STARTDATE_Max + " 23:59:59'");
var ENDDATE_Min = form.findField('ENDDATE_Min').getRawValue();
sql = sql + getAndConSql(sql, ENDDATE_Min, "f.ENDDATE >= '" + ENDDATE_Min + "'");
var ENDDATE_Max = form.findField('ENDDATE_Max').getRawValue();
sql = sql + getAndConSql(sql, ENDDATE_Max, "f.ENDDATE <= '" + ENDDATE_Max + " 23:59:59'");
return sql;
},
OprationSwap: function () {
var ret = new Array();
ret[0] = this.OprationStatus;
ret[1] = this.storeList;
ret[2] = this.SelectedRecord;
return ret;
}
});