'use strict'; /** * * * @author Mai * @date 2018/10/11 * @version */ const tenderListSpec = (function(){ let colSetCache; function generateColSetCache() { const result = {}; colSet.forEach(x => { result[x.field] = { show: x.show, alias: x.alias || x.name }; }); return result; }; function getTenderNodeHtml(node, arr, pid) { const html = []; html.push(''); // 名称 if (colSetCache.name.show) { html.push(''); if (node.cid) { html.push(' '); html.push((node.level === 1 ? '' : ''), node.name, (node.level === 1 ? '' : '')); } else { html.push(''); html.push(arr.indexOf(node) === arr.length - 1 ? '└' : '├'); html.push(''); //html.push('', node[c.field], ''); html.push('', node.name, ''); } html.push(''); } // 计量模式 if (colSetCache.measure_type.show) { html.push(''); if (node.measure_type) { html.push(node.measure_type === measureType.tz.value ? '0号台账' : '工程量清单'); } html.push(''); } // 计量进度 if (colSetCache.calc_flow.show) { html.push(''); if (!node.cid && node.cur_flow) { if (node.progress) { html.push(node.progress.title + ' (' + '' + node.progress.status + '' + ')'); } else { html.push(node.cur_flow.title + ' (' + '' + node.cur_flow.status + '' + ')'); } } html.push(''); } // 当前流程 if (colSetCache.cur_flow.show) { html.push(''); if (!node.cid && node.cur_flow) { const curUser = node.cur_flow instanceof Array && node.cur_flow[0].audit_type && node.cur_flow[0].audit_type !== auditType.key.common ? transFormToChinese(node.cur_flow[0].audit_order) + '审' : node.cur_flow instanceof Array ? (node.cur_flow[0].name + (node.cur_flow[0].role ? '-' + node.cur_flow[0].role : '')) : (node.cur_flow.name + (node.cur_flow.role ? '-' + node.cur_flow.role : '')); if (node.stage_status !== undefined) { html.push(((node.stage_count && node.stage_status === auditConst.stage.status.uncheck) || node.ledger_status === auditConst.ledger.status.uncheck) ? curUser : `${curUser}` ); html.push(`${node.progress.status}`); } else { html.push((node.lastStage && node.lastStage.status === auditConst.stage.status.uncheck) || (!node.lastStage && node.ledger_status === auditConst.ledger.status.uncheck) ? '' : ''); html.push(curUser); html.push((node.lastStage && node.lastStage.status === auditConst.stage.status.uncheck) || (!node.lastStage && node.ledger_status === auditConst.ledger.status.uncheck) ? ' ' : ' '); if (node.cur_flow instanceof Array) { html.push('' + node.cur_flow[0].status + ''); } else { html.push('' + node.cur_flow.status + ''); } } } html.push(''); } // 上一流程审批时间 // html.push(''); // if (!node.cid && node.pre_flow) { // html.push(node.pre_flow.name + ' ' + moment(node.pre_flow.time).format('YYYY-MM-DD')); // } // html.push(''); // 签约合同价 if (colSetCache.contract_price.show) { html.push(''); html.push(node.contract_price || ''); html.push(''); } // 0号台账合同 if (colSetCache.total_price.show) { html.push(''); html.push(node.total_price || ''); html.push(''); } // 本期完成 if (colSetCache.gather_tp.show) { html.push(''); html.push(node.gather_tp || ''); html.push(''); } // 截止本期合同 if (colSetCache.end_contract_tp.show) { html.push(''); html.push(node.end_contract_tp || ''); html.push(''); } // 截止本期变更 if (colSetCache.end_qc_tp.show) { html.push(''); html.push(node.end_qc_tp || ''); html.push(''); } // 截止本期完成 if (colSetCache.end_gather_tp.show) { html.push(''); html.push(node.end_gather_tp || ''); html.push(''); } // 截止上期完成 if (colSetCache.pre_gather_tp.show) { html.push(''); html.push(node.pre_gather_tp || ''); html.push(''); } // 预付款 if (colSetCache.advance_tp.show) { html.push(''); html.push(node.advance_tp || ''); html.push(''); } // 本期应付 if (colSetCache.yf_tp.show) { html.push(''); html.push(node.yf_tp || ''); html.push(''); } // 截止本期应付 if (colSetCache.end_yf_tp.show) { html.push(''); html.push(node.end_yf_tp || ''); html.push(''); } // 本期实付 if (colSetCache.sf_tp.show) { html.push(''); html.push(node.sf_tp || ''); html.push(''); } // 截止本期实付 if (colSetCache.end_sf_tp.show) { html.push(''); html.push(node.end_sf_tp || ''); html.push(''); } // 本期未付 if (colSetCache.wf_tp.show) { html.push(''); html.push(node.wf_tp || ''); html.push(''); } html.push(''); return html.join(''); } function getTenderTreeHeaderHtml() { colSetCache = generateColSetCache(); const html = []; html.push(''); html.push('', ''); if (colSetCache.name.show) html.push(''); if (colSetCache.measure_type.show) html.push(''); if (colSetCache.calc_flow.show) html.push(''); if (colSetCache.cur_flow.show) html.push(''); // html.push(''); if (colSetCache.contract_price.show) html.push(''); if (colSetCache.total_price.show) html.push(''); if (colSetCache.gather_tp.show) html.push(''); if (colSetCache.end_contract_tp.show) html.push(''); if (colSetCache.end_qc_tp.show) html.push(''); if (colSetCache.end_gather_tp.show) html.push(''); if (colSetCache.pre_gather_tp.show) html.push(''); if (colSetCache.advance_tp.show) html.push(''); if (colSetCache.yf_tp.show) html.push(''); if (colSetCache.end_yf_tp.show) html.push(''); if (colSetCache.sf_tp.show) html.push(''); if (colSetCache.end_sf_tp.show) html.push(''); if (colSetCache.wf_tp.show) html.push(''); html.push('', ''); return html.join(''); } function calculateTender(tender) { if (tender.stage_tp) { tender.gather_tp = ZhCalc.sum([tender.stage_tp.contract_tp, tender.stage_tp.qc_tp, tender.stage_tp.pc_tp]); tender.end_contract_tp = ZhCalc.sum([tender.stage_tp.pre_contract_tp, tender.stage_tp.contract_tp, tender.stage_tp.contract_pc_tp]); tender.end_qc_tp = ZhCalc.sum([tender.stage_tp.pre_qc_tp, tender.stage_tp.qc_tp, tender.stage_tp.qc_pc_tp]); tender.end_gather_tp = ZhCalc.add(tender.end_contract_tp, tender.end_qc_tp); tender.pre_gather_tp = ZhCalc.add(tender.stage_tp.pre_contract_tp, tender.stage_tp.pre_qc_tp); tender.yf_tp = ZhCalc.add(tender.stage_tp.yf_tp); tender.end_yf_tp = ZhCalc.add(tender.stage_tp.pre_yf_tp, tender.yf_tp); tender.sf_tp = ZhCalc.add(tender.stage_tp.sf_tp); tender.end_sf_tp = ZhCalc.add(tender.stage_tp.pre_sf_tp, tender.sf_tp); tender.wf_tp = ZhCalc.sub(tender.end_yf_tp, tender.end_sf_tp); } else if (tender.lastStage) { tender.gather_tp = ZhCalc.sum([tender.lastStage.contract_tp, tender.lastStage.qc_tp, tender.lastStage.pc_tp]); tender.end_contract_tp = ZhCalc.sum([tender.lastStage.pre_contract_tp, tender.lastStage.contract_tp, tender.lastStage.contract_pc_tp]); tender.end_qc_tp = ZhCalc.sum([tender.lastStage.pre_qc_tp, tender.lastStage.qc_tp, tender.lastStage.qc_pc_tp]); tender.end_gather_tp = ZhCalc.add(tender.end_contract_tp, tender.end_qc_tp); tender.pre_gather_tp = ZhCalc.add(tender.lastStage.pre_contract_tp, tender.lastStage.pre_qc_tp); tender.yf_tp = ZhCalc.add(tender.lastStage.yf_tp); tender.end_yf_tp = ZhCalc.add(tender.lastStage.pre_yf_tp, tender.yf_tp); tender.sf_tp = ZhCalc.add(tender.lastStage.sf_tp); tender.end_sf_tp = ZhCalc.add(tender.lastStage.pre_sf_tp, tender.sf_tp); tender.wf_tp = ZhCalc.sub(tender.end_yf_tp, tender.end_sf_tp); } } function calculateParent(node) { if (node.children && node.cid) { node.total_price = 0; node.gather_tp = 0; node.end_contract_tp = 0; node.end_qc_tp = 0; node.end_gather_tp = 0; node.pre_gather_tp = 0; node.yf_tp = 0; node.end_yf_tp = 0; node.advance_tp = 0; node.contract_price = 0; node.sf_tp = 0; node.end_sf_tp = 0; node.wf_tp = 0; for (const c of node.children) { calculateParent(c); node.total_price = ZhCalc.add(node.total_price, c.total_price); node.gather_tp = ZhCalc.add(node.gather_tp, c.gather_tp); node.end_contract_tp = ZhCalc.add(node.end_contract_tp, c.end_contract_tp); node.end_qc_tp = ZhCalc.add(node.end_qc_tp, c.end_qc_tp); node.end_gather_tp = ZhCalc.add(node.end_gather_tp, c.end_gather_tp); node.pre_gather_tp = ZhCalc.add(node.pre_gather_tp, c.pre_gather_tp); node.yf_tp = ZhCalc.add(node.yf_tp, c.yf_tp); node.end_yf_tp = ZhCalc.add(node.end_yf_tp, c.end_yf_tp); node.advance_tp = ZhCalc.add(node.advance_tp, c.advance_tp); node.contract_price = ZhCalc.add(node.contract_price, c.contract_price); node.sf_tp = ZhCalc.add(node.sf_tp, c.sf_tp); node.end_sf_tp = ZhCalc.add(node.end_sf_tp, c.end_sf_tp); node.wf_tp = ZhCalc.add(node.wf_tp, c.wf_tp); } } } return { getTenderNodeHtml, getTenderTreeHeaderHtml, calculateTender, calculateParent } })();
', colSetCache.name.alias, '', colSetCache.measure_type.alias, '', colSetCache.calc_flow.alias, '', colSetCache.cur_flow.alias, '', '上一流程审批时间', '', colSetCache.contract_price.alias, '', colSetCache.total_price.alias, '', colSetCache.gather_tp.alias, '', colSetCache.end_contract_tp.alias, '', colSetCache.end_qc_tp.alias, '', colSetCache.end_gather_tp.alias, '', colSetCache.pre_gather_tp.alias, '', colSetCache.advance_tp.alias, '', '', colSetCache.yf_tp.alias, '', colSetCache.end_yf_tp.alias, '', colSetCache.sf_tp.alias, '', colSetCache.end_sf_tp.alias, '', colSetCache.wf_tp.alias, '