shenpi.js 27 KB

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