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/Account/Viewsjs/Chfee_Invoicehexiao/ChInvoicehexiaoAudit.js

765 lines
26 KiB
JavaScript

2 years ago
Ext.namespace('Shipping');
Shipping.MsChInvoicehexiaoAudit = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.MsChInvoicehexiaoAudit.superclass.constructor.call(this);
};
Ext.extend(Shipping.MsChInvoicehexiaoAudit, Ext.Panel, {
PageSize: 8,
OprationStatus: null, //仅当弹出界面时使用
SelectedRecord: null,
isAudit: '',
initUIComponents: function () {
//定义数据集
this.storeList = Ext.create('Ext.data.Store', {
pageSize: this.PageSize,
model: 'MsChInvoicehexiao',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/Account/Chfee_Invoicehexiao/GetAuditDataList',
reader: {
id: 'BILLNO',
root: 'data',
totalProperty: 'totalCount'
}
}
});
//定义Grid
this.gridList = new Ext.grid.GridPanel({
store: this.storeList,
enableHdMenu: false,
height: 180,
region: 'north',
split: true,
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
columns: [{
sortable: true,
dataIndex: 'BILLNO',
header: '发票核销号',
width: 120
}, {
sortable: true,
dataIndex: 'BILLSTATUS',
header: '状态',
width: 160
}, {
sortable: true,
dataIndex: 'INVDATE',
header: '发票日期',
width: 160
}, {
sortable: true,
dataIndex: 'INVNO',
header: '发票号',
width: 160
}, {
sortable: true,
dataIndex: 'CUSTOMERNAME',
header: '开票单位',
width: 160
}, {
sortable: true,
dataIndex: 'CURR',
header: '币别',
width: 160
}, {
sortable: true,
dataIndex: 'AMOUNT',
header: '实际金额',
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
try {
var lsValue = usMoney(value, 2, '', false);
if (lsValue != "NaN") {
value = lsValue; if (parseFloat(lsValue) < 0) {
return '<SPAN style="COLOR: red">' + lsValue + '</SPAN>';
}
}
else {
return value;
}
}
catch (e) {
return value;
}
return value;
},
align: 'right',
width: 120
}, {
sortable: true,
dataIndex: 'INVAMOUNT',
header: '开票金额',
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
try {
var lsValue = usMoney(value, 2, '', false);
if (lsValue != "NaN") {
value = lsValue; if (parseFloat(lsValue) < 0) {
return '<SPAN style="COLOR: red">' + lsValue + '</SPAN>';
}
}
else {
return value;
}
}
catch (e) {
return value;
}
return value;
},
align: 'right',
width: 120
}, {
sortable: true,
dataIndex: 'TAXRATE',
header: '税率',
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
try {
var lsValue = usMoney(value, 2, '', false);
if (lsValue != "NaN") {
value = lsValue; if (parseFloat(lsValue) < 0) {
return '<SPAN style="COLOR: red">' + lsValue + '</SPAN>';
}
}
else {
return value;
}
}
catch (e) {
return value;
}
return value;
},
align: 'right',
width: 120
}, {
sortable: true,
dataIndex: 'TAX',
header: '税额',
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
try {
var lsValue = usMoney(value, 2, '', false);
if (lsValue != "NaN") {
value = lsValue; if (parseFloat(lsValue) < 0) {
return '<SPAN style="COLOR: red">' + lsValue + '</SPAN>';
}
}
else {
return value;
}
}
catch (e) {
return value;
}
return value;
},
align: 'right',
width: 120
}, {
sortable: true,
dataIndex: 'INVOICECUSTNAME',
header: '发票抬头',
width: 160
}, {
sortable: true,
dataIndex: 'OP',
header: '核销人',
width: 160
}, {
sortable: true,
dataIndex: 'REMARKS',
header: '备注',
width: 160
}
],
// paging bar on the bottom
bbar: Ext.create('Ext.PagingToolbar', {
store: this.storeList,
displayInfo: true,
displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录',
emptyMsg: "没有数据"
})
});
//#region formSearch
//#region formSearch枚举参照相关
//#endregion
this.storeAddDCType = Ext.create('Ext.data.Store', {
fields: ['DC', 'NAME']
});
this.storeAddDCType.add({ "DC": "", "NAME": "全部" });
this.storeAddDCType.add({ "DC": "1", "NAME": "待审核" });
this.storeAddDCType.add({ "DC": "2", "NAME": "已审核" });
this.comboxaddDCType = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '审核状态',
store: this.storeAddDCType,
valueField: 'DC',
displayField: 'NAME',
forceSelection: true,
name: 'DC',
value: '1'
});
this.formSearch = Ext.widget('form', {
frame: true,
region: 'center',
bodyPadding: 5,
fieldDefaults: {
margins: '2 2 2 2',
labelAlign: 'right',
flex: 1,
labelWidth: 80,
msgTarget: 'qtip'
},
items: [
{//fieldset 1
xtype: 'container',
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '发票号',
labelWidth: 80,
name: 'InvNo',
enableKeyEvents: true,
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
},{
fieldLabel: '发票核销号',
labelWidth: 90,
name: 'BsNo'
}, {
fieldLabel: '开票单位',
name: 'CustName'
}, {
fieldLabel: '从发票日期',
labelWidth: 90,
format: 'Y-m-d',
xtype: 'datefield',
name: 'ExpDateBgn'
}, {
fieldLabel: '到发票日期',
labelWidth: 90,
format: 'Y-m-d',
xtype: 'datefield',
name: 'ExpDateEnd'
}, this.comboxaddDCType
]
}
]//end items(fieldset 1)
}//end fieldset 1
]//end root items
});
this.storeBodyListdetail = Ext.create('Ext.data.Store', {
model: 'Chfee_do_detail',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/Account/Chfee_Invoicehexiao/GetBillList',
reader: {
id: 'BSNO,FEEDOID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.gridListdetail = new Ext.grid.GridPanel({
store: this.storeBodyListdetail,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
columns: [{
sortable: true,
dataIndex: 'BILLNO',
header: 'BILL',
hidden: true,
width: 100
}, {
sortable: true,
dataIndex: 'BSNO',
header: 'BSNO',
hidden: true,
width: 100
}, {
sortable: true,
dataIndex: 'FEEDOID',
header: 'FEEDOID',
hidden: true,
width: 100
}, {
sortable: true,
dataIndex: 'CUSTNO',
header: '委托编号',
width: 120
}, {
sortable: true,
dataIndex: 'MBLNO',
header: '主提单号',
width: 120
}, {
sortable: true,
dataIndex: 'CUSTOMERNAME',
header: '委托单位',
width: 100
}, {
sortable: true,
dataIndex: 'ETD',
header: '开船日期',
renderer: Ext.util.Format.dateRenderer('Y-m-d'),
width: 80
}, {
sortable: true,
dataIndex: 'BSSOURCE',
header: '业务来源',
width: 80
}, {
sortable: true,
dataIndex: 'FEENAME',
header: '费用名称',
width: 80
}, {
sortable: true,
dataIndex: 'FEETYPEREF',
header: '收付',
width: 40
}, {
sortable: true,
dataIndex: 'AMOUNT',
header: '核销金额',
width: 80,
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
try {
var lsValue = usMoney(value, 2, '', false);
if (lsValue != "NaN") {
value = lsValue; if (parseFloat(lsValue) < 0) {
return '<SPAN style="COLOR: red">' + lsValue + '</SPAN>';
}
}
else {
return value;
}
}
catch (e) {
return value;
}
return value;
}
}, {
sortable: true,
dataIndex: 'ORIGCURRENCY',
header: '原始币别',
width: 80
}, {
sortable: true,
dataIndex: 'ORIGAMOUNT',
header: '原始金额',
width: 80,
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
try {
var lsValue = usMoney(value, 2, '', false);
if (lsValue != "NaN") {
value = lsValue; if (parseFloat(lsValue) < 0) {
return '<SPAN style="COLOR: red">' + lsValue + '</SPAN>';
}
}
else {
return value;
}
}
catch (e) {
return value;
}
return value;
}
}, {
sortable: true,
dataIndex: 'SALE',
header: '揽货人',
width: 80
}
]
});
//#endregion formSearch
this.storeBodySum = Ext.create('Ext.data.Store', {
model: 'Chfee_do_sum',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/Account/Chfee_Invoicehexiao/GetBillSum',
reader: {
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.gridSum = new Ext.grid.GridPanel({
store: this.storeBodySum,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
tbar: [{
xtype: 'label',
width: 120,
height: 22,
text: '核销金额合计'
}],
columns: [{
sortable: true,
dataIndex: 'FEETYPEREF',
header: '收付',
width: 40
}, {
sortable: true,
dataIndex: 'CURRENCY',
header: '币 别',
width: 80
}, {
sortable: true,
dataIndex: 'AMOUNT',
header: '金额',
width: 80,
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
try {
var lsValue = usMoney(value, 2, '', false);
if (lsValue != "NaN") {
value = lsValue; if (parseFloat(lsValue) < 0) {
return '<SPAN style="COLOR: red">' + lsValue + '</SPAN>';
}
}
else {
return value;
}
}
catch (e) {
return value;
}
return value;
}
}
]
});
//查询工具条
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) {
this.onClearSql(button, event);
},
scope: this
}, '-', {
text: "审核通过",
iconCls: "btnadd",
handler: function (button, event) {
this.onAuditPassClick();
},
scope: this
},
'-',
{
text: "驳回提交",
iconCls: "btndelete",
handler: function (button, event) {
this.onAuditBackClick();
},
scope: this
}
]
});
this.panelTop = new Ext.Panel({
layout: "border",
region: "north",
height: 80,
items: [this.formSearch, this.panelBtn]
});
this.panelSum = new Ext.Panel({
layout: "border",
region: 'east',
width: 260,
split: true,
margin: '2 2',
items: [this.gridSum]
});
this.paneldetail = new Ext.Panel({
title: '发票核销明细',
layout: "border",
region: 'center',
split: true,
height: 420,
items: [
this.gridListdetail, this.panelSum
]
});
Ext.apply(this, {
items: [this.panelTop, this.gridList, this.paneldetail]
});
this.storeList.on('beforeload', function (store) {
var sql = this.getCondition();
Ext.apply(store.proxy.extraParams, { condition: sql, isaudit: this.isAudit });
}, this);
this.onRefreshClick();
this.storeList.on('load', function (store, records) {
if (store.getCount() > 0) {
this.gridList.getSelectionModel().select(0);
}
}, this);
_this = this;
this.gridList.getSelectionModel().on('select', function (model, record, index) {
var billno = record.data.BILLNO;
var sql = "";
sql = " BILLNO='" + billno + "'";
_this.storeBodyListdetail.load({ params: { condition: sql} });
_this.storeBodySum.load({ params: { condition: sql} });
}, this);
}, //end initUIComponents
onAuditPassClick: 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 bodyAddDatas = [];
for (var i = 0; i < selections.length; i++) {
var rec = selections[i];
var BILLSTATUS = rec.data.BILLSTATUS;
if (BILLSTATUS == '提交审核' || BILLSTATUS == '驳回提交') {
bodyAddDatas.push(rec);
} else {
Ext.Msg.show({ title: '提示', msg: '当前状态不允许审核!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
};
}
var jsonbodyAddDatas = ConvertRecordsToJsonAll(bodyAddDatas);
_this = this;
Ext.MessageBox.confirm('提示', '确定审核通过选中的业务吗?', function (btn) {
if (btn == 'yes') {
Ext.Msg.wait('正在审核数据...');
Ext.Ajax.request({
waitMsg: '正在审核数据...',
url: '/Account/Chfee_Invoicehexiao/AuditList',
params: {
data: jsonbodyAddDatas
},
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
_this.onRefreshClick();
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);
},
onAuditBackClick: 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 bodyAddDatas = [];
for (var i = 0; i < selections.length; i++) {
var rec = selections[i];
var BILLSTATUS = rec.data.BILLSTATUS;
if ((BILLSTATUS == '提交审核' || BILLSTATUS == '审核通过')) {
bodyAddDatas.push(rec);
} else {
Ext.Msg.show({ title: '提示', msg: '当前状态不允许驳回(只有提交审核、审核通过的未结算的发票核销允许驳回)!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
};
}
var jsonbodyAddDatas = ConvertRecordsToJsonAll(bodyAddDatas);
_this = this;
Ext.MessageBox.confirm('提示', '确定驳回选中的业务吗?', function (btn) {
if (btn == 'yes') {
Ext.Msg.wait('正在驳回数据...');
Ext.Ajax.request({
waitMsg: '正在驳回数据...',
url: '/Account/Chfee_Invoicehexiao/AuditBackList',
params: {
data: jsonbodyAddDatas
},
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
_this.onRefreshClick();
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);
},
onRefreshClick: function (button, event) {
var sql = this.getCondition();
this.storeList.load({
params: { start: 0, limit: this.PageSize, sort: '', condition: sql, isaudit: this.isAudit },
waitMsg: "正在查询数据...",
callback: function (r, options, success) {
if (success) {
if (r.length == 0) {
var sql = " BILLNO='11111111' ";
this.storeBodyListdetail.load({ params: { condition: sql} });
this.storeBodySum.load({ params: { condition: sql} });
}
}
},
scope: this
});
},
onClearSql: function () {
var form = this.formSearch.getForm();
form.reset();
}, //onDeleteClick
getCondition: function () {
var form = this.formSearch.getForm();
if (!form.isValid()) {
Ext.Msg.alert('提示', '查询条件赋值错误,请检查。');
return '';
}
var sql = '';
var InvNo = form.findField('InvNo').getValue();
sql = sql + getAndConSql(sql, InvNo, "INVNO like '%" + InvNo + "%'");
var customNo = form.findField('BsNo').getValue();
sql = sql + getAndConSql(sql, customNo, "BILLNO like '%" + customNo + "%'");
var custName = form.findField('CustName').getValue();
sql = sql + getAndConSql(sql, custName, "CUSTOMERNAME like '%" + custName + "%'");
var expDateBgn = form.findField('ExpDateBgn').getRawValue();
sql = sql + getAndConSql(sql, expDateBgn, "INVDATE >='" + expDateBgn + "'");
var expDateEnd = form.findField('ExpDateEnd').getRawValue();
sql = sql + getAndConSql(sql, expDateEnd, "INVDATE <='" + expDateEnd + "'");
this.isAudit = form.findField('DC').getValue();
return sql;
}
});