index.php 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. <div id="main">
  2. <div id="aa">
  3. <div title="角色管理">
  4. <table id="dg_role"></table>
  5. <div id="tb_role">
  6. <a href="#" class="easyui-linkbutton" onclick="javascript:jq_dg_role.edatagrid('addRow');" iconCls="icon-add" plain="true" >新增</a>
  7. <a href="#" class="easyui-linkbutton" onclick="javascript:jq_dg_role.edatagrid('destroyRow');" iconCls="icon-remove" plain="true" >删除</a>
  8. <a href="#" class="easyui-linkbutton" onclick="javascript:jq_dg_role.edatagrid('saveRow');" iconCls="icon-save" plain="true" >保存</a>
  9. <a href="#" class="easyui-linkbutton" onclick="javascript:jq_dg_role.edatagrid('cancelRow');" iconCls="icon-undo" plain="true" >取消</a>
  10. </div>
  11. </div>
  12. <div title="任务管理">
  13. <table id="dg_task"></table>
  14. <div id="tb_task">
  15. <a href="#" class="easyui-linkbutton" onclick="javascript:jq_dg_task.edatagrid('addRow');" iconCls="icon-add" plain="true" >新增</a>
  16. <a href="#" class="easyui-linkbutton" onclick="javascript:jq_dg_task.edatagrid('destroyRow');" iconCls="icon-remove" plain="true" >删除</a>
  17. <a href="#" class="easyui-linkbutton" onclick="javascript:jq_dg_task.edatagrid('saveRow');" iconCls="icon-save" plain="true" >保存</a>
  18. <a href="#" class="easyui-linkbutton" onclick="javascript:jq_dg_task.edatagrid('cancelRow');" iconCls="icon-undo" plain="true" >取消</a>
  19. </div>
  20. </div>
  21. <div title="操作管理">
  22. <table id="dg_operation"></table>
  23. <div id="tb_operation">
  24. <a href="#" class="easyui-linkbutton" onclick="javascript:jq_dg_operation.edatagrid('saveRow');" iconCls="icon-save" plain="true" >保存</a>
  25. <a href="#" class="easyui-linkbutton" onclick="javascript:jq_dg_operation.edatagrid('cancelRow');" iconCls="icon-undo" plain="true" >取消</a>
  26. <div class="right">
  27. <a href="#" class="easyui-linkbutton" onclick="javascript:scan_operation();return false;" iconCls="icon-search" plain="true">扫描控制器</a>
  28. </div>
  29. </div>
  30. </div>
  31. </div>
  32. </div>
  33. <script type="text/javascript">
  34. var post_url = 'post_data/';
  35. var get_url = 'get_data/';
  36. var jq_dg_role = $('#dg_role');
  37. var jq_dg_task = $('#dg_task');
  38. var jq_dg_operation = $('#dg_operation');
  39. var temp = new Date();
  40. var today = temp.getFullYear() + '-' + (temp.getMonth() + 1) + '-' + temp.getDate();
  41. var w_width = $(window).width();
  42. var w_height = $(window).height();
  43. var operations = [];
  44. var tasks = [];
  45. $(function(){
  46. $('#aa').accordion({
  47. width: w_width - 25
  48. });
  49. jq_dg_role.edatagrid({
  50. url: site_root + '/index.php?r=auth/getItems',
  51. width: w_width - 50,
  52. height: w_height - 110,
  53. fitColumns: true,
  54. autoRowHeight: true,
  55. striped: true,
  56. multiSort: true,
  57. toolbar: '#tb_role',
  58. singleSelect: true,
  59. pagination: true,
  60. pageList: [20, 30, 50],
  61. pageSize: 20,
  62. nowrap: false,
  63. idField: '_id',
  64. queryParams: {type : 2},
  65. columns:[[
  66. {field:'name', title:'角色', width:40, sortable: true, editor: {type:'validatebox', options: {required: true}}},
  67. {field:'desc', title:'说明', width:40, editor: {type:'validatebox'}},
  68. {field:'children', title:'操作', width:40, editor: {type:'combobox', options: {multiple: true, data:[]}},
  69. formatter: function(value, row){
  70. if (value){
  71. var arr = value.split(',');
  72. return arr.join(',');
  73. } else {
  74. return '';
  75. }
  76. }
  77. }
  78. ]],
  79. onBeforeEdit: function(index, row){
  80. var that = this;
  81. setTimeout(function(){
  82. var children_editor = $(that).edatagrid('getEditor', {index: index, field: 'children'});
  83. if (children_editor){
  84. $(children_editor.target).combobox('loadData', tasks);
  85. }
  86. }, 100);
  87. },
  88. saveUrl: site_root + '/index.php?r=auth/insertItem',
  89. updateUrl: site_root + '/index.php?r=auth/updateItem',
  90. destroyUrl: site_root + '/index.php?r=auth/removeItem',
  91. dataSave: {type : 2},
  92. dataUpdate: {type : 2},
  93. onSave: function(index, row){
  94. $(this).edatagrid('reload');
  95. },
  96. onDestroy: function(index, row){
  97. $(this).edatagrid('reload');
  98. },
  99. newRow: {children: ''},
  100. onLoadSuccess: function(res){
  101. if (res.hasOwnProperty('more')){
  102. roles = res.more;
  103. }
  104. }
  105. });
  106. jq_dg_task.edatagrid({
  107. url: site_root + '/index.php?r=auth/getItems',
  108. width: w_width - 50,
  109. height: w_height - 110,
  110. fitColumns: true,
  111. autoRowHeight: true,
  112. striped: true,
  113. multiSort: true,
  114. toolbar: '#tb_task',
  115. singleSelect: true,
  116. pagination: true,
  117. pageList: [20, 30, 50],
  118. pageSize: 20,
  119. nowrap: false,
  120. idField: '_id',
  121. queryParams: {type : 1},
  122. columns:[[
  123. {field:'name', title:'任务', width:40, sortable: true, editor: {type:'validatebox', options: {required: true}}},
  124. {field:'desc', title:'说明', width:40, editor: {type:'validatebox'}},
  125. {field:'children', title:'操作', width:40, editor: {type:'combobox', options: {multiple: true, data:[]}},
  126. formatter: function(value, row){
  127. if (value){
  128. var arr = value.split(',');
  129. return arr.join(',');
  130. } else {
  131. return '';
  132. }
  133. }
  134. }
  135. ]],
  136. onBeforeEdit: function(index, row){
  137. var that = this;
  138. setTimeout(function(){
  139. var children_editor = $(that).edatagrid('getEditor', {index: index, field: 'children'});
  140. if (children_editor){
  141. $(children_editor.target).combobox('loadData', operations);
  142. }
  143. }, 100);
  144. },
  145. saveUrl: site_root + '/index.php?r=auth/insertItem',
  146. updateUrl: site_root + '/index.php?r=auth/updateItem',
  147. destroyUrl: site_root + '/index.php?r=auth/removeItem',
  148. dataSave: {type : 1},
  149. dataUpdate: {type : 1},
  150. onSave: function(index, row){
  151. $(this).edatagrid('reload');
  152. },
  153. onDestroy: function(index, row){
  154. $(this).edatagrid('reload');
  155. },
  156. newRow: {children: ''},
  157. onLoadSuccess: function(res){
  158. if (res.hasOwnProperty('more')){
  159. tasks = res.more;
  160. }
  161. }
  162. });
  163. jq_dg_operation.edatagrid({
  164. url: site_root + '/index.php?r=auth/getItems',
  165. width: w_width - 50,
  166. height: w_height - 110,
  167. fitColumns: true,
  168. autoRowHeight: true,
  169. striped: true,
  170. multiSort: true,
  171. toolbar: '#tb_operation',
  172. singleSelect: true,
  173. pagination: true,
  174. pageList: [20, 30, 50],
  175. pageSize: 20,
  176. nowrap: false,
  177. idField: '_id',
  178. queryParams: {type : 0},
  179. sortName: 'name',
  180. columns:[[
  181. {field:'name', title:'操作', width:40, sortable: true},
  182. {field:'desc', title:'说明', width:40, editor: {type:'validatebox'}}
  183. ]],
  184. updateUrl: site_root + '/index.php?r=auth/updateItem',
  185. dataUpdate: {type : 0},
  186. onSave: function(index, row){
  187. $(this).edatagrid('reload');
  188. },
  189. onDestroy: function(index, row){
  190. $(this).edatagrid('reload');
  191. },
  192. onLoadSuccess: function(res){
  193. if (res.hasOwnProperty('more')){
  194. operations = res.more;
  195. }
  196. }
  197. });
  198. });
  199. function scan_operation(){
  200. $.messager.confirm('确认', '确认扫描控制器?', function(r){
  201. if (r){
  202. $.messager.progress({
  203. msg : '扫描中'
  204. })
  205. $.ajax({
  206. url: site_root + '/index.php?r=auth/scanOperation',
  207. type: 'get',
  208. dataType: 'json',
  209. success: function(res){
  210. if (res.success){
  211. $.messager.progress('close');
  212. jq_dg_operation.edatagrid('reload');
  213. }
  214. }
  215. });
  216. }
  217. });
  218. }
  219. </script>