payment_process.js 30 KB

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