rpt_custom.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597
  1. 'use strict';
  2. /**
  3. *
  4. *
  5. * @author Mai
  6. * @date
  7. * @version
  8. */
  9. const rptCustomObj = (function () {
  10. // 审批人选择
  11. const sAuditSelect = 'audit_select';
  12. let stageFlow = [];
  13. // 汇总表
  14. const sGatherSelect = 'gather_select';
  15. let gsObj = {
  16. setting: null,
  17. gsSheet: null,
  18. grSheet: null,
  19. tenderSourceTree: null,
  20. grArray: [],
  21. orgSelect: null,
  22. };
  23. // 期选择
  24. const sStageSelect = 'stage_select';
  25. const grSpreadSetting = {
  26. baseCols: [
  27. {title: '名称', colSpan: '1', rowSpan: '1', field: 'name', hAlign: 0, width: 180, formatter: '@', readOnly: true},
  28. ],
  29. extraCols: [
  30. {title: '%s', colSpan: '1', rowSpan: '1', field: '%s', hAlign: 1, vAlign: '1', width: 60, cellType: 'checkbox', readOnly: true},
  31. ],
  32. emptyRows: 0,
  33. headRows: 1,
  34. headRowHeight: [32],
  35. defaultRowHeight: 21,
  36. headerFont: '12px 微软雅黑',
  37. font: '12px 微软雅黑',
  38. headColWidth: []
  39. };
  40. const gatherSelectSpreadObj = {
  41. _addTender: function (tender) {
  42. const gr = gsObj.grArray.find(function (x) {
  43. return x.tid === tender.tid;
  44. });
  45. const t = {tid: tender.tid, name: tender.name}
  46. if (!gr) gsObj.grArray.push(t);
  47. return t;
  48. },
  49. _removeTender: function (tender) {
  50. const gri = gsObj.grArray.findIndex(function (x, i, arr) {
  51. return x.tid === tender.tid;
  52. });
  53. if (gri >= 0) gsObj.grArray.splice(gri, 1);
  54. },
  55. reloadResultData: function () {
  56. SpreadJsObj.reLoadSheetData(gsObj.grSheet);
  57. },
  58. gsButtonClicked: function (e, info) {
  59. if (!info.sheet.zh_setting) return;
  60. const col = info.sheet.zh_setting.cols[info.col];
  61. if (col.field !== 'selected') return;
  62. const node = SpreadJsObj.getSelectObject(info.sheet);
  63. node.selected = !node.selected;
  64. if (node.children && node.children.length > 0) {
  65. const posterity = gsObj.tenderSourceTree.getPosterity(node);
  66. for (const p of posterity) {
  67. p.selected = node.selected;
  68. if (!p.children || p.children.length === 0){
  69. if (p.selected) {
  70. gatherSelectSpreadObj._addTender(p);
  71. } else {
  72. gatherSelectSpreadObj._removeTender(p);
  73. }
  74. }
  75. }
  76. SpreadJsObj.reLoadRowData(info.sheet, info.row, posterity.length + 1);
  77. } else {
  78. if (node.selected) {
  79. gatherSelectSpreadObj._addTender(node);
  80. } else {
  81. gatherSelectSpreadObj._removeTender(node);
  82. }
  83. SpreadJsObj.reLoadRowData(info.sheet, info.row, 1);
  84. }
  85. gatherSelectSpreadObj.reloadResultData();
  86. },
  87. grButtonClicked: function (e, info) {
  88. if (!info.sheet.zh_setting) return;
  89. const col = info.sheet.zh_setting.cols[info.col];
  90. if (col.field === 'name') return;
  91. const node = SpreadJsObj.getSelectObject(info.sheet);
  92. const refreshRows = [info.row];
  93. node[col.field] = !node[col.field];
  94. for (const rCol of info.sheet.zh_setting.cols) {
  95. if (rCol.field !== 'name' && rCol.field !== col.field) {
  96. node[rCol.field] = false;
  97. }
  98. }
  99. if (node[col.field]) {
  100. for (const [i, gra] of gsObj.grArray.entries()) {
  101. if (gra[col.field] && gra.tid !== node.tid) {
  102. gra[col.field] = false;
  103. refreshRows.push(i);
  104. }
  105. }
  106. }
  107. SpreadJsObj.reLoadRowsData(info.sheet, refreshRows);
  108. },
  109. initSelectTenders: function (tenders) {
  110. if (!tenders) return;
  111. const specCol = gsObj.setting.special ? gsObj.setting.special : [];
  112. const select = [];
  113. for (const node of gsObj.tenderSourceTree.nodes) {
  114. node.selected = false;
  115. }
  116. for (const t of tenders) {
  117. const tender = gsObj.tenderSourceTree.nodes.find(function (x) { return x.tid === t.tid});
  118. tender.selected = true;
  119. select.push(tender);
  120. const st = this._addTender(tender);
  121. for (const sc of specCol) {
  122. st[sc.key] = t[sc.key];
  123. }
  124. }
  125. SpreadJsObj.reLoadColsData(gsObj.gsSheet, [0]);
  126. if (select.length > 0) SpreadJsObj.locateTreeNode(gsObj.gsSheet, select[0].tmt_id);
  127. this.reloadResultData();
  128. },
  129. };
  130. const getStageFlowSelectHtml = function (select, id) {
  131. const html = [];
  132. html.push('<select style="width: 80%" id="' + id + '" sf-title="' + select.title + '">');
  133. for (const sf of stageFlow) {
  134. html.push('<option>' + sf.name + '-' + sf.role +'</option>');
  135. }
  136. html.push('</select>');
  137. return html.join('');
  138. };
  139. const checkAsSelectValid = function (validFlow, asSelect) {
  140. for (const s of asSelect) {
  141. const f = validFlow.find(function (x) {
  142. return x.aid === s.aid && x.order === s.order;
  143. });
  144. if (!f) {
  145. $('#audit-select-hint').html('本期审批流程发生变动,原审批人选择不适配,需重新选择').show();
  146. return false;
  147. }
  148. }
  149. $('#audit-select-hint').hide();
  150. return true;
  151. };
  152. const initAuditSelect = function (asSetting, asSelect) {
  153. const setting = JSON.parse(asSetting), select = asSelect;
  154. $('#audit-select-title').html(setting.title);
  155. const html = [];
  156. for (const [i, s] of setting.select.entries()) {
  157. html.push('<tr>');
  158. html.push('<td>', s.title, '</td>');
  159. html.push('<td>', getStageFlowSelectHtml(s, 'sf-' + i), '</td>');
  160. html.push('</tr>');
  161. }
  162. $('#audit-select-list').html(html.join(''));
  163. for (const [i, s] of setting.select.entries()) {
  164. const obj = $('#sf-' + i);
  165. const s = select[i];
  166. const sf = s ? stageFlow.find(function (x) {
  167. return x.order === s.order && x.aid === s.aid;
  168. }) : null;
  169. obj[0].selectedIndex = sf ? sf.order : -1;
  170. }
  171. if (asSelect.length === 0 || !checkAsSelectValid(stageFlow, asSelect)) {
  172. $('#audit-select').modal('show');
  173. }
  174. };
  175. const initGrSpreadSetting = function (gsSetting) {
  176. grSpreadSetting.cols = [];
  177. for (const bc of grSpreadSetting.baseCols) {
  178. grSpreadSetting.cols.push(bc);
  179. if (bc.field === 'name') bc.width = gsSetting.nameColWidth ? gsSetting.nameColWidth : 180;
  180. }
  181. if (gsSetting.special) {
  182. for (const s of gsSetting.special) {
  183. for (const ec of grSpreadSetting.extraCols) {
  184. const c = {};
  185. c.title = ec.title.replace('%s', s.title);
  186. c.colSpan = ec.colSpan;
  187. c.field = ec.field.replace('%s', s.key);
  188. c.hAlign = ec.hAlign;
  189. c.width = s.width ? s.width : ec.width;
  190. c.cellType = ec.cellType;
  191. c.readOnly = ec.readOnly;
  192. grSpreadSetting.cols.push(c);
  193. }
  194. }
  195. }
  196. };
  197. const initGatherSelect = function (gsSetting, gsSelect, rptName, resolve = null) {
  198. gsObj.grArray = [];
  199. gsObj.setting = JSON.parse(gsSetting);
  200. gsObj.orgSelect = gsSelect;
  201. $('#gather-select-count').html(gsSelect ? gsSelect.tenders.length : 0);
  202. $('#gather-select-title').html(gsObj.setting.title + (rptName ? '-' + rptName : ''));
  203. initGrSpreadSetting(gsObj.setting);
  204. SpreadJsObj.initSheet(gsObj.grSheet, grSpreadSetting);
  205. if (gsObj.setting.type === 'month') {
  206. $('#gather-by-month').show();
  207. $('#gather-by-zone').hide();
  208. } else if (gsObj.setting.type === 'zone') {
  209. $('#gather-by-month').hide();
  210. $('#gather-by-zone').show();
  211. } else {
  212. $('#gather-by-month').hide();
  213. $('#gather-by-zone').hide();
  214. }
  215. SpreadJsObj.loadSheetData(gsObj.grSheet, SpreadJsObj.DataType.Data, gsObj.grArray);
  216. // 初始化选择结果
  217. if (gsSelect) {
  218. if (gsSelect.zone) {
  219. $('#gather-zone').val(gsSelect.zone ? gsSelect.zone : '');
  220. } else if (gsSelect.month) {
  221. $('#gather-month').val(gsSelect.month ? gsSelect.month: '');
  222. }
  223. }
  224. gatherSelectSpreadObj.initSelectTenders(gsSelect ? gsSelect.tenders : []);
  225. // 初始化
  226. $("#gather-select").modal('show');
  227. $('#gather-select-ok').unbind('click');
  228. $('#gather-select-ok').bind('click', () => {rptCustomObj.resetGatherSelect(resolve);});
  229. };
  230. const initStageSelect = function (gsSetting, gsSelect, rptName, resolve = null) {
  231. const setting = JSON.parse(gsSetting);
  232. $('#stage-select-count').html(gsSelect && gsSelect.stages ? gsSelect.stages.length : 0);
  233. $('#stage-select-title').html(setting.title + (rptName ? '-' + rptName : ''));
  234. // 初始化选择结果
  235. $('#stage-select-hint').attr('min-select', setting.min).attr('max-select', setting.max).hide();
  236. for (const sc of $('[name=stage-select-check]')) {
  237. sc.checked = false;
  238. }
  239. if (gsSelect && gsSelect.stages) {
  240. for (const s of gsSelect.stages) {
  241. $('#stage-select-' + s)[0].checked = true;
  242. }
  243. }
  244. $("#stage-select").modal('show');
  245. $('#stage-select-ok').unbind('click');
  246. $('#stage-select-ok').bind('click', () => {rptCustomObj.resetStageSelect(resolve);});
  247. };
  248. const init = function (cDefine, sfData, cSelect, rptName, resolve = null) {
  249. stageFlow = sfData;
  250. if (cDefine && cDefine[sAuditSelect] && cDefine[sAuditSelect].enable && cDefine[sAuditSelect].setting) {
  251. $('#pnl_audit_select').show();
  252. initAuditSelect(cDefine[sAuditSelect].setting, cSelect ? cSelect[sAuditSelect] : []);
  253. } else {
  254. $('#pnl_audit_select').hide();
  255. }
  256. if (cDefine && cDefine[sGatherSelect] && cDefine[sGatherSelect].enable && cDefine[sGatherSelect].setting) {
  257. $('#pnl_gather_select').show();
  258. initGatherSelect(cDefine[sGatherSelect].setting, cSelect ? cSelect[sGatherSelect] : null, rptName, resolve);
  259. } else {
  260. $('#pnl_gather_select').hide();
  261. }
  262. if (cDefine && cDefine[sStageSelect] && cDefine[sStageSelect].enable && cDefine[sStageSelect].setting) {
  263. $('#pnl_stage_select').show();
  264. initStageSelect(cDefine[sStageSelect].setting, cSelect ? cSelect[sStageSelect] : null, rptName, resolve);
  265. } else {
  266. $('#pnl_stage_select').hide();
  267. }
  268. };
  269. const reloadReportData = function (result) {
  270. // hintBox.unWaitBox();
  271. let pageRst = result.data;
  272. if (result.signatureRelInfo && result.signatureRelInfo.length > 0) {
  273. CURRENT_ROLE_REL_ID = result.signatureRelInfo[0].id;
  274. ROLE_REL_LIST = zTreeOprObj._parseRoleRelList(result.signatureRelInfo[0].rel_content);
  275. STAGE_AUDIT = result.stageAudit;
  276. rptSignatureHelper.originalRoleRelList = zTreeOprObj._parseRoleRelList(result.signatureRelInfo[0].rel_content);
  277. if (current_stage_status === 3) {
  278. rptSignatureHelper.mergeSignDate(pageRst, ROLE_REL_LIST, true);
  279. rptSignatureHelper.mergeSignature(pageRst, ROLE_REL_LIST);
  280. rptSignatureHelper.mergeSignAudit(pageRst, ROLE_REL_LIST, STAGE_AUDIT);
  281. }
  282. } else {
  283. CURRENT_ROLE_REL_ID = -1;
  284. ROLE_REL_LIST = [];
  285. }
  286. // if (ROLE_REL_LIST)
  287. let canvas = zTreeOprObj.canvas;
  288. if (pageRst && pageRst.items && pageRst.items.length > 0) {
  289. zTreeOprObj.resetAfter(pageRst);
  290. zTreeOprObj.currentRptPageRst = pageRst;
  291. zTreeOprObj.maxPages = pageRst.items.length;
  292. zTreeOprObj.currentPage = 1;
  293. zTreeOprObj.displayPageValue();
  294. let size = JpcCanvasOutput.getReportSizeInPixel(zTreeOprObj.currentRptPageRst, getScreenDPI());
  295. canvas.width = size[0] + 20;
  296. if (size[1] > size[0]) {
  297. canvas.height = size[1] + 100;
  298. } else {
  299. canvas.height = size[1] + 50;
  300. }
  301. // zTreeOprObj.resetESignature(zTreeOprObj.currentRptPageRst);
  302. rptSignatureHelper.buildSelectableAccount();
  303. rptSignatureHelper.buildSelectableAccountUsed();
  304. rptSignatureHelper.buildRoleDom(ROLE_LIST);
  305. zTreeOprObj.showPage(1, canvas);
  306. } else {
  307. //返回了无数据表
  308. JpcCanvasOutput.cleanCanvas(canvas);
  309. JpcCanvasOutput.drawPageBorder(zTreeOprObj.currentRptPageRst, canvas, getScreenDPI());
  310. }
  311. rptCustomObj.init(result.customDefine, result.stageFlow, result.customSelect);
  312. try {
  313. if (is_debug && result.debugInfo) {
  314. console.log('含有key的debug信息:');
  315. for (const k in result.debugInfo.key) {
  316. console.log(k + ':', ...result.debugInfo.key[k]);
  317. }
  318. //console.log(result.debugInfo.key);
  319. console.log('其他debug信息:');
  320. for (const di of result.debugInfo.other) {
  321. console.log(...di);
  322. }
  323. }
  324. } catch(err) {
  325. }
  326. zTreeOprObj.countChkedRptTpl();
  327. };
  328. const getCommonParams = function (data) {
  329. data.pageSize = rptControlObj.getCurrentPageSize();
  330. data.rpt_tpl_id = zTreeOprObj.currentNode.refId;
  331. data.custCfg = CUST_CFG;
  332. data.project_id = PROJECT_ID;
  333. data.tender_id = TENDER_ID;
  334. data.stage_id = getStageId();
  335. data.stage_status = getStageStatus();
  336. data.stage_order = getStageOrder();
  337. data.stage_times = getStageTimes();
  338. data.material_order = getMaterialOrder();
  339. };
  340. const resetAuditSelect = function () {
  341. const selObj = $('select', '#audit-select-list');
  342. const data = { audit_select: [] };
  343. getCommonParams(data);
  344. for (const s of selObj) {
  345. const sf = stageFlow[s.selectedIndex];
  346. if (!sf) {
  347. $('#audit-select-hint').html('未选择' + s.attributes['sf-title'].value).show();
  348. return;
  349. }
  350. data.audit_select.push(sf);
  351. }
  352. $('#audit-select-hint').hide();
  353. postData('/report/cDefine', data, function (result) {
  354. reloadReportData(result);
  355. $('#audit-select').modal('hide');
  356. });
  357. };
  358. const resetGatherSelect = function (resolve = null) {
  359. const data = {}, hintObj = $('#gather-hint');
  360. if (!resolve) getCommonParams(data);
  361. data[sGatherSelect] = {
  362. tenders: [],
  363. type: gsObj.setting.type,
  364. };
  365. const specCol = gsObj.setting.special ? gsObj.setting.special : [];
  366. for (const sc of specCol) {
  367. sc.sCount = 0;
  368. }
  369. for (const gra of gsObj.grArray) {
  370. const ra = {tid: gra.tid};
  371. for (const sc of specCol) {
  372. if (gra[sc.key]) {
  373. ra[sc.key] = true;
  374. sc.sCount += 1;
  375. }
  376. }
  377. data[sGatherSelect].tenders.push(ra);
  378. }
  379. for (const sc of specCol) {
  380. if (sc.sCount === 0) {
  381. hintObj.html('请选择 ' + sc.title).show();
  382. return;
  383. }
  384. }
  385. if (data[sGatherSelect].tenders.length <= specCol.length) {
  386. hintObj.html('请至少选择1个普通汇总项目').show();
  387. return;
  388. }
  389. if (gsObj.setting.type === 'month') {
  390. data[sGatherSelect].month = $('#gather-month').val();
  391. if (data[sGatherSelect].month === '') {
  392. hintObj.html('请选择 汇总年月').show();
  393. return;
  394. }
  395. } else if (gsObj.setting.type === 'zone') {
  396. data[sGatherSelect].zone = $('#gather-zone').val();
  397. if (data[sGatherSelect].zone === '') {
  398. hintObj.html('请选择 汇总周期').show();
  399. return;
  400. } else if(data[sGatherSelect].zone.indexOf(' - ') < 0) {
  401. hintObj.html('请选择 完整汇总周期').show();
  402. return;
  403. }
  404. }
  405. hintObj.hide();
  406. if (resolve) {
  407. resolve(data);
  408. } else {
  409. postData('/report/cDefine', data, function (result) {
  410. reloadReportData(result);
  411. const gather_select = customSelects.gather_select.find(function (x) {
  412. return x.id === zTreeOprObj.currentNode.refId;
  413. });
  414. if (gather_select) {
  415. gather_select.gather_select = data[sGatherSelect];
  416. }
  417. $('#gather-select-count').html(data[sGatherSelect].tenders.length);
  418. $('#gather-select').modal('hide');
  419. });
  420. }
  421. };
  422. const resetStageSelect = function (resolve = null) {
  423. const data = {}, hintObj = $('#stage-select-hint');
  424. if (!resolve) getCommonParams(data);
  425. data[sStageSelect] = {
  426. stages: [],
  427. };
  428. for (const sc of $('[name=stage-select-check]:checked')) {
  429. data[sStageSelect].stages.push(parseInt($(sc).attr('stage-order')));
  430. }
  431. if (data[sStageSelect].stages.length <= parseInt(hintObj.attr('min-select'))) {
  432. hintObj.html('请至少选择' + hintObj.attr('min-select') + '期数据').show();
  433. return;
  434. } else if (data[sStageSelect].stages.length >= parseInt(hintObj.attr('max-select'))) {
  435. hintObj.html('最多只能选择' + hintObj.attr('max-select') + '期数据').show();
  436. return;
  437. }
  438. hintObj.hide();
  439. if (resolve) {
  440. resolve(data);
  441. } else {
  442. postData('/report/cDefine', data, function (result) {
  443. reloadReportData(result);
  444. const stage_select = customSelects.stage_select.find(function (x) {
  445. return x.id === zTreeOprObj.currentNode.refId;
  446. });
  447. if (stage_select) {
  448. stage_select.gather_select = data[sStageSelect];
  449. }
  450. $('#stage-select-count').html(data[sStageSelect].stages.length);
  451. $('#stage-select').modal('hide');
  452. });
  453. }
  454. };
  455. const initTenderTree = function (tenders, category) {
  456. const gsSpread = SpreadJsObj.createNewSpread($('#gather-source-spread')[0]);
  457. gsObj.gsSheet = gsSpread.getActiveSheet();
  458. const spreadSetting = {
  459. cols: [
  460. {title: '选择', field: 'selected', hAlign: 1, width: 40, formatter: '@', cellType: 'checkbox', readOnly: true},
  461. {title: '名称', field: 'name', hAlign: 0, width: 180, formatter: '@', readOnly: true, cellType: 'tree'},
  462. {title: '期数', field: 'phase', hAlign: 1, width: 60, formatter: '@', readOnly: true},
  463. {title: '审批状态', field: 'status', hAlign: 1, width: 60, formatter: '@', readOnly: true}
  464. ],
  465. emptyRows: 0,
  466. headRows: 1,
  467. headRowHeight: [32],
  468. defaultRowHeight: 21,
  469. headerFont: '12px 微软雅黑',
  470. font: '12px 微软雅黑',
  471. headColWidth: [0],
  472. selectedBackColor: '#fffacd',
  473. };
  474. SpreadJsObj.initSheet(gsObj.gsSheet, spreadSetting);
  475. gsObj.tenderSourceTree = Tender2Tree.convert(category, tenders, ledgerAuditConst, auditConst);
  476. SpreadJsObj.loadSheetData(gsObj.gsSheet, SpreadJsObj.DataType.Tree, gsObj.tenderSourceTree);
  477. gsSpread.bind(spreadNS.Events.ButtonClicked, gatherSelectSpreadObj.gsButtonClicked);
  478. const grSpread = SpreadJsObj.createNewSpread($('#gather-result-spread')[0]);
  479. gsObj.grSheet = grSpread.getActiveSheet();
  480. grSpread.bind(spreadNS.Events.ButtonClicked, gatherSelectSpreadObj.grButtonClicked);
  481. $('#gather-hint').hide();
  482. $('#gather-select').bind('shown.bs.modal', function () {
  483. if (gsSpread) gsSpread.refresh();
  484. if (grSpread) grSpread.refresh();
  485. });
  486. $('.datepicker-here').datepicker({
  487. autoClose: true,
  488. });
  489. };
  490. const comfirmSelectPromise = function (rptName, gather_select) {
  491. const promise = new Promise(function (resolve, reject) {
  492. init(gather_select.custom_define, customSelects.stageFlow, gather_select, rptName, resolve, reject);
  493. });
  494. return promise;
  495. };
  496. const getCustomSelect = async function (params) {
  497. if (!params.rpt_ids || params.rpt_ids.length === 0) return;
  498. const currentRptId = zTreeOprObj.currentNode ? zTreeOprObj.currentNode.refId : -1;
  499. params.customSelect = [];
  500. const chkNodes = zTreeOprObj.treeObj.getCheckedNodes(true);
  501. for (const rptId of params.rpt_ids) {
  502. const gather_select = customSelects.gather_select.find(function (x) {
  503. return x.id === rptId;
  504. });
  505. if (gather_select && gather_select.custom_define && gather_select.custom_define[sGatherSelect].enable) {
  506. if (rptId === currentRptId) {
  507. params.customSelect.push(gather_select[sGatherSelect]);
  508. } else {
  509. const chkNode = chkNodes.find(function (x) { return x.refId === rptId});
  510. params.customSelect.push(await comfirmSelectPromise(chkNode ? chkNode.name : '', gather_select));
  511. }
  512. } else {
  513. params.customSelect.push(null);
  514. }
  515. const stage_select = customSelects.stage_select.find(function (x) {
  516. return x.id === rptId;
  517. });
  518. if (stage_select && stage_select.custom_define && stage_select.custom_define[sStageSelect].enable) {
  519. if (rptId === currentRptId) {
  520. params.customSelect.push(stage_select[sStageSelect]);
  521. } else {
  522. const chkNode = chkNodes.find(function (x) { return x.refId === rptId});
  523. params.customSelect.push(await comfirmSelectPromise(chkNode ? chkNode.name : '', stage_select));
  524. }
  525. } else {
  526. params.customSelect.push(null);
  527. }
  528. }
  529. $('#gather-select').modal('hide');
  530. $('#stage-select').modal('hide');
  531. };
  532. const showMaterialSelect = function () {
  533. const needShow = function () {
  534. if (zTreeOprObj.currentNode) {
  535. const ms = dataSelects.material_select.find(function (x) { return x.id === zTreeOprObj.currentNode.refId});
  536. if (ms) return true;
  537. }
  538. const chkNodes = zTreeOprObj.treeObj.getCheckedNodes(true);
  539. for (const node of chkNodes) {
  540. const ms = dataSelects.material_select.find(function (x) { return x.id === node.refId});
  541. if (ms) return true;
  542. }
  543. return false;
  544. };
  545. if (needShow()) {
  546. $('#material').show();
  547. } else {
  548. $('#material').hide();
  549. }
  550. };
  551. const changeMaterial = function (obj) {
  552. $('#material-select').attr('m-order', $(obj).attr('m-order')).html(obj.innerText);
  553. };
  554. return {
  555. init,
  556. resetAuditSelect, resetGatherSelect, resetStageSelect,
  557. initTenderTree,
  558. getCustomSelect,
  559. showMaterialSelect, changeMaterial,
  560. };
  561. })();