modal.ejs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. <% if (ctx.session.sessionUser.is_admin) { %>
  2. <link href="/public/css/bootstrap/bootstrap-table.min.css" rel="stylesheet">
  3. <link href="/public/css/bootstrap/bootstrap-table-fixed-columns.min.css" rel="stylesheet">
  4. <style>
  5. /*.bootstrap-table .fixed-table-container.fixed-height:not(.has-footer) {*/
  6. /*border-bottom: 0;*/
  7. /*}*/
  8. @-moz-document url-prefix() {
  9. table {
  10. table-layout: fixed;
  11. }
  12. }
  13. .customize-header tr th .th-inner{
  14. padding: 0.3rem!important;
  15. }
  16. </style>
  17. <!-- 成员管理 -->
  18. <div class="modal fade" id="authority-list" data-backdrop="static">
  19. <div class="modal-dialog modal-lg" role="document">
  20. <div class="modal-content">
  21. <div class="modal-header">
  22. <h5 class="modal-title">成员管理</h5>
  23. </div>
  24. <div class="modal-body pt-0">
  25. <div class="d-flex flex-row bg-graye">
  26. <input type="hidden" id="stid" />
  27. <div class="p-2 dropdown">
  28. <button class="btn btn-outline-primary btn-sm dropdown-toggle" type="button" id="dropdownMenuButton"
  29. data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
  30. 添加用户
  31. </button>
  32. <div class="dropdown-menu dropdown-menu-left" aria-labelledby="dropdownMenuButton" style="width:220px">
  33. <div class="mb-2 p-2"><input class="form-control form-control-sm" placeholder="姓名/手机 检索"
  34. id="gr-search" autocomplete="off"></div>
  35. <dl class="list-unstyled book-list">
  36. <% accountGroup.forEach((group, idx) => { %>
  37. <dt><a href="javascript: void(0);" class="acc-btn" data-groupid="<%- idx %>"
  38. data-type="hide"><i class="fa fa-plus-square"></i></a> <%- group.groupName %></dt>
  39. <div class="dd-content" data-toggleid="<%- idx %>">
  40. <% group.groupList.forEach(item => { %>
  41. <dd class="border-bottom p-2 mb-0 " data-id="<%- item.id %>">
  42. <p class="mb-0 d-flex"><span class="text-primary"><%- item.name %></span><span
  43. class="ml-auto"><%- item.mobile %></span></p>
  44. <span class="text-muted"><%- item.role %></span>
  45. </dd>
  46. <% });%>
  47. </div>
  48. <% }) %>
  49. </dl>
  50. </div>
  51. </div>
  52. <!-- <div class="p-2"><a href="">同步计量账号</a></div>-->
  53. <div class="ml-auto p-2">
  54. <div class="btn-group">
  55. <a href="javascript:void(0)" data-toggle="dropdown" title="权限说明"><i class="fa fa-question-circle"></i></a>
  56. <div class="dropdown-menu bg-dark">
  57. <div class="dropdown-item text-light bg-dark">1、编辑节点:编辑合同管理内页树结构</div>
  58. <div class="dropdown-item text-light bg-dark">2、添加合同:允许添加合同</div>
  59. <div class="dropdown-item text-light bg-dark">3、授权范围本单位:授权节点下查看本单位人员添加的所有合同</div>
  60. <div class="dropdown-item text-light bg-dark">4、授权范围本节点:授权节点下查看所有人上传的合同</div>
  61. </div>
  62. </div>
  63. </div>
  64. </div>
  65. <table id="contract-audit-table" class="table table-bordered text-center" data-height="300" data-toggle="table">
  66. <thead>
  67. <tr>
  68. <th rowspan="2" class="align-middle">用户名</th>
  69. <th rowspan="2" class="align-middle">角色/职位</th>
  70. <th rowspan="2" class="align-middle">编辑节点</th>
  71. <th rowspan="2" class="align-middle">添加合同</th>
  72. <th colspan="2">授权节点合同查看范围</th>
  73. <th rowspan="2" class="align-middle">上传附件</th>
  74. <th rowspan="2" class="align-middle">操作</th>
  75. </tr>
  76. <tr>
  77. <th>本单位</th>
  78. <th>本节点</th>
  79. </tr>
  80. </thead>
  81. <tbody id="contract-audit-list">
  82. </tbody>
  83. </table>
  84. </div>
  85. <div class="modal-footer">
  86. <button type="button" class="btn btn-sm btn-outline-secondary" data-dismiss="modal">关闭</button>
  87. </div>
  88. </div>
  89. </div>
  90. </div>
  91. <!-- 弹窗删除权限用户 -->
  92. <div class="modal fade" id="del-contract-audit" data-backdrop="static">
  93. <div class="modal-dialog" role="document">
  94. <div class="modal-content">
  95. <div class="modal-header">
  96. <h5 class="modal-title">删除用户</h5>
  97. </div>
  98. <div class="modal-body">
  99. <h6>确认删除当前所选用户?</h6>
  100. </div>
  101. <div class="modal-footer">
  102. <button type="button" class="btn btn-sm btn-secondary" data-dismiss="modal">取消</button>
  103. <input type="hidden" id="del-audit-ids" />
  104. <button type="button" class="btn btn-sm btn-danger" id="del-audit-btn">确定删除</button>
  105. </div>
  106. </div>
  107. </div>
  108. </div>
  109. <script src="/public/js/bootstrap/bootstrap-table.min.js"></script>
  110. <script src="/public/js/bootstrap/locales/bootstrap-table-zh-CN.min.js"></script>
  111. <script>
  112. const accountGroup = JSON.parse(unescape('<%- escape(JSON.stringify(accountGroup)) %>'));
  113. const accountList = JSON.parse(unescape('<%- escape(JSON.stringify(accountList)) %>'));
  114. </script>
  115. <script>
  116. $(function () {
  117. let timer = null
  118. let oldSearchVal = null
  119. $('#gr-search').bind('input propertychange', function (e) {
  120. oldSearchVal = e.target.value
  121. timer && clearTimeout(timer)
  122. timer = setTimeout(() => {
  123. const newVal = $('#gr-search').val()
  124. let html = ''
  125. if (newVal && newVal === oldSearchVal) {
  126. accountList.filter(item => item && (item.name.indexOf(newVal) !== -1 || (item.mobile && item.mobile.indexOf(newVal) !== -1))).forEach(item => {
  127. html += `<dd class="border-bottom p-2 mb-0 " data-id="${item.id}" >
  128. <p class="mb-0 d-flex"><span class="text-primary">${item.name}</span><span
  129. class="ml-auto">${item.mobile || ''}</span></p>
  130. <span class="text-muted">${item.role || ''}</span>
  131. </dd>`
  132. })
  133. $('#authority-list .book-list').empty()
  134. $('#authority-list .book-list').append(html)
  135. } else {
  136. if (!$('#authority-list .acc-btn').length) {
  137. accountGroup.forEach((group, idx) => {
  138. if (!group) return
  139. html += `<dt><a href="javascript: void(0);" class="acc-btn" data-groupid="${idx}" data-type="hide"><i class="fa fa-plus-square"></i>
  140. </a> ${group.groupName}</dt>
  141. <div class="dd-content" data-toggleid="${idx}">`
  142. group.groupList.forEach(item => {
  143. html += `<dd class="border-bottom p-2 mb-0 " data-id="${item.id}" >
  144. <p class="mb-0 d-flex"><span class="text-primary">${item.name}</span><span
  145. class="ml-auto">${item.mobile || ''}</span></p>
  146. <span class="text-muted">${item.role || ''}</span>
  147. </dd>`
  148. });
  149. html += '</div>'
  150. })
  151. $('#authority-list .book-list').empty()
  152. $('#authority-list .book-list').append(html)
  153. }
  154. }
  155. }, 400);
  156. });
  157. // 添加到成员中
  158. $('.book-list').on('click', 'dt', function () {
  159. const idx = $(this).find('.acc-btn').attr('data-groupid')
  160. const type = $(this).find('.acc-btn').attr('data-type')
  161. if (type === 'hide') {
  162. $(this).parent().find(`div[data-toggleid="${idx}"]`).show(() => {
  163. $(this).children().find('i').removeClass('fa-plus-square').addClass('fa-minus-square-o')
  164. $(this).find('.acc-btn').attr('data-type', 'show')
  165. })
  166. } else {
  167. $(this).parent().find(`div[data-toggleid="${idx}"]`).hide(() => {
  168. $(this).children().find('i').removeClass('fa-minus-square-o').addClass('fa-plus-square')
  169. $(this).find('.acc-btn').attr('data-type', 'hide')
  170. })
  171. }
  172. return false
  173. });
  174. // 添加到成员中
  175. $('body').on('click', '#authority-list dl dd', function () {
  176. const id = parseInt($(this).data('id'));
  177. if (!isNaN(id) && id !== 0) {
  178. postData(auditSaveUrl, {type: 'add-audit', id: id}, function (result) {
  179. setList(result);
  180. })
  181. }
  182. });
  183. let first = 1;
  184. let auditSaveUrl = '';
  185. $('#authority-list').on('shown.bs.modal', function () {
  186. if (first) {
  187. const option = {
  188. locale: 'zh-CN',
  189. height: 300,
  190. }
  191. $("#contract-audit-table").bootstrapTable('destroy').bootstrapTable(option);
  192. first = 0;
  193. }
  194. postData(auditSaveUrl, { type: 'list' }, function (result) {
  195. setList(result);
  196. });
  197. });
  198. $('body').on('click', '.get-audits', function () {
  199. const stid = $(this).data('stid');
  200. $('#stid').val(stid);
  201. auditSaveUrl = stid ? `/sp/${spid}/contract/tender/${stid}/audit/save`: `/sp/${spid}/contract/audit/save`;
  202. $('#contract-audit-list').html('');
  203. postData(auditSaveUrl, { type: 'check' }, function (result) {
  204. $('#authority-list').modal('show');
  205. });
  206. });
  207. function setList(datas) {
  208. let list = '';
  209. for (const ca of datas) {
  210. list += `<tr>
  211. <td>${ca.name}</td>
  212. <td>${ca.role}</td>
  213. <td>
  214. <input type="checkbox" class="permission-checkbox" data-type="permission_edit" value="${ca.uid}" ${ca.permission_edit ? 'checked' : ''}>
  215. </td>
  216. <td>
  217. <input type="checkbox" class="permission-checkbox" data-type="permission_add" value="${ca.uid}" ${ca.permission_add ? 'checked' : ''}>
  218. </td>
  219. <td>
  220. <input type="checkbox" class="permission-checkbox" data-type="permission_show_unit" value="${ca.uid}" ${ca.permission_show_unit ? 'checked' : ''}>
  221. </td>
  222. <td>
  223. <input type="checkbox" class="permission-checkbox" data-type="permission_show_node" value="${ca.uid}" ${ca.permission_show_node ? 'checked' : ''}>
  224. </td>
  225. <td>
  226. <input type="checkbox" class="permission-checkbox" data-type="permission_att" value="${ca.uid}" ${ca.permission_att ? 'checked' : ''}>
  227. </td>
  228. <td>
  229. <a href="#del-contract-audit" data-toggle="modal" data-target="#del-contract-audit" class="btn btn-outline-danger btn-sm ml-1 del-contract-audit-a" data-id="${ca.uid}">移除</a>
  230. </td>
  231. </tr>`;
  232. }
  233. $('#contract-audit-list').html(list);
  234. $("#contract-audit-table").bootstrapTable('resetView');
  235. }
  236. $('body').on('click', '.del-contract-audit-a', function () {
  237. $('#del-audit-ids').val($(this).attr('data-id'));
  238. $('#del-contract-audit').modal('show');
  239. });
  240. $('#del-audit-btn').click(function () {
  241. let uids = $('#del-audit-ids').val();
  242. postData(auditSaveUrl, { type: 'del-audit', id: uids.split(',') }, function (result) {
  243. // toastr.success(`成功添加 位用户`);
  244. $('#del-contract-audit').modal('hide');
  245. setList(result);
  246. })
  247. });
  248. // 上报人权限勾选
  249. $('body').on('click', '.permission-checkbox', function () {
  250. const type = $(this).attr('data-type');
  251. const value = $(this).is(':checked') ? 1 : 0;
  252. const uid = parseInt($(this).val());
  253. const updateInfo = { uid };
  254. updateInfo[type] = value;
  255. postData(auditSaveUrl, { type: 'save-permission', updateData: updateInfo }, function (result) {
  256. })
  257. });
  258. });
  259. </script>
  260. <% } %>