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/Payment/PaymentIndex.js

1170 lines
40 KiB
JavaScript

2 years ago

Ext.namespace('DsTruck');
DsTruck.PaymentIndex = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.DsTruck.PaymentIndex.superclass.constructor.call(this);
};
//201405161239
Ext.extend(DsTruck.PaymentIndex, Ext.Panel, {
PageSize: 500,
OprationStatus: null, //仅当弹出界面时使用
SelectedRecord: null,
VISIBLERANGE: 0,
OPERATERANGE: 0,
canedit: false,
FEEGID: "",
SELLER: "",
COMPANY: "",
CURRENCY: "",
initUIComponents: function () {
this.bodyDel = [];
//定义数据集
this.storeList = Ext.create('Ext.data.Store', {
pageSize: this.PageSize,
idProperty: 'GID',
model: 'Import_Paymentmb',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/Import/Payment/GetDataList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
//#region 相关参照
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: '用证公司',
forceSelection: true,
store: this.storeCompany,
name: 'company',
valueField: 'gid',
displayField: 'name'
});
this.storeport = Ext.create('DsExt.ux.RefEnumStore', {});
this.storeport.load({ params: { enumTypeId: 10} });
this.comboxPort = Ext.create('Ext.ux.form.field.BoxSelect', {
fieldLabel: '目的港',
autosize: true,
bodyPadding: 1,
flex: 2,
width: 80,
labelWidth: 90,
store: this.storeport,
queryMode: 'local',
triggerOnClick: false,
valueField: 'EnumValueId',
displayField: 'EnumValueName'
});
this.storeUser = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsTruckMng.ux.UserRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetUserRefList' }
});
this.storeUser.load({ params: { condition: ""} });
this.comboxOP = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '操作人',
forceSelection: true,
store: this.storeUser,
name: 'OP',
valueField: 'UserName',
displayField: 'CodeAndName'
});
this.storeSeller = Ext.create('DsExt.ux.RefTableStore', {
model: 'Tradermb',
proxy: { url: '/CommMng/BasicDataRef/GetTrader' }
});
this.storeSeller.load({ params: { condition: " isagent=1"} });
this.comboxSeller = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '贸易商',
forceSelection: true,
store: this.storeSeller,
name: 'seller',
valueField: 'name',
displayField: 'codename'
});
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('Ext.ux.form.field.BoxSelect', {
fieldLabel: '客户',
autosize: true,
bodyPadding: 7,
flex: 2,
labelWidth: 90,
store: this.storeBuyer,
queryMode: 'local',
triggerOnClick: false,
valueField: 'name',
displayField: 'codename'
});
//#endregion
this.formname = "Import_Payment";
this.column = [
{
dataIndex: 'GID',
header: 'GID',
width: 80, hidden: true
}, {
dataIndex: 'PaymentGID',
header: 'PaymentGID',
width: 80, hidden: true
},
{
dataIndex: 'COMPANYNAME',
header: '用证公司',
width: 80
}, {
dataIndex: 'id', hidden: true,
header: 'id',
width: 10
},
{
dataIndex: 'HTH',
header: '合同号',
width: 80
},
{
dataIndex: 'portRef',
header: '目的港',
width: 80
},
{
dataIndex: 'CURRENCY',
header: '币别',
width: 80
},
{
dataIndex: 'OP',
header: '操作人',
width: 80
},
{
dataIndex: 'BUYER',
header: '购货商',
width: 80
},
{
dataIndex: 'SELLER',
header: '供货方',
width: 80
},
{
dataIndex: 'REMARK',
header: '备注',
width: 120,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
},
{
dataIndex: 'CREATETIME',
header: '提交审核时间',
width: 120,
renderer: Ext.util.Format.dateRenderer('Y-m-d')
},
{
dataIndex: 'PAYTIME',
header: '付汇时间',
width: 80,
renderer: Ext.util.Format.dateRenderer('Y-m-d'),
editor: {
format: 'Y-m-d',
xtype: 'datefield',
selectOnFocus: true
}
},
{
dataIndex: 'CZDATE',
header: '操作时间',
width: 80,
renderer: Ext.util.Format.dateRenderer('Y-m-d'),
editor: {
format: 'Y-m-d',readOnly:true,
xtype: 'datefield',
selectOnFocus: true
}
},
{
dataIndex: 'AMOUNT',
header: '付汇金额',
width: 80
}, {
dataIndex: 'ReceiveAmount',
header: '收款金额(RMB)',
width: 100
}, {
dataIndex: 'EXCHANGERATE',
header: '汇率',
width: 100,
editor: {
xtype: 'numberfield',
selectOnFocus: true,
allowDecimals: true,
decimalPrecision: 4
}
},
{
dataIndex: 'DHF',
header: '电汇费',
width: 100,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
}, {
dataIndex: 'SXF',
header: '手续费',
width: 100,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
}, {
dataIndex: 'TotalAmount',
header: '合计',
width: 100,
disabled: true
}, {
dataIndex: 'ReceiveAgio',
header: '应收差额(RMB)',
width: 100,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
}, {
dataIndex: 'AMOUNT_DID',
header: '已做差额',
width: 100
},
{
dataIndex: 'CR_DR',
header: '结算单号(时间)',
width: 80
},
{
dataIndex: 'CF_CURRENCY',
header: '结算币别',
width: 80
},
{
dataIndex: 'SETTLEMENT',
header: '结算金额',
width: 80
}
];
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.cellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
this.PaymentCBModel = Ext.create('Ext.selection.CheckboxModel', { checkOnly: true });
Ext.grid.RowNumberer = Ext.extend(Ext.grid.RowNumberer, {
width: 50
});
this.gridList = new Ext.grid.GridPanel({
store: this.storeList,
enableHdMenu: false,
region: 'center',
trackResetOnLoad: true,
//height: 160,
title: '费用明细',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
viewConfig: {
enableTextSelection: true,
autoFill: true,
getRowClass: function (record, rowIndex, rowParams, store) {
var AMOUNT_DID = parseFloat(record.get('AMOUNT_DID'));
var feeStatus = 0;
if (AMOUNT_DID != 0) {
feeStatus = 1
} else {
feeStatus = 0
}
return DsTruck.MsChFeeGetRowClass(feeStatus);
}
},
plugins: [this.cellEditing],
stateful: false,
selModel: this.PaymentCBModel,
selType: 'cellmodel',
columns: [new Ext.grid.RowNumberer()],
bbar: [Ext.create('Ext.PagingToolbar', {
store: this.storeList,
displayInfo: true,
displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录',
emptyMsg: "没有数据"
}), this.Pagenum]
});
/////////////以下部分为获取存储的gridpanel显示样式
this.column = DsTruck.GetGridPanel(USERID, this.formname, this.column, 1);
this.column.unshift(new Ext.grid.RowNumberer());
this.gridList.reconfigure(this.storeList, this.column);
////////////////////////////
//#region formSearch
var _this = this;
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: 'HTH', flex: 1,
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
}, this.comboxCompany,
this.comboxOP,
this.comboxSeller
]
}
]//end items(fieldset 1)
}, //end fieldset 1
{//fieldset 2
xtype: 'container',
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [
this.comboxPort,
this.comboxBuyer]
}
]//end items(fieldset 2)
}//end fieldset 2
, {//fieldset 3
xtype: 'container',
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '从..付汇日',
format: 'Y-m-d',
xtype: 'datefield',
name: 'PAYTIME_min',
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
}, {
fieldLabel: '到..付汇日',
format: 'Y-m-d',
xtype: 'datefield',
name: 'PAYTIME_max',
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
}, {
fieldLabel: '从..操作日',
format: 'Y-m-d',
xtype: 'datefield',
name: 'CZDATE_min',
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
}, {
fieldLabel: '到..操作日',
format: 'Y-m-d',
xtype: 'datefield',
name: 'CZDATE_max',
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
}]
}
]//end items(fieldset 3)
}//end fieldset 3
]//end root items
});
//查询工具条
this.panelBtn = new Ext.Panel({
region: "north",
tbar: [
{
text: "执行查询",
iconCls: "btnrefresh",
handler: function (button, event) {
this.onRefreshClick(button, event);
},
scope: this
},
{
text: "导出Excel",
id: "btnExportExcel",
iconCls: 'btnexportexcel',
handler: function (button, event) {
this.onExportClick(button, event);
},
scope: this
},
{
text: "保存列表样式",
id: "btntest",
handler: function (button, event) {
//this.column = DsTruck.SaveGridPanel(USERID, this.formname, this.gridList.columns, this.column, 1, true);
var tempcolumns = this.gridList.columns;
DsTruck.SaveGridPanel(USERID, this.formname, tempcolumns, this.column, 1, false);
},
scope: this
}, '-', /*{
text: '增加明细',
tooltip: '增加明细',
iconCls: "btnadddetail",
handler: function (button, event) {
this.onAddProjectClick(button, event);
},
scope: this
}, {
text: '删除明细',
tooltip: '删除明细',
iconCls: "btndeletedetail",
handler: function (button, event) {
this.onDelProjectClick(button, event);
},
scope: this
},*/{
id: "btnSave",
text: '保存更改',
tooltip: '保存更改',
iconCls: "btnsave",
handler: function (button, event) {
this.Save();
//alert(USERID);
},
scope: this
}, {
id: "btnMakeFee",
text: '生成选定差额至业务应收',
tooltip: '保存更改',
iconCls: "btnMakeFee",
handler: function (button, event) {
this.MakeFee();
//alert(USERID);
},
scope: this
}, '-', {
text: "打印境外汇款申请书",
iconCls: "btnadd", id: "PrintSQS",
handler: function (button, event) {
var form = this.formPrint.getForm();
var XH = form.findField('XH'); //现汇
XH.setRawValue("0");
this.winPrintShow.show();
},
scope: this
}, '-', {
text: "打印对账单",
iconCls: "btnadd", id: "PrintDZD",
handler: function (button, event) {
this.Print_DZD();
},
scope: this
}
]
});
//#endregion
me = this;
this.formPrint = 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: '现汇金额',
xtype: 'textfield',
name: 'XH'
}
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '交易附言',
xtype: 'textfield',
name: 'FY'
}
]
}
]//end items(fieldset 1)
}//end fieldset 1
]//end root items
});
this.winPrintShow = Ext.create('Ext.window.Window', {
title: "打印境外汇款申请书",
width: 400,
//height : 120,
//plain : true,
iconCls: "addicon",
resizable: true,
// 是否可以拖动
// draggable:false,
collapsible: true, // 允许缩放条
closeAction: 'close',
closable: true,
modal: 'true',
buttonAlign: "center",
bodyStyle: "padding:0 0 0 0",
items: [this.formPrint],
buttons: [{
text: "打印境外汇款申请书",
minWidth: 70,
handler: function () {
var selectedRecords = me.gridList.selModel.getSelection();
if (selectedRecords.length == 0) {
Ext.Msg.show({ title: '提示', msg: '没有选择要打印的业务!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
};
me.FEEGID = "";
var COMPANY = [];
var SELLER = [];
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
if (me.FEEGID == "") {
me.FEEGID = me.FEEGID + "'" + rec.get('GID') + "'";
} else {
me.FEEGID = me.FEEGID + ",'" + rec.get('GID') + "'";
}
if (COMPANY[0] != rec.get('COMPANY')) {
COMPANY.push(rec.get('COMPANY'));
}
if (SELLER[0] != rec.get('SELLER')) {
SELLER.push(rec.get('SELLER'));
}
}
if (COMPANY.length > 1) {
alert("只能有一个用证公司");
return;
} else {
me.COMPANY = COMPANY[0];
}
if (SELLER.length > 1) {
alert("只能有一个结算对象");
return;
} else {
me.SELLER = SELLER[0];
}
//window.DsTruck.PaymentIndex.onPrintClick();
me.onPrintClick();
}
}, {
text: "关闭",
minWidth: 70,
handler: function () {
me.winPrintShow.close();
}
}]
});
this.panelTop = new Ext.Panel({
layout: "border",
region: "north",
height: 30,
items: [this.panelBtn]
});
this.panelSearch = new Ext.Panel({
layout: "border",
region: "north",
height: 110,
autoSize: true,
items: [this.formSearch]
});
Ext.apply(this, {
items: [this.panelTop, this.panelSearch
, this.gridList
]
});
this.storeList.on('beforeload', function (store) {
if (!this.checkSearchCondition())
return;
var sql = this.getCondition();
Ext.apply(store.proxy.extraParams, { condition: sql });
}, this);
var me = this;
this.cellEditing.on('beforeedit', function (editor, e) {
//alert("beforeedit");
return me.canedit;
}, this);
this.gridList.on('edit', function (editor, e, eOpts) {
this.ProjectAfterEdit(editor, e, eOpts);
}, this);
_this.onRefreshClick();
}, //end initUIComponents
ProjectAfterEdit: function (editor, e, eOpts) {
if (e.field == 'ISOVER') {
var records = DsStoreQueryBy(this.storeTF, 'TFID', e.value);
if (records.getCount() > 0) {
var data = records.getAt(0).data;
e.record.set('ISOVER_DEF', data.TFName);
} else {
e.record.set('ISOVER_DEF', '');
}
}
if (e.field == 'ReceiveAmount' || e.field == 'DHF' || e.field == 'SXF' || e.field == 'AMOUNT' || e.field == 'EXCHANGERATE' || e.field == 'TotalAmount') {//TotalAmount
var receiveAmount = parseFloat(e.record.get('ReceiveAmount'));//收款金额
var dhf = parseFloat(e.record.get('DHF'));//电汇费
var sxf = parseFloat(e.record.get('SXF'));//手续费
var amount = parseFloat(e.record.get('AMOUNT'));//付汇金额
var exchangerate = parseFloat(e.record.get('EXCHANGERATE'));//汇率
var totalAmount = Add(Mul(exchangerate, amount), Add(dhf, sxf));
var receiveAgio = Cut(totalAmount, receiveAmount);
e.record.set('TotalAmount', totalAmount);
e.record.set('ReceiveAgio', receiveAgio);
}
if (e.field == 'PAYTIME') {
e.record.set('PAYTIME', Ext.util.Format.date(e.record.get('PAYTIME'), 'Y-m-d'));
}
if (e.field == 'CZDATE') {
e.record.set('CZDATE', Ext.util.Format.date(e.record.get('CZDATE'), 'Y-m-d'));
}
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 printdate = GetDateStr(0);
if (e.record.get('CZDATE') == "") {
e.record.set('CZDATE', printdate);
}
},
onRefreshClick: function (button, event) {
if (!this.checkSearchCondition())
return;
var sql = this.getCondition();
this.PageSize = this.Pagenum.getValue();
this.storeList.pageSize = this.PageSize;
this.storeList.load({
params: { start: 0, limit: this.PageSize, condition: sql },
waitMsg: "正在查询数据...",
scope: this
});
var me = this;
Ext.Ajax.request({
waitMsg: '正在查询用户权限...',
url: '/CommMng/BasicDataRef/GetAuthorityRange',
params: {
modName: "mod_Payment",
USERID: USERID
},
callback: function (options, success, response) {
if (success) {
var result = Ext.JSON.decode(response.responseText);
rec = result.data;
//alert(rec.VISIBLERANGE);
//alert(rec.OPERATERANGE);
//可操作OPERATERANGE为012则可以修改3不能修改
this.VISIBLERANGE = rec.VISIBLERANGE;
this.OPERATERANGE = rec.OPERATERANGE;
if (this.OPERATERANGE == "0" || this.OPERATERANGE == "1" || this.OPERATERANGE == "2") {
me.canedit = true;
} else
if (this.OPERATERANGE == "3") {
me.canedit = false;
} else {//空
me.canedit = false;
}
}
else
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
},
scope: this
}); //request over
this.bodyDel = [];
},
getCondition: function () {
var form = this.formSearch.getForm();
if (!form.isValid()) {
Ext.Msg.alert('提示', '查询条件赋值错误,请检查。');
return '';
}
var sql = '';
var HTH = form.findField('HTH').getValue();
sql = sql + getAndConSql(sql, HTH, " HTH like '%" + HTH + "%'");
var port = this.comboxPort.getValue();
if (port != "") {
sql = sql + getAndConSql(sql, port, "port in (" + port + ")");
}
var company = form.findField('company').getValue();
sql = sql + getAndConSql(sql, company, "company = '" + company + "'");
var seller = form.findField('seller').getRawValue();
sql = sql + getAndConSql(sql, seller, "seller like '%" + seller + "%'");
var buyer = this.getStrValue(this.comboxBuyer.getValue());
sql = sql + getAndConSql(sql, buyer, "buyer in (" + buyer + ")");
var OP = form.findField('OP').getValue();
sql = sql + getAndConSql(sql, OP, "OP = '" + OP + "'");
var PAYTIME_min = form.findField('PAYTIME_min').getRawValue();
sql = sql + getAndConSql(sql, PAYTIME_min, "(PAYTIME >= '" + PAYTIME_min + "' )");
var PAYTIME_max = form.findField('PAYTIME_max').getRawValue();
sql = sql + getAndConSql(sql, PAYTIME_max, "(PAYTIME <= '" + PAYTIME_max + " 23:59:59' )");
var CZDATE_min = form.findField('CZDATE_min').getRawValue();
sql = sql + getAndConSql(sql, CZDATE_min, "CZDATE >= '" + CZDATE_min + "' ");
var CZDATE_max = form.findField('CZDATE_max').getRawValue();
sql = sql + getAndConSql(sql, CZDATE_max, "CZDATE <= '" + CZDATE_max + " 23:59:59'");
return sql;
},
checkSearchCondition: function () {
/*var form = this.formSearch.getForm();
if (!form.isValid()) {
Ext.Msg.alert('提示', '查询条件赋值错误,请检查。');
return false;
}*/
return true;
},
onExportClick: function (button, event) {
GridExportExcelPage(this.gridList);
},
getStrValue: function (list) {
var _list = [];
for (var _i = 0; _i < list.length; _i++) {
_list.push("'" + list[_i] + "'");
}
return _list;
},
Save: function (type) {
//费用
var bodyList = [];
for (i = 0; i < this.storeList.getCount(); i += 1) {
var member = this.storeList.getAt(i);
bodyList.push(member);
/*
var BLNO = member.data.BLNO;
var PROJECTNO = member.data.PROJECTNO;
if (BLNO == ''||PROJECTNO == '') {
Ext.Msg.show({ title: '警告',
msg: '项目单号和项目编码均不允许为空,请修改后再保存',
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
return;
}*/
};
var jsonBody = ConvertRecordsToJson(bodyList);
var jsonDelBody = ConvertRecordsToJsonAll(this.bodyDel);
if (jsonBody == '' && jsonDelBody == '') {
return;
}
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/Import/Payment/Save',
scope: this,
params: {
PaymentBody: jsonBody,
PaymentDelBody: jsonDelBody
},
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.storeList.commitChanges();
} 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
});
}
//alert('03');
}
});
},
onPrintClick: function () {
var form = this.formPrint.getForm();
var XH = form.findField('XH').getRawValue();
var FY = form.findField('FY').getValue();
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 printdate = GetDateStr(0);
var printType = 'Print_HKSQS'; //汇款申请书
var sql1 = "select sum(amount)," + XH + " as xh,'" + FY + "' as FY,'" + printdate + "' as madedate,currency from import_payment where gid in(" + this.FEEGID + ") group by currency";
var sql2 = "select c.*,(select top 1 account from sys_bank where codename=c.name and remark like '%付汇%') as account from [company] c where name='" + this.COMPANY + "'";
var sql3 = "select * from info_client where shortname='" + this.SELLER + "'";
var sql4 = "select * from info_client_contact where linkid=(select gid from info_client where shortname='" + this.SELLER + "')";
var sql4 = sql4 + " and showname='银行' ";
var sql5 = " select substring(cc.country,1,charindex('(' ,cc.country )-1) country,m.* from import_main m ";
var sql5 = sql5 + " left join code_country cc on cc.COUNTRYID=m.countryid ";
var sql5 = sql5 + " where contractno=(select top 1 bsno from ch_fee where gid in(" + this.FEEGID + "))";
//var sql6 = "select '" + printdate + "' as madedate";
var sql6 = "declare @S varchar(100) ";
var sql6 = sql6 + " select @S=isnull(@S,'')+','+HTH from import_main where contractno in( ";
var sql6 = sql6 + " select bsno from ch_fee where gid in(" + this.FEEGID + ")) select substring(@S,2,100) HTHs ";
PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6);
}
,
Print_DZD: function () { //不知道什么用途的对账单_曹青
var MainList = "";
var MainListString = "";
var selectedRecords = [];
selectedRecords = this.gridList.selModel.getSelection();
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
if (MainList == "") { MainList = "" + rec.get('id') + ""; }
else {
MainList = MainList + "," + rec.get('id') + "";
}
}
if (MainList == "") {
Ext.Msg.show({ title: '错误', msg: '选中至少一个记录', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
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 printdate = GetDateStr(0);
var printType = 'XXH_FHDZ'; //付外汇记录对账
var sql1 = " update import_main set hth='' where isdelete=1 and hth<>'' ";
sql1 = sql1 + " select ip.id,ip.gid ,c.NAME [company],M.HTH,ip.AMOUNT,ip.currency,m.op,M.buyer buyer,m.seller ";
sql1 = sql1 + " ,dbo.trimdate(ip.createtime) createtime,ip.remark,dbo.f_danhao(ip.gid,1) CR_DR ";
sql1 = sql1 + " ,cf.currency CF_currency,cf.settlement,ip.EXCHANGERATE,ip.DHF,ip.SXF,ip.ReceiveAgio,ip.TotalAmount ";
sql1 = sql1 + " ,(select sum(amount) amount from ch_fee where bsno= ";
sql1 = sql1 + " (select top 1 contractno from import_main where hth=M.hth and m.ISDELETE=0) ";
sql1 = sql1 + " and feetype=1 and (feename=ip.feename or remark like '%'+ip.feename+'%' )) ReceiveAmount ";
sql1 = sql1 + " ,(select EnumValueName from tSysEnumValue where EnumTypeID=10 and EnumValueID=m.port) Port ";
sql1 = sql1 + " ,case when ip.Receiveagio>0 then '付我司' when ip.Receiveagio<0 then '退贵司' else '' end PaySide ";
sql1 = sql1 + " ,case ip.feename when '预付款' then dbo.trimdate(m.prepaydate) else dbo.trimdate(m.paydate) end paytime ";
sql1 = sql1 + " from Import_Payment ip ";
sql1 = sql1 + " left join ch_fee cf on cf.gid=ip.gid ";
sql1 = sql1 + " left join import_main m on m.contractno=cf.BSNO and m.ContractNo<>'' ";
sql1 = sql1 + " left join [company] c on c.gid=m.company where ip.id in(" + MainList + ")";
var sql2 = "select '" + SHOWNAME + "' showname,'" + printdate + "' printdate";
var sql3 = "";
var sql4 = "";
var sql5 = "";
var sql6 = "";
var sql6 = sql6 + "";
var sql6 = sql6 + "";
PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6);
}
,
MakeFee: function (button, event) { //初始化应收应付,
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 msgBox = Ext.create('Ext.window.MessageBox', { autoScroll: true, minHeight: 150, width: 300 });
msgBox.show({ title: '提示', icon: Ext.window.MessageBox.INFO, buttons: Ext.Msg.OK, closable: true});
var htmlArray = ['<table cellspacing="0" cellpadding="0" border="0" style="width:100%;text-align:left"><thead><tr><td>序号</td><td>合同号</td><td>结果</td></tr></thead>'];
htmlArray.push('<tbody>');
htmlArray.push('</tbody>');
htmlArray.push('</table>');
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i].data;
if (rec.PaymentGID !== rec.GID) {
//var receiveAgio = rec.ReceiveAgio;
var receiveAgio = Mul(rec.EXCHANGERATE, rec.AMOUNT);
receiveAgio = Add(receiveAgio, rec.DHF);
receiveAgio = Add(receiveAgio, rec.SXF);
receiveAgio = Add(receiveAgio,-rec.ReceiveAmount);
if (receiveAgio > 0) {
this.addChFee(rec.HTH,
rec.BUYER,
1,
"RMB",
1,
rec.FEENAME+"差额",
receiveAgio,
1,
rec.FEENAME + "差额 = " +
rec.EXCHANGERATE +
" * " +
rec.AMOUNT +
" + ( " +
rec.DHF +
" + " +
rec.SXF +
" ) - " +
rec.ReceiveAmount,
"", null,
rec.GID, selectedRecords[i], htmlArray, msgBox);
}
else if (receiveAgio < 0) {
this.addChFee(rec.HTH,
rec.BUYER,
1,
"RMB",
1,
rec.FEENAME + "差额",
receiveAgio,
1,
rec.FEENAME + "差额 = " +
rec.EXCHANGERATE +
" * " +
rec.AMOUNT +
" + ( " +
rec.DHF +
" + " +
rec.SXF +
" ) - " +
rec.ReceiveAmount,
"",null,
rec.GID, selectedRecords[i], htmlArray,msgBox);
}
else {
htmlArray.splice(htmlArray.length-2,0,'<tr><td>'+(htmlArray.length-3) +'</td><td>' + rec.HTH + '</td><td>差额为0不需要生成</td></tr>');
msgBox.update(htmlArray.join(''));
}
} else {
htmlArray.splice(htmlArray.length - 2,0,'<tr><td>' + (htmlArray.length - 3) + '</td><td>' + rec.HTH + '</td><td>该差额已存在</td></tr>');
msgBox.update(htmlArray.join(''));
}
}
},
addChFee: function (HTH, _CustomerName, FeeType, Currency, Exchangerate, FeeName, price, Quantity, Remark, FeeDescription, feedate, gid, rec, htmlArray,msgBox) {
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;
if (feedate== null) {
enterDate = GetDateStr(0);
} else {
enterDate = feedate;
}
var field =
" (GId,BsNo,FeeStatus,FeeType,FeeName,FeeDescription,CustomerType,CustomerName,Unit,UnitPrice,Quantity ";
field = field +
" ,Amount,Currency,ExChangerate,Reason,Remark,Commissionrate,Settlement,Invoice,OrderAmount,OrderInvoice ";
field = field +
" ,Auditoperator,EnterOperator,EnterDate,MODIFIEDUSER,MODIFIEDTIME,DebitNo,IsDebit,IsOpen,IsAdvancedpay,IsInvoice,FeeFrt,IsCrmOrderFee,AuditStatus,PaymentGID) ";
var _value = " values ('" + NewGuid() + "',(select contractno from import_main where hth='" + HTH + "'),0," + FeeType + ",'" + FeeName + "','','','" + _CustomerName + "',''," + price + "," + Quantity + "";
_value = _value + "," + price + "*" + Quantity + ",'" + Currency + "'," + Exchangerate + ",'','" + Remark + "',0,0,0,0,0";
_value = _value + ",'','" + USERID + "','" + enterDate + "','" + USERID + "','" + enterDate + "','',0,0,0,0,'PP',0,0,'" + gid+"')";
var SQL = " Insert into ch_fee " + field + _value;
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/Import/ImportSync/SaveSync',
scope: this,
params: {
SQL: SQL
},
callback: function (options, success, response) {
if (success) {
htmlArray.splice(htmlArray.length - 2,0,'<tr><td>' + (htmlArray.length - 3) + '</td><td>' + HTH + '</td><td>生成成功</td></tr>');
msgBox.update(htmlArray.join(''));
rec.set('PaymentGID', gid);
} else {
Ext.Msg.show({ title: '请重试',
msg: '服务器响应出错',
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
}
}
});
}
});