weatherMachine.vue 8.8 KB

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