modal.ejs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  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. <div class="modal fade" id="add-cy" data-backdrop="static" >
  18. <div class="modal-dialog" role="document">
  19. <div class="modal-content">
  20. <div class="modal-header">
  21. <h5 class="modal-title">成员管理</h5>
  22. </div>
  23. <div class="modal-body">
  24. <input type="hidden" id="tender_id" />
  25. <div class="dropdown">
  26. <button class="btn btn-outline-primary btn-sm dropdown-toggle" type="button" id="dropdownMenuButton"
  27. data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
  28. 添加用户
  29. </button>
  30. <div class="dropdown-menu dropdown-menu-left" aria-labelledby="dropdownMenuButton" style="width:220px">
  31. <div class="mb-2 p-2"><input class="form-control form-control-sm" placeholder="姓名/手机 检索"
  32. id="gr-search" autocomplete="off"></div>
  33. <dl class="list-unstyled book-list">
  34. <% accountGroup.forEach((group, idx) => { %>
  35. <dt><a href="javascript: void(0);" class="acc-btn" data-groupid="<%- idx %>"
  36. data-type="hide"><i class="fa fa-plus-square"></i></a> <%- group.groupName %></dt>
  37. <div class="dd-content" data-toggleid="<%- idx %>">
  38. <% group.groupList.forEach(item => { %>
  39. <dd class="border-bottom p-2 mb-0 " data-id="<%- item.id %>">
  40. <p class="mb-0 d-flex"><span class="text-primary"><%- item.name %></span><span
  41. class="ml-auto"><%- item.mobile %></span></p>
  42. <span class="text-muted"><%- item.role %></span>
  43. </dd>
  44. <% });%>
  45. </div>
  46. <% }) %>
  47. </dl>
  48. </div>
  49. </div>
  50. <div class="mt-1" style="height:300px">
  51. <table id="construction-audit-table" class="table table-bordered" data-height="300" data-toggle="table">
  52. <thead class="text-center customize-header">
  53. <tr>
  54. <th width="100">成员名称</th>
  55. <th width="150">职位</th>
  56. <th>填报人</th>
  57. <th>操作</th>
  58. </tr>
  59. </thead>
  60. <tbody id="construction-audit-list" class="text-center">
  61. </tbody>
  62. </table>
  63. </div>
  64. </div>
  65. <div class="modal-footer">
  66. <button type="button" class="btn btn-sm btn-secondary" data-dismiss="modal">关闭</button>
  67. </div>
  68. </div>
  69. </div>
  70. </div>
  71. <!-- 弹窗删除权限用户 -->
  72. <div class="modal fade" id="del-construction-audit" data-backdrop="static">
  73. <div class="modal-dialog" role="document">
  74. <div class="modal-content">
  75. <div class="modal-header">
  76. <h5 class="modal-title">删除用户</h5>
  77. </div>
  78. <div class="modal-body">
  79. <h6>确认删除当前所选用户?</h6>
  80. </div>
  81. <div class="modal-footer">
  82. <button type="button" class="btn btn-sm btn-secondary" data-dismiss="modal">取消</button>
  83. <input type="hidden" id="del-audit-ids" />
  84. <button type="button" class="btn btn-sm btn-danger" id="del-audit-btn">确定删除</button>
  85. </div>
  86. </div>
  87. </div>
  88. </div>
  89. <script src="/public/js/bootstrap/bootstrap-table.min.js"></script>
  90. <script src="/public/js/bootstrap/locales/bootstrap-table-zh-CN.min.js"></script>
  91. <script>
  92. $(function () {
  93. let timer = null
  94. let oldSearchVal = null
  95. const accountGroup = JSON.parse(unescape('<%- escape(JSON.stringify(accountGroup)) %>'));
  96. const accountList = JSON.parse(unescape('<%- escape(JSON.stringify(accountList)) %>'));
  97. $('#gr-search').bind('input propertychange', function (e) {
  98. oldSearchVal = e.target.value
  99. timer && clearTimeout(timer)
  100. timer = setTimeout(() => {
  101. const newVal = $('#gr-search').val()
  102. let html = ''
  103. if (newVal && newVal === oldSearchVal) {
  104. accountList.filter(item => item && (item.name.indexOf(newVal) !== -1 || (item.mobile && item.mobile.indexOf(newVal) !== -1))).forEach(item => {
  105. html += `<dd class="border-bottom p-2 mb-0 " data-id="${item.id}" >
  106. <p class="mb-0 d-flex"><span class="text-primary">${item.name}</span><span
  107. class="ml-auto">${item.mobile || ''}</span></p>
  108. <span class="text-muted">${item.role || ''}</span>
  109. </dd>`
  110. })
  111. $('.book-list').empty()
  112. $('.book-list').append(html)
  113. } else {
  114. if (!$('.acc-btn').length) {
  115. accountGroup.forEach((group, idx) => {
  116. if (!group) return
  117. html += `<dt><a href="javascript: void(0);" class="acc-btn" data-groupid="${idx}" data-type="hide"><i class="fa fa-plus-square"></i>
  118. </a> ${group.groupName}</dt>
  119. <div class="dd-content" data-toggleid="${idx}">`
  120. group.groupList.forEach(item => {
  121. html += `<dd class="border-bottom p-2 mb-0 " data-id="${item.id}" >
  122. <p class="mb-0 d-flex"><span class="text-primary">${item.name}</span><span
  123. class="ml-auto">${item.mobile || ''}</span></p>
  124. <span class="text-muted">${item.role || ''}</span>
  125. </dd>`
  126. });
  127. html += '</div>'
  128. })
  129. $('.book-list').empty()
  130. $('.book-list').append(html)
  131. }
  132. }
  133. }, 400);
  134. });
  135. // 添加到成员中
  136. $('.book-list').on('click', 'dt', function () {
  137. const idx = $(this).find('.acc-btn').attr('data-groupid')
  138. const type = $(this).find('.acc-btn').attr('data-type')
  139. if (type === 'hide') {
  140. $(this).parent().find(`div[data-toggleid="${idx}"]`).show(() => {
  141. $(this).children().find('i').removeClass('fa-plus-square').addClass('fa-minus-square-o')
  142. $(this).find('.acc-btn').attr('data-type', 'show')
  143. })
  144. } else {
  145. $(this).parent().find(`div[data-toggleid="${idx}"]`).hide(() => {
  146. $(this).children().find('i').removeClass('fa-minus-square-o').addClass('fa-plus-square')
  147. $(this).find('.acc-btn').attr('data-type', 'hide')
  148. })
  149. }
  150. return false
  151. });
  152. // 添加到成员中
  153. $('dl').on('click', 'dd', function () {
  154. const id = parseInt($(this).data('id'));
  155. console.log(id);
  156. if (!isNaN(id) && id !== 0) {
  157. postData(`/sp/${spid}/construction/${$('#tender_id').val()}/audit/save`, {type: 'add-audit', id: id}, function (result) {
  158. setList(result);
  159. })
  160. }
  161. });
  162. let first = 1;
  163. $('#add-cy').on('shown.bs.modal', function () {
  164. if (first) {
  165. const option = {
  166. locale: 'zh-CN',
  167. height: 300,
  168. }
  169. $("#construction-audit-table").bootstrapTable('destroy').bootstrapTable(option);
  170. first = 0;
  171. }
  172. const tid = $('#tender_id').val();
  173. if (tid) {
  174. postData(`/sp/${spid}/construction/${$('#tender_id').val()}/audit/save`, { type: 'list' }, function (result) {
  175. setList(result);
  176. });
  177. }
  178. });
  179. $('body').on('click', '.get-audits', function () {
  180. const tid = $(this).data('tid');
  181. $('#tender_id').val(tid);
  182. $('#construction-audit-list').html('');
  183. });
  184. function setList(datas) {
  185. let list = '';
  186. for (const ca of datas) {
  187. list += `<tr>
  188. <td>${ca.name}</td>
  189. <td>${ca.role}</td>
  190. <td>
  191. <input type="checkbox" class="report-checkbox" data-type="is_report" value="${ca.id}" ${ca.is_report ? 'checked' : ''}>
  192. </td>
  193. <td>
  194. <a href="#del-construction-audit" data-toggle="modal" data-target="#del-construction-audit" class="btn btn-outline-danger btn-sm ml-1 del-construction-audit-a" data-id="${ca.id}">移除</a>
  195. </td>
  196. </tr>`;
  197. }
  198. $('#construction-audit-list').html(list);
  199. $("#construction-audit-table").bootstrapTable('resetView');
  200. }
  201. $('body').on('click', '.del-construction-audit-a', function () {
  202. $('#del-audit-ids').val($(this).attr('data-id'));
  203. $('#del-construction-audit').modal('show');
  204. });
  205. $('#del-audit-btn').click(function () {
  206. let uids = $('#del-audit-ids').val();
  207. postData(`/sp/${spid}/construction/${$('#tender_id').val()}/audit/save`, { type: 'del-audit', id: uids.split(',') }, function (result) {
  208. // toastr.success(`成功添加 位用户`);
  209. $('#del-construction-audit').modal('hide');
  210. setList(result);
  211. })
  212. });
  213. // 上报人权限勾选
  214. $('body').on('click', '.report-checkbox', function () {
  215. const type = $(this).attr('data-type');
  216. const value = $(this).is(':checked') ? 1 : 0;
  217. const id = parseInt($(this).val());
  218. const updateInfo = {
  219. id,
  220. is_report: $(this).is(':checked'),
  221. }
  222. postData(`/sp/${spid}/construction/${$('#tender_id').val()}/audit/save`, { type: 'save-report', updateData: updateInfo }, function (result) {
  223. })
  224. });
  225. });
  226. </script>
  227. <% } %>