tender_list_info.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  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. let stageOrder = node.stage_count;
  65. if (node.cur_flow) stageOrder = node.cur_flow instanceof Array ? node.cur_flow[0].order : node.cur_flow.order;
  66. html.push(((node.stage_count && node.stage_status === auditConst.stage.status.uncheck) || node.ledger_status === auditConst.ledger.status.uncheck)
  67. ? curUser
  68. : `<a href="#sp-list" data-toggle="modal" data-target="#sp-list" data-type="${node.stage_count ? 'stage' : 'ledger'}" data-tender="${node.id}" data-order="${stageOrder ? stageOrder + '' : ''}">${curUser}</a>`
  69. );
  70. html.push(`<span class="${node.progress.status_class} ml-1">${node.progress.status}</span>`);
  71. } else {
  72. html.push((node.lastStage && node.lastStage.status === auditConst.stage.status.uncheck) || (!node.lastStage && node.ledger_status === auditConst.ledger.status.uncheck) ? '' :
  73. '<a href="#sp-list" data-toggle="modal" data-target="#sp-list" data-type="' + (node.lastStage ? 'stage' : 'ledger') + '"' +
  74. ' data-tender="' + node.id + '" data-order="' + (node.lastStage ? node.lastStage.order : '') + '">');
  75. html.push(curUser);
  76. html.push((node.lastStage && node.lastStage.status === auditConst.stage.status.uncheck) || (!node.lastStage && node.ledger_status === auditConst.ledger.status.uncheck) ? ' ' :
  77. '</a> ');
  78. if (node.cur_flow instanceof Array) {
  79. html.push('<span class="' + node.cur_flow[0].status_class + '">' + node.cur_flow[0].status + '</span>');
  80. } else {
  81. html.push('<span class="' + node.cur_flow.status_class + '">' + node.cur_flow.status + '</span>');
  82. }
  83. }
  84. }
  85. html.push('</td>');
  86. }
  87. // 上一流程审批时间
  88. // html.push('<td style="width: 7%">');
  89. // if (!node.cid && node.pre_flow) {
  90. // html.push(node.pre_flow.name + ' ' + moment(node.pre_flow.time).format('YYYY-MM-DD'));
  91. // }
  92. // html.push('</td>');
  93. // 签约合同价
  94. if (colSetCache.contract_price.show) {
  95. html.push('<td style="width: 100px" class="text-right">');
  96. html.push(node.contract_price || '');
  97. html.push('</td>');
  98. }
  99. // 0号台账合同
  100. if (colSetCache.total_price.show) {
  101. html.push('<td style="width: 100px" class="text-right">');
  102. html.push(node.total_price || '');
  103. html.push('</td>');
  104. }
  105. // 本期完成
  106. if (colSetCache.gather_tp.show) {
  107. html.push('<td style="width: 100px" class="text-right">');
  108. html.push(node.gather_tp || '');
  109. html.push('</td>');
  110. }
  111. // 截止本期合同
  112. if (colSetCache.end_contract_tp.show) {
  113. html.push('<td style="width: 100px" class="text-right">');
  114. html.push(node.end_contract_tp || '');
  115. html.push('</td>');
  116. }
  117. // 截止本期变更
  118. if (colSetCache.end_qc_tp.show) {
  119. html.push('<td style="width: 100px" class="text-right">');
  120. html.push(node.end_qc_tp || '');
  121. html.push('</td>');
  122. }
  123. // 截止本期完成
  124. if (colSetCache.end_gather_tp.show) {
  125. html.push('<td style="width: 100px" class="text-right">');
  126. html.push(node.end_gather_tp || '');
  127. html.push('</td>');
  128. }
  129. // 截止上期完成
  130. if (colSetCache.pre_gather_tp.show) {
  131. html.push('<td style="width: 100px" class="text-right">');
  132. html.push(node.pre_gather_tp || '');
  133. html.push('</td>');
  134. }
  135. // 预付款
  136. if (colSetCache.advance_tp.show) {
  137. html.push('<td style="width: 100px" class="text-right">');
  138. html.push(node.advance_tp || '');
  139. html.push('</td>');
  140. }
  141. // 本期应付
  142. if (colSetCache.yf_tp.show) {
  143. html.push('<td style="width: 100px" class="text-right">');
  144. html.push(node.yf_tp || '');
  145. html.push('</td>');
  146. }
  147. // 截止本期应付
  148. if (colSetCache.end_yf_tp.show) {
  149. html.push('<td style="width: 100px" class="text-right">');
  150. html.push(node.end_yf_tp || '');
  151. html.push('</td>');
  152. }
  153. // 本期实付
  154. if (colSetCache.sf_tp.show) {
  155. html.push('<td style="width: 100px" class="text-right">');
  156. html.push(node.sf_tp || '');
  157. html.push('</td>');
  158. }
  159. // 截止本期实付
  160. if (colSetCache.end_sf_tp.show) {
  161. html.push('<td style="width: 100px" class="text-right">');
  162. html.push(node.end_sf_tp || '');
  163. html.push('</td>');
  164. }
  165. // 本期未付
  166. if (colSetCache.wf_tp.show) {
  167. html.push('<td style="width: 100px" class="text-right">');
  168. html.push(node.wf_tp || '');
  169. html.push('</td>');
  170. }
  171. html.push('</tr>');
  172. return html.join('');
  173. }
  174. function getTenderTreeHeaderHtml() {
  175. colSetCache = generateColSetCache();
  176. const html = [];
  177. const left = $('#sub-menu').css('display') === 'none' ? 56 : 176;
  178. html.push('<table class="table table-hover table-bordered">');
  179. html.push('<thead style="position: fixed;left:'+ left +'px;top: 34px;">', '<tr>');
  180. if (colSetCache.name.show) html.push('<th class="text-center" style="min-width: 300px;">', colSetCache.name.alias, '</th>');
  181. if (colSetCache.measure_type.show) html.push('<th class="text-center" style="width: 85px">', colSetCache.measure_type.alias, '</th>');
  182. if (colSetCache.calc_flow.show) html.push('<th class="text-center" style="width: 125px">', colSetCache.calc_flow.alias, '</th>');
  183. if (colSetCache.cur_flow.show) html.push('<th class="text-center" style="width: 230px">', colSetCache.cur_flow.alias, '</th>');
  184. // html.push('<th class="text-center" style="width: 7%">', '上一流程审批时间', '</th>');
  185. if (colSetCache.contract_price.show) html.push('<th class="text-center" style="width: 100px">', colSetCache.contract_price.alias, '</th>');
  186. if (colSetCache.total_price.show) html.push('<th class="text-center" style="width: 100px">', colSetCache.total_price.alias, '</th>');
  187. if (colSetCache.gather_tp.show) html.push('<th class="text-center" style="width: 100px">', colSetCache.gather_tp.alias, '</th>');
  188. if (colSetCache.end_contract_tp.show) html.push('<th class="text-center" style="width: 100px">', colSetCache.end_contract_tp.alias, '</th>');
  189. if (colSetCache.end_qc_tp.show) html.push('<th class="text-center" style="width: 100px">', colSetCache.end_qc_tp.alias, '</th>');
  190. if (colSetCache.end_gather_tp.show) html.push('<th class="text-center" style="width: 100px">', colSetCache.end_gather_tp.alias, '</th>');
  191. if (colSetCache.pre_gather_tp.show) html.push('<th class="text-center" style="width: 100px">', colSetCache.pre_gather_tp.alias, '</th>');
  192. 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>');
  193. if (colSetCache.yf_tp.show) html.push('<th class="text-center" style="width: 100px">', colSetCache.yf_tp.alias, '</th>');
  194. if (colSetCache.end_yf_tp.show) html.push('<th class="text-center" style="width: 100px">', colSetCache.end_yf_tp.alias, '</th>');
  195. if (colSetCache.sf_tp.show) html.push('<th class="text-center" style="width: 100px">', colSetCache.sf_tp.alias, '</th>');
  196. if (colSetCache.end_sf_tp.show) html.push('<th class="text-center" style="width: 100px">', colSetCache.end_sf_tp.alias, '</th>');
  197. if (colSetCache.wf_tp.show) html.push('<th class="text-center" style="width: 100px">', colSetCache.wf_tp.alias, '</th>');
  198. html.push('</tr>', '</thead>');
  199. return html.join('');
  200. }
  201. function calculateTender(tender) {
  202. if (tender.stage_tp) {
  203. tender.gather_tp = ZhCalc.sum([tender.stage_tp.contract_tp, tender.stage_tp.qc_tp, tender.stage_tp.pc_tp]);
  204. tender.end_contract_tp = ZhCalc.sum([tender.stage_tp.pre_contract_tp, tender.stage_tp.contract_tp, tender.stage_tp.contract_pc_tp]);
  205. tender.end_qc_tp = ZhCalc.sum([tender.stage_tp.pre_qc_tp, tender.stage_tp.qc_tp, tender.stage_tp.qc_pc_tp]);
  206. tender.end_gather_tp = ZhCalc.add(tender.end_contract_tp, tender.end_qc_tp);
  207. tender.pre_gather_tp = ZhCalc.add(tender.stage_tp.pre_contract_tp, tender.stage_tp.pre_qc_tp);
  208. tender.yf_tp = ZhCalc.add(tender.stage_tp.yf_tp);
  209. tender.end_yf_tp = ZhCalc.add(tender.stage_tp.pre_yf_tp, tender.yf_tp);
  210. tender.sf_tp = ZhCalc.add(tender.stage_tp.sf_tp);
  211. tender.end_sf_tp = ZhCalc.add(tender.stage_tp.pre_sf_tp, tender.sf_tp);
  212. tender.wf_tp = ZhCalc.sub(tender.end_yf_tp, tender.end_sf_tp);
  213. } else if (tender.lastStage) {
  214. tender.gather_tp = ZhCalc.sum([tender.lastStage.contract_tp, tender.lastStage.qc_tp, tender.lastStage.pc_tp]);
  215. tender.end_contract_tp = ZhCalc.sum([tender.lastStage.pre_contract_tp, tender.lastStage.contract_tp, tender.lastStage.contract_pc_tp]);
  216. tender.end_qc_tp = ZhCalc.sum([tender.lastStage.pre_qc_tp, tender.lastStage.qc_tp, tender.lastStage.qc_pc_tp]);
  217. tender.end_gather_tp = ZhCalc.add(tender.end_contract_tp, tender.end_qc_tp);
  218. tender.pre_gather_tp = ZhCalc.add(tender.lastStage.pre_contract_tp, tender.lastStage.pre_qc_tp);
  219. tender.yf_tp = ZhCalc.add(tender.lastStage.yf_tp);
  220. tender.end_yf_tp = ZhCalc.add(tender.lastStage.pre_yf_tp, tender.yf_tp);
  221. tender.sf_tp = ZhCalc.add(tender.lastStage.sf_tp);
  222. tender.end_sf_tp = ZhCalc.add(tender.lastStage.pre_sf_tp, tender.sf_tp);
  223. tender.wf_tp = ZhCalc.sub(tender.end_yf_tp, tender.end_sf_tp);
  224. }
  225. }
  226. function calculateParent(node) {
  227. if (node.children && node.cid) {
  228. node.total_price = 0;
  229. node.gather_tp = 0;
  230. node.end_contract_tp = 0;
  231. node.end_qc_tp = 0;
  232. node.end_gather_tp = 0;
  233. node.pre_gather_tp = 0;
  234. node.yf_tp = 0;
  235. node.end_yf_tp = 0;
  236. node.advance_tp = 0;
  237. node.contract_price = 0;
  238. node.sf_tp = 0;
  239. node.end_sf_tp = 0;
  240. node.wf_tp = 0;
  241. for (const c of node.children) {
  242. calculateParent(c);
  243. node.total_price = ZhCalc.add(node.total_price, c.total_price);
  244. node.gather_tp = ZhCalc.add(node.gather_tp, c.gather_tp);
  245. node.end_contract_tp = ZhCalc.add(node.end_contract_tp, c.end_contract_tp);
  246. node.end_qc_tp = ZhCalc.add(node.end_qc_tp, c.end_qc_tp);
  247. node.end_gather_tp = ZhCalc.add(node.end_gather_tp, c.end_gather_tp);
  248. node.pre_gather_tp = ZhCalc.add(node.pre_gather_tp, c.pre_gather_tp);
  249. node.yf_tp = ZhCalc.add(node.yf_tp, c.yf_tp);
  250. node.end_yf_tp = ZhCalc.add(node.end_yf_tp, c.end_yf_tp);
  251. node.advance_tp = ZhCalc.add(node.advance_tp, c.advance_tp);
  252. node.contract_price = ZhCalc.add(node.contract_price, c.contract_price);
  253. node.sf_tp = ZhCalc.add(node.sf_tp, c.sf_tp);
  254. node.end_sf_tp = ZhCalc.add(node.end_sf_tp, c.end_sf_tp);
  255. node.wf_tp = ZhCalc.add(node.wf_tp, c.wf_tp);
  256. }
  257. }
  258. }
  259. return { getTenderNodeHtml, getTenderTreeHeaderHtml, calculateTender, calculateParent }
  260. })();