weatherMachine.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  1. <template>
  2. <div class="stationPowerContro" :class="!theme ? 'themeDark' : ''">
  3. <div class="main_top">
  4. <div class="search-item" style="margin-left: 16px">
  5. <span class="label">场站:</span>
  6. <div class="search-content">
  7. <el-select v-model="stationId" style="width: 120px" clearable size="mini" placeholder="全部"
  8. popper-class="select" @change="getWindturbineList">
  9. <el-option v-for="item in stationList" :key="item.id" :value="item.id" :label="item.name">
  10. </el-option>
  11. </el-select>
  12. </div>
  13. </div>
  14. <div class="search-item" style="margin-left: 16px">
  15. <span class="label">年份:</span>
  16. <div class="search-content">
  17. <el-date-picker
  18. size="mini"
  19. type="year"
  20. v-model="year"
  21. value-format="YYYY"
  22. placeholder="请选择"
  23. popper-class="date-select"
  24. >
  25. </el-date-picker>
  26. </div>
  27. </div>
  28. <el-button class="buttons" round size="mini" @click="getStationData">查询</el-button>
  29. </div>
  30. <div class="stationPowerControTable">
  31. <h2 class="tableTitle">{{ stationName }}气象单机偏差分析</h2>
  32. <span class="tableUnit">单位:风速m/s,风向°</span>
  33. <div :style="tableHeight">
  34. <div class="tablestyle warn-table" style="margin-top: 5px">
  35. <el-table :data="tableData" v-loading="loading" border style="width: 100%"
  36. :max-height="tableMainHeight" ref="stationPowerTable"
  37. element-loading-background="rgba(0,0,0,.5)"
  38. :header-cell-style="{ 'text-align': 'center', 'font-size': '12px' }" :cell-style="{
  39. 'font-size': '12px',
  40. }" :row-style="{ height: '23px' }">
  41. <el-table-column :prop="item.value" :label="item.name" align="center"
  42. v-for="(item, index) in tableColumn" :key="index">
  43. <template #default="scope">
  44. <span>{{scope.row[item.value]}}</span>
  45. </template>
  46. </el-table-column>
  47. </el-table>
  48. </div>
  49. </div>
  50. </div>
  51. </div>
  52. </template>
  53. <script>
  54. import {
  55. getWpList,
  56. apiGetweatherMachine
  57. } from "@/api/zhbj";
  58. import dataJson from './dataJson.json'
  59. import dayjs from "dayjs";
  60. import * as XLSX from "xlsx";
  61. import {
  62. saveAs
  63. } from "file-saver";
  64. import * as XLSXD from "xlsx-js-style";
  65. import {
  66. forIn
  67. } from '@antv/x6/lib/util/object/object';
  68. export default {
  69. data() {
  70. return {
  71. year: "",
  72. stationId: "",
  73. stationName: "",
  74. stationList: [],
  75. loading: false,
  76. tableData: [],
  77. tableColumn: [{
  78. value: "name",
  79. name: "名称",
  80. },
  81. {
  82. value: "january",
  83. name: "一月",
  84. },
  85. {
  86. value: "february",
  87. name: "二月",
  88. },
  89. {
  90. value: "march",
  91. name: "三月",
  92. },
  93. {
  94. value: "april",
  95. name: "四月",
  96. },
  97. {
  98. value: "may",
  99. name: "五月",
  100. },
  101. {
  102. value: "june",
  103. name: "六月",
  104. },
  105. {
  106. value: "july",
  107. name: "七月",
  108. },
  109. {
  110. value: "august",
  111. name: "八月",
  112. },
  113. {
  114. value: "september",
  115. name: "九月",
  116. },
  117. {
  118. value: "october",
  119. name: "十月",
  120. },
  121. {
  122. value: "november",
  123. name: "十一月",
  124. },
  125. {
  126. value: "december",
  127. name: "十二月",
  128. }
  129. ]
  130. };
  131. },
  132. created() {
  133. this.changeData(dataJson)
  134. this.funGetStation();
  135. this.year = dayjs().format("YYYY")
  136. },
  137. computed: {
  138. tableHeight() {
  139. let height = (document.documentElement.clientHeight - 190) / 2 + "px";
  140. return {
  141. width: "100%",
  142. height: height,
  143. };
  144. },
  145. tableMainHeight() {
  146. let height = document.documentElement.clientHeight - 180 + "px";
  147. return height;
  148. },
  149. },
  150. methods: {
  151. /**场站 */
  152. funGetStation() {
  153. let that = this;
  154. that.stationList = [];
  155. that.windStation = ""
  156. getWpList().then((res) => {
  157. if (res) {
  158. that.stationList = res.data;
  159. if (that.stationList.length) {
  160. that.stationId = that.stationList[0].id;
  161. that.stationName = that.stationList[0].name;
  162. that.getStationData()
  163. }
  164. }
  165. });
  166. },
  167. getStationData() {
  168. let that = this;
  169. let params = {
  170. wpid: that.stationId,
  171. year: that.year
  172. }
  173. apiGetweatherMachine(params).then(res => {
  174. that.changeData(res)
  175. })
  176. },
  177. changeData(res) {
  178. if (res && res.data) {
  179. for (const key in res.data) {
  180. const element = res.data[key];
  181. let obj = {
  182. name: key,
  183. january: element[0],
  184. february: element[1],
  185. march: element[2],
  186. april: element[3],
  187. may: element[4],
  188. june: element[5],
  189. july: element[6],
  190. august: element[7],
  191. september: element[8],
  192. october: element[9],
  193. november: element[10],
  194. december: element[11],
  195. }
  196. this.tableData.push(obj)
  197. }
  198. }
  199. },
  200. seachData() {
  201. this.funGetStation();
  202. },
  203. },
  204. };
  205. </script>
  206. <style lang="less">
  207. .stationPowerContro {
  208. padding: 0 20px 0 20px;
  209. .main_top {
  210. height: 40px;
  211. display: flex;
  212. align-items: center;
  213. .search-item {
  214. display: flex;
  215. margin-right: 10px;
  216. max-width: 450px;
  217. align-items: center;
  218. .label {
  219. margin-right: 10px;
  220. text-align: right;
  221. white-space: nowrap;
  222. // width: 60px;
  223. }
  224. .search-content {
  225. flex: 1;
  226. }
  227. }
  228. }
  229. .stationPowerControSeach {
  230. margin-top: 20px;
  231. .seach_top {
  232. display: flex;
  233. .exceed {
  234. .exceedName {
  235. margin-top: 7px;
  236. font-size: 14px;
  237. margin-left: 10px;
  238. }
  239. display: flex;
  240. margin-right: 20px;
  241. .el-select,
  242. .el-select__wrapper {
  243. height: 32px;
  244. }
  245. .el-date-editor {
  246. height: 32px;
  247. .el-input__icon,
  248. .el-range-separator {
  249. line-height: 30px;
  250. }
  251. }
  252. .select-trigger {
  253. .el-input {
  254. .el-input__wrapper {
  255. height: 30px;
  256. }
  257. }
  258. .el-input__suffix {
  259. .el-input__icon {
  260. line-height: 30px;
  261. }
  262. }
  263. }
  264. }
  265. .el-button {
  266. height: 30px;
  267. padding: 0 20px;
  268. line-height: 5px;
  269. }
  270. }
  271. }
  272. .stationPowerControTable {
  273. .tableTitle {
  274. display: flex;
  275. justify-content: center;
  276. // font-size: 18px;
  277. font-weight: 600;
  278. }
  279. .tableUnit {
  280. font-size: 14px;
  281. }
  282. }
  283. }
  284. .themeDark {
  285. background-image: none;
  286. .stationPowerControSeach {
  287. .exceedName {
  288. color: #fff;
  289. }
  290. }
  291. .stationPowerControTable {
  292. .tableTitle,
  293. .tableUnit {
  294. color: #fff;
  295. }
  296. }
  297. }
  298. .themeLight {
  299. .stationPowerControSeach {
  300. .exceedName {
  301. color: #000;
  302. }
  303. }
  304. .stationPowerControTable {
  305. .tableTitle,
  306. .tableUnit {
  307. color: #000;
  308. }
  309. }
  310. }
  311. </style>