'use strict'; /** * * * @author Mai * @date * @version */ const rptCustomObj = (function () { const sAuditSelect = 'audit_select'; let stageFlow = []; const getStageFlowSelectHtml = function (select, id) { const html = []; html.push(''); return html.join(''); }; const checkAsSelectValid = function (validFlow, asSelect) { for (const s of asSelect) { const f = validFlow.find(function (x) { return x.aid === s.aid && x.order === s.order; }); if (!f) { $('#audit-select-hint').html('本期审批流程发生变动,原审批人选择不适配,需重新选择').show(); return false; } } $('#audit-select-hint').hide(); return true; }; const initAuditSelect = function (asSetting, asSelect) { const setting = JSON.parse(asSetting), select = asSelect; $('#audit-select-title').html(setting.title); const html = []; for (const [i, s] of setting.select.entries()) { html.push(''); html.push('', s.title, ''); html.push('', getStageFlowSelectHtml(s, 'sf-' + i), ''); html.push(''); } $('#audit-select-list').html(html.join('')); for (const [i, s] of setting.select.entries()) { const obj = $('#sf-' + i); const s = select[i]; const sf = s ? stageFlow.find(function (x) { return x.order === s.order && x.aid === s.aid; }) : null; obj[0].selectedIndex = sf ? sf.order : -1; } if (asSelect.length === 0 || !checkAsSelectValid(stageFlow, asSelect)) { $('#audit-select').modal('show'); } }; const init = function (cDefine, sfData, cSelect) { stageFlow = sfData; if (cDefine && cDefine[sAuditSelect] && cDefine[sAuditSelect].enable && cDefine[sAuditSelect].setting) { $('#pnl_audit_select').show(); initAuditSelect(cDefine[sAuditSelect].setting, cSelect ? cSelect.audit_select : []); } else { $('#pnl_audit_select').hide(); } }; const reloadReportData = function (result) { // hintBox.unWaitBox(); let pageRst = result.data; if (result.signatureRelInfo && result.signatureRelInfo.length > 0) { CURRENT_ROLE_REL_ID = result.signatureRelInfo[0].id; ROLE_REL_LIST = zTreeOprObj._parseRoleRelList(result.signatureRelInfo[0].rel_content); STAGE_AUDIT = result.stageAudit; rptSignatureHelper.originalRoleRelList = zTreeOprObj._parseRoleRelList(result.signatureRelInfo[0].rel_content); if (current_stage_status === 3) { rptSignatureHelper.mergeSignDate(pageRst); rptSignatureHelper.mergeSignature(pageRst); } } else { CURRENT_ROLE_REL_ID = -1; ROLE_REL_LIST = []; } // if (ROLE_REL_LIST) let canvas = zTreeOprObj.canvas; if (pageRst && pageRst.items && pageRst.items.length > 0) { zTreeOprObj.resetAfter(pageRst); zTreeOprObj.currentRptPageRst = pageRst; zTreeOprObj.maxPages = pageRst.items.length; zTreeOprObj.currentPage = 1; zTreeOprObj.displayPageValue(); let size = JpcCanvasOutput.getReportSizeInPixel(zTreeOprObj.currentRptPageRst, getScreenDPI()); canvas.width = size[0] + 20; if (size[1] > size[0]) { canvas.height = size[1] + 100; } else { canvas.height = size[1] + 50; } // zTreeOprObj.resetESignature(zTreeOprObj.currentRptPageRst); rptSignatureHelper.buildSelectableAccount(); rptSignatureHelper.buildSelectableAccountUsed(); rptSignatureHelper.buildRoleDom(ROLE_LIST); zTreeOprObj.showPage(1, canvas); } else { //返回了无数据表 JpcCanvasOutput.cleanCanvas(canvas); JpcCanvasOutput.drawPageBorder(zTreeOprObj.currentRptPageRst, canvas, getScreenDPI()); } rptCustomObj.init(result.customDefine, result.stageFlow, result.customSelect); try { if (is_debug && result.debugInfo) { console.log('含有key的debug信息:'); for (const k in result.debugInfo.key) { console.log(k + ':', ...result.debugInfo.key[k]); } //console.log(result.debugInfo.key); console.log('其他debug信息:'); for (const di of result.debugInfo.other) { console.log(...di); } } } catch(err) { } }; const resetAuditSelect = function () { const selObj = $('select', '#audit-select-list'); const data = { audit_select: [] }; data.pageSize = rptControlObj.getCurrentPageSize(); data.orientation = rptControlObj.getCurrentOrientation(); data.rpt_tpl_id = zTreeOprObj.currentNode.refId; data.custCfg = CUST_CFG; data.project_id = PROJECT_ID; data.tender_id = TENDER_ID; data.stage_id = getStageId(); data.stage_status = getStageStatus(); data.stage_order = getStageOrder(); data.stage_times = getStageTimes(); for (const s of selObj) { const sf = stageFlow[s.selectedIndex]; if (!sf) { $('#audit-select-hint').html('未选择' + s.attributes['sf-title'].value).show(); return; } data.audit_select.push(sf); } $('#audit-select-hint').hide(); postData('/report/cDefine', data, function (result) { reloadReportData(result); $('#audit-select').modal('hide'); }); }; return {init, resetAuditSelect}; })();