deptment.html 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>部门管理</title>
  6. <link rel="stylesheet" href="../../component/pear/css/pear.css" />
  7. <link rel="stylesheet" href="../../demos/css/department.css"/>
  8. </head>
  9. <body class="pear-container">
  10. <div class="layui-card">
  11. <div class="layui-card-body">
  12. <form class="layui-form" action="">
  13. <div class="layui-form-item">
  14. <div class="layui-form-item layui-inline">
  15. <label class="layui-form-label">用户名</label>
  16. <div class="layui-input-inline">
  17. <input type="text" name="realName" placeholder="" class="layui-input">
  18. </div>
  19. </div>
  20. <div class="layui-form-item layui-inline">
  21. <label class="layui-form-label">性别</label>
  22. <div class="layui-input-inline">
  23. <input type="text" name="realName" placeholder="" class="layui-input">
  24. </div>
  25. </div>
  26. <div class="layui-form-item layui-inline">
  27. <label class="layui-form-label">邮箱</label>
  28. <div class="layui-input-inline">
  29. <input type="text" name="realName" placeholder="" class="layui-input">
  30. </div>
  31. </div>
  32. <div class="layui-form-item layui-inline">
  33. <button class="pear-btn pear-btn-md pear-btn-primary" lay-submit lay-filter="user-query">
  34. <i class="layui-icon layui-icon-search"></i>
  35. 查询
  36. </button>
  37. <button type="reset" class="pear-btn pear-btn-md">
  38. <i class="layui-icon layui-icon-refresh"></i>
  39. 重置
  40. </button>
  41. </div>
  42. </div>
  43. </form>
  44. </div>
  45. </div>
  46. <div class="layui-row layui-col-space15">
  47. <div class="layui-col-md3">
  48. <div class="layui-card">
  49. <div class="layui-card-body">
  50. <div id="organizationTreeContent" style="overflow: auto">
  51. <ul id="organizationTree" class="dtree organizationTree" data-id="9527"></ul>
  52. </div>
  53. </div>
  54. </div>
  55. </div>
  56. <div class="layui-col-md9">
  57. <div class="layui-card">
  58. <div class="layui-card-body">
  59. <table id="organization-table" lay-filter="organization-table"></table>
  60. </div>
  61. </div>
  62. </div>
  63. </div>
  64. <script type="text/html" id="organization-toolbar">
  65. <button class="pear-btn pear-btn-primary pear-btn-md" lay-event="add">
  66. <i class="layui-icon layui-icon-add-1"></i>
  67. 新增
  68. </button>
  69. <button class="pear-btn pear-btn-danger pear-btn-md" lay-event="batchRemove">
  70. <i class="layui-icon layui-icon-delete"></i>
  71. 删除
  72. </button>
  73. </script>
  74. <script type="text/html" id="organization-bar">
  75. <button class="pear-btn pear-btn-primary pear-btn-sm" lay-event="edit"><i
  76. class="layui-icon layui-icon-edit"></i></button>
  77. <button class="pear-btn pear-btn-danger pear-btn-sm" lay-event="remove"><i
  78. class="layui-icon layui-icon-delete"></i></button>
  79. </script>
  80. <script src="../../component/layui/layui.js"></script>
  81. <script src="../../component/pear/pear.js"></script>
  82. <script>
  83. layui.use(['table', 'form', 'jquery', 'dtree'], function() {
  84. let table = layui.table;
  85. let form = layui.form;
  86. let $ = layui.jquery;
  87. let dtree = layui.dtree;
  88. let MODULE_PATH = "operate/";
  89. let cols = [
  90. [{
  91. type: 'checkbox'
  92. },
  93. {
  94. title: '名称',
  95. field: 'name',
  96. align: 'center'
  97. },
  98. {
  99. title: '人数',
  100. field: 'userCount',
  101. align: 'center'
  102. },
  103. {
  104. title: '位置',
  105. field: 'location',
  106. align: 'center'
  107. },
  108. {
  109. title: '负责人',
  110. field: 'leader',
  111. align: 'center'
  112. },
  113. {
  114. title: '操作',
  115. toolbar: '#organization-bar',
  116. align: 'center',
  117. width: 130
  118. }
  119. ]
  120. ]
  121. var DTree = dtree.render({
  122. elem: "#organizationTree",
  123. //data: data,
  124. initLevel: "2", //默认展开层级为1
  125. line: true, // 有线树
  126. ficon: ["1", "-1"], // 设定一级图标样式。0表示方形加减图标,8表示小圆点图标
  127. icon: ["0", "2"], // 设定二级图标样式。0表示文件夹图标,5表示叶子图标
  128. method: 'get',
  129. url: "../../demos/data/organizationtree.json"
  130. });
  131. table.render({
  132. elem: '#organization-table',
  133. url: '../../demos/data/organization.json',
  134. height: 'full-150',
  135. page: true,
  136. cols: cols,
  137. skin: 'line',
  138. toolbar: '#organization-toolbar',
  139. defaultToolbar: [{
  140. title: '刷新',
  141. layEvent: 'refresh',
  142. icon: 'layui-icon-refresh',
  143. }, 'filter', 'print', 'exports']
  144. });
  145. // 绑定节点点击事件
  146. dtree.on("node(organizationTree)", function(obj) {
  147. if (!obj.param.leaf) {
  148. var $div = obj.dom;
  149. DTree.clickSpread($div); //调用内置函数展开节点
  150. } else {
  151. layer.msg("叶子节点就不展开了,刷新右侧列表");
  152. table.reload("organization-table");
  153. }
  154. });
  155. table.on('tool(organization-table)', function(obj) {
  156. if (obj.event === 'remove') {
  157. window.remove(obj);
  158. } else if (obj.event === 'edit') {
  159. window.edit(obj);
  160. }
  161. });
  162. table.on('toolbar(organization-table)', function(obj) {
  163. if (obj.event === 'add') {
  164. window.add();
  165. } else if (obj.event === 'refresh') {
  166. window.refresh();
  167. } else if (obj.event === 'batchRemove') {
  168. window.batchRemove(obj);
  169. }
  170. });
  171. form.on('submit(organization-query)', function(data) {
  172. table.reload('organization-table', {
  173. where: data.field
  174. })
  175. return false;
  176. });
  177. window.add = function() {
  178. layer.open({
  179. type: 2,
  180. title: '新增',
  181. shade: 0.1,
  182. area: ['500px', '400px'],
  183. content: MODULE_PATH + 'add.html'
  184. });
  185. }
  186. window.edit = function(obj) {
  187. layer.open({
  188. type: 2,
  189. title: '修改',
  190. shade: 0.1,
  191. area: ['500px', '400px'],
  192. content: MODULE_PATH + 'edit.html'
  193. });
  194. }
  195. window.remove = function(obj) {
  196. layer.confirm('确定要删除该用户', {
  197. icon: 3,
  198. title: '提示'
  199. }, function(index) {
  200. layer.close(index);
  201. let loading = layer.load();
  202. $.ajax({
  203. url: MODULE_PATH + "remove/" + obj.data['organizationId'],
  204. dataType: 'json',
  205. type: 'delete',
  206. success: function(result) {
  207. layer.close(loading);
  208. if (result.success) {
  209. layer.msg(result.msg, {
  210. icon: 1,
  211. time: 1000
  212. }, function() {
  213. obj.del();
  214. });
  215. } else {
  216. layer.msg(result.msg, {
  217. icon: 2,
  218. time: 1000
  219. });
  220. }
  221. }
  222. })
  223. });
  224. }
  225. window.batchRemove = function(obj) {
  226. let data = table.checkStatus(obj.config.id).data;
  227. if (data.length === 0) {
  228. layer.msg("未选中数据", {
  229. icon: 3,
  230. time: 1000
  231. });
  232. return false;
  233. }
  234. let ids = "";
  235. for (let i = 0; i < data.length; i++) {
  236. ids += data[i].organizationId + ",";
  237. }
  238. ids = ids.substr(0, ids.length - 1);
  239. layer.confirm('确定要删除这些用户', {
  240. icon: 3,
  241. title: '提示'
  242. }, function(index) {
  243. layer.close(index);
  244. let loading = layer.load();
  245. $.ajax({
  246. url: MODULE_PATH + "batchRemove/" + ids,
  247. dataType: 'json',
  248. type: 'delete',
  249. success: function(result) {
  250. layer.close(loading);
  251. if (result.success) {
  252. layer.msg(result.msg, {
  253. icon: 1,
  254. time: 1000
  255. }, function() {
  256. table.reload('organization-table');
  257. });
  258. } else {
  259. layer.msg(result.msg, {
  260. icon: 2,
  261. time: 1000
  262. });
  263. }
  264. }
  265. })
  266. });
  267. }
  268. window.refresh = function(param) {
  269. table.reload('organization-table');
  270. }
  271. })
  272. </script>
  273. </body>
  274. </html>