Нет описания

menuManage.js 4.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. /**
  2. * 菜单设置
  3. * */
  4. $(function() {
  5. $('.tool_bars').authorizeButton();
  6. gridList();
  7. });
  8. function gridList() {
  9. var $gridList = $("#gridList");
  10. $gridList.jqGrid({
  11. url: huayi.config.callcenter_url + 'configurationapi/api/moduleinfo/gettreegridjson',
  12. datatype: "json",
  13. autowidth: true,
  14. rownumbers: true, //如果为ture则会在表格左边新增一列,显示行顺序号,从1开始递增。此列名为'rn'.
  15. rownumWidth: 60,
  16. shrinkToFit: false, //此属性用来说明当初始化列宽度时候的计算类型,如果为ture,则按比例初始化列宽度。如果为false,则列宽度使用colModel指定的宽度
  17. gridview: true, //构造一行数据后添加到grid中,如果设为true则是将整个表格的数据都构造完成后再添加到grid中,但treeGrid, subGrid, or afterInsertRow 不能用
  18. treeGrid: true, //启用或者禁用treegrid模式
  19. treeGridModel: "adjacency", //treeGrid所使用的方法
  20. ExpandColumn: "opt_url", //指定那列来展开tree grid,默认为第一列,只有在treeGrid为true时起作用
  21. height: '100%',
  22. postData: {
  23. },
  24. colModel: [{
  25. label: "主键",
  26. name: "id",
  27. hidden: true,
  28. key: true
  29. },
  30. {
  31. label: '名称',
  32. name: 'module_name',
  33. width: 200,
  34. align: 'left'
  35. },
  36. {
  37. label: '链接',
  38. name: 'opt_url',
  39. width: 520,
  40. align: 'left'
  41. },
  42. {
  43. label: '菜单类型',
  44. name: 'target',
  45. width: 80,
  46. align: 'center',
  47. formatter: function(cellvalue) {
  48. if(cellvalue == "expand") {
  49. return "无页面";
  50. } else if(cellvalue == "iframe") {
  51. return "框架页";
  52. } else if(cellvalue == "open") {
  53. return "弹出页";
  54. } else if(cellvalue == "blank") {
  55. return "新窗口";
  56. }
  57. }
  58. },
  59. // {
  60. // label: "是否是菜单",
  61. // name: "F_IsMenu",
  62. // width: 100,
  63. // align: "center",
  64. // formatter: function(cellvalue) {
  65. // return cellvalue == true ? "<i class=\"glyphicon glyphicon-ok-circle\"></i>" : "<i class=\"glyphicon glyphicon-ban-circle\"></i>";
  66. // }
  67. // },
  68. {
  69. label: "是否启用",
  70. name: "state_flag",
  71. width: 100,
  72. align: "center",
  73. formatter: function(cellvalue) {
  74. return cellvalue == 1 ? "<i class=\"glyphicon glyphicon-ok-circle\"></i>" : "<i class=\"glyphicon glyphicon-ban-circle\"></i>";
  75. }
  76. },
  77. {
  78. label: '介绍',
  79. name: 'remark',
  80. width: 300,
  81. align: 'left'
  82. }
  83. ]
  84. });
  85. $("#sc_btns").click(function() {
  86. $gridList.jqGrid('setGridParam', {
  87. postData: {
  88. keyword: $("#sc_keyWords").val(),
  89. },
  90. }).trigger('reloadGrid');
  91. });
  92. }
  93. function btn_add() {
  94. var mid = $("#gridList").jqGridRowValue().id;
  95. var txt = $("#gridList").jqGridRowValue().module_name;
  96. layer.open({
  97. type: 2,
  98. content: "template/addOrEditMenus.html?mid=" + mid + "&txt=" + $(txt).text(), //iframe的url,no代表不显示滚动条
  99. title: '新增菜单',
  100. resize: false,
  101. area: ['80%', '90%'], //宽高
  102. });
  103. }
  104. function btn_edit() {
  105. var mid = $("#gridList").jqGridRowValue().id;
  106. var pid = $("#gridList").jqGridRowValue().parent;
  107. var pTxt = $("#gridList").getRowData(pid).module_name;
  108. if(!mid) {
  109. layer.confirm('您还没有选择菜单', {
  110. icon: 7,
  111. btn: ['确定', '取消'],
  112. });
  113. return;
  114. }
  115. layer.open({
  116. type: 2,
  117. content: "template/addOrEditMenus.html?isEdit=true&mid=" + mid + "&pid=" + pid + "&pTxt=" + $(pTxt).text(), //iframe的url,no代表不显示滚动条
  118. title: '修改菜单',
  119. resize: false,
  120. area: ['80%', '90%'], //宽高
  121. });
  122. }
  123. function btn_delete() {
  124. var mid = $("#gridList").jqGridRowValue().id;
  125. if(!mid) {
  126. layer.confirm('您还没有选择菜单', {
  127. icon: 7,
  128. btn: ['确定', '取消'],
  129. });
  130. return;
  131. }
  132. layer.confirm('您确定要删除当前选项吗?', {
  133. icon: 7,
  134. btn: ['确定', '取消'],
  135. yes: function(index, layero) {
  136. $.post(huayi.config.callcenter_url + "configurationapi/api/moduleinfo/delmodule", {
  137. ids: mid,
  138. }, function(result) {
  139. result = JSON.parse(result);
  140. if(result.state.toLowerCase() == "success") {
  141. layer.msg("删除成功");
  142. $("#gridList").resetSelection();
  143. $("#gridList").trigger("reloadGrid");
  144. }
  145. })
  146. },
  147. });
  148. }
  149. function btn_modulebutton() {
  150. var mid = $("#gridList").jqGridRowValue().id;
  151. if(!mid) {
  152. layer.confirm('您还没有选择菜单', {
  153. icon: 7,
  154. btn: ['确定', '取消'],
  155. });
  156. return;
  157. }
  158. layer.open({
  159. type: 2,
  160. content: "template/modulebuttons.html?mid=" + mid, //iframe的url,no代表不显示滚动条
  161. title: '按钮管理',
  162. resize: false,
  163. area: ['80%', '90%'], //宽高
  164. });
  165. }