shenpi.js 27 KB

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