tender_list_info.js 11 KB

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