1
0

index.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  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. <el-select
  20. size="mini"
  21. v-model="station"
  22. placeholder="请选择"
  23. style="margin-left: 15px"
  24. @change="stationChanged"
  25. >
  26. <el-option
  27. v-for="item in stationOptions"
  28. :key="item.id"
  29. :label="item.aname"
  30. :value="item.id"
  31. >
  32. </el-option>
  33. </el-select>
  34. <el-button round size="mini" class="searchColor" @click="getDatas"
  35. >搜索</el-button
  36. >
  37. </div>
  38. </div>
  39. <div class="parcel-content" v-loading="loading" element-loading-background="rgba(4, 12, 11, 0.8)">
  40. <div class="line clearfix">
  41. <div class="leftContent">
  42. <span>{{ selectValue }}</span>
  43. </div>
  44. </div>
  45. <div class="echarts">
  46. <div class="chart-wrapper">
  47. <BarCharts :list="list" width="100%" height="100%"></BarCharts>
  48. </div>
  49. </div>
  50. <div class="table-wrapper">
  51. <el-table
  52. :data="tableData"
  53. size="mini"
  54. stripe
  55. width="100%"
  56. height="100%"
  57. >
  58. <el-table-column
  59. v-for="(item, index) in tableHead"
  60. :label="item"
  61. :key="index"
  62. align="center"
  63. >
  64. <template #default="scope">
  65. <span>
  66. {{ scope.row[index] ? scope.row[index] : "--" }}
  67. </span>
  68. </template>
  69. </el-table-column>
  70. </el-table>
  71. </div>
  72. </div>
  73. </div>
  74. </template>
  75. <script>
  76. // import Panel from "@/components/curveAnalyse/panel.vue";
  77. // import ChartColumnar from '@/components/curveAnalyse/multiple-bar-chart.vue'
  78. import BarCharts from "./components/barCharts.vue";
  79. // import { companys, fnlylList, gzsslList, whsslList, xdsslList, xnsslList, slsslList } from '@/api/curveAnalyse'
  80. import {
  81. companys,
  82. gzsslList,
  83. whsslList,
  84. xdsslList,
  85. xnsslList,
  86. slsslList,
  87. } from "@/api/curveAnalyse";
  88. import { GetStationByCompany } from "@/api/factoryMonitor/index.js";
  89. import { getMonthElectricAnalyse } from "@/api/monthlyPerformanceAnalysis.js";
  90. export default {
  91. name: "monthElectricAnalyse",
  92. components: {
  93. // ChartColumnar,
  94. // Panel,
  95. BarCharts,
  96. },
  97. data() {
  98. return {
  99. loading: false,
  100. list: [],
  101. barList: [],
  102. tableData: [],
  103. tableHead: [
  104. "指标名称",
  105. "一月",
  106. "二月",
  107. "三月",
  108. "四月",
  109. "五月",
  110. "六月",
  111. "七月",
  112. "八月",
  113. "九月",
  114. "十月",
  115. "十一月",
  116. "十二月",
  117. "合计",
  118. ],
  119. company: "",
  120. companyOptions: [],
  121. station: "",
  122. stationOptions: [],
  123. selectValue: "全域数据当年-月发电量",
  124. headers: [
  125. "计划电量",
  126. "实发电量",
  127. "当月占比",
  128. "全年占比",
  129. "短期准确率",
  130. "超短期准确率",
  131. ],
  132. };
  133. },
  134. watch: {},
  135. filters: {},
  136. created() {
  137. this.initialization();
  138. },
  139. methods: {
  140. initialization() {
  141. companys().then(({ data: res }) => {
  142. if (res.data) {
  143. this.companyOptions = res.data;
  144. this.company = res.data[0].id;
  145. // this.search();
  146. this.getStation();
  147. }
  148. });
  149. },
  150. companyChanged() {
  151. this.station = "";
  152. this.getStation();
  153. },
  154. getStation() {
  155. GetStationByCompany({ companyids: this.company, type: 0 }).then(
  156. ({ data: res, code }) => {
  157. if (res.code == 200) {
  158. this.stationOptions = res.data;
  159. this.station = this.stationOptions[0].id;
  160. this.getDatas();
  161. }
  162. }
  163. );
  164. },
  165. getDatas() {
  166. this.loading = true;
  167. getMonthElectricAnalyse({ wpId: this.station }).then(({ data, code }) => {
  168. if (code == 200) {
  169. //合计列
  170. let hj = [
  171. data.bnjhdlhj,
  172. data.bnsjdlhj + "%",
  173. null,
  174. data.bnsjdlhj + "%",
  175. null,
  176. null,
  177. ];
  178. //处理纵向表格数据
  179. let resData = JSON.parse(JSON.stringify(data.value));
  180. // 数组按矩阵思路, 变成转置矩阵
  181. let matrixData = resData.map((row) => {
  182. let arr = [];
  183. for (let key in row) {
  184. if (key != "hours") {
  185. if (key.includes("zb") || key.includes("zql")) {
  186. arr.push(row[key] ? row[key] + "%" : row[key]);
  187. } else {
  188. arr.push(row[key]);
  189. }
  190. }
  191. }
  192. return arr;
  193. });
  194. // 加入标题拼接最终的数据
  195. this.tableData = matrixData[0].map((col, i) => {
  196. let newArr = new Array(
  197. this.tableHead.length - matrixData.length - 2
  198. ).fill(null);
  199. let array = [
  200. this.headers[i],
  201. ...matrixData.map((row) => {
  202. return row[i];
  203. }),
  204. ...newArr,
  205. hj[i],
  206. ];
  207. return array;
  208. });
  209. //处理图表数据
  210. let list = [
  211. {
  212. name: "计划电量",
  213. data: resData.map((ele) => ele.jhdl),
  214. color: "#4B55AE",
  215. },
  216. {
  217. name: "实发电量",
  218. data: resData.map((ele) => ele.sjdl),
  219. color: "#05BB4C",
  220. },
  221. ];
  222. this.list = list;
  223. this.loading = false;
  224. }
  225. });
  226. },
  227. },
  228. mounted() {},
  229. beforeUnmount() {},
  230. };
  231. </script>
  232. <style lang="less" scoped>
  233. .parcel-box {
  234. padding: 0 20px;
  235. box-sizing: border-box;
  236. width: 100%;
  237. height: 100%;
  238. .search {
  239. display: flex;
  240. flex-direction: row;
  241. padding-top: 20px;
  242. align-items: center;
  243. justify-content: space-between;
  244. .search-left {
  245. display: flex;
  246. flex-direction: row;
  247. align-items: center;
  248. }
  249. .search-right {
  250. position: relative;
  251. .select-back {
  252. position: absolute;
  253. right: 5px;
  254. top: 0px;
  255. z-index: 0;
  256. }
  257. .title-select {
  258. z-index: 2;
  259. }
  260. }
  261. button {
  262. margin-left: 10px;
  263. background: rgba(67, 81, 107, 0.3);
  264. border: 1px solid #274934;
  265. color: #b3b3b3;
  266. }
  267. .searchColor {
  268. background-color: rgba(5, 187, 76, 0.2);
  269. border: 1px solid #3b6c53;
  270. color: #b3b3b3;
  271. font-size: 14px;
  272. &:hover {
  273. background-color: rgba(5, 187, 76, 0.5);
  274. color: #ffffff;
  275. }
  276. }
  277. }
  278. .parcel-content {
  279. width: 100%;
  280. height: calc(100% - 77px);
  281. margin-top: 10px;
  282. // background: url("~@/assets/imgs/yfdl-bg.png") no-repeat;
  283. // background-size: contain;
  284. .line {
  285. .leftContent {
  286. width: 242px;
  287. height: 45px;
  288. line-height: 45px;
  289. background: url("~@/assets/imgs/title_left_bg.png");
  290. span {
  291. font-size: 16px;
  292. font-family: Microsoft YaHei;
  293. font-weight: 400;
  294. color: #ffffff;
  295. margin-left: 25px;
  296. }
  297. }
  298. }
  299. .echarts {
  300. height: calc(100% - 300px - 45px);
  301. padding: 0 20px;
  302. .chart-wrapper {
  303. height: 100%;
  304. width: 100%;
  305. }
  306. }
  307. .table-wrapper {
  308. height: 300px;
  309. width: 100%;
  310. padding: 0 20px;
  311. }
  312. }
  313. }
  314. </style>