tender_list_info.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. 'use strict';
  2. /**
  3. *
  4. *
  5. * @author Mai
  6. * @date 2018/10/11
  7. * @version
  8. */
  9. const tenderListSpec = (function(){
  10. function getTenderNodeHtml(node, arr, pid) {
  11. const html = [];
  12. html.push('<tr pid="' + pid + '">');
  13. // 名称
  14. html.push('<td style="min-width: 300px;" class="in-' + node.level + '">');
  15. if (node.cid) {
  16. 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);
  17. } else {
  18. html.push('<span class="text-muted mr-2">');
  19. html.push(arr.indexOf(node) === arr.length - 1 ? '└' : '├');
  20. html.push('</span>');
  21. //html.push('<a href="/tender/' + node.id + '">', node[c.field], '</a>');
  22. html.push('<a href="javascript: void(0)" name="name" style="min-width: 300px;word-break:break-all;" id="' + node.id + '">', node.name, '</a>');
  23. }
  24. html.push('</td>');
  25. // 计量模式
  26. html.push('<td style="width: 75px" class="text-center">');
  27. if (node.measure_type) {
  28. html.push(node.measure_type === measureType.tz.value ? '0号台账' : '工程量清单');
  29. }
  30. html.push('</td>');
  31. // 计量进度
  32. html.push('<td style="width: 105px">');
  33. if (!node.cid && node.cur_flow) {
  34. if (node.progress) {
  35. html.push(node.progress.title + ' (' + '<span class="' + node.progress.status_class +'">' + node.progress.status + '</span>' + ')');
  36. } else {
  37. html.push(node.cur_flow.title + ' (' + '<span class="' + node.cur_flow.status_class +'">' + node.cur_flow.status + '</span>' + ')');
  38. }
  39. }
  40. html.push('</td>');
  41. // 当前流程
  42. html.push('<td style="width: 230px">');
  43. if (!node.cid && node.cur_flow) {
  44. if (node.stage_status !== undefined) {
  45. const curUser = node.cur_flow.name + (node.cur_flow.role ? '-'+node.cur_flow.role : '');
  46. html.push((node.stage_status === auditConst.stage.status.uncheck || node.ledger_status === auditConst.ledger.status.uncheck)
  47. ? curUser
  48. : `<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>`
  49. );
  50. html.push(`<span class="${node.progress.status_class} ml-1">${node.progress.status}</span>`);
  51. } else {
  52. html.push((node.lastStage && node.lastStage.status === auditConst.stage.status.uncheck) || (!node.lastStage && node.ledger_status === auditConst.ledger.status.uncheck ) ? '' :
  53. '<a href="#sp-list" data-toggle="modal" data-target="#sp-list" data-type="'+ (node.lastStage ? 'stage' : 'ledger') +'"' +
  54. ' data-tender="'+ node.id +'" data-order="'+ (node.lastStage ? node.lastStage.order : '') +'">');
  55. html.push(node.cur_flow.name+ (node.cur_flow.role ? '-'+node.cur_flow.role : ''));
  56. html.push((node.lastStage && node.lastStage.status === auditConst.stage.status.uncheck) || (!node.lastStage && node.ledger_status === auditConst.ledger.status.uncheck ) ? ' ':
  57. '</a> ');
  58. html.push('<span class="' + node.cur_flow.status_class +'">' + node.cur_flow.status + '</span>');
  59. }
  60. }
  61. html.push('</td>');
  62. // 上一流程审批时间
  63. // html.push('<td style="width: 7%">');
  64. // if (!node.cid && node.pre_flow) {
  65. // html.push(node.pre_flow.name + ' ' + moment(node.pre_flow.time).format('YYYY-MM-DD'));
  66. // }
  67. // html.push('</td>');
  68. // 签约合同价
  69. html.push('<td style="width: 100px" class="text-right">');
  70. html.push(node.contract_price || '');
  71. html.push('</td>');
  72. // 0号台账合同
  73. html.push('<td style="width: 100px" class="text-right">');
  74. html.push(node.total_price || '');
  75. html.push('</td>');
  76. // 本期完成
  77. html.push('<td style="width: 100px" class="text-right">');
  78. html.push(node.gather_tp || '');
  79. html.push('</td>');
  80. // 截止本期合同
  81. html.push('<td style="width: 100px" class="text-right">');
  82. html.push(node.end_contract_tp || '');
  83. html.push('</td>');
  84. // 截止本期变更
  85. html.push('<td style="width: 100px" class="text-right">');
  86. html.push(node.end_qc_tp || '');
  87. html.push('</td>');
  88. // 截止本期完成
  89. html.push('<td style="width: 100px" class="text-right">');
  90. html.push(node.end_gather_tp || '');
  91. html.push('</td>');
  92. // 截止上期完成
  93. html.push('<td style="width: 100px" class="text-right">');
  94. html.push(node.pre_gather_tp || '');
  95. html.push('</td>');
  96. // 预付款
  97. html.push('<td style="width: 100px" class="text-right">');
  98. html.push(node.advance_tp || '');
  99. html.push('</td>');
  100. // 本期应付
  101. html.push('<td style="width: 100px" class="text-right">');
  102. html.push(node.yf_tp || '');
  103. html.push('</td>');
  104. // 截止本期应付
  105. html.push('<td style="width: 100px" class="text-right">');
  106. html.push(node.end_yf_tp || '');
  107. html.push('</td>');
  108. html.push('</tr>');
  109. return html.join('');
  110. }
  111. function getTenderTreeHeaderHtml() {
  112. const html = [];
  113. html.push('<table class="table table-hover table-bordered">');
  114. html.push('<thead style="position: fixed;left:56px;top: 34px;">', '<tr>');
  115. html.push('<th class="text-center" style="min-width: 300px;">', '标段名称', '</th>');
  116. html.push('<th class="text-center" style="width: 75px">', '计量模式', '</th>');
  117. html.push('<th class="text-center" style="width: 105px">', '计量进度', '</th>');
  118. html.push('<th class="text-center" style="width: 230px">', '当前流程', '</th>');
  119. // html.push('<th class="text-center" style="width: 7%">', '上一流程审批时间', '</th>');
  120. html.push('<th class="text-center" style="width: 100px">', '签约合同价', '</th>');
  121. html.push('<th class="text-center" style="width: 100px">', '0号台账', '</th>');
  122. html.push('<th class="text-center" style="width: 100px">', '本期完成', '</th>');
  123. html.push('<th class="text-center" style="width: 100px">', '截止本期合同', '</th>');
  124. html.push('<th class="text-center" style="width: 100px">', '截止本期变更', '</th>');
  125. html.push('<th class="text-center" style="width: 100px">', '截止本期完成', '</th>');
  126. html.push('<th class="text-center" style="width: 100px">', '截止上期完成', '</th>');
  127. html.push('<th class="text-center" style="width: 100px">', '预付款', '<i class="fa fa-question-circle text-primary" data-placement="bottom" data-toggle="tooltip" data-original-title="预付款流程中截止本期金额"></i>', '</th>');
  128. html.push('<th class="text-center" style="width: 100px">', '本期应付', '</th>');
  129. html.push('<th class="text-center" style="width: 100px">', '截止本期应付', '</th>');
  130. html.push('</tr>', '</thead>');
  131. return html.join('');
  132. }
  133. function calculateTender(tender) {
  134. if (tender.stage_tp) {
  135. tender.gather_tp = ZhCalc.sum([tender.stage_tp.contract_tp, tender.stage_tp.qc_tp, tender.stage_tp.pc_tp]);
  136. tender.end_contract_tp = ZhCalc.sum([tender.stage_tp.pre_contract_tp, tender.stage_tp.contract_tp, tender.stage_tp.contract_pc_tp]);
  137. tender.end_qc_tp = ZhCalc.sum([tender.stage_tp.pre_qc_tp, tender.stage_tp.qc_tp, tender.stage_tp.qc_pc_tp]);
  138. tender.end_gather_tp = ZhCalc.add(tender.end_contract_tp, tender.end_qc_tp);
  139. tender.pre_gather_tp = ZhCalc.add(tender.stage_tp.pre_contract_tp, tender.stage_tp.pre_qc_tp);
  140. tender.yf_tp = ZhCalc.add(tender.stage_tp.yf_tp);
  141. tender.end_yf_tp = ZhCalc.add(tender.stage_tp.pre_yf_tp, tender.yf_tp);
  142. } else if (tender.lastStage) {
  143. tender.gather_tp = ZhCalc.sum([tender.lastStage.contract_tp, tender.lastStage.qc_tp, tender.lastStage.pc_tp]);
  144. tender.end_contract_tp = ZhCalc.sum([tender.lastStage.pre_contract_tp, tender.lastStage.contract_tp, tender.lastStage.contract_pc_tp]);
  145. tender.end_qc_tp = ZhCalc.sum([tender.lastStage.pre_qc_tp, tender.lastStage.qc_tp, tender.lastStage.qc_pc_tp]);
  146. tender.end_gather_tp = ZhCalc.add(tender.end_contract_tp, tender.end_qc_tp);
  147. tender.pre_gather_tp = ZhCalc.add(tender.lastStage.pre_contract_tp, tender.lastStage.pre_qc_tp);
  148. tender.yf_tp = ZhCalc.add(tender.lastStage.yf_tp);
  149. tender.end_yf_tp = ZhCalc.add(tender.lastStage.pre_yf_tp, tender.yf_tp);
  150. }
  151. }
  152. function calculateParent(node) {
  153. if (node.children && node.cid) {
  154. node.total_price = 0;
  155. node.gather_tp = 0;
  156. node.end_contract_tp = 0;
  157. node.end_qc_tp = 0;
  158. node.end_gather_tp = 0;
  159. node.pre_gather_tp = 0;
  160. node.yf_tp = 0;
  161. node.end_yf_tp = 0;
  162. node.advance_tp = 0;
  163. node.contract_price = 0;
  164. for (const c of node.children) {
  165. calculateParent(c);
  166. node.total_price = ZhCalc.add(node.total_price, c.total_price);
  167. node.gather_tp = ZhCalc.add(node.gather_tp, c.gather_tp);
  168. node.end_contract_tp = ZhCalc.add(node.end_contract_tp, c.end_contract_tp);
  169. node.end_qc_tp = ZhCalc.add(node.end_qc_tp, c.end_qc_tp);
  170. node.end_gather_tp = ZhCalc.add(node.end_gather_tp, c.end_gather_tp);
  171. node.pre_gather_tp = ZhCalc.add(node.pre_gather_tp, c.pre_gather_tp);
  172. node.yf_tp = ZhCalc.add(node.yf_tp, c.yf_tp);
  173. node.end_yf_tp = ZhCalc.add(node.end_yf_tp, c.end_yf_tp);
  174. node.advance_tp = ZhCalc.add(node.advance_tp, c.advance_tp);
  175. node.contract_price = ZhCalc.add(node.contract_price, c.contract_price);
  176. }
  177. }
  178. }
  179. return { getTenderNodeHtml, getTenderTreeHeaderHtml, calculateTender, calculateParent }
  180. })();