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.
480 lines
15 KiB
JavaScript
480 lines
15 KiB
JavaScript
Ext.namespace('Shipping');
|
|
|
|
Shipping.UserMainFormSet = function (config) {
|
|
Ext.applyIf(this, config);
|
|
this.initUIComponents();
|
|
window.Shipping.UserMainFormSet.superclass.constructor.call(this);
|
|
};
|
|
|
|
|
|
Ext.extend(Shipping.UserMainFormSet, Ext.Panel, {
|
|
initUIComponents: function () {
|
|
|
|
|
|
|
|
|
|
//#region 框架结构
|
|
|
|
|
|
|
|
Ext.define('DsShipping.ux.ModuleModel', {
|
|
extend: 'Ext.data.Model',
|
|
fields: [
|
|
{ name: 'GID', type: 'string' },
|
|
{ name: 'MODULEID', type: 'string' },
|
|
{ name: 'MODULENAME', type: 'string' },
|
|
{ name: 'MODULETITLE', type: 'string' },
|
|
{ name: 'MODULEURL', type: 'string' },
|
|
{ name: 'SORT', type: 'number' },
|
|
{ name: 'MODULEWIDTH', type: 'number' },
|
|
{ name: 'ISSYS', type: 'bool' }
|
|
]
|
|
});
|
|
|
|
Ext.define('DsExt.ux.RefTableStore', {
|
|
extend: 'Ext.data.Store',
|
|
|
|
constructor: function (config) {
|
|
|
|
var proxy = {
|
|
type: 'ajax',
|
|
timeout: 120000,
|
|
url: config.proxy.url,
|
|
reader: {
|
|
root: 'data'
|
|
}
|
|
};
|
|
|
|
config.proxy = proxy;
|
|
|
|
this.callParent([config]);
|
|
}
|
|
});
|
|
|
|
|
|
this.storeModuTree = Ext.create('DsExt.ux.RefTableStore', {
|
|
model: 'DsShipping.ux.ModuleModel',
|
|
proxy: { url: '/MvcShipping/MsMainForm/GetDataList' }
|
|
});
|
|
this.cellEditingDrChFee = Ext.create('Ext.grid.plugin.CellEditing', {
|
|
clicksToEdit: 1
|
|
|
|
});
|
|
|
|
this.gridList = new Ext.grid.GridPanel({
|
|
store: this.storeModuTree,
|
|
enableHdMenu: false,
|
|
region: 'center',
|
|
loadMask: { msg: "数据加载中,请稍等..." },
|
|
trackMouseOver: true,
|
|
viewConfig: {
|
|
autoHeight: true
|
|
|
|
},
|
|
disableSelection: false,
|
|
columns: [{
|
|
sortable: true,
|
|
dataIndex: 'GID',
|
|
header: 'GID',
|
|
hidden: true,
|
|
width: 120
|
|
}, {
|
|
sortable: true,
|
|
dataIndex: 'MODULENAME',
|
|
header: '模块名称',
|
|
width: 220
|
|
}
|
|
]
|
|
});
|
|
|
|
this.gridList.addListener('itemdblclick', function (dataview, record, item, index, e, b) {
|
|
this.onAddClick();
|
|
}, this);
|
|
|
|
|
|
this.topleft = Ext.create('Ext.panel.Panel', {
|
|
title: "全部主页模块",
|
|
layout: "border", //设置为手风琴布局
|
|
width: 240,
|
|
minWidth: 90,
|
|
region: "west", //设置方位
|
|
split: true,
|
|
collapsible: true,
|
|
items: [this.gridList]
|
|
});
|
|
|
|
this.storeModuUser = Ext.create('DsExt.ux.RefTableStore', {
|
|
model: 'DsShipping.ux.ModuleModel',
|
|
proxy: { url: '/MvcShipping/MsMainForm/GetUserDataList' }
|
|
});
|
|
|
|
this.gridListUser = new Ext.grid.GridPanel({
|
|
store: this.storeModuUser,
|
|
enableHdMenu: false,
|
|
region: 'center',
|
|
plugins: [this.cellEditingDrChFee],
|
|
loadMask: { msg: "数据加载中,请稍等..." },
|
|
trackMouseOver: true,
|
|
viewConfig: {
|
|
autoHeight: true
|
|
|
|
},
|
|
disableSelection: false,
|
|
columns: [{
|
|
sortable: true,
|
|
dataIndex: 'GID',
|
|
header: 'GID',
|
|
hidden: true,
|
|
width: 120
|
|
}, {
|
|
sortable: true,
|
|
dataIndex: 'USERID',
|
|
header: 'USERID',
|
|
hidden: true,
|
|
width: 120
|
|
}, {
|
|
sortable: true,
|
|
dataIndex: 'MODULENAME',
|
|
header: '模块名称',
|
|
width: 220
|
|
}, {
|
|
sortable: true,
|
|
dataIndex: 'MODULEWIDTH',
|
|
header: '模块宽度',
|
|
editor: {
|
|
xtype: 'numberfield'
|
|
|
|
},
|
|
width: 100
|
|
}, {
|
|
sortable: true,
|
|
dataIndex: 'SORT',
|
|
header: '顺序号',
|
|
width: 100
|
|
}, {
|
|
header: '设置',
|
|
width: 100,
|
|
dataIndex: 'GID',
|
|
sortable: true,
|
|
renderer: function (data, metadata, record, rowIndex, columnIndex, store) {
|
|
var linkGID = store.getAt(rowIndex).get('GID');
|
|
var moduleName = store.getAt(rowIndex).get('MODULENAME');
|
|
return "<a href='javascript:fnDetailSetting(\"" + linkGID + "\", \"" + moduleName + "\");' style='font-size:12px;color:#f39800;font-family:微软雅黑'>详细设置</a>";
|
|
}
|
|
}
|
|
]
|
|
});
|
|
|
|
|
|
this.panelBtn = new Ext.Panel({
|
|
region: "north",
|
|
tbar: [{
|
|
text: "添加显示",
|
|
iconCls: "btnadd",
|
|
handler: function (button, event) {
|
|
this.onAddClick(button, event);
|
|
},
|
|
scope: this
|
|
}, '-', {
|
|
text: "保存显示",
|
|
iconCls: "btnsave",
|
|
handler: function (button, event) {
|
|
this.onPostClick(button, event);
|
|
},
|
|
scope: this
|
|
},
|
|
'-',
|
|
{
|
|
text: "取消显示",
|
|
iconCls: "btndelete",
|
|
handler: function (button, event) {
|
|
this.onDeleteClick(button, event);
|
|
},
|
|
scope: this
|
|
},
|
|
'-',
|
|
{
|
|
text: "上移",
|
|
handler: function (button, event) {
|
|
this.PrevRecord();
|
|
},
|
|
scope: this
|
|
},
|
|
{
|
|
text: "下移",
|
|
handler: function (button, event) {
|
|
this.NextRecord();
|
|
},
|
|
scope: this
|
|
}
|
|
]
|
|
});
|
|
|
|
this.panelCenter = new Ext.Panel({
|
|
title: "个人主页模块",
|
|
layout: "border",
|
|
region: "center",
|
|
items: [this.panelBtn, this.gridListUser]
|
|
});
|
|
|
|
|
|
Ext.apply(this, {
|
|
items: [this.topleft, this.panelCenter]
|
|
});
|
|
//#endregion
|
|
|
|
//#region 其他
|
|
|
|
this.storeModuTree.load({
|
|
params: { condition: '' },
|
|
waitMsg: "正在查询数据...",
|
|
scope: this
|
|
});
|
|
this.storeModuUser.load({
|
|
params: { condition: '' },
|
|
waitMsg: "正在查询数据...",
|
|
scope: this
|
|
});
|
|
|
|
//#endregion
|
|
}, //end initUIComponents
|
|
onAddClick: 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 addrecord = selections[0];
|
|
var newSerialno = this.GetHandleSerialNo(this.storeModuUser);
|
|
|
|
|
|
var record = Ext.create('DsShipping.ux.ModuleModel', {
|
|
GID: NewGuid(),
|
|
MODULEID: addrecord.data.GID,
|
|
MODULENAME: addrecord.data.MODULENAME,
|
|
MODULEWIDTH: addrecord.data.MODULEWIDTH,
|
|
SORT: newSerialno
|
|
|
|
});
|
|
|
|
this.storeModuUser.add(record);
|
|
|
|
|
|
|
|
},
|
|
GetHandleSerialNo: function (store) {
|
|
var result = 0;
|
|
|
|
if (result == 0) {
|
|
for (var i = 0; i < store.getCount(); i += 1) {
|
|
var member = store.getAt(i);
|
|
if (parseInt(member.data.SORT) > parseInt(result)) {
|
|
result = member.data.SORT;
|
|
}
|
|
}
|
|
}
|
|
|
|
result = parseInt(result) + 1;
|
|
return result;
|
|
},
|
|
onPostClick: function (button, event) {
|
|
|
|
var bodyDrChFeeDatas = [];
|
|
var i;
|
|
|
|
|
|
|
|
for (i = 0; i < this.storeModuUser.getCount(); i += 1) {
|
|
var memberyf = this.storeModuUser.getAt(i);
|
|
|
|
bodyDrChFeeDatas.push(memberyf);
|
|
|
|
};
|
|
var jsonChFeeBody = ConvertRecordsToJsonAll(bodyDrChFeeDatas);
|
|
|
|
|
|
_this = this;
|
|
Ext.Msg.wait('正在保存数据, 请稍侯..');
|
|
Ext.Ajax.request({
|
|
waitMsg: '正在保存数据...',
|
|
url: '/MvcShipping/MsMainForm/SaveUserSetDetail',
|
|
scope: this,
|
|
params: {
|
|
body: jsonChFeeBody
|
|
},
|
|
callback: function (options, success, response) {
|
|
if (success) {
|
|
Ext.MessageBox.hide();
|
|
var jsonresult = Ext.JSON.decode(response.responseText);
|
|
if (jsonresult.Success) {
|
|
|
|
_this.storeModuUser.load({
|
|
params: { condition: '' },
|
|
waitMsg: "正在查询数据...",
|
|
scope: this
|
|
});
|
|
} 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
|
|
});
|
|
}
|
|
}
|
|
});
|
|
}, //end save
|
|
onDeleteClick: function (button, event) {
|
|
var selections = this.gridListUser.getSelectionModel().getSelection();
|
|
if (selections.length == 0) {
|
|
Ext.Msg.show({ title: '提示', msg: '请先选择单据!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
|
|
return;
|
|
}
|
|
|
|
var record = selections[0];
|
|
if (record.data.ISSYS == true) {
|
|
Ext.Msg.show({ title: '提示', msg: '此模块为系统模块,不允许取消显示!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
_this = this;
|
|
Ext.MessageBox.confirm('提示', '确定删除该记录吗?', function (btn) {
|
|
if (btn == 'yes') {
|
|
Ext.Msg.wait('正在删除数据...');
|
|
Ext.Ajax.request({
|
|
waitMsg: '正在删除数据...',
|
|
url: '/MvcShipping/MsMainForm/DeleteUserModule',
|
|
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.storeModuUser.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);
|
|
},
|
|
PrevRecord: function () {
|
|
|
|
var selections = this.gridListUser.getSelectionModel().getSelection();
|
|
if (selections.length == 0) {
|
|
Ext.Msg.show({ title: '提示', msg: '请先选择模块!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
|
|
return;
|
|
}
|
|
|
|
var aRecord = selections[0];
|
|
|
|
var j = this.storeModuUser.indexOf(aRecord);
|
|
if (j == 0) {
|
|
Ext.Msg.show({ title: '警告', msg: '已是最前模块', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
|
|
|
|
return;
|
|
}
|
|
if (j == this.storeModuUser.count) {
|
|
Ext.Msg.show({ title: '警告', msg: '已是最后模块', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
var b = j - 1;
|
|
|
|
var bRecord = this.storeModuUser.getAt(b);
|
|
var aGID = aRecord.data.GID;
|
|
var aMODULEID = aRecord.data.MODULEID;
|
|
var aMODULENAME = aRecord.data.MODULENAME;
|
|
var aMODULEWIDTH = aRecord.data.MODULEWIDTH;
|
|
|
|
var bGID = bRecord.data.GID;
|
|
var bMODULEID = bRecord.data.MODULEID;
|
|
var bMODULENAME = bRecord.data.MODULENAME;
|
|
var bMODULEWIDTH = bRecord.data.MODULEWIDTH;
|
|
|
|
bRecord.set("GID", aGID);
|
|
bRecord.set("MODULEID", aMODULEID);
|
|
bRecord.set("MODULENAME", aMODULENAME);
|
|
bRecord.set("MODULEWIDTH", aMODULEWIDTH);
|
|
bRecord.commit();
|
|
|
|
aRecord.set("GID", bGID);
|
|
aRecord.set("MODULEID", bMODULEID);
|
|
aRecord.set("MODULENAME", bMODULENAME);
|
|
aRecord.set("MODULEWIDTH", bMODULEWIDTH);
|
|
aRecord.commit();
|
|
|
|
this.gridListUser.getSelectionModel().select(b);
|
|
},
|
|
NextRecord: function () {
|
|
var selections = this.gridListUser.getSelectionModel().getSelection();
|
|
if (selections.length == 0) {
|
|
Ext.Msg.show({ title: '提示', msg: '请先选择模块!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
|
|
return;
|
|
}
|
|
|
|
var aRecord = selections[0];
|
|
|
|
var j = this.storeModuUser.indexOf(aRecord);
|
|
|
|
if (j == this.storeModuUser.count) {
|
|
Ext.Msg.show({ title: '警告', msg: '已是最后模块', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
var b = j + 1;
|
|
|
|
var bRecord = this.storeModuUser.getAt(b);
|
|
var aGID = aRecord.data.GID;
|
|
var aMODULEID = aRecord.data.MODULEID;
|
|
var aMODULENAME = aRecord.data.MODULENAME;
|
|
var aMODULEWIDTH = aRecord.data.MODULEWIDTH;
|
|
|
|
var bGID = bRecord.data.GID;
|
|
var bMODULEID = bRecord.data.MODULEID;
|
|
var bMODULENAME = bRecord.data.MODULENAME;
|
|
var bMODULEWIDTH = bRecord.data.MODULEWIDTH;
|
|
|
|
bRecord.set("GID", aGID);
|
|
bRecord.set("MODULEID", aMODULEID);
|
|
bRecord.set("MODULENAME", aMODULENAME);
|
|
bRecord.set("MODULEWIDTH", aMODULEWIDTH);
|
|
bRecord.commit();
|
|
|
|
aRecord.set("GID", bGID);
|
|
aRecord.set("MODULEID", bMODULEID);
|
|
aRecord.set("MODULENAME", bMODULENAME);
|
|
aRecord.set("MODULEWIDTH", bMODULEWIDTH);
|
|
aRecord.commit();
|
|
this.gridListUser.getSelectionModel().select(b);
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
/*function fnDetailSetting(id) {
|
|
alert(id);
|
|
document.getElementById("lay").style.display = "block";
|
|
}*/
|