payment_process.js 30 KB

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