modal.ejs 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561
  1. <% if (auditPermission.admin) { %>
  2. <!-- 弹窗新建目录 -->
  3. <div class="modal fade" id="add-folder" data-backdrop="static">
  4. <div class="modal-dialog" role="document">
  5. <div class="modal-content">
  6. <div class="modal-header">
  7. <h5 class="modal-title">新建文件夹</h5>
  8. </div>
  9. <div class="modal-body">
  10. <div class="form-group" id="parent_folder" style="display: none">
  11. <label for="parent_folder_name">父文件夹名称</label>
  12. <input type="text" class="form-control form-control-sm" id="parent_folder_name" readonly>
  13. </div>
  14. <div class="form-group">
  15. <label for="new_folder_name">文件夹名称</label>
  16. <input type="text" class="form-control form-control-sm" id="new_folder_name" placeholder="请输入文件夹名称" required>
  17. <div class="invalid-feedback">
  18. <!--名称超过100个字,请缩减名称-->
  19. </div>
  20. </div>
  21. </div>
  22. <div class="modal-footer">
  23. <input type="hidden" id="parent_id" value="0">
  24. <button type="button" class="btn btn-sm btn-secondary" data-dismiss="modal">取消</button>
  25. <button type="button" class="btn btn-sm btn-primary" id="new_folder_btn">确定添加</button>
  26. </div>
  27. </div>
  28. </div>
  29. </div>
  30. <div class="modal fade" id="edit-name" data-backdrop="static">
  31. <div class="modal-dialog" role="document">
  32. <div class="modal-content">
  33. <div class="modal-header">
  34. <h5 class="modal-title">修改文件夹</h5>
  35. </div>
  36. <div class="modal-body">
  37. <form>
  38. <div class="form-group">
  39. <label for="edit_name_input">名称</label>
  40. <input type="text" class="form-control form-control-sm" id="edit_name_input" placeholder="请输入名称" required>
  41. <div class="invalid-feedback">
  42. <!--名称超过100个字,请缩减名称-->
  43. </div>
  44. </div>
  45. </form>
  46. </div>
  47. <div class="modal-footer">
  48. <input type="hidden" id="edit_name_id" />
  49. <input type="hidden" id="edit_name_type" />
  50. <button type="button" class="btn btn-sm btn-secondary" data-dismiss="modal">取消</button>
  51. <button type="button" class="btn btn-sm btn-primary" id="edit_name_btn">确定修改</button>
  52. </div>
  53. </div>
  54. </div>
  55. </div>>
  56. <!-- 弹窗新建标段 -->
  57. <div class="modal fade" id="add-tender" data-backdrop="static">
  58. <div class="modal-dialog" role="document">
  59. <div class="modal-content">
  60. <div class="modal-header">
  61. <h5 class="modal-title">新建标段</h5>
  62. </div>
  63. <div class="modal-body">
  64. <div class="form-group">
  65. <label for="add_tender_folder_name">文件夹名称</label>
  66. <input type="text" class="form-control form-control-sm" id="add_tender_folder_name" readonly>
  67. </div>
  68. <div class="form-group">
  69. <label for="add_tender_name">标段名称</label>
  70. <input type="text" class="form-control form-control-sm" id="add_tender_name" placeholder="请输入标段名称" required>
  71. <div class="invalid-feedback">
  72. <!--名称超过100个字,请缩减名称-->
  73. </div>
  74. </div>
  75. </div>
  76. <div class="modal-footer">
  77. <input type="hidden" id="add_tender_folder_id" />
  78. <button type="button" class="btn btn-sm btn-secondary" data-dismiss="modal">取消</button>
  79. <button type="button" class="btn btn-sm btn-primary" id="new_tender_btn">确定添加</button>
  80. </div>
  81. </div>
  82. </div>
  83. </div>
  84. <!-- 弹窗删除项目 -->
  85. <div class="modal fade" id="del-project" data-backdrop="static">
  86. <div class="modal-dialog" role="document">
  87. <div class="modal-content">
  88. <div class="modal-header">
  89. <h5 class="modal-title">删除标段</h5>
  90. </div>
  91. <div class="modal-body">
  92. <h6>确认删除 <span></span>?</h6>
  93. </div>
  94. <div class="modal-footer">
  95. <input type="hidden" id="del_id" />
  96. <input type="hidden" id="del_type" />
  97. <button type="button" class="btn btn-sm btn-secondary" data-dismiss="modal">取消</button>
  98. <button type="button" class="btn btn-sm btn-danger" id="del_btn">确定删除</button>
  99. </div>
  100. </div>
  101. </div>
  102. </div>
  103. <% } %>
  104. <% if (ctx.session.sessionUser.is_admin) { %>
  105. <link href="/public/css/bootstrap/bootstrap-table.min.css" rel="stylesheet">
  106. <link href="/public/css/bootstrap/bootstrap-table-fixed-columns.min.css" rel="stylesheet">
  107. <style>
  108. /*.bootstrap-table .fixed-table-container.fixed-height:not(.has-footer) {*/
  109. /*border-bottom: 0;*/
  110. /*}*/
  111. @-moz-document url-prefix() {
  112. table {
  113. table-layout: fixed;
  114. }
  115. }
  116. </style>
  117. <!-- 弹窗编辑项目 -->
  118. <div class="modal fade" id="authority-list" data-backdrop="static">
  119. <div class="modal-dialog modal-lg" role="document">
  120. <div class="modal-content">
  121. <div class="modal-header">
  122. <h5 class="modal-title">权限管理</h5>
  123. </div>
  124. <div class="modal-body">
  125. <div class="d-flex flex-row bg-graye">
  126. <div class="p-2">
  127. <button class="btn btn-outline-primary btn-sm dropdown-toggle" type="button" id="dropdownMenuButton"
  128. data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
  129. 添加用户
  130. </button>
  131. <div class="dropdown-menu dropdown-menu-left" aria-labelledby="dropdownMenuButton" style="width:220px">
  132. <div class="mb-2 p-2"><input class="form-control form-control-sm" placeholder="姓名/手机 检索"
  133. id="gr-search" autocomplete="off"></div>
  134. <dl class="list-unstyled book-list">
  135. <% accountGroup.forEach((group, idx) => { %>
  136. <dt><a href="javascript: void(0);" class="acc-btn" data-groupid="<%- idx %>"
  137. data-type="hide"><i class="fa fa-plus-square"></i></a> <%- group.groupName %></dt>
  138. <div class="dd-content" data-toggleid="<%- idx %>">
  139. <dd class="border-bottom p-2 mb-0" data-groupname="<%- group.groupName %>"><p class="mb-0 d-flex"><span class="text-primary">该单位下所有组员</span></p></dd>
  140. <% group.groupList.forEach(item => { %>
  141. <dd class="border-bottom p-2 mb-0 " data-id="<%- item.id %>">
  142. <p class="mb-0 d-flex"><span class="text-primary"><%- item.name %></span><span
  143. class="ml-auto"><%- item.mobile %></span></p>
  144. <span class="text-muted"><%- item.role %></span>
  145. </dd>
  146. <% });%>
  147. </div>
  148. <% }) %>
  149. </dl>
  150. </div>
  151. </div>
  152. <div class="p-2"><a href="javascript:void(0)" id="del-permission-audits-btn">批量删除</a></div>
  153. </div>
  154. <div style="height:300px">
  155. <table id="permission-audit-table" class="table table-bordered" data-height="300" data-toggle="table">
  156. <thead>
  157. <tr>
  158. <th class="text-center">选择</th>
  159. <th class="text-center">用户名</th>
  160. <th class="text-center">单位</th>
  161. <th class="text-center">添加时间</th>
  162. <th class="text-center">模块管理员</th>
  163. <th class="text-center">查看所有标段</th>
  164. <th class="text-center">操作</th>
  165. </tr>
  166. </thead>
  167. <tbody id="permission-audit-list">
  168. <% for (const pa of permissionAudits) { %>
  169. <tr>
  170. <td class="text-center"><input type="checkbox" name="uid[]" value="<%- pa.uid %>"></td>
  171. <td class="text-left"><%- pa.name %></td>
  172. <td class="text-left"><%- pa.company %></td>
  173. <td class="text-left"><%- ctx.helper.formatFullDate(pa.create_time) %></td>
  174. <td class="text-center"><input type="checkbox" class="permission-checkbox" data-type="admin" value="<%- pa.uid %>" <% if (pa.permission_json.admin) { %>checked<% } %>></td>
  175. <td class="text-center"><input type="checkbox" class="permission-checkbox" data-type="view_all" value="<%- pa.uid %>" <% if (pa.permission_json.view_all) { %>checked<% } %>></td>
  176. <td class="text-center"><a href="javascript:void(0);" class="text-danger del-permission-audit-a" data-id="<%- pa.uid %>">移除</a></td>
  177. </tr>
  178. <% } %>
  179. </tbody>
  180. </table>
  181. </div>
  182. </div>
  183. <div class="modal-footer">
  184. <button type="button" class="btn btn-sm btn-outline-dark" data-dismiss="modal">关闭</button>
  185. </div>
  186. </div>
  187. </div>
  188. </div>
  189. <!-- 弹窗删除权限用户 -->
  190. <div class="modal fade" id="del-permission-audit" data-backdrop="static">
  191. <div class="modal-dialog" role="document">
  192. <div class="modal-content">
  193. <div class="modal-header">
  194. <h5 class="modal-title">删除用户</h5>
  195. </div>
  196. <div class="modal-body">
  197. <h6>确认删除当前所选用户?</h6>
  198. </div>
  199. <div class="modal-footer">
  200. <button type="button" class="btn btn-sm btn-secondary" data-dismiss="modal">取消</button>
  201. <input type="hidden" id="del-audit-ids" />
  202. <button type="button" class="btn btn-sm btn-danger" id="del-audit-btn">确定删除</button>
  203. </div>
  204. </div>
  205. </div>
  206. </div>
  207. <% if (noSpTenderList.length > 0) { %>
  208. <div class="modal fade" id="nosp-list" data-backdrop="static">
  209. <div class="modal-dialog modal-lg" role="document">
  210. <div class="modal-content">
  211. <div class="modal-header">
  212. <h5 class="modal-title">关联标段</h5>
  213. </div>
  214. <div class="modal-body" style="position: relative;overflow: auto;max-height: 800px;padding-top: 0;margin-top: 1rem;">
  215. <style>
  216. .c-NoSpBody .table thead th {
  217. border: none;
  218. outline-width: 1px;
  219. outline-style: solid;
  220. outline-color: #dee2e6;
  221. }
  222. </style>
  223. <div class="c-NoSpBody">
  224. </div>
  225. </div>
  226. <div class="modal-footer">
  227. <button type="button" class="btn btn-sm btn-secondary" data-dismiss="modal">取消</button>
  228. <button type="button" class="btn btn-sm btn-primary" id="bind-spBtn">确定</button>
  229. </div>
  230. </div>
  231. </div>
  232. </div>
  233. <% } %>
  234. <% } %>
  235. <% if (ctx.session.sessionUser.is_admin) { %>
  236. <script src="/public/js/bootstrap/bootstrap-table.min.js"></script>
  237. <script src="/public/js/bootstrap/locales/bootstrap-table-zh-CN.min.js"></script>
  238. <!--<script src="/public/js/bootstrap/bootstrap-table-fixed-columns.min.js"></script>-->
  239. <script>
  240. <% if (noSpTenderList.length > 0) { %>
  241. const noSpTenderList = JSON.parse(unescape('<%- escape(JSON.stringify(noSpTenderList)) %>'));
  242. const noSpFolderList = JSON.parse(unescape('<%- escape(JSON.stringify(noSpFolderList)) %>'));
  243. <% } %>
  244. $(function () {
  245. // $("#permission-audit-table").bootstrapTable('destroy').bootstrapTable({
  246. // fixedColumns: true,
  247. // // height:200
  248. // // fixedNumber: 1 //固定列数
  249. // });
  250. let timer = null
  251. let oldSearchVal = null
  252. let permissionAudits = JSON.parse(unescape('<%- escape(JSON.stringify(permissionAudits)) %>'));
  253. const accountGroup = JSON.parse(unescape('<%- escape(JSON.stringify(accountGroup)) %>'));
  254. const accountList = JSON.parse(unescape('<%- escape(JSON.stringify(accountList)) %>'));
  255. $('#gr-search').bind('input propertychange', function(e) {
  256. oldSearchVal = e.target.value
  257. timer && clearTimeout(timer)
  258. timer = setTimeout(() => {
  259. const newVal = $('#gr-search').val()
  260. let html = ''
  261. if (newVal && newVal === oldSearchVal) {
  262. accountList.filter(item => item && (item.name.indexOf(newVal) !== -1 || (item.mobile && item.mobile.indexOf(newVal) !== -1))).forEach(item => {
  263. html += `<dd class="border-bottom p-2 mb-0 " data-id="${item.id}" >
  264. <p class="mb-0 d-flex"><span class="text-primary">${item.name}</span><span
  265. class="ml-auto">${item.mobile || ''}</span></p>
  266. <span class="text-muted">${item.role || ''}</span>
  267. </dd>`
  268. })
  269. $('.book-list').empty()
  270. $('.book-list').append(html)
  271. } else {
  272. if (!$('.acc-btn').length) {
  273. accountGroup.forEach((group, idx) => {
  274. if (!group) return
  275. html += `<dt><a href="javascript: void(0);" class="acc-btn" data-groupid="${idx}" data-type="hide"><i class="fa fa-plus-square"></i>
  276. </a> ${group.groupName}</dt>
  277. <div class="dd-content" data-toggleid="${idx}">
  278. <dd class="border-bottom p-2 mb-0" data-groupname="${group.groupName}"><p class="mb-0 d-flex"><span class="text-primary">该单位下所有组员</span></p></dd>`
  279. group.groupList.forEach(item => {
  280. html += `<dd class="border-bottom p-2 mb-0 " data-id="${item.id}" >
  281. <p class="mb-0 d-flex"><span class="text-primary">${item.name}</span><span
  282. class="ml-auto">${item.mobile || ''}</span></p>
  283. <span class="text-muted">${item.role || ''}</span>
  284. </dd>`
  285. });
  286. html += '</div>'
  287. })
  288. $('.book-list').empty()
  289. $('.book-list').append(html)
  290. }
  291. }
  292. }, 400);
  293. });
  294. // 添加到成员中
  295. $('.book-list').on('click', 'dt', function () {
  296. const idx = $(this).find('.acc-btn').attr('data-groupid')
  297. const type = $(this).find('.acc-btn').attr('data-type')
  298. if (type === 'hide') {
  299. $(this).parent().find(`div[data-toggleid="${idx}"]`).show(() => {
  300. $(this).children().find('i').removeClass('fa-plus-square').addClass('fa-minus-square-o')
  301. $(this).find('.acc-btn').attr('data-type', 'show')
  302. })
  303. } else {
  304. $(this).parent().find(`div[data-toggleid="${idx}"]`).hide(() => {
  305. $(this).children().find('i').removeClass('fa-minus-square-o').addClass('fa-plus-square')
  306. $(this).find('.acc-btn').attr('data-type', 'hide')
  307. })
  308. }
  309. return false
  310. });
  311. // 添加到成员中
  312. $('dl').on('click', 'dd', function () {
  313. const id = parseInt($(this).data('id'));
  314. const groupName = $(this).data('groupname');
  315. console.log(groupName);
  316. if (!isNaN(id) && id !== 0) {
  317. postData('/sp/' + spid + '/payment/permission/save', { type: 'add-audit', id: id }, function (result) {
  318. permissionAudits = result;
  319. setList(permissionAudits);
  320. })
  321. } else if (groupName && groupName !== '') {
  322. const groupAuditList = _.filter(accountList, { company: groupName });
  323. const groupAidList = _.map(groupAuditList, 'id');
  324. const groupPAList = _.map(permissionAudits, 'uid');
  325. const addAidList = _.difference(groupAidList, groupPAList);
  326. console.log(groupAidList, groupPAList, addAidList);
  327. if (addAidList.length > 0) {
  328. postData('/sp/' + spid + '/payment/permission/save', { type: 'add-audit', id: addAidList }, function (result) {
  329. // toastr.success(`成功添加 位用户`);
  330. permissionAudits = result;
  331. setList(permissionAudits);
  332. })
  333. } else {
  334. toastr.warning('暂无用户添加');
  335. }
  336. }
  337. });
  338. function setList(datas) {
  339. let list = '';
  340. for (const pa of datas) {
  341. list += `<tr>
  342. <td class="text-center"><input type="checkbox" name="uid[]" value="${pa.uid}"></td>
  343. <td class="text-left">${pa.name}</td>
  344. <td class="text-left">${pa.company}</td>
  345. <td class="text-left">${moment(pa.create_time).format('YYYY-MM-DD HH:mm:ss')}</td>
  346. <td class="text-center"><input type="checkbox" class="permission-checkbox" data-type="admin" value="${pa.uid}" ${pa.permission_json.admin ? 'checked' : ''}></td>
  347. <td class="text-center"><input type="checkbox" class="permission-checkbox" data-type="view_all" value="${pa.uid}" ${pa.permission_json.view_all ? 'checked' : ''}></td>
  348. <td class="text-center"><a href="javascript:void(0);" class="text-danger del-permission-audit-a" data-id="${pa.uid}">移除</a></td>
  349. </tr>`;
  350. }
  351. $('#permission-audit-list').html(list);
  352. $("#permission-audit-table").bootstrapTable('resetView');
  353. }
  354. let first = 1;
  355. $('#authority-list').on('shown.bs.modal', function () {
  356. if (first) {
  357. const option = {
  358. // fixedColumns: true,
  359. // fixedNumber: 1, //固定列数
  360. locale: 'zh-CN',
  361. height: 300,
  362. }
  363. // if (permissionAudits.length === 0) {
  364. // option.formatName = function () {
  365. // return '暂无数据';
  366. // }
  367. // }
  368. $("#permission-audit-table").bootstrapTable('destroy').bootstrapTable(option);
  369. first = 0;
  370. }
  371. })
  372. $('#del-permission-audits-btn').click(function () {
  373. const checkArray = [];
  374. $('#permission-audit-list input[name="uid[]"]:checked').each(function() {
  375. checkArray.push(parseInt($(this).val())); //向数组中添加元素
  376. });
  377. console.log(checkArray);
  378. if (checkArray.length === 0) {
  379. toastr.warning('暂无用户被选中');
  380. } else {
  381. $('#del-audit-ids').val(checkArray.join(','));
  382. $('#del-permission-audit').modal('show');
  383. }
  384. });
  385. $('body').on('click', '.del-permission-audit-a', function () {
  386. $('#del-audit-ids').val($(this).attr('data-id'));
  387. $('#del-permission-audit').modal('show');
  388. });
  389. $('#del-audit-btn').click(function () {
  390. let uids = $('#del-audit-ids').val();
  391. postData('/sp/' + spid + '/payment/permission/save', { type: 'del-audit', id: uids.split(',') }, function (result) {
  392. // toastr.success(`成功添加 位用户`);
  393. $('#del-permission-audit').modal('hide');
  394. permissionAudits = result;
  395. setList(permissionAudits);
  396. })
  397. });
  398. // 权限勾选
  399. $('body').on('click', '.permission-checkbox', function () {
  400. const type = $(this).attr('data-type');
  401. const value = $(this).is(':checked') ? 1 : 0;
  402. const userInfo = _.find(permissionAudits, { uid: parseInt($(this).val()) });
  403. if (!userInfo) {
  404. toastr.error('用户不存在');
  405. }
  406. userInfo.permission_json[type] = value;
  407. if (value === 1 && type === 'admin') {
  408. userInfo.permission_json['view_all'] = value;
  409. $(this).parents('tr').find('input[data-type="view_all"]').prop('checked', value);
  410. }
  411. const updateInfo = {
  412. uid: userInfo.uid,
  413. permission_json: userInfo.permission_json,
  414. }
  415. postData('/sp/' + spid + '/payment/permission/save', { type: 'save-permission-one', updateData: updateInfo }, function (result) {
  416. // toastr.success(`成功添加 位用户`);
  417. })
  418. });
  419. // $('body').on('click', '.permission-all-checkbox', function () {
  420. // console.log($(this).attr('data-type'), $(this).is(':checked'));
  421. // const type = $(this).attr('data-type');
  422. // const value = $(this).is(':checked') ? 1 : 0;
  423. // postData('/sp/' + spid + '/payment/permission/save', { type: 'save-permission-all', permission_type: type, value }, function (result) {
  424. // // toastr.success(`成功添加 位用户`);
  425. // permissionAudits = result;
  426. // setList(permissionAudits);
  427. // })
  428. // })
  429. <% if (noSpTenderList.length > 0) { %>
  430. let noSpTenderTree = [];
  431. let noSpParentId = 0;
  432. function initNoSpTenderTree(folderList, tenderList) {
  433. noSpTenderTree = [];
  434. const folders = folderList;
  435. const tenders = tenderList;
  436. function makeNoSpTenderTree(parent) {
  437. if (parent.is_leaf) {
  438. parent.children = _.filter(tenders, { folder_id: parent.folder_id });
  439. if (parent.children.length > 0) {
  440. parent.is_tender = true;
  441. parent.children.forEach((value, index) => {
  442. value.level = parent.level + 1;
  443. });
  444. }
  445. } else {
  446. const children = _.filter(folders, { parent_id: parent.folder_id });
  447. parent.children = children;
  448. if (children.length > 0) {
  449. for (const c of children) {
  450. makeNoSpTenderTree(c);
  451. }
  452. }
  453. }
  454. }
  455. const level0Folders = _.filter(folders, { level: 1 });
  456. for (const l of level0Folders) {
  457. makeNoSpTenderTree(l);
  458. noSpTenderTree.push(l);
  459. }
  460. console.log(noSpTenderTree);
  461. }
  462. function recursiveGetNoSpTenderNodeHtml (node, arr, pid) {
  463. const html = [];
  464. html.push('<tr fid="' + (node.parent_id !== undefined ? node.id: 0) + '" pid="' + pid + '">');
  465. // 选择框
  466. html.push('<td style="width: 5%;text-align: center;">');
  467. if (node.parent_id === undefined) {
  468. html.push('<input type="checkbox" name="tender[]" value="' + node.id + '">');
  469. }
  470. html.push('</td>');
  471. // 名称
  472. html.push('<td class="in-' + node.level + '">');
  473. if (node.parent_id !== undefined) {
  474. // html.push('<span onselectstart="return false" style="{-moz-user-select:none}" class="fold-switch mr-1" title="收起" cid="'+ node.sort_id +'"><i class="fa fa-minus-square-o"></i></span> <i class="fa fa-folder-o"></i> ', node.name);
  475. html.push('<i class="fa fa-folder-o"></i> ', node.name);
  476. } else {
  477. html.push('<span class="text-muted mr-2">');
  478. html.push(arr.indexOf(node) === arr.length - 1 ? '└' : '├');
  479. html.push('</span>');
  480. //html.push('<a href="/tender/' + node.id + '">', node[c.field], '</a>');
  481. html.push(node.name);
  482. }
  483. html.push('</td>');
  484. // 创建人
  485. html.push('<td style="width: 15%" class="text-center">', node.user_name ? node.user_name : '', '</td>');
  486. // 创建时间
  487. html.push('<td style="width: 20%" class="text-center">', node.in_time && node.parent_id === undefined ? moment(node.in_time).format('YYYY-MM-DD HH:mm:ss') : '', '</td>');
  488. html.push('</tr>');
  489. if (node.children) {
  490. for (const c of node.children) {
  491. html.push(recursiveGetNoSpTenderNodeHtml(c, node.children, node.sort_id));
  492. }
  493. }
  494. return html.join('');
  495. }
  496. // 根据TenderTree数据获取Html代码
  497. function getNoSpTenderTreeHtml () {
  498. if (noSpTenderTree.length > 0) {
  499. const html = [];
  500. html.push('<table class="table table-hover table-bordered">');
  501. html.push('<thead style="position: sticky;left:56px;top: 0;">', '<tr>');
  502. html.push('<th class="text-center" style="width: 5%;">', '<input type="checkbox" id="select-all-tender" />', '</th>');
  503. html.push('<th class="text-center">', '名称', '</th>');
  504. html.push('<th class="text-center" style="width: 15%">', '创建人', '</th>');
  505. html.push('<th class="text-center" style="width: 20%">', '创建时间', '</th>');
  506. html.push('</tr>', '</thead>');
  507. noSpParentId = 0;
  508. for (const t of noSpTenderTree) {
  509. html.push(recursiveGetNoSpTenderNodeHtml(t, noSpTenderTree, ''));
  510. }
  511. html.push('</table>');
  512. return html.join('');
  513. } else {
  514. return '';
  515. }
  516. }
  517. function makeNoSpList(folderList, tenderList) {
  518. initNoSpTenderTree(folderList, tenderList);
  519. $('.c-NoSpBody').html(getNoSpTenderTreeHtml());
  520. $('[data-toggle="tooltip"]').tooltip()
  521. }
  522. makeNoSpList(noSpFolderList, noSpTenderList);
  523. $('body').on('click', '#select-all-tender', function () {
  524. const checked = $(this).is(':checked');
  525. $('.c-NoSpBody table').find('input[type="checkbox"]').prop('checked', checked);
  526. });
  527. $("#bind-spBtn").click(function () {
  528. const checkedTender = $('.c-NoSpBody table tbody').find('input[type="checkbox"]:checked');
  529. const tenderIds = [];
  530. checkedTender.each(function () {
  531. tenderIds.push(parseInt($(this).val()));
  532. });
  533. if (tenderIds.length === 0) {
  534. toastr.error('请选择需要关联的标段');
  535. return;
  536. }
  537. console.log(tenderIds);
  538. postData('/sp/' + spid + '/payment/permission/save', { type: 'bind-sp', tids: tenderIds }, function (result) {
  539. window.location.reload();
  540. })
  541. })
  542. <% } %>
  543. })
  544. </script>
  545. <% } %>