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_ForeignSettlement/ChSettlementView.js

740 lines
22 KiB
JavaScript

Ext.namespace('Shipping');
Shipping.MsSettlementView = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.MsSettlementView.superclass.constructor.call(this);
};
Ext.extend(Shipping.MsSettlementView, Ext.Panel, {
ParentWin: null,
OpStatus: 'add',
StoreList: null,
EditRecord: null,
addstore: false,
PageSize: 30,
initUIComponents: function () {
this.serialNo = 0;
this.workSerialNo = 0;
this.bodyDel = [];
this.FeeSql = '';
this.BillSql = '';
this.DuiBillSql = '';
this.IsDebit = '0';
this.StoreLockOp = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsFeeOP',
proxy: { url: '/MvcShipping/MsBaseInfo/GetOpIDRang' }
});
this.StoreUnLockOp = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsFeeOP',
proxy: { url: '/MvcShipping/MsBaseInfo/GetOpIDRang' }
});
//#region 编辑form
//枚举参照相关(编辑form)
//表参照相关(编辑form)
this.storeCustCode = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CustomRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetCustomRefList' }
});
this.storeCustCode.load({ params: { condition: ""} });
this.comboxCustCode = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '结算单位',
store: this.storeCustCode,
allowBlank: false,
forceSelection: true,
name: 'CUSTOMERNAME',
valueField: 'CustName',
displayField: 'CodeAndName',
listeners: {
scope: this,
'select': function (combo, records, eOpts) {
if (records.length > 0) {
var CUSTOMERNAME = this.formEdit.getForm().findField('CUSTOMERNAME').getValue();
if (CUSTOMERNAME == '') return;
var CUSTNAME = this.formSearch.getForm().findField('CUSTNAME');
var tmpcust = CUSTNAME.getValue();
if (tmpcust == '' || tmpcust == null || tmpcust == undefined) {
CUSTNAME.setValue(CUSTOMERNAME);
}
}
}
}
});
this.StoreOpRange = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsOP',
proxy: { url: '/MvcShipping/MsBaseInfo/GetOpRang' }
});
this.StoreCurr = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsFeeCurr',
proxy: { url: '/MvcShipping/MsChFee/GetFeeCurrList' }
});
this.StoreCurr.load({ params: { condition: ""} });
this.comboxCurr = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '币别',
store: this.StoreCurr,
forceSelection: true,
allowBlank: false,
name: 'CURR',
valueField: 'CURR',
displayField: 'CURR',
listeners: {
scope: this,
'select': function (combo, records, eOpts) {
if (records.length > 0) {
var curr = this.formACCOUNTS.getForm().findField('ACCOUNTS_CURRENCY');
curr.setValue(records[0].data.CURR);
var curr = this.formPREPAY.getForm().findField('PREPAY_CURRENCY');
curr.setValue(records[0].data.CURR);
var curr = this.formAHSR.getForm().findField('AHSR_CURRENCY');
curr.setValue(records[0].data.CURR);
var curr = this.formFINANCIAL.getForm().findField('FINANCIAL_CURRENCY');
curr.setValue(records[0].data.CURR);
var curr = this.formADVANCE.getForm().findField('ADVANCE_CURRENCY');
curr.setValue(records[0].data.CURR);
}
}
}
});
this.StoreStlMode = Ext.create('DsExt.ux.RefTableStore', {
model: 'STLMODE',
proxy: { url: '/MvcShipping/MsBaseInfo/GetStlModeList' }
});
this.StoreStlMode.load({ params: { condition: ""} });
this.comboxStlMode = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '结算方式',
store: this.StoreStlMode,
forceSelection: true,
name: 'SETTLETYPE',
valueField: 'STLCODE',
displayField: 'STLNAME'
});
this.StoreBANK = Ext.create('DsExt.ux.RefTableStore', {
model: 'BANK',
proxy: { url: '/MvcShipping/MsBaseInfo/GetBANKList' }
});
this.StoreBANK.load({ params: { condition: ""} });
this.comboxBANK = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '银行账号',
store: this.StoreBANK,
forceSelection: true,
name: 'ACCOUNT',
valueField: 'GID',
displayField: 'BANKNAME'
});
//编辑form
this.formEdit = Ext.widget('form', {
region: 'center',
frame: true,
bodyPadding: 3,
trackResetOnLoad: true,
// autoScroll: true,
fieldDefaults: {
margins: '2 2 2 2',
labelAlign: 'right',
flex: 1,
labelWidth: 90,
msgTarget: 'qtip'
},
items: [
{//fieldset 1
xtype: 'fieldset',
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: 'GID',
name: 'GID', flex: 0, hidden: true, margins: '0'
}, {
fieldLabel: 'BILLSTATUS',
name: 'BILLSTATUS', flex: 0, hidden: true, margins: '0'
}, {
fieldLabel: 'BILLDATE',
name: 'BILLDATE', flex: 0, hidden: true, margins: '0'
}, {
fieldLabel: 'SETTLEUSER',
name: 'SETTLEUSER', flex: 0, hidden: true, margins: '0'
}, {
fieldLabel: 'COMPANYID',
name: 'COMPANYID', flex: 0, hidden: true, margins: '0'
}, {
fieldLabel: 'SETTLEMODE',
name: 'SETTLEMODE', flex: 0, hidden: true, margins: '0'
}, {
fieldLabel: 'BILLTYPE',
name: 'BILLTYPE', flex: 0, hidden: true, margins: '0'
}, {
fieldLabel: 'ISEXPORT',
name: 'ISEXPORT', flex: 0, hidden: true, margins: '0'
},
{
fieldLabel: '结算单号',
readOnly: true,
name: 'BILLNO'
}, {
fieldLabel: '状态',
readOnly: true,
name: 'BILLSTATUSREF'
}, this.comboxCustCode, {
fieldLabel: '结算日期',
// readOnly: true,
format: 'Y-m-d',
xtype: 'datefield',
name: 'SETTLETIME'
}, {
fieldLabel: '结算人',
readOnly: true,
name: 'SETTLEUSERREF'
}
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [this.comboxCurr, {
fieldLabel: '金额',
readOnly: true,
name: 'AMOUNT'
}, this.comboxStlMode, this.comboxBANK, {
fieldLabel: '凭证备注',
name: 'VOUCHERNO'
}]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '备注',
name: 'REMARK'
}]
}
]//end items(fieldset 1)
}//end fieldset 1
]//end root items
}); //end this.formEdit
//#endregion
//#region 按钮Toolbar
this.panelBtn = new Ext.Panel({
region: "north",
tbar: [
{
id: 'Close',
text: "关闭",
handler: function (button, event) {
window.close();
},
scope: this
}
]
}); //end 按钮Toolbar
//#endregion
//#region 明细表
//明细表表格相关
this.GridCheckBoxModel = Ext.create('Ext.selection.CheckboxModel');
//明细表-数据集
this.storeBodyList = Ext.create('Ext.data.Store', {
model: 'Chfee_do_detail',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/Account/Chfee_Foreignsettlement/GetBillList',
reader: {
id: 'BSNO,FEEDOID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
//明细表表格
this.gridListCellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
this.gridList = new Ext.grid.GridPanel({
store: this.storeBodyList,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
selModel: this.GridCheckBoxModel,
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: 100
}, {
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
}, {
sortable: true,
dataIndex: 'ORIGCURRENCY',
header: '原始币别',
width: 80
}, {
sortable: true,
dataIndex: 'ORIGAMOUNT',
header: '原始金额',
width: 80
}, {
sortable: true,
dataIndex: 'SALE',
header: '揽货人',
width: 80
}, {
sortable: true,
dataIndex: 'ENTERP',
header: '经营单位',
width: 80
}, {
sortable: true,
dataIndex: 'CUSTOMNO',
header: '报关单号',
width: 108
}
]
});
this.storeBodySum = Ext.create('Ext.data.Store', {
model: 'Chfee_do_sum',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/Account/Chfee_Foreignsettlement/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
}
]
});
this.storeAddFeeList = Ext.create('Ext.data.Store', {
pageSize: this.PageSize,
model: 'MsChFeeAddBillFee',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/Account/Chfee_Foreignsettlement/GetFeeDataList',
reader: {
id: 'BSNO',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.AddFeeGridCheckBoxModel = Ext.create('Ext.selection.CheckboxModel');
this.cellEditingFee = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1,
listeners: {
'edit': function (editor, e) {
}
}
});
_this = this;
this.CurrGroup = new Ext.form.RadioGroup({
id: 'CurrGroup',
xtype: 'radiogroup',
fieldLabel: '折算币别',
columns: 2,
items: [
{ boxLabel: 'RMB', name: 'Curr', inputValue: 'RMB', checked: true },
{ boxLabel: 'USD', name: 'Curr', inputValue: 'USD' }
]
});
_this = this;
this.panelService = new Ext.Panel({
layout: "border",
region: 'center',
margin: '2 2',
items: [this.gridList]
});
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,
items: [
this.panelService, this.panelSum
]
});
//#endregion 明细表
//#endregion
//#region 布局
//控件布局
this.panelTop = new Ext.Panel({
layout: "border",
region: "north",
height: 130,
items: [this.panelBtn, this.formEdit]
});
this.panelBody = new Ext.Panel({
title: "结算明细",
layout: "border",
region: "center",
items: [this.paneldetail]
});
this.tabpanel = new Ext.TabPanel
({
activeTab: 0,
autoWidth: true,
border: false,
frame: false,
region: 'center',
id: "TabPanelID",
enableTabScroll: true,
items:
[
this.panelBody
]
});
Ext.apply(this, {
items: [this.panelTop, this.tabpanel]
});
//#endregion
//绑定查询窗体
this.ParentWin = window.parent.opener._this;
//初始化数据
this.InitData();
//绑定事件
var billno = '*';
if (this.opStatus == 'edit') {
billno = this.editRecord.get('BILLNO');
};
this.storeBodyList.on('beforeload', function (store) {
var sql = " BILLNO='" + billno + "'";
Ext.apply(store.proxy.extraParams, { condition: sql });
}, this);
this.storeBodyList.on('load', function (store, records) {
if (store.getCount() > 0) {
this.gridList.getSelectionModel().select(0);
}
}, this);
}, //end initUIComponents
InitData: function () {
this.opStatus = 'add';
var condition = '';
if (this.ParentWin) {
var ret = this.ParentWin.OprationSwap();
this.opStatus = 'edit';
this.StoreList = ret[1];
this.editRecord = ret[2];
}
condition = " BILLNO='" + this.editRecord.get('BILLNO') + "'";
this.LoadData(this.opStatus, condition);
}, //end InitData
LoadData: function (opstatus, condition) {
this.serialNo = 0;
this.workSerialNo = 0;
this.bodyDel = [];
this.opStatus = opstatus;
var billno = '*';
if (this.opStatus == 'edit') {
billno = this.editRecord.get('BILLNO');
};
_this = this;
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/Account/Chfee_Foreignsettlement/GetData',
params: {
handle: opstatus,
condition: condition
},
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;
}
var data = result.data;
_this.formEdit.getForm().findField('BILLSTATUS').setDisabled(false);
_this.formEdit.getForm().findField('SETTLEUSERREF').setDisabled(false);
_this.formEdit.getForm().reset();
_this.formEdit.getForm().setValues(data);
_this.formEdit.getForm().findField('BILLSTATUS').setDisabled(true);
_this.formEdit.getForm().findField('SETTLEUSERREF').setDisabled(true);
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
_this.storeBodyList.load({ params: { condition: " BILLNO='" + billno + "'" },
callback: function (r, options, success) {
if (success) {
if (_this.storeBodyList.getCount() > 0) {
_this.comboxCurr.setReadOnly(true);
_this.comboxCustCode.setReadOnly(true);
}
else {
_this.comboxCurr.setReadOnly(false);
_this.comboxCustCode.setReadOnly(false);
}
}
},
scope: this
});
// billno = this.formEdit.getForm().findField('DUINO').getValue();
this.storeBodySum.load({ params: { condition: " BILLNO='" + billno + "'"} });
// this.storeFeeList.load({ params: { condition: " DUINO='" + billno + "'"} });
}, // end LoadDate
Print: function () {
var basicForm = this.formEdit.getForm();
var billNo = basicForm.findField('BILLNO').value;
if (billNo == '*' || billNo == '') {
Ext.Msg.show({ title: '错误', msg: '单据还没有保存,请保存后再打印', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
return;
}
var printType = 'MSCHFEEPAYSETTLEMENT';
var sql1 = "SELECT s.*,(select ShowName from [user] where GID=s.SETTLEUSER) as SETTLEUSERREF FROM ch_fee_settlement s WHERE BILLNO='" + billNo + "'";
var sql2 = "SELECT c.GID,c.BSNO,c.FEEID,c.FEENAME,c.CURRENCY,c.AMOUNT,c.DOAMOUNT,c.ORIGCURRENCY,c.ORIGAMOUNT,c.EXCHANGERATE,FEETYPE ";
sql2 = sql2 + ",b.CUSTOMERNAME,b.VESSEL,b.VOYNO,b.ETD,b.PORTLOAD";
sql2 = sql2 + " ,b.PORTDISCHARGE,b.INPUTBY,b.OP,b.CUSTSERVICE,b.DOC,b.SALE,b.MBLNO";
sql2 = sql2 + " FROM ch_fee_do c left join v_op_bill b on (b.bsno=c.bsno)";
sql2 = sql2 + " WHERE C.BILLNO='" + billNo + "' ORDER BY b.VESSEL,b.VOYNO,b.MBLNO";
var sql3 = "";
var sql4 = "";
var sql5 = "";
var sql6 = "";
PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6);
}
});