'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 = '
' +
'
' + yfP + '%
' +
'
' + otherP + '%
' +
'
';
return html;
} else {
return '';
}
}
function getTenderNodeHtml(node, arr, pid) {
const html = [];
html.push('');
// 名称
html.push('');
if (node.cid) {
html.push(' ', node.name);
} else {
html.push('');
html.push(arr.indexOf(node) === arr.length - 1 ? '└' : '├');
html.push('');
//html.push('', node[c.field], '');
html.push('', node.name, '');
}
html.push(' | ');
// 创建时间
html.push('');
html.push(node.create_time ? moment(node.create_time).format('YYYY-MM-DD') : '');
html.push(' | ');
html.push(`${node.expenses_count || ''} |
${node.expenses_total_price || ''} |
${getProgressHtml(node.expenses_total_price, node.expenses_yf_price, '累计应付')}
|
${node.income_count || ''} |
${node.income_total_price || ''} |
${getProgressHtml(node.income_total_price, node.income_yf_price, '累计应回')}
| `);
// 设置
if (is_admin) {
html.push('');
if (!node.cid) {
html.push(` 成员管理`);
// html.push('成员管理');
}
html.push(' | ');
}
html.push('
');
return html.join('');
}
function getTenderTreeHeaderHtml() {
const html = [];
const left = $('#sub-menu').css('display') === 'none' ? 56 : 176;
html.push('')
html.push('', '');
// html.push('');
// html.push('', '');
html.push('', '标段名称', ' | ');
html.push('', '创建时间', ' | ');
html.push('支出合同 | ');
html.push('收入合同 | ');
if (is_admin) {
html.push('', '操作', ' | ');
}
html.push('
');
html.push(`
合同个数 |
合同金额 |
支出进度 |
合同个数 |
合同金额 |
回款进度 |
`, '');
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 }
})();