shenpi.js 55 KB

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