tender_list_progress.js 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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, pre, cur) {
  11. if (total !== 0) {
  12. let preP = ZhCalc.mul(ZhCalc.div(pre, total, 2), 100, 0);
  13. let curP = ZhCalc.mul(ZhCalc.div(cur, total, 2), 100, 0);
  14. let other = Math.max(ZhCalc.sub(ZhCalc.sub(total, pre), cur), 0);
  15. let otherP = Math.max(100 - preP - curP, 0);
  16. const html = '<div class="progress">' +
  17. '<div class="progress-bar bg-success" style="width: ' + preP + '%;" data-placement="bottom" data-toggle="tooltip" data-original-title="截止上期完成:¥' + (pre || 0) + '">' + preP + '%</div>' +
  18. '<div class="progress-bar bg-info" style="width: ' + curP + '%;" data-placement="bottom" data-toggle="tooltip" data-original-title="本期完成:¥' + (cur || 0) + '">' + curP + '%</div>' +
  19. '<div class="progress-bar bg-gray" style="width: ' + otherP + '%;" data-placement="bottom" data-toggle="tooltip" data-original-title="未完成:¥' + (other || 0) + '">' + otherP + '%</div>' +
  20. '</div>';
  21. return html;
  22. } else {
  23. return '';
  24. }
  25. }
  26. function getTenderNodeHtml(node, arr, pid) {
  27. const html = [];
  28. html.push('<tr pid="' + pid + '">');
  29. // 名称
  30. html.push('<td width="20%" class="in-' + node.level + '">');
  31. if (node.cid) {
  32. 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);
  33. } else {
  34. html.push('<span class="text-muted mr-2">');
  35. html.push(arr.indexOf(node) === arr.length - 1 ? '└' : '├');
  36. html.push('</span>');
  37. //html.push('<a href="/tender/' + node.id + '">', node[c.field], '</a>');
  38. html.push('<a href="javascript: void(0)" id="' + node.id + '">', node.name, '</a>');
  39. }
  40. html.push('</td>');
  41. // 计量进度
  42. html.push('<td style="width: 8%">');
  43. if (!node.cid && node.cur_flow) {
  44. if (node.progress) {
  45. html.push(node.progress.title + ' (' + '<span class="' + node.progress.status_class +'">' + node.progress.status + '</span>' + ')');
  46. } else {
  47. html.push(node.cur_flow.title + ' (' + '<span class="' + node.cur_flow.status_class +'">' + node.cur_flow.status + '</span>' + ')');
  48. }
  49. }
  50. html.push('</td>');
  51. // 当前流程
  52. html.push('<td style="width: 13%">');
  53. if (!node.cid && node.cur_flow) {
  54. if (node.stage_status !== undefined) {
  55. const curUser = node.cur_flow.name + (node.cur_flow.role ? '-'+node.cur_flow.role : '');
  56. html.push((node.stage_status === auditConst.stage.status.uncheck || node.ledger_status === auditConst.ledger.status.uncheck)
  57. ? curUser
  58. : `<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>`
  59. );
  60. html.push(`<span class="${node.progress.status_class} ml-1">${node.progress.status}</span>`);
  61. } else {
  62. html.push((node.lastStage && node.lastStage.status === auditConst.stage.status.uncheck) || (!node.lastStage && node.ledger_status === auditConst.ledger.status.uncheck ) ? '' :
  63. '<a href="#sp-list" data-toggle="modal" data-target="#sp-list" data-type="'+ (node.lastStage ? 'stage' : 'ledger') +'"' +
  64. ' data-tender="'+ node.id +'" data-order="'+ (node.lastStage ? node.lastStage.order : '') +'">');
  65. html.push(node.cur_flow.name+ (node.cur_flow.role ? '-'+node.cur_flow.role : ''));
  66. html.push((node.lastStage && node.lastStage.status === auditConst.stage.status.uncheck) || (!node.lastStage && node.ledger_status === auditConst.ledger.status.uncheck ) ? ' ':
  67. '</a> ');
  68. html.push('<span class="' + node.cur_flow.status_class +'">' + node.cur_flow.status + '</span>');
  69. }
  70. }
  71. html.push('</td>');
  72. // 上一流程审批时间
  73. html.push('<td style="width: 8%">');
  74. if (!node.cid && node.pre_flow) {
  75. if (node.name === '123456677') console.log(node.pre_flow);
  76. html.push(node.pre_flow.name + ' ' + moment(node.pre_flow.time).format('YYYY-MM-DD'));
  77. }
  78. html.push('</td>');
  79. // 签约合同价
  80. html.push('<td width="8%" class="text-right">');
  81. html.push(node.contract_price ? node.contract_price : '');
  82. html.push('</td>');
  83. // 总价
  84. html.push('<td width="8%" class="text-right">');
  85. html.push(node.sum_tp ? node.sum_tp : '');
  86. html.push('</td>');
  87. // 截止本期累计完成/本期完成/未完成
  88. html.push('<td>');
  89. if (node.lastStage || node.stage_count > 0) {
  90. html.push(getProgressHtml(node.sum_tp, node.pre_gather_tp, node.gather_tp));
  91. } else {
  92. html.push('');
  93. }
  94. html.push('</td>');
  95. html.push('</tr>');
  96. return html.join('');
  97. }
  98. function getTenderTreeHeaderHtml() {
  99. const html = [];
  100. html.push('<table class="table table-hover table-bordered">');
  101. html.push('<thead style="position: fixed;left:56px;top: 34px;">', '<tr>');
  102. html.push('<th style="width: 25%" class="text-center">', '标段名称', '</th>');
  103. html.push('<th class="text-center" style="width: 8%">', '计量进度', '</th>');
  104. html.push('<th class="text-center" style="width: 8%">', '当前流程', '</th>');
  105. html.push('<th class="text-center" style="width: 8%">', '上一流程审批时间', '</th>');
  106. html.push('<th class="text-center" style="width: 8%">', '签约合同价', '</th>');
  107. html.push('<th style="width: 8%" class="text-center">', '总价 <i class="fa fa-question-circle text-primary" data-placement="bottom" data-toggle="tooltip" data-original-title="0号台账+截止本期数量变更"></i>', '</th>');
  108. html.push('<th style="width: 35%" class="text-center">', '截止上期完成/本期完成/未完成', '</th>');
  109. html.push('</tr>', '</thead>');
  110. return html.join('');
  111. }
  112. function calculateTender(tender) {
  113. if (tender.stage_tp) {
  114. tender.end_qc_tp = ZhCalc.sum([tender.stage_tp.pre_qc_tp, tender.stage_tp.qc_tp, tender.stage_tp.qc_pc_tp]);
  115. tender.pre_gather_tp = ZhCalc.add(tender.stage_tp.pre_contract_tp, tender.stage_tp.pre_qc_tp);
  116. tender.gather_tp = ZhCalc.sum([tender.stage_tp.contract_tp, tender.stage_tp.qc_tp, tender.stage_tp.pc_tp]);
  117. tender.sum_tp = ZhCalc.add(tender.total_price, tender.end_qc_tp);
  118. } else if (tender.lastStage) {
  119. tender.end_qc_tp = ZhCalc.sum([tender.lastStage.pre_qc_tp, tender.lastStage.qc_tp, tender.lastStage.qc_pc_tp]);
  120. tender.pre_gather_tp = ZhCalc.add(tender.lastStage.pre_contract_tp, tender.lastStage.pre_qc_tp);
  121. tender.gather_tp = ZhCalc.sum([tender.lastStage.contract_tp, tender.lastStage.qc_tp, tender.lastStage.pc_tp]);
  122. tender.sum_tp = ZhCalc.add(tender.total_price, tender.end_qc_tp);
  123. } else {
  124. tender.sum_tp = tender.total_price;
  125. }
  126. }
  127. function calculateParent(node) {
  128. if (node.children && node.cid) {
  129. node.end_qc_tp = 0;
  130. node.pre_gather_tp = 0;
  131. node.gather_tp = 0;
  132. node.sum_tp = 0;
  133. node.lastStage = 0;
  134. node.contract_price = 0;
  135. node.stage_count = 0;
  136. for (const c of node.children) {
  137. calculateParent(c);
  138. node.end_qc_tp = ZhCalc.add(node.end_qc_tp, c.end_qc_tp);
  139. node.pre_gather_tp = ZhCalc.add(node.pre_gather_tp, c.pre_gather_tp);
  140. node.gather_tp = ZhCalc.add(node.gather_tp, c.gather_tp);
  141. node.sum_tp = ZhCalc.add(node.sum_tp, c.sum_tp);
  142. node.lastStage = c.cid
  143. ? Math.max(node.lastStage, c.lastStage)
  144. : (c.lastStage ? Math.max(node.lastStage, c.lastStage.order) : node.lastStage);
  145. 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);
  146. node.contract_price = ZhCalc.add(node.contract_price, c.contract_price);
  147. }
  148. }
  149. }
  150. return { getTenderNodeHtml, getTenderTreeHeaderHtml, calculateTender, calculateParent }
  151. })();