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.

565 lines
20 KiB
JavaScript

11 months ago
Ext.namespace('Shipping');
Shipping.MsCodeGoodsIndex = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.MsCodeGoodsIndex.superclass.constructor.call(this);
};
//创建弹出窗口
Ext.extend(Shipping.MsCodeGoodsIndex, Ext.Panel, {
OprationStatus: null, //仅当弹出界面时使用 电话里得人原来是你的妈咪
SelectedRecord: null,
status: null,
PageSize: 30,
initUIComponents: function () {
this.formname = "MsOpCtnRentBuyIndex"; //页面名称
this.initgirdcolums = [
{
sortable: true,
dataIndex: 'GID',
header: 'GID',
width: 1,
hidden: true
},
{
sortable: true,
dataIndex: 'STATUSREF',
header: '箱单状态',
width: 90
}, {
sortable: true,
dataIndex: 'CTNTYPEREF',
header: '箱单类型',
width: 90
}, {
sortable: true,
dataIndex: 'CNTROWNER',
header: '箱主',
width: 100
}, {
sortable: true,
dataIndex: 'CNSOURCE',
header: '箱源',
width: 90
}, {
sortable: true,
dataIndex: 'BUYTIME',
header: '购买日期',
width: 90
}, {
sortable: true,
dataIndex: 'SELLTIME',
header: '卖出日期',
width: 90
},
{
sortable: true,
dataIndex: 'RENT_BEGINTIME',
header: '租用开始日期',
width: 90
},
{
sortable: true,
dataIndex: 'RENT_ENDTIME',
header: '租用结束日期',
width: 90
},
{
sortable: true,
dataIndex: 'BSDATE',
header: '操作时间',
width: 90
},
{
sortable: true,
dataIndex: 'INPUTBY',
header: '操作人',
width: 90
},
{
sortable: true,
dataIndex: 'AUDITBY',
header: '审核人',
width: 90
}
,
{
sortable: true,
dataIndex: 'BSNO',
header: '委托编号',
width: 80
},
{
sortable: true,
dataIndex: 'Remarks',
header: '备注',
width: 100
}
];
this.girdcolums = this.initgirdcolums;
//定义数据集
this.storeList = Ext.create('Ext.data.Store', {
model: 'MsCodeGoods',
pageSize: this.PageSize,
proxy: {
type: 'ajax',
url: '/MvcShipping/MsOpCtnRentBuy/GetDataList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
//定义Grid
this.gridList = new Ext.grid.GridPanel({
store: this.storeList,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
columns: this.girdcolums,
bbar: Ext.create('Ext.PagingToolbar', {
store: this.storeList,
displayInfo: true,
displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录',
emptyMsg: "没有数据"
})
});
this.girdcolums = DsTruck.GetGridPanel(USERID, this.formname, this.girdcolums, 1); //使用者id表名中间column数组跳过一开始的几列
this.girdcolums.unshift(new Ext.grid.RowNumberer());
this.gridList.addListener('itemdblclick', function (dataview, record, item, index, e, b) {
this.SelectedRecord = record;
switch (this.SelectedRecord.data.CTNTYPEREF) {
case "买箱":
this.status = 1;
break;
case "租入":
this.status = 2;
break;
case "租出":
this.status = 3;
break;
case "卖箱":
this.status = 4;
break;
default:
break;
}
this.OprationStatus = 'edit';
DsOpenEditWin('/MvcShipping/MsOpCtnRentBuy/Edit');
}, this);
//#region formSearch
//#region formSearch枚举参照相关
//#endregion
_this = this;
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: '80%'
},
items: [, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '箱号',
name: 'cntrno',
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
}, {
fieldLabel: '箱主',
name: 'cntrowner',
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
},
{
fieldLabel: '委托编号',
name: 'BSNO',
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
}
]
}
]//end items(fieldset 1)
}//end fieldset 1
]//end root items
});
//#endregion formSearch
var h = "1";
//查询工具条
_o = this;
_this = this;
_aaa = this;
this.panelBtn = new Ext.Panel({
region: "north",
tbar: [
{
text: "新建",
iconCls: "btnadd",
menu: [
{ text: "买箱",
handler: function (button, event) {
_aaa.status = '1';
_aaa.OprationStatus = 'add';
DsOpenEditWin('/MvcShipping/MsOpCtnRentBuy/Edit');
}
}, { text: "租入",
handler: function (menu, event) {
_aaa.status = '2';
_aaa.OprationStatus = 'add';
DsOpenEditWin('/MvcShipping/MsOpCtnRentBuy/Edit');
}
}, , { text: "租出",
handler: function (menu, event) {
_aaa.status = '3';
_aaa.OprationStatus = 'add';
DsOpenEditWin('/MvcShipping/MsOpCtnRentBuy/Edit');
}
}, , { text: "卖箱",
handler: function (menu, event) {
_aaa.status = '4';
_aaa.OprationStatus = 'add';
DsOpenEditWin('/MvcShipping/MsOpCtnRentBuy/Edit');
}
}],
scope: this
},
{
text: "删除",
iconCls: "btndelete",
handler: function (button, event) {
this.onDeleteClick(button, event);
},
scope: this
},
'-',
{
text: "执行查询",
iconCls: "btnrefresh",
handler: function (button, event) {
this.onRefreshClick(button, event);
},
scope: this
},
{
text: "重置条件",
iconCls: "btnreset",
handler: function (button, event) {
var form = this.formSearch.getForm();
form.findField('cntrno').setValue("");
form.findField('cntrowner').setValue("");
form.findField('BSNO').setValue("");
},
scope: this
},
{
text: "提交审核",
id: "tjsh",
iconCls: "btnadd",
menu: [
{ text: "提交审核",
handler: function (button, event) {
var s = 2;
_aaa.ontjClick(button, event, s);
}
}, { text: "取消提交",
handler: function (button, event, s) {
var s = 1;
_aaa.ontjClick(button, event, s);
}
}],
scope: this
},
{
text: "审核通过",
id: "shtg",
iconCls: "btnsubmit",
menu: [
{ text: "审核通过",
handler: function (button, event) {
var s = 3;
_aaa.ontjClick(button, event, s);
}
}, { text: "取消审核",
handler: function (button, event, s) {
var s = 4;
_aaa.ontjClick(button, event, s);
}
}],
scope: this
}, '-', {
text: "保存列表样式",//缠中说缠
menu: [
{ text: "保存",
handler: function (button, event) {
this.girdcolums = DsTruck.SaveGridPanel(USERID, _this.formname, _this.gridList.columns, _this.girdcolums, 1, true);
}
}, { text: "初始化",
handler: function (menu, event) {
_this.InitGrid(_this.initgirdcolums);
_this.girdcolums = DsTruck.SaveGridPanel(USERID, _this.formname, _this.gridList.columns, _this.initgirdcolums, 1, true);
}
}],
scope: this
}
]
});
this.panelTop = new Ext.Panel({
layout: "border",
region: "north",
height: 80,
items: [this.formSearch, this.panelBtn]
});
Ext.apply(this, {
items: [this.panelTop, this.gridList]
});
this.storeList.on('beforeload', function (store) {
this.setSaveBtnStatus();
var sql = this.getCondition();
Ext.apply(store.proxy.extraParams, { condition: sql });
}, this);
this.gridList.reconfigure(this.storeList, this.girdcolums);
this.onRefreshClick();
}, //end initUIComponents
onRefreshClick: function (button, event) {
var sql = this.getCondition();
var form = this.formSearch.getForm();
if (!form.isValid()) {
Ext.Msg.alert('提示', '查询条件赋值错误,请检查。');
return '';
}
this.storeList.load({
params: { start: 0, limit: this.PageSize, sort: '', condition: sql },
waitMsg: "正在查询数据...",
scope: this
});
},
//提交审核
ontjClick: function (button, event, s) {
var selections = this.gridList.getSelectionModel().getSelection();
if (selections.length == 0) {
Ext.Msg.show({ title: '提示', msg: '请先选择单据!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
var record = selections[0];
var tijiao = "";
var sdie = "";
if (s == "2" || s == 2) {
tijiao = "确定要提交审核吗?";
sdie = "提交审核";
} else if (s == "1" || s == 1) {
tijiao = "确认要取消审核吗?";
sdie = "新建";
} else if (s == "3" || s == 3) {
tijiao = "确认要审核通过吗?"
sdie = "审核";
} else if (s == "4" || s == 4) {
tijiao = "确认要取消审核吗";
sdie = "新建";
}
Ext.MessageBox.confirm('提示', tijiao, function (btn) {
if (btn == 'yes') {
Ext.Msg.wait('正在提交数据...');
Ext.Ajax.request({
waitMsg: '正在提交数据...',
url: '/MvcShipping/MsOpCtnRentBuy/tjsh',
params: {
data: Ext.JSON.encode(record.data),
st: s
},
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);
}, //onDeleteClick
//提交审核
setSaveBtnStatus: function () {
var tjsh = Ext.getCmp('tjsh');
var shtg = Ext.getCmp('shtg');
Ext.Ajax.request({
waitMsg: '',
url: '/MvcShipping/MsBaseInfo/GetUserModuleEnable',
params: {
modulename: "modFeenotPraa"
},
callback: function (options, success, response) {
if (success) {
var result = Ext.JSON.decode(response.responseText);
if (result.Success != true) {
tjsh.disable();
} else {
tjsh.enable();
}
} else {
}
},
scope: this
});
Ext.Ajax.request({
waitMsg: '',
url: '/MvcShipping/MsBaseInfo/GetUserModuleEnable',
params: {
modulename: "jizhuangxsh"
},
callback: function (options, success, response) {
if (success) {
var result = Ext.JSON.decode(response.responseText);
if (result.Success != true) {
shtg.disable();
} else {
shtg.enable();
}
} else {
}
},
scope: this
});
},
onDeleteClick: function (button, event) {
var selections = this.gridList.getSelectionModel().getSelection();
if (selections.length == 0) {
Ext.Msg.show({ title: '提示', msg: '请先选择单据!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
var record = selections[0];
Ext.MessageBox.confirm('提示', '确定删除该记录吗?', function (btn) {
if (btn == 'yes') {
Ext.Msg.wait('正在删除数据...');
Ext.Ajax.request({
waitMsg: '正在删除数据...',
url: '/MvcShipping/MsOpCtnRentBuy/Delete',
params: {
data: Ext.JSON.encode(record.data)
},
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
this.storeList.remove(record);
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);
}, //onDeleteClick
//#region 加载函数
InitGrid: function (grid) {
var agirdcolums = grid;
this.gridList.reconfigure(this.storeList, agirdcolums);
},
//#endregion
getCondition: function () {
var form = this.formSearch.getForm();
if (!form.isValid()) {
Ext.Msg.alert('提示', '查询条件赋值错误,请检查。');
return '';
}
var sql = '';
var cno = form.findField('cntrno').getValue();
var cowner = form.findField('cntrowner').getValue();
var bs = form.findField('BSNO').getValue();
sql = sql + getAndConSql(sql, cno, "o.gid=(select top 1 linkgid from op_ctn_outinmx where cntrno='" + cno + "')");
sql = sql + getAndConSql(sql, cowner, "cntrowner ='" + cowner + "'");
sql = sql + getAndConSql(sql, bs, "BSNO ='" + bs + "'");
return sql;
},
OprationSwap: function () {
var ret = new Array();
ret[0] = this.OprationStatus;
ret[1] = this.storeList;
ret[2] = this.SelectedRecord;
ret[3] = this.status;
return ret;
}
});