payment_process.js 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514
  1. $(function () {
  2. autoFlashHeight();
  3. // 全选报表
  4. $('#select_all_rpt_checkbox').click(function () {
  5. $(this).prop('checked', false);
  6. $('#rpt_table input[name="rptId[]"]').each(function () {
  7. if (parseInt($(this).val()) !== -1) {
  8. $(this).prop('checked', true);
  9. }
  10. });
  11. });
  12. $('#add_rpt_btn').click(function () {
  13. const checkArray = [];
  14. $('#rpt_table input[name="rptId[]"]:checked').each(function() {
  15. checkArray.push({
  16. id: parseInt($(this).val()),
  17. name: $(this).attr('data-name'),
  18. }); //向数组中添加元素
  19. });
  20. postData('/payment/' + tenderId + '/process/save', { type: 'add-rpt', rpt_list: checkArray }, function (result) {
  21. const html = [];
  22. for (const data of result) {
  23. html.push(`<tr data-id="${data.id}">\n`);
  24. html.push(`<td>${data.rpt_name}</td>\n`);
  25. html.push(`<td>${data.user_name}</td>\n`);
  26. html.push(`<td>${data.uid ? _.find(accountList, { id: data.uid }).name : ''}</td>\n`);
  27. html.push('</tr>\n');
  28. }
  29. tenderRptList = result;
  30. $('#tender_rpt_table').html(html.join(''));
  31. if (result.length === 0) {
  32. $('#process_set').hide();
  33. } else {
  34. fisrtSetProcess();
  35. }
  36. $('#add-rpt').modal('hide');
  37. })
  38. });
  39. let timer = null;
  40. let oldSearchVal = null;
  41. $('body').on('input propertychange', '.gr-search', function(e) {
  42. oldSearchVal = e.target.value;
  43. timer && clearTimeout(timer);
  44. timer = setTimeout(() => {
  45. const newVal = $(this).val();
  46. const code = $(this).attr('data-trid');
  47. let html = '';
  48. if (newVal && newVal === oldSearchVal) {
  49. accountList.filter(item => item && (!cur_uid || item.id !== cur_uid) && (item.name.indexOf(newVal) !== -1 || (item.mobile && item.mobile.indexOf(newVal) !== -1))).forEach(item => {
  50. html += `<dd class="border-bottom p-2 mb-0 " data-id="${item.id}" >
  51. <p class="mb-0 d-flex"><span class="text-primary">${item.name}</span><span
  52. class="ml-auto">${item.mobile || ''}</span></p>
  53. <span class="text-muted">${item.role || ''}</span>
  54. </dd>`
  55. });
  56. $(this).parents('.dropdown-menu').children('.book-list').empty();
  57. $(this).parents('.dropdown-menu').children('.book-list').append(html);
  58. // $('#' + code + '_dropdownMenu .book-list').empty();
  59. // $('#' + code + '_dropdownMenu .book-list').append(html);
  60. } else {
  61. if (!$('#' + code + '_dropdownMenu .acc-btn').length) {
  62. accountGroup.forEach((group, idx) => {
  63. if (!group) return;
  64. html += `<dt><a href="javascript: void(0);" class="acc-btn" data-groupid="${idx}" data-type="hide"><i class="fa fa-plus-square"></i>
  65. </a> ${group.groupName}</dt>
  66. <div class="dd-content" data-toggleid="${idx}">`;
  67. group.groupList.forEach(item => {
  68. if (!cur_uid || item.id !== cur_uid) {
  69. html += `<dd class="border-bottom p-2 mb-0 " data-id="${item.id}" >
  70. <p class="mb-0 d-flex"><span class="text-primary">${item.name}</span><span
  71. class="ml-auto">${item.mobile || ''}</span></p>
  72. <span class="text-muted">${item.role || ''}</span>
  73. </dd>`;
  74. }
  75. });
  76. html += '</div>';
  77. });
  78. // $('#' + code + '_dropdownMenu .book-list').empty();
  79. // $('#' + code + '_dropdownMenu .book-list').append(html);
  80. $(this).parents('.dropdown-menu').children('.book-list').empty();
  81. $(this).parents('.dropdown-menu').children('.book-list').append(html);
  82. }
  83. }
  84. }, 400);
  85. });
  86. function setLcShowHtml(this_status, this_tr_id, data) {
  87. if (this_status === sp_status.sqspr) {
  88. $('#process_set').find('.lc-show').html('');
  89. } else if (this_status === sp_status.gdspl) {
  90. let addhtml = '<ul class="list-unstyled">\n';
  91. if (data.length !== 0) {
  92. for(const [i, audit] of data.entries()) {
  93. addhtml += makeAudit(audit, transFormToChinese(i+1));
  94. }
  95. addhtml += '<li class="pl-3"><a href="javascript:void(0);" class="add-audit"><i class="fa fa-plus"></i> 添加流程</a></li>';
  96. } else {
  97. addhtml += makeSelectAudit(this_tr_id, '一');
  98. }
  99. addhtml += '</ul>\n';
  100. $('#process_set').find('.lc-show').html(addhtml);
  101. } else if (this_status === sp_status.gdzs) {
  102. let addhtml = '<ul class="list-unstyled">\n' +
  103. ' <li class="d-flex justify-content-start mb-3">\n' +
  104. ' <span class="col-auto">授权审批人</span>\n' +
  105. ' <span class="col-7">\n' +
  106. ' <span class="d-inline-block"></span>\n' +
  107. ' </span>\n' +
  108. ' </li>\n';
  109. addhtml += data ? makeAudit(data) : makeSelectAudit(this_tr_id);
  110. addhtml += '</ul>\n';
  111. $('#process_set').find('.lc-show').html(addhtml);
  112. }
  113. }
  114. function fisrtSetProcess() {
  115. $('#tender_rpt_table tr').eq(0).addClass('table-warning');
  116. const tr_id = parseInt($('#tender_rpt_table tr').eq(0).attr('data-id'));
  117. $('#process_set').show();
  118. makeProcess(tr_id);
  119. }
  120. // 初始化选中table
  121. if ($('#tender_rpt_table tr').length > 0) {
  122. fisrtSetProcess();
  123. }
  124. // 选中切换table
  125. $('body').on('click', '#tender_rpt_table tr', function () {
  126. if (!$(this).hasClass('table-warning')) {
  127. $('#tender_rpt_table tr').removeClass('table-warning');
  128. $(this).addClass('table-warning');
  129. const tr_id = parseInt($(this).attr('data-id'));
  130. makeProcess(tr_id);
  131. }
  132. });
  133. // 初始化审批流程
  134. function makeProcess(tr_id) {
  135. const trInfo = _.find(tenderRptList, { id: tr_id });
  136. $('#process_set').find('.card-title').text(trInfo.rpt_name);
  137. cur_uid = trInfo.uid;
  138. let html = '<div class="mr-2">上报人<b class="text-danger">*</b></div>';
  139. let divhtml = '';
  140. accountGroup.forEach((group, idx) => {
  141. let didivhtml = '';
  142. if(group) {
  143. group.groupList.forEach(item => {
  144. didivhtml += item.id !== cur_uid ? '<dd class="border-bottom p-2 mb-0 " data-id="' + item.id + '" >\n' +
  145. '<p class="mb-0 d-flex"><span class="text-primary">' + item.name + '</span><span\n' +
  146. ' class="ml-auto">' + item.mobile + '</span></p>\n' +
  147. ' <span class="text-muted">' + item.role + '</span>\n' +
  148. ' </dd>\n' : '';
  149. });
  150. divhtml += '<dt><a href="javascript: void(0);" class="acc-btn" data-groupid="' + idx + '" data-type="hide"><i class="fa fa-plus-square"></i></a> ' + group.groupName + '</dt>\n' +
  151. ' <div class="dd-content" data-toggleid="' + idx + '">\n' + didivhtml +
  152. ' </div>\n';
  153. }
  154. });
  155. if (trInfo.uid) {
  156. const userInfo = _.find(accountList, { id: trInfo.uid });
  157. html += '<div class="mr-2">'+ userInfo.name +'</div>\n' +
  158. '<div><span class="d-inline-block">\n' +
  159. ' <div class="dropdown text-right">\n' +
  160. ' <button class="btn btn-sm btn-primary dropdown-toggle" type="button" id="' + tr_id + '_dropdownMenuButton1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">\n' +
  161. ' 替换\n' +
  162. ' </button>\n' +
  163. ' <div class="dropdown-menu dropdown-menu-right" id="' + tr_id + '_dropdownMenu1" aria-labelledby="' + tr_id + '_dropdownMenuButton1" style="width:220px">\n' +
  164. ' <div class="mb-2 p-2"><input class="form-control form-control-sm gr-search"\n' +
  165. ' placeholder="姓名/手机 检索" autocomplete="off" data-trid="' + tr_id + '"></div>\n' +
  166. ' <dl class="list-unstyled book-list">\n' + divhtml +
  167. ' </dl>\n' +
  168. ' </div>\n' +
  169. ' </div>\n' +
  170. ' </span>\n' +
  171. '</div>';;
  172. } else {
  173. html +='<div><span class="d-inline-block">\n' +
  174. ' <div class="dropdown text-right">\n' +
  175. ' <button class="btn btn-outline-primary btn-sm dropdown-toggle" type="button" id="' + tr_id + '_dropdownMenuButton2" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">\n' +
  176. ' 选择上报人\n' +
  177. ' </button>\n' +
  178. ' <div class="dropdown-menu dropdown-menu-right" id="' + tr_id + '_dropdownMenu2" aria-labelledby="' + tr_id + '_dropdownMenuButton2" style="width:220px">\n' +
  179. ' <div class="mb-2 p-2"><input class="form-control form-control-sm gr-search"\n' +
  180. ' placeholder="姓名/手机 检索" autocomplete="off" data-trid="' + tr_id + '"></div>\n' +
  181. ' <dl class="list-unstyled book-list">\n' + divhtml +
  182. ' </dl>\n' +
  183. ' </div>\n' +
  184. ' </div>\n' +
  185. ' </span>\n' +
  186. '</div>';
  187. }
  188. $('#rpt_user').html(html);
  189. $('#process_set input[name="tender_process"][value="'+ trInfo.sp_status +'"]').prop('checked', true);
  190. const spt = sp_status_list[trInfo.sp_status];
  191. $('#process_set').find('.alert-warning').text(spt.name + ':' + spt.msg);
  192. const prop = {
  193. type: 'get-audits',
  194. tr_id: trInfo.id,
  195. status: trInfo.sp_status,
  196. };
  197. postData('/payment/' + tenderId + '/process/save', prop, function (data) {
  198. setLcShowHtml(trInfo.sp_status, trInfo.id, data);
  199. });
  200. }
  201. // 添加审批流程按钮逻辑
  202. $('body').on('click', '.book-list dt', function () {
  203. const idx = $(this).find('.acc-btn').attr('data-groupid');
  204. const type = $(this).find('.acc-btn').attr('data-type');
  205. if (type === 'hide') {
  206. $(this).parent().find(`div[data-toggleid="${idx}"]`).show(() => {
  207. $(this).children().find('i').removeClass('fa-plus-square').addClass('fa-minus-square-o');
  208. $(this).find('.acc-btn').attr('data-type', 'show');
  209. })
  210. } else {
  211. $(this).parent().find(`div[data-toggleid="${idx}"]`).hide(() => {
  212. $(this).children().find('i').removeClass('fa-minus-square-o').addClass('fa-plus-square');
  213. $(this).find('.acc-btn').attr('data-type', 'hide');
  214. })
  215. }
  216. return false;
  217. });
  218. // 更改审批流程状态
  219. $('#process_set .form-check input').on('change', function () {
  220. // 获取所有审批的checked值并更新
  221. const this_status = parseInt($(this).val());
  222. const this_tr_id = parseInt($('#tender_rpt_table').find('.table-warning').attr('data-id'));
  223. const spt = sp_status_list[this_status];
  224. $(this).parents('.form-group').siblings('.alert-warning').text(spt.name + ':' + spt.msg);
  225. // 拼接post json
  226. const prop = {
  227. type: 'change-status',
  228. tr_id: this_tr_id,
  229. status: this_status
  230. };
  231. postData('/payment/' + tenderId + '/process/save', prop, function (data) {
  232. const trInfo = _.find(tenderRptList, { id: this_tr_id });
  233. trInfo.sp_status = this_status;
  234. setLcShowHtml(this_status, this_tr_id, data);
  235. });
  236. });
  237. // 选中审批流里的审批人
  238. $('body').on('click', '.lc-show dl dd', function () {
  239. const id = parseInt($(this).data('id'));
  240. if (!id) return;
  241. let this_tr_id = parseInt($('#tender_rpt_table').find('.table-warning').attr('data-id'));
  242. if (!this_tr_id) this_tr_id = $(this).parents('.dropdown').attr('data-trid');
  243. const user = _.find(accountList, function (item) {
  244. return item.id === id;
  245. });
  246. const this_status = parseInt($(this).parents('.lc-show').siblings('.form-group').find('input:checked').val());
  247. if (this_status === sp_status.gdspl) {
  248. // 判断是否已存在审批人
  249. const aid_num = $(this).parents('ul').find('.remove-audit').length;
  250. for (let i = 0; i < aid_num; i++) {
  251. const aid = parseInt($(this).parents('ul').find('.remove-audit').eq(i).data('id'));
  252. if (aid === id) {
  253. toastr.warning('该审核人已存在,请勿重复添加');
  254. return;
  255. }
  256. }
  257. }
  258. const prop = {
  259. status: this_status,
  260. tr_id: this_tr_id,
  261. audit_id: id,
  262. type: 'add-audit',
  263. };
  264. const _self = $(this);
  265. postData('/payment/' + tenderId + '/process/save', prop, function (data) {
  266. if (this_status === sp_status.gdspl) {
  267. _self.parents('ul').append('<li class="pl-3"><a href="javascript:void(0);" class="add-audit"><i class="fa fa-plus"></i> 添加流程</a></li>');
  268. }
  269. _self.parents('.spr-span').html('<span class="d-inline-block"></span>\n' +
  270. '<span class="d-inline-block"><span class="badge badge-light">'+ user.name +' <span class="dropdown">\n' +
  271. ' <a href="javascript:void(0);" class="btn-sm text-danger px-1" title="移除" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><i class="fa fa-remove"></i></a>\n' +
  272. ' <div class="dropdown-menu">\n' +
  273. ' <a class="dropdown-item" href="javascript:void(0);">确认移除审批人?</a>\n' +
  274. ' <div class="dropdown-divider"></div>\n' +
  275. ' <div class="px-2 py-1 text-center">\n' +
  276. ' <button class="remove-audit btn btn-sm btn-danger" data-id="' + user.id + '">移除</button>\n' +
  277. ' <button class="btn btn-sm btn-secondary">取消</button>\n' +
  278. ' </div>\n' +
  279. ' </div>\n' +
  280. ' </span> ' +
  281. ' </span></span></span>\n');
  282. // <a href="javascript:void(0);" class="remove-audit btn-sm text-danger px-1" title="移除" data-id="'+ user.id +'"><i class="fa fa-remove"></i></a></span> </span>');
  283. });
  284. });
  285. // 选中上报人
  286. $('body').on('click', '#rpt_user dl dd', function () {
  287. const id = parseInt($(this).data('id'));
  288. if (!id) return;
  289. console.log(id);
  290. let this_tr_id = parseInt($('#tender_rpt_table').find('.table-warning').attr('data-id'));
  291. if (!this_tr_id) this_tr_id = $(this).parents('.dropdown').attr('data-trid');
  292. const user = _.find(accountList, function (item) {
  293. return item.id === id;
  294. });
  295. if (!user) toastr.error('用户列表不存在此人');
  296. const prop = {
  297. tr_id: this_tr_id,
  298. uid: id,
  299. type: 'update-report',
  300. };
  301. postData('/payment/' + tenderId + '/process/save', prop, function (result) {
  302. tenderRptList = result.list;
  303. if (result.updateRows) {
  304. toastr.warning('上报人不能同时作为审批人,审批流已移除 ' + user.name);
  305. }
  306. $('#tender_rpt_table tr[data-id="'+ this_tr_id +'"]').children('td').eq(2).html(user.name);
  307. makeProcess(this_tr_id);
  308. });
  309. //
  310. // const this_status = parseInt($(this).parents('.lc-show').siblings('.form-group').find('input:checked').val());
  311. // if (this_status === sp_status.gdspl) {
  312. // // 判断是否已存在审批人
  313. // const aid_num = $(this).parents('ul').find('.remove-audit').length;
  314. // for (let i = 0; i < aid_num; i++) {
  315. // const aid = parseInt($(this).parents('ul').find('.remove-audit').eq(i).data('id'));
  316. // if (aid === id) {
  317. // toastr.warning('该审核人已存在,请勿重复添加');
  318. // return;
  319. // }
  320. // }
  321. //
  322. // }
  323. // const prop = {
  324. // status: this_status,
  325. // tr_id: this_tr_id,
  326. // audit_id: id,
  327. // type: 'add-audit',
  328. // };
  329. // const _self = $(this);
  330. // postData('/payment/' + tenderId + '/process/save', prop, function (data) {
  331. // if (this_status === sp_status.gdspl) {
  332. // _self.parents('ul').append('<li class="pl-3"><a href="javascript:void(0);" class="add-audit"><i class="fa fa-plus"></i> 添加流程</a></li>');
  333. // }
  334. // _self.parents('.spr-span').html('<span class="d-inline-block"></span>\n' +
  335. // '<span class="d-inline-block"><span class="badge badge-light">'+ user.name +' <span class="dropdown">\n' +
  336. // ' <a href="javascript:void(0);" class="btn-sm text-danger px-1" title="移除" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><i class="fa fa-remove"></i></a>\n' +
  337. // ' <div class="dropdown-menu">\n' +
  338. // ' <a class="dropdown-item" href="javascript:void(0);">确认移除审批人?</a>\n' +
  339. // ' <div class="dropdown-divider"></div>\n' +
  340. // ' <div class="px-2 py-1 text-center">\n' +
  341. // ' <button class="remove-audit btn btn-sm btn-danger" data-id="' + user.id + '">移除</button>\n' +
  342. // ' <button class="btn btn-sm btn-secondary">取消</button>\n' +
  343. // ' </div>\n' +
  344. // ' </div>\n' +
  345. // ' </span> ' +
  346. // ' </span></span></span>\n');
  347. // // <a href="javascript:void(0);" class="remove-audit btn-sm text-danger px-1" title="移除" data-id="'+ user.id +'"><i class="fa fa-remove"></i></a></span> </span>');
  348. // });
  349. });
  350. // 移除审批人
  351. $('body').on('click', '.remove-audit', function () {
  352. const id = parseInt($(this).data('id'));
  353. const this_status = parseInt($(this).parents('.lc-show').siblings('.form-group').find('input:checked').val());
  354. const this_tr_id = parseInt($('#tender_rpt_table').find('.table-warning').attr('data-id'));
  355. const prop = {
  356. status: this_status,
  357. tr_id: this_tr_id,
  358. audit_id: id,
  359. type: 'del-audit',
  360. };
  361. const _self = $(this);
  362. postData('/payment/' + tenderId + '/process/save', prop, function (data) {
  363. if (this_status === sp_status.gdspl) {
  364. const _selflc = _self.parents('.lc-show');
  365. _self.parents('li').remove();
  366. const aid_num = parseInt(_selflc.children('ul').find('li.d-flex').length);
  367. if (aid_num === 0) {
  368. let addhtml = '<ul class="list-unstyled">\n';
  369. addhtml += makeSelectAudit(this_tr_id, '一');
  370. addhtml += '</ul>\n';
  371. _selflc.html(addhtml);
  372. } else {
  373. for (let i = 0; i < aid_num; i++) {
  374. _selflc.find('li.d-flex').eq(i).find('.col-auto').text(transFormToChinese(i+1) + '审');
  375. }
  376. }
  377. } else if (this_status === sp_status.gdzs) {
  378. let addhtml = '<ul class="list-unstyled">\n' +
  379. ' <li class="d-flex justify-content-start mb-3">\n' +
  380. ' <span class="col-auto">授权审批人</span>\n' +
  381. ' <span class="col-7">\n' +
  382. ' <span class="d-inline-block"></span>\n' +
  383. ' </span>\n' +
  384. ' </li>\n';
  385. addhtml += makeSelectAudit(this_tr_id);
  386. addhtml += '</ul>\n';
  387. _self.parents('.lc-show').html(addhtml);
  388. }
  389. })
  390. });
  391. // 固定审批流-添加流程
  392. $('body').on('click', '.add-audit', function () {
  393. const num = $(this).parents('ul').children('li').length;
  394. const this_tr_id = parseInt($('#tender_rpt_table').find('.table-warning').attr('data-id'));
  395. const addhtml = makeSelectAudit(this_tr_id, transFormToChinese(num));
  396. $(this).parents('ul').append(addhtml);
  397. $(this).parents('li').remove();
  398. });
  399. // 审批流程-审批人html 生成
  400. function makeAudit(audit, i = '终') {
  401. return '<li class="d-flex justify-content-start mb-3">\n' +
  402. ' <span class="col-auto">'+ i +'审</span>\n' +
  403. ' <span class="col-7 spr-span">\n' +
  404. ' <span class="d-inline-block"></span>\n' +
  405. ' <span class="d-inline-block"><span class="badge badge-light">'+ audit.name +' <span class="dropdown">\n' +
  406. ' <a href="javascript:void(0);" class="btn-sm text-danger px-1" title="移除" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><i class="fa fa-remove"></i></a>\n' +
  407. ' <div class="dropdown-menu">\n' +
  408. ' <a class="dropdown-item" href="javascript:void(0);">确认移除审批人?</a>\n' +
  409. ' <div class="dropdown-divider"></div>\n' +
  410. ' <div class="px-2 py-1 text-center">\n' +
  411. ' <button class="remove-audit btn btn-sm btn-danger" data-id="' + audit.audit_id + '">移除</button>\n' +
  412. ' <button class="btn btn-sm btn-secondary">取消</button>\n' +
  413. ' </div>\n' +
  414. ' </div>\n' +
  415. ' </span> ' +
  416. // '<a href="javascript:void(0);" class="remove-audit btn-sm text-danger px-1" title="移除" data-id="'+ audit.audit_id +'"><i class="fa fa-remove"></i></a></span> </span>\n' +
  417. ' </span></span></span>\n' +
  418. ' </li>';
  419. }
  420. // 审批流程-选择审批人html 生成
  421. function makeSelectAudit(tr_id, i = '终') {
  422. let divhtml = '';
  423. accountGroup.forEach((group, idx) => {
  424. let didivhtml = '';
  425. if(group) {
  426. group.groupList.forEach(item => {
  427. didivhtml += item.id !== cur_uid ? '<dd class="border-bottom p-2 mb-0 " data-id="' + item.id + '" >\n' +
  428. '<p class="mb-0 d-flex"><span class="text-primary">' + item.name + '</span><span\n' +
  429. ' class="ml-auto">' + item.mobile + '</span></p>\n' +
  430. ' <span class="text-muted">' + item.role + '</span>\n' +
  431. ' </dd>\n' : '';
  432. });
  433. divhtml += '<dt><a href="javascript: void(0);" class="acc-btn" data-groupid="' + idx + '" data-type="hide"><i class="fa fa-plus-square"></i></a> ' + group.groupName + '</dt>\n' +
  434. ' <div class="dd-content" data-toggleid="' + idx + '">\n' + didivhtml +
  435. ' </div>\n';
  436. }
  437. });
  438. let html = '<li class="d-flex justify-content-start mb-3">\n' +
  439. ' <span class="col-auto">' + i + '审</span>\n' +
  440. ' <span class="col-7 spr-span">\n' +
  441. ' <span class="d-inline-block">\n' +
  442. ' <div class="dropdown text-right">\n' +
  443. ' <button class="btn btn-outline-primary btn-sm dropdown-toggle" type="button" id="' + tr_id + '_dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">\n' +
  444. ' 选择审批人\n' +
  445. ' </button>\n' +
  446. ' <div class="dropdown-menu dropdown-menu-right" id="' + tr_id + '_dropdownMenu" aria-labelledby="' + tr_id + '_dropdownMenuButton" style="width:220px">\n' +
  447. ' <div class="mb-2 p-2"><input class="form-control form-control-sm gr-search"\n' +
  448. ' placeholder="姓名/手机 检索" autocomplete="off" data-trid="' + tr_id + '"></div>\n' +
  449. ' <dl class="list-unstyled book-list">\n' + divhtml +
  450. ' </dl>\n' +
  451. ' </div>\n' +
  452. ' </div>\n' +
  453. ' </span>\n' +
  454. ' </span>\n' +
  455. ' </li>';
  456. return html;
  457. };
  458. $('#add-rpt').on('show.bs.modal', function () {
  459. $('#rpt_table').find('input:checked:not(:disabled)').prop('checked', false);
  460. $('#rpt_table').find('input:not(:disabled)').each(function () {
  461. if (_.findIndex(tenderRptList, { rpt_id: parseInt($(this).val()) }) !== -1) {
  462. $(this).prop('checked', true);
  463. }
  464. });
  465. });
  466. $('#rpt_table input').on('click', function () {
  467. if ($(this).is(':checked') && parseInt($(this).val()) === -1) {
  468. $(this).prop('checked', false);
  469. const index = $("#rpt_table input").index(this);
  470. // 循环选中当前子项值
  471. checkedRptProjectList(rptProjectList[index].items);
  472. }
  473. });
  474. function checkedRptProjectList(items) {
  475. if (items && items.length > 0) {
  476. for (const item of items) {
  477. if (item.ID !== -1 && item.items === null) {
  478. console.log(item);
  479. $('#rpt_table input').eq(item.index).prop('checked', true);
  480. } else {
  481. checkedRptProjectList(item.items);
  482. }
  483. }
  484. }
  485. }
  486. });