shenpi.js 55 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072
  1. 'use strict';
  2. /**
  3. *
  4. *
  5. * @author Ellisran
  6. * @date 2020/10/09
  7. * @version
  8. */
  9. // 冲突解决,要把这里丢tenderTree改成tenderTree2
  10. const tenderTree2 = [];
  11. let parentId2 = 0;
  12. let selects;
  13. let auditUtils;
  14. const needYB = ['advance', 'ledger', 'revise', 'change', 'audit-ass'];
  15. // 查询方法
  16. function findNode2 (key, value, arr) {
  17. for (const a of arr) {
  18. if (a[key] && a[key] === value) {
  19. return a;
  20. }
  21. }
  22. }
  23. // 分类数据排序
  24. function sortCategory2() {
  25. category.sort(function (a, b) {
  26. return a.level ? (b.level ? a.level - b.level : -1) : a.id - b.id;
  27. });
  28. }
  29. // 初始化TenderTree数据
  30. function initTenderTree2 () {
  31. const levelCategory = category.filter(function (c) {
  32. return c.level && c.level > 0;
  33. });
  34. function findCategoryNode2(cid, value, array) {
  35. for (const a of array) {
  36. if (a.cid === cid && a.vid === value) {
  37. return a;
  38. }
  39. }
  40. }
  41. function getCategoryNode2(category, value, parent, i = null) {
  42. const array = parent ? parent.children : tenderTree2;
  43. let cate = findCategoryNode2(category.id, value, array);
  44. if (!cate) {
  45. const cateValue = findNode2('id', value, category.value);
  46. if (!cateValue) return null;
  47. cate = {
  48. cid: category.id,
  49. vid: value,
  50. name: cateValue.value,
  51. children: [],
  52. level: i ? i : category.level,
  53. sort_id: ++parentId2,
  54. sort: cateValue.sort,
  55. };
  56. array.push(cate);
  57. }
  58. return cate;
  59. }
  60. function loadTenderCategory2 (tender) {
  61. let tenderCategory = null;
  62. for (const [index,lc] of levelCategory.entries()) {
  63. const tenderCate = findNode2('cid', lc.id, tender.category);
  64. if (tenderCate) {
  65. tenderCategory = getCategoryNode2(lc, tenderCate.value, tenderCategory);
  66. } else {
  67. if (index === 0 && tender.category) {
  68. for (const [i,c] of tender.category.entries()) {
  69. const cate = findNode2('id', c.cid, category);
  70. if (cate) tenderCategory = getCategoryNode2(cate, c.value, tenderCategory, i+1);
  71. }
  72. }
  73. return tenderCategory;
  74. }
  75. }
  76. return tenderCategory;
  77. }
  78. function calculateTender2(tender) {
  79. if (tender.lastStage) {
  80. tender.gather_tp = ZhCalc.add(tender.lastStage.contract_tp, tender.lastStage.qc_tp);
  81. tender.end_contract_tp = ZhCalc.add(tender.lastStage.pre_contract_tp, tender.lastStage.contract_tp);
  82. tender.end_qc_tp = ZhCalc.add(tender.lastStage.pre_qc_tp, tender.lastStage.qc_tp);
  83. tender.end_gather_tp = ZhCalc.add(tender.end_contract_tp, tender.end_qc_tp);
  84. tender.pre_gather_tp = ZhCalc.add(tender.lastStage.pre_contract_tp, tender.lastStage.pre_qc_tp);
  85. tender.yf_tp = ZhCalc.add(tender.lastStage.yf_tp);
  86. tender.end_yf_tp = ZhCalc.add(tender.lastStage.pre_yf_tp, tender.yf_tp);
  87. }
  88. }
  89. tenderTree2.splice(0, tenderTree2.length);
  90. for (const t of tenders) {
  91. calculateTender2(t);
  92. t.valid = true;
  93. delete t.level;
  94. if (t.category && levelCategory.length > 0) {
  95. const parent = loadTenderCategory2(t);
  96. if (parent) {
  97. t.level = parent.level + 1;
  98. parent.children.push(t);
  99. } else {
  100. tenderTree2.push(t);
  101. }
  102. } else {
  103. tenderTree2.push(t);
  104. }
  105. }
  106. sortTenderTree(tenderTree2);
  107. console.log(tenderTree2);
  108. }
  109. function recursiveGetTenderNodeHtml2 (node, arr, pid, this_code, this_status, aidList = []) {
  110. const html = [];
  111. html.push('<tr pid="' + pid + '">');
  112. // 名称
  113. html.push('<td class="in-' + node.level + '">');
  114. if (node.cid) {
  115. html.push('<i class="fa fa-folder-o"></i> ', node.name);
  116. } else {
  117. html.push('<span class="text-muted mr-2">');
  118. html.push(arr.indexOf(node) === arr.length - 1 ? '└' : '├');
  119. html.push('</span>');
  120. //html.push('<a href="/tender/' + node.id + '">', node[c.field], '</a>');
  121. html.push('<a href="javascript: void(0)" id="' + node.id + '">', node.name, '</a>');
  122. }
  123. html.push('</td>');
  124. // 创建人
  125. // html.push('<td>', sp_status_list[node.shenpiInfo[shenpi_type]].name, '</td>');
  126. html.push('<td>');
  127. if (!node.cid) {
  128. if(cur_tenderid === node.id) {
  129. html.push(sp_status_list[this_status].name);
  130. } else {
  131. html.push(sp_status_list[node.shenpiInfo[this_code]].name);
  132. }
  133. }
  134. html.push('</td>');
  135. html.push('<td>');
  136. if (!node.cid) {
  137. let auditList = [];
  138. let tender_status = 1;
  139. if(cur_tenderid === node.id) {
  140. auditList = aidList;
  141. tender_status = this_status;
  142. } else {
  143. auditList = node.shenpiauditList[this_code];
  144. tender_status = node.shenpiInfo[this_code];
  145. }
  146. if(tender_status === sp_status.gdspl || tender_status === sp_status.gdzs) {
  147. const nameList = [];
  148. if(auditList) {
  149. for (const uid of auditList) {
  150. const user = _.find(accountList, { id: uid });
  151. nameList.push(user.name);
  152. }
  153. }
  154. // html.push('<i class="fa fa-question-circle text-primary" data-container="body" data-toggle="tooltip" data-placement="bottom" ' +
  155. // 'data-original-title="'+ (nameList.length > 0 ? nameList.join('-') : '') +'"></i>');
  156. html.push(nameList.length > 0 ? nameList.join('-') : '');
  157. }
  158. }
  159. html.push('</td>');
  160. html.push('<td>');
  161. if (!node.cid) {
  162. html.push('<input data-tid="'+ node.id +'" type="checkbox"'+ (cur_tenderid === node.id ? ' checked disabled' : '') +'>');
  163. }
  164. html.push('</td>');
  165. html.push('</tr>');
  166. if (node.children) {
  167. for (const c of node.children) {
  168. html.push(recursiveGetTenderNodeHtml2(c, node.children, node.sort_id, this_code, this_status, aidList));
  169. }
  170. }
  171. return html.join('');
  172. }
  173. // 根据TenderTree数据获取Html代码
  174. function getTenderTreeHtml2 (this_code, this_status, aidList = []) {
  175. if (tenderTree2.length > 0) {
  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="80">流程模式</th>');
  181. html.push('<th>详细流程</th>');
  182. html.push('<th width="40">选择</th>');
  183. html.push('</tr>', '</thead>');
  184. parentId2 = 0;
  185. for (const t of tenderTree2) {
  186. html.push(recursiveGetTenderNodeHtml2(t, tenderTree2, '', this_code, this_status, aidList));
  187. }
  188. html.push('</table>');
  189. return html.join('');
  190. } else {
  191. return EmptyTenderHtml.join('');
  192. }
  193. }
  194. function getShenpiHtml (this_code) {
  195. const html = [];
  196. html.push('<table class="table table-hover table-bordered">');
  197. html.push('<thead>', '<tr>');
  198. html.push('<th>名称</th>');
  199. html.push('<th width="100">审批流程</th>');
  200. html.push('<th width="40">选择</th>');
  201. html.push('</tr>', '</thead>');
  202. for (const sp of sp_lc) {
  203. html.push('<tr>');
  204. html.push('<td>', sp.name, '</td>');
  205. html.push('<td>');
  206. const this_status = parseInt($('.' + sp.code + '_div').children('.lc-show').siblings('.form-group').find('input:checked').val());
  207. html.push(sp_status_list[this_status].name);
  208. if(this_status !== sp_status.sqspr) {
  209. const nameList = [];
  210. const aid_num = $('.' + sp.code + '_div').children('.lc-show').children('ul').find('.remove-audit').length;
  211. const aidList = [];
  212. for (let i = 0; i < aid_num; i++) {
  213. const aid = parseInt($('.' + sp.code + '_div').children('.lc-show').children('ul').find('.remove-audit').eq(i).data('id'));
  214. aidList.push(aid);
  215. }
  216. if(aidList.length > 0) {
  217. for (const uid of aidList) {
  218. const user = _.find(accountList, { id: uid });
  219. nameList.push(user.name);
  220. }
  221. }
  222. html.push('<i class="fa fa-question-circle text-primary" data-container="body" data-toggle="tooltip" data-placement="bottom" ' +
  223. 'data-original-title="'+ (nameList.length > 0 ? nameList.join('-') : '') +'"></i>');
  224. }
  225. html.push('</td>');
  226. html.push('<td>', this_code !== sp.code ? '<input type="checkbox" data-code="'+ sp.code +'">' : '', '</td>');
  227. html.push('</tr>');
  228. }
  229. html.push('</table>');
  230. return html.join('');
  231. }
  232. $(document).ready(function () {
  233. auditUtils = {
  234. getAuditHtml: function(audit) {
  235. return '<span class="d-inline-block"><span class="badge badge-light">'+ audit.name +' <span class="dropdown">\n' +
  236. ' <a href="javascript:void(0);" class="btn-sm text-danger px-1" title="移除" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><i class="fa fa-remove"></i></a>\n' +
  237. ' <div class="dropdown-menu">\n' +
  238. ' <a class="dropdown-item" href="javascript:void(0);">确认移除审批人?</a>\n' +
  239. ' <div class="dropdown-divider"></div>\n' +
  240. ' <div class="px-2 py-1 text-center">\n' +
  241. ' <button class="remove-audit btn btn-sm btn-danger" data-id="' + audit.audit_id + '">移除</button>\n' +
  242. ' <button class="btn btn-sm btn-secondary">取消</button>\n' +
  243. ' </div>\n' +
  244. ' </div>\n' +
  245. ' </span> ' +
  246. ' </span></span>\n'
  247. },
  248. getAuditTypeHtml: function(code, type) {
  249. const html = [];
  250. const hide = code !== 'stage' ? 'style="display: none;"' : '';
  251. html.push(`<span class="d-inline-block"><select class="form-control form-control-sm" ${hide} data-type="${type}">`);
  252. for (const t of auditType.types) {
  253. html.push(`<option value="${t.value}" ${t.value === type ? 'selected' : ''}>${t.name}</option>`);
  254. }
  255. html.push('</select></span>');
  256. return html.join('');
  257. },
  258. getSelectAuditHtml: function (code) {
  259. let divhtml = '';
  260. accountGroup.forEach((group, idx) => {
  261. let didivhtml = '';
  262. if(group) {
  263. group.groupList.forEach(item => {
  264. 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' +
  265. '<p class="mb-0 d-flex"><span class="text-primary">' + item.name + '</span><span\n' +
  266. ' class="ml-auto">' + item.mobile + '</span></p>\n' +
  267. ' <span class="text-muted">' + item.role + '</span>\n' +
  268. ' </dd>\n' : '';
  269. });
  270. 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' +
  271. ' <div class="dd-content" data-toggleid="' + idx + '">\n' + didivhtml +
  272. ' </div>\n';
  273. }
  274. });
  275. const html =
  276. ' <span class="d-inline-block">\n' +
  277. ' <div class="dropdown text-right">\n' +
  278. ' <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' +
  279. ' 选择审批人\n' +
  280. ' </button>\n' +
  281. ' <div class="dropdown-menu dropdown-menu-right" id="' + code + '_dropdownMenu" aria-labelledby="' + code + '_dropdownMenuButton" style="width:220px">\n' +
  282. ' <div class="mb-2 p-2"><input class="form-control form-control-sm gr-search"\n' +
  283. ' placeholder="姓名/手机 检索" autocomplete="off" data-code="' + code + '"></div>\n' +
  284. ' <dl class="list-unstyled book-list">\n' + divhtml +
  285. ' </dl>\n' +
  286. ' </div>\n' +
  287. ' </div>\n' +
  288. ' </span>\n';
  289. return html;
  290. },
  291. // 以下i从1开始
  292. getAuditGroupInnerHtml: function(code, auditGroup, i) {
  293. const html = [];
  294. const type = auditGroup.length > 0 ? auditGroup[0].audit_type : auditType.key.common;
  295. html.push(`<span class="col-auto">${transFormToChinese(i)}审</span><span class="col-7 spr-span">`);
  296. html.push(this.getAuditTypeHtml(code, type));
  297. for (const audit of auditGroup) {
  298. html.push(this.getAuditHtml(audit));
  299. }
  300. if (type !== auditType.key.common || auditGroup.length === 0) {
  301. html.push(this.getSelectAuditHtml(code));
  302. }
  303. html.push('</span>');
  304. return html.join('');
  305. },
  306. getAuditGroupHtml: function (code, auditGroup, i) {
  307. return `<li class="d-flex justify-content-start align-items-center mb-3">${this.getAuditGroupInnerHtml(code, auditGroup, i)}</li>`;
  308. },
  309. getFinalAuditHtml: function (audit) {
  310. const html = [];
  311. html.push('<li class="d-flex justify-content-start mb-3"><span class="col-auto">终审</span><span class="col-7 spr-span">');
  312. html.push(this.getAuditHtml(audit));
  313. html.push('</span></span></li>');
  314. return html.join('');
  315. },
  316. // 以下i从0开始
  317. addAudit: function (code, user, i) {
  318. const flow = sp_lc.find(x => { return x.code === code });
  319. if (!flow.auditGroupList) flow.auditGroupList = [];
  320. if (!flow.auditGroupList[i]) flow.auditGroupList[i] = [];
  321. flow.auditGroupList[i].push(user);
  322. return flow.auditGroupList[i];
  323. },
  324. removeAudit: function (code, audit_id, i) {
  325. const flow = sp_lc.find(x => { return x.code === code });
  326. if (flow.auditGroupList[i].length === 1) {
  327. flow.auditGroupList.splice(i, 1);
  328. return null;
  329. }
  330. flow.auditGroupList[i].splice(flow.auditGroupList[i].findIndex(x => { return x.audit_id === audit_id; }), 1);
  331. return flow.auditGroupList[i];
  332. },
  333. setAuditType: function (code, audit_type, i) {
  334. const flow = sp_lc.find(x => { return x.code === code });
  335. if (!flow || !flow.auditGroupList || !flow.auditGroupList[i]) return;
  336. flow.auditGroupList[i].forEach(x => { x.audit_type = audit_type});
  337. return flow.auditGroupList[i];
  338. }
  339. };
  340. let timer = null;
  341. let oldSearchVal = null;
  342. $('body').on('input propertychange', 'div[id$="_dropdownMenu"] .gr-search', function(e) {
  343. oldSearchVal = e.target.value;
  344. timer && clearTimeout(timer);
  345. timer = setTimeout(() => {
  346. const newVal = $(this).val();
  347. const code = $(this).attr('data-code');
  348. let html = '';
  349. if (newVal && newVal === oldSearchVal) {
  350. 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 => {
  351. html += `<dd class="border-bottom p-2 mb-0 " data-id="${item.id}" >
  352. <p class="mb-0 d-flex"><span class="text-primary">${item.name}</span><span
  353. class="ml-auto">${item.mobile || ''}</span></p>
  354. <span class="text-muted">${item.role || ''}</span>
  355. </dd>`
  356. });
  357. $('#' + code + '_dropdownMenu .book-list').empty();
  358. $('#' + code + '_dropdownMenu .book-list').append(html);
  359. } else {
  360. if (!$('#' + code + '_dropdownMenu .acc-btn').length) {
  361. accountGroup.forEach((group, idx) => {
  362. if (!group) return;
  363. html += `<dt><a href="javascript: void(0);" class="acc-btn" data-groupid="${idx}" data-type="hide"><i class="fa fa-plus-square"></i>
  364. </a> ${group.groupName}</dt>
  365. <div class="dd-content" data-toggleid="${idx}">`;
  366. group.groupList.forEach(item => {
  367. if ((item.id !== cur_uid || (item.id === cur_uid && needYB.indexOf(code) !== -1))) {
  368. html += `<dd class="border-bottom p-2 mb-0 " data-id="${item.id}" >
  369. <p class="mb-0 d-flex"><span class="text-primary">${item.name}</span><span
  370. class="ml-auto">${item.mobile || ''}</span></p>
  371. <span class="text-muted">${item.role || ''}</span>
  372. </dd>`;
  373. }
  374. });
  375. html += '</div>';
  376. });
  377. $('#' + code + '_dropdownMenu .book-list').empty();
  378. $('#' + code + '_dropdownMenu .book-list').append(html);
  379. }
  380. }
  381. }, 400);
  382. });
  383. // 添加审批流程按钮逻辑
  384. $('body').on('click', 'div[id$="_dropdownMenu"] .book-list dt', function () {
  385. const idx = $(this).find('.acc-btn').attr('data-groupid');
  386. const type = $(this).find('.acc-btn').attr('data-type');
  387. if (type === 'hide') {
  388. $(this).parent().find(`div[data-toggleid="${idx}"]`).show(() => {
  389. $(this).children().find('i').removeClass('fa-plus-square').addClass('fa-minus-square-o');
  390. $(this).find('.acc-btn').attr('data-type', 'show');
  391. })
  392. } else {
  393. $(this).parent().find(`div[data-toggleid="${idx}"]`).hide(() => {
  394. $(this).children().find('i').removeClass('fa-minus-square-o').addClass('fa-plus-square');
  395. $(this).find('.acc-btn').attr('data-type', 'hide');
  396. })
  397. }
  398. return false;
  399. });
  400. // 更改审批流程状态
  401. $('body').on('change', '.form-check input[type="radio"]', function () {
  402. // 获取所有审批的checked值并更新
  403. const this_status = parseInt($(this).val());
  404. const this_code = $(this).data('code');
  405. const spt = sp_status_list[this_status];
  406. $(this).parents('.form-group').siblings('.alert-warning').text(spt.name + ':' + spt.msg);
  407. // 拼接post json
  408. const prop = {
  409. code: this_code,
  410. status: this_status
  411. };
  412. const _self = $(this);
  413. postData('/tender/' + cur_tenderid + '/shenpi/save', prop, function (data) {
  414. if (this_status === sp_status.sqspr) {
  415. _self.parents('.form-group').siblings('.lc-show').html('');
  416. } else if (this_status === sp_status.gdspl) {
  417. let addhtml = '<ul class="list-unstyled">\n';
  418. const flow = sp_lc.find(x => { return x.code === this_code; });
  419. flow.auditGroupList = data;
  420. if (data.length !== 0) {
  421. for(const [i, auditGroup] of data.entries()) {
  422. addhtml += auditUtils.getAuditGroupHtml(this_code, auditGroup, i + 1);
  423. }
  424. addhtml += '<li class="pl-3"><a href="javascript:void(0);" class="add-audit"><i class="fa fa-plus"></i> 添加流程</a></li>';
  425. } else {
  426. addhtml += auditUtils.getAuditGroupHtml(this_code, [], 1);
  427. }
  428. addhtml += '</ul>\n';
  429. _self.parents('.form-group').siblings('.lc-show').html(addhtml);
  430. } else if (this_status === sp_status.gdzs) {
  431. let addhtml = '<ul class="list-unstyled">\n' +
  432. ' <li class="d-flex justify-content-start mb-3">\n' +
  433. ' <span class="col-auto">授权审批人</span>\n' +
  434. ' <span class="col-7">\n' +
  435. ' <span class="d-inline-block"></span>\n' +
  436. ' </span>\n' +
  437. ' </li>\n';
  438. addhtml += data ? makeAudit(data) : makeSelectAudit(this_code);
  439. addhtml += '</ul>\n';
  440. _self.parents('.form-group').siblings('.lc-show').html(addhtml);
  441. }
  442. if(this_code === 'stage') {
  443. if(this_status === sp_status.gdspl) {
  444. $('#stage_cooperation').show();
  445. } else {
  446. $('#stage_cooperation').hide();
  447. }
  448. }
  449. });
  450. });
  451. // 选中审批人
  452. $('body').on('click', 'div[id$="_dropdownMenu"] dl dd', function () {
  453. const id = parseInt($(this).data('id'));
  454. if (!id) return;
  455. let this_code = $(this).parents('.lc-show').siblings('.form-group').find('input:checked').data('code');
  456. if (!this_code) this_code = $(this).parents('.dropdown').data('code');
  457. const user = _.find(accountList, function (item) {
  458. return item.id === id;
  459. });
  460. if (this_code === 'audit-ass') {
  461. auditAss.setAuditAssist(user);
  462. } else {
  463. const this_status = parseInt($(this).parents('.lc-show').siblings('.form-group').find('input:checked').val());
  464. if (this_status === sp_status.gdspl) {
  465. // 判断是否已存在审批人
  466. const aid_num = $(this).parents('ul').find('.remove-audit').length;
  467. for (let i = 0; i < aid_num; i++) {
  468. const aid = parseInt($(this).parents('ul').find('.remove-audit').eq(i).data('id'));
  469. if (aid === id) {
  470. toastr.warning('该审核人已存在,请勿重复添加');
  471. return;
  472. }
  473. }
  474. }
  475. const prop = {
  476. status: this_status,
  477. code: sp_type[this_code],
  478. audit_id: id,
  479. type: 'add',
  480. };
  481. if (this_status === sp_status.gdspl) {
  482. prop.audit_type = parseInt($(this).parents('li').find('select')[0].value);
  483. prop.audit_order = $(this).parents('li').index() + 1;
  484. }
  485. const _self = $(this);
  486. postData('/tender/' + cur_tenderid + '/shenpi/audit/save', prop, function (data) {
  487. if (this_status === sp_status.gdspl) {
  488. const auditGroup = auditUtils.addAudit(this_code, { audit_id: data.audit_id, name: user.name, audit_type: data.audit_type, audit_order: data.audit_order }, prop.audit_order - 1);
  489. if (_self.parents('ul').find('.add-audit').length === 0) {
  490. _self.parents('ul').append('<li class="pl-3"><a href="javascript:void(0);" class="add-audit"><i class="fa fa-plus"></i> 添加流程</a></li>');
  491. }
  492. _self.parents('li').html(auditUtils.getAuditGroupInnerHtml(this_code, auditGroup, prop.audit_order));
  493. } else {
  494. _self.parents('.spr-span').html('<span class="d-inline-block"></span>\n' +
  495. '<span class="d-inline-block"><span class="badge badge-light">'+ user.name +' <span class="dropdown">\n' +
  496. ' <a href="javascript:void(0);" class="btn-sm text-danger px-1" title="移除" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><i class="fa fa-remove"></i></a>\n' +
  497. ' <div class="dropdown-menu">\n' +
  498. ' <a class="dropdown-item" href="javascript:void(0);">确认移除审批人?</a>\n' +
  499. ' <div class="dropdown-divider"></div>\n' +
  500. ' <div class="px-2 py-1 text-center">\n' +
  501. ' <button class="remove-audit btn btn-sm btn-danger" data-id="' + user.id + '">移除</button>\n' +
  502. ' <button class="btn btn-sm btn-secondary">取消</button>\n' +
  503. ' </div>\n' +
  504. ' </div>\n' +
  505. ' </span> ' +
  506. ' </span></span></span>\n');
  507. }
  508. });
  509. }
  510. });
  511. // 移除审批人
  512. $('body').on('click', '.remove-audit', function () {
  513. const id = parseInt($(this).data('id'));
  514. const this_status = parseInt($(this).parents('.lc-show').siblings('.form-group').find('input:checked').val());
  515. const this_code = $(this).parents('.lc-show').siblings('.form-group').find('input:checked').data('code');
  516. const prop = {
  517. status: this_status,
  518. code: sp_type[this_code],
  519. audit_id: id,
  520. type: 'del',
  521. };
  522. const _self = $(this);
  523. postData('/tender/' + cur_tenderid + '/shenpi/audit/save', prop, function (data) {
  524. if (this_status === sp_status.gdspl) {
  525. const index = _self.parents('li').index();
  526. const auditGroup = auditUtils.removeAudit(this_code, id, index);
  527. if (auditGroup) {
  528. _self.parents('li').html(auditUtils.getAuditGroupInnerHtml(this_code, auditGroup, index + 1));
  529. } else {
  530. const _selflc = _self.parents('.lc-show');
  531. _self.parents('li').remove();
  532. const aid_num = parseInt(_selflc.children('ul').find('li.d-flex').length);
  533. if (aid_num === 0) {
  534. _selflc.children('ul').html(auditUtils.getAuditGroupHtml(this_code, [], 1));
  535. } else {
  536. for (let i = 0; i < aid_num; i++) {
  537. _selflc.find('li.d-flex').eq(i).find('.col-auto').text(transFormToChinese(i+1) + '审');
  538. }
  539. }
  540. }
  541. } else if (this_status === sp_status.gdzs) {
  542. let addhtml = '<ul class="list-unstyled">\n' +
  543. ' <li class="d-flex justify-content-start mb-3">\n' +
  544. ' <span class="col-auto">授权审批人</span>\n' +
  545. ' <span class="col-7">\n' +
  546. ' <span class="d-inline-block"></span>\n' +
  547. ' </span>\n' +
  548. ' </li>\n';
  549. addhtml += makeSelectAudit(this_code);
  550. addhtml += '</ul>\n';
  551. _self.parents('.lc-show').html(addhtml);
  552. }
  553. })
  554. });
  555. // 固定审批流-添加流程
  556. $('body').on('click', '.add-audit', function () {
  557. const num = $(this).parents('ul').children('li').length;
  558. const this_code = $(this).parents('.lc-show').siblings('.form-group').find('input:checked').data('code');
  559. //const addhtml = makeSelectAudit(this_code, transFormToChinese(num));
  560. const addhtml = auditUtils.getAuditGroupHtml(this_code, [], num);
  561. $(this).parents('ul').append(addhtml);
  562. $(this).parents('li').remove();
  563. });
  564. sortCategory2();
  565. initTenderTree2();
  566. $('body').on('click', '.set-otherTender', function () {
  567. const this_code = $(this).data('code');
  568. const this_status = parseInt($(this).siblings('.lc-show').siblings('.form-group').find('input:checked').val());
  569. const lis = $(this).siblings('.lc-show').find('li');
  570. const auditList = [], aidList = [];
  571. lis.each((i, li) => {
  572. const removes = $(li).find('.remove-audit');
  573. if (removes.length === 0) return;
  574. const select = $(li).find('select');
  575. const audit_type = select.length > 0 ? parseInt(select.val()) : 1;
  576. for (const remove of removes) {
  577. auditList.push({ audit_id: parseInt(remove.getAttribute('data-id')), audit_type, audit_order: i + 1 });
  578. aidList.push(parseInt(remove.getAttribute('data-id')));
  579. }
  580. });
  581. const html = getTenderTreeHtml2(this_code, this_status, aidList);
  582. $('#shenpi-name').text($(this).data('name'));
  583. $('#shenpi_code').val(this_code);
  584. $('#shenpi_status').val(this_status);
  585. $('#shenpi_auditors').val(JSON.stringify(auditList));
  586. $('#tender-list').html(html);
  587. $('#search-audit').val('');
  588. $('#search-result').text('0/0');
  589. $('#up-search').attr('disabled', true);
  590. $('#down-search').attr('disabled', true);
  591. setTimeout(function () { $("#tender-list [data-toggle='tooltip']").tooltip(); },800);
  592. });
  593. $('#save-other-tender').click(function () {
  594. $(this).attr('disabled', true);
  595. const num = $('#tender-list input:checked').length;
  596. if (num < 2) {
  597. toastr.warning('请选择需要设置审批同步的标段');
  598. return;
  599. }
  600. const data = {
  601. type: 'copy2ot',
  602. status: parseInt($('#shenpi_status').val()),
  603. code: $('#shenpi_code').val(),
  604. };
  605. if(data.status !== shenpi_status.gdspl) {
  606. data.auditList = JSON.parse($('#shenpi_auditors').val());
  607. }
  608. // 获取已选中的标段
  609. const tenderList = [];
  610. for (let i = 0; i < num; i++) {
  611. const tid = parseInt($('#tender-list input:checked').eq(i).data('tid'));
  612. if (tid !== cur_tenderid) {
  613. tenderList.push(tid);
  614. }
  615. }
  616. data.tidList = tenderList.join(',');
  617. postData('/tender/' + cur_tenderid + '/shenpi/audit/save', data, function () {
  618. toastr.success('设置成功');
  619. setTimeout(function () {
  620. window.location.reload();
  621. }, 1000)
  622. })
  623. });
  624. $('body').on('click', '.set-otherShenpi', function () {
  625. let canSetOther = true;
  626. const this_code = $(this).data('code');
  627. if (this_code === 'stage') {
  628. const select = $(this).siblings('.lc-show').find('select');
  629. select.each((i, s) => {
  630. if (s.value !== '1') canSetOther = false;
  631. });
  632. }
  633. if (!canSetOther) {
  634. toastr.warning('该流程含有会签或签,不可同步至其他流程');
  635. $('#batch2').modal('hide');
  636. return;
  637. }
  638. const this_status = parseInt($(this).siblings('.lc-show').siblings('.form-group').find('input:checked').val());
  639. const aid_num = $(this).siblings('.lc-show').children('ul').find('.remove-audit').length;
  640. const aidList = [];
  641. for (let i = 0; i < aid_num; i++) {
  642. const aid = parseInt($(this).siblings('.lc-show').children('ul').find('.remove-audit').eq(i).data('id'));
  643. aidList.push(aid);
  644. }
  645. const html = getShenpiHtml(this_code);
  646. $('#shenpi-name2').text($(this).data('name'));
  647. $('#shenpi_code2').val(this_code);
  648. $('#shenpi_status2').val(this_status);
  649. $('#shenpi_auditors2').val(aidList.join(','));
  650. $('#shenpi-list').html(html);
  651. setTimeout(function () { $("#shenpi-list [data-toggle='tooltip']").tooltip(); },800);
  652. $('#batch2').modal('show');
  653. });
  654. $('#save-other-shenpi').click(function () {
  655. $(this).attr('disabled', true);
  656. const num = $('#shenpi-list input:checked').length;
  657. if (num < 1) {
  658. toastr.warning('请选择需要设置审批同步的流程');
  659. return;
  660. }
  661. const data = {
  662. type: 'copy2os',
  663. status: parseInt($('#shenpi_status2').val()),
  664. code: $('#shenpi_code2').val(),
  665. };
  666. if(data.status !== shenpi_status.gdspl) {
  667. data.aidList = $('#shenpi_auditors2').val();
  668. }
  669. // 获取已选中的标段
  670. const shenpiList = [];
  671. for (let i = 0; i < num; i++) {
  672. const code = $('#shenpi-list input:checked').eq(i).data('code');
  673. shenpiList.push(code);
  674. }
  675. data.shenpiList = shenpiList.join(',');
  676. postData('/tender/' + cur_tenderid + '/shenpi/audit/save', data, function () {
  677. toastr.success('设置成功');
  678. setTimeout(function () {
  679. window.location.reload();
  680. }, 1000)
  681. })
  682. });
  683. // 设置会签、或签
  684. $('body').on('change', 'select', function() {
  685. const removes = $(this).parents('.d-flex').find('.remove-audit');
  686. if (removes.length === 0) return;
  687. const this_status = parseInt($(this).parents('.lc-show').siblings('.form-group').find('input:checked').val());
  688. const this_code = $(this).parents('.lc-show').siblings('.form-group').find('input:checked').data('code');
  689. const ids = [];
  690. const liParent = $(this).parents('li');
  691. removes.each((i, r) => { ids.push(parseInt(r.getAttribute('data-id'))); });
  692. const prop = {
  693. status: this_status,
  694. code: sp_type[this_code],
  695. audit_id: ids,
  696. audit_type: parseInt(this.value),
  697. type: 'audit-type',
  698. };
  699. if (prop.audit_type === auditType.key.common && ids.length > 1) {
  700. toastr.warning('设置个人审批前请先删除多余的审批人');
  701. this.value = this.getAttribute('data-type');
  702. return;
  703. }
  704. const _self = this;
  705. postData('/tender/'+ cur_tenderid +'/shenpi/audit/save', prop, function () {
  706. _self.setAttribute('data-type', _self.value);
  707. const auditGroup = auditUtils.setAuditType(this_code, prop.audit_type, liParent.index());
  708. liParent.html(auditUtils.getAuditGroupInnerHtml(this_code, auditGroup, liParent.index() + 1));
  709. });
  710. });
  711. class AuditAss {
  712. constructor() {
  713. this.spread = SpreadJsObj.createNewSpread($('#ledger-spread')[0]);
  714. this.sheet = this.spread.getActiveSheet();
  715. this.tree = createNewPathTree('base', {
  716. id: 'ledger_id',
  717. pid: 'ledger_pid',
  718. order: 'order',
  719. level: 'level',
  720. rootId: -1,
  721. });
  722. this.spreadSetting = {
  723. cols: [
  724. {title: '编号', colSpan: '1', rowSpan: '2', field: 'code', hAlign: 0, width: 165, formatter: '@', cellType: 'tree'},
  725. {title: '名称', colSpan: '1', rowSpan: '2', field: 'name', hAlign: 0, width: 185, formatter: '@'},
  726. {title: '协同人', colSpan: '1', rowSpan: '2', field: 'ass_name', hAlign: 1, width: 100, formatter: '@'},
  727. ],
  728. emptyRows: 0,
  729. headRows: 1,
  730. headRowHeight: [25, 25],
  731. defaultRowHeight: 21,
  732. headerFont: '12px 微软雅黑',
  733. font: '12px 微软雅黑',
  734. readOnly: true,
  735. localCache: {
  736. key: 'ledger-cooperation',
  737. colWidth: true,
  738. }
  739. };
  740. sjsSettingObj.setFxTreeStyle(this.spreadSetting, sjsSettingObj.FxTreeStyle.jz);
  741. SpreadJsObj.initSheet(this.sheet, this.spreadSetting);
  742. const self = this;
  743. SpreadJsObj.addDeleteBind(this.spread, function() { return; });
  744. SpreadJsObj.selChangedRefreshBackColor(this.sheet);
  745. this.spread.bind(spreadNS.Events.SelectionChanged, function() {
  746. self.refreshOperate();
  747. });
  748. $('#stage_audits').change(function () {
  749. self.uid = $(this).val();
  750. });
  751. // 多人协同
  752. $('#cooperation').on('shown.bs.modal', function () {
  753. // 执行一些动作...
  754. // 更新新的多人协同表格信息
  755. const newUidList = [];
  756. $('.stage_div ul li').each(function (k, v) {
  757. const audit_type = parseInt($(v).find('select').val());
  758. if (audit_type !== auditType.key.common) return;
  759. const uid = $(v).find('button').eq(0).data('id');
  760. if(uid) newUidList.push({ order: k + 1, audit_id: uid });
  761. });
  762. const yb = _.find(accountList, { 'id': cur_uid });
  763. let newhtml = '<option value="' + yb.id + '">' + yb.name + '(原报)</option>';
  764. if(newUidList.length > 0) {
  765. for (const id of newUidList) {
  766. const audit = _.find(accountList, { 'id': id.audit_id });
  767. newhtml += '<option value="' + audit.id + '">' + audit.name + '(' + transFormToChinese(id.order) + '审)</option>';
  768. }
  769. }
  770. $('#stage_audits').html(newhtml);
  771. self.uid = cur_uid;
  772. self.initLedgerTree(cur_uid);
  773. });
  774. $('#del-audit-ass').click(function () {
  775. self.setAuditAssist();
  776. });
  777. $('body').on('click', 'button[asid]', function () {
  778. self.removeAuditAss(parseInt(this.getAttribute('asid')));
  779. });
  780. }
  781. set uid(id) {
  782. this._uid = parseInt(id);
  783. this._refreshAss();
  784. }
  785. get uid() {
  786. return this._uid;
  787. }
  788. _refreshAssTable(){
  789. $('#stage_audit').text($("#stage_audits option:selected").text());
  790. const html = [];
  791. for (const sa of this.showAssList) {
  792. const lid = sa.ass_ledger_id ? sa.ass_ledger_id.split(',') : [];
  793. html.push(`<tr><td>${sa.name}</td><td>${sa.company}</td><td>${lid.length}<button class="ml-2 btn btn-sm btn-outline-danger" asid="${sa.id}">移除</button></td></tr>`);
  794. }
  795. $('#coo_table').html(html.join(''));
  796. }
  797. _refreshAssTree() {
  798. const ledgerAss = {};
  799. for (const sa of this.showAssList) {
  800. const ledger = sa.ass_ledger_id ? sa.ass_ledger_id.split(',') : [];
  801. ledger.forEach(l => { ledgerAss[l] = sa; });
  802. }
  803. for (const n of this.tree.nodes) {
  804. const la = ledgerAss[n.ledger_id];
  805. n.ass_audit_id = la ? la.ass_user_id : null;
  806. n.ass_name = la ? la.name : '';
  807. }
  808. SpreadJsObj.reloadColData(this.sheet, 2);
  809. }
  810. _refreshAss() {
  811. this.showAssList = _.filter(this.assList, { 'user_id': parseInt(this.uid) });
  812. this._refreshAssTable();
  813. this._refreshAssTree();
  814. }
  815. initLedgerTree(uid) {
  816. if (this.loaded) return;
  817. this.spread.refresh();
  818. const self = this;
  819. postData('/tender/' + cur_tenderid + '/shenpi/ass/load', {}, function (data) {
  820. self.loaded = true;
  821. self.assList = data.auditAssList;
  822. self.tree.loadDatas(data.ledgerList);
  823. SpreadJsObj.loadSheetData(self.sheet, SpreadJsObj.DataType.Tree, self.tree);
  824. self.uid = uid;
  825. self.refreshOperate();
  826. }, null, true);
  827. }
  828. loadPostData(data) {
  829. if (data.add) {
  830. this.assList.push(data.add);
  831. }
  832. if (data.del) {
  833. this.assList.splice(this.assList.findIndex(x => { return x.id === data.del.id }), 1);
  834. }
  835. if (data.update) {
  836. for (const d of data.update) {
  837. const od = this.assList.find(x => { return x.id === d.id });
  838. if (!od) continue;
  839. od.ass_ledger_id = d.ass_ledger_id;
  840. }
  841. }
  842. this._refreshAss();
  843. }
  844. setAuditAssist(assist){
  845. const node = SpreadJsObj.getSelectObject(this.sheet);
  846. if (assist && node.ass_audit_id === assist.id) return;
  847. if (assist && assist.id === this.uid) {
  848. toastr.warning('请勿添加本人');
  849. return;
  850. }
  851. const self = this;
  852. const data = { type: 'audit-ass'};
  853. if (assist) {
  854. const newAss = this.showAssList.find(x => { return x.ass_user_id === assist.id; });
  855. if (!newAss) {
  856. data.add = { user_id: this.uid, ass_user_id: assist.id, name: assist.name, company: assist.company, role: assist.role, ass_ledger_id: node.ledger_id + '' };
  857. } else {
  858. data.update = [{ id: newAss.id, ass_ledger_id: newAss.ass_ledger_id + ',' + node.ledger_id}];
  859. }
  860. }
  861. if (node.ass_audit_id) {
  862. const orgAss = this.showAssList.find(x => { return x.ass_user_id === node.ass_audit_id; });
  863. const rela_lid = orgAss.ass_ledger_id ? orgAss.ass_ledger_id.split(',') : [];
  864. rela_lid.splice(rela_lid.indexOf(node.ledger_id + ''), 1);
  865. if (rela_lid.length === 0) {
  866. data.del = { id: orgAss.id };
  867. } else {
  868. if (!data.update) data.update = [];
  869. data.update.push({ id: orgAss.id, ass_ledger_id: rela_lid.join(',')});
  870. }
  871. }
  872. postData('/tender/' + cur_tenderid + '/shenpi/audit/save', data, function (result) {
  873. self.loadPostData(result);
  874. self.refreshOperate();
  875. });
  876. }
  877. removeAuditAss(assistId) {
  878. const self = this;
  879. postData('/tender/' + cur_tenderid + '/shenpi/audit/save', { type: 'audit-ass', del: { id: assistId } }, function (result) {
  880. self.loadPostData(result);
  881. self.refreshOperate();
  882. });
  883. }
  884. refreshOperate() {
  885. const node = SpreadJsObj.getSelectObject(this.sheet);
  886. if (node && node.ass_audit_id) {
  887. $('#del-audit-ass').show();
  888. $('#audit-ass_dropdownMenuButton')[0].innerHTML = '替换协同人';
  889. } else {
  890. $('#del-audit-ass').hide();
  891. $('#audit-ass_dropdownMenuButton')[0].innerHTML = '添加协同人';
  892. }
  893. }
  894. }
  895. const auditAss = new AuditAss();
  896. $.subMenu({
  897. menu: '#sub-menu', miniMenu: '#sub-mini-menu', miniMenuList: '#mini-menu-list',
  898. toMenu: '#to-menu', toMiniMenu: '#to-mini-menu',
  899. key: 'menu.1.0.0',
  900. miniHint: '#sub-mini-hint', hintKey: 'menu.hint.1.0.1',
  901. callback: function (info) {
  902. if (info.mini) {
  903. $('.panel-title').addClass('fluid');
  904. $('#sub-menu').removeClass('panel-sidebar');
  905. } else {
  906. $('.panel-title').removeClass('fluid');
  907. $('#sub-menu').addClass('panel-sidebar');
  908. }
  909. autoFlashHeight();
  910. }
  911. });
  912. let timer2 = null;
  913. let oldSearchVal2 = null;
  914. $('body').on('input propertychange', '#batch input[name="audit-name"]', function(e) {
  915. oldSearchVal2 = e.target.value;
  916. timer2 && clearTimeout(timer2);
  917. timer2 = setTimeout(() => {
  918. const newVal = $(this).val();
  919. const resultLength = $('#tender-list').find('.result').length;
  920. if (resultLength > 0) {
  921. let content = $('#tender-list').html();
  922. const replaceStr = $('#tender-list').find('.result').eq(0).html();
  923. const regExp2 = new RegExp('<span class="result" style="background: yellow;">' + replaceStr + '</span>', 'g');
  924. content = content.replace(regExp2, replaceStr);
  925. const regExp3 = new RegExp('<span class="result" style="background: orange;">' + replaceStr + '</span>', 'g');
  926. content = content.replace(regExp3, replaceStr);
  927. $('#tender-list').html(content);
  928. }
  929. $('#search-result').text('0/0');
  930. $('#up-search').attr('disabled', true);
  931. $('#down-search').attr('disabled', true);
  932. if (newVal && newVal === oldSearchVal2) {
  933. const regExp = new RegExp(newVal, 'g');
  934. for (let i = 0; i < $('#tender-list tr').length; i++) {
  935. if (_.includes($('#tender-list tr').eq(i).children('td').eq(2).html(), newVal)) {
  936. $('#tender-list tr').eq(i).children('td').eq(2).html($('#tender-list tr').eq(i).children('td').eq(2).html().replace(regExp, '<span class="result" style="background: yellow;">' + newVal + '</span>'))
  937. }
  938. }
  939. const resultLength2 = $('#tender-list').find('.result').length;
  940. if (resultLength2 > 0) {
  941. $('#tender-list').find('.result').eq(0).css('background', 'orange');
  942. $('#search-result').text('1/' + resultLength2);
  943. $('#up-search').attr('disabled', false);
  944. $('#down-search').attr('disabled', false);
  945. }
  946. }
  947. if($('#tender-list').find('.result').length > 0) {
  948. const X = $('#tender-list').find('.result').eq(0).offset().top;
  949. $('#tender-list').scrollTop(X - $('#tender-list').offset().top + $('#tender-list').scrollTop() - 30);
  950. }
  951. }, 400);
  952. });
  953. $('#up-search').on('click', function () {
  954. const cur = parseInt($('#search-result').text().split('/')[0]);
  955. const total = parseInt($('#search-result').text().split('/')[1]);
  956. const now = cur - 1 !== 0 ? cur - 1: total;
  957. $('#tender-list').find('.result').eq(cur-1).css('background', 'yellow');
  958. $('#tender-list').find('.result').eq(now-1).css('background', 'orange');
  959. // $('#tender-list tr').eq(searchUser[cur-1]).children('td').eq(2).html($('#tender-list tr').eq(searchUser[cur-1]).children('td').eq(2).html().replace('<span class="result" style="background:orange;">', '<span class="result" style="background:yellow;">'))
  960. // $('#tender-list tr').eq(searchUser[now-1]).children('td').eq(2).html($('#tender-list tr').eq(searchUser[now-1]).children('td').eq(2).html().replace('<span class="result" style="background:yellow;">', '<span class="result" style="background:orange;">'))
  961. $('#search-result').text(now + '/' + total);
  962. const X = $('#tender-list').find('.result').eq(now-1).offset().top;
  963. $('#tender-list').scrollTop(X - $('#tender-list').offset().top + $('#tender-list').scrollTop() - 30);
  964. });
  965. $('#down-search').on('click', function () {
  966. const cur = parseInt($('#search-result').text().split('/')[0]);
  967. const total = parseInt($('#search-result').text().split('/')[1]);
  968. const now = cur + 1 > total ? 1: cur + 1;
  969. $('#tender-list').find('.result').eq(cur-1).css('background', 'yellow');
  970. $('#tender-list').find('.result').eq(now-1).css('background', 'orange');
  971. // $('#tender-list tr').eq(searchUser[cur-1]).children('td').eq(2).html($('#tender-list tr').eq(searchUser[cur-1]).children('td').eq(2).html().replace('<span class="result" style="background:orange;">', '<span class="result" style="background:yellow;">'))
  972. // $('#tender-list tr').eq(searchUser[now-1]).children('td').eq(2).html($('#tender-list tr').eq(searchUser[now-1]).children('td').eq(2).html().replace('<span class="result" style="background:yellow;">', '<span class="result" style="background:orange;">'))
  973. $('#search-result').text(now + '/' + total);
  974. const X = $('#tender-list').find('.result').eq(now-1).offset().top;
  975. $('#tender-list').scrollTop(X - $('#tender-list').offset().top + $('#tender-list').scrollTop() -30);
  976. });
  977. });
  978. // 审批流程-审批人html 生成
  979. function makeAudit(audit, i = '终') {
  980. return '<li class="d-flex justify-content-start mb-3">\n' +
  981. ' <span class="col-auto">'+ i +'审</span>\n' +
  982. ' <span class="col-7 spr-span">\n' +
  983. ' <span class="d-inline-block"></span>\n' +
  984. ' <span class="d-inline-block"><span class="badge badge-light">'+ audit.name +' <span class="dropdown">\n' +
  985. ' <a href="javascript:void(0);" class="btn-sm text-danger px-1" title="移除" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><i class="fa fa-remove"></i></a>\n' +
  986. ' <div class="dropdown-menu">\n' +
  987. ' <a class="dropdown-item" href="javascript:void(0);">确认移除审批人?</a>\n' +
  988. ' <div class="dropdown-divider"></div>\n' +
  989. ' <div class="px-2 py-1 text-center">\n' +
  990. ' <button class="remove-audit btn btn-sm btn-danger" data-id="' + audit.audit_id + '">移除</button>\n' +
  991. ' <button class="btn btn-sm btn-secondary">取消</button>\n' +
  992. ' </div>\n' +
  993. ' </div>\n' +
  994. ' </span> ' +
  995. // '<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' +
  996. ' </span></span></span>\n' +
  997. ' </li>';
  998. }
  999. // 审批流程-选择审批人html 生成
  1000. function makeSelectAudit(code, i = '终') {
  1001. let divhtml = '';
  1002. accountGroup.forEach((group, idx) => {
  1003. let didivhtml = '';
  1004. if(group) {
  1005. group.groupList.forEach(item => {
  1006. 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' +
  1007. '<p class="mb-0 d-flex"><span class="text-primary">' + item.name + '</span><span\n' +
  1008. ' class="ml-auto">' + item.mobile + '</span></p>\n' +
  1009. ' <span class="text-muted">' + item.role + '</span>\n' +
  1010. ' </dd>\n' : '';
  1011. });
  1012. 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' +
  1013. ' <div class="dd-content" data-toggleid="' + idx + '">\n' + didivhtml +
  1014. ' </div>\n';
  1015. }
  1016. });
  1017. let html = '<li class="d-flex justify-content-start mb-3">\n' +
  1018. ' <span class="col-auto">' + i + '审</span>\n' +
  1019. ' <span class="col-7 spr-span">\n' +
  1020. ' <span class="d-inline-block">\n' +
  1021. ' <div class="dropdown text-right">\n' +
  1022. ' <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' +
  1023. ' 选择审批人\n' +
  1024. ' </button>\n' +
  1025. ' <div class="dropdown-menu dropdown-menu-right" id="' + code + '_dropdownMenu" aria-labelledby="' + code + '_dropdownMenuButton" style="width:220px">\n' +
  1026. ' <div class="mb-2 p-2"><input class="form-control form-control-sm gr-search"\n' +
  1027. ' placeholder="姓名/手机 检索" autocomplete="off" data-code="' + code + '"></div>\n' +
  1028. ' <dl class="list-unstyled book-list">\n' + divhtml +
  1029. ' </dl>\n' +
  1030. ' </div>\n' +
  1031. ' </div>\n' +
  1032. ' </span>\n' +
  1033. ' </span>\n' +
  1034. ' </li>';
  1035. return html;
  1036. }