123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299 |
- /**
- * @class 系统菜单管理类
- * 功能:管理系统菜单,该菜单内容只有“系统管理员”才有访问权限
- *
- * @author 徐杨
- * @since v1.0 2014-07-18
- *
- */
- com.sinosoft.lz.system.right.SysMenu = function(){
-
- var _this = this;
- _this.listTreeGrid = null;
-
- /** 菜单表名 **/
- var tableName = 'SYS_MENU';
- /** 根节点 **/
- var root = 10;
-
- var classid = 893;
-
- function filterHandler(childData){
- //alert(JSON.stringify(childData));
- var newData=[];
- $.each(childData["rows"],function(idx,item){
- newData.push(item);
- });
- return newData;
- }
- /******新增Form信息***********/
- _this.addForm = function(){
- /*
- * 思路:
- * 当点击一条记录的时候获得该记录id的值, 并作为新增记录的id值
- * 如果没有点击记录,则默认值是根节点id
- * 并将id值和父id值给表单初始化
- */
- var rows = _this.listTreeGrid.getSelectedRows();
- var initrow = {};
- initrow['classid'] = classid;
- if(rows.length == 1){
- initrow['PARENTCODE_893'] = rows[0]['code'];
- }else{
- initrow['PARENTCODE_893'] = root;
- }
- $.ajax({
- type: "POST",
- url:$.pathname() + '/ws/indexMag/SysMenuService/newMenu',
- data: initrow['PARENTCODE_893'],
- success: function(data){
- // alert(data);
- if(data != '2'){
- top.Dialog.alert("此处不允许添加新菜单!");
- return ;
- }else {
- //自动生成id
- createId(initrow['PARENTCODE_893'], function(id){
- var diag = new top.Dialog();
- diag.Title = '新增';
- diag.URL = $.pathname() + '/page/system/right/addMenu.jsp?fd_id=&code='+id+"&pcode="+initrow['PARENTCODE_893'];
- //alert(diag.URL);
- diag.OkButtonText = '提交';
- diag.OKEvent = function(){
- _this.add(diag);
- };
- diag.Width = 750; //宽度
- diag.Height = 320; //高度
- diag.ButtonAlign = 'center';
- diag.show();
- });
- }
- },
- error:function(data){
-
- }
- });
-
- };
-
-
- /**
- * 功能:保存方法
- */
- _this.add = function(diag) {
- $form = diag.innerFrame.contentWindow.$('#sysmenu_form');
- var valid = $form.validationEngine({returnIsValid: true});
- if(valid){
- var formValue = $form.serialize();
- $.ajax({
- url : url = $.pathname() + '/ws/crud/CRUDService/create',
- type : 'post',
- timeout : 15000,
- data : formValue,
- dataType : 'json',
- success : function(data){
-
- top.Dialog.close();
- top.Dialog.alert("提交成功", null, null, null, 1);
- window.location.href='/nwyj/page/system/right/SysMenu.jsp';
- },
- error : function(e){
- $.messager.alert('系统提示信息', '访问服务失败!', 'error');
- }
- });
- }
- };
-
-
- /**
- * 功能:根据父id自动创建id
- * @param parentId 父id
- * @param fn 成功时调用的函数
- */
- var createId = function(parentId, fn){
- var url = $.pathname() + '/ws/indexMag/SysMenuService/createDetail';
- var param = {node : parentId, name : tableName};
- $.ajax({
- url : url,
- type : 'post',
- data : param,
- dataType : 'text',
- success : function(data){
- if (data) fn(data);
- },
- error : function(){
- $.messager.alert('系统提示信息', '访问服务失败!', 'error');
- }
- });
- };
- /******修改Form信息***********/
- _this.editForm = function(){
- var rows = _this.listTreeGrid.getSelectedRows();
- var rowsLength = rows.length;
- if (rowsLength == 0) {
- Dialog.alert('请选中要修改的记录!');
- return;
- } else if (rowsLength > 1) {
- Dialog.alert('请选中一条要修改的记录!');
- return;
- } else {
- var fd_id = _this.listTreeGrid.getSelectedRow().fd_objectid; //
- var diag = new Dialog();
- diag.Title = '修改';
- diag.URL = $.pathname() +'/page/system/right/addMenu.jsp?fd_id='+fd_id;
- diag.OkButtonText = '提交';
- diag.OKEvent = function(){
- _this.edit(diag);
- };
- diag.Width = 750; //宽度
- diag.Height = 320; //高度
- diag.ButtonAlign = 'center';
- diag.show();
- }
- };
- _this.edit = function(diag){
- $form = diag.innerFrame.contentWindow.$('#sysmenu_form');
- var valid = $form.validationEngine({returnIsValid: true});
-
- if(valid){
- var formValue = $form.serialize();
- $.ajax({
- url : $.pathname() + '/ws/crud/CRUDService/update',
- type : 'post',
- timeout : 15000,
- data : formValue,
- dataType : 'json',
- success : function(data){
- Dialog.close();
- Dialog.alert("修改成功", null, null, null, 1);
- _this.listTreeGrid.loadData(); //刷新表格数据
- window.location.href='/nwyj/page/system/right/SysMenu.jsp';
- },
- error : function(e){
- $.messager.alert('系统提示信息', '访问服务失败!', 'error');
- }
- });
- }
- };
- /****删除****/
- _this.del = function(){
- var rows = _this.listTreeGrid.getSelectedRows();
- var rowsLength = rows.length;
- if (rowsLength == 0) {
- top.Dialog.alert('请选中要删除的记录!');
- return;
- }
- var ids = '';
- for ( var i = 0; i < rowsLength; i++) {
- ids += rows[i].fd_objectid + ',';
- }
- top.Dialog.confirm('确定要删除吗?', function() {
- $.post($.pathname() +'/ws/crud/CRUDService/delete/', {
- objectIDs : ids,
- classid : '893'
- },
- function(result) {
- if (result.Msg.sucsess == true) {
- top.Dialog.alert('删除成功!', null, null, null, 1);
- window.location.href='/nwyj/page/system/right/SysMenu.jsp';
- _this.listTreeGrid.loadData();
- }else{
- top.Dialog.alert('删除失败!');
- }
- }, 'json');
- });
- };
-
- $('#searchButton').click(function() {
- var name = $('#searchInput').val();
- $.ajax({
- url : $.pathname() + '/ws/crud/CRUDService/query',
- type : 'post',
- timeout : 15000,
- data : {'RIGHTNAME_893':name,'listId':'893'},
- dataType : 'json',
- success : function(data){
- _this.listTreeGrid.loadData(); //刷新表格数据
- },
- error : function(e){
- $.messager.alert('系统提示信息', '访问服务失败!', 'error');
- }
- });
- });
- _this.InitGrid = function (){
-
- var gridData={"rows":[{"rightName":"菜单管理","isParent":true,"open":false}]};
-
- _this.listTreeGrid = $("#system_right_sysmenu").quiGrid({
- columns: [
- { name: 'fd_objectid', align: 'left',hide:true },
- { display: '菜单名称', name: 'rightName', id:'code', align: 'left', width:'20%' },
- { display: '节点', name: 'code', align: 'left',hide:true, width:'20%' },
- { display: '父节点', name: 'parentcode', align: 'left',hide:true, width:'20%' } ,
- { display: '排序号', name: 'sort', align: 'left', width:'20%' },
- { display: '按钮图片', name: 'img', align: 'left', width:'20%' },
- { display: '菜单功能', name: 'functionlink', align: 'left', width:'20%' }
- ],
- toolbar:{
- items:[
- {text: '新增',click:_this.addForm, iconClass: 'icon_add'},
- { line : true },
- {text: '删除', click: _this.del, iconClass: 'icon_delete'},
- { line : true },
- {text: '修改', click:_this.editForm, iconClass: 'icon_edit'},
- { line : true }
- // ,
- // {text: '查看详细信息', /*click: exportPageData,*/ iconClass: 'icon_view'}
- ]
- } ,
- height: '100%',
- width:'100%',
- percentWidthMode:true,
- checkbox:true,
- usePager: false,
- data:gridData,
- autoCheckChildren:true,
- tree: { columnId: 'code' },
- treeChildDataPath: $.pathname() +"/ws/indexMag/SysMenuService/getMenutTree/",
- autoCheckChildren:false,
- treeAjax:true,
- treeAutoParam:"code",
- treeDataFilter:filterHandler
- });
- };
- return {
- init : function(){
- _this.InitGrid();
- },
- searchHandler :function(){
- var name = $('#searchInput').val();
- $.ajax({
- url : $.pathname() + '/ws/crud/CRUDService/queryQuiTree',
- type : 'post',
- timeout : 15000,
- data : {'RIGHTNAME_893':name,'listId':'893'},
- dataType : 'json',
- success : function(data){
- alert($treegrid.loadData());
- $treegrid.loadData(); //刷新表格数据
- },
- error : function(e){
- $.messager.alert('系统提示信息', '访问服务失败!', 'error');
- }
- });
- }
- };
-
-
- }();
- $(function(){
- com.sinosoft.lz.system.right.SysMenu.init();
- });
- $.menu = com.sinosoft.lz.system.right.SysMenu;
|