user_modal.ejs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. <link href="/public/css/bootstrap/select2.min.css" rel="stylesheet" />
  2. <link rel="stylesheet" href="/public/css/bootstrap/select2-bootstrap4.min.css">
  3. <script src="/public/js/bootstrap/select2.min.js"></script>
  4. <div class="modal fade" id="sel-batch" data-backdrop="static">
  5. <div class="modal-dialog modal-lg" role="document">
  6. <div class="modal-content">
  7. <div class="modal-header">
  8. <h5 class="modal-title">添加账号至项目成员</h5>
  9. </div>
  10. <div class="modal-body">
  11. <div class="d-flex align-items-center justify-content-between mb-2 project-member-filters">
  12. <div class="col-5 pl-0">
  13. <div class="input-group input-group-sm">
  14. <input type="text" class="form-control" placeholder="姓名/职位 搜索" aria-label="姓名/职位 搜索" id="sb-keyword" aria-describedby="sb-search">
  15. <div class="input-group-append">
  16. <button class="btn btn-outline-primary" type="button" id="sb-search"><i class="fa fa-search"></i></button>
  17. </div>
  18. </div>
  19. </div>
  20. <div class="col pr-0">
  21. <div class="d-flex align-items-center justify-content-end">
  22. <label for="sel-batch-unit" class="mb-0 text-nowrap">单位:</label>
  23. <select class="form-control form-control-sm" style="width:300px" id="sel-batch-unit">
  24. <option value="">全部单位</option>
  25. <% for (const g of accountGroup) { %>
  26. <option value="<%- g.name %>"><%- g.name %></option>
  27. <% } %>
  28. </select>
  29. </div>
  30. </div>
  31. </div>
  32. <div class="modal-height-500 scroll-y">
  33. <table class="table table-bordered">
  34. <thead><tr class="text-center"><th width="15%"><input type="checkbox" id="sel-batch-all"></th><th width="20%">用户</th><th width="30%">职位</th><th>单位</th></tr></thead>
  35. <tbody id="sel-batch-users"></tbody>
  36. </table>
  37. </div>
  38. </div>
  39. <div class="modal-footer">
  40. <button type="button" class="btn btn-sm btn-secondary" data-dismiss="modal">关闭</button>
  41. <button type="button" class="btn btn-sm btn-sm btn-primary" id="sel-batch-ok">确定</button>
  42. </div>
  43. </div>
  44. </div>
  45. </div>
  46. <div class="modal fade" id="permission" data-backdrop="static" style="display: none;" aria-hidden="true">
  47. <div class="modal-dialog modal-xl" role="document">
  48. <div class="modal-content">
  49. <div class="modal-header">
  50. <h5 class="modal-title">编辑权限</h5>
  51. </div>
  52. <div class="modal-body" style="max-height: 800px;overflow: auto;">
  53. <% for (const pb of permissionBlock) { %>
  54. <div class="card mb-2">
  55. <h6 class="card-header">
  56. <%- pb.name %>
  57. <% if (pb.hint) { %>
  58. <div class="btn-group">
  59. <a href="javascript:void(0);" data-toggle="dropdown" title="权限说明" aria-expanded="false"><i class="fa fa-question-circle"></i></a>
  60. <div class="dropdown-menu bg-dark" style="will-change: transform;">
  61. <% for (const i of pb.hint) { %>
  62. <div class="dropdown-item text-light bg-dark"><%- i %></div>
  63. <% } %>
  64. </div>
  65. </div>
  66. <% } %>
  67. </h6>
  68. <div class="card-body permission-parent">
  69. <% if (pb.children) { %>
  70. <% for (const [i, c] of pb.children.entries()) { %>
  71. <% if (i !== 0) { %><hr/><% } %>
  72. <div class="d-flex">
  73. <div class="vertical-align ml-3" style="width:100px"><%- c.name %></div>
  74. <div class="container ml-0">
  75. <div class="row">
  76. <% for (const cp of c.permission) { %>
  77. <div class="col-md-3">
  78. <div class="form-check">
  79. <input class="form-check-input" type="checkbox" name="permission-check" id="icb-<%- c.key %>-<%- cp.value %>" ptype="<%- c.key %>" pvalue="<%- cp.value %>">
  80. <label class="form-check-label" for="icb-<%- c.key %>-<%- cp.value %>"><%- cp.title %></label>
  81. </div>
  82. </div>
  83. <% } %>
  84. </div>
  85. </div>
  86. </div>
  87. <% } %>
  88. <% } else { %>
  89. <div class="d-flex">
  90. <div class="vertical-align ml-3" style="width:100px"><%- pb.name %></div>
  91. <div class="container ml-0">
  92. <div class="row">
  93. <% for (const p of pb.permission) { %>
  94. <div class="col-md-3">
  95. <div class="form-check">
  96. <input class="form-check-input" type="checkbox" name="permission-check" id="icb-<%- pb.key %>-<%- p.value %>" ptype="<%- pb.key %>" pvalue="<%- p.value %>">
  97. <label class="form-check-label" for="icb-<%- pb.key %>-<%- p.value %>"><%- p.title %></label>
  98. </div>
  99. </div>
  100. <% } %>
  101. </div>
  102. </div>
  103. </div>
  104. <% } %>
  105. </div>
  106. </div>
  107. <% } %>
  108. </div>
  109. <div class="modal-footer">
  110. <input type="hidden" id="permission-uid">
  111. <button type="button" class="btn btn-sm btn-secondary" data-dismiss="modal">关闭</button>
  112. <button type="button" class="btn btn-sm btn-primary" id="permission-ok">提交修改</button>
  113. </div>
  114. </div>
  115. </div>
  116. </div>
  117. <div class="modal fade" id="copy-permission" data-backdorp="static" style="display: none" aria-hidden="true">
  118. <div class="modal-dialog modal-lg" role="document">
  119. <div class="modal-content">
  120. <div class="modal-header">
  121. <h5 class="modal-title">拷贝权限</h5>
  122. </div>
  123. <div class="modal-body">
  124. <div class="modal-height-500 scroll-y">
  125. <table class="table table-bordered">
  126. <thead><tr class="text-center"><th width="15%"><input type="checkbox" id="copy-batch-all"></th><th width="20%">用户</th><th width="30%">职位</th><th>单位</th></tr></thead>
  127. <tbody id="copy-batch-users">
  128. </tbody>
  129. </table>
  130. </div>
  131. </div>
  132. <div class="modal-footer">
  133. <input type="hidden" id="source-permission">
  134. <button type="button" class="btn btn-sm btn-secondary" data-dismiss="modal">关闭</button>
  135. <button type="button" class="btn btn-sm btn-sm btn-primary" id="copy-batch-ok">确定</button>
  136. </div>
  137. </div>
  138. </div>
  139. </div>
  140. <div class="modal fade" id="copy-user-batch" data-backdorp="static" style="display: none" aria-hidden="true">
  141. <div class="modal-dialog modal-lgx" role="document">
  142. <div class="modal-content">
  143. <div class="modal-header">
  144. <h5 class="modal-title">拷贝权限</h5>
  145. </div>
  146. <div class="modal-body">
  147. <div class="row">
  148. <div class="col-5">
  149. <div class="modal-height-500 scroll-y">
  150. <table class="table table-bordered">
  151. <thead class="text-center" style="position: sticky; top:0; z-index:1;"><tr><th width="15%"><input type="checkbox" id="cub-sp-all"></th><th>项目名称</th></tr></thead>
  152. <tbody>
  153. <% for (const sp of subProjects) { %>
  154. <% if (sp.id === ctx.subProject.id) continue; %>
  155. <tr tree_id="<%- sp.id %>" tree_pid="<%- sp.tree_pid %>" tree_expand="1" tree_leaf="<%- (sp.has_children ? 0 : 1) %>">
  156. <td class="text-center"><input type="checkbox" name="cub-sp-check" tree_is_folder="<%- (sp.is_folder ? 1 : 0) %>" spid="<%- sp.id %>"></td>
  157. <td class="in-<%- sp.tree_level%> d-flex">
  158. <% if (sp.has_children) { %>
  159. <div onselectstart="return false" style="{-moz-user-select:none}" class="fold-switch mr-1 d-inline-block" title="收起" id="<%- sp.id %>"><i class="fa fa-minus-square-o"></i></div>
  160. <% } else { %>
  161. <div class="text-muted mr-1 d-inline-block" style="heigth: 100%"><%- (sp.is_last_sibling ? '└' : '├') %></div>
  162. <% } %>
  163. <div class="d-inline-block"><%- sp.name %></div>
  164. </td>
  165. </tr>
  166. <% } %>
  167. </tbody>
  168. </table>
  169. </div>
  170. </div>
  171. <div class="col">
  172. <div class="modal-height-500 scroll-y">
  173. <table class="table table-bordered">
  174. <thead style="position: sticky; top:0; z-index:1;"><tr class="text-center"><th width="15%"><input type="checkbox" id="cub-user-all"></th><th width="20%">用户</th><th width="30%">职位</th><th>单位</th></tr></thead>
  175. <tbody>
  176. <% for (const u of subProjectAllAccountList) { %>
  177. <tr><td class="text-center"><input type="checkbox" name="cub-user-check" uid="<%- u.id %>"></td><td><%- u.name %></td><td><%- u.role %></td><td><%- u.company %></td></tr>
  178. <% } %>
  179. </tbody>
  180. </table>
  181. </div>
  182. </div>
  183. </div>
  184. </div>
  185. <div class="modal-footer" style="justify-content: space-between">
  186. <div class="d-flex">
  187. <div class="form-check form-check-inline">已有用户:</div>
  188. <div class="form-check form-check-inline">
  189. <input class="form-check-input" type="radio" name="exist-type" id="inlineRadio2" value="cover" checked>
  190. <label class="form-check-label" for="inlineRadio2">覆盖</label>
  191. </div>
  192. <div class="form-check form-check-inline">
  193. <input class="form-check-input" type="radio" name="exist-type" id="inlineRadio3" value="skip">
  194. <label class="form-check-label" for="inlineRadio3">跳过</label>
  195. </div>
  196. </div>
  197. <div class="d-flex">
  198. <input type="hidden" id="source-permission">
  199. <button type="button" class="btn btn-sm btn-secondary" data-dismiss="modal">关闭</button>
  200. <button type="button" class="btn btn-sm btn-sm btn-primary ml-1" id="copy-user-batch-ok">确定</button>
  201. </div>
  202. </div>
  203. </div>
  204. </div>
  205. </div>
  206. <script>
  207. const setPosterityShow = function(id, show) {
  208. const children = $(`tr[tree_pid=${id}]`);
  209. for (const c of children) {
  210. if (show) {
  211. $(c).show();
  212. } else {
  213. $(c).hide();
  214. }
  215. if (c.getAttribute('tree_leaf') !== '1') {
  216. setPosterityShow(c.getAttribute('tree_id'), c.getAttribute('tree_expand') === '1' && show);
  217. }
  218. }
  219. }
  220. $('body').on('click', '.fold-switch', function() {
  221. const id = this.getAttribute('id');
  222. const nodeTr = $(`tr[tree_id=${id}]`);
  223. const expand = nodeTr.attr('tree_expand') === '1';
  224. nodeTr.attr('tree_expand', expand ? 0 : 1);
  225. if (!expand) {
  226. $(this).html(`<i class="fa fa-minus-square-o"></i>`);
  227. } else {
  228. $(this).html(`<i class="fa fa-plus-square-o"></i>`);
  229. }
  230. setPosterityShow(id, !expand);
  231. });
  232. const setChildrenCheck = function(id, check) {
  233. const children = $(`tr[tree_pid=${id}]`);
  234. for (const c of children) {
  235. $('input', c)[0].checked = check;
  236. if (c.getAttribute('tree_leaf') !== '1') {
  237. setChildrenCheck(c.getAttribute('tree_id'), check);
  238. }
  239. }
  240. }
  241. $('body').on('change', 'input[name=cub-sp-check][tree_is_folder="1"]', function() {
  242. setChildrenCheck(this.getAttribute('spid'), this.checked);
  243. })
  244. </script>