shenpi.js 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560
  1. 'use strict';
  2. /**
  3. *
  4. *
  5. * @author Ellisran
  6. * @date 2020/10/09
  7. * @version
  8. */
  9. const tenderTree = [];
  10. let parentId = 0;
  11. // 查询方法
  12. function findNode (key, value, arr) {
  13. for (const a of arr) {
  14. if (a[key] && a[key] === value) {
  15. return a;
  16. }
  17. }
  18. }
  19. // 初始化TenderTree数据
  20. function initTenderTree () {
  21. const levelCategory = category.filter(function (c) {
  22. return c.level && c.level > 0;
  23. });
  24. function findCategoryNode(cid, value, array) {
  25. for (const a of array) {
  26. if (a.cid === cid && a.vid === value) {
  27. return a;
  28. }
  29. }
  30. }
  31. function getCategoryNode(category, value, parent, i = null) {
  32. const array = parent ? parent.children : tenderTree;
  33. let cate = findCategoryNode(category.id, value, array);
  34. if (!cate) {
  35. const cateValue = findNode('id', value, category.value);
  36. if (!cateValue) return null;
  37. cate = {
  38. cid: category.id,
  39. vid: value,
  40. name: cateValue.value,
  41. children: [],
  42. level: i ? i : category.level,
  43. sort_id: ++parentId,
  44. };
  45. array.push(cate);
  46. }
  47. return cate;
  48. }
  49. function loadTenderCategory (tender) {
  50. let tenderCategory = null;
  51. for (const [index,lc] of levelCategory.entries()) {
  52. const tenderCate = findNode('cid', lc.id, tender.category);
  53. if (tenderCate) {
  54. tenderCategory = getCategoryNode(lc, tenderCate.value, tenderCategory);
  55. } else {
  56. if (index === 0 && tender.category) {
  57. for (const [i,c] of tender.category.entries()) {
  58. const cate = findNode('id', c.cid, category);
  59. tenderCategory = getCategoryNode(cate, c.value, tenderCategory, i+1);
  60. }
  61. }
  62. return tenderCategory;
  63. }
  64. }
  65. return tenderCategory;
  66. }
  67. function calculateTender(tender) {
  68. if (tender.lastStage) {
  69. tender.gather_tp = ZhCalc.add(tender.lastStage.contract_tp, tender.lastStage.qc_tp);
  70. tender.end_contract_tp = ZhCalc.add(tender.lastStage.pre_contract_tp, tender.lastStage.contract_tp);
  71. tender.end_qc_tp = ZhCalc.add(tender.lastStage.pre_qc_tp, tender.lastStage.qc_tp);
  72. tender.end_gather_tp = ZhCalc.add(tender.end_contract_tp, tender.end_qc_tp);
  73. tender.pre_gather_tp = ZhCalc.add(tender.lastStage.pre_contract_tp, tender.lastStage.pre_qc_tp);
  74. tender.yf_tp = ZhCalc.add(tender.lastStage.yf_tp);
  75. tender.end_yf_tp = ZhCalc.add(tender.lastStage.pre_yf_tp, tender.yf_tp);
  76. }
  77. }
  78. tenderTree.splice(0, tenderTree.length);
  79. for (const t of tenders) {
  80. calculateTender(t);
  81. t.valid = true;
  82. delete t.level;
  83. if (t.category && levelCategory.length > 0) {
  84. const parent = loadTenderCategory(t);
  85. if (parent) {
  86. t.level = parent.level + 1;
  87. parent.children.push(t);
  88. } else {
  89. tenderTree.push(t);
  90. }
  91. } else {
  92. tenderTree.push(t);
  93. }
  94. }
  95. sortTenderTree();
  96. }
  97. function recursiveGetTenderNodeHtml (node, arr, pid, this_code, this_status, aidList = []) {
  98. const html = [];
  99. html.push('<tr pid="' + pid + '">');
  100. // 名称
  101. html.push('<td class="in-' + node.level + '">');
  102. if (node.cid) {
  103. html.push('<i class="fa fa-folder-o"></i> ', node.name);
  104. } else {
  105. html.push('<span class="text-muted mr-2">');
  106. html.push(arr.indexOf(node) === arr.length - 1 ? '└' : '├');
  107. html.push('</span>');
  108. //html.push('<a href="/tender/' + node.id + '">', node[c.field], '</a>');
  109. html.push('<a href="javascript: void(0)" id="' + node.id + '">', node.name, '</a>');
  110. }
  111. html.push('</td>');
  112. // 创建人
  113. // html.push('<td>', sp_status_list[node.shenpiInfo[shenpi_type]].name, '</td>');
  114. html.push('<td>');
  115. if (!node.cid) {
  116. let auditList = [];
  117. let tender_status = 1;
  118. if(cur_tenderid === node.id) {
  119. html.push(sp_status_list[this_status].name);
  120. auditList = aidList;
  121. tender_status = this_status;
  122. } else {
  123. html.push(sp_status_list[node.shenpiInfo[this_code]].name);
  124. auditList = node.shenpiauditList[this_code];
  125. tender_status = node.shenpiInfo[this_code];
  126. }
  127. if(tender_status === sp_status.gdspl || tender_status === sp_status.gdzs) {
  128. const nameList = [];
  129. if(auditList) {
  130. for (const uid of auditList) {
  131. const user = _.find(accountList, { id: uid });
  132. nameList.push(user.name);
  133. }
  134. }
  135. html.push('<i class="fa fa-question-circle text-primary" data-container="body" data-toggle="tooltip" data-placement="bottom" ' +
  136. 'data-original-title="'+ (nameList.length > 0 ? nameList.join('-') : '') +'"></i>');
  137. }
  138. }
  139. html.push('</td>');
  140. html.push('<td>');
  141. if (!node.cid) {
  142. html.push('<input data-tid="'+ node.id +'" type="checkbox"'+ (cur_tenderid === node.id ? ' checked disabled' : '') +'>');
  143. }
  144. html.push('</td>');
  145. html.push('</tr>');
  146. if (node.children) {
  147. for (const c of node.children) {
  148. html.push(recursiveGetTenderNodeHtml(c, node.children, node.sort_id, this_code, this_status, aidList));
  149. }
  150. }
  151. return html.join('');
  152. }
  153. // 根据TenderTree数据获取Html代码
  154. function getTenderTreeHtml (this_code, this_status, aidList = []) {
  155. if (tenderTree.length > 0) {
  156. const html = [];
  157. html.push('<table class="table table-hover table-bordered">');
  158. html.push('<thead>', '<tr>');
  159. html.push('<th>名称</th>');
  160. html.push('<th width="100">审批流程</th>');
  161. html.push('<th width="40">选择</th>');
  162. html.push('</tr>', '</thead>');
  163. parentId = 0;
  164. for (const t of tenderTree) {
  165. html.push(recursiveGetTenderNodeHtml(t, tenderTree, '', this_code, this_status, aidList));
  166. }
  167. html.push('</table>');
  168. return html.join('');
  169. } else {
  170. return EmptyTenderHtml.join('');
  171. }
  172. }
  173. function getShenpiHtml (this_code) {
  174. const html = [];
  175. html.push('<table class="table table-hover table-bordered">');
  176. html.push('<thead>', '<tr>');
  177. html.push('<th>名称</th>');
  178. html.push('<th width="100">审批流程</th>');
  179. html.push('<th width="40">选择</th>');
  180. html.push('</tr>', '</thead>');
  181. for (const sp of sp_lc) {
  182. html.push('<tr>');
  183. html.push('<td>', sp.name, '</td>');
  184. html.push('<td>');
  185. const this_status = parseInt($('.' + sp.code + '_div').children('.lc-show').siblings('.form-group').find('input:checked').val());
  186. html.push(sp_status_list[this_status].name);
  187. if(this_status !== sp_status.sqspr) {
  188. const nameList = [];
  189. const aid_num = $('.' + sp.code + '_div').children('.lc-show').children('ul').find('.remove-audit').length;
  190. const aidList = [];
  191. for (let i = 0; i < aid_num; i++) {
  192. const aid = parseInt($('.' + sp.code + '_div').children('.lc-show').children('ul').find('.remove-audit').eq(i).data('id'));
  193. aidList.push(aid);
  194. }
  195. if(aidList.length > 0) {
  196. for (const uid of aidList) {
  197. const user = _.find(accountList, { id: uid });
  198. nameList.push(user.name);
  199. }
  200. }
  201. html.push('<i class="fa fa-question-circle text-primary" data-container="body" data-toggle="tooltip" data-placement="bottom" ' +
  202. 'data-original-title="'+ (nameList.length > 0 ? nameList.join('-') : '') +'"></i>');
  203. }
  204. html.push('</td>');
  205. html.push('<td>', this_code !== sp.code ? '<input type="checkbox" data-code="'+ sp.code +'">' : '', '</td>');
  206. html.push('</tr>');
  207. }
  208. html.push('</table>');
  209. return html.join('');
  210. }
  211. $(document).ready(function () {
  212. let timer = null;
  213. let oldSearchVal = null;
  214. const needYB = ['ledger', 'revise', 'change'];
  215. $('body').on('input propertychange', '.gr-search', function(e) {
  216. oldSearchVal = e.target.value;
  217. timer && clearTimeout(timer);
  218. timer = setTimeout(() => {
  219. const newVal = $(this).val();
  220. const code = $(this).attr('data-code');
  221. let html = '';
  222. if (newVal && newVal === oldSearchVal) {
  223. accountList.filter(item => item && (item.id !== cur_uid || (item.id === cur_uid && needYB.indexOf(code) !== -1)) && (item.name.indexOf(newVal) !== -1 || (item.mobile && item.mobile.indexOf(newVal) !== -1))).forEach(item => {
  224. html += `<dd class="border-bottom p-2 mb-0 " data-id="${item.id}" >
  225. <p class="mb-0 d-flex"><span class="text-primary">${item.name}</span><span
  226. class="ml-auto">${item.mobile || ''}</span></p>
  227. <span class="text-muted">${item.role || ''}</span>
  228. </dd>`
  229. });
  230. $('#' + code + '_dropdownMenu .book-list').empty();
  231. $('#' + code + '_dropdownMenu .book-list').append(html);
  232. } else {
  233. if (!$('#' + code + '_dropdownMenu .acc-btn').length) {
  234. accountGroup.forEach((group, idx) => {
  235. if (!group) return;
  236. html += `<dt><a href="javascript: void(0);" class="acc-btn" data-groupid="${idx}" data-type="hide"><i class="fa fa-plus-square"></i>
  237. </a> ${group.groupName}</dt>
  238. <div class="dd-content" data-toggleid="${idx}">`;
  239. group.groupList.forEach(item => {
  240. if ((item.id !== cur_uid || (item.id === cur_uid && needYB.indexOf(code) !== -1))) {
  241. html += `<dd class="border-bottom p-2 mb-0 " data-id="${item.id}" >
  242. <p class="mb-0 d-flex"><span class="text-primary">${item.name}</span><span
  243. class="ml-auto">${item.mobile || ''}</span></p>
  244. <span class="text-muted">${item.role || ''}</span>
  245. </dd>`;
  246. }
  247. });
  248. html += '</div>';
  249. });
  250. $('#' + code + '_dropdownMenu .book-list').empty();
  251. $('#' + code + '_dropdownMenu .book-list').append(html);
  252. }
  253. }
  254. }, 400);
  255. });
  256. // 添加审批流程按钮逻辑
  257. $('body').on('click', '.book-list dt', function () {
  258. const idx = $(this).find('.acc-btn').attr('data-groupid');
  259. const type = $(this).find('.acc-btn').attr('data-type');
  260. if (type === 'hide') {
  261. $(this).parent().find(`div[data-toggleid="${idx}"]`).show(() => {
  262. $(this).children().find('i').removeClass('fa-plus-square').addClass('fa-minus-square-o');
  263. $(this).find('.acc-btn').attr('data-type', 'show');
  264. })
  265. } else {
  266. $(this).parent().find(`div[data-toggleid="${idx}"]`).hide(() => {
  267. $(this).children().find('i').removeClass('fa-minus-square-o').addClass('fa-plus-square');
  268. $(this).find('.acc-btn').attr('data-type', 'hide');
  269. })
  270. }
  271. return false;
  272. });
  273. // 更改审批流程状态
  274. $('.form-check input').on('change', function () {
  275. // 获取所有审批的checked值并更新
  276. const this_status = parseInt($(this).val());
  277. const this_code = $(this).data('code');
  278. const spt = sp_status_list[this_status];
  279. $(this).parents('.form-group').siblings('.alert-warning').text(spt.name + ':' + spt.msg);
  280. // 拼接post json
  281. const prop = {
  282. code: this_code,
  283. status: this_status
  284. };
  285. const _self = $(this);
  286. postData('/tender/' + cur_tenderid + '/shenpi/save', prop, function (data) {
  287. if (this_status === sp_status.sqspr) {
  288. _self.parents('.form-group').siblings('.lc-show').html('');
  289. } else if (this_status === sp_status.gdspl) {
  290. let addhtml = '<ul class="list-unstyled">\n';
  291. if (data.length !== 0) {
  292. for(const [i, audit] of data.entries()) {
  293. addhtml += makeAudit(audit, transFormToChinese(i+1));
  294. }
  295. addhtml += '<li class="pl-3"><a href="javascript:void(0);" class="add-audit"><i class="fa fa-plus"></i> 添加流程</a></li>';
  296. } else {
  297. addhtml += makeSelectAudit(this_code, '一');
  298. }
  299. addhtml += '</ul>\n';
  300. _self.parents('.form-group').siblings('.lc-show').html(addhtml);
  301. } else if (this_status === sp_status.gdzs) {
  302. let addhtml = '<ul class="list-unstyled">\n' +
  303. ' <li class="d-flex justify-content-start mb-3">\n' +
  304. ' <span class="col-auto">授权审批人</span>\n' +
  305. ' <span class="col-7">\n' +
  306. ' <span class="d-inline-block"></span>\n' +
  307. ' </span>\n' +
  308. ' </li>\n';
  309. addhtml += data ? makeAudit(data) : makeSelectAudit(this_code);
  310. addhtml += '</ul>\n';
  311. _self.parents('.form-group').siblings('.lc-show').html(addhtml);
  312. }
  313. });
  314. });
  315. // 选中审批人
  316. $('body').on('click', 'dl dd', function () {
  317. const id = parseInt($(this).data('id'));
  318. if (id) {
  319. const user = _.find(accountList, function (item) {
  320. return item.id === id;
  321. });
  322. const this_status = parseInt($(this).parents('.lc-show').siblings('.form-group').find('input:checked').val());
  323. const this_code = $(this).parents('.lc-show').siblings('.form-group').find('input:checked').data('code');
  324. if (this_status === sp_status.gdspl) {
  325. // 判断是否已存在审批人
  326. const aid_num = $(this).parents('ul').find('.remove-audit').length;
  327. for (let i = 0; i < aid_num; i++) {
  328. const aid = parseInt($(this).parents('ul').find('.remove-audit').eq(i).data('id'));
  329. if (aid === id) {
  330. toastr.warning('该审核人已存在,请勿重复添加');
  331. return;
  332. }
  333. }
  334. }
  335. const prop = {
  336. status: this_status,
  337. code: sp_type[this_code],
  338. audit_id: id,
  339. type: 'add',
  340. };
  341. const _self = $(this);
  342. postData('/tender/' + cur_tenderid + '/shenpi/audit/save', prop, function (data) {
  343. if (this_status === sp_status.gdspl) {
  344. _self.parents('ul').append('<li class="pl-3"><a href="javascript:void(0);" class="add-audit"><i class="fa fa-plus"></i> 添加流程</a></li>');
  345. }
  346. _self.parents('.spr-span').html('<span class="d-inline-block"></span>\n' +
  347. '<span class="d-inline-block"><span class="badge badge-light">'+ user.name +' <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. // 移除审批人
  352. $('body').on('click', '.remove-audit', function () {
  353. const id = parseInt($(this).data('id'));
  354. const this_status = parseInt($(this).parents('.lc-show').siblings('.form-group').find('input:checked').val());
  355. const this_code = $(this).parents('.lc-show').siblings('.form-group').find('input:checked').data('code');
  356. const prop = {
  357. status: this_status,
  358. code: sp_type[this_code],
  359. audit_id: id,
  360. type: 'del',
  361. };
  362. const _self = $(this);
  363. postData('/tender/' + cur_tenderid + '/shenpi/audit/save', prop, function (data) {
  364. if (this_status === sp_status.gdspl) {
  365. const _selflc = _self.parents('.lc-show');
  366. _self.parents('li').remove();
  367. const aid_num = parseInt(_selflc.children('ul').find('li.d-flex').length);
  368. if (aid_num === 0) {
  369. let addhtml = '<ul class="list-unstyled">\n';
  370. addhtml += makeSelectAudit(this_code, '一');
  371. addhtml += '</ul>\n';
  372. _selflc.html(addhtml);
  373. } else {
  374. for (let i = 0; i < aid_num; i++) {
  375. _selflc.find('li.d-flex').eq(i).find('.col-auto').text(transFormToChinese(i+1) + '审');
  376. }
  377. }
  378. } else if (this_status === sp_status.gdzs) {
  379. let addhtml = '<ul class="list-unstyled">\n' +
  380. ' <li class="d-flex justify-content-start mb-3">\n' +
  381. ' <span class="col-auto">授权审批人</span>\n' +
  382. ' <span class="col-7">\n' +
  383. ' <span class="d-inline-block"></span>\n' +
  384. ' </span>\n' +
  385. ' </li>\n';
  386. addhtml += makeSelectAudit(this_code);
  387. addhtml += '</ul>\n';
  388. _self.parents('.lc-show').html(addhtml);
  389. }
  390. })
  391. });
  392. // 固定审批流-添加流程
  393. $('body').on('click', '.add-audit', function () {
  394. const num = $(this).parents('ul').children('li').length;
  395. const this_code = $(this).parents('.lc-show').siblings('.form-group').find('input:checked').data('code');
  396. const addhtml = makeSelectAudit(this_code, transFormToChinese(num));
  397. $(this).parents('ul').append(addhtml);
  398. $(this).parents('li').remove();
  399. });
  400. // 审批流程-审批人html 生成
  401. function makeAudit(audit, i = '终') {
  402. return '<li class="d-flex justify-content-start mb-3">\n' +
  403. ' <span class="col-auto">'+ i +'审</span>\n' +
  404. ' <span class="col-7 spr-span">\n' +
  405. ' <span class="d-inline-block"></span>\n' +
  406. ' <span class="d-inline-block"><span class="badge badge-light">'+ audit.name +' <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' +
  407. ' </span>\n' +
  408. ' </li>';
  409. }
  410. // 审批流程-选择审批人html 生成
  411. function makeSelectAudit(code, i = '终') {
  412. let divhtml = '';
  413. accountGroup.forEach((group, idx) => {
  414. let didivhtml = '';
  415. if(group) {
  416. group.groupList.forEach(item => {
  417. didivhtml += (item.id !== cur_uid || (item.id === cur_uid && needYB.indexOf(code) !== -1)) ? '<dd class="border-bottom p-2 mb-0 " data-id="' + item.id + '" >\n' +
  418. '<p class="mb-0 d-flex"><span class="text-primary">' + item.name + '</span><span\n' +
  419. ' class="ml-auto">' + item.mobile + '</span></p>\n' +
  420. ' <span class="text-muted">' + item.role + '</span>\n' +
  421. ' </dd>\n' : '';
  422. });
  423. 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' +
  424. ' <div class="dd-content" data-toggleid="' + idx + '">\n' + didivhtml +
  425. ' </div>\n';
  426. }
  427. });
  428. let html = '<li class="d-flex justify-content-start mb-3">\n' +
  429. ' <span class="col-auto">' + i + '审</span>\n' +
  430. ' <span class="col-7 spr-span">\n' +
  431. ' <span class="d-inline-block">\n' +
  432. ' <div class="dropdown text-right">\n' +
  433. ' <button class="btn btn-outline-primary btn-sm dropdown-toggle" type="button" id="' + code + '_dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">\n' +
  434. ' 选择审批人\n' +
  435. ' </button>\n' +
  436. ' <div class="dropdown-menu dropdown-menu-right" id="' + code + '_dropdownMenu" aria-labelledby="' + code + '_dropdownMenuButton" style="width:220px">\n' +
  437. ' <div class="mb-2 p-2"><input class="form-control form-control-sm gr-search"\n' +
  438. ' placeholder="姓名/手机 检索" autocomplete="off" data-code="' + code + '"></div>\n' +
  439. ' <dl class="list-unstyled book-list">\n' + divhtml +
  440. ' </dl>\n' +
  441. ' </div>\n' +
  442. ' </div>\n' +
  443. ' </span>\n' +
  444. ' </span>\n' +
  445. ' </li>';
  446. return html;
  447. }
  448. initTenderTree();
  449. $('.set-otherTender').on('click', function () {
  450. const this_code = $(this).data('code');
  451. const this_status = parseInt($(this).siblings('.lc-show').siblings('.form-group').find('input:checked').val());
  452. const aid_num = $(this).siblings('.lc-show').children('ul').find('.remove-audit').length;
  453. const aidList = [];
  454. for (let i = 0; i < aid_num; i++) {
  455. const aid = parseInt($(this).siblings('.lc-show').children('ul').find('.remove-audit').eq(i).data('id'));
  456. aidList.push(aid);
  457. }
  458. const html = getTenderTreeHtml(this_code, this_status, aidList);
  459. $('#shenpi-name').text($(this).data('name'));
  460. $('#shenpi_code').val(this_code);
  461. $('#shenpi_status').val(this_status);
  462. $('#shenpi_auditors').val(aidList.join(','));
  463. $('#tender-list').html(html);
  464. setTimeout(function () { $("#tender-list [data-toggle='tooltip']").tooltip(); },800);
  465. });
  466. $('#save-other-tender').click(function () {
  467. $(this).attr('disabled', true);
  468. const num = $('#tender-list input:checked').length;
  469. if (num < 2) {
  470. toastr.warning('请选择需要设置审批同步的标段');
  471. return;
  472. }
  473. const data = {
  474. type: 'copy2ot',
  475. status: parseInt($('#shenpi_status').val()),
  476. code: $('#shenpi_code').val(),
  477. };
  478. if(data.status !== shenpi_status.gdspl) {
  479. data.aidList = $('#shenpi_auditors').val();
  480. }
  481. // 获取已选中的标段
  482. const tenderList = [];
  483. for (let i = 0; i < num; i++) {
  484. const tid = parseInt($('#tender-list input:checked').eq(i).data('tid'));
  485. if (tid !== cur_tenderid) {
  486. tenderList.push(tid);
  487. }
  488. }
  489. data.tidList = tenderList.join(',');
  490. postData('/tender/' + cur_tenderid + '/shenpi/audit/save', data, function () {
  491. toastr.success('设置成功');
  492. setTimeout(function () {
  493. window.location.reload();
  494. }, 1000)
  495. })
  496. });
  497. $('.set-otherShenpi').on('click', function () {
  498. const this_code = $(this).data('code');
  499. const this_status = parseInt($(this).siblings('.lc-show').siblings('.form-group').find('input:checked').val());
  500. const aid_num = $(this).siblings('.lc-show').children('ul').find('.remove-audit').length;
  501. const aidList = [];
  502. for (let i = 0; i < aid_num; i++) {
  503. const aid = parseInt($(this).siblings('.lc-show').children('ul').find('.remove-audit').eq(i).data('id'));
  504. aidList.push(aid);
  505. }
  506. const html = getShenpiHtml(this_code);
  507. $('#shenpi-name2').text($(this).data('name'));
  508. $('#shenpi_code2').val(this_code);
  509. $('#shenpi_status2').val(this_status);
  510. $('#shenpi_auditors2').val(aidList.join(','));
  511. $('#shenpi-list').html(html);
  512. setTimeout(function () { $("#shenpi-list [data-toggle='tooltip']").tooltip(); },800);
  513. });
  514. $('#save-other-shenpi').click(function () {
  515. $(this).attr('disabled', true);
  516. const num = $('#shenpi-list input:checked').length;
  517. if (num < 1) {
  518. toastr.warning('请选择需要设置审批同步的流程');
  519. return;
  520. }
  521. const data = {
  522. type: 'copy2os',
  523. status: parseInt($('#shenpi_status2').val()),
  524. code: $('#shenpi_code2').val(),
  525. };
  526. if(data.status !== shenpi_status.gdspl) {
  527. data.aidList = $('#shenpi_auditors2').val();
  528. }
  529. // 获取已选中的标段
  530. const shenpiList = [];
  531. for (let i = 0; i < num; i++) {
  532. const code = $('#shenpi-list input:checked').eq(i).data('code');
  533. shenpiList.push(code);
  534. }
  535. data.shenpiList = shenpiList.join(',');
  536. postData('/tender/' + cur_tenderid + '/shenpi/audit/save', data, function () {
  537. toastr.success('设置成功');
  538. setTimeout(function () {
  539. window.location.reload();
  540. }, 1000)
  541. })
  542. });
  543. });