tender_list_info.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. 'use strict';
  2. /**
  3. *
  4. *
  5. * @author Mai
  6. * @date 2018/10/11
  7. * @version
  8. */
  9. const tenderListSpec = (function(){
  10. let colSetCache;
  11. function generateColSetCache() {
  12. const result = {};
  13. colSet.forEach(x => {
  14. result[x.field] = { show: x.show, alias: x.alias || x.name };
  15. });
  16. return result;
  17. };
  18. function getTenderNodeHtml(node, arr, pid) {
  19. const html = [];
  20. html.push('<tr pid="' + pid + '">');
  21. // 名称
  22. if (colSetCache.name.show) {
  23. html.push('<td style="min-width: 300px;" class="in-' + node.level + '">');
  24. if (node.cid) {
  25. 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> ');
  26. html.push((node.level === 1 ? '<b>' : ''), node.name, (node.level === 1 ? '</b>' : ''));
  27. } else {
  28. html.push('<span class="text-muted mr-2">');
  29. html.push(arr.indexOf(node) === arr.length - 1 ? '└' : '├');
  30. html.push('</span>');
  31. //html.push('<a href="/tender/' + node.id + '">', node[c.field], '</a>');
  32. html.push('<a href="javascript: void(0)" name="name" style="min-width: 300px;word-break:break-all;" id="' + node.id + '">', node.name, '</a>');
  33. }
  34. html.push('</td>');
  35. }
  36. // 计量模式
  37. if (colSetCache.measure_type.show) {
  38. html.push('<td style="width: 85px" class="text-center">');
  39. if (node.measure_type) {
  40. html.push(node.measure_type === measureType.tz.value ? '0号台账' : '工程量清单');
  41. }
  42. html.push('</td>');
  43. }
  44. // 计量进度
  45. if (colSetCache.calc_flow.show) {
  46. html.push('<td style="width: 125px">');
  47. if (!node.cid && node.cur_flow) {
  48. if (node.progress) {
  49. html.push(node.progress.title + ' (' + '<span class="' + node.progress.status_class + '">' + node.progress.status + '</span>' + ')');
  50. } else {
  51. html.push(node.cur_flow.title + ' (' + '<span class="' + node.cur_flow.status_class + '">' + node.cur_flow.status + '</span>' + ')');
  52. }
  53. }
  54. html.push('</td>');
  55. }
  56. // 当前流程
  57. if (colSetCache.cur_flow.show) {
  58. html.push('<td style="width: 230px">');
  59. if (!node.cid && node.cur_flow) {
  60. const curUser = node.cur_flow instanceof Array && node.cur_flow[0].audit_type && node.cur_flow[0].audit_type !== auditType.key.common
  61. ? transFormToChinese(node.cur_flow[0].audit_order) + '审'
  62. : 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 : ''));
  63. if (node.stage_status !== undefined) {
  64. html.push(((node.stage_count && node.stage_status === auditConst.stage.status.uncheck) || node.ledger_status === auditConst.ledger.status.uncheck)
  65. ? curUser
  66. : `<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>`
  67. );
  68. html.push(`<span class="${node.progress.status_class} ml-1">${node.progress.status}</span>`);
  69. } else {
  70. html.push((node.lastStage && node.lastStage.status === auditConst.stage.status.uncheck) || (!node.lastStage && node.ledger_status === auditConst.ledger.status.uncheck) ? '' :
  71. '<a href="#sp-list" data-toggle="modal" data-target="#sp-list" data-type="' + (node.lastStage ? 'stage' : 'ledger') + '"' +
  72. ' data-tender="' + node.id + '" data-order="' + (node.lastStage ? node.lastStage.order : '') + '">');
  73. html.push(curUser);
  74. html.push((node.lastStage && node.lastStage.status === auditConst.stage.status.uncheck) || (!node.lastStage && node.ledger_status === auditConst.ledger.status.uncheck) ? ' ' :
  75. '</a> ');
  76. if (node.cur_flow instanceof Array) {
  77. html.push('<span class="' + node.cur_flow[0].status_class + '">' + node.cur_flow[0].status + '</span>');
  78. } else {
  79. html.push('<span class="' + node.cur_flow.status_class + '">' + node.cur_flow.status + '</span>');
  80. }
  81. }
  82. }
  83. html.push('</td>');
  84. }
  85. // 上一流程审批时间
  86. // html.push('<td style="width: 7%">');
  87. // if (!node.cid && node.pre_flow) {
  88. // html.push(node.pre_flow.name + ' ' + moment(node.pre_flow.time).format('YYYY-MM-DD'));
  89. // }
  90. // html.push('</td>');
  91. // 签约合同价
  92. if (colSetCache.contract_price.show) {
  93. html.push('<td style="width: 100px" class="text-right">');
  94. html.push(node.contract_price || '');
  95. html.push('</td>');
  96. }
  97. // 0号台账合同
  98. if (colSetCache.total_price.show) {
  99. html.push('<td style="width: 100px" class="text-right">');
  100. html.push(node.total_price || '');
  101. html.push('</td>');
  102. }
  103. // 本期完成
  104. if (colSetCache.gather_tp.show) {
  105. html.push('<td style="width: 100px" class="text-right">');
  106. html.push(node.gather_tp || '');
  107. html.push('</td>');
  108. }
  109. // 截止本期合同
  110. if (colSetCache.end_contract_tp.show) {
  111. html.push('<td style="width: 100px" class="text-right">');
  112. html.push(node.end_contract_tp || '');
  113. html.push('</td>');
  114. }
  115. // 截止本期变更
  116. if (colSetCache.end_qc_tp.show) {
  117. html.push('<td style="width: 100px" class="text-right">');
  118. html.push(node.end_qc_tp || '');
  119. html.push('</td>');
  120. }
  121. // 截止本期完成
  122. if (colSetCache.end_gather_tp.show) {
  123. html.push('<td style="width: 100px" class="text-right">');
  124. html.push(node.end_gather_tp || '');
  125. html.push('</td>');
  126. }
  127. // 截止上期完成
  128. if (colSetCache.pre_gather_tp.show) {
  129. html.push('<td style="width: 100px" class="text-right">');
  130. html.push(node.pre_gather_tp || '');
  131. html.push('</td>');
  132. }
  133. // 预付款
  134. if (colSetCache.advance_tp.show) {
  135. html.push('<td style="width: 100px" class="text-right">');
  136. html.push(node.advance_tp || '');
  137. html.push('</td>');
  138. }
  139. // 本期应付
  140. if (colSetCache.yf_tp.show) {
  141. html.push('<td style="width: 100px" class="text-right">');
  142. html.push(node.yf_tp || '');
  143. html.push('</td>');
  144. }
  145. // 截止本期应付
  146. if (colSetCache.end_yf_tp.show) {
  147. html.push('<td style="width: 100px" class="text-right">');
  148. html.push(node.end_yf_tp || '');
  149. html.push('</td>');
  150. }
  151. // 本期实付
  152. if (colSetCache.sf_tp.show) {
  153. html.push('<td style="width: 100px" class="text-right">');
  154. html.push(node.sf_tp || '');
  155. html.push('</td>');
  156. }
  157. // 截止本期实付
  158. if (colSetCache.end_sf_tp.show) {
  159. html.push('<td style="width: 100px" class="text-right">');
  160. html.push(node.end_sf_tp || '');
  161. html.push('</td>');
  162. }
  163. // 本期未付
  164. if (colSetCache.wf_tp.show) {
  165. html.push('<td style="width: 100px" class="text-right">');
  166. html.push(node.wf_tp || '');
  167. html.push('</td>');
  168. }
  169. html.push('</tr>');
  170. return html.join('');
  171. }
  172. function getTenderTreeHeaderHtml() {
  173. colSetCache = generateColSetCache();
  174. const html = [];
  175. html.push('<table class="table table-hover table-bordered">');
  176. html.push('<thead style="position: fixed;left:56px;top: 34px;">', '<tr>');
  177. if (colSetCache.name.show) html.push('<th class="text-center" style="min-width: 300px;">', colSetCache.name.alias, '</th>');
  178. if (colSetCache.measure_type.show) html.push('<th class="text-center" style="width: 85px">', colSetCache.measure_type.alias, '</th>');
  179. if (colSetCache.calc_flow.show) html.push('<th class="text-center" style="width: 125px">', colSetCache.calc_flow.alias, '</th>');
  180. if (colSetCache.cur_flow.show) html.push('<th class="text-center" style="width: 230px">', colSetCache.cur_flow.alias, '</th>');
  181. // html.push('<th class="text-center" style="width: 7%">', '上一流程审批时间', '</th>');
  182. if (colSetCache.contract_price.show) html.push('<th class="text-center" style="width: 100px">', colSetCache.contract_price.alias, '</th>');
  183. if (colSetCache.total_price.show) html.push('<th class="text-center" style="width: 100px">', colSetCache.total_price.alias, '</th>');
  184. if (colSetCache.gather_tp.show) html.push('<th class="text-center" style="width: 100px">', colSetCache.gather_tp.alias, '</th>');
  185. if (colSetCache.end_contract_tp.show) html.push('<th class="text-center" style="width: 100px">', colSetCache.end_contract_tp.alias, '</th>');
  186. if (colSetCache.end_qc_tp.show) html.push('<th class="text-center" style="width: 100px">', colSetCache.end_qc_tp.alias, '</th>');
  187. if (colSetCache.end_gather_tp.show) html.push('<th class="text-center" style="width: 100px">', colSetCache.end_gather_tp.alias, '</th>');
  188. if (colSetCache.pre_gather_tp.show) html.push('<th class="text-center" style="width: 100px">', colSetCache.pre_gather_tp.alias, '</th>');
  189. if (colSetCache.advance_tp.show) html.push('<th class="text-center" style="width: 100px">', colSetCache.advance_tp.alias, '<i class="fa fa-question-circle text-primary" data-placement="bottom" data-toggle="tooltip" data-original-title="预付款流程中截止本期金额"></i>', '</th>');
  190. if (colSetCache.yf_tp.show) html.push('<th class="text-center" style="width: 100px">', colSetCache.yf_tp.alias, '</th>');
  191. if (colSetCache.end_yf_tp.show) html.push('<th class="text-center" style="width: 100px">', colSetCache.end_yf_tp.alias, '</th>');
  192. if (colSetCache.sf_tp.show) html.push('<th class="text-center" style="width: 100px">', colSetCache.sf_tp.alias, '</th>');
  193. if (colSetCache.end_sf_tp.show) html.push('<th class="text-center" style="width: 100px">', colSetCache.end_sf_tp.alias, '</th>');
  194. if (colSetCache.wf_tp.show) html.push('<th class="text-center" style="width: 100px">', colSetCache.wf_tp.alias, '</th>');
  195. html.push('</tr>', '</thead>');
  196. return html.join('');
  197. }
  198. function calculateTender(tender) {
  199. if (tender.stage_tp) {
  200. tender.gather_tp = ZhCalc.sum([tender.stage_tp.contract_tp, tender.stage_tp.qc_tp, tender.stage_tp.pc_tp]);
  201. tender.end_contract_tp = ZhCalc.sum([tender.stage_tp.pre_contract_tp, tender.stage_tp.contract_tp, tender.stage_tp.contract_pc_tp]);
  202. tender.end_qc_tp = ZhCalc.sum([tender.stage_tp.pre_qc_tp, tender.stage_tp.qc_tp, tender.stage_tp.qc_pc_tp]);
  203. tender.end_gather_tp = ZhCalc.add(tender.end_contract_tp, tender.end_qc_tp);
  204. tender.pre_gather_tp = ZhCalc.add(tender.stage_tp.pre_contract_tp, tender.stage_tp.pre_qc_tp);
  205. tender.yf_tp = ZhCalc.add(tender.stage_tp.yf_tp);
  206. tender.end_yf_tp = ZhCalc.add(tender.stage_tp.pre_yf_tp, tender.yf_tp);
  207. tender.sf_tp = ZhCalc.add(tender.stage_tp.sf_tp);
  208. tender.end_sf_tp = ZhCalc.add(tender.stage_tp.pre_sf_tp, tender.sf_tp);
  209. tender.wf_tp = ZhCalc.sub(tender.end_yf_tp, tender.end_sf_tp);
  210. } else if (tender.lastStage) {
  211. tender.gather_tp = ZhCalc.sum([tender.lastStage.contract_tp, tender.lastStage.qc_tp, tender.lastStage.pc_tp]);
  212. tender.end_contract_tp = ZhCalc.sum([tender.lastStage.pre_contract_tp, tender.lastStage.contract_tp, tender.lastStage.contract_pc_tp]);
  213. tender.end_qc_tp = ZhCalc.sum([tender.lastStage.pre_qc_tp, tender.lastStage.qc_tp, tender.lastStage.qc_pc_tp]);
  214. tender.end_gather_tp = ZhCalc.add(tender.end_contract_tp, tender.end_qc_tp);
  215. tender.pre_gather_tp = ZhCalc.add(tender.lastStage.pre_contract_tp, tender.lastStage.pre_qc_tp);
  216. tender.yf_tp = ZhCalc.add(tender.lastStage.yf_tp);
  217. tender.end_yf_tp = ZhCalc.add(tender.lastStage.pre_yf_tp, tender.yf_tp);
  218. tender.sf_tp = ZhCalc.add(tender.lastStage.sf_tp);
  219. tender.end_sf_tp = ZhCalc.add(tender.lastStage.pre_sf_tp, tender.sf_tp);
  220. tender.wf_tp = ZhCalc.sub(tender.end_yf_tp, tender.end_sf_tp);
  221. }
  222. }
  223. function calculateParent(node) {
  224. if (node.children && node.cid) {
  225. node.total_price = 0;
  226. node.gather_tp = 0;
  227. node.end_contract_tp = 0;
  228. node.end_qc_tp = 0;
  229. node.end_gather_tp = 0;
  230. node.pre_gather_tp = 0;
  231. node.yf_tp = 0;
  232. node.end_yf_tp = 0;
  233. node.advance_tp = 0;
  234. node.contract_price = 0;
  235. node.sf_tp = 0;
  236. node.end_sf_tp = 0;
  237. node.wf_tp = 0;
  238. for (const c of node.children) {
  239. calculateParent(c);
  240. node.total_price = ZhCalc.add(node.total_price, c.total_price);
  241. node.gather_tp = ZhCalc.add(node.gather_tp, c.gather_tp);
  242. node.end_contract_tp = ZhCalc.add(node.end_contract_tp, c.end_contract_tp);
  243. node.end_qc_tp = ZhCalc.add(node.end_qc_tp, c.end_qc_tp);
  244. node.end_gather_tp = ZhCalc.add(node.end_gather_tp, c.end_gather_tp);
  245. node.pre_gather_tp = ZhCalc.add(node.pre_gather_tp, c.pre_gather_tp);
  246. node.yf_tp = ZhCalc.add(node.yf_tp, c.yf_tp);
  247. node.end_yf_tp = ZhCalc.add(node.end_yf_tp, c.end_yf_tp);
  248. node.advance_tp = ZhCalc.add(node.advance_tp, c.advance_tp);
  249. node.contract_price = ZhCalc.add(node.contract_price, c.contract_price);
  250. node.sf_tp = ZhCalc.add(node.sf_tp, c.sf_tp);
  251. node.end_sf_tp = ZhCalc.add(node.end_sf_tp, c.end_sf_tp);
  252. node.wf_tp = ZhCalc.add(node.wf_tp, c.wf_tp);
  253. }
  254. }
  255. }
  256. return { getTenderNodeHtml, getTenderTreeHeaderHtml, calculateTender, calculateParent }
  257. })();