fdl.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698
  1. <template>
  2. <div class="ztfx">
  3. <div class="action-bar">
  4. <div class="query mg-b-16">
  5. <div class="query-items">
  6. <div class="query-item">
  7. <div class="lable">日期:</div>
  8. <div class="search-input">
  9. <el-date-picker
  10. v-model="monthValue"
  11. type="year"
  12. placeholder="选择年份"
  13. popper-class="date-select"
  14. :clearable="false"
  15. >
  16. </el-date-picker>
  17. </div>
  18. </div>
  19. <div class="query-item">
  20. <div class="search-input select-btn">
  21. <button class="btn green" @click="onClickSearch">搜索</button>
  22. </div>
  23. <div class="search-input select-btn">
  24. <button class="btn green" @click="exportPDF">导出</button>
  25. </div>
  26. </div>
  27. </div>
  28. </div>
  29. </div>
  30. <el-row :gutter="20" class="table-panel pdfDom">
  31. <el-col :span="24">
  32. <!-- <panel :title="'月度'" :showLine="false"> -->
  33. <div class="table">
  34. <table style="width: 100%" border="0" cellspacing="0">
  35. <thead>
  36. <tr>
  37. <th rowspan="2" class="type1" style="width: 4vh"></th>
  38. <template v-for="m of monthData" :key="m">
  39. <th style="width: 6vh" class="type1" rowspan="2">{{ m }}</th>
  40. </template>
  41. </tr>
  42. </thead>
  43. </table>
  44. <div style="">
  45. <table
  46. style="width: 100%; text-align: center"
  47. border="0"
  48. cellspacing="0"
  49. >
  50. <tbody>
  51. <tr>
  52. <td style="width: 4vh"></td>
  53. <template v-for="(x, i) of GsList" :key="i">
  54. <td style="width: 3vh">本期</td>
  55. <td style="width: 3vh">同期</td>
  56. </template>
  57. </tr>
  58. <tr v-for="(items,key,index) in stations" :key="index">
  59. <td class="td-item" style="width: 4vh">{{items.name}}</td>
  60. <template v-for="(item, index) of items.children" :key="index">
  61. <td style="width: 3vh">
  62. {{ item.current }}
  63. <template v-if="item.compare === -1">
  64. <span class="svg-icon svg-icon-yellow">
  65. <svg-icon svgid="svg-arrow-dpwn-1" />
  66. </span>
  67. </template>
  68. <template v-if="item.compare === 1">
  69. <span class="svg-icon svg-icon-green">
  70. <svg-icon svgid="svg-arrow-up-1" />
  71. </span>
  72. </template>
  73. </td>
  74. <td style="width: 3vh">
  75. {{ item.sameperiod }}
  76. </td>
  77. </template>
  78. </tr>
  79. <!-- <tr>
  80. <td style="width: 4vh"></td>
  81. <template v-for="(x, i) of MhsLists" :key="i">
  82. <td style="width: 3vh">本期</td>
  83. <td style="width: 3vh">同期</td>
  84. </template>
  85. </tr>
  86. <tr>
  87. <td class="td-item" style="width: 4vh">麻黄山</td>
  88. <template v-for="(item, index) of MhsLists" :key="index">
  89. <td style="width: 3vh">
  90. {{ item.current }}
  91. <template v-if="item.compare === -1">
  92. <span class="svg-icon svg-icon-yellow">
  93. <svg-icon svgid="svg-arrow-dpwn-1" />
  94. </span>
  95. </template>
  96. <template v-if="item.compare === 1">
  97. <span class="svg-icon svg-icon-green">
  98. <svg-icon svgid="svg-arrow-up-1" />
  99. </span>
  100. </template>
  101. </td>
  102. <td style="width: 3vh">
  103. {{ item.sameperiod }}
  104. </td>
  105. </template>
  106. </tr>
  107. <tr>
  108. <td class="td-item" style="width: 4vh">牛首山</td>
  109. <template v-for="(item, index) of NshList" :key="index">
  110. <td style="width: 3vh">
  111. {{ item.current }}
  112. <template v-if="item.compare === -1">
  113. <span class="svg-icon svg-icon-yellow">
  114. <svg-icon svgid="svg-arrow-dpwn-1" />
  115. </span>
  116. </template>
  117. <template v-if="item.compare === 1">
  118. <span class="svg-icon svg-icon-green">
  119. <svg-icon svgid="svg-arrow-up-1" />
  120. </span>
  121. </template>
  122. </td>
  123. <td style="width: 3vh">
  124. {{ item.sameperiod }}
  125. </td>
  126. </template>
  127. </tr>
  128. <tr>
  129. <td class="td-item" style="width: 4vh">青山</td>
  130. <template v-for="(item, index) of QshList" :key="index">
  131. <td style="width: 3vh">
  132. {{ item.current }}
  133. <template v-if="item.compare === -1">
  134. <span class="svg-icon svg-icon-yellow">
  135. <svg-icon svgid="svg-arrow-dpwn-1" />
  136. </span>
  137. </template>
  138. <template v-if="item.compare === 1">
  139. <span class="svg-icon svg-icon-green">
  140. <svg-icon svgid="svg-arrow-up-1" />
  141. </span>
  142. </template>
  143. </td>
  144. <td style="width: 3vh">
  145. {{ item.sameperiod }}
  146. </td>
  147. </template>
  148. </tr>
  149. <tr>
  150. <td class="td-item" style="width: 4vh">石板泉</td>
  151. <template v-for="(item, index) of SbaqList" :key="index">
  152. <td style="width: 3vh">
  153. {{ item.current }}
  154. <template v-if="item.compare === -1">
  155. <span class="svg-icon svg-icon-yellow">
  156. <svg-icon svgid="svg-arrow-dpwn-1" />
  157. </span>
  158. </template>
  159. <template v-if="item.compare === 1">
  160. <span class="svg-icon svg-icon-green">
  161. <svg-icon svgid="svg-arrow-up-1" />
  162. </span>
  163. </template>
  164. </td>
  165. <td style="width: 3vh">
  166. {{ item.sameperiod }}
  167. </td>
  168. </template>
  169. </tr>
  170. <tr>
  171. <td class="td-item" style="width: 4vh">香山</td>
  172. <template v-for="(item, index) of XshList" :key="index">
  173. <td style="width: 3vh">
  174. {{ item.current }}
  175. <template v-if="item.compare === -1">
  176. <span class="svg-icon svg-icon-yellow">
  177. <svg-icon svgid="svg-arrow-dpwn-1" />
  178. </span>
  179. </template>
  180. <template v-if="item.compare === 1">
  181. <span class="svg-icon svg-icon-green">
  182. <svg-icon svgid="svg-arrow-up-1" />
  183. </span>
  184. </template>
  185. </td>
  186. <td style="width: 3vh">
  187. {{ item.sameperiod }}
  188. </td>
  189. </template>
  190. </tr>
  191. <tr>
  192. <td class="td-item" style="width: 4vh">公司</td>
  193. <template v-for="(item, index) of GsList" :key="index">
  194. <td style="width: 3vh">
  195. {{ item.current }}
  196. <template v-if="item.compare === -1">
  197. <span class="svg-icon svg-icon-yellow">
  198. <svg-icon svgid="svg-arrow-dpwn-1" />
  199. </span>
  200. </template>
  201. <template v-if="item.compare === 1">
  202. <span class="svg-icon svg-icon-green">
  203. <svg-icon svgid="svg-arrow-up-1" />
  204. </span>
  205. </template>
  206. </td>
  207. <td style="width: 3vh">
  208. {{ item.sameperiod }}
  209. </td>
  210. </template>
  211. </tr> -->
  212. </tbody>
  213. </table>
  214. </div>
  215. <!-- </el-scrollbar> -->
  216. </div>
  217. </el-col>
  218. </el-row>
  219. <el-row :gutter="20" class="table-panel">
  220. <el-col :span="24">
  221. <panel title="公司发电量分析" :showLine="false">
  222. <!-- <vertival-bar-line-chart
  223. :height="'360px'"
  224. :units="units"
  225. :bardata="bardata"
  226. :lineData="lineData"
  227. /> -->
  228. <MultipleLineChart
  229. :list="DayPower.value"
  230. :units="DayPower.units"
  231. height="40vh"
  232. :showLegend="true"
  233. />
  234. <!-- :units="units"
  235. :bardata="bardata"
  236. :lineData="lineData" -->
  237. </panel>
  238. </el-col>
  239. </el-row>
  240. </div>
  241. </template>
  242. <script>
  243. // import VertivalBarLineChart from "../../components/chart/combination/vertival-bar-line-chart.vue";
  244. // import VertivalBarLineChart from "../../components/chart/bar/list-bar-chart.vue";
  245. import MultipleLineChart from "../../components/chart/bar/multiple-bar-chart.vue";
  246. import Panel from "../../components/coms/panel/panel.vue";
  247. import DualPieChart from "../../components/chart/pie/dual-pie-chart.vue";
  248. import SvgIcon from "../../components/coms/icon/svg-icon.vue";
  249. import Get_PDF from "@tools/htmlToPdf";
  250. import api from "@api/economic/index.js";
  251. export default {
  252. setup() {},
  253. components: {
  254. Panel,
  255. DualPieChart,
  256. SvgIcon,
  257. // VertivalBarLineChart,
  258. MultipleLineChart,
  259. },
  260. data() {
  261. return {
  262. stations:{},
  263. monthData: [],
  264. MhsLists: [],
  265. NshList: [],
  266. QshList: [],
  267. SbaqList: [],
  268. XshList: [],
  269. GsList: [],
  270. units: [],
  271. nowCurrent: 1,
  272. months: new Date().getMonth() + 1,
  273. pickerOptions: {},
  274. bardata: { area: [], legend: [], data: [] }, // 损失电量分析echart数值
  275. lineData: [],
  276. timmer: null,
  277. monthValue: this.getmonthValue(),
  278. list: [],
  279. DayPower: {
  280. // 图表所用单位
  281. units: [""],
  282. value: [
  283. {
  284. title: "",
  285. yAxisIndex: 0, // 使用单位
  286. value: [],
  287. },
  288. ],
  289. },
  290. };
  291. },
  292. created() {
  293. let _this = this;
  294. // _this.$nextTick(() => {
  295. _this.getLists(false);
  296. // _this.timmer = setInterval(() => {
  297. // _this.getLists(false)
  298. // }, _this.$store.state.websocketTimeSec);
  299. // });
  300. },
  301. unmounted() {
  302. clearInterval(this.timmer);
  303. this.timmer = null;
  304. },
  305. mounted() {},
  306. methods: {
  307. exportPDF(name) {
  308. this.BASE.showMsg({
  309. type: "success",
  310. msg: "正在导出...请稍后...",
  311. });
  312. Get_PDF.downloadPDF(document.querySelector(".pdfDom"), "发电量");
  313. },
  314. getmonthValue() {
  315. let year = new Date().getFullYear().toString();
  316. return year;
  317. },
  318. onClickSearch() {
  319. this.getLists(false);
  320. },
  321. monthChange(data) {
  322. let year = data.getFullYear().toString();
  323. return year;
  324. },
  325. isNumber(val) {
  326. return typeof val === "number" && !isNaN(val);
  327. },
  328. getLists(showLoading) {
  329. let MhsLists = [];
  330. let NshList = [];
  331. let QshList = [];
  332. let SbaqList = [];
  333. let XshList = [];
  334. let GsList = [];
  335. let _this = this;
  336. let year = "";
  337. if (typeof this.monthValue === "string") {
  338. year = this.monthValue;
  339. } else {
  340. year = this.monthChange(this.monthValue);
  341. }
  342. const site = ["compare", "year", "month"];
  343. api
  344. .specificFdlList({
  345. year: year,
  346. })
  347. .then((res) => {
  348. let stations = {}
  349. let company ={
  350. id:'0',
  351. name:'公司',
  352. children: []
  353. }
  354. this.list = res.data.map((item) => {
  355. for (let key in item) {
  356. if (!site.includes(key)) {
  357. if (this.isNumber(item[key])) {
  358. item[key] = item[key].toFixed(2);
  359. } else if (!item[key]) {
  360. item[key] = 0;
  361. item[key] = item[key].toFixed(2);
  362. }
  363. }
  364. }
  365. if(item.wpid === "0"){
  366. company.children.push(item)
  367. }
  368. if(!stations[item.wpid] && item.wpid !== "0" ){
  369. stations[item.wpid] = {
  370. id:item.wpid,
  371. name:item.wpname||'',
  372. children: []
  373. }
  374. }
  375. stations[item.wpid]?.children.push(item)
  376. if (item.wpid === "0") {
  377. GsList.push(item);
  378. }
  379. });
  380. stations.company = company
  381. for (const item in stations) {
  382. stations[item].children = stations[item].children.sort(this.compare("month"));
  383. }
  384. console.log(stations);
  385. this.stations = stations
  386. this.MhsLists = MhsLists.sort(this.compare("month"));
  387. this.NshList = NshList.sort(this.compare("month"));
  388. this.QshList = QshList.sort(this.compare("month"));
  389. this.SbaqList = SbaqList.sort(this.compare("month"));
  390. this.XshList = XshList.sort(this.compare("month"));
  391. this.GsList = GsList.sort(this.compare("month"));
  392. let nowCureent = [];
  393. let sameCureent = [];
  394. let monthData = [];
  395. let monthsAll = [];
  396. this.GsList.map((item) => {
  397. let objs = {};
  398. let obj = {};
  399. monthsAll.push(item.month);
  400. if (item.month > 10) {
  401. objs.text = item.month.toString();
  402. obj.text = item.month.toString();
  403. } else {
  404. item.text = "0" + item.month;
  405. objs.text = item.text;
  406. obj.text = item.text;
  407. }
  408. for (let key in item) {
  409. if (key === "current") {
  410. objs.value = item.current;
  411. nowCureent.push(objs);
  412. } else if (key === "sameperiod") {
  413. obj.value = item.sameperiod;
  414. sameCureent.push(obj);
  415. }
  416. }
  417. });
  418. this.monthData = monthsAll;
  419. this.DayPower = {
  420. // 图表所用单位
  421. units: [""],
  422. value: [
  423. {
  424. title: "本期",
  425. yAxisIndex: 0, // 使用单位
  426. value: nowCureent,
  427. // nowCureent
  428. },
  429. {
  430. title: "同期",
  431. yAxisIndex: 0, // 使用单位
  432. value: sameCureent,
  433. // sameCureent
  434. },
  435. ],
  436. };
  437. // this.DayPower = {
  438. // // 图表所用单位
  439. // units: [""],
  440. // value: [
  441. // {
  442. // title: "本期",
  443. // yAxisIndex: 0, // 使用单位
  444. // value: [],
  445. // },
  446. // {
  447. // title: "同期",
  448. // yAxisIndex: 0, // 使用单位
  449. // value: [],
  450. // },
  451. // ],
  452. // },
  453. // this.bardata.legend = ["本期", "同期"]
  454. // this.lineData = [];
  455. // this.bardata.area = monthData;
  456. // this.bardata.data[0] = sameCureent;
  457. // this.bardata.data[1] = nowCureent;
  458. });
  459. // this.API.requestData({
  460. // showLoading,
  461. // method: "GET",
  462. // baseURL: "http://10.155.32.4:8034",
  463. // subUrl: "/specific/fdlList",
  464. // data: {
  465. // year: year,
  466. // },
  467. // success(res) {
  468. // this.list = res.data.map((item) => {
  469. // for (let key in item) {
  470. // if (!site.includes(key)) {
  471. // if (this.isNumber(item[key])) {
  472. // item[key] = item[key].toFixed(2);
  473. // } else if (!item[key]) {
  474. // item[key] = 0;
  475. // item[key] = item[key].toFixed(2);
  476. // }
  477. // }
  478. // }
  479. // if (item.wpid === "MHS_FDC") {
  480. // MhsLists.push(item);
  481. // } else if (item.wpid === "NSS_FDC") {
  482. // NshList.push(item);
  483. // } else if (item.wpid === "QS_FDC") {
  484. // QshList.push(item);
  485. // } else if (item.wpid === "NSS_FDC") {
  486. // NshList.push(item);
  487. // } else if (item.wpid === "SBQ_FDC") {
  488. // SbaqList.push(item);
  489. // } else if (item.wpid === "XS_FDC") {
  490. // XshList.push(item);
  491. // } else {
  492. // GsList.push(item);
  493. // }
  494. // });
  495. // this.MhsLists = MhsLists.sort(this.compare("month"));
  496. // this.NshList = NshList.sort(this.compare("month"));
  497. // this.QshList = QshList.sort(this.compare("month"));
  498. // this.SbaqList = SbaqList.sort(this.compare("month"));
  499. // this.XshList = XshList.sort(this.compare("month"));
  500. // this.GsList = GsList.sort(this.compare("month"));
  501. // let nowCureent = [];
  502. // let sameCureent = [];
  503. // let monthData = [];
  504. // let monthsAll = [];
  505. // this.GsList.map((item) => {
  506. // let objs = {};
  507. // let obj = {};
  508. // monthsAll.push(item.month);
  509. // if (item.month > 10) {
  510. // objs.text = item.month.toString();
  511. // obj.text = item.month.toString();
  512. // } else {
  513. // item.text = "0" + item.month;
  514. // objs.text = item.text;
  515. // obj.text = item.text;
  516. // }
  517. // for (let key in item) {
  518. // if (key === "current") {
  519. // objs.value = item.current;
  520. // nowCureent.push(objs);
  521. // } else if (key === "sameperiod") {
  522. // obj.value = item.sameperiod;
  523. // sameCureent.push(obj);
  524. // }
  525. // }
  526. // });
  527. // this.monthData = monthsAll;
  528. // this.DayPower = {
  529. // // 图表所用单位
  530. // units: [""],
  531. // value: [
  532. // {
  533. // title: "本期",
  534. // yAxisIndex: 0, // 使用单位
  535. // value: nowCureent,
  536. // // nowCureent
  537. // },
  538. // {
  539. // title: "同期",
  540. // yAxisIndex: 0, // 使用单位
  541. // value: sameCureent,
  542. // // sameCureent
  543. // },
  544. // ],
  545. // };
  546. // // this.DayPower = {
  547. // // // 图表所用单位
  548. // // units: [""],
  549. // // value: [
  550. // // {
  551. // // title: "本期",
  552. // // yAxisIndex: 0, // 使用单位
  553. // // value: [],
  554. // // },
  555. // // {
  556. // // title: "同期",
  557. // // yAxisIndex: 0, // 使用单位
  558. // // value: [],
  559. // // },
  560. // // ],
  561. // // },
  562. // // this.bardata.legend = ["本期", "同期"]
  563. // // this.lineData = [];
  564. // // this.bardata.area = monthData;
  565. // // this.bardata.data[0] = sameCureent;
  566. // // this.bardata.data[1] = nowCureent;
  567. // },
  568. // });
  569. },
  570. compare(property) {
  571. return (a, b) => {
  572. let val1 = a[property];
  573. let val2 = b[property];
  574. return val1 - val2;
  575. };
  576. },
  577. },
  578. };
  579. </script>
  580. <style lang="less">
  581. .ztfx {
  582. font-size: 12px;
  583. .select-btn {
  584. width: 92px;
  585. }
  586. .com-panel {
  587. border: 1px solid #6067697d;
  588. }
  589. .table-complex {
  590. margin-top: 10px;
  591. .table {
  592. border: 1px solid #6067697d;
  593. tbody {
  594. tr:nth-child(2n) td {
  595. background-color: fade(@gray, 20%);
  596. &.item {
  597. background-color: transparent;
  598. }
  599. }
  600. }
  601. th {
  602. background: fade(@gray, 40);
  603. font-size: 12px;
  604. font-weight: 400;
  605. line-height: 24px;
  606. color: @gray-l;
  607. &.type1 {
  608. border-left: 0;
  609. border-right: 0;
  610. }
  611. }
  612. td {
  613. color: @gray-l;
  614. text-align: center;
  615. height: 26px;
  616. line-height: 26px;
  617. // &.item {
  618. // width: 100px;
  619. // }
  620. }
  621. svg {
  622. height: 1.222vh;
  623. }
  624. }
  625. }
  626. .table-panel {
  627. margin-top: 10px;
  628. .panel-header {
  629. text-align: center;
  630. }
  631. .table {
  632. border: 1px solid #6067697d;
  633. tbody {
  634. tr:nth-child(2n) td {
  635. background-color: fade(@gray, 20%);
  636. &.item {
  637. background-color: transparent;
  638. }
  639. }
  640. }
  641. .td-item {
  642. width: 6vh;
  643. }
  644. th {
  645. background: fade(@gray, 40);
  646. font-size: 12px;
  647. font-weight: 400;
  648. line-height: 24px;
  649. color: @gray-l;
  650. &.type1 {
  651. border-left: 0;
  652. border-right: 0;
  653. height: 4vh;
  654. }
  655. }
  656. td {
  657. color: @gray-l;
  658. text-align: center;
  659. height: 46px;
  660. line-height: 46px;
  661. &.item {
  662. width: 100px;
  663. }
  664. }
  665. svg {
  666. height: 1.222vh;
  667. }
  668. }
  669. }
  670. .pie-chart-panel {
  671. margin-top: 10px;
  672. .line {
  673. border: none;
  674. }
  675. }
  676. }
  677. </style>