modal.ejs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  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>
  44. <span class="selected-mark text-success ml-2" style="display:none;"><i class="fa fa-check"></i></span>
  45. </p>
  46. <span class="text-muted"><%- item.role %></span>
  47. </dd>
  48. <% });%>
  49. </div>
  50. <% }) %>
  51. </dl>
  52. </div>
  53. </div>
  54. <!-- <div class="p-2"><a href="">同步计量账号</a></div>-->
  55. <div class="ml-auto p-2">
  56. <div class="btn-group">
  57. <a href="javascript:void(0)" data-toggle="dropdown" title="权限说明"><i class="fa fa-question-circle"></i></a>
  58. <div class="dropdown-menu bg-dark">
  59. <div class="dropdown-item text-light bg-dark">1、编辑节点:编辑合同管理内页树结构</div>
  60. <div class="dropdown-item text-light bg-dark">2、添加合同:允许添加合同</div>
  61. <div class="dropdown-item text-light bg-dark">3、编辑合同:编辑非自己上传的合同信息</div>
  62. <div class="dropdown-item text-light bg-dark">4、添加支付:给非自己上传的合同添加合同支付</div>
  63. <div class="dropdown-item text-light bg-dark">5、授权范围本单位:授权节点下查看本单位人员添加的所有合同</div>
  64. <div class="dropdown-item text-light bg-dark">6、授权范围本节点:授权节点下查看所有人上传的合同</div>
  65. </div>
  66. </div>
  67. </div>
  68. </div>
  69. <table id="contract-audit-table" class="table table-bordered text-center" data-height="300" data-toggle="table">
  70. <thead>
  71. <tr>
  72. <th rowspan="2" class="align-middle">用户名</th>
  73. <th rowspan="2" class="align-middle">角色/职位</th>
  74. <th rowspan="2" class="align-middle">编辑节点</th>
  75. <th rowspan="2" class="align-middle">添加合同</th>
  76. <th rowspan="2" class="align-middle">编辑合同</th>
  77. <th rowspan="2" class="align-middle">添加支付</th>
  78. <th colspan="2">授权节点合同查看范围</th>
  79. <th rowspan="2" class="align-middle">上传附件</th>
  80. <th rowspan="2" class="align-middle">操作</th>
  81. </tr>
  82. <tr>
  83. <th>本单位</th>
  84. <th>本节点</th>
  85. </tr>
  86. </thead>
  87. <tbody id="contract-audit-list">
  88. </tbody>
  89. </table>
  90. </div>
  91. <div class="modal-footer">
  92. <button type="button" class="btn btn-sm btn-outline-secondary" data-dismiss="modal">关闭</button>
  93. </div>
  94. </div>
  95. </div>
  96. </div>
  97. <!-- 弹窗删除权限用户 -->
  98. <div class="modal fade" id="del-contract-audit" data-backdrop="static">
  99. <div class="modal-dialog" role="document">
  100. <div class="modal-content">
  101. <div class="modal-header">
  102. <h5 class="modal-title">删除用户</h5>
  103. </div>
  104. <div class="modal-body">
  105. <h6>确认删除当前所选用户?</h6>
  106. </div>
  107. <div class="modal-footer">
  108. <button type="button" class="btn btn-sm btn-secondary" data-dismiss="modal">取消</button>
  109. <input type="hidden" id="del-audit-ids" />
  110. <button type="button" class="btn btn-sm btn-danger" id="del-audit-btn">确定删除</button>
  111. </div>
  112. </div>
  113. </div>
  114. </div>
  115. <script src="/public/js/bootstrap/bootstrap-table.min.js"></script>
  116. <script src="/public/js/bootstrap/locales/bootstrap-table-zh-CN.min.js"></script>
  117. <script>
  118. const accountGroup = JSON.parse(unescape('<%- escape(JSON.stringify(accountGroup)) %>'));
  119. const accountList = JSON.parse(unescape('<%- escape(JSON.stringify(accountList)) %>'));
  120. </script>
  121. <script>
  122. $(function () {
  123. let timer = null
  124. let oldSearchVal = null
  125. $('#gr-search').bind('input propertychange', function (e) {
  126. oldSearchVal = e.target.value
  127. timer && clearTimeout(timer)
  128. timer = setTimeout(() => {
  129. const newVal = $('#gr-search').val()
  130. let html = ''
  131. if (newVal && newVal === oldSearchVal) {
  132. accountList.filter(item => item && (item.name.indexOf(newVal) !== -1 || (item.mobile && item.mobile.indexOf(newVal) !== -1))).forEach(item => {
  133. html += `<dd class="border-bottom p-2 mb-0 " data-id="${item.id}" >
  134. <p class="mb-0 d-flex"><span class="text-primary">${item.name}</span><span
  135. class="ml-auto">${item.mobile || ''}</span>
  136. <span class="selected-mark text-success ml-2" style="display:none;"><i class="fa fa-check"></i></span>
  137. </p>
  138. <span class="text-muted">${item.role || ''}</span>
  139. </dd>`
  140. })
  141. $('#authority-list .book-list').empty()
  142. $('#authority-list .book-list').append(html)
  143. syncSelectedMarks();
  144. } else {
  145. if (!$('#authority-list .acc-btn').length) {
  146. accountGroup.forEach((group, idx) => {
  147. if (!group) return
  148. html += `<dt><a href="javascript: void(0);" class="acc-btn" data-groupid="${idx}" data-type="hide"><i class="fa fa-plus-square"></i>
  149. </a> ${group.groupName}</dt>
  150. <div class="dd-content" data-toggleid="${idx}">`
  151. group.groupList.forEach(item => {
  152. html += `<dd class="border-bottom p-2 mb-0 " data-id="${item.id}" >
  153. <p class="mb-0 d-flex"><span class="text-primary">${item.name}</span><span
  154. class="ml-auto">${item.mobile || ''}</span>
  155. <span class="selected-mark text-success ml-2" style="display:none;"><i class="fa fa-check"></i></span>
  156. </p>
  157. <span class="text-muted">${item.role || ''}</span>
  158. </dd>`
  159. });
  160. html += '</div>'
  161. })
  162. $('#authority-list .book-list').empty()
  163. $('#authority-list .book-list').append(html)
  164. syncSelectedMarks();
  165. }
  166. }
  167. }, 400);
  168. });
  169. // 添加到成员中
  170. $('.book-list').on('click', 'dt', function () {
  171. const idx = $(this).find('.acc-btn').attr('data-groupid')
  172. const type = $(this).find('.acc-btn').attr('data-type')
  173. if (type === 'hide') {
  174. $(this).parent().find(`div[data-toggleid="${idx}"]`).show(() => {
  175. $(this).children().find('i').removeClass('fa-plus-square').addClass('fa-minus-square-o')
  176. $(this).find('.acc-btn').attr('data-type', 'show')
  177. })
  178. } else {
  179. $(this).parent().find(`div[data-toggleid="${idx}"]`).hide(() => {
  180. $(this).children().find('i').removeClass('fa-minus-square-o').addClass('fa-plus-square')
  181. $(this).find('.acc-btn').attr('data-type', 'hide')
  182. })
  183. }
  184. return false
  185. });
  186. // 添加到成员中
  187. $('body').on('click', '#authority-list dl dd', function (e) {
  188. e.stopPropagation();
  189. const id = parseInt($(this).data('id'));
  190. if (!isNaN(id) && id !== 0) {
  191. postData(auditSaveUrl, {type: 'add-audit', id: id}, function (result) {
  192. setList(result);
  193. syncSelectedMarks();
  194. })
  195. }
  196. });
  197. let first = 1;
  198. let auditSaveUrl = '';
  199. $('#authority-list').on('shown.bs.modal', function () {
  200. if (first) {
  201. const option = {
  202. locale: 'zh-CN',
  203. height: 300,
  204. }
  205. $("#contract-audit-table").bootstrapTable('destroy').bootstrapTable(option);
  206. first = 0;
  207. }
  208. postData(auditSaveUrl, { type: 'list' }, function (result) {
  209. setList(result);
  210. });
  211. });
  212. $('body').on('click', '.get-audits', function () {
  213. const stid = $(this).data('stid');
  214. $('#stid').val(stid);
  215. auditSaveUrl = stid ? `/sp/${spid}/contract/tender/${stid}/audit/save`: `/sp/${spid}/contract/audit/save`;
  216. $('#contract-audit-list').html('');
  217. postData(auditSaveUrl, { type: 'check' }, function (result) {
  218. $('#authority-list').modal('show');
  219. });
  220. });
  221. function setList(datas) {
  222. let list = '';
  223. for (const ca of datas) {
  224. list += `<tr>
  225. <td>${ca.name}</td>
  226. <td>${ca.role}</td>
  227. <td>
  228. <input type="checkbox" class="permission-checkbox" data-type="permission_edit" value="${ca.uid}" ${ca.permission_edit ? 'checked' : ''}>
  229. </td>
  230. <td>
  231. <input type="checkbox" class="permission-checkbox" data-type="permission_add" value="${ca.uid}" ${ca.permission_add ? 'checked' : ''}>
  232. </td>
  233. <td>
  234. <input type="checkbox" class="permission-checkbox" data-type="permission_edit_contract" value="${ca.uid}" ${ca.permission_edit_contract ? 'checked' : ''}>
  235. </td>
  236. <td>
  237. <input type="checkbox" class="permission-checkbox" data-type="permission_add_pay" value="${ca.uid}" ${ca.permission_add_pay ? 'checked' : ''}>
  238. </td>
  239. <td>
  240. <input type="checkbox" class="permission-checkbox" data-type="permission_show_unit" value="${ca.uid}" ${ca.permission_show_unit ? 'checked' : ''}>
  241. </td>
  242. <td>
  243. <input type="checkbox" class="permission-checkbox" data-type="permission_show_node" value="${ca.uid}" ${ca.permission_show_node ? 'checked' : ''}>
  244. </td>
  245. <td>
  246. <input type="checkbox" class="permission-checkbox" data-type="permission_att" value="${ca.uid}" ${ca.permission_att ? 'checked' : ''}>
  247. </td>
  248. <td>
  249. <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>
  250. </td>
  251. </tr>`;
  252. }
  253. $('#contract-audit-list').html(list);
  254. $("#contract-audit-table").bootstrapTable('resetView');
  255. syncSelectedMarks();
  256. }
  257. // --- 新增:同步下拉菜单选中状态的函数 ---
  258. function syncSelectedMarks() {
  259. // 1. 获取表格中所有用户的 UID
  260. const tableUids = new Set(); // 使用 Set 提高查找效率
  261. $('#contract-audit-list tr').each(function() {
  262. // 假设每个权限复选框的 value 都是用户的 uid
  263. const $firstCheckbox = $(this).find('.permission-checkbox').first();
  264. if ($firstCheckbox.length) {
  265. const uid = parseInt($firstCheckbox.val(), 10);
  266. if (!isNaN(uid)) {
  267. tableUids.add(uid);
  268. }
  269. }
  270. });
  271. // 2. 遍历下拉菜单中的所有用户项 (dd),并根据 UID 状态更新 .selected-mark
  272. $('.dropdown-menu .book-list dd[data-id]').each(function() {
  273. const userId = parseInt($(this).data('id'), 10); // 获取 dd 的 data-id
  274. const $mark = $(this).find('.selected-mark'); // 找到对应的标记 span
  275. if (!isNaN(userId) && $mark.length > 0) {
  276. if (tableUids.has(userId)) {
  277. // 如果用户已在表格中,则显示勾选标记
  278. $mark.show();
  279. } else {
  280. // 如果用户不在表格中,则隐藏勾选标记
  281. $mark.hide();
  282. }
  283. }
  284. });
  285. }
  286. // --- 新增结束 ---
  287. $('body').on('click', '.del-contract-audit-a', function () {
  288. $('#del-audit-ids').val($(this).attr('data-id'));
  289. $('#del-contract-audit').modal('show');
  290. });
  291. $('#del-audit-btn').click(function () {
  292. let uids = $('#del-audit-ids').val();
  293. postData(auditSaveUrl, { type: 'del-audit', id: uids.split(',') }, function (result) {
  294. // toastr.success(`成功添加 位用户`);
  295. $('#del-contract-audit').modal('hide');
  296. setList(result);
  297. syncSelectedMarks();
  298. })
  299. });
  300. // 上报人权限勾选
  301. $('body').on('click', '.permission-checkbox', function () {
  302. const type = $(this).attr('data-type');
  303. const value = $(this).is(':checked') ? 1 : 0;
  304. const uid = parseInt($(this).val());
  305. const updateInfo = { uid };
  306. updateInfo[type] = value;
  307. postData(auditSaveUrl, { type: 'save-permission', updateData: updateInfo }, function (result) {
  308. })
  309. });
  310. });
  311. </script>
  312. <% } %>