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.

564 lines
17 KiB
JavaScript

Ext.namespace('Shipping');
Shipping.MsOpCtnIndex = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.MsOpCtnIndex.superclass.constructor.call(this);
};
Ext.extend(Shipping.MsOpCtnIndex, Ext.Panel, {
PageSize: 30,
OprationStatus: null, //仅当弹出界面时使用
SelectedRecord: null,
EditRecord: null,
initUIComponents: function () {
//定义数据集
this.storeList = Ext.create('Ext.data.Store', {
pageSize: this.PageSize,
model: 'MsCtn',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/MvcShipping/MsOpCtnStatus/GetCtnListData',
reader: {
id: 'cntrid',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.girdcolums = [{
sortable: true,
dataIndex: 'cntrid',
header: 'cntrid',
hidden: true,
width: 150
}, {
sortable: true,
dataIndex: 'cntrno',
header: '箱号',
width: 150
}, {
sortable: true,
dataIndex: 'cntrowner',
header: '箱主',
width: 120
}, {
sortable: true,
dataIndex: 'cntype',
header: '箱型',
width: 120
}, {
sortable: true,
dataIndex: 'cnsource',
header: '箱源',
width: 80
}, {
sortable: true,
dataIndex: 'buytime',
header: '购买时间',
width: 80
}, {
sortable: true,
dataIndex: 'rent_begintime',
header: '租用开始日期',
width: 80
}, {
sortable: true,
dataIndex: 'rent_endtime',
header: '租用结束日期',
width: 80
}, {
sortable: true,
dataIndex: 'selltime',
header: '卖出时间',
width: 80
}, {
sortable: true,
dataIndex: 'statusref',
header: '状态',
width: 80
}, {
sortable: true,
dataIndex: 'vessel',
header: '船名',
width: 150
}, {
sortable: true,
dataIndex: 'voyage',
header: '航次',
width: 80
}, {
sortable: true,
dataIndex: 'positioncname',
header: '当前位置',
width: 80
}, {
sortable: true,
dataIndex: 'beginpostionref',
header: '启用位置',
width: 80
}, {
sortable: true,
dataIndex: 'REMARK',
header: '备注',
width: 150
}
];
this.gridListCellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
this.CheckBoxModel = Ext.create('Ext.selection.CheckboxModel');
//定义Grid
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,
viewConfig: {
getRowClass: function (record, rowIndex, rowParams, store) {
if (record.data.statusref == '卖出') {
return 'feestatus_Del';
}
}
},
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/CtnEdit', "CTN 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: 'CntrNo'
}, {
fieldLabel: '箱主',
name: 'CntrOwner'
}, {
fieldLabel: '箱型',
name: 'CntrSize'
}]
}]//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/CtnEdit', "CTN 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: "btnreset",
handler: function (button, event) {
},
scope: this
},
'-',
{
text: "导入集装箱",
iconCls: "btnexportexcel",
handler: function (button, event) {
this.onImportCtnClick(button, event);
},
scope: this
}, '-', {
text: "批量修改",
iconCls: "btnadd",
handler: function (button, event) {
this.winModifyShow.show();
},
scope: this
}
]
});
this.panelTop = new Ext.Panel({
layout: "border",
region: "north",
height: 80,
items: [this.panelBtn, this.formSearch]
});
Ext.apply(this, {
items: [this.panelTop, this.gridList]
});
this.onRefreshClick();
this.storeList.on('beforeload', function (store) {
var sql = this.getCondition();
Ext.apply(store.proxy.extraParams, { condition: sql });
}, this);
//编辑form
this.StoreStatus = Ext.create('Ext.data.Store', {
fields: ['ID', 'NAME']
});
this.StoreStatus.add({ "ID": 0, "NAME": "" });
this.StoreStatus.add({ "ID": 1, "NAME": "可用" });
this.StoreStatus.add({ "ID": 2, "NAME": "已用" });
this.StoreStatus.add({ "ID": 3, "NAME": "维修" });
this.StoreStatus.add({ "ID": 4, "NAME": "停用" });
this.StoreStatus.add({ "ID": 5, "NAME": "退租" });
this.StoreStatus.add({ "ID": 6, "NAME": "灭失" });
this.StoreStatus.add({ "ID": 7, "NAME": "卖出" });
this.comboxStatus = Ext.create('DsExt.ux.RefTableCombox', {
store: this.StoreStatus,
fieldLabel: '状态',
forceSelection: true,
name: 'status',
valueField: 'ID',
displayField: 'NAME'
});
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: [this.comboxStatus, {
fieldLabel: '租用开始',
format: 'Y-m-d',
xtype: 'datefield',
name: 'rent_begintime'
}, {
fieldLabel: '租用结束',
format: 'Y-m-d',
xtype: 'datefield',
name: 'rent_endtime'
}
]
}
]//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();
}
}]
});
},
onRefreshClick: function (button, event) {
var sql = this.getCondition();
this.storeList.load({
params: { start: 0, limit: this.PageSize, sort: '', condition: sql },
waitMsg: "正在查询数据...",
scope: this
});
},
deleteDetail: function () {
var selectedRecords = this.CheckBoxModel.selected.items;
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);
_this = this;
Ext.Msg.wait('正在删除数据...');
Ext.Ajax.request({
waitMsg: '正在删除数据...',
url: '/MvcShipping/MsOpCtnStatus/DeleteCtn',
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/modifyCtn',
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, "(cntrno like '%" + CntrNo + "%' )");
var CntrOwner = form.findField('CntrOwner').getValue();
sql = sql + getAndConSql(sql, CntrOwner, "(cntrowner like '%" + CntrOwner + "%' )");
var CntrSize = form.findField('CntrSize').getValue();
sql = sql + getAndConSql(sql, CntrSize, "(cntype like '%" + CntrSize + "%' )");
return sql;
},
OprationSwap: function () {
var ret = new Array();
ret[0] = this.OprationStatus;
ret[1] = this.storeList;
ret[2] = this.SelectedRecord;
return ret;
},
onImportCtnClick: function (button, event) {
var winAccess = new Shipping.CtnFileImport({
});
winAccess.StoreList = this.storeList;
winAccess.show();
return;
}
});