xnssl.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696
  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. <panel title="性能损失率分析" :showLine="false">
  223. <!-- <vertival-bar-line-chart
  224. :height="'360px'"
  225. :units="units"
  226. :bardata="bardata"
  227. :lineData="lineData"
  228. /> -->
  229. <MultipleLineChart
  230. :list="DayPower.value"
  231. :units="DayPower.units"
  232. height="40vh"
  233. :showLegend="true"
  234. />
  235. <!-- :units="units"
  236. :bardata="bardata"
  237. :lineData="lineData" -->
  238. </panel>
  239. </el-col>
  240. </el-row>
  241. </div>
  242. </template>
  243. <script>
  244. // import VertivalBarLineChart from "../../components/chart/combination/vertival-bar-line-chart.vue";
  245. // import VertivalBarLineChart from "../../components/chart/bar/list-bar-chart.vue";
  246. import MultipleLineChart from "../../components/chart/bar/multiple-bar-chart.vue";
  247. import Panel from "../../components/coms/panel/panel.vue";
  248. import DualPieChart from "../../components/chart/pie/dual-pie-chart.vue";
  249. import SvgIcon from "../../components/coms/icon/svg-icon.vue";
  250. import Get_PDF from "@tools/htmlToPdf";
  251. import api from "@api/economic/index.js";
  252. export default {
  253. setup() {},
  254. components: {
  255. Panel,
  256. DualPieChart,
  257. SvgIcon,
  258. // VertivalBarLineChart,
  259. MultipleLineChart,
  260. },
  261. data() {
  262. return {
  263. stations:{},
  264. monthData: [],
  265. MhsLists: [],
  266. NshList: [],
  267. QshList: [],
  268. SbaqList: [],
  269. XshList: [],
  270. GsList: [],
  271. units: [],
  272. nowCurrent: 1,
  273. months: new Date().getMonth() + 1,
  274. pickerOptions: {},
  275. bardata: { area: [], legend: [], data: [] }, // 损失电量分析echart数值
  276. lineData: [],
  277. timmer: null,
  278. monthValue: this.getmonthValue(),
  279. list: [],
  280. DayPower: {
  281. // 图表所用单位
  282. units: [""],
  283. value: [
  284. {
  285. title: "",
  286. yAxisIndex: 0, // 使用单位
  287. value: [],
  288. },
  289. ],
  290. },
  291. };
  292. },
  293. created() {
  294. let _this = this;
  295. // _this.$nextTick(() => {
  296. _this.getLists(false);
  297. // _this.timmer = setInterval(() => {
  298. // _this.getLists(false)
  299. // }, _this.$store.state.websocketTimeSec);
  300. // });
  301. },
  302. unmounted() {
  303. clearInterval(this.timmer);
  304. this.timmer = null;
  305. },
  306. mounted() {},
  307. methods: {
  308. exportPDF(name) {
  309. this.BASE.showMsg({
  310. type: "success",
  311. msg: "正在导出...请稍后...",
  312. });
  313. Get_PDF.downloadPDF(document.querySelector(".pdfDom"), "性能损失率");
  314. },
  315. getmonthValue() {
  316. let year = new Date().getFullYear().toString();
  317. return year;
  318. },
  319. onClickSearch() {
  320. this.getLists(false);
  321. },
  322. monthChange(data) {
  323. let year = data.getFullYear().toString();
  324. return year;
  325. },
  326. isNumber(val) {
  327. return typeof val === "number" && !isNaN(val);
  328. },
  329. getLists(showLoading) {
  330. let MhsLists = [];
  331. let NshList = [];
  332. let QshList = [];
  333. let SbaqList = [];
  334. let XshList = [];
  335. let GsList = [];
  336. let _this = this;
  337. let year = "";
  338. if (typeof this.monthValue === "string") {
  339. year = this.monthValue;
  340. } else {
  341. year = this.monthChange(this.monthValue);
  342. }
  343. const site = ["compare", "year", "month"];
  344. api.specificXnsslList({
  345. year: year,
  346. }).then((res) => {
  347. let stations = {}
  348. let company ={
  349. id:'0',
  350. name:'公司',
  351. children: []
  352. }
  353. this.list = res.data.map((item) => {
  354. for (let key in item) {
  355. if (!site.includes(key)) {
  356. if (this.isNumber(item[key])) {
  357. item[key] = item[key].toFixed(2);
  358. } else if (!item[key]) {
  359. item[key] = 0;
  360. item[key] = item[key].toFixed(2);
  361. }
  362. }
  363. }
  364. if(item.wpid === "0"){
  365. company.children.push(item)
  366. }
  367. if(!stations[item.wpid] && item.wpid !== "0" ){
  368. stations[item.wpid] = {
  369. id:item.wpid,
  370. name:item.wpname||'',
  371. children: []
  372. }
  373. }
  374. stations[item.wpid]?.children.push(item)
  375. if (item.wpid === "0") {
  376. GsList.push(item);
  377. }
  378. });
  379. stations.company = company
  380. for (const item in stations) {
  381. stations[item].children = stations[item].children.sort(this.compare("month"));
  382. }
  383. console.log(stations);
  384. this.stations = stations
  385. this.MhsLists = MhsLists.sort(this.compare("month"));
  386. this.NshList = NshList.sort(this.compare("month"));
  387. this.QshList = QshList.sort(this.compare("month"));
  388. this.SbaqList = SbaqList.sort(this.compare("month"));
  389. this.XshList = XshList.sort(this.compare("month"));
  390. this.GsList = GsList.sort(this.compare("month"));
  391. let nowCureent = [];
  392. let sameCureent = [];
  393. let monthData = [];
  394. let monthsAll = [];
  395. this.GsList.map((item) => {
  396. let objs = {};
  397. let obj = {};
  398. monthsAll.push(item.month);
  399. if (item.month > 10) {
  400. objs.text = item.month.toString();
  401. obj.text = item.month.toString();
  402. } else {
  403. item.text = "0" + item.month;
  404. objs.text = item.text;
  405. obj.text = item.text;
  406. }
  407. for (let key in item) {
  408. if (key === "current") {
  409. objs.value = item.current;
  410. nowCureent.push(objs);
  411. } else if (key === "sameperiod") {
  412. obj.value = item.sameperiod;
  413. sameCureent.push(obj);
  414. }
  415. }
  416. });
  417. this.monthData = monthsAll;
  418. this.DayPower = {
  419. // 图表所用单位
  420. units: [""],
  421. value: [
  422. {
  423. title: "本期",
  424. yAxisIndex: 0, // 使用单位
  425. value: nowCureent,
  426. // nowCureent
  427. },
  428. {
  429. title: "同期",
  430. yAxisIndex: 0, // 使用单位
  431. value: sameCureent,
  432. // sameCureent
  433. },
  434. ],
  435. };
  436. // _this.DayPower = {
  437. // // 图表所用单位
  438. // units: [""],
  439. // value: [
  440. // {
  441. // title: "本期",
  442. // yAxisIndex: 0, // 使用单位
  443. // value: [],
  444. // },
  445. // {
  446. // title: "同期",
  447. // yAxisIndex: 0, // 使用单位
  448. // value: [],
  449. // },
  450. // ],
  451. // },
  452. // _this.bardata.legend = ["本期", "同期"]
  453. // _this.lineData = [];
  454. // _this.bardata.area = monthData;
  455. // _this.bardata.data[0] = sameCureent;
  456. // _this.bardata.data[1] = nowCureent;
  457. });
  458. // _this.API.requestData({
  459. // showLoading,
  460. // method: "GET",
  461. // baseURL: "http://10.155.32.4:8034",
  462. // subUrl: "/specific/xnsslList",
  463. // data: {
  464. // year: year,
  465. // },
  466. // success(res) {
  467. // _this.list = res.data.map((item) => {
  468. // for (let key in item) {
  469. // if (!site.includes(key)) {
  470. // if (_this.isNumber(item[key])) {
  471. // item[key] = item[key].toFixed(2);
  472. // } else if (!item[key]) {
  473. // item[key] = 0;
  474. // item[key] = item[key].toFixed(2);
  475. // }
  476. // }
  477. // }
  478. // if (item.wpid === "MHS_FDC") {
  479. // MhsLists.push(item);
  480. // } else if (item.wpid === "NSS_FDC") {
  481. // NshList.push(item);
  482. // } else if (item.wpid === "QS_FDC") {
  483. // QshList.push(item);
  484. // } else if (item.wpid === "NSS_FDC") {
  485. // NshList.push(item);
  486. // } else if (item.wpid === "SBQ_FDC") {
  487. // SbaqList.push(item);
  488. // } else if (item.wpid === "XS_FDC") {
  489. // XshList.push(item);
  490. // } else {
  491. // GsList.push(item);
  492. // }
  493. // });
  494. // _this.MhsLists = MhsLists.sort(_this.compare("month"));
  495. // _this.NshList = NshList.sort(_this.compare("month"));
  496. // _this.QshList = QshList.sort(_this.compare("month"));
  497. // _this.SbaqList = SbaqList.sort(_this.compare("month"));
  498. // _this.XshList = XshList.sort(_this.compare("month"));
  499. // _this.GsList = GsList.sort(_this.compare("month"));
  500. // let nowCureent = [];
  501. // let sameCureent = [];
  502. // let monthData = [];
  503. // let monthsAll = [];
  504. // _this.GsList.map((item) => {
  505. // let objs = {};
  506. // let obj = {};
  507. // monthsAll.push(item.month);
  508. // if (item.month > 10) {
  509. // objs.text = item.month.toString();
  510. // obj.text = item.month.toString();
  511. // } else {
  512. // item.text = "0" + item.month;
  513. // objs.text = item.text;
  514. // obj.text = item.text;
  515. // }
  516. // for (let key in item) {
  517. // if (key === "current") {
  518. // objs.value = item.current;
  519. // nowCureent.push(objs);
  520. // } else if (key === "sameperiod") {
  521. // obj.value = item.sameperiod;
  522. // sameCureent.push(obj);
  523. // }
  524. // }
  525. // });
  526. // _this.monthData = monthsAll;
  527. // _this.DayPower = {
  528. // // 图表所用单位
  529. // units: [""],
  530. // value: [
  531. // {
  532. // title: "本期",
  533. // yAxisIndex: 0, // 使用单位
  534. // value: nowCureent,
  535. // // nowCureent
  536. // },
  537. // {
  538. // title: "同期",
  539. // yAxisIndex: 0, // 使用单位
  540. // value: sameCureent,
  541. // // sameCureent
  542. // },
  543. // ],
  544. // };
  545. // // _this.DayPower = {
  546. // // // 图表所用单位
  547. // // units: [""],
  548. // // value: [
  549. // // {
  550. // // title: "本期",
  551. // // yAxisIndex: 0, // 使用单位
  552. // // value: [],
  553. // // },
  554. // // {
  555. // // title: "同期",
  556. // // yAxisIndex: 0, // 使用单位
  557. // // value: [],
  558. // // },
  559. // // ],
  560. // // },
  561. // // _this.bardata.legend = ["本期", "同期"]
  562. // // _this.lineData = [];
  563. // // _this.bardata.area = monthData;
  564. // // _this.bardata.data[0] = sameCureent;
  565. // // _this.bardata.data[1] = nowCureent;
  566. // },
  567. // });
  568. },
  569. compare(property) {
  570. return (a, b) => {
  571. let val1 = a[property];
  572. let val2 = b[property];
  573. return val1 - val2;
  574. };
  575. },
  576. },
  577. };
  578. </script>
  579. <style lang="less">
  580. .ztfx {
  581. font-size: 12px;
  582. .select-btn {
  583. width: 92px;
  584. }
  585. .com-panel {
  586. border: 1px solid #6067697d;
  587. }
  588. .table-complex {
  589. margin-top: 10px;
  590. .table {
  591. border: 1px solid #6067697d;
  592. tbody {
  593. tr:nth-child(2n) td {
  594. background-color: fade(@gray, 20%);
  595. &.item {
  596. background-color: transparent;
  597. }
  598. }
  599. }
  600. th {
  601. background: fade(@gray, 40);
  602. font-size: 12px;
  603. font-weight: 400;
  604. line-height: 24px;
  605. color: @gray-l;
  606. &.type1 {
  607. border-left: 0;
  608. border-right: 0;
  609. }
  610. }
  611. td {
  612. color: @gray-l;
  613. text-align: center;
  614. height: 26px;
  615. line-height: 26px;
  616. // &.item {
  617. // width: 100px;
  618. // }
  619. }
  620. svg {
  621. height: 1.222vh;
  622. }
  623. }
  624. }
  625. .table-panel {
  626. margin-top: 10px;
  627. .panel-header {
  628. text-align: center;
  629. }
  630. .table {
  631. border: 1px solid #6067697d;
  632. tbody {
  633. tr:nth-child(2n) td {
  634. background-color: fade(@gray, 20%);
  635. &.item {
  636. background-color: transparent;
  637. }
  638. }
  639. }
  640. .td-item {
  641. width: 6vh;
  642. }
  643. th {
  644. background: fade(@gray, 40);
  645. font-size: 12px;
  646. font-weight: 400;
  647. line-height: 24px;
  648. color: @gray-l;
  649. &.type1 {
  650. border-left: 0;
  651. border-right: 0;
  652. height: 4vh;
  653. }
  654. }
  655. td {
  656. color: @gray-l;
  657. text-align: center;
  658. height: 46px;
  659. line-height: 46px;
  660. &.item {
  661. width: 100px;
  662. }
  663. }
  664. svg {
  665. height: 1.222vh;
  666. }
  667. }
  668. }
  669. .pie-chart-panel {
  670. margin-top: 10px;
  671. .line {
  672. border: none;
  673. }
  674. }
  675. }
  676. </style>