shenpi.js 27 KB

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