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/Account/Viewsjs/Chfee_recvprocess/ChRecvprocessEditIndex.js

725 lines
24 KiB
JavaScript

Ext.namespace('Shipping');
Shipping.MsChRecvprocessEditIndex = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.MsChRecvprocessEditIndex.superclass.constructor.call(this);
};
Ext.extend(Shipping.MsChRecvprocessEditIndex, Ext.Panel, {
PageSize: 30,
OprationStatus: null, //仅当弹出界面时使用
SelectedRecord: null,
sqlcontext: '',
initUIComponents: function () {
this.StoreOpRange = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsOP',
proxy: { url: '/MvcShipping/MsBaseInfo/GetOpRang' }
});
this.StoreOpRange.load({ params: { optype: "modRecvSettlementList"} });
//定义数据集
this.storeList = Ext.create('Ext.data.Store', {
pageSize: this.PageSize,
model: 'MsChSettlement',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/Account/Chfee_recvprocess/GetDataList',
reader: {
id: 'BILLNO',
root: 'data',
totalProperty: 'totalCount'
}
}
});
//定义Grid
this.gridList = new Ext.grid.GridPanel({
store: this.storeList,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
columns: [{
sortable: true,
dataIndex: 'BILLNO',
header: '结算单号',
width: 120
}, {
sortable: true,
dataIndex: 'BILLSTATUSREF',
header: '状态',
width: 60
}, {
sortable: true,
dataIndex: 'CUSTOMERNAME',
header: '结算单位',
width: 120
}, {
sortable: true,
dataIndex: 'SETTLETYPEREF',
header: '结算方式',
width: 100
}, {
sortable: true,
dataIndex: 'CURR',
header: '结算币别',
width: 100
}, {
sortable: true,
dataIndex: 'AHSR_MONEY',
header: '实收金额',
align: 'right',
width: 120,
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: 'AMOUNT',
header: '结算金额',
align: 'right',
width: 120,
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: 'SETTLETIME',
header: '核销日期',
width: 100
}, {
sortable: true,
dataIndex: 'SETTLEUSERREF',
header: '核销人',
width: 100
}, {
sortable: true,
dataIndex: 'ACCOUNTREF',
header: '结算账户',
width: 150
}, {
sortable: true,
dataIndex: 'ISEXPORT',
header: '是否导出凭证',
width: 120
}, {
sortable: true,
dataIndex: 'REMARK',
header: '备注',
width: 160
}
],
// paging bar on the bottom
bbar: Ext.create('Ext.PagingToolbar', {
store: this.storeList,
displayInfo: true,
displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录',
emptyMsg: "没有数据"
})
});
this.gridList.addListener('itemdblclick', function (dataview, record, item, index, e, b) {
this.SelectedRecord = record;
this.OprationStatus = 'edit';
DsOpenEditWin('/Account/Chfee_recvprocess/Edit');
}, this);
//#region formSearch
//#region formSearch枚举参照相关
//#endregion
_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: 'BsNo',
enableKeyEvents: true,
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
}, {
fieldLabel: '结算单位',
name: 'CustName',
enableKeyEvents: true,
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
}, {
fieldLabel: '从结算日期',
format: 'Y-m-d',
xtype: 'datefield',
name: 'ExpDateBgn',
enableKeyEvents: true,
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
}, {
fieldLabel: '到结算日期',
format: 'Y-m-d',
xtype: 'datefield',
name: 'ExpDateEnd',
enableKeyEvents: true,
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
}
]
}
]//end items(fieldset 1)
}//end fieldset 1
]//end root items
});
//#endregion formSearch
//查询工具条
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: 'btnprint',
handler: function (button, event) {
this.Print();
},
scope: this
}, '-', {
id: 'btnConfirm',
text: '确认核销',
tooltip: '确认核销',
handler: function (button, event) {
this.onConfirmClick();
},
scope: this
}, '-', {
id: 'btnCancelConfirm',
text: '撤销确认',
tooltip: '撤销确认核销',
handler: function (button, event) {
this.onCancelConfirmClick();
},
scope: this
}, '-', {
id: 'btnSubmitAudit',
text: '提交审核',
tooltip: '提交核销审核',
handler: function (button, event) {
this.onSubmitAuditClick();
},
scope: this
}, '-', {
id: 'btnCancelSubmitAudit',
text: '撤销提交审核',
tooltip: '撤销提交审核',
handler: function (button, event) {
this.onCancelSubmitAuditClick();
},
scope: this
}
]
});
this.panelTop = new Ext.Panel({
layout: "border",
region: "north",
height: 80,
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, billtype: 1,self:1 });
}, this);
this.gridList.getSelectionModel().on('select', function (model, record, index) {
var op = record.data.SETTLEUSER;
var opname = record.data.SETTLEUSERREF;
var bsstatus = record.data.BILLSTATUS;
var btnESubmitAudit = Ext.getCmp('btnSubmitAudit');
var btnESubmitAuditBack = Ext.getCmp('btnCancelSubmitAudit');
var btnEConfirm = Ext.getCmp('btnConfirm');
var btnECancelConfirm = Ext.getCmp('btnCancelConfirm');
var records = DsStoreQueryBy(this.StoreOpRange, 'OPID', opname);
if (records.getCount() > 0) {
if (bsstatus == 10) {
btnESubmitAuditBack.enable();
} else {
btnESubmitAuditBack.disable();
}
if (bsstatus == 9) {
btnESubmitAudit.enable();
} else {
btnESubmitAudit.disable();
}
if (bsstatus == 8) {
btnEConfirm.enable();
} else {
btnEConfirm.disable();
}
if (bsstatus == 9) {
btnECancelConfirm.enable();
} else {
btnECancelConfirm.disable();
}
} else {
btnESubmitAudit.disable();
btnESubmitAuditBack.disable();
btnEConfirm.disable();
btnECancelConfirm.disable();
}
}, this);
this.onRefreshClick();
}, //end initUIComponents
onRefreshClick: function (button, event) {
var sql = this.getCondition();
sqlcontext = sql;
this.storeList.load({
params: { start: 0, limit: this.PageSize, sort: '', condition: sql, billtype: 1, self: 1 },
waitMsg: "正在查询数据...",
scope: this
});
},
onConfirmClick: 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.BILLNO;
if (rec.data.BILLSTATUS == '8') {
if (BILLNOStr == '')
BILLNOStr = BILLNO;
else {
BILLNOStr = BILLNOStr + ',' + BILLNO;
}
}
}
_this = this;
if (BILLNOStr == '') {
} else {
Ext.Ajax.request({
waitMsg: '正在添加数据...',
url: '/Account/Chfee_recvprocess/UpdateStatus',
params: {
bill: BILLNOStr,
status: 'Confirm'
},
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
});
}
},
onCancelConfirmClick: 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.BILLNO;
var isvou = rec.data.ISEXPORT;
if ((rec.data.BILLSTATUS == '9') ) {
if (BILLNOStr == '')
BILLNOStr = BILLNO;
else {
BILLNOStr = BILLNOStr + ',' + BILLNO;
}
}
}
_this = this;
if (BILLNOStr == '') {
} else {
Ext.Ajax.request({
waitMsg: '正在添加数据...',
url: '/Account/Chfee_recvprocess/UpdateStatus',
params: {
bill: BILLNOStr,
status: 'CancelConfirm'
},
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
});
};
},
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.BILLNO;
if (rec.data.BILLSTATUS == '9') {
if (BILLNOStr == '')
BILLNOStr = BILLNO;
else {
BILLNOStr = BILLNOStr + ',' + BILLNO;
}
}
}
_this = this;
if (BILLNOStr == '') {
} else {
Ext.Ajax.request({
waitMsg: '正在添加数据...',
url: '/Account/Chfee_recvprocess/UpdateStatus',
params: {
bill: BILLNOStr,
status: 'SubmitAudit'
},
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.BILLNO;
var isvou = rec.data.ISEXPORT;
if ((rec.data.BILLSTATUS == '10')) {
if (BILLNOStr == '')
BILLNOStr = BILLNO;
else {
BILLNOStr = BILLNOStr + ',' + BILLNO;
}
}
}
_this = this;
if (BILLNOStr == '') {
} else {
Ext.Ajax.request({
waitMsg: '正在添加数据...',
url: '/Account/Chfee_recvprocess/UpdateStatus',
params: {
bill: BILLNOStr,
status: 'CancelSubmitAudit'
},
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 = ' BILLTYPE=1 ';
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, "SETTLETIME >='" + expDateBgn + "'");
var expDateEnd = form.findField('ExpDateEnd').getRawValue();
sql = sql + getAndConSql(sql, expDateEnd, "SETTLETIME <='" + expDateEnd + "'");
return sql;
},
OprationSwap: function () {
var ret = new Array();
ret[0] = this.OprationStatus;
ret[1] = this.storeList;
ret[2] = this.SelectedRecord;
return ret;
},
Print: function () {
_this = this;
if (this.storeList.getCount() == 0) {
return;
}
Ext.Msg.wait('正在组织数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在组织数据...',
url: '/Account/Chfee_settlement/GetDataListStr',
scope: this,
params: {
condition: _this.sqlcontext,
billtype: 1, self: 1
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
var returnstr = jsonresult.data;
var printType = 'MSRECVETTLLIST';
var sql1 = returnstr;
var sql2 = "";
var sql3 = "";
var sql4 = "";
var sql5 = "";
var sql6 = "";
PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6);
} 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
});
}
}
});
}
});