index_cost.ejs 58 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221
  1. <link href="/public/css/bootstrap/bootstrap-colorpicker.min.css" rel="stylesheet">
  2. <div class="panel-content" style="background:#2c3237 !important">
  3. <div class="panel-title fluid border-top-0" style="background:#2c3237 !important">
  4. <div class="title-main d-flex justify-content-between">
  5. <div class="d-inline-block mr-2">
  6. <div class="btn-group" id="first-category">
  7. <button type="button" class="btn btn-sm btn-outline-dark text-white dropdown-toggle" data-cid="" data-value="" data-toggle="dropdown">全部</button>
  8. <div class="dropdown-menu" aria-labelledby="zhankai">
  9. <a class="dropdown-item select-cate" data-value="" href="javascript:void(0);">全部</a>
  10. <% if (categoryData.length > 0 && categoryData[0].value.length > 0) { %>
  11. <% for (const c of categoryData[0].value) { %>
  12. <a class="dropdown-item select-cate" data-cid="<%- c.cid %>" data-value="<%- c.id %>" href="javascript:void(0);"><%- c.value %></a>
  13. <% } %>
  14. <% } %>
  15. </div>
  16. </div>
  17. <% if (categoryData[1] && categoryData[1].value.length > 0) { %>
  18. <div class="btn-group" id="second-category" style="display: none">
  19. <button type="button" class="btn btn-sm btn-outline-dark text-white dropdown-toggle" data-cid="" data-value="" data-toggle="dropdown">全部</button>
  20. <div class="dropdown-menu" aria-labelledby="zhankai">
  21. <a class="dropdown-item select-cate" data-value="" href="javascript:void(0);">全部</a>
  22. <% for (const c of categoryData[1].value) { %>
  23. <a class="dropdown-item select-cate" data-cid="<%- c.cid %>" data-value="<%- c.id %>" href="javascript:void(0);"><%- c.value %></a>
  24. <% } %>
  25. </div>
  26. </div>
  27. <% } %>
  28. <% if (categoryData[2] && categoryData[2].value.length > 0) { %>
  29. <div class="btn-group" id="third-category" style="display: none">
  30. <button type="button" class="btn btn-sm btn-outline-dark text-white dropdown-toggle" data-cid="" data-value="" data-toggle="dropdown">全部</button>
  31. <div class="dropdown-menu" aria-labelledby="zhankai">
  32. <a class="dropdown-item select-cate" data-value="" href="javascript:void(0);">全部</a>
  33. <% for (const c of categoryData[2].value) { %>
  34. <a class="dropdown-item select-cate" data-cid="<%- c.cid %>" data-value="<%- c.id %>" href="javascript:void(0);"><%- c.value %></a>
  35. <% } %>
  36. </div>
  37. </div>
  38. <% } %>
  39. </div>
  40. <div>
  41. <a href="javascript:void(0)" title="全屏显示" id="showFull" class="text-white"><i class="fa fa-arrows-alt"></i></a>
  42. <div class="btn-group">
  43. <button type="button" class="btn btn-sm btn-outline-dark text-white dropdown-toggle" data-toggle="dropdown" id="zhankai">成本管理</button>
  44. <div class="dropdown-menu" aria-labelledby="zhankai">
  45. <% for (const i of ctx.subProject.data_collect_pages) { %>
  46. <a class="dropdown-item" href="/sp/<%- ctx.subProject.id %>/datacollect/index/<%- i %>"><% if (i === '7') { %>成本管理<% } else if (i === '8') { %>投资总控<% } else { %>决策大屏<%- i %><% } %></a>
  47. <% } %>
  48. </div>
  49. </div>
  50. </div>
  51. </div>
  52. </div>
  53. <div class="content-wrap" id="big-data">
  54. <div style="height: 30px;background-color: #2c3237; display: none" id="exitfull-div">
  55. <div class="title-main d-flex">
  56. <div class="ml-auto">
  57. <div class="dropdown d-flex float-left mt-1 mr-2">
  58. <button id="exitFull" class="btn btn-sm btn-secondary ml-auto">退出全屏</button>
  59. </div>
  60. </div>
  61. </div>
  62. </div>
  63. <div class="c-body" style="background:#2c3237 !important">
  64. <div class="flex-content">
  65. <div class="row mx-2" style="height: 95.5vh">
  66. <div class="col-9 px-0 height-100">
  67. <div class="row m-0 px-0 mb-2" style="height: 50%;">
  68. <div class="col-4 px-0 bg-dark height-100">
  69. <div class="col-12 text-white pt-2">
  70. <div class="card-big-htext">| 金额对比<span class="float-right mr-2">万元&nbsp;</span></div>
  71. </div>
  72. <div class="col-12 pb-2 text-white m-0 mt-2 bg-dark" style="height: 89%;overflow: auto;">
  73. <style>
  74. .level1-table tbody tr td {
  75. padding: 6px 10px; /* 默认一般是 8~16px,可根据需要继续调小 */
  76. line-height: 1.2;
  77. border-bottom: 1px solid rgba(255,255,255,0.2);
  78. }
  79. .level1-table tbody tr:last-child td {
  80. border-bottom: none;
  81. }
  82. </style>
  83. <table class="level1-table" style="width: 100%; height: 100%;">
  84. <thead style="height: 50px;border-bottom: 1px solid rgba(255,255,255,0.2);background-color: #2C3034;">
  85. <tr class="text-center">
  86. <th>分类</th>
  87. <th>责任成本</th>
  88. <th>实际成本</th>
  89. </tr>
  90. </thead>
  91. <tbody>
  92. <tr>
  93. <td>项目收入</td>
  94. <td class="text-center data_duty_total_in_tp"></td>
  95. <td class="text-center data_total_in_tp"></td>
  96. </tr>
  97. <tr>
  98. <td>项目成本</td>
  99. <td class="text-center data_duty_total_out_tp"></td>
  100. <td class="text-center data_total_out_tp"></td>
  101. </tr>
  102. <tr>
  103. <td>利润</td>
  104. <td class="text-center data_duty_total_profit"></td>
  105. <td class="text-center data_total_profit"></td>
  106. </tr>
  107. <tr>
  108. <td>利润率</td>
  109. <td class="text-center data_duty_total_profit_percent"></td>
  110. <td class="text-center data_total_profit_percent"></td>
  111. </tr>
  112. </tbody>
  113. </table>
  114. </div>
  115. </div>
  116. <div class="col-8 px-0 height-100">
  117. <div class="row mx-2 mb-2 height-100 bg-dark">
  118. <div class="col-12 text-white pt-2 pl-3">
  119. <div class="card-big-htext">| 标段利润及利润率<span class="float-right mr-2">万元&nbsp;</span></div>
  120. </div>
  121. <div class="col-12 m-0" style="height: 88%">
  122. <div class="jlchart" data-chart-num="1" id="jlchart" style="height: 100%; width: 100%;"></div>
  123. </div>
  124. </div>
  125. </div>
  126. </div>
  127. <div class="row m-0 px-0 mr-2 bg-dark" style="height: 49%;">
  128. <div class="col-12 text-white pt-2 pl-3">
  129. <div class="card-big-htext">| 累计计量<span class="float-right mr-2">万元&nbsp;</span></div>
  130. </div>
  131. <div class="col-12 m-0" style="height: 88%">
  132. <div class="jldbchart" id="jldbchart" style="height: 100%; width: 100%;"></div>
  133. </div>
  134. </div>
  135. </div>
  136. <div class="col-3 px-0 height-100">
  137. <div class="row mb-2 bg-dark m-0 p-0" style="height: 31.2vh">
  138. <div class="col-12 text-white pt-2 pl-3">
  139. <div class="card-big-htext">| 期数统计<span class="float-right mr-2">&nbsp;</span></div>
  140. </div>
  141. <!-- <h6 class="card bg-dark text-center text-white m-0 pt-2 pb-3">期数统计</h6>-->
  142. <div class="col-12 p-0 m-0 right-month-height">
  143. <div class="row p-0 m-0 height-100">
  144. <div class="col-6 px-0 height-50">
  145. <div class="card text-center bg-dark text-white border-0 height-100">
  146. <div class="card-body card-small-body height-100">
  147. <h5 class="card-title text-center height-50" style="font-size: 2.80rem;line-height: 200%"><span class="stage_num">0</span></h5>
  148. <p class="card-text text-muted height-50">计量期</p>
  149. </div>
  150. </div>
  151. </div>
  152. <div class="col-6 px-0 height-50">
  153. <div class="card text-center bg-dark text-white border-0 height-100">
  154. <div class="card-body card-small-body height-100">
  155. <h5 class="card-title text-center height-50" style="font-size: 2.80rem;line-height: 200%"><span class="cost_ledger_num">0</span></h5>
  156. <p class="card-text text-muted height-50">成本报审</p>
  157. </div>
  158. </div>
  159. </div>
  160. <div class="col-6 px-0 height-50">
  161. <div class="card text-center bg-dark text-white border-0 border-top-0 height-100">
  162. <div class="card-body card-small-body height-100">
  163. <h5 class="card-title text-center height-50" style="font-size: 2.80rem;line-height: 200%"><span class="cost_book_num">0</span></h5>
  164. <p class="card-text text-muted height-50">财务账面</p>
  165. </div>
  166. </div>
  167. </div>
  168. <div class="col-6 px-0 height-50">
  169. <div class="card text-center bg-dark text-white border-0 height-100">
  170. <div class="card-body card-small-body height-100">
  171. <h5 class="card-title text-center height-50" style="font-size: 2.80rem;line-height: 200%"><span class="cost_analysis_num">0</span></h5>
  172. <p class="card-text text-muted height-50">成本分析</p>
  173. </div>
  174. </div>
  175. </div>
  176. </div>
  177. </div>
  178. </div>
  179. <div class="m-0 mb-2 bg-dark p-0" style="height: 31.2vh">
  180. <div class="row mx-0 mb-2 height-100">
  181. <div class="col-12 text-white pt-2 pl-3">
  182. <div class="card-big-htext">| 利润占比<span class="float-right mr-2">万元&nbsp;</span></div>
  183. </div>
  184. <div class="col-12 m-0" style="height: 88%">
  185. <div class="jlwcdchart" id="jlwcdchart" style="height: 100%; width: 100%;"></div>
  186. </div>
  187. </div>
  188. </div>
  189. <div class="m-0 mb-2 bg-dark p-0" style="height: 31.3vh">
  190. <div class="height-100">
  191. <div class="col-12 text-white pt-2 pl-3">
  192. <div class="card-big-htext">| 利润率排名<span class="float-right mr-2">&nbsp;</span></div>
  193. </div>
  194. <div class="tablebox mt-2" style="height: 80%">
  195. <table id="profit_tableId">
  196. <thead>
  197. <tr class="text-center">
  198. <th width="50">排名</th>
  199. <th>标段</th>
  200. <th width="80">利润率</th>
  201. </tr>
  202. </thead>
  203. <tbody class="tender-data">
  204. </tbody>
  205. </table>
  206. </div>
  207. </div>
  208. </div>
  209. </div>
  210. </div>
  211. </div>
  212. </div>
  213. </div>
  214. </div>
  215. <script src="/public/js/path_tree.js"></script>
  216. <script src="/public/js/shares/tenders2tree.js"></script>
  217. <script src="/public/js/datacollect_scroll.js"></script>
  218. <script type="text/javascript"> autoFlashHeight();</script>
  219. <script type="text/javascript">
  220. // 利润排名占比饼图表
  221. var chart1 = document.getElementsByClassName('jlwcdchart');
  222. option1 = {
  223. tooltip : {
  224. trigger: 'item',
  225. formatter: "{a} <br/>{b} : {c} ({d}%)",
  226. // 当前鼠标位置
  227. // position: 'top',
  228. },
  229. title: {
  230. },
  231. color: ['rgba(38, 217, 217,0.7)','rgba(78, 139, 229,0.7)',
  232. 'rgba(78, 229, 139,0.7)','rgba(108, 78, 229,0.7)',
  233. 'rgba(58,207,221,0.7)','rgba(164, 229, 78,0.7)',
  234. 'rgba(199, 78, 229,0.7)', 'rgba(229, 92, 174, 0.7)',
  235. 'rgba(229, 214, 78, 0.7)', 'rgba(241, 87, 96, 0.7)',
  236. 'rgba(242, 179, 82, 0.7)'],
  237. backgroundColor: '#343a40 ',
  238. // tooltip: {
  239. // trigger: 'item'
  240. // },
  241. // legend: {
  242. // orient: 'vertical',
  243. // left: 'center',
  244. // },
  245. series: [
  246. {
  247. name: '利润金额',
  248. type: 'pie',
  249. radius: '65%',
  250. top:'2%',
  251. formatter: function(name){
  252. return name.length>10?name.substr(0,10)+"...":name;
  253. },
  254. data: [],
  255. emphasis: {
  256. itemStyle: {
  257. shadowBlur: 10,
  258. shadowOffsetX: 0,
  259. shadowColor: 'rgba(0, 0, 0, 0.5)'
  260. }
  261. }
  262. }
  263. ]
  264. };
  265. var myChart1_1 = echarts.init(chart1[0], 'dark');
  266. myChart1_1.setOption(option1);
  267. // 利润统计状图表
  268. option2 = {
  269. title: {
  270. },
  271. color: ['rgba(38, 217, 217,0.7)','rgba(78, 139, 229,0.7)',
  272. 'rgba(78, 229, 139,0.7)','rgba(108, 78, 229,0.7)',
  273. 'rgba(58,207,221,0.7)','rgba(164, 229, 78,0.7)',
  274. 'rgba(199, 78, 229,0.7)', 'rgba(229, 92, 174, 0.7)',
  275. 'rgba(229, 214, 78, 0.7)', 'rgba(241, 87, 96, 0.7)',
  276. 'rgba(242, 179, 82, 0.7)'],
  277. backgroundColor: '#343a40 ',
  278. tooltip: {
  279. trigger: 'axis',
  280. axisPointer: { // 坐标轴指示器,坐标轴触发有效
  281. type: 'shadow' // 默认为直线,可选为:'line' | 'shadow'
  282. },
  283. formatter: function (params) {
  284. let html = params[0].axisValue + '<br/>';
  285. params.forEach(function (item) {
  286. let value = item.value;
  287. if (item.seriesName === '利润率') {
  288. value += '%';
  289. }
  290. html += `
  291. <div style="display:flex;justify-content:space-between;min-width:150px;">
  292. <span>${item.marker}${item.seriesName}</span>
  293. <span style="font-weight:bold;">${value}</span>
  294. </div>
  295. `;
  296. });
  297. return html;
  298. }
  299. },
  300. dataZoom: [
  301. {
  302. brushSelect:false,
  303. // zoomLock: false,
  304. type: 'slider',
  305. show: true,
  306. realtime: true,
  307. showdetail: false,
  308. showDataShadow: false,
  309. // dataZoomIndex: 10,
  310. start: 0,
  311. end: 8,
  312. handleSize: 0,
  313. height: 10,
  314. bottom: '10%',
  315. },
  316. ],
  317. legend: {
  318. top: '5%',
  319. left: 'center',
  320. data: ['利润', '利润率'],
  321. textStyle: {
  322. color: '#fff',
  323. fontSize: 14
  324. },
  325. icon: 'roundRect' // 可选:rect、circle、roundRect
  326. },
  327. grid: {
  328. top:'25%',
  329. left: '3%',
  330. right: '4%',
  331. bottom: '15%',
  332. containLabel: true
  333. },
  334. xAxis: [
  335. {
  336. type: 'category',
  337. data: [],
  338. axisLabel: {
  339. show: true,
  340. interval: 0,
  341. textStyle: {
  342. color: "#fff",
  343. fontSize: 14
  344. },
  345. formatter: function(value) {
  346. var res = value;
  347. if(res.length > 6) {
  348. res = res.substring(0, 5) + "..";
  349. }
  350. return res;
  351. }
  352. }
  353. }
  354. ],
  355. yAxis: [
  356. {
  357. type: 'value',
  358. name:'',
  359. position: 'left',
  360. axisLabel : {
  361. formatter: function (value, index) {
  362. if (value < 0) {
  363. let newValue = Math.abs(value);
  364. if (newValue >= 10000 && newValue < 10000000) {
  365. newValue = newValue / 10000 + "万";
  366. } else if (newValue >= 10000000) {
  367. newValue = newValue / 10000000 + "千万";
  368. }
  369. value = '-' + newValue;
  370. }
  371. if (value >= 10000 && value < 10000000) {
  372. value = value / 10000 + "万";
  373. } else if (value >= 10000000) {
  374. value = value / 10000000 + "千万";
  375. }
  376. return value;
  377. }
  378. },
  379. splitLine: {
  380. show: true,
  381. lineStyle: {
  382. color: 'rgba(255,255,255,0.5)',
  383. type: 'dashed', // 虚线
  384. width: 1
  385. }
  386. }
  387. },
  388. {
  389. type: 'value',
  390. name: '',
  391. position: 'right',
  392. axisLabel: {
  393. formatter: '{value}%'
  394. },
  395. splitLine: {
  396. show: false // 不显示右侧网格线
  397. }
  398. }
  399. ],
  400. series: [
  401. {
  402. name: '利润',
  403. type: 'bar',
  404. emphasis: {
  405. focus: 'series'
  406. },
  407. data: []
  408. },
  409. {
  410. name: '利润率',
  411. type: 'line',
  412. yAxisIndex: 1, // 使用右侧坐标轴
  413. smooth: true,
  414. symbol: 'circle',
  415. symbolSize: 8,
  416. lineStyle: {
  417. width: 3
  418. },
  419. itemStyle: {
  420. color: '#fea844'
  421. },
  422. data: []
  423. }
  424. ]
  425. };
  426. var chart2 = document.getElementsByClassName('jlchart');
  427. var myChart2_1 = echarts.init(chart2[0], 'dark');
  428. myChart2_1.setOption(option2);
  429. // myChart2.setOption(option);
  430. const option4_default = {
  431. title: {
  432. },
  433. color: ['rgba(38, 217, 217,0.7)','rgba(78, 139, 229,0.7)',
  434. 'rgba(78, 229, 139,0.7)','rgba(108, 78, 229,0.7)',
  435. 'rgba(58,207,221,0.7)','rgba(164, 229, 78,0.7)',
  436. 'rgba(199, 78, 229,0.7)', 'rgba(229, 92, 174, 0.7)',
  437. 'rgba(229, 214, 78, 0.7)', 'rgba(241, 87, 96, 0.7)',
  438. 'rgba(242, 179, 82, 0.7)'],
  439. backgroundColor: '#343a40 ',
  440. tooltip: {
  441. trigger: 'axis',
  442. axisPointer: {
  443. type: 'cross',
  444. label: {
  445. backgroundColor: '#6a7985'
  446. }
  447. }
  448. },
  449. legend: {
  450. type: 'scroll',
  451. bottom: '2%',
  452. data: [],
  453. textStyle: {
  454. color: '#fff'
  455. }
  456. },
  457. grid: {
  458. top:'10%',
  459. left: '3%',
  460. right: '4%',
  461. bottom: '15%',
  462. containLabel: true
  463. },
  464. xAxis: [
  465. {
  466. type: 'category',
  467. boundaryGap: false,
  468. data: []
  469. }
  470. ],
  471. yAxis: [
  472. {
  473. type: 'value',
  474. axisLabel : {
  475. formatter: function (value, index) {
  476. if (value < 0) {
  477. let newValue = Math.abs(value);
  478. if (newValue >= 10000 && newValue < 10000000) {
  479. newValue = newValue / 10000 + "万";
  480. } else if (newValue >= 10000000) {
  481. newValue = newValue / 10000000 + "千万";
  482. }
  483. value = '-' + newValue;
  484. }
  485. if (value >= 10000 && value < 10000000) {
  486. value = value / 10000 + "万";
  487. } else if (value >= 10000000) {
  488. value = value / 10000000 + "千万";
  489. }
  490. return value;
  491. }
  492. },
  493. splitLine: {
  494. show: true,
  495. lineStyle: {
  496. color: 'rgba(255,255,255,0.5)',
  497. type: 'dashed', // 虚线
  498. width: 1
  499. }
  500. }
  501. }
  502. ],
  503. dataZoom: [
  504. {
  505. brushSelect: false,
  506. showdetail: false,
  507. show: true,
  508. realtime: true,
  509. dataZoomIndex: 10,
  510. start: 0,
  511. end: 5,
  512. handleSize: 0,
  513. height: 10,
  514. bottom: '10%'
  515. },
  516. ],
  517. series: [],
  518. };
  519. var chart4 = document.getElementsByClassName('jldbchart');
  520. var myChart4_1 = echarts.init(chart4[0], 'dark');
  521. myChart4_1.setOption(option4_default);
  522. function echartsReset() {
  523. myChart1_1.resize();
  524. myChart2_1.resize();
  525. myChart4_1.resize();
  526. }
  527. $(function () {
  528. $('#showFull').click(function () {
  529. const full=document.getElementById("big-data");
  530. launchIntoFullscreen(full);
  531. });
  532. $('#exitFull').click(function () {
  533. exitFullscreen();
  534. })
  535. })
  536. let resizeTimer = null;
  537. $(window).bind('resize', function () {
  538. if (resizeTimer) clearTimeout(resizeTimer);
  539. resizeTimer = setTimeout(function () {
  540. echartsReset();
  541. $(".tableid_").find('th').each(function(i) {
  542. $(this).css('width', $('#tableId').find('th:eq(' + i + ')').innerWidth());
  543. });
  544. }, 500);
  545. })
  546. // 数据全屏
  547. function launchIntoFullscreen(element) {
  548. if(element.requestFullscreen){
  549. element.requestFullscreen();
  550. }
  551. else if(element.mozRequestFullScreen) {
  552. element.mozRequestFullScreen();
  553. }
  554. else if(element.webkitRequestFullscreen) {
  555. element.webkitRequestFullscreen();
  556. }
  557. else if(element.msRequestFullscreen) {
  558. element.msRequestFullscreen();
  559. }
  560. }
  561. function exitFullscreen() {
  562. if(document.exitFullscreen) {
  563. document.exitFullscreen();
  564. } else if(document.mozCancelFullScreen) {
  565. document.mozCancelFullScreen();
  566. } else if(document.webkitExitFullscreen) {
  567. document.webkitExitFullscreen();
  568. }
  569. }
  570. document.addEventListener("fullscreenchange", function (event) {
  571. if (document.fullscreenElement) {
  572. $('#exitfull-div').show();
  573. $('#showFull').hide();
  574. } else {
  575. $('#exitfull-div').hide();
  576. $('#showFull').show();
  577. }
  578. });
  579. </script>
  580. <script>
  581. const originDataCollect = parseInt('<%- ctx.subProject.data_collect %>');
  582. const category = JSON.parse(unescape('<%- escape(JSON.stringify(categoryData)) %>'));
  583. let tenders = '';
  584. // let noticeList = '';
  585. $(function () {
  586. const compareObj = {
  587. curFinalId() {
  588. return this.finalInfo ? this.finalInfo.id : undefined;
  589. },
  590. expand(tree, tag) {
  591. switch (tag) {
  592. case "1":
  593. case "2":
  594. case "3":
  595. case "4":
  596. case "5":
  597. tree.expandByLevel(parseInt(tag));
  598. break;
  599. case "last":
  600. tree.expandByCustom(() => { return true; });
  601. break;
  602. }
  603. },
  604. calcStackedBar(tree) {
  605. const calcField = this.stackedBarField;
  606. const calcFieldColor = { 'gu_tp': '#657798', 'gai_tp': '#EE6666', 'yu_tp': '#74CBED', 'total_price': '#FAC858', 'final_tp': '#62DAAB' };
  607. const calcFieldCaption = { 'gu_tp': '估算', 'gai_tp': '概算', 'yu_tp': '预算', 'total_price': '台账', 'final_tp': '决算' };
  608. const calc = function(node, base){
  609. // const parent = tree.getParent(node);
  610. // if (!parent) {
  611. // base = 0;
  612. // for (const cf of calcField) {
  613. // base = Math.max(node[cf], base);
  614. // }
  615. // }
  616. node.stackedBar = [];
  617. node.stackedBarTips = [];
  618. for (const cf of calcField) {
  619. node.stackedBar.push({color: calcFieldColor[cf], percent: ZhCalc.div(node[cf], base), field: cf});
  620. node.stackedBarTips.push(`${calcFieldCaption[cf]}: ${node[cf] || 0}`);
  621. }
  622. if (node.children) {
  623. for (const child of node.children) {
  624. calc(child, base);
  625. }
  626. }
  627. };
  628. let commonBase = 0;
  629. tree.children.forEach(x => {
  630. for (const cf of calcField) {
  631. commonBase = Math.max(x[cf] || 0, commonBase);
  632. }
  633. });
  634. for (const child of tree.children) {
  635. calc(child, commonBase);
  636. }
  637. },
  638. loadBudgetData(result) {
  639. const compareTree = createNewPathTree('final', {
  640. id: 'id',
  641. pid: 'pid',
  642. order: 'order',
  643. level: 'level',
  644. rootId: -1,
  645. });
  646. const setting = { id: 'tree_id', pid: 'tree_pid', order: 'order', level: 'level', rootId: -1, calcFields: ['total_price'] };
  647. const guTree = createNewPathTree('ledger', setting);
  648. guTree.loadDatas(result.gu);
  649. treeCalc.calculateAll(guTree);
  650. compareTree.loadTree(guTree, function (cur, source) {
  651. cur.base = true;
  652. cur.gu_dgn_qty1 = ZhCalc.add(cur.gu_dgn_qty1, source.dgn_qty1);
  653. cur.gu_dgn_qty2 = ZhCalc.add(cur.gu_dgn_qty2, source.dgn_qty2);
  654. cur.gu_tp = ZhCalc.add(cur.gu_tp, source.total_price);
  655. });
  656. const gaiTree = createNewPathTree('ledger', setting);
  657. gaiTree.loadDatas(result.gai);
  658. treeCalc.calculateAll(gaiTree);
  659. compareTree.loadTree(gaiTree, function (cur, source) {
  660. cur.base = true;
  661. cur.gai_dgn_qty1 = ZhCalc.add(cur.gai_dgn_qty1, source.dgn_qty1);
  662. cur.gai_dgn_qty2 = ZhCalc.add(cur.gai_dgn_qty2, source.dgn_qty2);
  663. cur.gai_tp = ZhCalc.add(cur.gai_tp, source.total_price);
  664. });
  665. const yuTree = createNewPathTree('ledger', setting);
  666. yuTree.loadDatas(result.yu);
  667. treeCalc.calculateAll(yuTree);
  668. compareTree.loadTree(yuTree, function (cur, source) {
  669. cur.base = true;
  670. cur.yu_dgn_qty1 = ZhCalc.add(cur.yu_dgn_qty1, source.dgn_qty1);
  671. cur.yu_dgn_qty2 = ZhCalc.add(cur.yu_dgn_qty2, source.dgn_qty2);
  672. cur.yu_tp = ZhCalc.add(cur.yu_tp, source.total_price);
  673. });
  674. compareTree.afterLoad(node => {
  675. node.gu_dgn_price = ZhCalc.div(node.gu_tp, node.gu_dgn_qty1, 2);
  676. node.gu_dgn_qty = node.gu_dgn_qty1
  677. ? (node.gu_dgn_qty2 ? node.gu_dgn_qty1 + '/' + node.gu_dgn_qty2 : node.gu_dgn_qty1)
  678. : (node.gu_dgn_qty2 ? '/' + node.gu_dgn_qty2 : '');
  679. node.gai_dgn_price = ZhCalc.div(node.gai_tp, node.gai_dgn_qty1, 2);
  680. node.gai_dgn_qty = node.gai_dgn_qty1
  681. ? (node.gai_dgn_qty2 ? node.gai_dgn_qty1 + '/' + node.gai_dgn_qty2 : node.gai_dgn_qty1)
  682. : (node.gai_dgn_qty2 ? '/' + node.gai_dgn_qty2 : '');
  683. node.yu_dgn_price = ZhCalc.div(node.yu_tp, node.yu_dgn_qty1, 2);
  684. node.yu_dgn_qty = node.yu_dgn_qty1
  685. ? (node.yu_dgn_qty2 ? node.yu_dgn_qty1 + '/' + node.yu_dgn_qty2 : node.yu_dgn_qty1)
  686. : (node.yu_dgn_qty2 ? '/' + node.yu_dgn_qty2 : '');
  687. });
  688. compareTree.resortChildrenByCustom(function (x, y) {
  689. const iCode = compareCode(x.code, y.code);
  690. if (iCode) return iCode;
  691. if (!x.name) return -1;
  692. if (!y.name) return 1;
  693. return x.name.localeCompare(y.name);
  694. });
  695. const expandTag = getLocalCache('revise-compare-level');
  696. if (expandTag) compareObj.expand(compareTree, expandTag);
  697. this.calcStackedBar(compareTree);
  698. // console.log(compareTree);
  699. setPageData(compareTree);
  700. },
  701. loadFinalData(result, msg) {
  702. if (msg) toastr.warning(msg);
  703. this.finalInfo = result.finalInfo;
  704. const finalTree = createNewPathTree('ledger', {
  705. id: 'tree_id',
  706. pid: 'tree_pid',
  707. order: 'order',
  708. level: 'level',
  709. rootId: -1,
  710. });
  711. finalTree.loadDatas(result.final);
  712. const expandTag = getLocalCache('revise-compare-level');
  713. if (expandTag) compareObj.expand(finalTree, expandTag);
  714. this.calcStackedBar(finalTree);
  715. // console.log(finalTree);
  716. setPageData(finalTree);
  717. },
  718. loadCacheData(){
  719. const stackedBarCache = 'gai_tp,total_price,final_tp';
  720. this.setStackedBarField(stackedBarCache.split(','));
  721. },
  722. setStackedBarField(field){
  723. this.stackedBarField = field;
  724. },
  725. };
  726. compareObj.loadCacheData();
  727. function compareCode(str1, str2, symbol = '-') {
  728. if (!str1) {
  729. return 1;
  730. } else if (!str2) {
  731. return -1;
  732. }
  733. function compareSubCode(code1, code2) {
  734. if (numReg.test(code1)) {
  735. if (numReg.test(code2)) {
  736. return parseInt(code1) - parseInt(code2);
  737. } else {
  738. return -1
  739. }
  740. } else {
  741. if (numReg.test(code2)) {
  742. return 1;
  743. } else {
  744. return code1 === code2 ? 0 : (code1 < code2 ? -1 : 1); //code1.localeCompare(code2);
  745. }
  746. }
  747. }
  748. const numReg = /^[0-9]+$/;
  749. const aCodes = str1.split(symbol), bCodes = str2.split(symbol);
  750. for (let i = 0, iLength = Math.min(aCodes.length, bCodes.length); i < iLength; ++i) {
  751. const iCompare = compareSubCode(aCodes[i], bCodes[i]);
  752. if (iCompare !== 0) {
  753. return iCompare;
  754. }
  755. }
  756. return aCodes.length - bCodes.length;
  757. }
  758. postData(`/sp/${spid}/datacollect/load`, {}, function (result, msg) {
  759. if (result.budget) {
  760. if (result.budget.final) {
  761. compareObj.loadFinalData(result.budget, msg);
  762. } else {
  763. compareObj.loadBudgetData(result.budget);
  764. }
  765. }
  766. const cost_tenderList = _.filter(result.tenderList, function (item) {
  767. return item.cost_analysis || item.cost_analsis_num || item.cost_ledger_num || item.cost_book_num || item.stage_num;
  768. })
  769. tenders = cost_tenderList;
  770. if (category && category.length > 0) {
  771. if (category[0] && category[0].value.length > 0) {
  772. for (const [i, fc] of category[0].value.entries()) {
  773. const fcCategory = {cid: fc.cid, value: fc.id};
  774. if (_.findIndex(tenders, function (item) {
  775. return _.findIndex(item.category, fcCategory) !== -1;
  776. }) === -1) {
  777. $('#first-category .select-cate').eq(i + 1).hide();
  778. } else {
  779. $('#first-category .select-cate').eq(i + 1).show();
  780. }
  781. }
  782. }
  783. }
  784. setData(tenders, 0);
  785. });
  786. function setPageData(tree) {
  787. let html = '';
  788. if (tree.children.length > 0) {
  789. // 分析第一层结构,获取各个部分金额非全0的及除了回收金额层
  790. const level1List = _.filter(tree.children, function (item) {
  791. return item.name.indexOf('回收金额') === -1 &&
  792. (item.gu_tp || item.gai_tp || (item.final_tp !== undefined && item.final_tp) || item.yu_tp || (item.ctrl_tp !== undefined && item.ctrl_tp))
  793. });
  794. if (level1List.length > 0) {
  795. for (const t of level1List) {
  796. html += '<tr class="text-center">\n' +
  797. ' <td class="text-left"><span data-toggle="tooltip" data-placement="right" data-original-title="'+ t.name +'">'+ (t.name.length > 15 ? t.name.substring(0, 15) + '...' : t.name) +'</span></td>\n' +
  798. ' <td>'+ (t.gu_tp ? ZhCalc.round(ZhCalc.div(t.gu_tp, 10000), 4) : 0) + '</td>\n' +
  799. ' <td>'+ (t.gai_tp ? ZhCalc.round(ZhCalc.div(t.gai_tp, 10000), 4) : 0) +'</td>\n' +
  800. ' <td>'+ (t.yu_tp ? ZhCalc.round(ZhCalc.div(t.yu_tp, 10000), 4) : 0) +'</td>\n' +
  801. ' <td>'+ (t.ctrl_tp ? ZhCalc.round(ZhCalc.div(t.ctrl_tp, 10000), 4) : 0) +'</td>\n' +
  802. ' <td>'+ (t.final_tp ? ZhCalc.round(ZhCalc.div(t.final_tp, 10000), 4) : 0) +'</td>\n' +
  803. ' <td>' + (t.final_tp && t.ctrl_tp ? ZhCalc.round(ZhCalc.div(t.final_tp, t.ctrl_tp) * 100, 2) : 0) + '</td>\n' +
  804. ' </tr>\n';
  805. }
  806. }
  807. }
  808. // 滚动数据
  809. $('.stage-data').eq(0).html(html);
  810. tableScroll('tableId', '100%', 30, 7);
  811. $('#tableId').css({'margin-top': 0});
  812. }
  813. function setData(tenderList, categoryIndex = 0) {
  814. let total_duty_in_tp = 0;
  815. let total_duty_out_tp = 0;
  816. let total_duty_profit = 0;
  817. let total_in_tp = 0;
  818. let total_out_tp = 0;
  819. let total_profit = 0;
  820. let stage_num = 0;
  821. let cost_ledger_num = 0;
  822. let cost_book_num = 0;
  823. let cost_analysis_num = 0;
  824. let tender_html = '';
  825. const chart_option_name = [];
  826. const chart_option2_data = [];
  827. const chart_option3_data = [];
  828. const chart_option1_data = [];
  829. // let option1_is_tender = false;
  830. const chart_category_data = [];
  831. // if (category && category.length > 0 && category[categoryIndex] && category[categoryIndex].value.length > 0) {
  832. // for (const c of category[categoryIndex].value) {
  833. // chart_category_data.push({
  834. // cid: category[categoryIndex].id,
  835. // value: c.id,
  836. // });
  837. // chart_option1_data.push({
  838. // value: 0,
  839. // name: c.value,
  840. // });
  841. // }
  842. // } else {
  843. // option1_is_tender = true;
  844. // }
  845. const chart_option4_data = [];
  846. for(const t of tenderList) {
  847. const stage_tp = t.cost_analysis ? t.cost_analysis.stage_tp : null;
  848. if (stage_tp) {
  849. total_in_tp = ZhCalc.add(total_in_tp, stage_tp.in_tp);
  850. total_out_tp = ZhCalc.add(total_out_tp, stage_tp.out_tp);
  851. total_profit = ZhCalc.add(total_profit, stage_tp.profit);
  852. chart_option2_data.push(stage_tp.profit ? ZhCalc.round(ZhCalc.div(stage_tp.profit, 10000), 0) : 0);
  853. chart_option3_data.push(stage_tp.profit_percent ? stage_tp.profit_percent : 0);
  854. chart_option_name.push(t.name);
  855. chart_option1_data.push({ value: stage_tp.profit ? ZhCalc.round(ZhCalc.div(stage_tp.profit, 10000), 0) : 0, name: t.name});
  856. }
  857. const dutyInfo = t.cost_duty ? t.cost_duty : null;
  858. if (dutyInfo) {
  859. const duty_in_tp = dutyInfo.extra_info ? dutyInfo.extra_info.in_tp : 0;
  860. const duty_out_tp = dutyInfo.stage_tp ? dutyInfo.stage_tp.total_price : 0;
  861. total_duty_in_tp = ZhCalc.add(total_duty_in_tp, duty_in_tp);
  862. total_duty_out_tp = ZhCalc.add(total_duty_out_tp, duty_out_tp);
  863. const profit = ZhCalc.sub(duty_in_tp, duty_out_tp);
  864. total_duty_profit = ZhCalc.add(total_duty_profit, profit);
  865. }
  866. stage_num = ZhCalc.add(stage_num, t.stage_num);
  867. cost_ledger_num = ZhCalc.add(cost_ledger_num, t.cost_ledger_num);
  868. cost_book_num = ZhCalc.add(cost_book_num, t.cost_book_num);
  869. cost_analysis_num = ZhCalc.add(cost_analysis_num, t.cost_analysis_num);
  870. // if (option1_is_tender) {
  871. // if(stage_tp.profit)
  872. // } else {
  873. // const sameObject = _.intersectionWith(t.category, chart_category_data, _.isEqual);
  874. // const index = sameObject[0] ? _.findIndex(chart_category_data, { cid: sameObject[0].cid, value: sameObject[0].value }) : -1;
  875. // if (index !== -1) {
  876. // chart_option1_data[index].value = ZhCalc.add(chart_option1_data[index].value, (stage_tp.profit ? stage_tp.profit : 0));
  877. // }
  878. // }
  879. const one_option4_data = {
  880. id: t.id,
  881. name: t.name,
  882. list: [],
  883. };
  884. for (const s of t.month_stage) {
  885. const index = _.findIndex(one_option4_data.list, { yearmonth: s.yearmonth });
  886. if (index === -1) {
  887. one_option4_data.list.push({
  888. yearmonth: s.yearmonth,
  889. tp: s.tp,
  890. end_tp: s.end_tp,
  891. })
  892. } else {
  893. one_option4_data.list[index].tp = ZhCalc.add(one_option4_data.list[index].tp, s.tp);
  894. one_option4_data.list[index].end_tp = ZhCalc.add(one_option4_data.list[index].end_tp, s.end_tp);
  895. }
  896. }
  897. chart_option4_data.push(one_option4_data);
  898. }
  899. // 根据利润率排行并只显示前5位
  900. let index = 1;
  901. const percent_tender_list = _.orderBy(tenderList, (t) => {
  902. const stage_tp = t.cost_analysis ? t.cost_analysis.stage_tp : null;
  903. return stage_tp && stage_tp.profit_percent ? stage_tp.profit_percent : 0;
  904. }, 'desc').slice(0, 5);
  905. const medalIcons = {
  906. 1: '<i class="fa fa-trophy" style="font-size:18px; color:#F0C040;"></i>',
  907. 2: '<i class="fa fa-trophy" style="font-size:18px; color:#B0B8C1;"></i>',
  908. 3: '<i class="fa fa-trophy" style="font-size:18px; color:#CD7F4A;"></i>',
  909. };
  910. for (const t of percent_tender_list) {
  911. const stage_tp = t.cost_analysis ? t.cost_analysis.stage_tp : null;
  912. if (stage_tp) {
  913. const rankDisplay = medalIcons[index] ?? index;
  914. tender_html += `<tr class="bg-dark">
  915. <td class="text-center py-2">${rankDisplay}</td>
  916. <td class="py-2">${t.name}</td>
  917. <td class="text-center py-2">${stage_tp.profit_percent}%</td>
  918. </tr>`;
  919. index++;
  920. }
  921. }
  922. // console.log(tenderList);
  923. const profit_percent = total_in_tp && total_profit ? ZhCalc.round(ZhCalc.div(total_profit, total_in_tp) * 100, 2) : 0;
  924. const profit_duty_percent = total_duty_in_tp && total_duty_profit ? ZhCalc.round(ZhCalc.div(total_duty_profit, total_duty_in_tp) * 100, 2) : 0;
  925. $('.data_total_profit_percent').text(profit_percent ? profit_percent + '%' : '0%');
  926. $('.data_total_in_tp').text(ZhCalc.round(ZhCalc.div(total_in_tp, 10000), 0));
  927. $('.data_total_out_tp').text(ZhCalc.round(ZhCalc.div(total_out_tp, 10000), 0));
  928. $('.data_total_profit').text(ZhCalc.round(ZhCalc.div(total_profit, 10000), 0));
  929. $('.data_duty_total_profit_percent').text(profit_duty_percent ? profit_duty_percent + '%' : '0%');
  930. $('.data_duty_total_in_tp').text(ZhCalc.round(ZhCalc.div(total_duty_in_tp, 10000), 0));
  931. $('.data_duty_total_out_tp').text(ZhCalc.round(ZhCalc.div(total_duty_out_tp, 10000), 0));
  932. $('.data_duty_total_profit').text(ZhCalc.round(ZhCalc.div(total_duty_profit, 10000), 0));
  933. $('.stage_num').text(stage_num);
  934. $('.cost_ledger_num').text(cost_ledger_num);
  935. $('.cost_analysis_num').text(cost_analysis_num);
  936. $('.cost_book_num').text(cost_book_num);
  937. // 滚动数据
  938. $('.tender-data').eq(0).html(tender_html);
  939. // }
  940. $('[data-toggle="tooltip"]').tooltip();
  941. // 图表数据赋值
  942. const analysis_num = _.filter(tenderList, t => t.cost_analysis).length;
  943. const option2 = myChart2_1.getOption();
  944. option2.dataZoom[0].start = 0;
  945. option2.dataZoom[0].end = computedPosition(analysis_num);
  946. option2.xAxis[0].data = chart_option_name;
  947. option2.series[0].data = chart_option2_data;
  948. option2.series[1].data = chart_option3_data;
  949. if (analysis_num >= 8) {
  950. option2.dataZoom[0].show = true;
  951. } else {
  952. option2.dataZoom[0].show = false;
  953. }
  954. myChart2_1.setOption(option2);
  955. const option4_data = {
  956. yearmonth: [],
  957. series: [],
  958. names: [],
  959. totalMap: {},
  960. }
  961. console.log(chart_option4_data);
  962. if (chart_option4_data.length > 0) {
  963. const monthSet = new Set();
  964. const namesSet = new Set();
  965. chart_option4_data.forEach(tender => {
  966. namesSet.add(tender.name);
  967. tender.list.forEach(item => {
  968. monthSet.add(item.yearmonth);
  969. });
  970. });
  971. option4_data.names = [...namesSet];
  972. option4_data.yearmonth = [...monthSet].sort();
  973. chart_option4_data.forEach(tender => {
  974. const data = [];
  975. let total = 0; // 当前标段累计
  976. option4_data.yearmonth.forEach(month => {
  977. const item = tender.list.find(v => v.yearmonth === month);
  978. // const value = item ? ZhCalc.round(ZhCalc.div(item.tp, 10000), 0) : 0;
  979. const endtp = item ? ZhCalc.round(ZhCalc.div(item.end_tp, 10000), 0) : 0;
  980. total = endtp ? endtp : total; // 累计
  981. data.push(total);
  982. option4_data.totalMap[month] = ZhCalc.add((option4_data.totalMap[month] || 0), total);
  983. });
  984. option4_data.series.push({
  985. name: tender.name,
  986. type: 'line',
  987. smooth: true,
  988. // itemStyle: {
  989. // color: option4_default.color[index % option4_default.color.length]
  990. // },
  991. // lineStyle: {
  992. // color: option4_default.color[index % option4_default.color.length]
  993. // },
  994. data
  995. });
  996. });
  997. option4_data.names.push('合计');
  998. option4_data.series.push({
  999. name: '合计',
  1000. type: 'line',
  1001. smooth: true,
  1002. lineStyle: {
  1003. width: 4,
  1004. color: '#FFD54F'
  1005. },
  1006. itemStyle: {
  1007. color: '#FFD54F'
  1008. },
  1009. symbolSize: 8,
  1010. data: option4_data.yearmonth.map(month => option4_data.totalMap[month] || 0)
  1011. })
  1012. }
  1013. console.log(option4_data);
  1014. const option4 = _.cloneDeep(option4_default);
  1015. option4.dataZoom[0].start = 0;
  1016. option4.dataZoom[0].end = computedPosition(option4_data.yearmonth.length);
  1017. option4.xAxis[0].data = option4_data.yearmonth;
  1018. option4.series = option4_data.series;
  1019. option4.legend.data = option4_data.names;
  1020. if (option4_data.yearmonth.length >= 8) {
  1021. option4.dataZoom[0].show = true;
  1022. } else {
  1023. option4.dataZoom[0].show = false;
  1024. }
  1025. console.log(option4);
  1026. myChart4_1.setOption(option4, true);
  1027. const option1 = myChart1_1.getOption();
  1028. option1.series[0].data = _.filter(chart_option1_data, function (item) {
  1029. return item.value !== 0;
  1030. });
  1031. myChart1_1.setOption(option1);
  1032. // $('#profit_tableId').css({'margin-top': 0});
  1033. }
  1034. // 第一层分类选择
  1035. $("body").on('click', '#first-category .select-cate', function () {
  1036. const id = $(this).data('value');
  1037. $(this).parents('.dropdown-menu').siblings('button').text($(this).text());
  1038. let newTenderList = tenders;
  1039. let categoryIndex = 0;
  1040. if (!id) {
  1041. $('#second-category').hide();
  1042. $('#third-category').hide();
  1043. $('#first-category').children('button').attr('data-cid', '').attr('data-value', '');
  1044. } else {
  1045. // 获取第一层已选类别
  1046. const firstCategory = { cid: parseInt($(this).data('cid')), value: parseInt(id) };
  1047. $('#first-category').children('button').attr('data-cid', $(this).data('cid')).attr('data-value', id);
  1048. newTenderList = _.filter(tenders, function (item) {
  1049. return _.findIndex(item.category, firstCategory) !== -1;
  1050. })
  1051. categoryIndex = 1;
  1052. if (category[1] && category[1].value.length > 0) {
  1053. $('#second-category').show();
  1054. $('#third-category').hide();
  1055. $('#second-category').children('button').text('全部').attr('data-cid', '').attr('data-value', '');
  1056. for (const [i,sc] of category[1].value.entries()) {
  1057. const scCategory = { cid: sc.cid, value: sc.id };
  1058. if (_.findIndex(newTenderList, function (item) {
  1059. return _.findIndex(item.category, scCategory) !== -1;}) === -1) {
  1060. $('#second-category .select-cate').eq(i+1).hide();
  1061. } else {
  1062. $('#second-category .select-cate').eq(i+1).show();
  1063. }
  1064. }
  1065. }
  1066. // categoryList.push(firstCategory);
  1067. }
  1068. setData(newTenderList, categoryIndex);
  1069. // 获取新的tenderList及categoryList
  1070. });
  1071. // 第二层分类选择
  1072. $("body").on('click', '#second-category .select-cate', function () {
  1073. const id = $(this).data('value');
  1074. // 获取第一层已选类别
  1075. const first_cid = $('#first-category').children('button').attr('data-cid');
  1076. const first_value = $('#first-category').children('button').attr('data-value');
  1077. const firstCategory = { cid: parseInt(first_cid), value: parseInt(first_value) };
  1078. let newTenderList = _.filter(tenders, function (item) {
  1079. return _.findIndex(item.category, firstCategory) !== -1;
  1080. });
  1081. // let categoryList = [firstCategory];
  1082. let categoryIndex = 1;
  1083. $(this).parents('.dropdown-menu').siblings('button').text($(this).text());
  1084. if (!id) {
  1085. $('#third-category').hide();
  1086. } else {
  1087. // 获取第二层已选类别
  1088. const secondCategory = { cid: parseInt($(this).data('cid')), value: parseInt(id) };
  1089. $('#second-category').children('button').attr('data-cid', $(this).data('cid')).attr('data-value', id);
  1090. newTenderList = _.filter(newTenderList, function (item) {
  1091. return _.findIndex(item.category, secondCategory) !== -1;
  1092. });
  1093. categoryIndex = 2;
  1094. if (category[2] && category[2].value.length > 0) {
  1095. $('#third-category').show();
  1096. $('#third-category').children('button').text('全部').attr('data-cid', '').attr('data-value', '');
  1097. for (const [i,sc] of category[2].value.entries()) {
  1098. const tcCategory = { cid: sc.cid, value: sc.id };
  1099. if (_.findIndex(newTenderList, function (item) {
  1100. return _.findIndex(item.category, tcCategory) !== -1;}) === -1) {
  1101. $('#third-category .select-cate').eq(i+1).hide();
  1102. } else {
  1103. $('#third-category .select-cate').eq(i+1).show();
  1104. }
  1105. }
  1106. }
  1107. // categoryList.push(secondCategory);
  1108. }
  1109. setData(newTenderList, categoryIndex);
  1110. // 获取新的tenderList及categoryList
  1111. });
  1112. // 第三层分类选择(至多三层)
  1113. $("body").on('click', '#third-category .select-cate', function () {
  1114. const id = $(this).data('value');
  1115. // 获取第一层已选类别
  1116. const first_cid = $('#first-category').children('button').attr('data-cid');
  1117. const first_value = $('#first-category').children('button').attr('data-value');
  1118. const firstCategory = { cid: parseInt(first_cid), value: parseInt(first_value) };
  1119. let newTenderList = _.filter(tenders, function (item) {
  1120. return _.findIndex(item.category, firstCategory) !== -1;
  1121. });
  1122. // 获取第二层已选类别
  1123. const second_cid = $('#second-category').children('button').attr('data-cid');
  1124. const second_value = $('#second-category').children('button').attr('data-value');
  1125. const secondCategory = { cid: parseInt(second_cid), value: parseInt(second_value) };
  1126. newTenderList = _.filter(newTenderList, function (item) {
  1127. return _.findIndex(item.category, secondCategory) !== -1;
  1128. });
  1129. // let categoryList = [firstCategory, secondCategory];
  1130. let categoryIndex = 2;
  1131. $(this).parents('.dropdown-menu').siblings('button').text($(this).text());
  1132. if (!id) {
  1133. $('#third-category').children('button').text('全部').attr('data-cid', '').attr('data-value', '');
  1134. } else {
  1135. $('#third-category').children('button').attr('data-cid', $(this).data('cid')).attr('data-value', id);
  1136. categoryIndex = 3;
  1137. const third_cid = $('#third-category').children('button').attr('data-cid');
  1138. const third_value = $('#third-category').children('button').attr('data-value');
  1139. const thirdCategory = { cid: parseInt(third_cid), value: parseInt(third_value) };
  1140. newTenderList = _.filter(newTenderList, function (item) {
  1141. return _.findIndex(item.category, thirdCategory) !== -1;
  1142. });
  1143. // categoryList.push({ cid: parseInt($(this).data('cid')), value: parseInt($(this).data('value')) });
  1144. }
  1145. setData(newTenderList, categoryIndex);
  1146. // 获取新的tenderList及categoryList
  1147. })
  1148. })
  1149. function formatMoney(s, dot = ',', decimal = 2) {
  1150. if (!s) {
  1151. s = 0;
  1152. return s.toFixed(decimal);
  1153. }
  1154. console.log(parseFloat((s + '').replace(/[^\d\.-]/g, '')).toFixed(decimal) + '');
  1155. // 按decimal位数四舍五入方法
  1156. s = decimal === 0 ? parseFloat((s + '').replace(/[^\d\.-]/g, '')).toFixed(decimal) + '' : (Math.round(parseFloat((s + '').replace(/[^\d\.-]/g, '')) * Math.pow(10, decimal)) / Math.pow(10, decimal)).toFixed(decimal) + '';
  1157. console.log(s, Math.pow(10, decimal));
  1158. if (!decimal) {
  1159. s += '.';
  1160. }
  1161. const l = s.split('.')[0].split('').reverse(),
  1162. r = s.split('.')[1];
  1163. let t = '';
  1164. for (let i = 0; i < l.length; i++) {
  1165. t += l[i] + ((i + 1) % 3 == 0 && (i + 1) != l.length ? dot : '');
  1166. }
  1167. const num = t.split('').reverse().join('') + (decimal === 0 ? '' : '.' + r);
  1168. return num.replace('-,', '-');
  1169. }
  1170. // 计算显示滚动条长度
  1171. function computedPosition(xArrayLength) {
  1172. if (xArrayLength >= 8) {
  1173. return Math.floor(8 / xArrayLength * 100) > 100 ? 100 : Math.floor(8 / xArrayLength * 100);
  1174. // return length <= 10 ? 35 : 100 - Math.floor(35 / length * 100);
  1175. } else {
  1176. return 100;
  1177. }
  1178. }
  1179. </script>