index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375
  1. <template>
  2. <div>
  3. <div class="title-list">
  4. <div class="search">
  5. <div class="date">风场:</div>
  6. <el-select class="inputs" v-model="selectValue" placeholder="请选择">
  7. <el-option v-for="item in stationList" :key="item.name" :label="item.name" :value="item.id">
  8. </el-option>
  9. </el-select>
  10. </div>
  11. <div class="search">
  12. <div class="date">类型:</div>
  13. <el-select class="inputs" clearable v-model="typeStatus" placeholder="请选择">
  14. <el-option v-for="item in typeList" :key="item.name" :label="item.name" :value="item.value">
  15. </el-option>
  16. </el-select>
  17. </div>
  18. <div class="query-item">
  19. <div class="lable">日期:</div>
  20. <div class="search-input">
  21. <el-date-picker v-model="timeValue" type="daterange" range-separator="至" start-placeholder="开始日期"
  22. end-placeholder="结束日期">
  23. </el-date-picker>
  24. </div>
  25. </div>
  26. <div class="query-actions">
  27. <button class="button" @click="getTableData">查询</button>
  28. <button class="button" @click="exportExcel">导出</button>
  29. </div>
  30. </div>
  31. <div>
  32. <el-table height="90vh" ref="multipleTable" empty-text="暂无数据" :data="tableList" stripe
  33. style="width: 100%; margin-bottom: 10px">
  34. <el-table-column prop="windturbineid" label="风机" align="center" width="220" sortable></el-table-column>
  35. <el-table-column label="停机时间" prop="stoptime" align="center" sortable>
  36. </el-table-column>
  37. <el-table-column label="恢复时间" prop="starttime" align="center" sortable>
  38. </el-table-column>
  39. <el-table-column label="停机小时" prop="stophours" align="center" sortable>
  40. </el-table-column>
  41. <el-table-column label="损失电量" prop="losspower" align="center" sortable>
  42. </el-table-column>
  43. <el-table-column label="停机类型" prop="stoptypeid" align="center" sortable>
  44. </el-table-column>
  45. </el-table>
  46. </div>
  47. </div>
  48. </template>
  49. <script>
  50. import api from "api/index";
  51. import dayjs from "dayjs";
  52. import XLSX from "xlsx";
  53. export default {
  54. data() {
  55. return {
  56. timeValue: [],
  57. selectValue: "WNS_FDC",
  58. tableList: [
  59. {
  60. "id": "4ee7456f-50a1-4452-bf17-c17c899d4013",
  61. "windpowerstationid": "GL_FDC",
  62. "windturbineid": "广灵第012台风机",
  63. "stoptime": "2022-08-03T01:23:55.000+0000",
  64. "starttime": null,
  65. "stophours": null,
  66. "losspower": null,
  67. "stoptypeid": "故障不明确",
  68. "ishandle": null,
  69. "warningid": null,
  70. "projectid": "GL01_GC",
  71. "handleway": null,
  72. "faultview": null,
  73. "statuscode": 2,
  74. "mainid": null,
  75. "resetrate": null,
  76. "staterate": null,
  77. "failrate": null,
  78. "warningrecordsid": null
  79. },
  80. {
  81. "id": "9459be59-5baf-4557-8696-3adb76a2f2e4",
  82. "windpowerstationid": "GL_FDC",
  83. "windturbineid": "广灵第023台风机",
  84. "stoptime": "2022-08-03T01:23:04.000+0000",
  85. "starttime": null,
  86. "stophours": null,
  87. "losspower": null,
  88. "stoptypeid": "维护停机",
  89. "ishandle": null,
  90. "warningid": null,
  91. "projectid": "GL01_GC",
  92. "handleway": null,
  93. "faultview": null,
  94. "statuscode": 4,
  95. "mainid": null,
  96. "resetrate": null,
  97. "staterate": null,
  98. "failrate": null,
  99. "warningrecordsid": null
  100. },
  101. ],
  102. stationList: [
  103. {
  104. "id": "WNS_FDC",
  105. "code": "WNS_FDC",
  106. "name": "太旗卧牛山风电场",
  107. "address": "太旗卧牛山风电场",
  108. "telephone": null,
  109. "capacity": 148.5,
  110. "capacityunit": "MW",
  111. "quantity": 99,
  112. "aname": "卧牛山风电场",
  113. "longitude": 1000,
  114. "latitude": 1000,
  115. "photo": null,
  116. "companyid": "1",
  117. "systemmanufact": null,
  118. "headfarm": null,
  119. "headfarmphone": null,
  120. "model": "UP77-1500/UP77-1500-1/UP77-1500-2",
  121. "ordernum": 1,
  122. "altitude": 1000,
  123. "height": null
  124. },
  125. {
  126. "id": "YY_FDC",
  127. "code": "YY_FDC",
  128. "name": "右玉高家堡风电场 ",
  129. "address": "右玉高家堡风电场 ",
  130. "telephone": null,
  131. "capacity": 198,
  132. "capacityunit": "MW",
  133. "quantity": 132,
  134. "aname": "高家堡风电场 ",
  135. "longitude": 1000,
  136. "latitude": 1000,
  137. "photo": null,
  138. "companyid": "1",
  139. "systemmanufact": null,
  140. "headfarm": null,
  141. "headfarmphone": null,
  142. "model": "UP82-1500/UP82-1500-1/UP86-1500/UP86-1500-1/UP86-1500-2/UP86-1500-3/UP86-1500-4/MY-1.5se",
  143. "ordernum": 2,
  144. "altitude": 1000,
  145. "height": null
  146. },
  147. {
  148. "id": "PL_FDC",
  149. "code": "PL_FDC",
  150. "name": "平鲁虎头山风电场 ",
  151. "address": "平鲁虎头山风电场 ",
  152. "telephone": null,
  153. "capacity": 223.5,
  154. "capacityunit": "MW",
  155. "quantity": 110,
  156. "aname": "虎头山风电场 ",
  157. "longitude": 1000,
  158. "latitude": 1000,
  159. "photo": null,
  160. "companyid": "1",
  161. "systemmanufact": null,
  162. "headfarm": null,
  163. "headfarmphone": null,
  164. "model": "GW77-1500/GW82-1500/UP3000-120/GW109-2500",
  165. "ordernum": 3,
  166. "altitude": 1000,
  167. "height": null
  168. },
  169. {
  170. "id": "GL_FDC",
  171. "code": "GL_FDC",
  172. "name": "广灵劲风风电场 ",
  173. "address": "广灵劲风风电场 ",
  174. "telephone": null,
  175. "capacity": 48,
  176. "capacityunit": "MW",
  177. "quantity": 24,
  178. "aname": "劲风风电场 ",
  179. "longitude": 1000,
  180. "latitude": 1000,
  181. "photo": null,
  182. "companyid": "1",
  183. "systemmanufact": null,
  184. "headfarm": null,
  185. "headfarmphone": null,
  186. "model": "UP2000-105s",
  187. "ordernum": 4,
  188. "altitude": 1000,
  189. "height": null
  190. },
  191. {
  192. "id": "HY_FDC",
  193. "code": "HY_FDC",
  194. "name": "浑源峰岳风电场 ",
  195. "address": "浑源峰岳风电场 ",
  196. "telephone": null,
  197. "capacity": 149.5,
  198. "capacityunit": "MW",
  199. "quantity": 80,
  200. "aname": "峰岳风电场 ",
  201. "longitude": 1000,
  202. "latitude": 1000,
  203. "photo": null,
  204. "companyid": "1",
  205. "systemmanufact": null,
  206. "headfarm": null,
  207. "headfarmphone": null,
  208. "model": "UP82-1500-2/UP86-1500-2/UP2000-96/UP2000-105s",
  209. "ordernum": 5,
  210. "altitude": 1000,
  211. "height": null
  212. },
  213. {
  214. "id": "FS_FDC",
  215. "code": "FS_FDC",
  216. "name": "方山宝塔山风电场 ",
  217. "address": "方山宝塔山风电场 ",
  218. "telephone": null,
  219. "capacity": 96,
  220. "capacityunit": "MW",
  221. "quantity": 48,
  222. "aname": "宝塔山风电场 ",
  223. "longitude": 1000,
  224. "latitude": 1000,
  225. "photo": null,
  226. "companyid": "1",
  227. "systemmanufact": null,
  228. "headfarm": null,
  229. "headfarmphone": null,
  230. "model": "UP2000-105s/UP2000-96",
  231. "ordernum": 6,
  232. "altitude": 1000,
  233. "height": null
  234. },
  235. {
  236. "id": "YG_FDC",
  237. "code": "YG_FDC",
  238. "name": "阳高采凉山风电场",
  239. "address": "阳高采凉山风电场",
  240. "telephone": null,
  241. "capacity": 90,
  242. "capacityunit": "MW",
  243. "quantity": 45,
  244. "aname": "采凉山风电场",
  245. "longitude": 1000,
  246. "latitude": 1000,
  247. "photo": null,
  248. "companyid": "1",
  249. "systemmanufact": null,
  250. "headfarm": null,
  251. "headfarmphone": null,
  252. "model": "UP2000-115s",
  253. "ordernum": 7,
  254. "altitude": 1000,
  255. "height": null
  256. }
  257. ],
  258. typeList:[
  259. {
  260. value: 2,
  261. name: '故障',
  262. },
  263. {
  264. value: 4,
  265. name: '维护',
  266. },
  267. ],
  268. typeStatus: '',
  269. };
  270. },
  271. created() {
  272. let date = new Date();
  273. this.timeValue[0] = date.getTime() - 86400000;
  274. this.timeValue[1] = date.getTime() - 86400000;
  275. this.getStation()
  276. },
  277. methods: {
  278. getStation() {
  279. api.getStation().then(res => {
  280. if (res.data) {
  281. this.stationList = res.data.data
  282. this.getTableData()
  283. }
  284. })
  285. },
  286. getTableData() {
  287. api.getShutdownevent({
  288. wpid: this.selectValue,
  289. beginDate: dayjs(this.timeValue[0]).format("YYYY-MM-DD"),
  290. endDate: dayjs(this.timeValue[1]).format("YYYY-MM-DD"),
  291. type: this.typeStatus,
  292. }).then(res => {
  293. if (res.data) {
  294. res.data.data.forEach(item => {
  295. if (item.stoptime) {
  296. item.stoptime = dayjs(item.stoptime).format("YYYY-MM-DD HH:mm:ss")
  297. }
  298. if (item.starttime) {
  299. item.starttime = dayjs(item.starttime).format("YYYY-MM-DD HH:mm:ss")
  300. }
  301. });
  302. this.tableList = res.data.data
  303. }
  304. })
  305. },
  306. exportExcel() {
  307. // 数据源
  308. let data = [];
  309. this.tableList.forEach((item) => {
  310. let values = {
  311. 风机: item.windturbineid,
  312. 停机时间: item.stoptime,
  313. 恢复时间: item.starttime,
  314. 停机小时: item.stophours,
  315. 损失电量: item.losspower,
  316. 停机类型: item.stoptypeid,
  317. };
  318. data.push(values);
  319. });
  320. // 下载的路径
  321. let fileName = `风机停机分析.xlsx`;
  322. let filePath = fileName;
  323. // 新建workbook
  324. const wb = XLSX.utils.book_new();
  325. // 新建worksheet,并载入数据
  326. const ws = XLSX.utils.json_to_sheet(data);
  327. // 设置每列的列宽,10代表10个字符,注意中文占2个字符
  328. ws["!cols"] = [{ wch: 20 }, { wch: 25 }, { wch: 25 }, { wch: 10 }, { wch: 10 }, { wch: 25 }];
  329. // 生成xlsx文件(workbook,worksheet数据,sheet命名)
  330. XLSX.utils.book_append_sheet(wb, ws, "Sheet1");
  331. // 写文件(workbook,xlsx文件路径+文件名)
  332. XLSX.writeFile(wb, filePath);
  333. },
  334. },
  335. }
  336. </script>
  337. <style lang="less" scoped>
  338. .title-list {
  339. display: flex;
  340. flex-direction: row;
  341. align-items: center;
  342. margin-top: 10px;
  343. .search {
  344. display: flex;
  345. flex-direction: row;
  346. align-items: center;
  347. margin-left: 30px;
  348. .date {
  349. margin-right: 20px;
  350. font-size: 18px;
  351. }
  352. }
  353. .query-item {
  354. display: flex;
  355. flex-direction: row;
  356. align-items: center;
  357. margin-left: 30px;
  358. .lable {
  359. margin-right: 20px;
  360. font-size: 18px;
  361. }
  362. }
  363. .button {
  364. width: 80px;
  365. height: 40px;
  366. margin-left: 30px;
  367. }
  368. }
  369. </style>