shenpi.js 55 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056
  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. return html.join('');
  295. },
  296. getAuditGroupHtml: function (code, auditGroup, i) {
  297. return `<li class="d-flex justify-content-start align-items-center mb-3">${this.getAuditGroupInnerHtml(code, auditGroup, i)}</li>`;
  298. },
  299. getFinalAuditHtml: function (audit) {
  300. const html = [];
  301. html.push('<li class="d-flex justify-content-start mb-3"><span class="col-auto">终审</span><span class="col-7 spr-span">');
  302. html.push(this.getAuditHtml(audit));
  303. html.push('</span></span></li>');
  304. return html.join('');
  305. },
  306. // 以下i从0开始
  307. addAudit: function (code, user, i) {
  308. const flow = sp_lc.find(x => { return x.code === code });
  309. if (!flow.auditGroupList) flow.auditGroupList = [];
  310. if (!flow.auditGroupList[i]) flow.auditGroupList[i] = [];
  311. flow.auditGroupList[i].push(user);
  312. return flow.auditGroupList[i];
  313. },
  314. removeAudit: function (code, audit_id, i) {
  315. const flow = sp_lc.find(x => { return x.code === code });
  316. if (flow.auditGroupList[i].length === 1) {
  317. flow.auditGroupList.splice(i, 1);
  318. return null;
  319. }
  320. flow.auditGroupList[i].splice(flow.auditGroupList[i].findIndex(x => { return x.audit_id === audit_id; }), 1);
  321. return flow.auditGroupList[i];
  322. },
  323. setAuditType: function (code, audit_type, i) {
  324. const flow = sp_lc.find(x => { return x.code === code });
  325. if (!flow || !flow.auditGroupList || !flow.auditGroupList[i]) return;
  326. flow.auditGroupList[i].forEach(x => { x.audit_type = audit_type});
  327. return flow.auditGroupList[i];
  328. }
  329. };
  330. let timer = null;
  331. let oldSearchVal = null;
  332. const needYB = ['advance', 'ledger', 'revise', 'change', 'audit-ass'];
  333. $('body').on('input propertychange', '.gr-search', function(e) {
  334. oldSearchVal = e.target.value;
  335. timer && clearTimeout(timer);
  336. timer = setTimeout(() => {
  337. const newVal = $(this).val();
  338. const code = $(this).attr('data-code');
  339. let html = '';
  340. if (newVal && newVal === oldSearchVal) {
  341. 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 => {
  342. html += `<dd class="border-bottom p-2 mb-0 " data-id="${item.id}" >
  343. <p class="mb-0 d-flex"><span class="text-primary">${item.name}</span><span
  344. class="ml-auto">${item.mobile || ''}</span></p>
  345. <span class="text-muted">${item.role || ''}</span>
  346. </dd>`
  347. });
  348. $('#' + code + '_dropdownMenu .book-list').empty();
  349. $('#' + code + '_dropdownMenu .book-list').append(html);
  350. } else {
  351. if (!$('#' + code + '_dropdownMenu .acc-btn').length) {
  352. accountGroup.forEach((group, idx) => {
  353. if (!group) return;
  354. html += `<dt><a href="javascript: void(0);" class="acc-btn" data-groupid="${idx}" data-type="hide"><i class="fa fa-plus-square"></i>
  355. </a> ${group.groupName}</dt>
  356. <div class="dd-content" data-toggleid="${idx}">`;
  357. group.groupList.forEach(item => {
  358. if ((item.id !== cur_uid || (item.id === cur_uid && needYB.indexOf(code) !== -1))) {
  359. html += `<dd class="border-bottom p-2 mb-0 " data-id="${item.id}" >
  360. <p class="mb-0 d-flex"><span class="text-primary">${item.name}</span><span
  361. class="ml-auto">${item.mobile || ''}</span></p>
  362. <span class="text-muted">${item.role || ''}</span>
  363. </dd>`;
  364. }
  365. });
  366. html += '</div>';
  367. });
  368. $('#' + code + '_dropdownMenu .book-list').empty();
  369. $('#' + code + '_dropdownMenu .book-list').append(html);
  370. }
  371. }
  372. }, 400);
  373. });
  374. // 添加审批流程按钮逻辑
  375. $('body').on('click', '.book-list dt', function () {
  376. const idx = $(this).find('.acc-btn').attr('data-groupid');
  377. const type = $(this).find('.acc-btn').attr('data-type');
  378. if (type === 'hide') {
  379. $(this).parent().find(`div[data-toggleid="${idx}"]`).show(() => {
  380. $(this).children().find('i').removeClass('fa-plus-square').addClass('fa-minus-square-o');
  381. $(this).find('.acc-btn').attr('data-type', 'show');
  382. })
  383. } else {
  384. $(this).parent().find(`div[data-toggleid="${idx}"]`).hide(() => {
  385. $(this).children().find('i').removeClass('fa-minus-square-o').addClass('fa-plus-square');
  386. $(this).find('.acc-btn').attr('data-type', 'hide');
  387. })
  388. }
  389. return false;
  390. });
  391. // 更改审批流程状态
  392. $('.form-check input').on('change', function () {
  393. // 获取所有审批的checked值并更新
  394. const this_status = parseInt($(this).val());
  395. const this_code = $(this).data('code');
  396. const spt = sp_status_list[this_status];
  397. $(this).parents('.form-group').siblings('.alert-warning').text(spt.name + ':' + spt.msg);
  398. // 拼接post json
  399. const prop = {
  400. code: this_code,
  401. status: this_status
  402. };
  403. const _self = $(this);
  404. postData('/tender/' + cur_tenderid + '/shenpi/save', prop, function (data) {
  405. if (this_status === sp_status.sqspr) {
  406. _self.parents('.form-group').siblings('.lc-show').html('');
  407. } else if (this_status === sp_status.gdspl) {
  408. let addhtml = '<ul class="list-unstyled">\n';
  409. const flow = sp_lc.find(x => { return x.code === this_code; });
  410. flow.auditGroupList = data;
  411. if (data.length !== 0) {
  412. for(const [i, auditGroup] of data.entries()) {
  413. addhtml += auditUtils.getAuditGroupHtml(this_code, auditGroup, i + 1);
  414. }
  415. addhtml += '<li class="pl-3"><a href="javascript:void(0);" class="add-audit"><i class="fa fa-plus"></i> 添加流程</a></li>';
  416. } else {
  417. addhtml += auditUtils.getAuditGroupHtml(this_code, [], 1);
  418. }
  419. addhtml += '</ul>\n';
  420. _self.parents('.form-group').siblings('.lc-show').html(addhtml);
  421. } else if (this_status === sp_status.gdzs) {
  422. let addhtml = '<ul class="list-unstyled">\n' +
  423. ' <li class="d-flex justify-content-start mb-3">\n' +
  424. ' <span class="col-auto">授权审批人</span>\n' +
  425. ' <span class="col-7">\n' +
  426. ' <span class="d-inline-block"></span>\n' +
  427. ' </span>\n' +
  428. ' </li>\n';
  429. addhtml += data ? makeAudit(data) : makeSelectAudit(this_code);
  430. addhtml += '</ul>\n';
  431. _self.parents('.form-group').siblings('.lc-show').html(addhtml);
  432. }
  433. if(this_code === 'stage') {
  434. if(this_status === sp_status.gdspl) {
  435. $('#stage_cooperation').show();
  436. } else {
  437. $('#stage_cooperation').hide();
  438. }
  439. }
  440. });
  441. });
  442. // 选中审批人
  443. $('body').on('click', 'dl dd', function () {
  444. const id = parseInt($(this).data('id'));
  445. if (!id) return;
  446. let this_code = $(this).parents('.lc-show').siblings('.form-group').find('input:checked').data('code');
  447. if (!this_code) this_code = $(this).parents('.dropdown').data('code');
  448. const user = _.find(accountList, function (item) {
  449. return item.id === id;
  450. });
  451. if (this_code === 'audit-ass') {
  452. auditAss.setAuditAssist(user);
  453. } else {
  454. const this_status = parseInt($(this).parents('.lc-show').siblings('.form-group').find('input:checked').val());
  455. if (this_status === sp_status.gdspl) {
  456. // 判断是否已存在审批人
  457. const aid_num = $(this).parents('ul').find('.remove-audit').length;
  458. for (let i = 0; i < aid_num; i++) {
  459. const aid = parseInt($(this).parents('ul').find('.remove-audit').eq(i).data('id'));
  460. if (aid === id) {
  461. toastr.warning('该审核人已存在,请勿重复添加');
  462. return;
  463. }
  464. }
  465. }
  466. const prop = {
  467. status: this_status,
  468. code: sp_type[this_code],
  469. audit_id: id,
  470. type: 'add',
  471. };
  472. if (this_status === sp_status.gdspl) {
  473. prop.audit_type = parseInt($(this).parents('li').find('select')[0].value);
  474. prop.audit_order = $(this).parents('li').index() + 1;
  475. }
  476. const _self = $(this);
  477. postData('/tender/' + cur_tenderid + '/shenpi/audit/save', prop, function (data) {
  478. if (this_status === sp_status.gdspl) {
  479. 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);
  480. if (_self.parents('ul').find('.add-audit').length === 0) {
  481. _self.parents('ul').append('<li class="pl-3"><a href="javascript:void(0);" class="add-audit"><i class="fa fa-plus"></i> 添加流程</a></li>');
  482. }
  483. _self.parents('li').html(auditUtils.getAuditGroupInnerHtml(this_code, auditGroup, prop.audit_order));
  484. } else {
  485. _self.parents('.spr-span').html('<span class="d-inline-block"></span>\n' +
  486. '<span class="d-inline-block"><span class="badge badge-light">'+ user.name +' <span class="dropdown">\n' +
  487. ' <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' +
  488. ' <div class="dropdown-menu">\n' +
  489. ' <a class="dropdown-item" href="javascript:void(0);">确认移除审批人?</a>\n' +
  490. ' <div class="dropdown-divider"></div>\n' +
  491. ' <div class="px-2 py-1 text-center">\n' +
  492. ' <button class="remove-audit btn btn-sm btn-danger" data-id="' + user.id + '">移除</button>\n' +
  493. ' <button class="btn btn-sm btn-secondary">取消</button>\n' +
  494. ' </div>\n' +
  495. ' </div>\n' +
  496. ' </span> ' +
  497. ' </span></span></span>\n');
  498. }
  499. });
  500. }
  501. });
  502. // 移除审批人
  503. $('body').on('click', '.remove-audit', function () {
  504. const id = parseInt($(this).data('id'));
  505. const this_status = parseInt($(this).parents('.lc-show').siblings('.form-group').find('input:checked').val());
  506. const this_code = $(this).parents('.lc-show').siblings('.form-group').find('input:checked').data('code');
  507. const prop = {
  508. status: this_status,
  509. code: sp_type[this_code],
  510. audit_id: id,
  511. type: 'del',
  512. };
  513. const _self = $(this);
  514. postData('/tender/' + cur_tenderid + '/shenpi/audit/save', prop, function (data) {
  515. if (this_status === sp_status.gdspl) {
  516. const index = _self.parents('li').index();
  517. const auditGroup = auditUtils.removeAudit(this_code, id, index);
  518. if (auditGroup) {
  519. _self.parents('li').html(auditUtils.getAuditGroupInnerHtml(this_code, auditGroup, index + 1));
  520. } else {
  521. const _selflc = _self.parents('.lc-show');
  522. _self.parents('li').remove();
  523. const aid_num = parseInt(_selflc.children('ul').find('li.d-flex').length);
  524. if (aid_num === 0) {
  525. _selflc.html(auditUtils.getAuditGroupHtml(this_code, [], 1));
  526. } else {
  527. for (let i = 0; i < aid_num; i++) {
  528. _selflc.find('li.d-flex').eq(i).find('.col-auto').text(transFormToChinese(i+1) + '审');
  529. }
  530. }
  531. }
  532. } else if (this_status === sp_status.gdzs) {
  533. let addhtml = '<ul class="list-unstyled">\n' +
  534. ' <li class="d-flex justify-content-start mb-3">\n' +
  535. ' <span class="col-auto">授权审批人</span>\n' +
  536. ' <span class="col-7">\n' +
  537. ' <span class="d-inline-block"></span>\n' +
  538. ' </span>\n' +
  539. ' </li>\n';
  540. addhtml += makeSelectAudit(this_code);
  541. addhtml += '</ul>\n';
  542. _self.parents('.lc-show').html(addhtml);
  543. }
  544. })
  545. });
  546. // 固定审批流-添加流程
  547. $('body').on('click', '.add-audit', function () {
  548. const num = $(this).parents('ul').children('li').length;
  549. const this_code = $(this).parents('.lc-show').siblings('.form-group').find('input:checked').data('code');
  550. //const addhtml = makeSelectAudit(this_code, transFormToChinese(num));
  551. const addhtml = auditUtils.getAuditGroupHtml(this_code, [], num);
  552. $(this).parents('ul').append(addhtml);
  553. $(this).parents('li').remove();
  554. });
  555. // 审批流程-审批人html 生成
  556. function makeAudit(audit, i = '终') {
  557. return '<li class="d-flex justify-content-start mb-3">\n' +
  558. ' <span class="col-auto">'+ i +'审</span>\n' +
  559. ' <span class="col-7 spr-span">\n' +
  560. ' <span class="d-inline-block"></span>\n' +
  561. ' <span class="d-inline-block"><span class="badge badge-light">'+ audit.name +' <span class="dropdown">\n' +
  562. ' <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' +
  563. ' <div class="dropdown-menu">\n' +
  564. ' <a class="dropdown-item" href="javascript:void(0);">确认移除审批人?</a>\n' +
  565. ' <div class="dropdown-divider"></div>\n' +
  566. ' <div class="px-2 py-1 text-center">\n' +
  567. ' <button class="remove-audit btn btn-sm btn-danger" data-id="' + audit.audit_id + '">移除</button>\n' +
  568. ' <button class="btn btn-sm btn-secondary">取消</button>\n' +
  569. ' </div>\n' +
  570. ' </div>\n' +
  571. ' </span> ' +
  572. // '<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' +
  573. ' </span></span></span>\n' +
  574. ' </li>';
  575. }
  576. // 审批流程-选择审批人html 生成
  577. function makeSelectAudit(code, i = '终') {
  578. let divhtml = '';
  579. accountGroup.forEach((group, idx) => {
  580. let didivhtml = '';
  581. if(group) {
  582. group.groupList.forEach(item => {
  583. 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' +
  584. '<p class="mb-0 d-flex"><span class="text-primary">' + item.name + '</span><span\n' +
  585. ' class="ml-auto">' + item.mobile + '</span></p>\n' +
  586. ' <span class="text-muted">' + item.role + '</span>\n' +
  587. ' </dd>\n' : '';
  588. });
  589. 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' +
  590. ' <div class="dd-content" data-toggleid="' + idx + '">\n' + didivhtml +
  591. ' </div>\n';
  592. }
  593. });
  594. let html = '<li class="d-flex justify-content-start mb-3">\n' +
  595. ' <span class="col-auto">' + i + '审</span>\n' +
  596. ' <span class="col-7 spr-span">\n' +
  597. ' <span class="d-inline-block">\n' +
  598. ' <div class="dropdown text-right">\n' +
  599. ' <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' +
  600. ' 选择审批人\n' +
  601. ' </button>\n' +
  602. ' <div class="dropdown-menu dropdown-menu-right" id="' + code + '_dropdownMenu" aria-labelledby="' + code + '_dropdownMenuButton" style="width:220px">\n' +
  603. ' <div class="mb-2 p-2"><input class="form-control form-control-sm gr-search"\n' +
  604. ' placeholder="姓名/手机 检索" autocomplete="off" data-code="' + code + '"></div>\n' +
  605. ' <dl class="list-unstyled book-list">\n' + divhtml +
  606. ' </dl>\n' +
  607. ' </div>\n' +
  608. ' </div>\n' +
  609. ' </span>\n' +
  610. ' </span>\n' +
  611. ' </li>';
  612. return html;
  613. }
  614. initTenderTree();
  615. $('.set-otherTender').on('click', function () {
  616. const this_code = $(this).data('code');
  617. const this_status = parseInt($(this).siblings('.lc-show').siblings('.form-group').find('input:checked').val());
  618. const aid_num = $(this).siblings('.lc-show').children('ul').find('.remove-audit').length;
  619. const aidList = [];
  620. for (let i = 0; i < aid_num; i++) {
  621. const aid = parseInt($(this).siblings('.lc-show').children('ul').find('.remove-audit').eq(i).data('id'));
  622. aidList.push(aid);
  623. }
  624. const html = getTenderTreeHtml(this_code, this_status, aidList);
  625. $('#shenpi-name').text($(this).data('name'));
  626. $('#shenpi_code').val(this_code);
  627. $('#shenpi_status').val(this_status);
  628. $('#shenpi_auditors').val(aidList.join(','));
  629. $('#tender-list').html(html);
  630. $('#search-audit').val('');
  631. $('#search-result').text('0/0');
  632. $('#up-search').attr('disabled', true);
  633. $('#down-search').attr('disabled', true);
  634. setTimeout(function () { $("#tender-list [data-toggle='tooltip']").tooltip(); },800);
  635. });
  636. $('#save-other-tender').click(function () {
  637. $(this).attr('disabled', true);
  638. const num = $('#tender-list input:checked').length;
  639. if (num < 2) {
  640. toastr.warning('请选择需要设置审批同步的标段');
  641. return;
  642. }
  643. const data = {
  644. type: 'copy2ot',
  645. status: parseInt($('#shenpi_status').val()),
  646. code: $('#shenpi_code').val(),
  647. };
  648. if(data.status !== shenpi_status.gdspl) {
  649. data.aidList = $('#shenpi_auditors').val();
  650. }
  651. // 获取已选中的标段
  652. const tenderList = [];
  653. for (let i = 0; i < num; i++) {
  654. const tid = parseInt($('#tender-list input:checked').eq(i).data('tid'));
  655. if (tid !== cur_tenderid) {
  656. tenderList.push(tid);
  657. }
  658. }
  659. data.tidList = tenderList.join(',');
  660. postData('/tender/' + cur_tenderid + '/shenpi/audit/save', data, function () {
  661. toastr.success('设置成功');
  662. setTimeout(function () {
  663. window.location.reload();
  664. }, 1000)
  665. })
  666. });
  667. $('.set-otherShenpi').on('click', function () {
  668. let canSetOther = true;
  669. const this_code = $(this).data('code');
  670. if (this_code === 'stage') {
  671. const select = $(this).siblings('.lc-show').find('select');
  672. select.each((i, s) => {
  673. if (s.value !== '1') canSetOther = false;
  674. });
  675. }
  676. if (!canSetOther) {
  677. toastr.warning('该流程含有会签或签,不可同步至其他流程');
  678. $('#batch2').modal('hide');
  679. return;
  680. }
  681. const this_status = parseInt($(this).siblings('.lc-show').siblings('.form-group').find('input:checked').val());
  682. const aid_num = $(this).siblings('.lc-show').children('ul').find('.remove-audit').length;
  683. const aidList = [];
  684. for (let i = 0; i < aid_num; i++) {
  685. const aid = parseInt($(this).siblings('.lc-show').children('ul').find('.remove-audit').eq(i).data('id'));
  686. aidList.push(aid);
  687. }
  688. const html = getShenpiHtml(this_code);
  689. $('#shenpi-name2').text($(this).data('name'));
  690. $('#shenpi_code2').val(this_code);
  691. $('#shenpi_status2').val(this_status);
  692. $('#shenpi_auditors2').val(aidList.join(','));
  693. $('#shenpi-list').html(html);
  694. setTimeout(function () { $("#shenpi-list [data-toggle='tooltip']").tooltip(); },800);
  695. $('#batch2').modal('show');
  696. });
  697. $('#save-other-shenpi').click(function () {
  698. $(this).attr('disabled', true);
  699. const num = $('#shenpi-list input:checked').length;
  700. if (num < 1) {
  701. toastr.warning('请选择需要设置审批同步的流程');
  702. return;
  703. }
  704. const data = {
  705. type: 'copy2os',
  706. status: parseInt($('#shenpi_status2').val()),
  707. code: $('#shenpi_code2').val(),
  708. };
  709. if(data.status !== shenpi_status.gdspl) {
  710. data.aidList = $('#shenpi_auditors2').val();
  711. }
  712. // 获取已选中的标段
  713. const shenpiList = [];
  714. for (let i = 0; i < num; i++) {
  715. const code = $('#shenpi-list input:checked').eq(i).data('code');
  716. shenpiList.push(code);
  717. }
  718. data.shenpiList = shenpiList.join(',');
  719. postData('/tender/' + cur_tenderid + '/shenpi/audit/save', data, function () {
  720. toastr.success('设置成功');
  721. setTimeout(function () {
  722. window.location.reload();
  723. }, 1000)
  724. })
  725. });
  726. // 设置会签、或签
  727. $('body').on('change', 'select', function() {
  728. const removes = $(this).parents('.d-flex').find('.remove-audit');
  729. if (removes.length === 0) return;
  730. const this_status = parseInt($(this).parents('.lc-show').siblings('.form-group').find('input:checked').val());
  731. const this_code = $(this).parents('.lc-show').siblings('.form-group').find('input:checked').data('code');
  732. const ids = [];
  733. const liParent = $(this).parents('li');
  734. removes.each((i, r) => { ids.push(parseInt(r.getAttribute('data-id'))); });
  735. const prop = {
  736. status: this_status,
  737. code: sp_type[this_code],
  738. audit_id: ids,
  739. audit_type: parseInt(this.value),
  740. type: 'audit-type',
  741. };
  742. if (prop.audit_type === auditType.key.common && ids.length > 1) {
  743. toastr.warning('设置个人审批前请先删除多余的审批人');
  744. this.value = this.getAttribute('data-type');
  745. return;
  746. }
  747. const _self = this;
  748. postData('shenpi/audit/save', prop, function () {
  749. _self.setAttribute('data-type', _self.value);
  750. const auditGroup = auditUtils.setAuditType(this_code, prop.audit_type, liParent.index());
  751. liParent.html(auditUtils.getAuditGroupInnerHtml(this_code, auditGroup, liParent.index() + 1));
  752. });
  753. });
  754. class AuditAss {
  755. constructor() {
  756. this.spread = SpreadJsObj.createNewSpread($('#ledger-spread')[0]);
  757. this.sheet = this.spread.getActiveSheet();
  758. this.tree = createNewPathTree('base', {
  759. id: 'ledger_id',
  760. pid: 'ledger_pid',
  761. order: 'order',
  762. level: 'level',
  763. rootId: -1,
  764. });
  765. this.spreadSetting = {
  766. cols: [
  767. {title: '编号', colSpan: '1', rowSpan: '2', field: 'code', hAlign: 0, width: 165, formatter: '@', cellType: 'tree'},
  768. {title: '名称', colSpan: '1', rowSpan: '2', field: 'name', hAlign: 0, width: 185, formatter: '@'},
  769. {title: '协同人', colSpan: '1', rowSpan: '2', field: 'ass_name', hAlign: 1, width: 100, formatter: '@'},
  770. ],
  771. emptyRows: 0,
  772. headRows: 1,
  773. headRowHeight: [25, 25],
  774. defaultRowHeight: 21,
  775. headerFont: '12px 微软雅黑',
  776. font: '12px 微软雅黑',
  777. readOnly: true,
  778. localCache: {
  779. key: 'ledger-cooperation',
  780. colWidth: true,
  781. }
  782. };
  783. sjsSettingObj.setFxTreeStyle(this.spreadSetting, sjsSettingObj.FxTreeStyle.jz);
  784. SpreadJsObj.initSheet(this.sheet, this.spreadSetting);
  785. const self = this;
  786. SpreadJsObj.addDeleteBind(this.spread, function() { return; });
  787. SpreadJsObj.selChangedRefreshBackColor(this.sheet);
  788. this.spread.bind(spreadNS.Events.SelectionChanged, function() {
  789. self.refreshOperate();
  790. });
  791. $('#stage_audits').change(function () {
  792. self.uid = $(this).val();
  793. });
  794. // 多人协同
  795. $('#cooperation').on('shown.bs.modal', function () {
  796. // 执行一些动作...
  797. // 更新新的多人协同表格信息
  798. const newUidList = [];
  799. $('.stage_div ul li').each(function (k, v) {
  800. const audit_type = parseInt($(v).find('select').val());
  801. if (audit_type !== auditType.key.common) return;
  802. const uid = $(v).find('button').eq(0).data('id');
  803. if(uid) newUidList.push({ order: k + 1, audit_id: uid });
  804. });
  805. const yb = _.find(accountList, { 'id': cur_uid });
  806. let newhtml = '<option value="' + yb.id + '">' + yb.name + '(原报)</option>';
  807. if(newUidList.length > 0) {
  808. for (const id of newUidList) {
  809. const audit = _.find(accountList, { 'id': id.audit_id });
  810. newhtml += '<option value="' + audit.id + '">' + audit.name + '(' + transFormToChinese(id.order) + '审)</option>';
  811. }
  812. }
  813. $('#stage_audits').html(newhtml);
  814. self.uid = cur_uid;
  815. self.initLedgerTree(cur_uid);
  816. });
  817. $('#del-audit-ass').click(function () {
  818. self.setAuditAssist();
  819. });
  820. $('body').on('click', 'button[asid]', function () {
  821. self.removeAuditAss(parseInt(this.getAttribute('asid')));
  822. });
  823. }
  824. set uid(id) {
  825. this._uid = parseInt(id);
  826. this._refreshAss();
  827. }
  828. get uid() {
  829. return this._uid;
  830. }
  831. _refreshAssTable(){
  832. $('#stage_audit').text($("#stage_audits option:selected").text());
  833. const html = [];
  834. for (const sa of this.showAssList) {
  835. const lid = sa.ass_ledger_id ? sa.ass_ledger_id.split(',') : [];
  836. 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>`);
  837. }
  838. $('#coo_table').html(html.join(''));
  839. }
  840. _refreshAssTree() {
  841. const ledgerAss = {};
  842. for (const sa of this.showAssList) {
  843. const ledger = sa.ass_ledger_id ? sa.ass_ledger_id.split(',') : [];
  844. ledger.forEach(l => { ledgerAss[l] = sa; });
  845. }
  846. for (const n of this.tree.nodes) {
  847. const la = ledgerAss[n.ledger_id];
  848. n.ass_audit_id = la ? la.ass_user_id : null;
  849. n.ass_name = la ? la.name : '';
  850. }
  851. SpreadJsObj.reloadColData(this.sheet, 2);
  852. }
  853. _refreshAss() {
  854. this.showAssList = _.filter(this.assList, { 'user_id': parseInt(this.uid) });
  855. this._refreshAssTable();
  856. this._refreshAssTree();
  857. }
  858. initLedgerTree(uid) {
  859. if (this.loaded) return;
  860. this.spread.refresh();
  861. const self = this;
  862. postData('/tender/' + cur_tenderid + '/shenpi/ass/load', {}, function (data) {
  863. self.loaded = true;
  864. self.assList = data.auditAssList;
  865. self.tree.loadDatas(data.ledgerList);
  866. SpreadJsObj.loadSheetData(self.sheet, SpreadJsObj.DataType.Tree, self.tree);
  867. self.uid = uid;
  868. self.refreshOperate();
  869. }, null, true);
  870. }
  871. loadPostData(data) {
  872. if (data.add) {
  873. this.assList.push(data.add);
  874. }
  875. if (data.del) {
  876. this.assList.splice(this.assList.findIndex(x => { return x.id === data.del.id }), 1);
  877. }
  878. if (data.update) {
  879. for (const d of data.update) {
  880. const od = this.assList.find(x => { return x.id === d.id });
  881. if (!od) continue;
  882. od.ass_ledger_id = d.ass_ledger_id;
  883. }
  884. }
  885. this._refreshAss();
  886. }
  887. setAuditAssist(assist){
  888. const node = SpreadJsObj.getSelectObject(this.sheet);
  889. if (assist && node.ass_audit_id === assist.id) return;
  890. if (assist && assist.id === this.uid) {
  891. toastr.warning('请勿添加本人');
  892. return;
  893. }
  894. const self = this;
  895. const data = { type: 'audit-ass'};
  896. if (assist) {
  897. const newAss = this.showAssList.find(x => { return x.ass_user_id === assist.id; });
  898. if (!newAss) {
  899. 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 + '' };
  900. } else {
  901. data.update = [{ id: newAss.id, ass_ledger_id: newAss.ass_ledger_id + ',' + node.ledger_id}];
  902. }
  903. }
  904. if (node.ass_audit_id) {
  905. const orgAss = this.showAssList.find(x => { return x.ass_user_id === node.ass_audit_id; });
  906. const rela_lid = orgAss.ass_ledger_id ? orgAss.ass_ledger_id.split(',') : [];
  907. rela_lid.splice(rela_lid.indexOf(node.ledger_id + ''), 1);
  908. if (rela_lid.length === 0) {
  909. data.del = { id: orgAss.id };
  910. } else {
  911. if (!data.update) data.update = [];
  912. data.update.push({ id: orgAss.id, ass_ledger_id: rela_lid.join(',')});
  913. }
  914. }
  915. postData('/tender/' + cur_tenderid + '/shenpi/audit/save', data, function (result) {
  916. self.loadPostData(result);
  917. self.refreshOperate();
  918. });
  919. }
  920. removeAuditAss(assistId) {
  921. const self = this;
  922. postData('/tender/' + cur_tenderid + '/shenpi/audit/save', { type: 'audit-ass', del: { id: assistId } }, function (result) {
  923. self.loadPostData(result);
  924. self.refreshOperate();
  925. });
  926. }
  927. refreshOperate() {
  928. const node = SpreadJsObj.getSelectObject(this.sheet);
  929. if (node && node.ass_audit_id) {
  930. $('#del-audit-ass').show();
  931. $('#audit-ass_dropdownMenuButton')[0].innerHTML = '替换协同人';
  932. } else {
  933. $('#del-audit-ass').hide();
  934. $('#audit-ass_dropdownMenuButton')[0].innerHTML = '添加协同人';
  935. }
  936. }
  937. }
  938. const auditAss = new AuditAss();
  939. $.subMenu({
  940. menu: '#sub-menu', miniMenu: '#sub-mini-menu', miniMenuList: '#mini-menu-list',
  941. toMenu: '#to-menu', toMiniMenu: '#to-mini-menu',
  942. key: 'menu.1.0.0',
  943. miniHint: '#sub-mini-hint', hintKey: 'menu.hint.1.0.1',
  944. callback: function (info) {
  945. if (info.mini) {
  946. $('.panel-title').addClass('fluid');
  947. $('#sub-menu').removeClass('panel-sidebar');
  948. } else {
  949. $('.panel-title').removeClass('fluid');
  950. $('#sub-menu').addClass('panel-sidebar');
  951. }
  952. autoFlashHeight();
  953. }
  954. });
  955. let timer2 = null;
  956. let oldSearchVal2 = null;
  957. $('body').on('input propertychange', '#batch input[name="audit-name"]', function(e) {
  958. oldSearchVal2 = e.target.value;
  959. timer2 && clearTimeout(timer2);
  960. timer2 = setTimeout(() => {
  961. const newVal = $(this).val();
  962. const resultLength = $('#tender-list').find('.result').length;
  963. if (resultLength > 0) {
  964. let content = $('#tender-list').html();
  965. const replaceStr = $('#tender-list').find('.result').eq(0).html();
  966. const regExp2 = new RegExp('<span class="result" style="background: yellow;">' + replaceStr + '</span>', 'g');
  967. content = content.replace(regExp2, replaceStr);
  968. const regExp3 = new RegExp('<span class="result" style="background: orange;">' + replaceStr + '</span>', 'g');
  969. content = content.replace(regExp3, replaceStr);
  970. $('#tender-list').html(content);
  971. }
  972. $('#search-result').text('0/0');
  973. $('#up-search').attr('disabled', true);
  974. $('#down-search').attr('disabled', true);
  975. if (newVal && newVal === oldSearchVal2) {
  976. const regExp = new RegExp(newVal, 'g');
  977. for (let i = 0; i < $('#tender-list tr').length; i++) {
  978. if (_.includes($('#tender-list tr').eq(i).children('td').eq(2).html(), newVal)) {
  979. $('#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>'))
  980. }
  981. }
  982. const resultLength2 = $('#tender-list').find('.result').length;
  983. if (resultLength2 > 0) {
  984. $('#tender-list').find('.result').eq(0).css('background', 'orange');
  985. $('#search-result').text('1/' + resultLength2);
  986. $('#up-search').attr('disabled', false);
  987. $('#down-search').attr('disabled', false);
  988. }
  989. }
  990. if($('#tender-list').find('.result').length > 0) {
  991. const X = $('#tender-list').find('.result').eq(0).offset().top;
  992. $('#tender-list').scrollTop(X - $('#tender-list').offset().top + $('#tender-list').scrollTop() - 30);
  993. }
  994. }, 400);
  995. });
  996. $('#up-search').on('click', function () {
  997. const cur = parseInt($('#search-result').text().split('/')[0]);
  998. const total = parseInt($('#search-result').text().split('/')[1]);
  999. const now = cur - 1 !== 0 ? cur - 1: total;
  1000. $('#tender-list').find('.result').eq(cur-1).css('background', 'yellow');
  1001. $('#tender-list').find('.result').eq(now-1).css('background', 'orange');
  1002. // $('#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;">'))
  1003. // $('#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;">'))
  1004. $('#search-result').text(now + '/' + total);
  1005. const X = $('#tender-list').find('.result').eq(now-1).offset().top;
  1006. $('#tender-list').scrollTop(X - $('#tender-list').offset().top + $('#tender-list').scrollTop() - 30);
  1007. });
  1008. $('#down-search').on('click', function () {
  1009. const cur = parseInt($('#search-result').text().split('/')[0]);
  1010. const total = parseInt($('#search-result').text().split('/')[1]);
  1011. const now = cur + 1 > total ? 1: cur + 1;
  1012. $('#tender-list').find('.result').eq(cur-1).css('background', 'yellow');
  1013. $('#tender-list').find('.result').eq(now-1).css('background', 'orange');
  1014. // $('#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;">'))
  1015. // $('#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;">'))
  1016. $('#search-result').text(now + '/' + total);
  1017. const X = $('#tender-list').find('.result').eq(now-1).offset().top;
  1018. $('#tender-list').scrollTop(X - $('#tender-list').offset().top + $('#tender-list').scrollTop() -30);
  1019. });
  1020. });