main.html 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. #include("/template/common/layout/_page_layout.html")
  2. #@layout()
  3. #define css()
  4. <link rel="stylesheet" href="#(RESOURCE_HOST)/static/css/zTreeStyle/zTreeStyle.css" type="text/css">
  5. <style>
  6. </style>
  7. #end
  8. #define js()
  9. <script type="text/javascript" src="#(RESOURCE_HOST)/static/js/ztree/jquery.ztree.all.min.js"></script>
  10. <script type="text/javascript">
  11. var setting = {
  12. data: {
  13. simpleData: {
  14. enable: true
  15. }
  16. },
  17. callback: {
  18. onClick: zTreeOnClick
  19. }
  20. };
  21. var pid = 0;
  22. var reloadTable;
  23. function zTreeOnClick(event, treeId, treeNode) {
  24. reloadTable(treeNode.id);
  25. }
  26. function zTreeReload() {
  27. util.sendAjax ({
  28. url : '#(ctxPath)/system/res/resTree',
  29. notice: false,
  30. success : function(data){
  31. $.fn.zTree.init($("#tree"), setting, data.data);
  32. }
  33. })
  34. }
  35. $(document).ready(function(){
  36. zTreeReload();
  37. });
  38. layui.use(['table', 'layer'], function () {
  39. var table = layui.table
  40. , layer = layui.layer
  41. , $ = layui.jquery;
  42. // 表格渲染
  43. var tableIns = table.render({
  44. elem: '#dateTable' //指定原始表格元素选择器(推荐id选择器)
  45. , id: 'dateTable'
  46. , even: true //开启隔行背景
  47. , size: 'sm' //小尺寸的表格
  48. , height: 'full-100' //容器高度
  49. , cols: [[ //标题栏
  50. {checkbox: false, sort: true, fixed: true, space: true}
  51. , {field: 'id', title: 'ID', width: 60}
  52. , {field: 'name', title: '资源名称', width: 120}
  53. , {field: 'des', title: '资源描述', width: 120}
  54. , {field: 'url', title: '资源URL', width: 120}
  55. , {field: 'iconCls', title: '资源图标', width: 100, templet: '<div><i class="iconfont">{{d.iconCls }}</i></div>'}
  56. , {field: 'seq', title: '资源序号', width: 100}
  57. , {field: 'type', title: '资源类型', width: 100, templet: '#dataTpl("TYPE_SYSTEM_RES", "type")'}
  58. , {field: 'status', title: '状态', width: 60, templet: '#statusTpl(io.jboot.admin.service.entity.status.system.ResStatus::me(), "status")'}
  59. , {field: 'lastUpdAcct', title: '最后更新人', width: 100}
  60. , {field: 'lastUpdTime', title: '最后更新时间', width: 150}
  61. , {field: 'note', title: '备注', width: 150}
  62. , {fixed: 'right', title: '操作', width: 160, align: 'center', toolbar: '#barOption'} //这里的toolbar值是模板元素的选择器
  63. ]]
  64. , url: '#(ctxPath)/system/res/resData'
  65. , method: 'get'
  66. , request: {
  67. pageName: 'pageNumber' //页码的参数名称,默认:page
  68. ,limitName: 'pageSize' //每页数据量的参数名,默认:limit
  69. }
  70. , page: true
  71. , limits: [30, 60, 90, 150, 300]
  72. , limit: 30 //默认采用30
  73. , loading: true
  74. , done: function (res, curr, count) {
  75. }
  76. });
  77. // 获取选中行
  78. table.on('checkbox(dateTable)', function (obj) {
  79. console.log(obj.checked); //当前是否选中状态
  80. console.log(obj.data); //选中行的相关数据
  81. console.log(obj.type); //如果触发的是全选,则为:all,如果触发的是单选,则为:one
  82. });
  83. table.on('tool(dateTable)', function(obj){
  84. var data = obj.data;
  85. if(obj.event === 'del'){
  86. layer.confirm('真的删除行么', function(index){
  87. util.sendAjax ({
  88. type: 'POST',
  89. url: '#(ctxPath)/system/res/delete',
  90. data: {id : data.id},
  91. loadFlag: true,
  92. success : function(data){
  93. layer.close(index);
  94. reloadTable(pid);
  95. zTreeReload();
  96. },
  97. unSuccess: function (data) {
  98. layer.close(index);
  99. }
  100. })
  101. });
  102. } else if(obj.event === 'edit'){
  103. pop_show('编辑资源','#(ctxPath)/system/res/update?id=' + data.id,'','', function(){
  104. reloadTable(pid);
  105. zTreeReload();
  106. });
  107. } else if(obj.event === 'use'){
  108. util.sendAjax ({
  109. type: 'POST',
  110. url: '#(ctxPath)/system/res/use',
  111. data: {id : data.id},
  112. loadFlag: true,
  113. success : function(data){
  114. reloadTable(pid);
  115. }
  116. });
  117. } else if(obj.event === 'unuse'){
  118. util.sendAjax ({
  119. type: 'POST',
  120. url: '#(ctxPath)/system/res/unuse',
  121. data: {id : data.id},
  122. loadFlag: true,
  123. success : function(data){
  124. reloadTable(pid);
  125. }
  126. });
  127. }
  128. });
  129. $("#addRes").click(function(){
  130. pop_show('添加资源','#(ctxPath)/system/res/add?pid=' + pid,'','', function(){
  131. reloadTable(pid);
  132. zTreeReload();
  133. });
  134. });
  135. $("#module").click(function(){
  136. reloadTable(0);
  137. });
  138. reloadTable = function (_pid) {
  139. pid = _pid;
  140. table.reload('dateTable', {
  141. url: '#(ctxPath)/system/res/resData'
  142. ,where: {pid: pid} //设定异步数据接口的额外参数
  143. });
  144. }
  145. $(window).resize(function() {
  146. $(document).find(".layui-fluid .layui-row div.layui-col-md3").height($(window).height()-50);
  147. });
  148. });
  149. </script>
  150. #end
  151. #define content()
  152. <div class="layui-fluid">
  153. <div class="layui-row">
  154. <div class="layui-col-md3" style="overflow:auto;">
  155. <ul id="tree" class="ztree"></ul>
  156. </div>
  157. <div class="layui-col-md9">
  158. <div class="layui-btn-group">
  159. #shiroHasPermission('/system/res/add')
  160. <button id="addRes" class="layui-btn layui-btn-small">添加资源</button>
  161. #end
  162. <button id="module" class="layui-btn layui-btn-small">子模块管理</button>
  163. </div>
  164. <table id="dateTable" lay-filter="dateTable"></table>
  165. </div>
  166. </div>
  167. </div>
  168. <script type="text/html" id="barOption">
  169. #shiroHasPermission('/system/res/update')
  170. <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
  171. #end
  172. #[[
  173. {{# if(d.status == '0'){ }}
  174. ]]#
  175. #shiroHasPermission('/system/res/use')
  176. <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="use">启用</a>
  177. #end
  178. #[[
  179. {{# } }}
  180. ]]#
  181. #[[
  182. {{# if(d.status == '1'){ }}
  183. ]]#
  184. #shiroHasPermission('/system/res/unuse')
  185. <a class="layui-btn layui-btn-warm layui-btn-xs" lay-event="unuse">停用</a>
  186. #end
  187. #[[
  188. {{# } }}
  189. ]]#
  190. #shiroHasPermission('/system/res/delete')
  191. <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
  192. #end
  193. </script>
  194. #end