shenpi.js 55 KB

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