contract_tender.js 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. 'use strict';
  2. /**
  3. *
  4. *
  5. * @author Mai
  6. * @date 2018/10/11
  7. * @version
  8. */
  9. const tenderListSpec = (function(){
  10. function getProgressHtml(total, yf, title = '') {
  11. if (total !== 0) {
  12. let yfP = ZhCalc.mul(ZhCalc.div(yf, total, 2), 100, 0);
  13. let other = Math.max(ZhCalc.sub(total, yf), 0);
  14. let otherP = Math.max(100 - yfP, 0);
  15. const html = '<div class="progress">' +
  16. '<div class="progress-bar bg-success" style="width: ' + yfP + '%;" data-placement="bottom" data-toggle="tooltip" data-original-title="'+ title + ':¥' + (yf || 0) + '">' + yfP + '%</div>' +
  17. '<div class="progress-bar bg-gray" style="width: ' + otherP + '%;" data-placement="bottom" data-toggle="tooltip" data-original-title="未完成:¥' + (other || 0) + '">' + otherP + '%</div>' +
  18. '</div>';
  19. return html;
  20. } else {
  21. return '';
  22. }
  23. }
  24. function getTenderNodeHtml(node, arr, pid) {
  25. const html = [];
  26. html.push('<tr pid="' + pid + '">');
  27. // 名称
  28. html.push('<td style="min-width: 200px" class="in-' + node.level + '">');
  29. if (node.cid) {
  30. 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);
  31. } else {
  32. html.push('<span class="text-muted mr-2">');
  33. html.push(arr.indexOf(node) === arr.length - 1 ? '└' : '├');
  34. html.push('</span>');
  35. //html.push('<a href="/tender/' + node.id + '">', node[c.field], '</a>');
  36. 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>');
  37. }
  38. html.push('</td>');
  39. // 创建时间
  40. html.push('<td style="width: 8%" class="text-center">');
  41. html.push(node.create_time ? moment(node.create_time).format('YYYY-MM-DD') : '');
  42. html.push('</td>');
  43. html.push(`<td style="width: 5%" class="text-center">${node.expenses_count || ''}</td>
  44. <td style="width: 8%" class="text-right">${node.expenses_total_price || ''}</td>
  45. <td style="width: 15%">
  46. ${getProgressHtml(node.expenses_total_price, node.expenses_yf_price, '累计应付')}
  47. </td>
  48. <td style="width: 5%" class="text-center">${node.income_count || ''}</td>
  49. <td style="width: 8%" class="text-right">${node.income_total_price || ''}</td>
  50. <td style="width: 15%">
  51. ${getProgressHtml(node.income_total_price, node.income_yf_price, '累计应回')}
  52. </td>`);
  53. // 设置
  54. if (is_admin) {
  55. html.push('<td style="width: 10%" class="text-center">');
  56. if (!node.cid) {
  57. html.push(`<a href="javascript:void(0);" data-toggle="modal" data-stid="${node.id}" class="btn btn-sm btn-outline-primary get-audits"> 成员管理</a>`);
  58. // html.push('<a href="#empower" data-toggle="modal" data-target="#empower" class="btn btn-sm btn-primary ">成员管理</a>');
  59. }
  60. html.push('</td>');
  61. }
  62. html.push('</tr>');
  63. return html.join('');
  64. }
  65. function getTenderTreeHeaderHtml() {
  66. const html = [];
  67. const left = $('#sub-menu').css('display') === 'none' ? 56 : 176;
  68. html.push('<table class="table table-hover table-bordered" id="progress-table">')
  69. html.push('<thead style="position: sticky;left:'+ left +'px;top: 0px;" class="text-center">', '<tr>');
  70. // html.push('<table class="table table-hover table-bordered">');
  71. // html.push('<thead style="position: fixed;left:56px;top: 34px;" class="text-center">', '<tr>');
  72. html.push('<th style="min-width: 200px" rowspan="2">', '标段名称', '</th>');
  73. html.push('<th style="width: 8%" rowspan="2">', '创建时间', '</th>');
  74. html.push('<th colspan="3">支出合同</th>');
  75. html.push('<th colspan="3">收入合同</th>');
  76. if (is_admin) {
  77. html.push('<th style="width: 10%" rowspan="2">', '操作', '</th>');
  78. }
  79. html.push('</tr>');
  80. html.push(`<tr>
  81. <th style="width: 5%">合同个数</th>
  82. <th style="width: 8%">合同金额</th>
  83. <th style="width: 15%">支出进度</th>
  84. <th style="width: 5%">合同个数</th>
  85. <th style="width: 8%">合同金额</th>
  86. <th style="width: 15%">回款进度</th>
  87. </tr>`, '</thead>');
  88. return html.join('');
  89. }
  90. function calculateParent(node) {
  91. if (node.children && node.cid) {
  92. node.expenses_count = 0;
  93. node.expenses_total_price = 0;
  94. node.expenses_yf_price = 0;
  95. node.income_count = 0;
  96. node.income_total_price = 0;
  97. node.income_yf_price = 0;
  98. for (const c of node.children) {
  99. calculateParent(c);
  100. node.expenses_count = ZhCalc.add(node.expenses_count, c.expenses_count);
  101. node.expenses_total_price = ZhCalc.add(node.expenses_total_price, c.expenses_total_price);
  102. node.expenses_yf_price = ZhCalc.add(node.expenses_yf_price, c.expenses_yf_price);
  103. node.income_count = ZhCalc.add(node.income_count, c.income_count);
  104. node.income_total_price = ZhCalc.add(node.income_total_price, c.income_total_price);
  105. node.income_yf_price = ZhCalc.add(node.income_yf_price, c.income_yf_price);
  106. }
  107. }
  108. }
  109. return { getTenderNodeHtml, getTenderTreeHeaderHtml, calculateParent }
  110. })();