fdl.vue 22 KB

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