index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517
  1. <template>
  2. <div class="parcel-box">
  3. <div class="search">
  4. <div class="search-left">
  5. <el-select
  6. size="mini"
  7. v-model="company"
  8. placeholder="请选择"
  9. @change="companyChanged"
  10. >
  11. <el-option
  12. v-for="item in companyOptions"
  13. :key="item.id"
  14. :label="item.aname"
  15. :value="item.id"
  16. >
  17. </el-option>
  18. </el-select>
  19. <div class="tabCut" v-if="$store.state.showGf">
  20. <div
  21. @click="tabClick(val.id)"
  22. :class="[
  23. tabIndex === val.id ? 'active' : '',
  24. displayDetail ? 'disabled' : '',
  25. ]"
  26. v-for="val in tabOptions"
  27. :key="val.id"
  28. >
  29. <span>{{ val.name }}</span>
  30. </div>
  31. </div>
  32. <el-select
  33. size="mini"
  34. v-model="station"
  35. placeholder="请选择"
  36. style="margin-left: 15px"
  37. >
  38. <el-option
  39. v-for="item in stationOptions"
  40. :key="item.id"
  41. :label="item.aname"
  42. :value="item.id"
  43. >
  44. </el-option>
  45. </el-select>
  46. <el-date-picker
  47. size="mini"
  48. v-model="year"
  49. type="year"
  50. value-format="YYYY"
  51. placeholder="请选择"
  52. style="margin-left: 15px"
  53. popper-class="date-select"
  54. >
  55. </el-date-picker>
  56. <el-radio-group v-model="filter" size="mini">
  57. <el-radio label="1"> 同比 </el-radio>
  58. <el-radio label="2"> 环比 </el-radio>
  59. </el-radio-group>
  60. <el-button round size="mini" class="searchColor" @click="getDatas"
  61. >搜 索</el-button
  62. >
  63. </div>
  64. </div>
  65. <div
  66. class="parcel-content"
  67. v-loading="loading"
  68. element-loading-background="rgba(4, 12, 11, 0.8)"
  69. >
  70. <!-- <img src="@/assets/imgs/glycfx-bg1.png" alt="" /> -->
  71. <div class="line clearfix">
  72. <div class="leftContent">
  73. <span>{{ selectValue }}</span>
  74. </div>
  75. </div>
  76. <div class="table-wrapper">
  77. <el-table
  78. :data="tableData"
  79. size="mini"
  80. stripe
  81. width="100%"
  82. height="100%"
  83. >
  84. <el-table-column align="center" label="指标名称" width="158">
  85. <template #default="{ row }">
  86. {{ row[0] }}
  87. </template>
  88. </el-table-column>
  89. <el-table-column
  90. v-for="(item, index) in tableHead.slice(1, 13)"
  91. :label="item.title"
  92. :key="index"
  93. align="center"
  94. show-overflow-tooltip
  95. >
  96. <el-table-column
  97. label="本月"
  98. width="85"
  99. v-if="filter == 1 || filter == 2"
  100. align="center"
  101. header-align="center"
  102. show-overflow-tooltip
  103. >
  104. <template #default="scope">
  105. <span>
  106. {{
  107. scope.row[index + 1][0] || scope.row[index + 1][0] == 0
  108. ? scope.row[index + 1][0]
  109. : "--"
  110. }}
  111. </span>
  112. </template>
  113. </el-table-column>
  114. <el-table-column
  115. label="同比"
  116. width="85"
  117. v-if="filter == 1"
  118. align="center"
  119. header-align="center"
  120. show-overflow-tooltip
  121. >
  122. <template #default="scope">
  123. <span>
  124. {{
  125. scope.row[index + 1][1] || scope.row[index + 1][1] == 0
  126. ? scope.row[index + 1][1]
  127. : "--"
  128. }}
  129. </span>
  130. </template>
  131. </el-table-column>
  132. <el-table-column
  133. label="环比"
  134. width="85"
  135. v-if="filter == 2"
  136. align="center"
  137. header-align="center"
  138. show-overflow-tooltip
  139. >
  140. <template #default="scope">
  141. <span>
  142. {{
  143. scope.row[index + 1][2] || scope.row[index + 1][2] == 0
  144. ? scope.row[index + 1][2]
  145. : "--"
  146. }}
  147. </span>
  148. </template>
  149. </el-table-column>
  150. </el-table-column>
  151. <el-table-column
  152. align="center"
  153. header-align="center"
  154. label="合计"
  155. width="85"
  156. show-overflow-tooltip
  157. >
  158. <template #default="{ row }">
  159. {{ row[13] }}
  160. </template>
  161. </el-table-column>
  162. </el-table>
  163. </div>
  164. <div class="echarts">
  165. <div class="chart-wrapper">
  166. <LineCharts :list="list" width="100%" height="100%" />
  167. </div>
  168. </div>
  169. </div>
  170. </div>
  171. </template>
  172. <script>
  173. import LineCharts from "./components/line-bar-charts.vue";
  174. import { companys } from "@/api/curveAnalyse";
  175. import { GetStationByCompany } from "@/api/factoryMonitor/index.js";
  176. import dataJson from "./dataJson.json";
  177. import {
  178. getOwnDemand,
  179. getAllStation,
  180. } from "@/api/monthlyPerformanceAnalysis.js";
  181. import dayjs from "dayjs";
  182. export default {
  183. name: "StationElectricAnalyse",
  184. components: {
  185. // ChartColumnar,
  186. // Panel,
  187. LineCharts,
  188. },
  189. data() {
  190. return {
  191. loading: false,
  192. list: [],
  193. barList: [],
  194. tableData: [],
  195. showDisplay: true,
  196. tableHead: [
  197. { title: "指标名称", children: [] },
  198. { title: "一月", children: ["本月", "同比", "环比"] },
  199. { title: "二月", children: ["本月", "同比", "环比"] },
  200. { title: "三月", children: ["本月", "同比", "环比"] },
  201. { title: "四月", children: ["本月", "同比", "环比"] },
  202. { title: "五月", children: ["本月", "同比", "环比"] },
  203. { title: "六月", children: ["本月", "同比", "环比"] },
  204. { title: "七月", children: ["本月", "同比", "环比"] },
  205. { title: "八月", children: ["本月", "同比", "环比"] },
  206. { title: "九月", children: ["本月", "同比", "环比"] },
  207. { title: "十月", children: ["本月", "同比", "环比"] },
  208. { title: "十一月", children: ["本月", "同比", "环比"] },
  209. { title: "十二月", children: ["本月", "同比", "环比"] },
  210. { title: "合计", children: [] },
  211. ],
  212. tabIndex: -1,
  213. tabOptions: [
  214. { id: -1, name: "风电" },
  215. { id: -2, name: "光伏" },
  216. ],
  217. company: "",
  218. companyOptions: [],
  219. station: "",
  220. stationOptions: [],
  221. year: dayjs().format("YYYY"),
  222. selectValue: "综合场用电量分析",
  223. headers: [
  224. "综合场用电量(万kWh)",
  225. "发电量(万kWh)",
  226. "上网电量(万kWh)",
  227. "购网电量(万kWh)",
  228. "综合场用电率(%)",
  229. ],
  230. filter: "1",
  231. };
  232. },
  233. watch: {},
  234. created() {
  235. this.initialization();
  236. this.year = dayjs().format("YYYY");
  237. },
  238. methods: {
  239. tabClick(tab) {
  240. this.tabIndex = tab;
  241. if (tab == -2) {
  242. this.company = "SXJ_KGDL_GFFD_ZGS";
  243. this.station = "";
  244. this.getStation();
  245. } else {
  246. this.company = this.companyOptions[0].id;
  247. this.station = "";
  248. this.getStation();
  249. }
  250. },
  251. initialization() {
  252. // this.dataChange(dataJson.data, dataJson.code);
  253. companys().then(({ data: res }) => {
  254. if (res.data) {
  255. this.companyOptions = res.data;
  256. this.company = res.data[0].id;
  257. this.getStation();
  258. }
  259. });
  260. },
  261. companyChanged() {
  262. this.station = "";
  263. this.getStation();
  264. },
  265. getStation() {
  266. GetStationByCompany({
  267. companyids: this.company,
  268. type: this.tabIndex,
  269. }).then(({ data: res, code }) => {
  270. if (res.code == 200) {
  271. this.stationOptions = res.data;
  272. this.station = this.stationOptions[0].id;
  273. this.getDatas();
  274. }
  275. });
  276. },
  277. getDatas() {
  278. this.loading = true;
  279. getOwnDemand({ wpId: this.station, year: this.year }).then(
  280. ({ data, code }) => {
  281. this.dataChange(data, code);
  282. }
  283. );
  284. },
  285. dataChange(data, code) {
  286. if (code == 200) {
  287. //合计列
  288. let hj = [
  289. data.zhcydlsum,
  290. data.sjdlsum,
  291. data.swdlsum,
  292. data.gwdlsum,
  293. data.zhcydllsum + "%",
  294. ];
  295. //处理纵向表格数据
  296. let resData = JSON.parse(JSON.stringify(data.value));
  297. let subKey = [
  298. ["zhcydl", "zhcydltb", "zhcydlhb"],
  299. ["sjdl", "sjdltb", "sjdlhb"],
  300. ["swdl", "swdltb", "swdlhb"],
  301. ["gwdl", "gwdltb", "gwdlhb"],
  302. ["zhcydll", "zhcydlltb", "zhcydllhb"],
  303. ];
  304. // 数组按矩阵思路, 变成转置矩阵
  305. let matrixData = resData.map((row) => {
  306. let arr = [];
  307. for (var i = 0; i <= 4; i++) {
  308. let subArr = [];
  309. subKey[i].forEach((sub) => {
  310. subArr.push(row[sub]);
  311. });
  312. arr.push(subArr);
  313. }
  314. return arr;
  315. });
  316. // 加入标题拼接最终的数据
  317. this.tableData = matrixData[0].map((col, i) => {
  318. let newArr = new Array(
  319. this.tableHead.length - matrixData.length - 2
  320. ).fill(null);
  321. let array = [
  322. this.headers[i],
  323. ...matrixData.map((row) => {
  324. return row[i];
  325. }),
  326. ...newArr,
  327. hj[i],
  328. ];
  329. return array;
  330. });
  331. // .map((item) => {
  332. // item[item.length - 1] = [item[item.length - 1]];
  333. // return item;
  334. // });
  335. //处理图表数据
  336. let list = [
  337. {
  338. name: "综合场用电量",
  339. data: resData.map((ele) => ele.zhcydl),
  340. color: "#4B55AE",
  341. },
  342. {
  343. name: "实发电量",
  344. data: resData.map((ele) => ele.sjdl),
  345. color: "#05BB4C",
  346. },
  347. {
  348. name: "上网电量",
  349. data: resData.map((ele) => ele.swdl),
  350. color: "#21a4f7",
  351. },
  352. {
  353. name: "购网电量",
  354. data: resData.map((ele) => ele.gwdl),
  355. color: "#FF8300",
  356. },
  357. ];
  358. this.list = list;
  359. this.loading = false;
  360. }
  361. },
  362. },
  363. };
  364. </script>
  365. <style lang="less" scoped>
  366. .parcel-box {
  367. padding: 0 20px;
  368. box-sizing: border-box;
  369. width: 100%;
  370. height: 100%;
  371. .search {
  372. display: flex;
  373. flex-direction: row;
  374. padding: 15px 0;
  375. align-items: center;
  376. justify-content: space-between;
  377. .search-left {
  378. display: flex;
  379. flex-direction: row;
  380. align-items: center;
  381. .tabCut {
  382. display: inline-block;
  383. margin: 0 10px;
  384. div {
  385. display: inline-block;
  386. width: 60px;
  387. height: 27px;
  388. border: 1px solid #274934;
  389. text-align: center;
  390. line-height: 25px;
  391. cursor: pointer;
  392. }
  393. div:nth-child(1) {
  394. border-radius: 13px 0px 0px 13px;
  395. border-right-width: 0;
  396. }
  397. div:nth-child(2) {
  398. border-radius: 0px 13px 13px 0px;
  399. }
  400. .active {
  401. background-color: rgba(5, 187, 76, 0.9);
  402. color: #fff;
  403. }
  404. .disabled {
  405. cursor: not-allowed;
  406. pointer-events: none;
  407. }
  408. }
  409. }
  410. .search-right {
  411. position: relative;
  412. .select-back {
  413. position: absolute;
  414. right: 5px;
  415. top: 0px;
  416. z-index: 0;
  417. }
  418. .title-select {
  419. z-index: 2;
  420. }
  421. }
  422. button {
  423. margin-left: 10px;
  424. background: rgba(67, 81, 107, 0.3);
  425. border: 1px solid #274934;
  426. color: #b3b3b3;
  427. }
  428. .searchColor {
  429. background-color: rgba(5, 187, 76, 0.2);
  430. border: 1px solid #3b6c53;
  431. color: #b3b3b3;
  432. font-size: 14px;
  433. &:hover {
  434. background-color: rgba(5, 187, 76, 0.5);
  435. color: #ffffff;
  436. }
  437. }
  438. }
  439. .parcel-content {
  440. width: 100%;
  441. height: calc(100% - 88px);
  442. // position: relative;
  443. background: url("~@/assets/imgs/glycfx-bg1.png") no-repeat;
  444. background-size: 100% 100%;
  445. background-position: center;
  446. img {
  447. position: absolute;
  448. top: 0;
  449. left: 0;
  450. width: 100%;
  451. height: 100%;
  452. }
  453. .line {
  454. .leftContent {
  455. width: 242px;
  456. height: 45px;
  457. line-height: 45px;
  458. background: url("~@/assets/imgs/title_left_bg.png") no-repeat;
  459. span {
  460. font-size: 16px;
  461. font-family: Microsoft YaHei;
  462. font-weight: 400;
  463. color: #05bb4c;
  464. margin-left: 25px;
  465. }
  466. }
  467. }
  468. .echarts {
  469. height: calc(100% - 305px - 45px);
  470. padding: 0 20px;
  471. .chart-wrapper {
  472. height: 100%;
  473. width: 100%;
  474. }
  475. }
  476. .table-wrapper {
  477. height: 305px;
  478. width: 100%;
  479. padding: 0 20px;
  480. padding-top: 10px;
  481. }
  482. }
  483. }
  484. .el-radio-group::v-deep {
  485. margin-left: 15px;
  486. display: flex;
  487. align-items: center;
  488. .el-radio__inner:hover {
  489. border-color: #05bb4c;
  490. }
  491. }
  492. .el-table--border::v-deep {
  493. th.el-table__cell {
  494. border-bottom: 1px solid #000 !important;
  495. }
  496. }
  497. </style>