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/MvcShipping/Viewsjs/MsOpCtnStatus/MsOpCtnStatusIndex.js

909 lines
31 KiB
JavaScript

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

Ext.namespace('Shipping');
Shipping.MsOpCtnStatusIndex = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.MsOpCtnStatusIndex.superclass.constructor.call(this);
};
Ext.extend(Shipping.MsOpCtnStatusIndex, Ext.Panel, {
PageSize: 30,
OprationStatus: null, //仅当弹出界面时使用
SelectedRecord: null,
EditRecord: null,
isnot: 1,
initUIComponents: function () {
//定义数据集
this.storeList = Ext.create('Ext.data.Store', {
pageSize: this.PageSize,
model: 'MsCtnStatus',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/MvcShipping/MsOpCtnStatus/GetListData',
reader: {
id: 'cntrid',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.girdcolums = [{
sortable: true,
dataIndex: 'b_id',
header: 'b_id',
hidden: true,
width: 150
}, {
sortable: true,
dataIndex: 'jcyy',
header: '箱动态',
width: 100
}, {
sortable: true,
dataIndex: 'sdzt',
id: 'sdztid',
header: '锁定状态',
width: 70,
renderer: function (value, cellmeta) {
if (value == '锁定') {
return "<img src='../../../../TruckMng/Content/Images/Lock.png' />";
}
}
}, {
sortable: true,
dataIndex: 'cz',
header: '堆场/码头',
width: 100
}, {
sortable: true,
dataIndex: 'cctime',
header: '出场日期',
width: 100
}, {
sortable: true,
dataIndex: 'jctime',
header: '进场日期',
width: 100
}, {
sortable: true,
dataIndex: 'box_no',
header: '箱号',
width: 150
}, {
sortable: true,
dataIndex: 'cntrsize',
header: '箱型',
width: 50
}, {
sortable: true,
dataIndex: 'vessel',
header: '船名',
width: 120
}, {
sortable: true,
dataIndex: 'voyage',
header: '航次',
width: 80
}, {
sortable: true,
dataIndex: 'blno',
header: '提单号',
width: 120
}, {
sortable: true,
dataIndex: 'etd',
header: '开航日',
width: 80
}, {
sortable: true,
dataIndex: 'reachtime',
header: '到港日',
width: 80
}, {
sortable: true,
dataIndex: 'stateref',
header: '箱状态',
width: 80
}, {
sortable: true,
dataIndex: 'fobportname',
header: '装货港',
width: 80
}, {
sortable: true,
dataIndex: 'positionname',
header: '卸货港',
width: 80
}, {
sortable: true,
dataIndex: 'operman',
header: '操作人',
width: 150
}, {
sortable: true,
dataIndex: 'opertime',
header: '操作时间',
width: 80
}, {
sortable: true,
dataIndex: 'OneWay',
header: '特殊状态',
width: 80
}, {
sortable: true,
dataIndex: 'Remarks',
header: '备注',
width: 150
}];
this.gridListCellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
this.CheckBoxModel = Ext.create('Ext.selection.CheckboxModel');
//定义Grid
_this = this;
this.gridList = new Ext.grid.GridPanel({
store: this.storeList,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
plugins: [this.gridListCellEditing],
selModel: this.CheckBoxModel,
selType: 'cellmodel',
columns: this.girdcolums,
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';
window.open('/MvcShipping/MsOpCtnStatus/Edit', "CTNSTATUS EDIT", 'width=800,height=220,top=200,left=200,resizable=yes,status=yes,menubar=no,scrollbars=yes');
}, this);
//#region formSearch 查询面板
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: 'Mblno'
}, {
fieldLabel: '船名',
name: 'Vessel'
}, {
fieldLabel: '航次',
name: 'Voy'
}, {
fieldLabel: '导入日期',
format: 'Y-m-d',
xtype: 'datefield',
name: 'OPDateBgn'
}, {
fieldLabel: '至',
format: 'Y-m-d',
xtype: 'datefield',
name: 'OPDateEnd'
}]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '箱号',
name: 'CntrNo'
}, {
fieldLabel: 'ETD',
format: 'Y-m-d',
xtype: 'datefield',
name: 'ETDDateBgn'
}, {
fieldLabel: '至',
format: 'Y-m-d',
xtype: 'datefield',
name: 'ETDDateEnd'
}, {
fieldLabel: 'ETA',
format: 'Y-m-d',
xtype: 'datefield',
name: 'ETADateBgn'
}, {
fieldLabel: '至',
format: 'Y-m-d',
xtype: 'datefield',
name: 'ETADateEnd'
}]
}]//end items(fieldset 1)
}]//end root items
});
//#endregion formSearch
//查询工具条
this.panelBtn = new Ext.Panel({
region: "north",
tbar: [
{
text: "新建",
iconCls: "btnadd",
handler: function (button, event) {
this.OprationStatus = 'add';
window.open('/MvcShipping/MsOpCtnStatus/Edit', "CTNSTATUS EDIT", 'width=800,height=220,top=200,left=200,resizable=yes,status=yes,menubar=no,scrollbars=yes');
},
scope: this
},
{
text: "删除",
iconCls: "btndelete",
handler: function (button, event) {
this.deleteDetail();
},
scope: this
},
'-',
{
text: "执行查询",
iconCls: "btnrefresh",
handler: function (button, event) {
this.onRefreshClick(button, event);
},
scope: this
},
'-',
{
text: "显示未入集装箱资料动态",
iconCls: "btnrefresh",
handler: function (button, event) {
this.isnot = 2;
this.storeList.load({
params: { start: 0, limit: this.PageSize, sort: '', condition: ' box_no not in (select cntrno from container_info)' },
waitMsg: "正在查询数据...",
scope: this
});
},
scope: this
},
{
text: "重置条件",
iconCls: "btnreset",
handler: function (button, event) {
},
scope: this
}, '-', {
text: "批量添加",
iconCls: "btnadd",
handler: function (button, event) {
this.OprationStatus = 'add';
window.open('/MvcShipping/MsOpCtnStatus/PiliangEdit', "CTNSTATUS EDIT", 'width=800,height=320,top=200,left=200,resizable=yes,status=yes,menubar=no,scrollbars=yes');
},
scope: this
}, '-', {
text: "批量修改",
iconCls: "btnadd",
handler: function (button, event) {
var selections = this.gridList.getSelectionModel().getSelection();
if (selections.length == 0) {
} else {
var record = selections[0];
this.formModify.getForm().findField('vessel').setValue(record.data.vessel);
this.formModify.getForm().findField('voyage').setValue(record.data.voyage);
this.formModify.getForm().findField('etd').setValue(record.data.etd);
this.formModify.getForm().findField('reachtime').setValue(record.data.reachtime);
}
this.winModifyShow.show();
},
scope: this
},
'-',
{
text: "进场数据导入",
iconCls: "btnexportexcel",
handler: function (button, event) {
var status = 1;
this.onImportBsClick(button, event, status);
},
scope: this
},
'-',
{
text: "出场数据导入",
iconCls: "btnexportexcel",
handler: function (button, event) {
var status = 2;
this.onImportBsClick(button, event, status);
},
scope: this
}, {
text: "锁定业务",
id: "sdywa",
menu: [
{ text: "锁定",
handler: function (button, event) {
var state = 1;
me.sdyw(button, event, state);
}
}, { text: "解锁",
handler: function (button, event, s) {
var state = 2;
me.sdyw(button, event, state);
}
}],
scope: this
}
]
});
this.panelTop = new Ext.Panel({
layout: "border",
region: "north",
height: 100,
items: [this.panelBtn, this.formSearch]
});
Ext.apply(this, {
items: [this.panelTop, this.gridList]
});
this.StoreStatus = Ext.create('Ext.data.Store', {
fields: ['ID', 'NAME']
});
this.StoreStatus.add({ "ID": 1, "NAME": "空箱" });
this.StoreStatus.add({ "ID": 2, "NAME": "重箱" });
this.comboxStatus = Ext.create('DsExt.ux.RefTableCombox', {
store: this.StoreStatus,
fieldLabel: '箱子状态',
forceSelection: true,
name: 'state',
valueField: 'ID',
displayField: 'NAME'
});
this.storeCodeDisport = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.PortRefModel',
proxy: { url: '/MvcShipping/MsBaseInfo/GetPortRefList' }
});
this.storeCodeDisport.load();
this.comboxPORT = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '起运港',
store: this.storeCodeDisport,
forceSelection: true,
name: 'fobport',
valueField: 'PORTID',
queryMode: 'local',
displayField: 'PORT'
});
this.comboxposition = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '目的港',
store: this.storeCodeDisport,
forceSelection: true,
name: 'position',
valueField: 'PORTID',
queryMode: 'local',
displayField: 'PORT'
});
//编辑form
this.formModify = Ext.widget('form', {
region: 'north',
frame: true,
bodyPadding: 5,
fieldDefaults: {
margins: '2 2 2 2',
labelAlign: 'right',
flex: 1,
labelWidth: 70,
msgTarget: 'qtip'
},
items: [
{//fieldset 1
xtype: 'fieldset',
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '船名',
name: 'vessel'
}, {
fieldLabel: '航次',
name: 'voyage'
}, {
fieldLabel: 'ETD',
format: 'Y-m-d',
xtype: 'datefield',
name: 'etd'
}
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [this.comboxPORT, {
fieldLabel: 'ETA',
format: 'Y-m-d',
xtype: 'datefield',
name: 'reachtime'
}, this.comboxStatus
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [this.comboxposition, {
fieldLabel: '备注',
flex: 2,
name: 'Remarks'
}
]
}
]//end items(fieldset 1)
}//end fieldset 1
]//end root items
}); //end this.formEdit
me = this;
this.winModifyShow = Ext.create('Ext.window.Window', {
title: "批量修改",
width: 620,
//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.formModify],
buttons: [{
text: "确认修改",
minWidth: 70,
handler: function () {
me.onModifyClick()
}
}, {
text: "关闭",
minWidth: 70,
handler: function () {
me.winModifyShow.close();
}
}]
});
this.onRefreshClick();
this.storeList.on('beforeload', function (store) {
if (this.isnot == 2) {
var sql = ' box_no not in (select cntrno from container_info)';
} else {
var sql = this.getCondition();
}
Ext.apply(store.proxy.extraParams, { condition: sql });
}, this);
},
onRefreshClick: function (button, event) {
this.isnot = 1;
var sql = this.getCondition();
this.storeList.load({
params: { start: 0, limit: this.PageSize, sort: '', condition: sql },
waitMsg: "正在查询数据...",
scope: this
});
},
sdyw: function (button, event, state) {
var selectedRecords = this.CheckBoxModel.selected.items;
if (selectedRecords.length == 0) {
Ext.Msg.show({ title: '提示', msg: '请先选择要锁定的数据!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return false;
}
var sure = "";
var now = "";
if (state == "1" || state == 1) {
sure = "确定要锁定选中的明细吗?";
now = "正在锁定...";
} else {
sure = "确定要解锁选中的明细吗?";
now = "正在解锁...";
}
Ext.MessageBox.confirm('提示', sure, function (btn) {
if (btn == 'yes') {
var bodyDatas = [];
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
if (rec.BSNO == "" || rec.BSNO == "*") //如果是新增但没有保存的数据,没有必要提交到后台
{
this.storeList.remove(selectedRecords[i]);
} else {
bodyDatas.push(rec);
}
}
var jsonBody = ConvertRecordsToJsonAll(bodyDatas);
_this = this;
Ext.Msg.wait(now);
Ext.Ajax.request({
waitMsg: now,
url: '/MvcShipping/MsOpCtnStatus/sdywc',
params: {
data: jsonBody,
type: state
},
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
this.storeList.reload();
Ext.Msg.show({ title: '提示', msg: jsonresult.Message, 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);
},
deleteDetail: function () {
var selectedRecords = this.CheckBoxModel.selected.items;
if (selectedRecords.length == 0) {
Ext.Msg.show({ title: '提示', msg: '请先选择要删除的数据!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return false;
}
Ext.MessageBox.confirm('提示', '确定要删除选中的明细吗?', function (btn) {
if (btn == 'yes') {
var bodyDatas = [];
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
if (rec.BSNO == "" || rec.BSNO == "*") //如果是新增但没有保存的数据,没有必要提交到后台
{
this.storeList.remove(selectedRecords[i]);
} else {
bodyDatas.push(rec);
}
}
var jsonBody = ConvertRecordsToJsonAll(bodyDatas);
var a = 0;
var datas = Ext.decode(jsonBody);
for (data in datas)// json数组的最外层对象  
{
Ext.each(datas, function (items) {
Ext.each(items, function (item) {
if (item.sdzt == "锁定") {
a = 1;
}
});
});
}
_this = this;
if (a == 1) {
alert("锁定状态下不能删除");
return false;
}
Ext.Msg.wait('正在删除数据...');
Ext.Ajax.request({
waitMsg: '正在删除数据...',
url: '/MvcShipping/MsOpCtnStatus/Delete',
params: {
data: jsonBody
},
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
for (var i = 0; i < selectedRecords.length; i++) {
this.storeList.remove(selectedRecords[i]);
}
Ext.Msg.show({ title: '提示', msg: jsonresult.Message, 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);
},
onModifyClick: function (menu, event) {
var GidStr = '';
var records = this.CheckBoxModel.selected.items;
if (records.length == 0) {
Ext.Msg.show({ title: '提示', msg: '请先选择要修改的业务!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
var bodyAddDatas = [];
for (var i = 0; i < records.length; i++) {
var rec = records[i];
bodyAddDatas.push(rec);
}
var data = this.formModify.getForm().getValues();
_this = this;
if (bodyAddDatas.length == 0) {
Ext.Msg.show({ title: '提示', msg: '没有要修改的业务!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
} else {
var jsonbodyAddDatas = ConvertRecordsToJsonAll(bodyAddDatas);
Ext.Ajax.request({
waitMsg: '正在锁定...',
url: '/MvcShipping/MsOpCtnStatus/modify',
params: {
data: jsonbodyAddDatas,
modifydata: Ext.JSON.encode(data)
},
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 {
Ext.Msg.show({ title: '提示', msg: result.Message, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
_this.onRefreshClick();
_this.winModifyShow.close();
}
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
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 CntrNo = form.findField('CntrNo').getValue();
sql = sql + getAndConSql(sql, CntrNo, "(box_no like '%" + CntrNo + "%' )");
var Mblno = form.findField('Mblno').getValue();
sql = sql + getAndConSql(sql, Mblno, "(blno like '%" + Mblno + "%' )");
var Vessel = form.findField('Vessel').getValue();
sql = sql + getAndConSql(sql, Vessel, "(Vessel like '%" + Vessel + "%' )");
var Voy = form.findField('Voy').getValue();
sql = sql + getAndConSql(sql, Voy, "(voyage like '%" + Voy + "%' )");
var ETDDateBgn = form.findField('ETDDateBgn').getRawValue();
sql = sql + getAndConSql(sql, ETDDateBgn, "ETD>='" + ETDDateBgn + "'");
var ETDDateEnd = form.findField('ETDDateEnd').getRawValue();
sql = sql + getAndConSql(sql, ETDDateEnd, "ETD <='" + ETDDateEnd + "'");
var ETADateBgn = form.findField('ETADateBgn').getRawValue();
sql = sql + getAndConSql(sql, ETADateBgn, "reachtime>='" + ETADateBgn + "'");
var ETADateEnd = form.findField('ETADateEnd').getRawValue();
sql = sql + getAndConSql(sql, ETADateEnd, "reachtime <='" + ETADateEnd + "'");
var OPDateBgn = form.findField('OPDateBgn').getRawValue();
sql = sql + getAndConSql(sql, OPDateBgn, "opertime>='" + OPDateBgn + "'");
var OPDateEnd = form.findField('OPDateEnd').getRawValue();
sql = sql + getAndConSql(sql, OPDateEnd, "opertime <='" + OPDateEnd + "'");
return sql;
},
OprationSwap: function () {
var ret = new Array();
ret[0] = this.OprationStatus;
ret[1] = this.storeList;
ret[2] = this.SelectedRecord;
return ret;
},
onImportBsClick: function (button, event, status) {
_this = this;
var imgform = new Ext.FormPanel({
region: 'center',
labelWidth: 20,
frame: true,
autoScroll: false,
border: false,
fileUpload: true,
items: [{
xtype: 'fileuploadfield',
id: 'LoadExcel',
name: 'LoadExcel',
emptyText: '请选择EXCEL文件',
fieldLabel: 'EXCEL',
buttonText: '选择文件',
allowBlank: false,
width: 200,
buttonCfg:
{
iconCls: 'uploaddialog'
},
anchor: '98%'
}],
buttons: [{
text: '上传',
type: 'submit',
handler: function () {
var UserFilePath = Ext.getCmp('LoadExcel').getValue();
if (!CheckFileExt(UserFilePath, /.xls|.xlsx/i)) {
Ext.Msg.show({ title: '错误', msg: '请确认你上传的文件为EXCEL文件!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
if (!imgform.form.isValid()) { return; }
imgform.form.submit({
url: '/MvcShipping/MsOpCtnStatus/ImportCtn',
waitMsg: '正在上传',
method: 'POST',
params: {
data: status
},
success: function (form, action) {
win.close();
Ext.Msg.show({ title: '提示', msg: action.result.Message, buttons: Ext.Msg.OK });
_this.storeList.reload();
},
failure: function (form, action) {
form.reset();
if (action.failureType == Ext.form.Action.SERVER_INVALID) {
Ext.MessageBox.alert('失败', action.result.Message);
} else {
Ext.MessageBox.alert('失败', action.result.Message);
}
}
});
}
}, {
text: '关闭',
type: 'submit',
handler: function () {
win.close(this);
}
}]
});
var win = new Ext.Window({
title: "上传EXCEL",
width: 380,
height: 120,
modal: true,
resizable: false,
border: false,
items: imgform
});
win.show();
}
});