53d19d035ee3dcadcdb7fdd409b217ba461f000b.svn-base 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. /**
  2. * @class 系统菜单管理类
  3. * 功能:管理系统菜单,该菜单内容只有“系统管理员”才有访问权限
  4. *
  5. * @author 徐杨
  6. * @since v1.0 2014-07-18
  7. *
  8. */
  9. com.sinosoft.lz.system.right.SysMenu = function(){
  10. var _this = this;
  11. _this.listTreeGrid = null;
  12. /** 菜单表名 **/
  13. var tableName = 'SYS_MENU';
  14. /** 根节点 **/
  15. var root = 10;
  16. var classid = 893;
  17. function filterHandler(childData){
  18. //alert(JSON.stringify(childData));
  19. var newData=[];
  20. $.each(childData["rows"],function(idx,item){
  21. newData.push(item);
  22. });
  23. return newData;
  24. }
  25. /******新增Form信息***********/
  26. _this.addForm = function(){
  27. /*
  28. * 思路:
  29. * 当点击一条记录的时候获得该记录id的值, 并作为新增记录的id值
  30. * 如果没有点击记录,则默认值是根节点id
  31. * 并将id值和父id值给表单初始化
  32. */
  33. var rows = _this.listTreeGrid.getSelectedRows();
  34. var initrow = {};
  35. initrow['classid'] = classid;
  36. if(rows.length == 1){
  37. initrow['PARENTCODE_893'] = rows[0]['code'];
  38. }else{
  39. initrow['PARENTCODE_893'] = root;
  40. }
  41. //自动生成id
  42. createId(initrow['PARENTCODE_893'], function(id){
  43. var diag = new top.Dialog();
  44. diag.Title = '新增';
  45. diag.URL = $.pathname() + '/page/system/right/addMenu.jsp?fd_id=&code='+id+"&pcode="+initrow['PARENTCODE_893'];
  46. //alert(diag.URL);
  47. diag.OkButtonText = '提交';
  48. diag.OKEvent = function(){
  49. _this.add(diag);
  50. };
  51. diag.Width = 750; //宽度
  52. diag.Height = 320; //高度
  53. diag.ButtonAlign = 'center';
  54. diag.show();
  55. });
  56. };
  57. /**
  58. * 功能:保存方法
  59. */
  60. _this.add = function(diag) {
  61. $form = diag.innerFrame.contentWindow.$('#sysmenu_form');
  62. var valid = $form.validationEngine({returnIsValid: true});
  63. if(valid){
  64. var formValue = $form.serialize();
  65. $.ajax({
  66. url : url = $.pathname() + '/ws/crud/CRUDService/create',
  67. type : 'post',
  68. timeout : 15000,
  69. data : formValue,
  70. dataType : 'json',
  71. success : function(data){
  72. _this.listTreeGrid.loadData(); //刷新表格数据
  73. top.Dialog.close();
  74. top.Dialog.alert("提交成功", null, null, null, 1);
  75. },
  76. error : function(e){
  77. $.messager.alert('系统提示信息', '访问服务失败!', 'error');
  78. }
  79. });
  80. }
  81. };
  82. /**
  83. * 功能:根据父id自动创建id
  84. * @param parentId 父id
  85. * @param fn 成功时调用的函数
  86. */
  87. var createId = function(parentId, fn){
  88. var url = $.pathname() + '/ws/indexMag/SysMenuService/createDetail';
  89. var param = {node : parentId, name : tableName};
  90. $.ajax({
  91. url : url,
  92. type : 'post',
  93. data : param,
  94. dataType : 'text',
  95. success : function(data){
  96. if (data) fn(data);
  97. },
  98. error : function(){
  99. $.messager.alert('系统提示信息', '访问服务失败!', 'error');
  100. }
  101. });
  102. };
  103. /******修改Form信息***********/
  104. _this.editForm = function(){
  105. var rows = _this.listTreeGrid.getSelectedRows();
  106. var rowsLength = rows.length;
  107. if (rowsLength == 0) {
  108. top.Dialog.alert('请选中要修改的记录!');
  109. return;
  110. } else if (rowsLength > 1) {
  111. top.Dialog.alert('请选中一条要修改的记录!');
  112. return;
  113. } else {
  114. var fd_id = _this.listTreeGrid.getSelectedRow().fd_objectid; //
  115. var diag = new top.Dialog();
  116. diag.Title = '修改';
  117. diag.URL = $.pathname() +'/page/system/right/addMenu.jsp?fd_id='+fd_id;
  118. diag.OkButtonText = '提交';
  119. diag.OKEvent = function(){
  120. _this.edit(diag);
  121. };
  122. diag.Width = 750; //宽度
  123. diag.Height = 320; //高度
  124. diag.ButtonAlign = 'center';
  125. diag.show();
  126. }
  127. };
  128. _this.edit = function(diag){
  129. $form = diag.innerFrame.contentWindow.$('#sysmenu_form');
  130. var valid = $form.validationEngine({returnIsValid: true});
  131. if(valid){
  132. var formValue = $form.serialize();
  133. $.ajax({
  134. url : $.pathname() + '/ws/crud/CRUDService/update',
  135. type : 'post',
  136. timeout : 15000,
  137. data : formValue,
  138. dataType : 'json',
  139. success : function(data){
  140. top.Dialog.close();
  141. top.Dialog.alert("修改成功", null, null, null, 1);
  142. _this.listTreeGrid.loadData(); //刷新表格数据
  143. },
  144. error : function(e){
  145. $.messager.alert('系统提示信息', '访问服务失败!', 'error');
  146. }
  147. });
  148. }
  149. };
  150. /****删除****/
  151. _this.del = function(){
  152. var rows = _this.listTreeGrid.getSelectedRows();
  153. var rowsLength = rows.length;
  154. if (rowsLength == 0) {
  155. top.Dialog.alert('请选中要删除的记录!');
  156. return;
  157. }
  158. var ids = '';
  159. for ( var i = 0; i < rowsLength; i++) {
  160. ids += rows[i].fd_objectid + ',';
  161. }
  162. top.Dialog.confirm('确定要删除吗?', function() {
  163. $.post($.pathname() +'/ws/crud/CRUDService/delete/', {
  164. objectIDs : ids,
  165. classid : '893'
  166. },
  167. function(result) {
  168. if (result.Msg.sucsess == true) {
  169. top.Dialog.alert('删除成功!', null, null, null, 1);
  170. _this.listTreeGrid.loadData();
  171. }else{
  172. top.Dialog.alert('删除失败!');
  173. }
  174. }, 'json');
  175. });
  176. };
  177. $('#searchButton').click(function() {
  178. var name = $('#searchInput').val();
  179. $.ajax({
  180. url : $.pathname() + '/ws/crud/CRUDService/query',
  181. type : 'post',
  182. timeout : 15000,
  183. data : {'RIGHTNAME_893':name,'listId':'893'},
  184. dataType : 'json',
  185. success : function(data){
  186. _this.listTreeGrid.loadData(); //刷新表格数据
  187. },
  188. error : function(e){
  189. $.messager.alert('系统提示信息', '访问服务失败!', 'error');
  190. }
  191. });
  192. });
  193. _this.InitGrid = function (){
  194. var gridData={"rows":[{"rightName":"菜单管理","isParent":true,"open":false}]};
  195. _this.listTreeGrid = $("#system_right_sysmenu").quiGrid({
  196. columns: [
  197. { name: 'fd_objectid', align: 'left',hide:true },
  198. { display: '菜单名称', name: 'menu_name', id:'code', align: 'left', width:'20%' },
  199. { display: '节点', name: 'code', align: 'left',hide:true, width:'20%' },
  200. { display: '父节点', name: 'parentcode', align: 'left',hide:true, width:'20%' } ,
  201. { display: '排序号', name: 'sortno', align: 'left', width:'20%' },
  202. { display: '按钮图片', name: 'menu_img', align: 'left', width:'28%' },
  203. { display: '调用方法', name: 'menu_url', align: 'left', width:'30%' }
  204. ],
  205. toolbar:{
  206. items:[
  207. {text: '新增',click:_this.addForm, iconClass: 'icon_add'},
  208. { line : true },
  209. {text: '删除', click: _this.del, iconClass: 'icon_delete'},
  210. { line : true },
  211. {text: '修改', click:_this.editForm, iconClass: 'icon_edit'},
  212. { line : true },
  213. {text: '查看详细信息', /*click: exportPageData,*/ iconClass: 'icon_view'}
  214. ]
  215. } ,
  216. height: '100%',
  217. width:'100%',
  218. percentWidthMode:true,
  219. checkbox:true,
  220. usePager: false,
  221. data:gridData,
  222. autoCheckChildren:true,
  223. tree: { columnId: 'code' },
  224. treeChildDataPath: $.pathname() +"/ws/indexMag/SysMenuService/getMenutTree/",
  225. autoCheckChildren:false,
  226. treeAjax:true,
  227. treeAutoParam:"code",
  228. treeDataFilter:filterHandler
  229. });
  230. };
  231. return {
  232. init : function(){
  233. _this.InitGrid();
  234. },
  235. searchHandler :function(){
  236. var name = $('#searchInput').val();
  237. $.ajax({
  238. url : $.pathname() + '/ws/crud/CRUDService/queryQuiTree',
  239. type : 'post',
  240. timeout : 15000,
  241. data : {'RIGHTNAME_893':name,'listId':'893'},
  242. dataType : 'json',
  243. success : function(data){
  244. alert($treegrid.loadData());
  245. $treegrid.loadData(); //刷新表格数据
  246. },
  247. error : function(e){
  248. $.messager.alert('系统提示信息', '访问服务失败!', 'error');
  249. }
  250. });
  251. }
  252. };
  253. }();
  254. $(function(){
  255. com.sinosoft.lz.system.right.SysMenu.init();
  256. });
  257. $.menu = com.sinosoft.lz.system.right.SysMenu;