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/MvcContainer/Viewsjs/MsOpCtnBsCard/MsRptCtnStatusIndex.js

709 lines
24 KiB
JavaScript

Ext.namespace('Shipping');
Shipping.MsRptCtnStatusIndex = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.MsRptCtnStatusIndex.superclass.constructor.call(this);
};
Ext.extend(Shipping.MsRptCtnStatusIndex, Ext.Panel, {
PageSize: 400,
OprationStatus: null, //仅当弹出界面时使用
SelectedRecord: null,
sqlcontext: '1=2',
bslistdrsortfield: '',
bslistdrsortdire: '',
bslistcrsortfield: '',
bslistcrsortdire: '',
feelistdrsortfield: '',
feelistdrsortdire: '',
feelistcrsortfield: '',
feelistcrsortdire: '',
salesumsortfield: '',
salesumsortdire: '',
custsumsortfield: '',
custsumsortdire: '',
vesselsumsortfield: '',
vesselsumsortdire: '',
sqlselect: '1=2',
initUIComponents: function () {
//定义数据集
this.formname = 'MsRptCtnStatusIndex';
this.storeList = Ext.create('Ext.data.Store', {
pageSize: this.PageSize,
fields: [
{ name: 'COUNTRY', type: 'string' },
{ name: 'DESTPORT', type: 'string' },
{ name: 'AGENTNAME', type: 'string' },
{ name: 'YARDCTN', type: 'integer' },
{ name: 'CANUSEYARDCTN', type: 'integer' },
{ name: 'CANUSETOTALCTN', type: 'integer' },
{ name: 'CANUSEONTHEWAYCTN', type: 'integer' },
{ name: 'PLANUSEYARDCTN', type: 'integer' },
{ name: 'PLANYARDCTN', type: 'integer' },
{ name: 'PLANUSECTN', type: 'integer' },
{ name: 'ARRIVALCTN', type: 'integer' },
{ name: 'TRANSCTN', type: 'integer' },
{ name: 'CANUSEYARDCTN7', type: 'integer' },
{ name: 'CANUSEYARDCTN15', type: 'integer' },
{ name: 'CANUSEYARDCTN30', type: 'integer' }
],
remoteSort: false,
proxy: {
type: 'ajax',
url: '/MvcContainer/MsOpCtnBsCard/GetRptCtnStatusData',
reader: {
id: '',
root: 'data',
totalProperty: 'totalCount'
}
}, groupField: 'DESTPORT'
});
this.Pagenum = Ext.create('Ext.form.field.Number', {
name: 'bottles',
fieldLabel: '每页记录数',
labelAlign: 'right',
value: this.PageSize,
maxValue: 100000,
width: 170,
minValue: 0,
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
})
//定义Grid
this.initgirdcolums = [{
sortable: true,
dataIndex: 'COUNTRY',
text: '国家',
width: 160
}, {
sortable: true,
dataIndex: 'DESTPORT',
text: '港 口',
width: 160
}, {
sortable: true,
dataIndex: 'AGENTNAME',
text: '目的港代理',
width: 160
}, {
sortable: true,
dataIndex: 'CANUSEYARDCTN',
text: '在场可用箱',
summaryType: 'sum',
width: 80
}, {
sortable: true,
dataIndex: 'CANUSEONTHEWAYCTN',
text: '在途可用箱',
summaryType: 'sum',
width: 80
}, {
sortable: true,
dataIndex: 'CANUSETOTALCTN',
text: '可用箱',
summaryType: 'sum',
width: 80
}, {
sortable: true,
dataIndex: 'PLANUSEYARDCTN',
text: '计划出箱',
summaryType: 'sum',
width: 80
}, {
sortable: true,
dataIndex: 'PLANUSECTN',
text: '未配箱计划',
summaryType: 'sum',
width: 80
}, {
sortable: true,
dataIndex: 'YARDCTN',
text: '场站堆存',
summaryType: 'sum',
width: 80
}, {
sortable: true,
dataIndex: 'ARRIVALCTN',
text: '到港未还箱子',
summaryType: 'sum',
width: 80
}, {
sortable: true,
dataIndex: 'TRANSCTN',
text: '运输中',
summaryType: 'sum',
width: 80
}, {
sortable: true,
dataIndex: 'CANUSEYARDCTN7',
text: '空箱滞留7天以上',
summaryType: 'sum',
width: 160
}, {
sortable: true,
dataIndex: 'CANUSEYARDCTN15',
text: '空箱滞留15天以上',
summaryType: 'sum',
width: 160
}, {
sortable: true,
dataIndex: 'CANUSEYARDCTN30',
text: '空箱滞留30天以上',
summaryType: 'sum',
width: 160
}
];
this.girdcolums = DsTruck.GetGridPanel(USERID, this.formname , this.initgirdcolums, 1);
this.gridList = new Ext.grid.GridPanel({
store: this.storeList,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
viewConfig: {
enableTextSelection: true
},
features: [{
id: 'group',
ftype: 'groupingsummary',
groupHeaderTpl: '{name}',
hideGroupedHeader: true,
enableGroupingMenu: true
}],
columns: this.girdcolums,
// paging bar on the bottom
bbar: [Ext.create('Ext.PagingToolbar', {
store: this.storeList,
displayInfo: true,
displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录',
emptyMsg: "没有数据"
}), this.Pagenum]
});
//this.gridList.addListener('itemdblclick', function (dataview, record, item, index, e, b) {
// this.sqlselect = " b.VDESTPORT='" + record.data.DESTPORT + "'";
// 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 = "";
// openUrl = "../../MvcContainer/MsOpCtnBsCard/CtnStatusDetail";
// window.open(openUrl, openType, openSet);
//}, this);
this.gridList.addListener('celldblclick', function (dataview, td, cellIndex, record, tr, rowIndex, e, eOpts) {
var columnfield = dataview.panel.columns[cellIndex].dataIndex;
var sql = '';
if (columnfield == 'YARDCTN') {
sql = " AND (CASE WHEN ISNULL(IS_RETURE_EMPTY,0)=1 THEN '' ELSE ISNULL(AGENTNAME,'') END)='" + record.data.AGENTNAME + "' AND ((VETA IS NOT NULL AND VDEST_RTCNT_TIME IS NOT NULL) OR (PORTLOAD_CNT_TIME IS NULL AND ETD IS NULL)) ";
} else if (columnfield == 'CANUSEYARDCTN') {
sql = " AND (CASE WHEN ISNULL(IS_RETURE_EMPTY,0)=1 THEN '' ELSE ISNULL(AGENTNAME,'') END)='" + record.data.AGENTNAME + "' AND (VDEST_RTCNT_TIME IS NOT NULL) ";
} else if (columnfield == 'CANUSEONTHEWAYCTN') {
sql = " AND (CASE WHEN ISNULL(IS_RETURE_EMPTY,0)=1 THEN '' ELSE ISNULL(AGENTNAME,'') END)='" + record.data.AGENTNAME + "' AND ((ISNULL(IS_RETURE_EMPTY,0)=1 AND VETA IS NULL AND I_PORTLOAD_CNT_TIME IS NOT NULL) OR (isnull(EMPTYCTNALLOCATION, 0) = 1 AND VETA IS NULL AND PORTLOAD_CNT_TIME IS NOT NULL)) ";
} else if (columnfield == 'CANUSETOTALCTN') {
sql = " AND (CASE WHEN ISNULL(IS_RETURE_EMPTY,0)=1 THEN '' ELSE ISNULL(AGENTNAME,'') END)='" + record.data.AGENTNAME + "' AND ((ISNULL(IS_RETURE_EMPTY,0)=1 AND VETA IS NULL AND I_PORTLOAD_CNT_TIME IS NOT NULL) OR (isnull(EMPTYCTNALLOCATION, 0) = 1 AND VETA IS NULL AND PORTLOAD_CNT_TIME IS NOT NULL) OR VDEST_RTCNT_TIME IS NOT NULL) ";
} else if (columnfield == 'PLANUSEYARDCTN') {
sql = " AND (CASE WHEN ISNULL(IS_RETURE_EMPTY,0)=1 THEN '' ELSE ISNULL(AGENTNAME,'') END)='" + record.data.AGENTNAME + "' AND (PORTLOAD_CNT_TIME IS NULL AND ETD IS NULL) ";
} else if (columnfield == 'ARRIVALCTN') {
sql = " AND (CASE WHEN ISNULL(IS_RETURE_EMPTY,0)=1 THEN '' ELSE ISNULL(AGENTNAME,'') END)='" + record.data.AGENTNAME + "' AND (VDEST_RTCNT_TIME IS NULL AND VETA IS NOT NULL) ";
} else if (columnfield == 'TRANSCTN') {
sql = " AND (CASE WHEN ISNULL(IS_RETURE_EMPTY,0)=1 THEN '' ELSE ISNULL(AGENTNAME,'') END)='" + record.data.AGENTNAME + "' AND (VETA IS NULL AND PORTLOAD_CNT_TIME IS NOT NULL) ";
} else if (columnfield == 'CANUSEYARDCTN7') {
sql = " AND (CASE WHEN ISNULL(IS_RETURE_EMPTY,0)=1 THEN '' ELSE ISNULL(AGENTNAME,'') END)='" + record.data.AGENTNAME + "' AND (VDEST_RTCNT_TIME IS NOT NULL AND CTNSTATUS='可用' and DATEDIFF (dd ,VDEST_RTCNT_TIME,GETDATE())>7 and DATEDIFF (dd ,VDEST_RTCNT_TIME,GETDATE())<=15) ";
} else if (columnfield == 'CANUSEYARDCTN15') {
sql = " AND (CASE WHEN ISNULL(IS_RETURE_EMPTY,0)=1 THEN '' ELSE ISNULL(AGENTNAME,'') END)='" + record.data.AGENTNAME + "' AND (VDEST_RTCNT_TIME IS NOT NULL AND CTNSTATUS='可用' and DATEDIFF (dd ,VDEST_RTCNT_TIME,GETDATE())>15 and DATEDIFF (dd ,VDEST_RTCNT_TIME,GETDATE())<=30) ";
} else if (columnfield == 'CANUSEYARDCTN30') {
sql = " AND (CASE WHEN ISNULL(IS_RETURE_EMPTY,0)=1 THEN '' ELSE ISNULL(AGENTNAME,'') END)='" + record.data.AGENTNAME + "' AND (VDEST_RTCNT_TIME IS NOT NULL AND CTNSTATUS='可用' and DATEDIFF (dd ,VDEST_RTCNT_TIME,GETDATE())>30) ";
} else if (columnfield == 'AGENTNAME') {
sql = " AND (CASE WHEN ISNULL(IS_RETURE_EMPTY,0)=1 THEN '' ELSE ISNULL(AGENTNAME,'') END)='" + record.data.AGENTNAME + "' ";
} else if (columnfield == 'PLANUSECTN') {
sql = " AND 1=2 ";
}
this.sqlselect = " b.VDESTPORT='" + record.data.DESTPORT + "'" + sql;
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 = "";
openUrl = "../../MvcContainer/MsOpCtnBsCard/CtnStatusDetail";
window.open(openUrl, openType, openSet);
}, this);
this.gridList.addListener('sortchange', function (ct, column, direction, eOpts) {
this.bslistdrsortfield = column.dataIndex;
this.bslistdrsortdire = direction;
}, this);
//#region formSearch
//#region formSearch枚举参照相关
//客户加载_委托单位
this.storeCustCode = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CustomRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetCustomRefList' }
});
this.storeCustCode.load({ params: { condition: " 1=1 "} });
//委托单位
_this = this;
this.comboxCustCode = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '罐东',
store: this.storeCustCode,
forceSelection: true,
name: 'OWNERCTN',
valueField: 'CustName',
displayField: 'CodeAndName',
enableKeyEvents: true,
listeners: {
keyup: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
});
this.storeCTNPROP = Ext.create('DsExt.ux.RefEnumStore', {});
this.storeCTNPROP.load({ params: { enumTypeId: 97030} });
this.comboxCTNPROP = Ext.create('Ext.ux.form.field.BoxSelect', {
fieldLabel: '箱属',
//renderTo: 'basicBoxselect',
//autoHeight:true,
autosize: true,
bodyPadding: 1,
flex: 2,
//height:60,
width: 80,
labelWidth: 90,
store: this.storeCTNPROP,
queryMode: 'local',
//stacked: true,
//pinList: false,
triggerOnClick: false,
valueField: 'EnumValueName',
displayField: 'EnumValueName',
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
//,value: ['TX', 'CA']
});
// this.comboxCTNPROP = Ext.create('DsExt.ux.RefTableCombox', {
// store: this.storeCTNPROP,
// fieldLabel: '箱属',
// name: 'CTNPROP',
// valueField: 'EnumValueName',
// displayField: 'EnumValueName',
// enableKeyEvents: true,
// listeners: {
// specialkey: function (field, e) {
// if (e.getKey() == e.ENTER) {
// _this.onRefreshClick();
// }
// }
// }
// });
//#endregion
this.formSearch = Ext.widget('form', {
frame: true,
region: 'center',
bodyPadding: 5,
fieldDefaults: {
margins: '2 2 2 2',
labelAlign: 'right',
flex: 1,
labelWidth: 60,
msgTarget: 'qtip'
},
items: [
{//fieldset 1
xtype: 'container',
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '箱号',
name: 'CTNNO',
enableKeyEvents: true,
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
}, this.comboxCTNPROP, { xtype: 'hiddenfield' }, { xtype: 'hiddenfield' }, { xtype: 'hiddenfield' }
]
}
]//end items(fieldset 1)
}//end fieldset 1
]//end root items
});
//#endregion formSearch
//查询工具条
this.CheckSaveQuery = new Ext.form.Checkbox({
fieldLabel: '记忆查询条件',
checked: true,
width: 120
});
_this = this;
this.SearchBtn = new Ext.Button({
text: '隐藏查询',
handler: function () {
if (_this.SearchBtn.text == '隐藏查询') {
_this.panelSearch.hide();
_this.SearchBtn.setText("显示查询");
} else {
_this.panelSearch.show();
_this.SearchBtn.setText("隐藏查询");
}
}
});
this.panelBtn = new Ext.Panel({
region: "north",
tbar: [
{
text: "执行查询",
iconCls: "btnrefresh",
id: "btnrefresh",
handler: function (button, event) {
this.onRefreshClick(button, event);
var isvisible = true;
var issavevalue = false;
if (_this.SearchBtn.text == '隐藏查询')
isvisible = true
else
isvisible = false;
if (this.CheckSaveQuery.checked)
issavevalue = true
saveQuerySetting(this.formname, this.formSearch, isvisible, issavevalue);
},
scope: this
}, {
text: "导出Excel",
id: "btnExportExcel",
iconCls: 'btnexportexcel',
handler: function (button, event) {
this.onExportClick(button, event);
},
scope: this
}, '-',
{
text: "打印",
iconCls: 'btnprint',
handler: function (button, event) {
this.Print();
},
scope: this
}, '-', this.SearchBtn, {
xtype: 'button',
width: 90,
text: "清空条件",
iconCls: "btnreset",
handler: function (button, event) {
this.onClearSql(button, event);
},
scope: this
}, this.CheckSaveQuery, '-', {
text: "保存列表样式",
id: "btntest",
menu: [
{ text: "保存列表",
handler: function (button, event) {
_this.onSaveGridClick(button, event);
}
}, { text: "刷新列表",
handler: function (button, event) {
_this.oninitGridClick(button, event);
}
}],
scope: this
}
]
});
this.panelTop = new Ext.Panel({
layout: "border",
region: "north",
height: 29,
items: [this.panelBtn]
});
this.panelSearch = new Ext.Panel({
layout: "border",
region: "north",
height: 50,
items: [this.formSearch]
});
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);
LoadQueryData(this.formname, this.formSearch, this.CheckSaveQuery);
}, //end initUIComponents
onRefreshClick: function (button, event) {
if (!this.checkSearchCondition())
return;
var sql = this.getCondition();
this.PageSize = this.Pagenum.getValue();
this.sqlcontext = sql;
this.storeList.pageSize = this.PageSize;
this.storeList.currentPage = 1;
this.storeList.load({
params: { start: 0, limit: this.PageSize, condition: sql },
waitMsg: "正在查询数据...",
scope: this
});
},
onClearSql: function () {
var form = this.formSearch.getForm();
form.reset();
},
getCondition: function () {
var form = this.formSearch.getForm();
var data = this.formSearch.getForm().getValues(false, false, false);
var sql = '';
/*
var sqldata = form.getValues();
sql = Ext.JSON.encode(sqldata);
*/
var CTNNO = form.findField('CTNNO').getValue();
sql = sql + getAndConSql(sql, CTNNO, " B.CTNNO like '%" + CTNNO + "%' ");
var port = BoxSelectgetStrValue(this.comboxCTNPROP.getValue());
if (port != "") {
sql = sql + getAndConSql(sql, port, " B.CTNPROP in (" + port + ")");
}
// var CTNPROP = form.findField('CTNPROP').getValue();
// sql = sql + getAndConSql(sql, CTNPROP, " B.CTNPROP='" + CTNPROP + "'");
// var OWNERCTN = form.findField('OWNERCTN').getValue();
// sql = sql + getAndConSql(sql, OWNERCTN, " B.OWNERCTN='" + OWNERCTN + "'");
return sql;
},
checkSearchCondition: function () {
var form = this.formSearch.getForm();
if (!form.isValid()) {
Ext.Msg.alert('提示', '查询条件赋值错误,请检查。');
return false;
}
return true;
},
OprationSwap: function () {
var ret = new Array();
ret[0] = this.sqlcontext;
ret[1] = this.sqlselect;
ret[2] = this.SelectedRecord;
ret[3] = "MsRptCtnStatusIndex";
return ret;
},
onSaveGridClick: function (button, event) {
this.girdcolums = DsTruck.SaveGridPanel(USERID, this.formname , this.gridList.columns, this.girdcolums, 1, true);
},
oninitGridClick: function (button, event) {
this.gridList.reconfigure(this.storeList, this.initgirdcolums);
this.girdcolums = DsTruck.SaveGridPanel(USERID, this.formname, this.gridList.columns, this.initgirdcolums, 1, true);
},
onExportClick: function (button, event) {
_this = this;
GridExportExcelPage(this.gridList);
},
Print: function () {
var sql = this.getCondition();
_this = this;
if (this.storeList.getCount() == 0) {
return;
}
var sortstr = '';
if (this.bslistdrsortfield != '' && this.bslistdrsortdire != '') {
sortstr = this.bslistdrsortfield + ' ' + this.bslistdrsortdire;
}
Ext.Msg.wait('正在组织数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在组织数据...',
url: '/MvcContainer/MsOpCtnBsCard/GetRptCtnStatusData',
scope: this,
params: {
start: 0, limit: this.PageSize,
condition: sql,
printstr: 'true',
sortstr: sortstr
},
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 = 'MsRptCtnStatusIndex';
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
});
}
}
});
}
});