123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- 'use strict';
- /**
- *
- *
- * @author Mai
- * @date 2018/10/11
- * @version
- */
- const tenderListSpec = (function(){
- function getProgressHtml(total, yf, title = '') {
- if (total !== 0) {
- let yfP = ZhCalc.mul(ZhCalc.div(yf, total, 2), 100, 0);
- let other = Math.max(ZhCalc.sub(total, yf), 0);
- let otherP = Math.max(100 - yfP, 0);
- const html = '<div class="progress">' +
- '<div class="progress-bar bg-success" style="width: ' + yfP + '%;" data-placement="bottom" data-toggle="tooltip" data-original-title="'+ title + ':¥' + (yf || 0) + '">' + yfP + '%</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 style="min-width: 200px" 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> ', node.name);
- } 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="/sp/' + spid + '/contract/tender/'+ node.id +'/detail" name="name" style="min-width: 200px;word-break:break-all;" id="' + node.id + '">', node.name, '</a>');
- }
- html.push('</td>');
- // 创建时间
- html.push('<td style="width: 8%" class="text-center">');
- html.push(node.create_time ? moment(node.create_time).format('YYYY-MM-DD') : '');
- html.push('</td>');
- html.push(`<td style="width: 5%" class="text-center">${node.expenses_count || ''}</td>
- <td style="width: 8%" class="text-right">${node.expenses_total_price || ''}</td>
- <td style="width: 15%">
- ${getProgressHtml(node.expenses_total_price, node.expenses_yf_price, '累计应付')}
- </td>
- <td style="width: 5%" class="text-center">${node.income_count || ''}</td>
- <td style="width: 8%" class="text-right">${node.income_total_price || ''}</td>
- <td style="width: 15%">
- ${getProgressHtml(node.income_total_price, node.income_yf_price, '累计应回')}
- </td>`);
- // 设置
- if (is_admin) {
- html.push('<td style="width: 10%" class="text-center">');
- if (!node.cid) {
- html.push(`<a href="javascript:void(0);" data-toggle="modal" data-stid="${node.id}" class="btn btn-sm btn-outline-primary get-audits"> 成员管理</a>`);
- // html.push('<a href="#empower" data-toggle="modal" data-target="#empower" class="btn btn-sm btn-primary ">成员管理</a>');
- }
- 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: 0;" class="text-center">', '<tr>');
- // html.push('<table class="table table-hover table-bordered">');
- // html.push('<thead style="position: fixed;left:56px;top: 34px;" class="text-center">', '<tr>');
- html.push('<th style="min-width: 200px" rowspan="2">', '标段名称', '</th>');
- html.push('<th style="width: 8%" rowspan="2">', '创建时间', '</th>');
- html.push('<th colspan="3">支出合同</th>');
- html.push('<th colspan="3">收入合同</th>');
- if (is_admin) {
- html.push('<th style="width: 10%" rowspan="2">', '操作', '</th>');
- }
- html.push('</tr>');
- html.push(`<tr>
- <th style="width: 5%">合同个数</th>
- <th style="width: 8%">合同金额</th>
- <th style="width: 15%">支出进度</th>
- <th style="width: 5%">合同个数</th>
- <th style="width: 8%">合同金额</th>
- <th style="width: 15%">回款进度</th>
- </tr>`, '</thead>');
- return html.join('');
- }
- function calculateParent(node) {
- if (node.children && node.cid) {
- node.expenses_count = 0;
- node.expenses_total_price = 0;
- node.expenses_yf_price = 0;
- node.income_count = 0;
- node.income_total_price = 0;
- node.income_yf_price = 0;
- for (const c of node.children) {
- calculateParent(c);
- node.expenses_count = ZhCalc.add(node.expenses_count, c.expenses_count);
- node.expenses_total_price = ZhCalc.add(node.expenses_total_price, c.expenses_total_price);
- node.expenses_yf_price = ZhCalc.add(node.expenses_yf_price, c.expenses_yf_price);
- node.income_count = ZhCalc.add(node.income_count, c.income_count);
- node.income_total_price = ZhCalc.add(node.income_total_price, c.income_total_price);
- node.income_yf_price = ZhCalc.add(node.income_yf_price, c.income_yf_price);
- }
- }
- }
- return { getTenderNodeHtml, getTenderTreeHeaderHtml, calculateParent }
- })();
|