setting_manage.js 68 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401
  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 = ['schedule'];
  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 === '#quality') currentNavType = 'quality';
  259. else if (href === '#safe') currentNavType = 'safe';
  260. if(currentNavType) {
  261. setTimeout(() => updateSelectedMarks(), 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. selectedUserIdsByType[type] = selectedUserIdsByType[type].filter(function(userId) {
  424. return userId !== showId;
  425. });
  426. updateSelectedMarks();
  427. });
  428. } else if (_.includes(tenderPermissionKeys, type)) {
  429. postData('/sp/' + spid + '/quality/' + cur_tenderid + '/audit/save', { type: 'del-audit', id, key: type }, function (data) {
  430. $('#'+ type + '-users').find('tr[data-uid="'+ id +'"]').remove();
  431. $('#remove-user').modal('hide');
  432. selectedUserIdsByType[type] = selectedUserIdsByType[type].filter(function(userId) {
  433. return userId !== showId;
  434. });
  435. updateSelectedMarks();
  436. });
  437. } else if (_.includes(Object.keys(tPsKeys), type)) {
  438. postData('/sp/' + spid + '/quality/' + cur_tenderid + '/audit/save', { type: 'del-audit', id, key: type, together: 1 }, function (data) {
  439. $('#'+ type + '-users').find('tr[data-uid="'+ id +'"]').remove();
  440. $('#remove-user').modal('hide');
  441. selectedUserIdsByType[type] = selectedUserIdsByType[type].filter(function(userId) {
  442. return userId !== showId;
  443. });
  444. updateSelectedMarks();
  445. });
  446. } else {
  447. const prop = {
  448. id: id,
  449. type: 'del',
  450. };
  451. postData('/tender/' + cur_tenderid + '/' + type + '/audit/save', prop, function (data) {
  452. $('#'+ type + '-users').find('tr[data-id="'+ id +'"]').remove();
  453. $('#remove-user').modal('hide');
  454. selectedUserIdsByType[type] = selectedUserIdsByType[type].filter(function(userId) {
  455. return userId !== showId;
  456. });
  457. updateSelectedMarks();
  458. });
  459. }
  460. });
  461. // 投资进度
  462. let timerAddUser = null;
  463. let oldSearchValAddUser = null;
  464. $('body').on('input propertychange', '#add_user_dropdownMenu2 .gr-search', function (e) {
  465. const currentDropdownType = $('#add_user_dropdownMenuButton').attr('data-type');
  466. let currentSelectedIdsForType = [];
  467. if (currentDropdownType && selectedUserIdsByType.hasOwnProperty(currentDropdownType)) {
  468. currentSelectedIdsForType = selectedUserIdsByType[currentDropdownType]; // 获取对应类型的ID数组
  469. }
  470. oldSearchValAddUser = e.target.value;
  471. timerAddUser && clearTimeout(timerAddUser);
  472. timerAddUser = setTimeout(() => {
  473. const newVal = $(this).val();
  474. if (newVal && newVal === oldSearchValAddUser) {
  475. let html = '';
  476. accountList.filter(item => item && item.id !== cur_uid && (item.name.indexOf(newVal) !== -1 || (item.mobile && item.mobile.indexOf(newVal) !== -1))).forEach(item => {
  477. const itemIdInt = parseInt(item.id, 10);
  478. const isSelected = currentSelectedIdsForType.includes(itemIdInt);
  479. const selectedMarkStyle = isSelected ? '' : ' style="display:none;"';
  480. html += `<dd class="border-bottom p-2 mb-0 user-item" data-id="${item.id}" >
  481. <p class="mb-0 d-flex"><span class="text-primary">${item.name}</span><span
  482. class="ml-auto">${item.mobile || ''}</span>
  483. <span class="selected-mark text-success ml-2"${selectedMarkStyle}><i class="fa fa-check"></i></span>
  484. </p>
  485. <span class="text-muted">${item.role || ''}</span>
  486. </dd>`
  487. });
  488. $('#add_user_dropdownMenu2 .book-list').empty();
  489. $('#add_user_dropdownMenu2 .book-list').append(html);
  490. } else {
  491. if (!$('#add_user_dropdownMenu2 .acc-btn').length) {
  492. resetAddUserHtml();
  493. }
  494. }
  495. }, 400);
  496. });
  497. function resetAddUserHtml() {
  498. const currentDropdownType = $('#add_user_dropdownMenuButton').attr('data-type');
  499. let currentSelectedIdsForType = [];
  500. if (currentDropdownType && selectedUserIdsByType.hasOwnProperty(currentDropdownType)) {
  501. currentSelectedIdsForType = selectedUserIdsByType[currentDropdownType];
  502. }
  503. let html = '';
  504. accountGroup.forEach((group, idx) => {
  505. if (!group) return;
  506. html += `<dt><a href="javascript: void(0);" class="acc-btn" data-groupid="${idx}" data-type="hide"><i class="fa fa-plus-square"></i>
  507. </a> ${group.groupName}</dt>
  508. <div class="dd-content" data-toggleid="${idx}">`;
  509. group.groupList.forEach(item => {
  510. if (item.id !== cur_uid) {
  511. const itemIdInt = parseInt(item.id, 10);
  512. const isSelected = currentSelectedIdsForType.includes(itemIdInt);
  513. const selectedMarkStyle = isSelected ? '' : ' style="display:none;"';
  514. html += `<dd class="border-bottom p-2 mb-0 user-item" data-id="${item.id}" >
  515. <p class="mb-0 d-flex"><span class="text-primary">${item.name}</span><span
  516. class="ml-auto">${item.mobile || ''}</span>
  517. <span class="selected-mark text-success ml-2"${selectedMarkStyle}><i class="fa fa-check"></i></span>
  518. </p>
  519. <span class="text-muted">${item.role || ''}</span>
  520. </dd>`;
  521. }
  522. });
  523. html += '</div>';
  524. });
  525. $('#add_user_dropdownMenu2 .book-list').empty();
  526. $('#add_user_dropdownMenu2 .book-list').append(html);
  527. }
  528. // 添加审批流程按钮逻辑
  529. $('body').on('click', '#add_user_dropdownMenu2 .book-list dt', function () {
  530. const idx = $(this).find('.acc-btn').attr('data-groupid');
  531. const type = $(this).find('.acc-btn').attr('data-type');
  532. if (type === 'hide') {
  533. $(this).parent().find(`div[data-toggleid="${idx}"]`).show(() => {
  534. $(this).children().find('i').removeClass('fa-plus-square').addClass('fa-minus-square-o');
  535. $(this).find('.acc-btn').attr('data-type', 'show');
  536. })
  537. } else {
  538. $(this).parent().find(`div[data-toggleid="${idx}"]`).hide(() => {
  539. $(this).children().find('i').removeClass('fa-minus-square-o').addClass('fa-plus-square');
  540. $(this).find('.acc-btn').attr('data-type', 'hide');
  541. })
  542. }
  543. return false;
  544. });
  545. // 选中用户
  546. $('body').on('click', '#add_user_dropdownMenu2 dl dd', function (e) {
  547. const id = parseInt($(this).data('id'));
  548. if (id) {
  549. const user = _.find(accountList, function (item) {
  550. return item.id === id;
  551. });
  552. const type = $('#add_user_dropdownMenuButton').attr('data-type');
  553. if (type === 'tourist') {
  554. const saIdList = [];
  555. for (let i = 0; i < $('#tourist-users tr').length; i++) {
  556. saIdList.push(parseInt($('#tourist-users tr').eq(i).data('uid')));
  557. }
  558. if (_.includes(saIdList, id)) {
  559. toastr.error('该用户已存在列表中,无需重复添加');
  560. e.stopPropagation();
  561. return;
  562. }
  563. const prop = {
  564. user_id: id,
  565. type: 'add',
  566. };
  567. postData('/tender/' + cur_tenderid + '/tourist/audit/save', prop, function (data) {
  568. selectedUserIdsByType.tourist.push(id);
  569. const html = `<tr data-uid="${user.id}" data-id="${data.id}">
  570. <td>${user.name}</td>
  571. <td>${user.role}</td>
  572. <td class="text-center">
  573. <div class="custom-control custom-checkbox mb-2">
  574. <input type="checkbox" id="${data.id}_file" data-id="${data.id}" name="file" class="custom-control-input set-tourist-permission">
  575. <label class="custom-control-label" for="${data.id}_file"></label>
  576. </div>
  577. </td>
  578. <td class="text-center">
  579. <div class="custom-control custom-checkbox mb-2">
  580. <input type="checkbox" id="${data.id}_tag" data-id="${data.id}" name="tag" class="custom-control-input set-tourist-permission">
  581. <label class="custom-control-label" for="${data.id}_tag"></label>
  582. </div>
  583. </td>
  584. <td class="text-center">
  585. <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>
  586. </td>
  587. </tr>`;
  588. $('#tourist-users').append(html);
  589. updateSelectedMarks();
  590. });
  591. // } else if (type === 'schedule') {
  592. // const user = _.find(accountList, function (item) {
  593. // return item.id === id;
  594. // });
  595. // const saIdList = [];
  596. // for (let i = 0; i < $('#schedule-users tr').length; i++) {
  597. // saIdList.push(parseInt($('#schedule-users tr').eq(i).data('uid')));
  598. // }
  599. // if (_.includes(saIdList, id)) {
  600. // toastr.error('该用户已存在列表中,无需重复添加');
  601. // e.stopPropagation();
  602. // return;
  603. // }
  604. //
  605. // const prop = {
  606. // audit_id: id,
  607. // type: 'add',
  608. // };
  609. // postData('/tender/' + cur_tenderid + '/schedule/audit/save', prop, function (data) {
  610. // selectedUserIdsByType.schedule.push(user.id);
  611. // const html = `<tr data-uid="${user.id}" data-id="${data.id}">
  612. // <td>${user.name}</td>
  613. // <td>${user.role}</td>
  614. // <td class="text-center">
  615. // <div class="custom-control custom-checkbox mb-2">
  616. // <input type="checkbox" data-zhi="${scPermission.show}" data-id="${data.id}" id="${data.id}_customRadio41" name="customCheckbox" class="custom-control-input" checked>
  617. // <label class="custom-control-label" for="${data.id}_customRadio41"></label>
  618. // </div>
  619. // </td>
  620. // <td class="text-center">
  621. // <div class="custom-control custom-checkbox mb-2">
  622. // <input type="checkbox" data-zhi="${scPermission.edit}" data-id="${data.id}" id="${data.id}_customRadio42" name="customCheckbox" class="custom-control-input">
  623. // <label class="custom-control-label" for="${data.id}_customRadio42"></label>
  624. // </div>
  625. // </td>
  626. // <td class="text-center">
  627. // <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>
  628. // </td>
  629. // </tr>`;
  630. // $('#schedule-users').append(html);
  631. // updateSelectedMarks();
  632. // });
  633. } else if (type === 'contract') {
  634. const user = _.find(accountList, function (item) {
  635. return item.id === id;
  636. });
  637. const saIdList = [];
  638. for (let i = 0; i < $('#contract-users tr').length; i++) {
  639. saIdList.push(parseInt($('#contract-users tr').eq(i).data('uid')));
  640. }
  641. if (_.includes(saIdList, id)) {
  642. toastr.error('该用户已存在列表中,无需重复添加');
  643. e.stopPropagation();
  644. return;
  645. }
  646. const prop = {
  647. id: id,
  648. type: 'add-audit',
  649. };
  650. postData('/sp/' + spid + '/contract/tender/' + cur_tenderid + '/audit/save', prop, function (datas) {
  651. setContractHtml(datas);
  652. updateSelectedMarks();
  653. });
  654. } else if (type === 'construction') {
  655. const user = _.find(accountList, function (item) {
  656. return item.id === id;
  657. });
  658. const saIdList = [];
  659. for (let i = 0; i < $('#construction-users tr').length; i++) {
  660. saIdList.push(parseInt($('#construction-users tr').eq(i).data('uid')));
  661. }
  662. if (_.includes(saIdList, id)) {
  663. toastr.error('该用户已存在列表中,无需重复添加');
  664. e.stopPropagation();
  665. return;
  666. }
  667. const prop = {
  668. id: id,
  669. type: 'add-audit',
  670. };
  671. postData('/sp/' + spid + '/construction/' + cur_tenderid + '/audit/save', prop, function (datas) {
  672. setConstructionHtml(datas);
  673. });
  674. } else if (_.includes(tenderPermissionKeys, type)) {
  675. const user = _.find(accountList, function (item) {
  676. return item.id === id;
  677. });
  678. const saIdList = [];
  679. for (let i = 0; i < $('#' + type + '-users tr').length; i++) {
  680. saIdList.push(parseInt($('#' + type + '-users tr').eq(i).data('uid')));
  681. }
  682. if (_.includes(saIdList, id)) {
  683. toastr.error('该用户已存在列表中,无需重复添加');
  684. e.stopPropagation();
  685. return;
  686. }
  687. const prop = {
  688. id: id,
  689. type: 'add-audit',
  690. key: type,
  691. };
  692. postData('/sp/' + spid + '/quality/' + cur_tenderid + '/audit/save', prop, function (datas) {
  693. setTenderPermissionHtml(datas, type);
  694. });
  695. } else if (_.includes(Object.keys(tPsKeys), type)) {
  696. const saIdList = [];
  697. for (let i = 0; i < $('#' + type + '-users tr').length; i++) {
  698. saIdList.push(parseInt($('#' + type + '-users tr').eq(i).data('uid')));
  699. }
  700. if (_.includes(saIdList, id)) {
  701. toastr.error('该用户已存在列表中,无需重复添加');
  702. e.stopPropagation();
  703. return;
  704. }
  705. const prop = {
  706. id: id,
  707. type: 'add-audit',
  708. key: type,
  709. together: 1,
  710. };
  711. postData('/sp/' + spid + '/quality/' + cur_tenderid + '/audit/save', prop, function (datas) {
  712. setTenderPermissionsHtml(datas, type, tPsKeys[type]);
  713. });
  714. }
  715. }
  716. e.stopPropagation();
  717. });
  718. sortCategory4User();
  719. initTenderTree4User();
  720. getFilterTenderTreeHtml();
  721. $('#set-other-tender-user-a').click(function () {
  722. if(!cur_tenderid) {
  723. toastr.warning('未选中标段无法设置');
  724. return;
  725. }
  726. const userType = $('#add_user_dropdownMenuButton').attr('data-type');
  727. const saIdList = [];
  728. for (let i = 0; i < $('#'+ userType +'-users tr').length; i++) {
  729. saIdList.push(parseInt($('#'+ userType +'-users tr').eq(i).data('uid')));
  730. }
  731. if (saIdList.length > 0) {
  732. $('#bdcopy').modal('show');
  733. } else {
  734. toastr.warning('未存在'+ tabTypes[userType] +'用户账号,无法应用至其他标段');
  735. return;
  736. }
  737. });
  738. $('#bdcopy').on('show.bs.modal', function () {
  739. const html = getTenderTreeHtml4User();
  740. $('#tender-list-4user').html(html);
  741. $('#search-tender').val('');
  742. $('#search-tender-result').text('0/0');
  743. $('#up-tender-search').attr('disabled', true);
  744. $('#down-tender-search').attr('disabled', true);
  745. setTimeout(function () { $('#tender-list-4user').scrollTop(0); },500);
  746. });
  747. let timer4SearchTender = null;
  748. let oldSearchVal4SearchTender = null;
  749. $('body').on('input propertychange', '#bdcopy input[name="tender-name"]', function(e) {
  750. oldSearchVal4SearchTender = e.target.value;
  751. timer4SearchTender && clearTimeout(timer4SearchTender);
  752. timer4SearchTender = setTimeout(() => {
  753. const newVal = $(this).val();
  754. const resultLength = $('#tender-list-4user').find('.result').length;
  755. if (resultLength > 0) {
  756. let content = $('#tender-list-4user').html();
  757. const replaceStr = $('#tender-list-4user').find('.result').eq(0).html();
  758. const regExp2 = new RegExp('<span class="result" style="background: yellow;">' + replaceStr + '</span>', 'g');
  759. content = content.replace(regExp2, replaceStr);
  760. const regExp3 = new RegExp('<span class="result" style="background: orange;">' + replaceStr + '</span>', 'g');
  761. content = content.replace(regExp3, replaceStr);
  762. $('#tender-list-4user').html(content);
  763. }
  764. $('#search-tender-result').text('0/0');
  765. $('#up-tender-search').attr('disabled', true);
  766. $('#down-tender-search').attr('disabled', true);
  767. if (newVal && newVal === oldSearchVal4SearchTender) {
  768. const regExp = new RegExp(newVal, 'g');
  769. for (let i = 0; i < $('#tender-list-4user tr').length; i++) {
  770. if (_.includes($('#tender-list-4user tr').eq(i).children('td').eq(0).children('a').html(), newVal)) {
  771. $('#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>'))
  772. }
  773. }
  774. const resultLength2 = $('#tender-list-4user').find('.result').length;
  775. if (resultLength2 > 0) {
  776. $('#tender-list-4user').find('.result').eq(0).css('background', 'orange');
  777. $('#search-tender-result').text('1/' + resultLength2);
  778. $('#up-tender-search').attr('disabled', false);
  779. $('#down-tender-search').attr('disabled', false);
  780. }
  781. }
  782. if($('#tender-list-4user').find('.result').length > 0) {
  783. const X = $('#tender-list-4user').find('.result').eq(0).offset().top;
  784. $('#tender-list-4user').scrollTop(X - $('#tender-list-4user').offset().top + $('#tender-list-4user').scrollTop() - 30);
  785. }
  786. }, 400);
  787. });
  788. $('#up-tender-search').on('click', function () {
  789. const cur = parseInt($('#search-tender-result').text().split('/')[0]);
  790. const total = parseInt($('#search-tender-result').text().split('/')[1]);
  791. const now = cur - 1 !== 0 ? cur - 1: total;
  792. $('#tender-list-4user').find('.result').eq(cur-1).css('background', 'yellow');
  793. $('#tender-list-4user').find('.result').eq(now-1).css('background', 'orange');
  794. // $('#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;">'))
  795. // $('#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;">'))
  796. $('#search-tender-result').text(now + '/' + total);
  797. const X = $('#tender-list-4user').find('.result').eq(now-1).offset().top;
  798. $('#tender-list-4user').scrollTop(X - $('#tender-list-4user').offset().top + $('#tender-list-4user').scrollTop() - 30);
  799. });
  800. $('#down-tender-search').on('click', function () {
  801. const cur = parseInt($('#search-tender-result').text().split('/')[0]);
  802. const total = parseInt($('#search-tender-result').text().split('/')[1]);
  803. const now = cur + 1 > total ? 1: cur + 1;
  804. $('#tender-list-4user').find('.result').eq(cur-1).css('background', 'yellow');
  805. $('#tender-list-4user').find('.result').eq(now-1).css('background', 'orange');
  806. // $('#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;">'))
  807. // $('#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;">'))
  808. $('#search-tender-result').text(now + '/' + total);
  809. const X = $('#tender-list-4user').find('.result').eq(now-1).offset().top;
  810. $('#tender-list-4user').scrollTop(X - $('#tender-list-4user').offset().top + $('#tender-list-4user').scrollTop() -30);
  811. });
  812. $('#save-other-tender-user').click(function () {
  813. $(this).attr('disabled', true);
  814. const num = $('#tender-list-4user input:checked').length;
  815. if (num < 2) {
  816. toastr.warning('请选择需要应用同步的标段');
  817. $(this).attr('disabled', false);
  818. return;
  819. }
  820. const userType = $('#add_user_dropdownMenuButton').attr('data-type');
  821. const data = {
  822. type: 'copy2otu',
  823. tid: cur_tenderid,
  824. userType,
  825. };
  826. const saIdList = [];
  827. for (let i = 0; i < $('#'+ userType +'-users tr').length; i++) {
  828. const userData = {
  829. uid: parseInt($('#'+ userType +'-users tr').eq(i).data('uid')),
  830. }
  831. if (userType === 'tourist') {
  832. userData.permission = {
  833. file: $('#tourist-users tr').eq(i).find('input[type="checkbox"]').eq(0).is(':checked') ? 1 : 0,
  834. tag: $('#tourist-users tr').eq(i).find('input[type="checkbox"]').eq(1).is(':checked') ? 1 : 0,
  835. };
  836. // } else if (userType === 'schedule') {
  837. // let permission = scPermission.no;
  838. // const _this = $('#schedule-users tr').eq(i).find('input[type="checkbox"]').eq(0);
  839. // const _other = $('#schedule-users tr').eq(i).find('input[type="checkbox"]').eq(1);
  840. // if (_this.is(':checked') && _other.is(':checked')) {
  841. // permission = scPermission.edit;
  842. // } else if (_this.is(':checked') && !_other.is(':checked')) {
  843. // permission = scPermission.show;
  844. // }
  845. // userData.permission = permission;
  846. } else if (userType === 'contract') {
  847. userData.permission = {
  848. add: $('#contract-users tr').eq(i).find('input[data-type="permission_add"]').eq(0).is(':checked') ? 1 : 0,
  849. edit: $('#contract-users tr').eq(i).find('input[data-type="permission_edit"]').eq(0).is(':checked') ? 1 : 0,
  850. edit_contract: $('#contract-users tr').eq(i).find('input[data-type="permission_edit_contract"]').eq(0).is(':checked') ? 1 : 0,
  851. add_pay: $('#contract-users tr').eq(i).find('input[data-type="permission_add_pay"]').eq(0).is(':checked') ? 1 : 0,
  852. showUnit: $('#contract-users tr').eq(i).find('input[data-type="permission_show_unit"]').eq(0).is(':checked') ? 1 : 0,
  853. showNode: $('#contract-users tr').eq(i).find('input[data-type="permission_show_node"]').eq(0).is(':checked') ? 1 : 0,
  854. }
  855. } else if (userType === 'construction') {
  856. userData.is_report = $('#construction-users tr').eq(i).find('input[type="checkbox"]').eq(0).is(':checked') ? 1 : 0;
  857. } else if (_.includes(tenderPermissionKeys, userType)) {
  858. userData.member = {};
  859. userData.member[userType] = [1];
  860. $('#'+ userType +'-users tr').eq(i).find('input[type="checkbox"]').each(function () {
  861. if ($(this).is(':checked')) {
  862. userData.member[userType].push(parseInt($(this).attr('data-value')));
  863. }
  864. });
  865. } else if (_.includes(Object.keys(tPsKeys), userType)) {
  866. userData.member = {};
  867. for (const key of tPsKeys[userType]) {
  868. userData.member[key] = [];
  869. $('#'+ userType +'-users tr').eq(i).find('input[data-key="' + key + '"]').each(function () {
  870. if ($(this).is(':checked')) {
  871. userData.member[key].push(parseInt($(this).attr('data-value')));
  872. }
  873. });
  874. }
  875. }
  876. saIdList.push(userData);
  877. }
  878. data.auditList = saIdList;
  879. // 获取已选中的标段
  880. const tenderList = [];
  881. for (let i = 0; i < num; i++) {
  882. const tid = parseInt($('#tender-list-4user input:checked').eq(i).data('tid'));
  883. if (tid !== cur_tenderid) {
  884. tenderList.push(tid);
  885. }
  886. }
  887. data.tidList = tenderList.join(',');
  888. // 请求获取右侧列表信息
  889. const _self = $(this);
  890. postData(`/sp/${spid}/setting/manage/tender/save`, data, function (result) {
  891. toastr.success('应用至其他标段成功');
  892. _self.attr('disabled', false);
  893. $('#bdcopy').modal('hide');
  894. }, function () {
  895. _self.attr('disabled', false);
  896. });
  897. });
  898. // 关联标段
  899. $('#select-tender').on('show.bs.modal', function () {
  900. $('#select-all-tender').prop('checked', false);
  901. postData(`/sp/${spid}/setting/manage/tender/save`, { type: 'noSp-tenders' }, function (result) {
  902. const html = [];
  903. for (const t of result) {
  904. html.push('<tr>');
  905. html.push('<td><a target="_blank" href="/tender/', t.id, '">', t.name, '</a></td>');
  906. html.push('<td>', t.user_name, '</td>');
  907. html.push('<td>', moment(t.create_time).format('YYYY-MM-DD'), '</td>');
  908. html.push('<td class="text-center">', '<input type="checkbox" data-tid="' + t.id + '">', '</td>');
  909. html.push('</tr>');
  910. }
  911. $('#no-project-tenders').html(html.join(''));
  912. });
  913. });
  914. $('#bind-sp-btn').click(function () {
  915. const num = $('#no-project-tenders input:checked').length;
  916. if (num < 1) {
  917. toastr.warning('请选择需要关联的标段');
  918. return;
  919. }
  920. const tidList = [];
  921. for (let i = 0; i < num; i++) {
  922. tidList.push($('#no-project-tenders input:checked').eq(i).data('tid'));
  923. }
  924. postData(`/sp/${spid}/setting/manage/tender/save`, { type: 'bind-sp', spid, tidList: tidList.join(',') }, function (result) {
  925. toastr.success('关联标段成功');
  926. $('#select-tender').modal('hide');
  927. setTimeout(function () {
  928. window.location.reload();
  929. }, 500);
  930. });
  931. });
  932. $('#select-all-tender').click(function () {
  933. const checked = $(this).is(':checked');
  934. $('#no-project-tenders input').prop('checked', checked);
  935. });
  936. // $('#change-sp').change(function () {
  937. // const spid = $(this).val();
  938. // console.log(spid);
  939. // postData(`/sp/${spid}/setting/manage/tender/save`, { type: 'get-category', spid }, function (result) {
  940. // $('#cate-list', '#edit-bd').html(getCategoryHtml(result));
  941. // const tender = _.find(tenders, { id: cur_tenderid });
  942. // if (tender && tender.spid === spid) {
  943. // for (const c of tender.category) {
  944. // // $('input[value=' + c.value + ']', '#edit-bd').prop('checked', 'checked');
  945. // $('option[value=' + c.value + ']', '#edit-bd').prop('selected', true);
  946. // }
  947. // }
  948. // });
  949. // })
  950. $('#filter-tender-ok').click(function() {
  951. const updateData = [];
  952. const tr = $('tr[tid]', '#filter-tender');
  953. for (const t of tr) {
  954. const data = { id: t.getAttribute('tid')};
  955. const checkes = $('input', t);
  956. for (const c of checkes) {
  957. data[c.getAttribute('data-type')] = c.checked ? 1 : 0;
  958. }
  959. updateData.push(data);
  960. }
  961. postData(`/sp/${spid}/list/batchUpdate`, updateData, function() {
  962. window.location.reload();
  963. });
  964. });
  965. $('#edit-bd').on('show.bs.modal', function () {
  966. const tree = new TreeSelect({
  967. element: '#tree-container',
  968. data: subProjects,
  969. selected: spid,
  970. onSelect: (id, label) => {
  971. const newSpid = id;
  972. console.log(newSpid);
  973. $('#change-sp').val(newSpid);
  974. postData(`/sp/${newSpid}/setting/manage/tender/save`, { type: 'get-category', spid: newSpid }, function (result) {
  975. $('#cate-list', '#edit-bd').html(getCategoryHtml(result));
  976. const tender = _.find(tenders, { id: cur_tenderid });
  977. if (tender && tender.spid === newSpid) {
  978. for (const c of tender.category) {
  979. // $('input[value=' + c.value + ']', '#edit-bd').prop('checked', 'checked');
  980. $('option[value=' + c.value + ']', '#edit-bd').prop('selected', true);
  981. }
  982. }
  983. });
  984. // console.log('选中了:', id, label);
  985. }
  986. });
  987. });
  988. });
  989. const tenderListSpec = (function(){
  990. function getTenderTreeHeaderHtml() {
  991. const html = [];
  992. html.push('<table class="table table-hover table-bordered">');
  993. html.push('<thead style="position: sticky;left:176px;top: 0;">', '<tr>');
  994. html.push('<th class="text-center" style="width: 80%">', '标段名称', '</th>');
  995. html.push('<th class="text-center" style="width: 20%">', '创建人', '</th>');
  996. html.push('</tr>', '</thead>');
  997. return html.join('');
  998. }
  999. function getTenderNodeHtml(node, arr, pid) {
  1000. const html = [];
  1001. html.push('<tr pid="' + pid + '"', (node.cid ? '' : 'class="tender-info" data-id="'+ node.id +'"'), '>');
  1002. // 名称
  1003. html.push('<td style="width: 80%" class="in-' + node.level + '"' + (node.cid ? '' : 'tid="' + node.id + '"') + '>');
  1004. if (node.cid) {
  1005. 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> ');
  1006. html.push((node.level === 1 ? '<b>' : ''), node.name, (node.level === 1 ? '</b>' : ''));
  1007. } else {
  1008. html.push('<div class="d-flex justify-content-between align-items-center">');
  1009. html.push('<div>');
  1010. html.push('<span class="text-muted mr-2">');
  1011. html.push(arr.indexOf(node) === arr.length - 1 ? '└' : '├');
  1012. html.push('</span>');
  1013. //html.push('<a href="/tender/' + node.id + '">', node[c.field], '</a>');
  1014. html.push('<a href="javascript: void(0)" id="' + node.id + '" name="name">', node.name, '</a>');
  1015. html.push('</div>');
  1016. html.push('<div class="btn-group-table" tid="' + node.id + '">');
  1017. html.push('<a href="javascript:void(0);" name="edit" class="mr-1"><i class="fa fa-pencil fa-fw"></i></a>');
  1018. const hasStage = node.progress ? (node.stage_count > 0 ? true : node.stage_status !== 0) : !!node.lastStage;
  1019. if (!hasStage) {
  1020. html.push('<a href="javascript:void(0);" name="del" class="mr-1"><i class="fa fa-trash-o fa-fw text-danger"></i></a>');
  1021. } else {
  1022. 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>');
  1023. }
  1024. html.push('</div></div>');
  1025. }
  1026. html.push('</td>');
  1027. // 创建人
  1028. html.push('<td style="width: 20%" class="text-center">', node.user_name ? node.user_name : '', '</td>');
  1029. html.push('</tr>');
  1030. return html.join('');
  1031. }
  1032. return { getTenderNodeHtml, getTenderTreeHeaderHtml }
  1033. })();
  1034. function updateSelectedMarks(forcedType = null) {
  1035. let currentUserListSelector = '';
  1036. let selectedIdsArray = [];
  1037. let currentType = forcedType;
  1038. if (!currentType) {
  1039. const $activeTabPane = $('.tab-pane.active');
  1040. const activeTabId = $activeTabPane.attr('id');
  1041. switch(activeTabId) {
  1042. case 'guest': currentType = 'tourist'; break;
  1043. case 'tzpro': currentType = 'schedule'; break;
  1044. case 'htgl': currentType = 'contract'; break;
  1045. case 'sgrz': currentType = 'construction'; break;
  1046. case 'quality': currentType = 'quality'; break;
  1047. case 'safe': currentType = 'safe'; break;
  1048. default: currentType = null;
  1049. }
  1050. }
  1051. if (currentType && selectedUserIdsByType.hasOwnProperty(currentType)) {
  1052. switch(currentType) {
  1053. case 'tourist': currentUserListSelector = '#tourist-users'; break;
  1054. case 'schedule': currentUserListSelector = '#schedule-users'; break;
  1055. case 'contract': currentUserListSelector = '#contract-users'; break;
  1056. case 'construction': currentUserListSelector = '#construction-users'; break;
  1057. case 'quality': currentUserListSelector = '#quality-users'; break;
  1058. case 'inspection': currentUserListSelector = '#inspection-users'; break;
  1059. case 'safe': currentUserListSelector = '#safe-users'; break;
  1060. }
  1061. selectedIdsArray = selectedUserIdsByType[currentType];
  1062. } else {
  1063. $('.user-item').find('.selected-mark').hide();
  1064. $('.user-item').removeClass('bg-light');
  1065. return;
  1066. }
  1067. if ($('#add_user_dropdownMenu2 .book-list').length > 0) {
  1068. $('.user-item').each(function() {
  1069. const userIdStr = $(this).data('id');
  1070. const userId = parseInt(userIdStr, 10);
  1071. const $mark = $(this).find('.selected-mark');
  1072. if (!isNaN(userId) && selectedIdsArray.includes(userId)) {
  1073. $mark.show();
  1074. $(this).addClass('bg-light');
  1075. } else {
  1076. $mark.hide();
  1077. $(this).removeClass('bg-light');
  1078. }
  1079. });
  1080. }
  1081. }
  1082. function setShenpiHtml(shenpi, tender, revising) {
  1083. let html = '';
  1084. if (shenpi.sp_lc.length > 0) {
  1085. for (const sp of shenpi.sp_lc) {
  1086. html += `<div class="card mb-3">
  1087. <div class="card-body ${sp.code}_div">
  1088. <a class="pull-right set-otherTender" data-name="${sp.name}" data-code="${sp.code}" href="#batch" data-toggle="modal" data-target="#batch">设置其他标段</a>
  1089. <a class="pull-right set-otherShenpi mr-3" data-name="${sp.name}" data-code="${sp.code}" href="javascript: void(0);">设置其他流程</a>`;
  1090. if (sp.code === 'stage' && !revising && tender.ledger_status === auditConst.ledger.status.checked) {
  1091. 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>`;
  1092. }
  1093. html += `
  1094. <h5 class="card-title">${sp.name}</h5>
  1095. <div class="form-group">
  1096. <div class="form-group form-check">`;
  1097. for (const st in shenpi.sp_status_list) {
  1098. if (shenpi.sp_status_list[st]) {
  1099. html += `<div class="custom-control custom-checkbox custom-control-inline">
  1100. <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' : ''}>
  1101. <label class="custom-control-label" for="${sp.code}_${shenpi.sp_status_list[st].status}">${shenpi.sp_status_list[st].name}</label>
  1102. </div>`;
  1103. }
  1104. }
  1105. html += `
  1106. </div>
  1107. </div>
  1108. <div class="alert alert-warning">${shenpi.sp_status_list[sp.status].name}:${shenpi.sp_status_list[sp.status].msg}</div>
  1109. <div class="lc-show">`;
  1110. if (sp.status === sp_status.sqspr) {
  1111. html += ``;
  1112. } else if (sp.status === sp_status.gdspl) {
  1113. const flow = sp_lc.find(x => { return x.code === sp.code; });
  1114. flow.auditGroupList = sp.auditGroupList;
  1115. html += auditUtils.getGroupHtml(flow, sp.code);
  1116. let addhtml = '<ul class="list-unstyled">\n';
  1117. addhtml += auditUtils.getgdsplHtml(flow, sp.code);
  1118. addhtml += '</ul>\n';
  1119. html += addhtml;
  1120. } else if (sp.status === sp_status.gdzs) {
  1121. let addhtml = '<ul class="list-unstyled">\n' +
  1122. ' <li class="d-flex justify-content-start mb-3">\n' +
  1123. ' <span class="col-auto">授权审批人</span>\n' +
  1124. ' <span class="col-7">\n' +
  1125. ' <span class="d-inline-block"></span>\n' +
  1126. ' </span>\n' +
  1127. ' </li>\n';
  1128. addhtml += sp.audit ? makeAudit(sp.audit) : makeSelectAudit(sp.code);
  1129. addhtml += '</ul>\n';
  1130. html += addhtml;
  1131. }
  1132. html += ` </div>
  1133. </div>
  1134. </div>`;
  1135. }
  1136. }
  1137. $('#splc').html(html);
  1138. }
  1139. let selectedUserIdsByType = {
  1140. tourist: [],
  1141. schedule: [],
  1142. contract: [],
  1143. construction: [],
  1144. quality: [],
  1145. inspection: [],
  1146. safe: []
  1147. };
  1148. function setTouristHtml(tourists) {
  1149. let html = '';
  1150. if (tourists.length > 0) {
  1151. for (const t of tourists) {
  1152. html += `<tr data-uid="${t.user_id}" data-id="${t.id}">
  1153. <td>${t.user_name}</td>
  1154. <td>${t.user_role}</td>
  1155. <td class="text-center">
  1156. <div class="custom-control custom-checkbox mb-2">
  1157. <input type="checkbox" id="${t.id}_file" data-id="${t.id}" name="file" class="custom-control-input set-tourist-permission" ${t.permission.file ? 'checked' : ''}>
  1158. <label class="custom-control-label" for="${t.id}_file"></label>
  1159. </div>
  1160. </td>
  1161. <td class="text-center">
  1162. <div class="custom-control custom-checkbox mb-2">
  1163. <input type="checkbox" id="${t.id}_tag" data-id="${t.id}" name="tag" class="custom-control-input set-tourist-permission" ${t.permission.tag ? 'checked' : ''}>
  1164. <label class="custom-control-label" for="${t.id}_tag"></label>
  1165. </div>
  1166. </td>
  1167. <td class="text-center">
  1168. <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>
  1169. </td>
  1170. </tr>`;
  1171. }
  1172. selectedUserIdsByType.tourist = [];
  1173. if (Array.isArray(tourists)) {
  1174. tourists.forEach(function(tourist) {
  1175. if (tourist.user_id !== undefined && tourist.user_id !== null) {
  1176. selectedUserIdsByType.tourist.push(parseInt(tourist.user_id, 10));
  1177. }
  1178. });
  1179. }
  1180. }
  1181. $('#tourist-users').html(html);
  1182. updateSelectedMarks();
  1183. }
  1184. function setScheduleHtml(scheduleAuditList) {
  1185. let html = '';
  1186. if (scheduleAuditList.length > 0) {
  1187. for (const sa of scheduleAuditList) {
  1188. const audit = _.find(accountList, { id: sa.audit_id });
  1189. html += `<tr data-uid="${sa.audit_id}" data-id="${sa.id}">
  1190. <td>${audit ? audit.name : ''}</td>
  1191. <td>${audit ? audit.role : ''}</td>
  1192. <td class="text-center">
  1193. <div class="custom-control custom-checkbox mb-2">
  1194. <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' : ''}>
  1195. <label class="custom-control-label" for="${sa.id}_customRadio41"></label>
  1196. </div>
  1197. </td>
  1198. <td class="text-center">
  1199. <div class="custom-control custom-checkbox mb-2">
  1200. <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' : ''}>
  1201. <label class="custom-control-label" for="${sa.id}_customRadio42"></label>
  1202. </div>
  1203. </td>
  1204. <td class="text-center">
  1205. <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>
  1206. </td>
  1207. </tr>`;
  1208. }
  1209. if (Array.isArray(scheduleAuditList)) {
  1210. scheduleAuditList.forEach(function(sa) {
  1211. if (sa.audit_id !== undefined && sa.audit_id !== null) {
  1212. selectedUserIdsByType.schedule.push(parseInt(sa.audit_id, 10));
  1213. }
  1214. });
  1215. }
  1216. }
  1217. $('#schedule-users').html(html);
  1218. updateSelectedMarks();
  1219. }
  1220. function setContractHtml(datas) {
  1221. let list = '';
  1222. for (const ca of datas) {
  1223. list += `<tr data-uid="${ca.uid}" data-id="${ca.id}">
  1224. <td>${ca.name}</td>
  1225. <td>${ca.role}</td>
  1226. <td class="text-center">
  1227. <input type="checkbox" class="permission-checkbox" data-type="permission_edit" value="${ca.uid}" ${ca.permission_edit ? 'checked' : ''}>
  1228. </td>
  1229. <td class="text-center">
  1230. <input type="checkbox" class="permission-checkbox" data-type="permission_add" value="${ca.uid}" ${ca.permission_add ? 'checked' : ''}>
  1231. </td>
  1232. <td class="text-center">
  1233. <input type="checkbox" class="permission-checkbox" data-type="permission_edit_contract" value="${ca.uid}" ${ca.permission_edit_contract ? 'checked' : ''}>
  1234. </td>
  1235. <td class="text-center">
  1236. <input type="checkbox" class="permission-checkbox" data-type="permission_add_pay" value="${ca.uid}" ${ca.permission_add_pay ? 'checked' : ''}>
  1237. </td>
  1238. <td class="text-center">
  1239. <input type="checkbox" class="permission-checkbox" data-type="permission_show_unit" value="${ca.uid}" ${ca.permission_show_unit ? 'checked' : ''}>
  1240. </td>
  1241. <td class="text-center">
  1242. <input type="checkbox" class="permission-checkbox" data-type="permission_show_node" value="${ca.uid}" ${ca.permission_show_node ? 'checked' : ''}>
  1243. </td>
  1244. <td class="text-center">
  1245. <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>
  1246. </td>
  1247. </tr>`;
  1248. }
  1249. if (Array.isArray(datas)) {
  1250. datas.forEach(function(ca) {
  1251. if (ca.uid !== undefined && ca.uid !== null) {
  1252. selectedUserIdsByType.contract.push(parseInt(ca.uid, 10));
  1253. }
  1254. });
  1255. }
  1256. $('#contract-users').html(list);
  1257. updateSelectedMarks();
  1258. }
  1259. function setConstructionHtml(constructionAuditList) {
  1260. let html = '';
  1261. if (constructionAuditList.length > 0) {
  1262. for (const sa of constructionAuditList) {
  1263. html += `<tr data-uid="${sa.uid}" data-id="${sa.id}">
  1264. <td>${sa.name}</td>
  1265. <td>${sa.role}</td>
  1266. <td class="text-center">
  1267. <div class="custom-control custom-checkbox mb-2">
  1268. <input type="checkbox" data-id="${sa.id}" id="${sa.id}_construction" name="customCheckbox" class="custom-control-input" ${sa.is_report ? 'checked' : ''}>
  1269. <label class="custom-control-label" for="${sa.id}_construction"></label>
  1270. </div>
  1271. </td>
  1272. <td class="text-center">
  1273. <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>
  1274. </td>
  1275. </tr>`;
  1276. }
  1277. if (Array.isArray(constructionAuditList)) {
  1278. constructionAuditList.forEach(function(sa) {
  1279. if (sa.uid !== undefined && sa.uid !== null) {
  1280. selectedUserIdsByType.construction.push(parseInt(sa.uid, 10));
  1281. }
  1282. });
  1283. }
  1284. }
  1285. $('#construction-users').html(html);
  1286. updateSelectedMarks();
  1287. }
  1288. function setTenderPermissionsHtml(auditList, key, keys) {
  1289. const html = [];
  1290. for (const m of auditList) {
  1291. html.push(getUserPermissionsHtml(m, key, keys));
  1292. }
  1293. if (Array.isArray(auditList)) {
  1294. auditList.forEach(function(sa) {
  1295. if (sa.uid !== undefined && sa.uid !== null) {
  1296. selectedUserIdsByType[key].push(parseInt(sa.uid, 10));
  1297. }
  1298. });
  1299. }
  1300. $('#' + key + '-users').html(html.join(''));
  1301. updateSelectedMarks();
  1302. }
  1303. const getUserPermissionsHtml = function(user, key, keys) {
  1304. const html = [];
  1305. html.push(`<tr data-uid="${user.uid}" data-id="${user.id}">`);
  1306. html.push(`<td>${user.name}</td>`, `<td>${user.role}</td>`);
  1307. const block = _.find(permissionBlock, { key: key });
  1308. for (const block of permissionBlock) {
  1309. if (keys.indexOf(block.key) < 0) continue;
  1310. for (const p of block.permission) {
  1311. const checked = user[block.key] ? (user[block.key].indexOf(p.value) >= 0 ? 'checked' : '') : '';
  1312. html.push(`<td class="text-center"><input type="checkbox" data-key="${block.key}" data-block="${p.key}" data-value="${p.value}" ${checked}></td>`);
  1313. }
  1314. }
  1315. html.push(`<td class="text-center"><a href="#remove-user1" data-id="${user.uid}" data-show-id="${user.uid}" data-toggle="modal" data-target="#remove-user" class="btn btn-sm btn-outline-danger remove-${key}-user">移除</a></td>`);
  1316. html.push('</tr>');
  1317. return html.join('');
  1318. };
  1319. function setTenderPermissionHtml(auditList, key) {
  1320. const html = [];
  1321. for (const m of auditList) {
  1322. html.push(getUserPermissionHtml(m, key));
  1323. }
  1324. if (Array.isArray(auditList)) {
  1325. auditList.forEach(function(sa) {
  1326. if (sa.uid !== undefined && sa.uid !== null) {
  1327. selectedUserIdsByType[key].push(parseInt(sa.uid, 10));
  1328. }
  1329. });
  1330. }
  1331. $('#' + key + '-users').html(html.join(''));
  1332. updateSelectedMarks();
  1333. }
  1334. const getUserPermissionHtml = function(user, key) {
  1335. const html = [];
  1336. html.push(`<tr data-uid="${user.uid}" data-id="${user.id}">`);
  1337. html.push(`<td>${user.name}</td>`, `<td>${user.role}</td>`);
  1338. const block = _.find(permissionBlock, { key: key });
  1339. for (const p of block.permission) {
  1340. if (p.isDefault) continue;
  1341. const checked = user[block.key] ? (user[block.key].indexOf(p.value) >= 0 ? 'checked' : '') : '';
  1342. html.push(`<td class="text-center"><input type="checkbox" data-block="${p.key}" data-value="${p.value}" ${checked}></td>`);
  1343. }
  1344. 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>`);
  1345. html.push('</tr>');
  1346. return html.join('');
  1347. };