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/FinanceIndex.js

894 lines
28 KiB
JavaScript

3 years ago
Ext.namespace('DsTruck');
var C_feeid = "";
var C_contractno = ""; //用于存储当前选定的合同号/ch_fee.id
var C_Customer = ""; //结算对象
var C_CustomerRef = "";
var M_contractno = ""; //用于存储当前选定的合同号/ch_fee.id
var M_Customer = ""; //结算对象
//var array = [0];
DsTruck.FinanceIndex = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.DsTruck.FinanceIndex.superclass.constructor.call(this);
};
Ext.extend(DsTruck.FinanceIndex, Ext.Panel, {
PageSize: 50,
OprationStatus: null,
//仅当弹出界面时使用
SelectedRecord: null,
OpStatus: null,
ChangePage: false,
//array: new Array(),
initUIComponents: function () {
this.FOBodyDel = [];
this.array = [];
this.formname = "Import_FINANCE";
var _this = this;
//#region formSearch参照
this.storeMainstate = Ext.create('DsExt.ux.RefEnumStore', {});
this.storeMainstate.load({ params: { enumTypeId: 3} });
this.comboxMainstate = Ext.create('DsExt.ux.RefEnumCombox', {
fieldLabel: '合同状态',
store: this.storeMainstate,
name: 'Mainstate'
});
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'
});
//表参照
this.storeCountry = Ext.create('DsExt.ux.RefTableStore', {
model: 'ConutryRef',
proxy: {
url: '/CommMng/BasicDataRef/GetCountryRefList'
}
});
this.storeCountry.load({ params: { condition: ""} });
this.comboxCountry = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '进口国',
store: this.storeCountry,
name: 'countryid',
valueField: 'countryid',
displayField: 'country_idandname'
});
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.storeRemind = Ext.create('DsExt.ux.RefTableStore', {
model: 'remind',
proxy: {
url: '/CommMng/BasicDataRef/Getimportremind'
}
});
this.storeRemind.load({ params: { condition: ""} });
this.comboxRemind = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '业务提醒',
store: this.storeRemind,
name: 'Remind',
valueField: 'RemindSql',
displayField: 'RemindName',
triggerAction: 'all',
selectOnFocus: true,
listeners: {
change: function (field, newValue, oldValue) {
this.onGetremind(field, newValue, oldValue);
},
scope: this
}
});
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',
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
});
this.storeBuyer2 = Ext.create('DsExt.ux.RefTableStore', {
model: 'Tradermb',
proxy: { url: '/CommMng/BasicDataRef/GetTrader' }
});
this.storeBuyer2.load({ params: { condition: ""} });
this.comboxBank = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '融资银行',
forceSelection: true,
store: this.storeBuyer2,
name: 'BANKNAME',
valueField: 'name',
displayField: 'codename',
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
});
Ext.define('PayTypeMd', {
extend: 'Ext.data.Model',
fields: [
{ name: 'SQLStr', type: 'string' },
{ name: 'Name', type: 'string' }
]
});
var PayTypeData = [
{ "SQLStr": "", "Name": "" },
{ "SQLStr": " (isnull(f.CUSTSTLAMOUNT,0)>=f.F_AMOUNT and isnull(f.CUSTSTLAMOUNT,0)>0) ", "Name": "全部归还" },
{ "SQLStr": " isnull(f.CUSTSTLAMOUNT,0)=0 ", "Name": "未还款" },
{ "SQLStr": " ( isnull(CUSTSTLAMOUNT,0)-isnull(F_AMOUNT,0)<0 and CUSTSTLAMOUNT>0 ) ", "Name": "部分归还" }
];
this.storePayType = Ext.create('Ext.data.Store', {
model: 'PayTypeMd',
data: PayTypeData
});
this.comboxPayType = Ext.create('DsExt.ux.RefEnumCombox', {
fieldLabel: '还款状态',
forceSelection: true,
store: this.storePayType,
name: 'CUSTSTLSTATUS',
valueField: 'SQLStr',
displayField: 'Name'
});
//#endregion
//#region 查询工具条
var menu1 = new Ext.menu.Menu({
id: 'basicMenu',
items: [{
text: "银行保函",
handler: function (button, event) {
this.Print();
},
scope: this
}]
});
this.panelBtn = new Ext.Panel({
region: "north",
tbar: [{
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: "删除",
iconCls: "btndelete",
handler: function (button, event) {
this.onDeleteClick(button, event);
},
scope: this
}, '-', {
text: "导出Excel",
id: "btnExportExcel",
iconCls: 'btnexportexcel',
handler: function (button, event) {
this.onExportClick(button, event);
},
scope: this
}, '-',
{
text: "打印", menu: menu1, scope: this
}]
});
this.formSearch = Ext.widget('form', {
frame: true,
region: 'center',
bodyPadding: 5,
fieldDefaults: {
margins: '2 2 2 2',
labelAlign: 'right',
flex: 1,
labelWidth: 96,
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.comboxBank,
this.comboxFinance,
{
fieldLabel: '备注中包含',
name: 'remark',
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
}
]
}]
},
//end items(fieldset 1)
{ //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();
}
}
}
}, {
fieldLabel: '从..银行还款日期',
format: 'Y-m-d',
xtype: 'datefield',
name: 'BANKENDDATE_Min',
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
}, {
fieldLabel: '到..银行还款日期',
format: 'Y-m-d',
xtype: 'datefield',
name: 'BANKENDDATE_Max',
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
}//, { xtype: 'hiddenfield' }
]
}]
} //end items(fieldset 5)
,
{ //fieldset 2
xtype: 'container',
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [
this.comboxPayType
, {xtype:'hiddenfield',flex:5}
]
}]
}
//end fieldset 2
] //end root items
});
//#endregion 查询条件
//融资业务列表
//定义数据集
this.storeList = Ext.create('Ext.data.Store', {
model: 'Financemb',
remoteSort: false,
pageSize: this.PageSize,
proxy: {
type: 'ajax',
url: '/Import/Finance/GetDataList',
reader: {
idProperty: 'F_NO',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.MainGridCheckBoxModel = new Ext.selection.CheckboxModel({
id: 'MainGridCheckBoxModel'
//,checkOnly: true
});
this.column = [
{
sortable: true,
dataIndex: 'F_NO',
header: '序号',
width: 80
}, {
sortable: true,
dataIndex: 'F_NO',
header: '融资业务号',
width: 110
},
{
sortable: true,
dataIndex: 'F_CURRENCY',
header: '融资币别',
width: 56
},
{
sortable: true,
dataIndex: 'F_AMOUNT',
header: '融资金额',
width: 80
},
{
sortable: true,
dataIndex: 'F_STATUS',
header: '融资状态',
width: 80
},
{
sortable: true,
dataIndex: 'CUSTOMER',
header: '客户名称',
width: 100
},
{
sortable: true,
dataIndex: 'REMARK',
header: '备注',
width: 80
},
{
sortable: true,
dataIndex: 'STARTDATE',
header: '融资开始时间',
width: 100
},
{
sortable: true,
dataIndex: 'ENDDATE',
header: '客户还款时间',
width: 100
},
{
sortable: true,
dataIndex: 'BANKENDDATE',
header: '银行还款时间',
width: 100
},
{
sortable: true,
dataIndex: 'CUSTSTLAMOUNT',
header: '客户还款金额',
width: 80
},
{
sortable: true,
dataIndex: 'CUSTBALAMOUNT',
header: '客户未还金额',
width: 80
},
{
sortable: true,
dataIndex: 'BANKSTLAMOUNT',
header: '还银行金额',
width: 80
},
{
sortable: true,
dataIndex: 'BANKBALAMOUNT',
header: '未还银行金额',
width: 80
},
{
sortable: true,
dataIndex: 'OPREF',
header: '申请人',
width: 80
},
{
sortable: true,
dataIndex: 'ENTERDATE',
header: '申请时间',
width: 80
},
{
sortable: true,
dataIndex: 'CUSTSTLSTATUS',
header: '客户还款状态',
width: 80,
renderer: function (value) {
if (value == "未还款") {
return "<a><font color='#FF0000'>" + value + "</font></a>";
} else if (value == "部分归还") {
return "<a><font color='#FF00FF'>" + value + "</font></a>";
} else if (value == "全部归还") {
return "<a><font color='#00FF00'>" + value + "</font></a>";
} else {
return "<a><font color='#FFFFFF'>" + value + "</font></a>";
}
}
},
{
sortable: true,
dataIndex: 'BANKNAME',
header: '融资银行',
width: 80
}];
//定义Grid
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({
id: 'gridList',
store: this.storeList,
enableHdMenu: false,
region: 'center',
loadMask: {
msg: "数据加载中,请稍等..."
},
trackMouseOver: true,
disableSelection: false,
selModel: this.MainGridCheckBoxModel,
stripeRows: true,
//height: 150,
viewConfig: {
autoFill: true,
enableTextSelection: true,
getRowClass: function (record, rowIndex, rowParams, store) {
var FinanceStatus = record.get('FinanceStatus');
return DsTruck.FinanceGetRowClass(FinanceStatus);
}
},
columns: [new Ext.grid.RowNumberer()],
bbar: [Ext.create('Ext.PagingToolbar', {
store: this.storeList,
pageSize: this.PageSize,
displayInfo: true,
displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录',
emptyMsg: "没有数据"
}), this.Pagenum]
});
/////////////////////////////////////////////////////////
/////////////以下部分为获取存储的gridpanel显示样式
this.column = DsTruck.GetGridPanel(USERID, this.formname, this.column, 1, false);
//使用者id表名 中间column数组跳过一开始的几列
this.gridList.reconfigure(this.storeList, this.column);
this.gridList.columns[0] = new Ext.grid.RowNumberer();
////////////////////////////
this.gridList.addListener('itemdblclick', function (dataview, record, item, index, e, b) {
this.SelectedRecord = record;
this.OprationStatus = 'edit';
DsOpenEditWin('/Import/Finance/Edit');
}, this);
//布局
this.panelTop = new Ext.Panel({
layout: "border",
region: "north",
height: 130,
//split: true,
items: [this.formSearch, this.panelBtn]
});
this.panelContract = new Ext.Panel({
layout: "border",
region: "center",
//height: 180,
//split: true,
items: [this.gridList]
});
this.panelMain = new Ext.Panel({
layout: "border",
region: "north",
height: 130,
//split: true,
items: [this.panelTop]
}); //合同查询和结果
this.panelFinanceOut = new Ext.Panel({
id: "page_1",
layout: "border",
region: "north",
title: "贸易融资管理",
items: [this.panelContract
]
});
this.MainTab = new Ext.tab.Panel({
layout: "border",
region: "center",
items: [this.panelFinanceOut
// ,
// //this.panelFinanceOut_M,
// //this.page_2,
// this.page_3
//, this.page_4, this.page_5
]
});
Ext.apply(this, {
items: [this.panelMain, this.MainTab]
});
this.storeList.on('beforeload', function (store) {
var sql = this.getCondition();
Ext.apply(store.proxy.extraParams, { condition: sql });
}, this);
this.onRefreshClick();
},
//end initUIComponents
onSaveClick: function (button, event) {
this.Save("0");
},
onRefreshClick: function (button, event) {
var _p = this.MainTab.getActiveTab().id;
this.PageSize = this.Pagenum.getValue();
this.storeList.pageSize = this.PageSize;
if (_p == "page_1") {
var sql = this.getCondition();
this.storeList.load({
params: { start: 0, limit: this.PageSize, sort: '', condition: sql },
waitMsg: "正在查询数据...",
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 F_NO from import_Finance_do where contractno in (select contractno from import_main where HTH like '%" + HTH + "%'))");
var CUSTOMER = form.findField('CUSTOMER').getValue();
sql = sql + getAndConSql(sql, CUSTOMER, "f.CUSTOMER = '" + CUSTOMER + "'");
var BANKNAME = form.findField('BANKNAME').getValue();
sql = sql + getAndConSql(sql, BANKNAME, " f.F_NO IN (select F_NO from Import_Finance_Bank where BANK= '" + BANKNAME + "')");
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'");
var BANKENDDATE_Min = form.findField('BANKENDDATE_Min').getRawValue();
sql = sql + getAndConSql(sql, BANKENDDATE_Min, "f.BANKENDDATE >= '" + BANKENDDATE_Min + "'");
var BANKENDDATE_Max = form.findField('BANKENDDATE_Max').getRawValue();
sql = sql + getAndConSql(sql, BANKENDDATE_Max, "f.BANKENDDATE <= '" + BANKENDDATE_Max + " 23:59:59'");
var CUSTSTLSTATUS = form.findField('CUSTSTLSTATUS').getValue();
sql = sql + getAndConSql(sql, CUSTSTLSTATUS, CUSTSTLSTATUS);
/*
var countryid = form.findField('countryid').getValue();
sql = sql + getAndConSql(sql, countryid, "m.countryid like '%" + countryid + "%'");
var seller = form.findField('seller').getRawValue();
sql = sql + getAndConSql(sql, seller, "M.seller like '%" + seller + "%'");*/
/*
var _p = this.MainTab.getActiveTab().id;
//alert(this.MainTab.getActiveTab().id);
var port = form.findField('port').getValue();
sql = sql + getAndConSql(sql, port, "m.port = " + port + "");
var Remind = form.findField('Remind').getValue();
sql = sql + getAndConSql(sql, Remind, Remind);
*/
return sql;
},
onGetremind: function (field, newValue, oldValue) {
if (newValue != null) {
this.storeList.load({
params: {
start: 0,
limit: this.PageSize,
sort: '',
condition: newValue
},
waitMsg: "正在查询数据...",
scope: this
});
}
},
OprationSwap: function () {
var ret = new Array();
ret[0] = this.OprationStatus;
ret[1] = this.storeList;
ret[2] = this.SelectedRecord;
return ret;
},
onExportClick: function (button, event) {
GridExportExcelPage(this.gridList);
},
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];
// if (record.data.BSSTATUS == 'true') {
// Ext.Msg.show({ title: '警告', msg: '业务已锁定,不允许删除!', icon: Ext.Msg.WARNING, 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: 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
}
}, this);
},
Print: function () {
var MainList = "";
var selectedRecords = [];
selectedRecords = this.gridList.selModel.getSelection();
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
if (MainList == "") { MainList = "'" + rec.get('F_NO') + "'"; }
else {
MainList = MainList + ",'" + rec.get('F_NO') + "'";
}
}
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 = 'Finance_YHBH'; //还款通知单
var sql1 = "SELECT f.*,dbo.[F_FinanceHTH](f.F_NO) 合同号 ";
sql1 = sql1 + " ,(select fullNAME from [COMPANY] where GID=(select company from import_main where ContractNo=(select top 1 contractno from Import_Finance_do where f.F_NO=F_NO))) 用证公司";
sql1 = sql1 + " ,(select min(arrivaldate) from import_main where ContractNo in(select contractno from Import_Finance_do where f.F_NO=F_NO)) 到港日";
sql1 = sql1 + " FROM import_finance f WHERE f.F_NO in(" + MainList + ")";
var sql2 = "";
// var sql3 = " select * from company where gid=(select top 1 companyid from ch_fee_do where BILLNO='" + billNo + "') ";
var sql3 = "";
var sql4 = "";
var sql5 = "";
var sql6 = "";
PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6);
}
});