tender_list_info.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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: 85px" 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: 125px">');
  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. const curUser = node.cur_flow instanceof Array && node.cur_flow[0].audit_type !== auditType.key.common
  45. ? transFormToChinese(node.cur_flow[0].audit_order) + '审'
  46. : node.cur_flow instanceof Array ? (node.cur_flow[0].name + (node.cur_flow[0].role ? '-'+node.cur_flow[0].role : '')): (node.cur_flow.name + (node.cur_flow.role ? '-'+node.cur_flow.role : ''));
  47. if (node.stage_status !== undefined) {
  48. html.push((node.stage_status === auditConst.stage.status.uncheck || node.ledger_status === auditConst.ledger.status.uncheck)
  49. ? curUser
  50. : `<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>`
  51. );
  52. html.push(`<span class="${node.progress.status_class} ml-1">${node.progress.status}</span>`);
  53. } else {
  54. html.push((node.lastStage && node.lastStage.status === auditConst.stage.status.uncheck) || (!node.lastStage && node.ledger_status === auditConst.ledger.status.uncheck ) ? '' :
  55. '<a href="#sp-list" data-toggle="modal" data-target="#sp-list" data-type="'+ (node.lastStage ? 'stage' : 'ledger') +'"' +
  56. ' data-tender="'+ node.id +'" data-order="'+ (node.lastStage ? node.lastStage.order : '') +'">');
  57. html.push(curUser);
  58. html.push((node.lastStage && node.lastStage.status === auditConst.stage.status.uncheck) || (!node.lastStage && node.ledger_status === auditConst.ledger.status.uncheck ) ? ' ':
  59. '</a> ');
  60. if (node.cur_flow instanceof Array) {
  61. html.push('<span class="' + node.cur_flow[0].status_class +'">' + node.cur_flow[0].status + '</span>');
  62. } else {
  63. html.push('<span class="' + node.cur_flow.status_class +'">' + node.cur_flow.status + '</span>');
  64. }
  65. }
  66. }
  67. html.push('</td>');
  68. // 上一流程审批时间
  69. // html.push('<td style="width: 7%">');
  70. // if (!node.cid && node.pre_flow) {
  71. // html.push(node.pre_flow.name + ' ' + moment(node.pre_flow.time).format('YYYY-MM-DD'));
  72. // }
  73. // html.push('</td>');
  74. // 签约合同价
  75. html.push('<td style="width: 100px" class="text-right">');
  76. html.push(node.contract_price || '');
  77. html.push('</td>');
  78. // 0号台账合同
  79. html.push('<td style="width: 100px" class="text-right">');
  80. html.push(node.total_price || '');
  81. html.push('</td>');
  82. // 本期完成
  83. html.push('<td style="width: 100px" class="text-right">');
  84. html.push(node.gather_tp || '');
  85. html.push('</td>');
  86. // 截止本期合同
  87. html.push('<td style="width: 100px" class="text-right">');
  88. html.push(node.end_contract_tp || '');
  89. html.push('</td>');
  90. // 截止本期变更
  91. html.push('<td style="width: 100px" class="text-right">');
  92. html.push(node.end_qc_tp || '');
  93. html.push('</td>');
  94. // 截止本期完成
  95. html.push('<td style="width: 100px" class="text-right">');
  96. html.push(node.end_gather_tp || '');
  97. html.push('</td>');
  98. // 截止上期完成
  99. html.push('<td style="width: 100px" class="text-right">');
  100. html.push(node.pre_gather_tp || '');
  101. html.push('</td>');
  102. // 预付款
  103. html.push('<td style="width: 100px" class="text-right">');
  104. html.push(node.advance_tp || '');
  105. html.push('</td>');
  106. // 本期应付
  107. html.push('<td style="width: 100px" class="text-right">');
  108. html.push(node.yf_tp || '');
  109. html.push('</td>');
  110. // 截止本期应付
  111. html.push('<td style="width: 100px" class="text-right">');
  112. html.push(node.end_yf_tp || '');
  113. html.push('</td>');
  114. html.push('</tr>');
  115. return html.join('');
  116. }
  117. function getTenderTreeHeaderHtml() {
  118. const html = [];
  119. html.push('<table class="table table-hover table-bordered">');
  120. html.push('<thead style="position: fixed;left:56px;top: 34px;">', '<tr>');
  121. html.push('<th class="text-center" style="min-width: 300px;">', '标段名称', '</th>');
  122. html.push('<th class="text-center" style="width: 85px">', '计量模式', '</th>');
  123. html.push('<th class="text-center" style="width: 125px">', '计量进度', '</th>');
  124. html.push('<th class="text-center" style="width: 230px">', '当前流程', '</th>');
  125. // html.push('<th class="text-center" style="width: 7%">', '上一流程审批时间', '</th>');
  126. html.push('<th class="text-center" style="width: 100px">', '签约合同价', '</th>');
  127. html.push('<th class="text-center" style="width: 100px">', '0号台账', '</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('<th class="text-center" style="width: 100px">', '截止本期变更', '</th>');
  131. html.push('<th class="text-center" style="width: 100px">', '截止本期完成', '</th>');
  132. html.push('<th class="text-center" style="width: 100px">', '截止上期完成', '</th>');
  133. 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>');
  134. html.push('<th class="text-center" style="width: 100px">', '本期应付', '</th>');
  135. html.push('<th class="text-center" style="width: 100px">', '截止本期应付', '</th>');
  136. html.push('</tr>', '</thead>');
  137. return html.join('');
  138. }
  139. function calculateTender(tender) {
  140. if (tender.stage_tp) {
  141. tender.gather_tp = ZhCalc.sum([tender.stage_tp.contract_tp, tender.stage_tp.qc_tp, tender.stage_tp.pc_tp]);
  142. tender.end_contract_tp = ZhCalc.sum([tender.stage_tp.pre_contract_tp, tender.stage_tp.contract_tp, tender.stage_tp.contract_pc_tp]);
  143. tender.end_qc_tp = ZhCalc.sum([tender.stage_tp.pre_qc_tp, tender.stage_tp.qc_tp, tender.stage_tp.qc_pc_tp]);
  144. tender.end_gather_tp = ZhCalc.add(tender.end_contract_tp, tender.end_qc_tp);
  145. tender.pre_gather_tp = ZhCalc.add(tender.stage_tp.pre_contract_tp, tender.stage_tp.pre_qc_tp);
  146. tender.yf_tp = ZhCalc.add(tender.stage_tp.yf_tp);
  147. tender.end_yf_tp = ZhCalc.add(tender.stage_tp.pre_yf_tp, tender.yf_tp);
  148. } else if (tender.lastStage) {
  149. tender.gather_tp = ZhCalc.sum([tender.lastStage.contract_tp, tender.lastStage.qc_tp, tender.lastStage.pc_tp]);
  150. tender.end_contract_tp = ZhCalc.sum([tender.lastStage.pre_contract_tp, tender.lastStage.contract_tp, tender.lastStage.contract_pc_tp]);
  151. tender.end_qc_tp = ZhCalc.sum([tender.lastStage.pre_qc_tp, tender.lastStage.qc_tp, tender.lastStage.qc_pc_tp]);
  152. tender.end_gather_tp = ZhCalc.add(tender.end_contract_tp, tender.end_qc_tp);
  153. tender.pre_gather_tp = ZhCalc.add(tender.lastStage.pre_contract_tp, tender.lastStage.pre_qc_tp);
  154. tender.yf_tp = ZhCalc.add(tender.lastStage.yf_tp);
  155. tender.end_yf_tp = ZhCalc.add(tender.lastStage.pre_yf_tp, tender.yf_tp);
  156. }
  157. }
  158. function calculateParent(node) {
  159. if (node.children && node.cid) {
  160. node.total_price = 0;
  161. node.gather_tp = 0;
  162. node.end_contract_tp = 0;
  163. node.end_qc_tp = 0;
  164. node.end_gather_tp = 0;
  165. node.pre_gather_tp = 0;
  166. node.yf_tp = 0;
  167. node.end_yf_tp = 0;
  168. node.advance_tp = 0;
  169. node.contract_price = 0;
  170. for (const c of node.children) {
  171. calculateParent(c);
  172. node.total_price = ZhCalc.add(node.total_price, c.total_price);
  173. node.gather_tp = ZhCalc.add(node.gather_tp, c.gather_tp);
  174. node.end_contract_tp = ZhCalc.add(node.end_contract_tp, c.end_contract_tp);
  175. node.end_qc_tp = ZhCalc.add(node.end_qc_tp, c.end_qc_tp);
  176. node.end_gather_tp = ZhCalc.add(node.end_gather_tp, c.end_gather_tp);
  177. node.pre_gather_tp = ZhCalc.add(node.pre_gather_tp, c.pre_gather_tp);
  178. node.yf_tp = ZhCalc.add(node.yf_tp, c.yf_tp);
  179. node.end_yf_tp = ZhCalc.add(node.end_yf_tp, c.end_yf_tp);
  180. node.advance_tp = ZhCalc.add(node.advance_tp, c.advance_tp);
  181. node.contract_price = ZhCalc.add(node.contract_price, c.contract_price);
  182. }
  183. }
  184. }
  185. return { getTenderNodeHtml, getTenderTreeHeaderHtml, calculateTender, calculateParent }
  186. })();