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.

936 lines
30 KiB
JavaScript

//月末结账
Ext.namespace('Shipping');
Shipping.Monthlock = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.Monthlock.superclass.constructor.call(this);
};
Ext.extend(Shipping.Monthlock, Ext.Panel, {
PageSize: 100,
OprationStatus: null, //仅当弹出界面时使用
SelectedRecord: null,
sqlcontext: '1=2',
AccDate: null,
IsAccDate: '',
initUIComponents: function () {
//定义数据集
this.storeList = Ext.create('Ext.data.Store', {
pageSize: this.PageSize,
fields: [
{ name: 'BSNO', type: 'string' },
{ name: 'OPLB', type: 'string' },
{ name: 'OPLBNAME', type: 'string' },
{ name: 'BSTYPE', type: 'string' },
{ name: 'CUSTOMERNAME', type: 'string' },
{ name: 'ACCDATE', type: 'string' },
{ name: 'CUSTNO', type: 'string' },
{ name: 'MBLNO', type: 'string' },
{ name: 'HBLNO', type: 'string' },
{ name: 'ETD', type: 'string' },
{ name: 'VESSEL', type: 'string' },
{ name: 'VOYNO', type: 'string' },
{ name: 'INPUTBY', type: 'string' },
{ name: 'CREATETIME', type: 'string' },
{ name: 'BSSTATUS', type: 'string' },
{ name: 'FEESTATUS', type: 'string' },
{ name: 'BSSTATUSREF', type: 'string' },
{ name: 'FEESTATUSREF', type: 'string' },
{ name: 'SALE', type: 'string' },
{ name: 'OP', type: 'string' },
{ name: 'DOC', type: 'string' },
{ name: 'CUSTSERVICE', type: 'string' },
{ name: 'PORTLOAD', type: 'string' },
{ name: 'PORTDISCHARGE', type: 'string' },
{ name: 'CUSTOMNO', type: 'string' },
{ name: 'ACCDATE', type: 'string' },
{ name: 'CARRIER', type: 'string' },
{ name: 'BSSOURCE', type: 'string' },
{ name: 'LANE', type: 'string' },
{ name: 'FORWARDER', type: 'string' },
{ name: 'CNTRTOTAL', type: 'string' },
{ name: 'TRADETYPE', type: 'string' },
{ name: 'GOODSNAME', type: 'string' },
{ name: 'OPDATE', type: 'string' },
{ name: 'CUSTOMDATE', type: 'string' },
{ name: 'ENTERP', type: 'string' },
{ name: 'NETWEIGHT', type: 'number' },
{ name: 'KGS', type: 'number' },
{ name: 'TEU', type: 'number' },
{ name: 'CNTR1', type: 'number' },
{ name: 'CNTR2', type: 'number' },
{ name: 'CNTR3', type: 'number' },
{ name: 'CNTR4', type: 'number' },
{ name: 'CNTR5', type: 'number' },
{ name: 'CNTR6', type: 'number' },
{ name: 'CNTR7', type: 'number' },
{ name: 'CNTR8', type: 'number' },
{ name: 'CNTR9', type: 'number' },
{ name: 'CNTR10', type: 'number' },
{ name: 'OTCNTR', type: 'number' },
{ name: 'RMBDR', type: 'number' },
{ name: 'RMBCR', type: 'number' },
{ name: 'USDDR', type: 'number' },
{ name: 'USDCR', type: 'number' },
{ name: 'OTDR', type: 'number' },
{ name: 'OTCR', type: 'number' },
{ name: 'TTLDR', type: 'number' },
{ name: 'TTLCR', type: 'number' },
{ name: 'RMBPROFIT', type: 'number' },
{ name: 'USDPROFIT', type: 'number' },
{ name: 'OTPROFIT', type: 'number' },
{ name: 'TTLPROFIT', type: 'number' },
{ name: 'PROFITRATE', type: 'string' }
],
remoteSort: true,
proxy: {
type: 'ajax',
url: '/Account/Account_MonthLock/BsListData',
reader: {
id: '',
root: 'data',
totalProperty: 'totalCount'
}
}
});
//定义Grid
this.GridCheckBoxModel = Ext.create('Ext.selection.CheckboxModel');
this.gridList = new Ext.grid.GridPanel({
store: this.storeList,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
selModel: this.GridCheckBoxModel,
columns: [{
sortable: true,
dataIndex: 'BSNO',
header: '编号',
hidden: true,
width: 130
}, {
sortable: true,
id: '',
align: 'center',
dataIndex: 'BSSTATUSREF',
header: '业务锁定',
width: 60,
renderer: function (value, cellmeta) {
if (value == '已锁定') {
return "<img src='../../../../TruckMng/Content/Images/Lock.png' />";
}
}
},
{
sortable: true,
id: '',
align: 'center',
dataIndex: 'FEESTATUSREF',
header: '费用锁定',
width: 60,
renderer: function (value, cellmeta) {
if (value == '已锁定') {
return "<img src='../../../../TruckMng/Content/Images/Lock.png' />";
}
}
}, {
sortable: true,
dataIndex: 'OPLBNAME',
header: '业务类型',
width: 70
}, {
sortable: true,
dataIndex: 'BSTYPE',
header: '运输类型',
width: 70
}, {
sortable: true,
dataIndex: 'ACCDATE',
header: '会计期间',
width: 86
}, {
sortable: true,
dataIndex: 'OPDATE',
header: '业务日期',
width: 86
}, {
sortable: true,
dataIndex: 'CUSTOMDATE',
header: '报关日期',
width: 86
}, {
sortable: true,
dataIndex: 'CUSTOMERNAME',
header: '委托单位',
width: 120
}, {
sortable: true,
dataIndex: 'CUSTNO',
header: '委托编号',
width: 136
}, {
sortable: true,
dataIndex: 'CUSTOMNO',
header: '报关单号',
width: 136
}, {
sortable: true,
dataIndex: 'ENTERP',
header: '经营单位',
width: 100
}, {
sortable: true,
dataIndex: 'MBLNO',
header: '主提单号',
width: 120
}, {
sortable: true,
dataIndex: 'HBLNO',
header: '分提单号',
width: 120
}, {
sortable: true,
dataIndex: 'ETD',
header: '开船日期',
width: 86
}, {
sortable: true,
dataIndex: 'VESSEL',
header: '船名',
width: 200
}, {
sortable: true,
dataIndex: 'VOYNO',
header: '航次',
width: 50
}, {
sortable: true,
dataIndex: 'SALE',
header: '业务员',
width: 80
}, {
sortable: true,
dataIndex: 'OP',
header: '操作',
width: 80
}, {
sortable: true,
dataIndex: 'PORTLOAD',
header: '起运港',
width: 80
}, {
sortable: true,
dataIndex: 'PORTDISCHARGE',
header: '目的港',
width: 150
}, {
sortable: true,
dataIndex: 'ACCDATE',
header: '会计期间',
width: 80
}, {
sortable: true,
dataIndex: 'CARRIER',
header: '船公司',
width: 80
}, {
sortable: true,
dataIndex: 'BSSOURCE',
header: '业务来源',
width: 120
}, {
sortable: true,
dataIndex: 'TEU',
header: 'TEU',
width: 80
}, {
sortable: true,
dataIndex: 'KGS',
header: 'KGS',
width: 80
}, {
sortable: true,
dataIndex: 'GOODSNAME',
header: '品名',
width: 80
}, {
sortable: true,
dataIndex: 'RMBDR',
header: 'RMB应收',
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: 80
}, {
sortable: true,
dataIndex: 'RMBCR',
header: 'RMB应付',
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: 80
}, {
sortable: true,
dataIndex: 'RMBPROFIT',
header: 'RMB利润',
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: 80
}, {
sortable: true,
dataIndex: 'USDDR',
header: 'USD应收',
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: 80
}, {
sortable: true,
dataIndex: 'USDCR',
header: 'USD应付',
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: 80
}, {
sortable: true,
dataIndex: 'USDPROFIT',
header: 'USD利润',
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: 80
}, {
sortable: true,
dataIndex: 'OTDR',
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: 80
}, {
sortable: true,
dataIndex: 'OTCR',
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: 80
}, {
sortable: true,
dataIndex: 'OTPROFIT',
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: 80
}, {
sortable: true,
dataIndex: 'TTLDR',
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: 80
}, {
sortable: true,
dataIndex: 'TTLCR',
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: 80
}, {
sortable: true,
dataIndex: 'TTLPROFIT',
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: 80
}, {
sortable: true,
dataIndex: 'PROFITRATE',
header: '利润率',
width: 80
}
],
// 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;
var openSet = "height=700, width=1024, toolbar=no, menubar=no,scrollbars=1, resizable=1,location=no, status=no,Top= " + (screen.height - 750) / 2 + ",Left= " + (screen.width - 1100) / 2
var openType = "_blank";
var openUrl = "/Account/Chfee_lock/Chfee_lockDetail";
window.open(openUrl, openType, openSet);
}, this);
this.MonthDate = new Ext.ux.form.MonthField({
fieldLabel: '本次结账期间',
xtype: 'monthfield',
readOnly: true,
name: 'ACCDATE'
});
this.panelBtn = new Ext.Panel({
region: "north",
tbar: [this.MonthDate, '-', {
xtype: 'button',
width: 90,
text: "月末结账",
iconCls: "btnsubmit",
handler: function (button, event) {
this.onMonthClose(button, event);
},
scope: this
}, '-', {
xtype: 'button',
width: 100,
text: "月末反结账",
handler: function (button, event) {
this.onMonthNoClose(button, event);
},
scope: this
}, '-', {
xtype: 'button',
width: 100,
text: "更改会计期间",
handler: function (button, event) {
this.onMonthNoClose(button, event);
},
scope: this
}
]
});
this.formAccMonthShow = Ext.widget('form', {
frame: true,
region: 'center',
bodyPadding: 5,
fieldDefaults: {
margins: '2 2 2 2',
labelAlign: 'right',
flex: 1,
labelWidth: 85,
msgTarget: 'qtip'
},
items: [
{//fieldset 1
xtype: 'container',
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '会计期间',
xtype: 'monthfield',
name: 'AccDate'
}
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
xtype: 'radiogroup',
id: 'rLOCKTYPE',
defaults: {
flex: 1
},
layout: 'hbox',
items: [
{
boxLabel: '选择',
name: 'LOCKTYPE',
checked: true,
inputValue: 'S',
id: 'radio1'
}, {
boxLabel: '全部',
name: 'LOCKTYPE',
inputValue: 'A',
id: 'radio2'
}
]
}
]
}
]//end items(fieldset 1)
}//end fieldset 1
]//end root items
});
me = this;
this.winFeeCloseShow = Ext.create('Ext.window.Window', {
title: "更改会计期间",
width: 420,
//height : 120,
//plain : true,
iconCls: "addicon",
resizable: false,
// 是否可以拖动
// draggable:false,
collapsible: true, // 允许缩放条
closeAction: 'close',
closable: true,
modal: 'true',
buttonAlign: "center",
bodyStyle: "padding:0 0 0 0",
items: [this.formAccMonthShow],
buttons: [{
text: "确认更改",
minWidth: 70,
handler: function () {
var form = me.formAccMonthShow.getForm();
var cgLOCKTYPE = Ext.getCmp('rLOCKTYPE');
var LOCKTYPE = cgLOCKTYPE.getValue();
me.AccDate = form.findField('AccDate').getRawValue();
if (me.AccDate == '' || me.AccDate == null || me.AccDate == undefined) {
Ext.Msg.show({ title: '提示', msg: '必须会计期间!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
};
var monthdate = _this.MonthDate.getValue()
var gaccdate = form.findField('AccDate').getValue();
if (gaccdate<monthdate) {
Ext.Msg.show({ title: '提示', msg: '更改的会计期间,不允许在已经月末结账的期间!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
if (LOCKTYPE.LOCKTYPE == 'A') {
_this.onFeeLockAll()
} else {
_this.onSelFeeLockClick()
}
}
}, {
text: "关闭",
minWidth: 70,
handler: function () {
me.winFeeCloseShow.close();
}
}]
});
this.panelTop = new Ext.Panel({
layout: "border",
region: "north",
height: 29,
items: [this.panelBtn]
});
this.panelBodyChFee = new Ext.Panel({
title: '本期间未费用封帐业务明细',
layout: "border",
region: 'center',
margin: '0 0',
frame: true,
items: [this.gridList]
});
this.tabpanel = new Ext.TabPanel
({
activeTab: 0,
autoWidth: true,
border: false,
frame: false,
region: 'center',
id: "TabPanelID",
enableTabScroll: true,
items:
[
this.panelBodyChFee
]
});
Ext.apply(this, {
items: [this.panelTop, this.panelSearch, this.tabpanel]
});
this.storeList.on('beforeload', function (store) {
if (!this.checkSearchCondition())
return;
var sql = this.getCondition();
Ext.apply(store.proxy.extraParams, { condition: sql });
}, this);
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/Account/Account_MonthLock/GetMonthsData',
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;
}
data = result.data;
this.MonthDate.setValue(data.MONTHNAME);
this.onRefreshClick();
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
}, //end initUIComponents
onRefreshClick: function (button, event) {
var sql = this.getCondition();
this.sqlcontext = sql;
this.storeList.load({
params: { start: 0, limit: this.PageSize, condition: sql },
waitMsg: "正在查询数据...",
scope: this
});
},
getCondition: function () {
var accDate_Min = this.MonthDate.getRawValue();
sql = sql + getAndConSql(sql, accDate_Min, " B.ACCDATE='" + accDate_Min + "'");
return sql;
},
OprationSwap: function () {
var ret = new Array();
ret[0] = this.OprationStatus;
ret[1] = this.storeList;
ret[2] = this.SelectedRecord;
ret[3] = this.SelectedRecord.data.BSNO;
ret[4] = "chfee_lock";
return ret;
},
onExportClick: function (button, event) {
GridExportExcelPage(this.gridList);
},
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);
},
GetBtnStatus: function () {
var btnFeeLock = Ext.getCmp('btnFeeLock');
var btnFeeUnLock = Ext.getCmp('btnFeeUnLock');
var btnBsLock = Ext.getCmp('btnBsLock');
var btnBsUnLock = Ext.getCmp('btnBsUnLock');
if (locktype == 'BS') {
btnBsLock.setVisible(true);
btnBsUnLock.setVisible(true);
btnFeeLock.setVisible(false);
btnFeeUnLock.setVisible(false);
} else if (locktype == 'FEE') {
btnBsLock.setVisible(false);
btnBsUnLock.setVisible(false);
btnFeeLock.setVisible(true);
btnFeeUnLock.setVisible(true);
}
},
Print: function () {
_this = this;
if (this.storeList.getCount() == 0) {
return;
}
Ext.Msg.wait('正在组织数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在组织数据...',
url: '/Account/Chfee_lock/BsListData',
scope: this,
params: {
start: 0, limit: this.PageSize,
condition: _this.sqlcontext,
type: locktype,
printstr: 'true'
},
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 = 'MSLOCKLIST';
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
});
}
}
});
}
});