123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170 |
- 'use strict';
- /**
- *
- *
- * @author Mai
- * @date 2018/10/11
- * @version
- */
- const tenderListSpec = (function(){
- function getProgressHtml(total, pre, cur) {
- if (total !== 0) {
- let preP = ZhCalc.mul(ZhCalc.div(pre, total, 2), 100, 0);
- let curP = ZhCalc.mul(ZhCalc.div(cur, total, 2), 100, 0);
- let other = Math.max(ZhCalc.sub(ZhCalc.sub(total, pre), cur), 0);
- let otherP = Math.max(100 - preP - curP, 0);
- const html = '<div class="progress">' +
- '<div class="progress-bar bg-success" style="width: ' + preP + '%;" data-placement="bottom" data-toggle="tooltip" data-original-title="截止上期完成:¥' + (pre || 0) + '">' + preP + '%</div>' +
- '<div class="progress-bar bg-info" style="width: ' + curP + '%;" data-placement="bottom" data-toggle="tooltip" data-original-title="本期完成:¥' + (cur || 0) + '">' + curP + '%</div>' +
- '<div class="progress-bar bg-gray" style="width: ' + otherP + '%;" data-placement="bottom" data-toggle="tooltip" data-original-title="未完成:¥' + (other || 0) + '">' + otherP + '%</div>' +
- '</div>';
- return html;
- } else {
- return '';
- }
- }
- function getTenderNodeHtml(node, arr, pid) {
- const html = [];
- html.push('<tr pid="' + pid + '">');
- // 名称
- html.push('<td width="30%" style="min-width: 300px;" class="in-' + node.level + '">');
- if (node.cid) {
- 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> ');
- html.push((node.level === 1 ? '<b>' : ''), node.name, (node.level === 1 ? '</b>' : ''));
- } else {
- html.push('<span class="text-muted mr-2">');
- html.push(arr.indexOf(node) === arr.length - 1 ? '└' : '├');
- html.push('</span>');
- //html.push('<a href="/tender/' + node.id + '">', node[c.field], '</a>');
- html.push('<a href="javascript: void(0)" name="name" id="' + node.id + '">', node.name, '</a>');
- }
- html.push('</td>');
- // 计量进度
- html.push('<td style="width: 120px">');
- if (!node.cid && node.cur_flow) {
- if (node.progress) {
- html.push(node.progress.title + ' (' + '<span class="' + node.progress.status_class +'">' + node.progress.status + '</span>' + ')');
- } else {
- html.push(node.cur_flow.title + ' (' + '<span class="' + node.cur_flow.status_class +'">' + node.cur_flow.status + '</span>' + ')');
- }
- }
- html.push('</td>');
- // 当前流程
- html.push('<td style="width: 230px">');
- 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
- : `<a href="#sp-list" data-toggle="modal" data-target="#sp-list" data-type="${node.stage_count ? 'stage' : 'ledger'}" data-tender="${node.id}" data-order="${node.stage_count ? node.stage_count + '' : ''}">${curUser}</a>`
- );
- html.push(`<span class="${node.progress.status_class} ml-1">${node.progress.status}</span>`);
- } else {
- html.push((node.lastStage && node.lastStage.status === auditConst.stage.status.uncheck) || (!node.lastStage && node.ledger_status === auditConst.ledger.status.uncheck ) ? '' :
- '<a href="#sp-list" data-toggle="modal" data-target="#sp-list" data-type="'+ (node.lastStage ? 'stage' : 'ledger') +'"' +
- ' data-tender="'+ node.id +'" data-order="'+ (node.lastStage ? node.lastStage.order : '') +'">');
- html.push(curUser);
- html.push((node.lastStage && node.lastStage.status === auditConst.stage.status.uncheck) || (!node.lastStage && node.ledger_status === auditConst.ledger.status.uncheck ) ? ' ':
- '</a> ');
- if (node.cur_flow instanceof Array) {
- html.push('<span class="' + node.cur_flow[0].status_class +'">' + node.cur_flow[0].status + '</span>');
- } else {
- html.push('<span class="' + node.cur_flow.status_class +'">' + node.cur_flow.status + '</span>');
- }
- }
- }
- html.push('</td>');
- // 上一流程审批时间
- html.push('<td style="width: 150px">');
- if (!node.cid && node.pre_flow) {
- if (node.pre_flow instanceof Array) {
- if (node.pre_flow.length > 1) {
- html.push(transFormToChinese(node.pre_flow[0].audit_order) + '审' + ' ' + moment(node.pre_flow[0].time).format('YYYY-MM-DD'));
- } else {
- html.push(node.pre_flow[0].name + ' ' + moment(node.pre_flow[0].time).format('YYYY-MM-DD'));
- }
- } else {
- html.push(node.pre_flow.name + ' ' + moment(node.pre_flow.time).format('YYYY-MM-DD'));
- }
- }
- html.push('</td>');
- // 签约合同价
- html.push('<td width="120px" class="text-right">');
- html.push(node.contract_price ? node.contract_price : '');
- html.push('</td>');
- // 总价
- html.push('<td width="120px" class="text-right">');
- html.push(node.sum_tp ? node.sum_tp : '');
- html.push('</td>');
- // 截止本期累计完成/本期完成/未完成
- html.push('<td width="30%">');
- if (node.lastStage || node.stage_count > 0) {
- html.push(getProgressHtml(node.sum_tp, node.pre_gather_tp, node.gather_tp));
- } else {
- html.push('');
- }
- html.push('</td>');
- html.push('</tr>');
- return html.join('');
- }
- function getTenderTreeHeaderHtml() {
- const html = [];
- const left = $('#sub-menu').css('display') === 'none' ? 56 : 176;
- html.push('<table class="table table-hover table-bordered" id="progress-table">')
- html.push('<thead style="position: sticky;left:'+ left +'px;top: 0px;">', '<tr>');
- // html.push('<thead style="left:56px;top: 34px;">', '<tr>');
- html.push('<th style="width: 30%;min-width: 300px" class="text-center">', '标段名称', '</th>');
- html.push('<th class="text-center" style="width: 120px">', '计量进度', '</th>');
- html.push('<th class="text-center" style="width: 230px">', '当前流程', '</th>');
- html.push('<th class="text-center" style="width: 150px">', '上一流程审批时间', '</th>');
- html.push('<th class="text-center" style="width: 120px">', '签约合同价', '</th>');
- html.push('<th style="width: 120px" class="text-center">', '总价 <i class="fa fa-question-circle text-primary" data-placement="bottom" data-toggle="tooltip" data-original-title="0号台账+截止本期数量变更"></i>', '</th>');
- html.push('<th style="width: 30%" class="text-center">', '截止上期完成/本期完成/未完成', '</th>');
- html.push('</tr>', '</thead>');
- return html.join('');
- }
- function calculateTender(tender) {
- if (tender.stage_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.pre_gather_tp = ZhCalc.add(tender.stage_tp.pre_contract_tp, tender.stage_tp.pre_qc_tp);
- tender.gather_tp = ZhCalc.sum([tender.stage_tp.contract_tp, tender.stage_tp.qc_tp, tender.stage_tp.pc_tp]);
- tender.sum_tp = ZhCalc.add(tender.total_price, tender.end_qc_tp);
- } else if (tender.lastStage) {
- tender.end_qc_tp = ZhCalc.sum([tender.lastStage.pre_qc_tp, tender.lastStage.qc_tp, tender.lastStage.qc_pc_tp]);
- tender.pre_gather_tp = ZhCalc.add(tender.lastStage.pre_contract_tp, tender.lastStage.pre_qc_tp);
- tender.gather_tp = ZhCalc.sum([tender.lastStage.contract_tp, tender.lastStage.qc_tp, tender.lastStage.pc_tp]);
- tender.sum_tp = ZhCalc.add(tender.total_price, tender.end_qc_tp);
- } else {
- tender.sum_tp = tender.total_price;
- }
- }
- function calculateParent(node) {
- if (node.children && node.cid) {
- node.end_qc_tp = 0;
- node.pre_gather_tp = 0;
- node.gather_tp = 0;
- node.sum_tp = 0;
- node.lastStage = 0;
- node.contract_price = 0;
- node.stage_count = 0;
- for (const c of node.children) {
- calculateParent(c);
- node.end_qc_tp = ZhCalc.add(node.end_qc_tp, c.end_qc_tp);
- node.pre_gather_tp = ZhCalc.add(node.pre_gather_tp, c.pre_gather_tp);
- node.gather_tp = ZhCalc.add(node.gather_tp, c.gather_tp);
- node.sum_tp = ZhCalc.add(node.sum_tp, c.sum_tp);
- node.lastStage = c.cid
- ? Math.max(node.lastStage, c.lastStage)
- : (c.lastStage ? Math.max(node.lastStage, c.lastStage.order) : node.lastStage);
- node.stage_count = c.cid ? Math.max(node.stage_count, c.stage_count) : (c.stage_count ? Math.max(node.stage_count, c.stage_count): node.stage_count);
- node.contract_price = ZhCalc.add(node.contract_price, c.contract_price);
- }
- }
- }
- return { getTenderNodeHtml, getTenderTreeHeaderHtml, calculateTender, calculateParent }
- })();
|