setting_manage.js 67 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388
  1. // 游客及投资管理用户添加到其他标段
  2. const tenderTree4User = [];
  3. let parentId4User = 0;
  4. // 分类数据排序
  5. function sortCategory4User() {
  6. category.sort(function (a, b) {
  7. return a.level ? (b.level ? a.level - b.level : -1) : a.id - b.id;
  8. });
  9. }
  10. // 初始化TenderTree数据
  11. function initTenderTree4User () {
  12. const levelCategory = category.filter(function (c) {
  13. return c.level && c.level > 0;
  14. });
  15. function findCategoryNode4User(cid, value, array) {
  16. for (const a of array) {
  17. if (a.cid === cid && a.vid === value) {
  18. return a;
  19. }
  20. }
  21. }
  22. function getCategoryNode4User(category, value, parent, i = null) {
  23. const array = parent ? parent.children : tenderTree4User;
  24. let cate = findCategoryNode4User(category.id, value, array);
  25. if (!cate) {
  26. const cateValue = findNode2('id', value, category.value);
  27. if (!cateValue) return null;
  28. cate = {
  29. cid: category.id,
  30. vid: value,
  31. name: cateValue.value,
  32. children: [],
  33. level: i ? i : category.level,
  34. sort_id: ++parentId4User,
  35. sort: cateValue.sort,
  36. };
  37. array.push(cate);
  38. }
  39. return cate;
  40. }
  41. function loadTenderCategory4User (tender) {
  42. let tenderCategory = null;
  43. for (const [index,lc] of levelCategory.entries()) {
  44. const tenderCate = findNode2('cid', lc.id, tender.category);
  45. if (tenderCate) {
  46. tenderCategory = getCategoryNode4User(lc, tenderCate.value, tenderCategory);
  47. } else {
  48. if (index === 0 && tender.category) {
  49. for (const [i,c] of tender.category.entries()) {
  50. const cate = findNode2('id', c.cid, category);
  51. if (cate) tenderCategory = getCategoryNode4User(cate, c.value, tenderCategory, i+1);
  52. }
  53. }
  54. return tenderCategory;
  55. }
  56. }
  57. return tenderCategory;
  58. }
  59. tenderTree4User.splice(0, tenderTree4User.length);
  60. for (const t of tenders) {
  61. t.valid = true;
  62. delete t.level;
  63. if (t.category && levelCategory.length > 0) {
  64. const parent = loadTenderCategory4User(t);
  65. if (parent) {
  66. t.level = parent.level + 1;
  67. parent.children.push(t);
  68. } else {
  69. tenderTree4User.push(t);
  70. }
  71. } else {
  72. tenderTree4User.push(t);
  73. }
  74. }
  75. sortTenderTree(tenderTree4User);
  76. }
  77. function recursiveGetTenderNodeHtml4User (node, arr, pid) {
  78. const html = [];
  79. html.push('<tr pid="' + pid + '">');
  80. // 名称
  81. html.push('<td class="in-' + node.level + '">');
  82. if (node.cid) {
  83. html.push('<i class="fa fa-folder-o"></i> ', node.name);
  84. } else {
  85. html.push('<span class="text-muted mr-2">');
  86. html.push(arr.indexOf(node) === arr.length - 1 ? '└' : '├');
  87. html.push('</span>');
  88. //html.push('<a href="/tender/' + node.id + '">', node[c.field], '</a>');
  89. html.push('<a href="javascript: void(0)" id="' + node.id + '">', node.name, '</a>');
  90. }
  91. html.push('</td>');
  92. html.push('<td>');
  93. if (!node.cid) {
  94. html.push('<input data-tid="'+ node.id +'" type="checkbox"'+ (cur_tenderid === node.id ? ' checked disabled' : '') +'>');
  95. }
  96. html.push('</td>');
  97. html.push('</tr>');
  98. if (node.children) {
  99. for (const c of node.children) {
  100. html.push(recursiveGetTenderNodeHtml4User(c, node.children, node.sort_id));
  101. }
  102. }
  103. return html.join('');
  104. }
  105. // 根据TenderTree数据获取Html代码
  106. function getTenderTreeHtml4User () {
  107. if (tenderTree4User.length > 0) {
  108. const html = [];
  109. html.push('<table class="table table-hover table-bordered">');
  110. html.push('<thead>', '<tr>');
  111. html.push('<th>名称</th>');
  112. html.push('<th width="40">选择</th>');
  113. html.push('</tr>', '</thead>');
  114. parentId4User = 0;
  115. for (const t of tenderTree4User) {
  116. html.push(recursiveGetTenderNodeHtml4User(t, tenderTree4User, ''));
  117. }
  118. html.push('</table>');
  119. return html.join('');
  120. } else {
  121. return EmptyTenderHtml.join('');
  122. }
  123. }
  124. function recursiveGetFilterTenderNodeHtml (node, arr) {
  125. const html = [];
  126. html.push(`<tr ${node.id ? 'tid="'+ node.id +'"' : ''}>`);
  127. // 名称
  128. html.push('<td class="in-' + node.level + '">');
  129. if (node.cid) {
  130. html.push('<i class="fa fa-folder-o"></i> ', node.name);
  131. } else {
  132. html.push('<span class="text-muted mr-2">');
  133. html.push(arr.indexOf(node) === arr.length - 1 ? '└' : '├');
  134. html.push('</span>', node.name);
  135. }
  136. html.push('</td>');
  137. html.push('<td class="text-center">');
  138. if (!node.cid) {
  139. html.push(`<input data-tid="${node.id}" data-type="filter_budget" type="checkbox" ${node.filter_budget ? 'checked' : ''}>`);
  140. }
  141. html.push('</td>');
  142. html.push('<td class="text-center">');
  143. if (!node.cid) {
  144. html.push(`<input data-tid="${node.id}" data-type="filter_fund" type="checkbox" ${node.filter_fund ? 'checked' : ''}>`);
  145. }
  146. html.push('</td>');
  147. html.push('</tr>');
  148. if (node.children) {
  149. for (const c of node.children) {
  150. html.push(recursiveGetFilterTenderNodeHtml(c, node.children));
  151. }
  152. }
  153. return html.join('');
  154. }
  155. function getFilterTenderTreeHtml() {
  156. const html = [];
  157. for (const t of tenderTree4User) {
  158. html.push(recursiveGetFilterTenderNodeHtml(t, tenderTree4User));
  159. }
  160. $('#filter-tender-list').html(html.join(''));
  161. }
  162. $(document).ready(() => {
  163. autoFlashHeight();
  164. function getObjHeight(select) {
  165. return select.length > 0 ? select.height() : 0;
  166. }
  167. const cHeader = getObjHeight($(".c-header"));
  168. $('.tab-content').height($(window).height()-cHeader-90+53-46);
  169. const tabTypes = {
  170. tourist: '游客',
  171. schedule: '投资进度',
  172. contract: '合同管理',
  173. construction: '施工日志',
  174. quality: '质量管理',
  175. safe: '安全管理',
  176. };
  177. const tabTypeKeys = ['tourist', 'schedule', 'contract', 'construction', 'quality', 'safe'];
  178. // 单个tenderPermission字段用这个
  179. const tenderPermissionKeys = [];
  180. // 多个tenderPermission字段融合处理用这个
  181. const tPsKeys = {
  182. quality: ['quality', 'inspection'],
  183. safe: ['safe_inspection', 'safe_payment'],
  184. };
  185. const $filterTenderDone = $('body #filter-tender-done')
  186. if (window.location.search && window.location.search.split('done=')[1]) {
  187. $filterTenderDone.prop('checked', window.location.search.split('done=')[1] === '1' ? true : false);
  188. } else {
  189. $filterTenderDone.prop('checked', true);
  190. }
  191. $filterTenderDone.on('change', function() {
  192. const isChecked = $(this).is(':checked');
  193. if (isChecked) {
  194. window.location.href = `/sp/${spid}/setting/manage?done=1`;
  195. } else {
  196. window.location.href = `/sp/${spid}/setting/manage?done=0`;
  197. }
  198. });
  199. $('body').on('click', '.c-body .tender-info', function () {
  200. $('.c-body .tender-info').removeClass('table-warning');
  201. $(this).addClass('table-warning');
  202. const tid = parseInt($(this).attr('data-id'));
  203. if (!tid) {
  204. toastr.warning('不存在标段无法设置');
  205. return;
  206. }
  207. // 请求获取右侧列表信息
  208. postData(`/sp/${spid}/setting/manage/tender/save`, { type: 'msg', tid: parseInt($(this).attr('data-id'))}, function (result) {
  209. sp_lc = result.shenpi.sp_lc;
  210. sp_type = result.shenpi.sp_type;
  211. sp_status = result.shenpi.sp_status;
  212. sp_status_list = result.shenpi.sp_status_list;
  213. cur_tenderid = result.tender.id;
  214. cur_uid = result.tender.user_id;
  215. setShenpiHtml(result.shenpi, result.tender, result.revising);
  216. setTouristHtml(result.tourists);
  217. setScheduleHtml(result.scheduleAuditList);
  218. setContractHtml(result.contractAuditList);
  219. setConstructionHtml(result.constructionAuditList);
  220. for (const tpkey of tenderPermissionKeys) {
  221. setTenderPermissionHtml(result[tpkey + 'AuditList'], tpkey);
  222. }
  223. for (const tpk in tPsKeys) {
  224. setTenderPermissionsHtml(result[tpk + 'AuditList'], tpk, tPsKeys[tpk]);
  225. }
  226. resetAddUserHtml();
  227. });
  228. });
  229. setTimeout(function () {
  230. $('.c-body .tender-info').eq(0).click();// 需要延时加载
  231. }, 500);
  232. $('body').on('click', '.nav .nav-link', function () {
  233. $('#contract-tip').hide();
  234. if ($(this).attr('href') === '#splc') {
  235. $('#user-set').hide();
  236. } else {
  237. $('#user-set').show();
  238. const href = $(this).attr('href');
  239. if (href === '#guest') {
  240. $('#add_user_dropdownMenuButton').attr('data-type', 'tourist');
  241. } else if (href === '#tzpro') {
  242. $('#add_user_dropdownMenuButton').attr('data-type', 'schedule');
  243. } else if (href === '#htgl') {
  244. $('#add_user_dropdownMenuButton').attr('data-type', 'contract');
  245. $('#contract-tip').show();
  246. } else if (href === '#sgrz') {
  247. $('#add_user_dropdownMenuButton').attr('data-type', 'construction');
  248. } else if (_.includes(tenderPermissionKeys, $(this).attr('href').substring(1))) {
  249. $('#add_user_dropdownMenuButton').attr('data-type', $(this).attr('href').substring(1));
  250. } else if (_.includes(Object.keys(tPsKeys), $(this).attr('href').substring(1))) {
  251. $('#add_user_dropdownMenuButton').attr('data-type', $(this).attr('href').substring(1));
  252. }
  253. let currentNavType = null;
  254. if (href === '#guest') currentNavType = 'tourist';
  255. else if (href === '#tzpro') currentNavType = 'schedule';
  256. else if (href === '#htgl') currentNavType = 'contract';
  257. else if (href === '#sgrz') currentNavType = 'construction';
  258. else if (href === '#zlgl') currentNavType = 'quality';
  259. else if (href === '#zlxj') currentNavType = 'inspection';
  260. if(currentNavType) {
  261. setTimeout(() => updateSelectedMarks(currentNavType), 0);
  262. }
  263. }
  264. });
  265. $('body').on('click', '.c-body a', function (e) {
  266. e.stopPropagation();
  267. });
  268. // 权限设置
  269. $('body').on('click', '#tourist-users .set-tourist-permission', function () {
  270. const id = parseInt($(this).data('id'));
  271. const permission = {
  272. file: ($(this).attr('name') === 'file' ? $(this).is(':checked') : $('#' + id + '_file').is(':checked')) ? 1 : 0,
  273. tag: ($(this).attr('name') === 'tag' ? $(this).is(':checked') : $('#' + id + '_tag').is(':checked')) ? 1 : 0,
  274. }
  275. const prop = {
  276. id,
  277. type: 'permission',
  278. permission,
  279. }
  280. console.log(prop);
  281. postData('/tender/' + cur_tenderid + '/tourist/audit/save', prop, function (data) {
  282. });
  283. });
  284. // 权限更改
  285. $('body').on('click', '#schedule-users input[type="checkbox"]', function () {
  286. let permission = scPermission.no;
  287. const value = parseInt($(this).data('zhi'));
  288. if ($(this).is(':checked')) {
  289. if (value === scPermission.edit) {
  290. permission = scPermission.edit;
  291. $(this).parents('td').siblings().find('input').prop('checked', true);
  292. } else if (value === scPermission.show) {
  293. permission = scPermission.show;
  294. }
  295. } else {
  296. if (value === scPermission.edit) {
  297. permission = scPermission.show;
  298. } else if (value === scPermission.show) {
  299. permission = scPermission.no;
  300. $(this).parents('td').siblings().find('input').prop('checked', false);
  301. }
  302. }
  303. const id = parseInt($(this).data('id'));
  304. const prop = {
  305. id,
  306. permission,
  307. type: 'edit',
  308. };
  309. const _self = $(this);
  310. postData('/tender/' + cur_tenderid + '/schedule/audit/save', prop, function (data) {
  311. });
  312. });
  313. // 权限更改
  314. $('body').on('click', '#contract-users input[type="checkbox"]', function () {
  315. const type = $(this).attr('data-type');
  316. const value = $(this).is(':checked') ? 1 : 0;
  317. const id = parseInt($(this).val());
  318. const updateInfo = { uid: id };
  319. updateInfo[type] = value;
  320. postData(`/sp/${spid}/contract/tender/${cur_tenderid}/audit/save`, { type: 'save-permission', updateData: updateInfo }, function (result) {
  321. })
  322. });
  323. // 权限更改
  324. $('body').on('click', '#construction-users input[type="checkbox"]', function () {
  325. const id = parseInt($(this).data('id'));
  326. const prop = {
  327. type: 'save-report',
  328. updateData: {
  329. id,
  330. is_report: $(this).is(':checked') ? 1 : 0,
  331. }
  332. };
  333. const _self = $(this);
  334. postData('/sp/' + spid + '/construction/' + cur_tenderid + '/audit/save', prop, function (data) {
  335. });
  336. });
  337. for (const tpKey of tenderPermissionKeys) {
  338. $('body').on('click', `#${tpKey}-users input[type="checkbox"]`, function () {
  339. const uid = parseInt($(this).parents('tr').data('uid'));
  340. const member = {
  341. uid,
  342. };
  343. member[tpKey] = [1];
  344. $(this).parents('tr').find('input[type="checkbox"]').each(function () {
  345. if ($(this).is(':checked')) {
  346. member[tpKey].push($(this).data('value'));
  347. }
  348. });
  349. const prop = {
  350. type: 'save-permission',
  351. uid,
  352. members: [member],
  353. key: tpKey,
  354. };
  355. const _self = $(this);
  356. postData('/sp/' + spid + '/quality/' + cur_tenderid + '/audit/save', prop, function (data) {
  357. });
  358. });
  359. }
  360. for (const tPsKey in tPsKeys) {
  361. $('body').on('click', `#${tPsKey}-users input[type="checkbox"]`, function () {
  362. const uid = parseInt($(this).parents('tr').data('uid'));
  363. const member = {
  364. uid,
  365. };
  366. const key = $(this).data('key');
  367. member[key] = [];
  368. if ($(this).data('block') === 'view' && !$(this).is(':checked')) {
  369. $(this).parents('tr').find(`input[data-key="${key}"]`).prop('checked', false);
  370. } else {
  371. let viewFlag = false;
  372. $(this).parents('tr').find(`input[data-key="${key}"]`).each(function () {
  373. if ($(this).is(':checked')) {
  374. if ($(this).data('block') !== 'view') {
  375. member[key].push(1);
  376. $(this).parents('tr').find(`input[data-key="${key}"][data-block="view"]`).prop('checked', true);
  377. viewFlag = true;
  378. }
  379. member[key].push($(this).data('value'));
  380. }
  381. });
  382. }
  383. const prop = {
  384. type: 'save-permission',
  385. uid,
  386. members: [member],
  387. key,
  388. };
  389. const _self = $(this);
  390. postData('/sp/' + spid + '/quality/' + cur_tenderid + '/audit/save', prop, function (data) {
  391. });
  392. });
  393. }
  394. for (const key of tabTypeKeys) {
  395. $('body').on('click', `#${key}-users .remove-${key}-user`, function () {
  396. $('#remove_user_type').val(key);
  397. $('#remove_user_id').val($(this).data('id'));
  398. $('#show_id').val($(this).data('show-id'));
  399. });
  400. }
  401. // 移除用户确定
  402. $('#remove_user_btn').click(function () {
  403. const type = $('#remove_user_type').val();
  404. if (tabTypeKeys.indexOf(type) === -1) {
  405. toastr.error('参数有误');
  406. return;
  407. }
  408. const id = parseInt($('#remove_user_id').val());
  409. const showId = parseInt($('#show_id').val());
  410. if (type === 'contract') {
  411. postData('/sp/' + spid + '/contract/tender/' + cur_tenderid + '/audit/save', { type: 'del-audit', id }, function (data) {
  412. $('#'+ type + '-users').find('tr[data-uid="'+ id +'"]').remove();
  413. $('#remove-user').modal('hide');
  414. selectedUserIdsByType[type] = selectedUserIdsByType[type].filter(function(userId) {
  415. return userId !== showId;
  416. });
  417. updateSelectedMarks();
  418. });
  419. } else if (type === 'construction') {
  420. postData('/sp/' + spid + '/' + type + '/' + cur_tenderid + '/audit/save', { type: 'del-audit', id }, function (data) {
  421. $('#'+ type + '-users').find('tr[data-id="'+ id +'"]').remove();
  422. $('#remove-user').modal('hide');
  423. });
  424. } else if (_.includes(tenderPermissionKeys, type)) {
  425. postData('/sp/' + spid + '/quality/' + cur_tenderid + '/audit/save', { type: 'del-audit', id, key: type }, function (data) {
  426. $('#'+ type + '-users').find('tr[data-uid="'+ id +'"]').remove();
  427. $('#remove-user').modal('hide');
  428. selectedUserIdsByType[type] = selectedUserIdsByType[type].filter(function(userId) {
  429. return userId !== showId;
  430. });
  431. updateSelectedMarks();
  432. });
  433. } else if (_.includes(Object.keys(tPsKeys), type)) {
  434. postData('/sp/' + spid + '/quality/' + cur_tenderid + '/audit/save', { type: 'del-audit', id, key: type, together: 1 }, function (data) {
  435. $('#'+ type + '-users').find('tr[data-uid="'+ id +'"]').remove();
  436. $('#remove-user').modal('hide');
  437. selectedUserIdsByType[type] = selectedUserIdsByType[type].filter(function(userId) {
  438. return userId !== showId;
  439. });
  440. updateSelectedMarks();
  441. });
  442. } else if (_.includes(Object.keys(tPsKeys), type)) {
  443. postData('/sp/' + spid + '/quality/' + cur_tenderid + '/audit/save', { type: 'del-audit', id, key: type, together: 1 }, function (data) {
  444. $('#'+ type + '-users').find('tr[data-uid="'+ id +'"]').remove();
  445. $('#remove-user').modal('hide');
  446. });
  447. } else {
  448. const prop = {
  449. id: id,
  450. type: 'del',
  451. };
  452. postData('/tender/' + cur_tenderid + '/' + type + '/audit/save', prop, function (data) {
  453. $('#'+ type + '-users').find('tr[data-id="'+ id +'"]').remove();
  454. $('#remove-user').modal('hide');
  455. selectedUserIdsByType[type] = selectedUserIdsByType[type].filter(function(userId) {
  456. return userId !== showId;
  457. });
  458. updateSelectedMarks();
  459. });
  460. }
  461. });
  462. // 投资进度
  463. let timerAddUser = null;
  464. let oldSearchValAddUser = null;
  465. $('body').on('input propertychange', '#add_user_dropdownMenu2 .gr-search', function (e) {
  466. const currentDropdownType = $('#add_user_dropdownMenuButton').attr('data-type');
  467. let currentSelectedIdsForType = [];
  468. if (currentDropdownType && selectedUserIdsByType.hasOwnProperty(currentDropdownType)) {
  469. currentSelectedIdsForType = selectedUserIdsByType[currentDropdownType]; // 获取对应类型的ID数组
  470. }
  471. oldSearchValAddUser = e.target.value;
  472. timerAddUser && clearTimeout(timerAddUser);
  473. timerAddUser = setTimeout(() => {
  474. const newVal = $(this).val();
  475. if (newVal && newVal === oldSearchValAddUser) {
  476. let html = '';
  477. accountList.filter(item => item && item.id !== cur_uid && (item.name.indexOf(newVal) !== -1 || (item.mobile && item.mobile.indexOf(newVal) !== -1))).forEach(item => {
  478. const itemIdInt = parseInt(item.id, 10);
  479. const isSelected = currentSelectedIdsForType.includes(itemIdInt);
  480. const selectedMarkStyle = isSelected ? '' : ' style="display:none;"';
  481. html += `<dd class="border-bottom p-2 mb-0 user-item" data-id="${item.id}" >
  482. <p class="mb-0 d-flex"><span class="text-primary">${item.name}</span><span
  483. class="ml-auto">${item.mobile || ''}</span>
  484. <span class="selected-mark text-success ml-2"${selectedMarkStyle}><i class="fa fa-check"></i></span>
  485. </p>
  486. <span class="text-muted">${item.role || ''}</span>
  487. </dd>`
  488. });
  489. $('#add_user_dropdownMenu2 .book-list').empty();
  490. $('#add_user_dropdownMenu2 .book-list').append(html);
  491. } else {
  492. if (!$('#add_user_dropdownMenu2 .acc-btn').length) {
  493. resetAddUserHtml();
  494. }
  495. }
  496. }, 400);
  497. });
  498. function resetAddUserHtml() {
  499. const currentDropdownType = $('#add_user_dropdownMenuButton').attr('data-type');
  500. let currentSelectedIdsForType = [];
  501. if (currentDropdownType && selectedUserIdsByType.hasOwnProperty(currentDropdownType)) {
  502. currentSelectedIdsForType = selectedUserIdsByType[currentDropdownType];
  503. }
  504. let html = '';
  505. accountGroup.forEach((group, idx) => {
  506. if (!group) return;
  507. html += `<dt><a href="javascript: void(0);" class="acc-btn" data-groupid="${idx}" data-type="hide"><i class="fa fa-plus-square"></i>
  508. </a> ${group.groupName}</dt>
  509. <div class="dd-content" data-toggleid="${idx}">`;
  510. group.groupList.forEach(item => {
  511. if (item.id !== cur_uid) {
  512. const itemIdInt = parseInt(item.id, 10);
  513. const isSelected = currentSelectedIdsForType.includes(itemIdInt);
  514. const selectedMarkStyle = isSelected ? '' : ' style="display:none;"';
  515. html += `<dd class="border-bottom p-2 mb-0 user-item" data-id="${item.id}" >
  516. <p class="mb-0 d-flex"><span class="text-primary">${item.name}</span><span
  517. class="ml-auto">${item.mobile || ''}</span>
  518. <span class="selected-mark text-success ml-2"${selectedMarkStyle}><i class="fa fa-check"></i></span>
  519. </p>
  520. <span class="text-muted">${item.role || ''}</span>
  521. </dd>`;
  522. }
  523. });
  524. html += '</div>';
  525. });
  526. $('#add_user_dropdownMenu2 .book-list').empty();
  527. $('#add_user_dropdownMenu2 .book-list').append(html);
  528. }
  529. // 添加审批流程按钮逻辑
  530. $('body').on('click', '#add_user_dropdownMenu2 .book-list dt', function () {
  531. const idx = $(this).find('.acc-btn').attr('data-groupid');
  532. const type = $(this).find('.acc-btn').attr('data-type');
  533. if (type === 'hide') {
  534. $(this).parent().find(`div[data-toggleid="${idx}"]`).show(() => {
  535. $(this).children().find('i').removeClass('fa-plus-square').addClass('fa-minus-square-o');
  536. $(this).find('.acc-btn').attr('data-type', 'show');
  537. })
  538. } else {
  539. $(this).parent().find(`div[data-toggleid="${idx}"]`).hide(() => {
  540. $(this).children().find('i').removeClass('fa-minus-square-o').addClass('fa-plus-square');
  541. $(this).find('.acc-btn').attr('data-type', 'hide');
  542. })
  543. }
  544. return false;
  545. });
  546. // 选中用户
  547. $('body').on('click', '#add_user_dropdownMenu2 dl dd', function (e) {
  548. const id = parseInt($(this).data('id'));
  549. if (id) {
  550. const user = _.find(accountList, function (item) {
  551. return item.id === id;
  552. });
  553. const type = $('#add_user_dropdownMenuButton').attr('data-type');
  554. if (type === 'tourist') {
  555. const saIdList = [];
  556. for (let i = 0; i < $('#tourist-users tr').length; i++) {
  557. saIdList.push(parseInt($('#tourist-users tr').eq(i).data('uid')));
  558. }
  559. if (_.includes(saIdList, id)) {
  560. toastr.error('该用户已存在列表中,无需重复添加');
  561. e.stopPropagation();
  562. return;
  563. }
  564. const prop = {
  565. user_id: id,
  566. type: 'add',
  567. };
  568. postData('/tender/' + cur_tenderid + '/tourist/audit/save', prop, function (data) {
  569. selectedUserIdsByType.tourist.push(id);
  570. const html = `<tr data-uid="${user.id}" data-id="${data.id}">
  571. <td>${user.name}</td>
  572. <td>${user.role}</td>
  573. <td class="text-center">
  574. <div class="custom-control custom-checkbox mb-2">
  575. <input type="checkbox" id="${data.id}_file" data-id="${data.id}" name="file" class="custom-control-input set-tourist-permission">
  576. <label class="custom-control-label" for="${data.id}_file"></label>
  577. </div>
  578. </td>
  579. <td class="text-center">
  580. <div class="custom-control custom-checkbox mb-2">
  581. <input type="checkbox" id="${data.id}_tag" data-id="${data.id}" name="tag" class="custom-control-input set-tourist-permission">
  582. <label class="custom-control-label" for="${data.id}_tag"></label>
  583. </div>
  584. </td>
  585. <td class="text-center">
  586. <a href="#remove-user1" data-id="${data.id}" data-show-id="${user.id}" data-toggle="modal" data-target="#remove-user" class="btn btn-sm btn-outline-danger remove-tourist-user">移除</a>
  587. </td>
  588. </tr>`;
  589. $('#tourist-users').append(html);
  590. updateSelectedMarks();
  591. });
  592. } else if (type === 'schedule') {
  593. const user = _.find(accountList, function (item) {
  594. return item.id === id;
  595. });
  596. const saIdList = [];
  597. for (let i = 0; i < $('#schedule-users tr').length; i++) {
  598. saIdList.push(parseInt($('#schedule-users tr').eq(i).data('uid')));
  599. }
  600. if (_.includes(saIdList, id)) {
  601. toastr.error('该用户已存在列表中,无需重复添加');
  602. return;
  603. }
  604. const prop = {
  605. audit_id: id,
  606. type: 'add',
  607. };
  608. postData('/tender/' + cur_tenderid + '/schedule/audit/save', prop, function (data) {
  609. selectedUserIdsByType.schedule.push(user.id);
  610. const html = `<tr data-uid="${user.id}" data-id="${data.id}">
  611. <td>${user.name}</td>
  612. <td>${user.role}</td>
  613. <td class="text-center">
  614. <div class="custom-control custom-checkbox mb-2">
  615. <input type="checkbox" data-zhi="${scPermission.show}" data-id="${data.id}" id="${data.id}_customRadio41" name="customCheckbox" class="custom-control-input" checked>
  616. <label class="custom-control-label" for="${data.id}_customRadio41"></label>
  617. </div>
  618. </td>
  619. <td class="text-center">
  620. <div class="custom-control custom-checkbox mb-2">
  621. <input type="checkbox" data-zhi="${scPermission.edit}" data-id="${data.id}" id="${data.id}_customRadio42" name="customCheckbox" class="custom-control-input">
  622. <label class="custom-control-label" for="${data.id}_customRadio42"></label>
  623. </div>
  624. </td>
  625. <td class="text-center">
  626. <a href="#remove-user1" data-id="${data.id}" data-show-id="${user.id}" data-toggle="modal" data-target="#remove-user" class="btn btn-sm btn-outline-danger remove-schedule-user">移除</a>
  627. </td>
  628. </tr>`;
  629. $('#schedule-users').append(html);
  630. updateSelectedMarks();
  631. });
  632. } else if (type === 'contract') {
  633. const user = _.find(accountList, function (item) {
  634. return item.id === id;
  635. });
  636. const saIdList = [];
  637. for (let i = 0; i < $('#contract-users tr').length; i++) {
  638. saIdList.push(parseInt($('#contract-users tr').eq(i).data('uid')));
  639. }
  640. if (_.includes(saIdList, id)) {
  641. toastr.error('该用户已存在列表中,无需重复添加');
  642. return;
  643. }
  644. const prop = {
  645. id: id,
  646. type: 'add-audit',
  647. };
  648. postData('/sp/' + spid + '/contract/tender/' + cur_tenderid + '/audit/save', prop, function (datas) {
  649. setContractHtml(datas);
  650. });
  651. } else if (type === 'construction') {
  652. const user = _.find(accountList, function (item) {
  653. return item.id === id;
  654. });
  655. const saIdList = [];
  656. for (let i = 0; i < $('#construction-users tr').length; i++) {
  657. saIdList.push(parseInt($('#construction-users tr').eq(i).data('uid')));
  658. }
  659. if (_.includes(saIdList, id)) {
  660. toastr.error('该用户已存在列表中,无需重复添加');
  661. return;
  662. }
  663. const prop = {
  664. id: id,
  665. type: 'add-audit',
  666. };
  667. postData('/sp/' + spid + '/construction/' + cur_tenderid + '/audit/save', prop, function (datas) {
  668. setConstructionHtml(datas);
  669. });
  670. } else if (_.includes(tenderPermissionKeys, type)) {
  671. const user = _.find(accountList, function (item) {
  672. return item.id === id;
  673. });
  674. const saIdList = [];
  675. for (let i = 0; i < $('#' + type + '-users tr').length; i++) {
  676. saIdList.push(parseInt($('#' + type + '-users tr').eq(i).data('uid')));
  677. }
  678. if (_.includes(saIdList, id)) {
  679. toastr.error('该用户已存在列表中,无需重复添加');
  680. return;
  681. }
  682. const prop = {
  683. id: id,
  684. type: 'add-audit',
  685. key: type,
  686. };
  687. postData('/sp/' + spid + '/quality/' + cur_tenderid + '/audit/save', prop, function (datas) {
  688. setTenderPermissionHtml(datas, type);
  689. });
  690. } else if (_.includes(Object.keys(tPsKeys), type)) {
  691. const saIdList = [];
  692. for (let i = 0; i < $('#' + type + '-users tr').length; i++) {
  693. saIdList.push(parseInt($('#' + type + '-users tr').eq(i).data('uid')));
  694. }
  695. if (_.includes(saIdList, id)) {
  696. toastr.error('该用户已存在列表中,无需重复添加');
  697. return;
  698. }
  699. const prop = {
  700. id: id,
  701. type: 'add-audit',
  702. key: type,
  703. together: 1,
  704. };
  705. postData('/sp/' + spid + '/quality/' + cur_tenderid + '/audit/save', prop, function (datas) {
  706. setTenderPermissionsHtml(datas, type, tPsKeys[type]);
  707. });
  708. }
  709. }
  710. e.stopPropagation();
  711. });
  712. sortCategory4User();
  713. initTenderTree4User();
  714. getFilterTenderTreeHtml();
  715. $('#set-other-tender-user-a').click(function () {
  716. if(!cur_tenderid) {
  717. toastr.warning('未选中标段无法设置');
  718. return;
  719. }
  720. const userType = $('#add_user_dropdownMenuButton').attr('data-type');
  721. const saIdList = [];
  722. for (let i = 0; i < $('#'+ userType +'-users tr').length; i++) {
  723. saIdList.push(parseInt($('#'+ userType +'-users tr').eq(i).data('uid')));
  724. }
  725. if (saIdList.length > 0) {
  726. $('#bdcopy').modal('show');
  727. } else {
  728. toastr.warning('未存在'+ tabTypes[userType] +'用户账号,无法应用至其他标段');
  729. return;
  730. }
  731. });
  732. $('#bdcopy').on('show.bs.modal', function () {
  733. const html = getTenderTreeHtml4User();
  734. $('#tender-list-4user').html(html);
  735. $('#search-tender').val('');
  736. $('#search-tender-result').text('0/0');
  737. $('#up-tender-search').attr('disabled', true);
  738. $('#down-tender-search').attr('disabled', true);
  739. setTimeout(function () { $('#tender-list-4user').scrollTop(0); },500);
  740. });
  741. let timer4SearchTender = null;
  742. let oldSearchVal4SearchTender = null;
  743. $('body').on('input propertychange', '#bdcopy input[name="tender-name"]', function(e) {
  744. oldSearchVal4SearchTender = e.target.value;
  745. timer4SearchTender && clearTimeout(timer4SearchTender);
  746. timer4SearchTender = setTimeout(() => {
  747. const newVal = $(this).val();
  748. const resultLength = $('#tender-list-4user').find('.result').length;
  749. if (resultLength > 0) {
  750. let content = $('#tender-list-4user').html();
  751. const replaceStr = $('#tender-list-4user').find('.result').eq(0).html();
  752. const regExp2 = new RegExp('<span class="result" style="background: yellow;">' + replaceStr + '</span>', 'g');
  753. content = content.replace(regExp2, replaceStr);
  754. const regExp3 = new RegExp('<span class="result" style="background: orange;">' + replaceStr + '</span>', 'g');
  755. content = content.replace(regExp3, replaceStr);
  756. $('#tender-list-4user').html(content);
  757. }
  758. $('#search-tender-result').text('0/0');
  759. $('#up-tender-search').attr('disabled', true);
  760. $('#down-tender-search').attr('disabled', true);
  761. if (newVal && newVal === oldSearchVal4SearchTender) {
  762. const regExp = new RegExp(newVal, 'g');
  763. for (let i = 0; i < $('#tender-list-4user tr').length; i++) {
  764. if (_.includes($('#tender-list-4user tr').eq(i).children('td').eq(0).children('a').html(), newVal)) {
  765. $('#tender-list-4user tr').eq(i).children('td').eq(0).children('a').html($('#tender-list-4user tr').eq(i).children('td').eq(0).children('a').html().replace(regExp, '<span class="result" style="background: yellow;">' + newVal + '</span>'))
  766. }
  767. }
  768. const resultLength2 = $('#tender-list-4user').find('.result').length;
  769. if (resultLength2 > 0) {
  770. $('#tender-list-4user').find('.result').eq(0).css('background', 'orange');
  771. $('#search-tender-result').text('1/' + resultLength2);
  772. $('#up-tender-search').attr('disabled', false);
  773. $('#down-tender-search').attr('disabled', false);
  774. }
  775. }
  776. if($('#tender-list-4user').find('.result').length > 0) {
  777. const X = $('#tender-list-4user').find('.result').eq(0).offset().top;
  778. $('#tender-list-4user').scrollTop(X - $('#tender-list-4user').offset().top + $('#tender-list-4user').scrollTop() - 30);
  779. }
  780. }, 400);
  781. });
  782. $('#up-tender-search').on('click', function () {
  783. const cur = parseInt($('#search-tender-result').text().split('/')[0]);
  784. const total = parseInt($('#search-tender-result').text().split('/')[1]);
  785. const now = cur - 1 !== 0 ? cur - 1: total;
  786. $('#tender-list-4user').find('.result').eq(cur-1).css('background', 'yellow');
  787. $('#tender-list-4user').find('.result').eq(now-1).css('background', 'orange');
  788. // $('#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;">'))
  789. // $('#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;">'))
  790. $('#search-tender-result').text(now + '/' + total);
  791. const X = $('#tender-list-4user').find('.result').eq(now-1).offset().top;
  792. $('#tender-list-4user').scrollTop(X - $('#tender-list-4user').offset().top + $('#tender-list-4user').scrollTop() - 30);
  793. });
  794. $('#down-tender-search').on('click', function () {
  795. const cur = parseInt($('#search-tender-result').text().split('/')[0]);
  796. const total = parseInt($('#search-tender-result').text().split('/')[1]);
  797. const now = cur + 1 > total ? 1: cur + 1;
  798. $('#tender-list-4user').find('.result').eq(cur-1).css('background', 'yellow');
  799. $('#tender-list-4user').find('.result').eq(now-1).css('background', 'orange');
  800. // $('#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;">'))
  801. // $('#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;">'))
  802. $('#search-tender-result').text(now + '/' + total);
  803. const X = $('#tender-list-4user').find('.result').eq(now-1).offset().top;
  804. $('#tender-list-4user').scrollTop(X - $('#tender-list-4user').offset().top + $('#tender-list-4user').scrollTop() -30);
  805. });
  806. $('#save-other-tender-user').click(function () {
  807. $(this).attr('disabled', true);
  808. const num = $('#tender-list-4user input:checked').length;
  809. if (num < 2) {
  810. toastr.warning('请选择需要应用同步的标段');
  811. $(this).attr('disabled', false);
  812. return;
  813. }
  814. const userType = $('#add_user_dropdownMenuButton').attr('data-type');
  815. const data = {
  816. type: 'copy2otu',
  817. tid: cur_tenderid,
  818. userType,
  819. };
  820. const saIdList = [];
  821. for (let i = 0; i < $('#'+ userType +'-users tr').length; i++) {
  822. const userData = {
  823. uid: parseInt($('#'+ userType +'-users tr').eq(i).data('uid')),
  824. }
  825. if (userType === 'tourist') {
  826. userData.permission = {
  827. file: $('#tourist-users tr').eq(i).find('input[type="checkbox"]').eq(0).is(':checked') ? 1 : 0,
  828. tag: $('#tourist-users tr').eq(i).find('input[type="checkbox"]').eq(1).is(':checked') ? 1 : 0,
  829. };
  830. } else if (userType === 'schedule') {
  831. let permission = scPermission.no;
  832. const _this = $('#schedule-users tr').eq(i).find('input[type="checkbox"]').eq(0);
  833. const _other = $('#schedule-users tr').eq(i).find('input[type="checkbox"]').eq(1);
  834. if (_this.is(':checked') && _other.is(':checked')) {
  835. permission = scPermission.edit;
  836. } else if (_this.is(':checked') && !_other.is(':checked')) {
  837. permission = scPermission.show;
  838. }
  839. userData.permission = permission;
  840. } else if (userType === 'contract') {
  841. userData.permission = {
  842. add: $('#contract-users tr').eq(i).find('input[data-type="permission_add"]').eq(0).is(':checked') ? 1 : 0,
  843. edit: $('#contract-users tr').eq(i).find('input[data-type="permission_edit"]').eq(0).is(':checked') ? 1 : 0,
  844. edit_contract: $('#contract-users tr').eq(i).find('input[data-type="permission_edit_contract"]').eq(0).is(':checked') ? 1 : 0,
  845. add_pay: $('#contract-users tr').eq(i).find('input[data-type="permission_add_pay"]').eq(0).is(':checked') ? 1 : 0,
  846. showUnit: $('#contract-users tr').eq(i).find('input[data-type="permission_show_unit"]').eq(0).is(':checked') ? 1 : 0,
  847. showNode: $('#contract-users tr').eq(i).find('input[data-type="permission_show_node"]').eq(0).is(':checked') ? 1 : 0,
  848. }
  849. } else if (userType === 'construction') {
  850. userData.is_report = $('#construction-users tr').eq(i).find('input[type="checkbox"]').eq(0).is(':checked') ? 1 : 0;
  851. } else if (_.includes(tenderPermissionKeys, userType)) {
  852. userData.member = {};
  853. userData.member[userType] = [1];
  854. $('#'+ userType +'-users tr').eq(i).find('input[type="checkbox"]').each(function () {
  855. if ($(this).is(':checked')) {
  856. userData.member[userType].push(parseInt($(this).attr('data-value')));
  857. }
  858. });
  859. } else if (_.includes(Object.keys(tPsKeys), userType)) {
  860. userData.member = {};
  861. for (const key of tPsKeys[userType]) {
  862. userData.member[key] = [];
  863. $('#'+ userType +'-users tr').eq(i).find('input[data-key="' + key + '"]').each(function () {
  864. if ($(this).is(':checked')) {
  865. userData.member[key].push(parseInt($(this).attr('data-value')));
  866. }
  867. });
  868. }
  869. }
  870. saIdList.push(userData);
  871. }
  872. data.auditList = saIdList;
  873. // 获取已选中的标段
  874. const tenderList = [];
  875. for (let i = 0; i < num; i++) {
  876. const tid = parseInt($('#tender-list-4user input:checked').eq(i).data('tid'));
  877. if (tid !== cur_tenderid) {
  878. tenderList.push(tid);
  879. }
  880. }
  881. data.tidList = tenderList.join(',');
  882. // 请求获取右侧列表信息
  883. const _self = $(this);
  884. postData(`/sp/${spid}/setting/manage/tender/save`, data, function (result) {
  885. toastr.success('应用至其他标段成功');
  886. _self.attr('disabled', false);
  887. $('#bdcopy').modal('hide');
  888. }, function () {
  889. _self.attr('disabled', false);
  890. });
  891. });
  892. // 关联标段
  893. $('#select-tender').on('show.bs.modal', function () {
  894. $('#select-all-tender').prop('checked', false);
  895. postData(`/sp/${spid}/setting/manage/tender/save`, { type: 'noSp-tenders' }, function (result) {
  896. const html = [];
  897. for (const t of result) {
  898. html.push('<tr>');
  899. html.push('<td><a target="_blank" href="/tender/', t.id, '">', t.name, '</a></td>');
  900. html.push('<td>', t.user_name, '</td>');
  901. html.push('<td>', moment(t.create_time).format('YYYY-MM-DD'), '</td>');
  902. html.push('<td class="text-center">', '<input type="checkbox" data-tid="' + t.id + '">', '</td>');
  903. html.push('</tr>');
  904. }
  905. $('#no-project-tenders').html(html.join(''));
  906. });
  907. });
  908. $('#bind-sp-btn').click(function () {
  909. const num = $('#no-project-tenders input:checked').length;
  910. if (num < 1) {
  911. toastr.warning('请选择需要关联的标段');
  912. return;
  913. }
  914. const tidList = [];
  915. for (let i = 0; i < num; i++) {
  916. tidList.push($('#no-project-tenders input:checked').eq(i).data('tid'));
  917. }
  918. postData(`/sp/${spid}/setting/manage/tender/save`, { type: 'bind-sp', spid, tidList: tidList.join(',') }, function (result) {
  919. toastr.success('关联标段成功');
  920. $('#select-tender').modal('hide');
  921. setTimeout(function () {
  922. window.location.reload();
  923. }, 500);
  924. });
  925. });
  926. $('#select-all-tender').click(function () {
  927. const checked = $(this).is(':checked');
  928. $('#no-project-tenders input').prop('checked', checked);
  929. });
  930. // $('#change-sp').change(function () {
  931. // const spid = $(this).val();
  932. // console.log(spid);
  933. // postData(`/sp/${spid}/setting/manage/tender/save`, { type: 'get-category', spid }, function (result) {
  934. // $('#cate-list', '#edit-bd').html(getCategoryHtml(result));
  935. // const tender = _.find(tenders, { id: cur_tenderid });
  936. // if (tender && tender.spid === spid) {
  937. // for (const c of tender.category) {
  938. // // $('input[value=' + c.value + ']', '#edit-bd').prop('checked', 'checked');
  939. // $('option[value=' + c.value + ']', '#edit-bd').prop('selected', true);
  940. // }
  941. // }
  942. // });
  943. // })
  944. $('#filter-tender-ok').click(function() {
  945. const updateData = [];
  946. const tr = $('tr[tid]', '#filter-tender');
  947. for (const t of tr) {
  948. const data = { id: t.getAttribute('tid')};
  949. const checkes = $('input', t);
  950. for (const c of checkes) {
  951. data[c.getAttribute('data-type')] = c.checked ? 1 : 0;
  952. }
  953. updateData.push(data);
  954. }
  955. postData(`/sp/${spid}/list/batchUpdate`, updateData, function() {
  956. window.location.reload();
  957. });
  958. });
  959. $('#edit-bd').on('show.bs.modal', function () {
  960. const tree = new TreeSelect({
  961. element: '#tree-container',
  962. data: subProjects,
  963. selected: spid,
  964. onSelect: (id, label) => {
  965. const newSpid = id;
  966. console.log(newSpid);
  967. $('#change-sp').val(newSpid);
  968. postData(`/sp/${newSpid}/setting/manage/tender/save`, { type: 'get-category', spid: newSpid }, function (result) {
  969. $('#cate-list', '#edit-bd').html(getCategoryHtml(result));
  970. const tender = _.find(tenders, { id: cur_tenderid });
  971. if (tender && tender.spid === newSpid) {
  972. for (const c of tender.category) {
  973. // $('input[value=' + c.value + ']', '#edit-bd').prop('checked', 'checked');
  974. $('option[value=' + c.value + ']', '#edit-bd').prop('selected', true);
  975. }
  976. }
  977. });
  978. // console.log('选中了:', id, label);
  979. }
  980. });
  981. });
  982. });
  983. const tenderListSpec = (function(){
  984. function getTenderTreeHeaderHtml() {
  985. const html = [];
  986. html.push('<table class="table table-hover table-bordered">');
  987. html.push('<thead style="position: sticky;left:176px;top: 0;">', '<tr>');
  988. html.push('<th class="text-center" style="width: 80%">', '标段名称', '</th>');
  989. html.push('<th class="text-center" style="width: 20%">', '创建人', '</th>');
  990. html.push('</tr>', '</thead>');
  991. return html.join('');
  992. }
  993. function getTenderNodeHtml(node, arr, pid) {
  994. const html = [];
  995. html.push('<tr pid="' + pid + '"', (node.cid ? '' : 'class="tender-info" data-id="'+ node.id +'"'), '>');
  996. // 名称
  997. html.push('<td style="width: 80%" class="in-' + node.level + '"' + (node.cid ? '' : 'tid="' + node.id + '"') + '>');
  998. if (node.cid) {
  999. html.push('<span onselectstart="return false" style="{-moz-user-select:none}" class="fold-switch mr-1" title="收起" cid="'+ node.sort_id +'"><i class="fa fa-minus-square-o"></i></span> <i class="fa fa-folder-o"></i> ');
  1000. html.push((node.level === 1 ? '<b>' : ''), node.name, (node.level === 1 ? '</b>' : ''));
  1001. } else {
  1002. html.push('<div class="d-flex justify-content-between align-items-center">');
  1003. html.push('<div>');
  1004. html.push('<span class="text-muted mr-2">');
  1005. html.push(arr.indexOf(node) === arr.length - 1 ? '└' : '├');
  1006. html.push('</span>');
  1007. //html.push('<a href="/tender/' + node.id + '">', node[c.field], '</a>');
  1008. html.push('<a href="javascript: void(0)" id="' + node.id + '" name="name">', node.name, '</a>');
  1009. html.push('</div>');
  1010. html.push('<div class="btn-group-table" tid="' + node.id + '">');
  1011. html.push('<a href="javascript:void(0);" name="edit" class="mr-1"><i class="fa fa-pencil fa-fw"></i></a>');
  1012. const hasStage = node.progress ? (node.stage_count > 0 ? true : node.stage_status !== 0) : !!node.lastStage;
  1013. if (!hasStage) {
  1014. html.push('<a href="javascript:void(0);" name="del" class="mr-1"><i class="fa fa-trash-o fa-fw text-danger"></i></a>');
  1015. } else {
  1016. html.push('<a href="javascript:void(0);" data-toggle="tooltip" title="请先删除所有期" class="mr-1"><i class="fa fa-trash-o fa-fw text-secondary"></i></a>');
  1017. }
  1018. html.push('</div></div>');
  1019. }
  1020. html.push('</td>');
  1021. // 创建人
  1022. html.push('<td style="width: 20%" class="text-center">', node.user_name ? node.user_name : '', '</td>');
  1023. html.push('</tr>');
  1024. return html.join('');
  1025. }
  1026. return { getTenderNodeHtml, getTenderTreeHeaderHtml }
  1027. })();
  1028. function updateSelectedMarks(forcedType = null) {
  1029. let currentUserListSelector = '';
  1030. let selectedIdsArray = [];
  1031. let currentType = forcedType;
  1032. if (!currentType) {
  1033. const $activeTabPane = $('.tab-pane.active');
  1034. const activeTabId = $activeTabPane.attr('id');
  1035. switch(activeTabId) {
  1036. case 'guest': currentType = 'tourist'; break;
  1037. case 'tzpro': currentType = 'schedule'; break;
  1038. case 'htgl': currentType = 'contract'; break;
  1039. case 'sgrz': currentType = 'construction'; break;
  1040. case 'zlgl': currentType = 'quality'; break;
  1041. case 'zlxj': currentType = 'inspection'; break;
  1042. default: currentType = null;
  1043. }
  1044. }
  1045. if (currentType && selectedUserIdsByType.hasOwnProperty(currentType)) {
  1046. switch(currentType) {
  1047. case 'tourist': currentUserListSelector = '#tourist-users'; break;
  1048. case 'schedule': currentUserListSelector = '#schedule-users'; break;
  1049. case 'contract': currentUserListSelector = '#contract-users'; break;
  1050. case 'construction': currentUserListSelector = '#construction-users'; break;
  1051. case 'quality': currentUserListSelector = '#quality-users'; break;
  1052. case 'inspection': currentUserListSelector = '#inspection-users'; break;
  1053. }
  1054. selectedIdsArray = selectedUserIdsByType[currentType];
  1055. } else {
  1056. $('.user-item').find('.selected-mark').hide();
  1057. $('.user-item').removeClass('bg-light');
  1058. return;
  1059. }
  1060. if ($('#add_user_dropdownMenu2 .book-list').length > 0) {
  1061. $('.user-item').each(function() {
  1062. const userIdStr = $(this).data('id');
  1063. const userId = parseInt(userIdStr, 10);
  1064. const $mark = $(this).find('.selected-mark');
  1065. if (!isNaN(userId) && selectedIdsArray.includes(userId)) {
  1066. $mark.show();
  1067. $(this).addClass('bg-light');
  1068. } else {
  1069. $mark.hide();
  1070. $(this).removeClass('bg-light');
  1071. }
  1072. });
  1073. }
  1074. }
  1075. function setShenpiHtml(shenpi, tender, revising) {
  1076. let html = '';
  1077. if (shenpi.sp_lc.length > 0) {
  1078. for (const sp of shenpi.sp_lc) {
  1079. html += `<div class="card mb-3">
  1080. <div class="card-body ${sp.code}_div">
  1081. <a class="pull-right set-otherTender" data-name="${sp.name}" data-code="${sp.code}" href="#batch" data-toggle="modal" data-target="#batch">设置其他标段</a>
  1082. <a class="pull-right set-otherShenpi mr-3" data-name="${sp.name}" data-code="${sp.code}" href="javascript: void(0);">设置其他流程</a>`;
  1083. if (sp.code === 'stage' && !revising && tender.ledger_status === auditConst.ledger.status.checked) {
  1084. html += `<a class="pull-right mr-3" id="stage_cooperation" ${sp.status !== shenpi.sp_status.gdspl ? 'style="display: none"' : '' } data-name="${sp.name}" data-code="${sp.code}" href="#cooperation" data-toggle="modal" data-target="#cooperation">多人协同 <i class="fa fa-lock"></i></a>`;
  1085. }
  1086. html += `
  1087. <h5 class="card-title">${sp.name}</h5>
  1088. <div class="form-group">
  1089. <div class="form-group form-check">`;
  1090. for (const st in shenpi.sp_status_list) {
  1091. if (shenpi.sp_status_list[st]) {
  1092. html += `<div class="custom-control custom-checkbox custom-control-inline">
  1093. <input type="radio" class="custom-control-input" data-code="${sp.code}" value="${shenpi.sp_status_list[st].status}" name="${sp.code}" id="${sp.code}_${shenpi.sp_status_list[st].status}" ${sp.status === shenpi.sp_status_list[st].status ? 'checked' : ''}>
  1094. <label class="custom-control-label" for="${sp.code}_${shenpi.sp_status_list[st].status}">${shenpi.sp_status_list[st].name}</label>
  1095. </div>`;
  1096. }
  1097. }
  1098. html += `
  1099. </div>
  1100. </div>
  1101. <div class="alert alert-warning">${shenpi.sp_status_list[sp.status].name}:${shenpi.sp_status_list[sp.status].msg}</div>
  1102. <div class="lc-show">`;
  1103. if (sp.status === sp_status.sqspr) {
  1104. html += ``;
  1105. } else if (sp.status === sp_status.gdspl) {
  1106. const flow = sp_lc.find(x => { return x.code === sp.code; });
  1107. flow.auditGroupList = sp.auditGroupList;
  1108. html += auditUtils.getGroupHtml(flow, sp.code);
  1109. let addhtml = '<ul class="list-unstyled">\n';
  1110. addhtml += auditUtils.getgdsplHtml(flow, sp.code);
  1111. addhtml += '</ul>\n';
  1112. html += addhtml;
  1113. } else if (sp.status === sp_status.gdzs) {
  1114. let addhtml = '<ul class="list-unstyled">\n' +
  1115. ' <li class="d-flex justify-content-start mb-3">\n' +
  1116. ' <span class="col-auto">授权审批人</span>\n' +
  1117. ' <span class="col-7">\n' +
  1118. ' <span class="d-inline-block"></span>\n' +
  1119. ' </span>\n' +
  1120. ' </li>\n';
  1121. addhtml += sp.audit ? makeAudit(sp.audit) : makeSelectAudit(sp.code);
  1122. addhtml += '</ul>\n';
  1123. html += addhtml;
  1124. }
  1125. html += ` </div>
  1126. </div>
  1127. </div>`;
  1128. }
  1129. }
  1130. $('#splc').html(html);
  1131. }
  1132. let selectedUserIdsByType = {
  1133. tourist: [],
  1134. schedule: [],
  1135. contract: [],
  1136. construction: [],
  1137. quality: [],
  1138. inspection: []
  1139. };
  1140. function setTouristHtml(tourists) {
  1141. let html = '';
  1142. if (tourists.length > 0) {
  1143. for (const t of tourists) {
  1144. html += `<tr data-uid="${t.user_id}" data-id="${t.id}">
  1145. <td>${t.user_name}</td>
  1146. <td>${t.user_role}</td>
  1147. <td class="text-center">
  1148. <div class="custom-control custom-checkbox mb-2">
  1149. <input type="checkbox" id="${t.id}_file" data-id="${t.id}" name="file" class="custom-control-input set-tourist-permission" ${t.permission.file ? 'checked' : ''}>
  1150. <label class="custom-control-label" for="${t.id}_file"></label>
  1151. </div>
  1152. </td>
  1153. <td class="text-center">
  1154. <div class="custom-control custom-checkbox mb-2">
  1155. <input type="checkbox" id="${t.id}_tag" data-id="${t.id}" name="tag" class="custom-control-input set-tourist-permission" ${t.permission.tag ? 'checked' : ''}>
  1156. <label class="custom-control-label" for="${t.id}_tag"></label>
  1157. </div>
  1158. </td>
  1159. <td class="text-center">
  1160. <a href="#remove-user1" data-id="${t.id}" data-show-id="${t.user_id}" data-toggle="modal" data-target="#remove-user" class="btn btn-sm btn-outline-danger remove-tourist-user">移除</a>
  1161. </td>
  1162. </tr>`;
  1163. }
  1164. selectedUserIdsByType.tourist = [];
  1165. if (Array.isArray(tourists)) {
  1166. tourists.forEach(function(tourist) {
  1167. if (tourist.user_id !== undefined && tourist.user_id !== null) {
  1168. selectedUserIdsByType.tourist.push(parseInt(tourist.user_id, 10));
  1169. }
  1170. });
  1171. }
  1172. }
  1173. $('#tourist-users').html(html);
  1174. updateSelectedMarks();
  1175. }
  1176. function setScheduleHtml(scheduleAuditList) {
  1177. let html = '';
  1178. if (scheduleAuditList.length > 0) {
  1179. for (const sa of scheduleAuditList) {
  1180. const audit = _.find(accountList, { id: sa.audit_id });
  1181. html += `<tr data-uid="${sa.audit_id}" data-id="${sa.id}">
  1182. <td>${audit ? audit.name : ''}</td>
  1183. <td>${audit ? audit.role : ''}</td>
  1184. <td class="text-center">
  1185. <div class="custom-control custom-checkbox mb-2">
  1186. <input type="checkbox" data-zhi="${scPermission.show}" data-id="${sa.id}" id="${sa.id}_customRadio41" name="customCheckbox" class="custom-control-input" ${sa.permission !== scPermission.no ? 'checked' : ''}>
  1187. <label class="custom-control-label" for="${sa.id}_customRadio41"></label>
  1188. </div>
  1189. </td>
  1190. <td class="text-center">
  1191. <div class="custom-control custom-checkbox mb-2">
  1192. <input type="checkbox" data-zhi="${scPermission.edit}" data-id="${sa.id}" id="${sa.id}_customRadio42" name="customCheckbox" class="custom-control-input" ${sa.permission === scPermission.edit ? 'checked' : ''}>
  1193. <label class="custom-control-label" for="${sa.id}_customRadio42"></label>
  1194. </div>
  1195. </td>
  1196. <td class="text-center">
  1197. <a href="#remove-user1" data-id="${sa.id}" data-show-id="${sa.user_id}" data-toggle="modal" data-target="#remove-user" class="btn btn-sm btn-outline-danger remove-schedule-user">移除</a>
  1198. </td>
  1199. </tr>`;
  1200. }
  1201. if (Array.isArray(scheduleAuditList)) {
  1202. scheduleAuditList.forEach(function(sa) {
  1203. if (sa.audit_id !== undefined && sa.audit_id !== null) {
  1204. selectedUserIdsByType.schedule.push(parseInt(sa.audit_id, 10));
  1205. }
  1206. });
  1207. }
  1208. }
  1209. $('#schedule-users').html(html);
  1210. updateSelectedMarks();
  1211. }
  1212. function setContractHtml(datas) {
  1213. let list = '';
  1214. for (const ca of datas) {
  1215. list += `<tr data-uid="${ca.uid}" data-id="${ca.id}">
  1216. <td>${ca.name}</td>
  1217. <td>${ca.role}</td>
  1218. <td class="text-center">
  1219. <input type="checkbox" class="permission-checkbox" data-type="permission_edit" value="${ca.uid}" ${ca.permission_edit ? 'checked' : ''}>
  1220. </td>
  1221. <td class="text-center">
  1222. <input type="checkbox" class="permission-checkbox" data-type="permission_add" value="${ca.uid}" ${ca.permission_add ? 'checked' : ''}>
  1223. </td>
  1224. <td class="text-center">
  1225. <input type="checkbox" class="permission-checkbox" data-type="permission_edit_contract" value="${ca.uid}" ${ca.permission_edit_contract ? 'checked' : ''}>
  1226. </td>
  1227. <td class="text-center">
  1228. <input type="checkbox" class="permission-checkbox" data-type="permission_add_pay" value="${ca.uid}" ${ca.permission_add_pay ? 'checked' : ''}>
  1229. </td>
  1230. <td class="text-center">
  1231. <input type="checkbox" class="permission-checkbox" data-type="permission_show_unit" value="${ca.uid}" ${ca.permission_show_unit ? 'checked' : ''}>
  1232. </td>
  1233. <td class="text-center">
  1234. <input type="checkbox" class="permission-checkbox" data-type="permission_show_node" value="${ca.uid}" ${ca.permission_show_node ? 'checked' : ''}>
  1235. </td>
  1236. <td class="text-center">
  1237. <a href="#remove-user1" data-show-id="${ca.uid}" data-toggle="modal" data-target="#remove-user" class="btn btn-outline-danger btn-sm ml-1 remove-contract-user" data-id="${ca.uid}">移除</a>
  1238. </td>
  1239. </tr>`;
  1240. }
  1241. if (Array.isArray(datas)) {
  1242. datas.forEach(function(ca) {
  1243. if (ca.uid !== undefined && ca.uid !== null) {
  1244. selectedUserIdsByType.contract.push(parseInt(ca.uid, 10));
  1245. }
  1246. });
  1247. }
  1248. $('#contract-users').html(list);
  1249. updateSelectedMarks();
  1250. }
  1251. function setConstructionHtml(constructionAuditList) {
  1252. let html = '';
  1253. if (constructionAuditList.length > 0) {
  1254. for (const sa of constructionAuditList) {
  1255. html += `<tr data-uid="${sa.uid}" data-id="${sa.id}">
  1256. <td>${sa.name}</td>
  1257. <td>${sa.role}</td>
  1258. <td class="text-center">
  1259. <div class="custom-control custom-checkbox mb-2">
  1260. <input type="checkbox" data-id="${sa.id}" id="${sa.id}_construction" name="customCheckbox" class="custom-control-input" ${sa.is_report ? 'checked' : ''}>
  1261. <label class="custom-control-label" for="${sa.id}_construction"></label>
  1262. </div>
  1263. </td>
  1264. <td class="text-center">
  1265. <a href="#remove-user1" data-show-id="${sa.uid}" data-id="${sa.id}" data-toggle="modal" data-target="#remove-user" class="btn btn-sm btn-outline-danger remove-construction-user">移除</a>
  1266. </td>
  1267. </tr>`;
  1268. }
  1269. if (Array.isArray(constructionAuditList)) {
  1270. constructionAuditList.forEach(function(sa) {
  1271. if (sa.uid !== undefined && sa.uid !== null) {
  1272. selectedUserIdsByType.construction.push(parseInt(sa.uid, 10));
  1273. }
  1274. });
  1275. }
  1276. }
  1277. $('#construction-users').html(html);
  1278. updateSelectedMarks();
  1279. }
  1280. function setTenderPermissionsHtml(auditList, key, keys) {
  1281. const html = [];
  1282. for (const m of auditList) {
  1283. html.push(getUserPermissionsHtml(m, key, keys));
  1284. }
  1285. $('#' + key + '-users').html(html.join(''));
  1286. }
  1287. const getUserPermissionsHtml = function(user, key, keys) {
  1288. const html = [];
  1289. html.push(`<tr data-uid="${user.uid}" data-id="${user.id}">`);
  1290. html.push(`<td>${user.name}</td>`, `<td>${user.role}</td>`);
  1291. const block = _.find(permissionBlock, { key: key });
  1292. for (const block of permissionBlock) {
  1293. if (keys.indexOf(block.key) < 0) continue;
  1294. for (const p of block.permission) {
  1295. const checked = user[block.key] ? (user[block.key].indexOf(p.value) >= 0 ? 'checked' : '') : '';
  1296. html.push(`<td class="text-center"><input type="checkbox" data-key="${block.key}" data-block="${p.key}" data-value="${p.value}" ${checked}></td>`);
  1297. }
  1298. }
  1299. html.push(`<td class="text-center"><a href="#remove-user1" data-id="${user.uid}" data-toggle="modal" data-target="#remove-user" class="btn btn-sm btn-outline-danger remove-${key}-user">移除</a></td>`);
  1300. html.push('</tr>');
  1301. return html.join('');
  1302. };
  1303. function setTenderPermissionHtml(auditList, key) {
  1304. const html = [];
  1305. for (const m of auditList) {
  1306. html.push(getUserPermissionHtml(m, key));
  1307. }
  1308. if (Array.isArray(auditList)) {
  1309. auditList.forEach(function(sa) {
  1310. if (sa.uid !== undefined && sa.uid !== null) {
  1311. selectedUserIdsByType[key].push(parseInt(sa.uid, 10));
  1312. }
  1313. });
  1314. }
  1315. $('#' + key + '-users').html(html.join(''));
  1316. updateSelectedMarks();
  1317. }
  1318. const getUserPermissionHtml = function(user, key) {
  1319. const html = [];
  1320. html.push(`<tr data-uid="${user.uid}" data-id="${user.id}">`);
  1321. html.push(`<td>${user.name}</td>`, `<td>${user.role}</td>`);
  1322. const block = _.find(permissionBlock, { key: key });
  1323. for (const p of block.permission) {
  1324. if (p.isDefault) continue;
  1325. const checked = user[block.key] ? (user[block.key].indexOf(p.value) >= 0 ? 'checked' : '') : '';
  1326. html.push(`<td class="text-center"><input type="checkbox" data-block="${p.key}" data-value="${p.value}" ${checked}></td>`);
  1327. }
  1328. html.push(`<td class="text-center"><a href="#remove-user1" data-show-id="${user.uid}" data-id="${user.uid}" data-toggle="modal" data-target="#remove-user" class="btn btn-sm btn-outline-danger remove-${key}-user">移除</a></td>`);
  1329. html.push('</tr>');
  1330. return html.join('');
  1331. };