index.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874
  1. <template>
  2. <div class="history-warning">
  3. <div class="form-wrapper">
  4. <div class="search-wrapper">
  5. <div class="search-item">
  6. <span class="label">类型:</span>
  7. <div class="search-content">
  8. <el-select
  9. v-model="state.typeVal"
  10. style="width: 100px"
  11. clearable
  12. size="mini"
  13. placeholder="全部"
  14. popper-class="select"
  15. @change="
  16. () => {
  17. getStationList();
  18. typechange();
  19. }
  20. "
  21. >
  22. <el-option
  23. v-for="item in state.typeList"
  24. :key="item.value"
  25. :value="item.value"
  26. :label="item.label"
  27. >
  28. </el-option>
  29. </el-select>
  30. </div>
  31. </div>
  32. <div class="search-item">
  33. <span class="label">{{
  34. state.isshowwindturbineName ? "场站:" : "升压站:"
  35. }}</span>
  36. <div class="search-content">
  37. <el-select
  38. v-model="state.stationId"
  39. style="width: 120px"
  40. clearable
  41. size="mini"
  42. placeholder="全部"
  43. popper-class="select"
  44. @change="getWindturbineList"
  45. >
  46. <el-option
  47. v-for="item in stationList"
  48. :key="item.id"
  49. :value="item.id"
  50. :label="item.name"
  51. ></el-option>
  52. </el-select>
  53. </div>
  54. </div>
  55. <div class="search-item" v-if="state.isshowwindturbineName">
  56. <span class="label">机组:</span>
  57. <div class="search-content">
  58. <el-select
  59. v-model="state.deviceId"
  60. style="width: 120px"
  61. clearable
  62. size="mini"
  63. placeholder="全部"
  64. popper-class="select"
  65. >
  66. <el-option
  67. v-for="item in state.windturbineList"
  68. :key="item.id"
  69. :value="item.id"
  70. :label="item.aname"
  71. >
  72. </el-option>
  73. </el-select>
  74. </div>
  75. </div>
  76. <div class="search-item" v-if="state.isshowwindturbineName">
  77. <span class="label">型号:</span>
  78. <div class="search-content">
  79. <el-select
  80. v-model="state.modelId"
  81. style="width: 120px"
  82. clearable
  83. size="mini"
  84. placeholder="全部"
  85. popper-class="select"
  86. >
  87. <el-option
  88. v-for="item in modelList"
  89. :key="item.id"
  90. :value="item.id"
  91. :label="item.name"
  92. >
  93. </el-option>
  94. </el-select>
  95. </div>
  96. </div>
  97. <div class="search-item" v-if="state.isshowwindturbineName">
  98. <span class="label">部件:</span>
  99. <div class="search-content">
  100. <el-select
  101. v-model="state.components"
  102. style="width: 120px"
  103. clearable
  104. size="mini"
  105. placeholder="全部"
  106. popper-class="select"
  107. multiple
  108. collapse-tags
  109. >
  110. <el-option
  111. v-for="item in componentList"
  112. :key="item.id"
  113. :value="item.nemCode"
  114. :label="item.name"
  115. >
  116. </el-option>
  117. </el-select>
  118. </div>
  119. </div>
  120. <div class="search-item">
  121. <span class="label">描述:</span>
  122. <div class="search-content"></div>
  123. <el-input
  124. v-model="state.description"
  125. placeholder="请输入..."
  126. size="mini"
  127. ></el-input>
  128. </div>
  129. <div class="search-item">
  130. <span class="label">日期:</span>
  131. <div class="search-content">
  132. <el-date-picker
  133. v-model="state.dateTime"
  134. size="mini"
  135. type="datetimerange"
  136. range-separator="-"
  137. format="YYYY-MM-DD HH:mm:ss"
  138. value-format="YYYY-MM-DD HH:mm:ss"
  139. start-placeholder="开始"
  140. end-placeholder="结束"
  141. popper-class="date-select"
  142. >
  143. </el-date-picker>
  144. </div>
  145. </div>
  146. </div>
  147. <div class="btns">
  148. <el-button class="buttons" round size="mini" @click="getAlarmHistoryt"
  149. >查询</el-button
  150. >
  151. <el-button
  152. size="mini"
  153. class="buttons"
  154. @click="export2Excel"
  155. round
  156. :disabled="state.tableData?.length == 0 ? true : false"
  157. >
  158. 导出</el-button
  159. >
  160. <!-- <el-button
  161. class="buttons"
  162. round
  163. size="mini"
  164. :disabled="!state.tableData?.length"
  165. @click="confirmItem(state.tableData)"
  166. >确认本页</el-button
  167. > -->
  168. </div>
  169. </div>
  170. <div class="table-wrapper">
  171. <div class="leftContent">
  172. <span>{{ pageTitle }}</span>
  173. </div>
  174. <el-table
  175. size="mini"
  176. :data="state.tableData"
  177. class="warpperTable"
  178. style="width: 100%; height: calc(100% - 35px - 55px)"
  179. stripe
  180. >
  181. <template v-if="state.isshowwindturbineName">
  182. <el-table-column
  183. v-for="item in state.tableHeader"
  184. :label="item.title"
  185. :prop="item.code"
  186. :key="item.code"
  187. :width="item.width || ''"
  188. show-overflow-tooltip
  189. align="center"
  190. >
  191. <template #default="scope">
  192. <p :style="item.style && item.style(scope.row)">
  193. <span v-if="item.code == 'rank'">
  194. {{ tableFilter(scope.row.rank) }}
  195. </span>
  196. <span v-else-if="item.code == 'alarmtype'">
  197. {{ tableFilter(scope.row.alarmtype) }}
  198. </span>
  199. <span v-else-if="item.code == 'ts'">
  200. {{ formatTime(scope.row.ts) }}
  201. </span>
  202. <span
  203. :style="`color:${
  204. scope.row.confirmed ? '#05bb4c' : 'var(--el-color-danger)'
  205. }`"
  206. v-else-if="item.code == 'confirmed'"
  207. >
  208. {{ scope.row.confirmed ? "是" : "否" }}
  209. </span>
  210. <span v-else-if="item.code == 'components'">
  211. <!-- {{ getComponentsName(scope.row.components) }} -->
  212. {{ scope.row.components }}
  213. </span>
  214. <span v-else>
  215. {{
  216. scope.row[item.code] != "NULL" ? scope.row[item.code] : "--"
  217. }}
  218. </span>
  219. </p>
  220. </template>
  221. </el-table-column>
  222. <el-table-column
  223. label="操作"
  224. width="100"
  225. header-align="center"
  226. align="center"
  227. >
  228. <template #default="scope">
  229. <el-button
  230. type="text"
  231. :style="`color: ${
  232. $store.state.theme ? '#1890ff' : '#47aee7'
  233. } !important`"
  234. @click="confirmItem([scope.row])"
  235. >确认本条</el-button
  236. >
  237. </template>
  238. </el-table-column>
  239. </template>
  240. <template v-else>
  241. <el-table-column
  242. v-for="item in state.tableHeader1"
  243. :label="item.title"
  244. :prop="item.code"
  245. :key="item.code"
  246. :width="item.width || ''"
  247. show-overflow-tooltip
  248. header-align="center"
  249. >
  250. <template #default="scope">
  251. <p :style="item.style && item.style(scope.row)">
  252. <span v-if="item.code == 'rank'">
  253. {{ tableFilter(scope.row.rank) }}
  254. </span>
  255. <span v-else-if="item.code == 'alarmtype'">
  256. {{ tableFilter(scope.row.alarmtype) }}
  257. </span>
  258. <span v-else-if="item.code == 'ts'">
  259. {{ formatTime(scope.row.ts) }}
  260. </span>
  261. <span
  262. :style="`color:${
  263. scope.row.confirmed ? '#05bb4c' : 'var(--el-color-danger)'
  264. }`"
  265. v-else-if="item.code == 'confirmed'"
  266. >
  267. {{ scope.row.confirmed ? "是" : "否" }}
  268. </span>
  269. <span v-else>
  270. {{
  271. scope.row[item.code] != "NULL" ? scope.row[item.code] : "--"
  272. }}
  273. </span>
  274. </p>
  275. </template>
  276. </el-table-column>
  277. <el-table-column
  278. label="操作"
  279. width="100"
  280. header-align="center"
  281. align="center"
  282. fixed="right"
  283. >
  284. <template #default="scope">
  285. <el-button
  286. type="text"
  287. style="color: #05bb4c"
  288. @click="confirmItem([scope.row])"
  289. >确认本条</el-button
  290. >
  291. </template>
  292. </el-table-column>
  293. </template>
  294. </el-table>
  295. <div class="pagination-wrapper">
  296. <el-pagination
  297. layout="total, sizes, prev, pager, next"
  298. :current-page="query.page"
  299. :page-size="query.limit"
  300. :page-sizes="[21, 100, 500, 1000]"
  301. :total="query.pageTotal"
  302. @size-change="
  303. (value) => {
  304. query.limit = value;
  305. query.page = 1;
  306. getAlarmHistoryt();
  307. }
  308. "
  309. @current-change="handlePageChange"
  310. ></el-pagination>
  311. </div>
  312. </div>
  313. </div>
  314. </template>
  315. <script setup name="historyWarning">
  316. import { watch, reactive, nextTick, computed, onMounted, ref } from "vue";
  317. import { useRouter, useRoute } from "vue-router";
  318. import BASE from "@/tools/basicTool.js";
  319. import dayjs from "dayjs";
  320. import {
  321. alarm_history,
  322. new_alarm_history,
  323. fetchWindturbineList,
  324. fetchModel,
  325. fetchRelatePartAndAlarmType,
  326. getWpList,
  327. confirmAlart,
  328. } from "@/api/zhbj/index.js";
  329. import { ElMessageBox, ElMessage } from "element-plus";
  330. import { outExportExcel } from "@/tools/excel/exportExcel.js"; //引入文件
  331. import { useStore } from "vuex";
  332. const pageTitle = "报警查询";
  333. const store = useStore();
  334. const route = useRoute();
  335. const getComponentsName = (components) => {
  336. const listItem =
  337. componentList?.value?.find((ele) => {
  338. return ele.nemCode === components;
  339. }) || {};
  340. return listItem?.name || "";
  341. };
  342. onMounted(() => {
  343. state.dateTime = [
  344. dayjs().startOf("day").format("YYYY-MM-DD HH:mm:ss"),
  345. dayjs().format("YYYY-MM-DD HH:mm:ss"),
  346. ];
  347. if (route.query.deviceType != "booststation") {
  348. state.deviceId = route.query.deviceId || "";
  349. state.alarmId = route.query.alarmId || "";
  350. state.typeVal = route.query.deviceType || "windturbine";
  351. state.modelId = route.query.modelId || "";
  352. } else {
  353. state.stationName = route.query.deviceId;
  354. state.deviceId = "";
  355. state.alarmId = route.query.alarmId || "";
  356. state.typeVal = route.query.deviceType || "booststation";
  357. }
  358. state.isshowwindturbineName = state.typeVal == "booststation" ? false : true;
  359. // if (route.query.ts) {
  360. // state.dateTime = [
  361. // `${dayjs(Number(route.query.ts)).format("YYYY-MM-DD")} 00:00:00`,
  362. // dayjs(Number(route.query.ts)).format("YYYY-MM-DD HH:mm:ss"),
  363. // ];
  364. // }
  365. getStationList(); //场站
  366. // getAlarmHistoryt();
  367. getequipmentmodel_list(); //机型
  368. getfetchRelatePart(); //部件
  369. });
  370. // 机型
  371. const getequipmentmodel_list = async () => {
  372. const { data } = await fetchModel();
  373. state.modelListAll = data;
  374. };
  375. //所属部件
  376. const getfetchRelatePart = async () => {
  377. const { data } = await fetchRelatePartAndAlarmType();
  378. state.fetchListAll = data;
  379. };
  380. const confirmItem = (alarmItem) => {
  381. ElMessageBox.confirm("您确定要执行此操作吗?", "提示", {
  382. confirmButtonText: "确定",
  383. cancelButtonText: "取消",
  384. type: "warning",
  385. })
  386. .then(() => {
  387. confirmAlart(alarmItem)
  388. .then((res) => {
  389. if (res.code === 200) {
  390. ElMessage.success("确认成功");
  391. store.commit("removeWarning", alarmItem);
  392. getAlarmHistoryt();
  393. }
  394. })
  395. .catch(() => {
  396. ElMessage.error("确认失败,请重试");
  397. });
  398. })
  399. .catch(() => {});
  400. };
  401. const getColumnStyle = (columnItem) => {
  402. let style = "color:";
  403. if (columnItem.endts) {
  404. style += " #05bb4c";
  405. } else {
  406. style += "var(--el-color-danger)";
  407. }
  408. return style;
  409. };
  410. const state = reactive({
  411. typeList: [
  412. {
  413. label: "升压站",
  414. value: "booststation",
  415. },
  416. // {
  417. // label: "自定义",
  418. // value: "custom",
  419. // },
  420. {
  421. label: "风机",
  422. value: "windturbine",
  423. },
  424. // {
  425. // label: "光伏",
  426. // value: "inverter",
  427. // },
  428. ],
  429. typeVal: "windturbine",
  430. stationId: "NX_FGS_HA_FDC_STA",
  431. stationName: "",
  432. alarmId: "",
  433. windturbineList: [],
  434. deviceId: "",
  435. modelListAll: {},
  436. fetchListAll: {},
  437. modelId: "", //型号
  438. components: [], //部件
  439. description: "", //描述
  440. dateTime: [],
  441. startDate: null,
  442. endDate: null,
  443. tableData: [],
  444. isshowwindturbineName: true,
  445. ts: "",
  446. tableHeader: [
  447. { title: "时间", code: "ts", width: "150" },
  448. { title: "场站", code: "wpName", width: "120" },
  449. { title: "机组", code: "code", width: "100" },
  450. { title: "报警信息", code: "description" },
  451. // { title: "故障原因", code: "faultCause" },
  452. // { title: "级别", code: "rank", width: "80" },
  453. { title: "部件类型", code: "components", width: "120" },
  454. // { title: "故障解决方法", code: "resolvent" },
  455. { title: "报警解除时间", code: "endtsName", width: "150" },
  456. {
  457. title: "状态",
  458. code: "isCloseName",
  459. // width: "80",
  460. style: getColumnStyle,
  461. width: 100,
  462. },
  463. { title: "是否确认", code: "confirmed", width: "100" },
  464. { title: "类型", code: "alarmTypeName", width: "80" },
  465. ],
  466. tableHeader1: [
  467. { title: "时间", code: "ts", width: "150" },
  468. { title: "升压站", code: "stationname", width: "150" },
  469. { title: "报警信息", code: "description" },
  470. // { title: "级别", code: "rank", width: "80" },
  471. { title: "报警解除时间", code: "endtsName", width: "150" },
  472. {
  473. title: "状态",
  474. code: "isCloseName",
  475. style: getColumnStyle,
  476. width: 100,
  477. // width: "80",
  478. },
  479. { title: "是否确认", code: "confirmed", width: "100" },
  480. { title: "类型", code: "alarmTypeName", width: "80" },
  481. ],
  482. });
  483. // 场站列表/升压站列表
  484. const stationList = ref([]);
  485. //获取场站列表
  486. const getStationList = async () => {
  487. const { data } = await getWpList(state.typeVal);
  488. stationList.value = data;
  489. if (state.deviceId && state.typeVal != "booststation") {
  490. let station = data.find((i) => {
  491. let st = i.id.split("_")[2];
  492. let dt = state.deviceId.split("_")[2];
  493. if (st == dt) {
  494. return i;
  495. }
  496. });
  497. // state.stationId = station?.id;
  498. } else if (state.typeVal == "booststation") {
  499. let station = data.find((i) => i.name == state.stationName);
  500. // state.stationId = station ? station?.id : data[0]?.id;
  501. } else {
  502. // state.stationId = data[0]?.id;
  503. }
  504. state.stationId = route.query.stationId || state.stationId;
  505. route.query.stationId ? (state.modelId = modelList.value?.[0]?.id || "") : "";
  506. if (stationList.value.length) {
  507. getWindturbineList();
  508. }
  509. };
  510. // watch(
  511. // () => stationList,
  512. // (val, old) => {
  513. // val?.value?.length &&
  514. // nextTick(async () => {
  515. // await getWindturbineList();
  516. // });
  517. // },
  518. // {
  519. // deep: true,
  520. // immediate: true,
  521. // }
  522. // );
  523. watch(
  524. () => route,
  525. (val, old) => {
  526. if (route.query.deviceType != "booststation") {
  527. state.deviceId = route.query.deviceId || "";
  528. state.alarmId = route.query.alarmId || "";
  529. state.typeVal = route.query.deviceType || "windturbine";
  530. state.modelId = route.query.modelId || "";
  531. } else {
  532. state.stationName = route.query.deviceId;
  533. state.deviceId = "";
  534. state.alarmId = route.query.alarmId || "";
  535. state.typeVal = route.query.deviceType || "booststation";
  536. }
  537. state.isshowwindturbineName =
  538. state.typeVal == "booststation" ? false : true;
  539. getStationList();
  540. },
  541. {
  542. deep: true,
  543. immediate: true,
  544. }
  545. );
  546. //型号列表
  547. const modelList = computed(() => {
  548. if (state.typeVal != "booststation") {
  549. if (state.stationId == "") {
  550. return [];
  551. } else {
  552. state.modelId = route.query.deviceId ? route.query.modelId : "";
  553. return state.modelListAll[state.stationId];
  554. }
  555. } else {
  556. return [];
  557. }
  558. });
  559. //部件列表
  560. const componentList = computed(() => {
  561. if (state.typeVal != "booststation") {
  562. if (state.stationId == "") {
  563. return [];
  564. } else {
  565. if (state.stationId.includes("FDC")) {
  566. return state.fetchListAll?.fjbj;
  567. } else {
  568. return state.fetchListAll?.gfbj;
  569. }
  570. }
  571. } else {
  572. return [];
  573. }
  574. });
  575. //get 风机
  576. const getWindturbineList = async () => {
  577. state.deviceId = "";
  578. const { data } = await fetchWindturbineList(state.stationId || "");
  579. state.windturbineList = data;
  580. // state.modelId = modelList.value?.[0]?.id || "";
  581. await getAlarmHistoryt();
  582. };
  583. const query = reactive({
  584. page: 1,
  585. limit: 1000,
  586. pageTotal: null,
  587. });
  588. // 获取历史记录表
  589. const getAlarmHistoryt = async () => {
  590. BASE.showLoading();
  591. let params = {
  592. pageNum: query.page,
  593. pageSize: query.limit,
  594. alarmId: state.alarmId,
  595. alarmType: state.typeVal,
  596. stationid: state.stationId,
  597. deviceid: state.typeVal == "booststation" ? "" : state.deviceId,
  598. modelId: state.typeVal == "booststation" ? "" : state.modelId,
  599. components: state.components.toString(),
  600. description: state.description,
  601. begin: state.dateTime[0],
  602. end: state.dateTime[1],
  603. };
  604. const { data } = await alarm_history(params);
  605. BASE.closeLoading();
  606. if (data) {
  607. query.pageTotal = data?.total;
  608. data?.ls?.forEach((ele) => {
  609. ele.isCloseName = ele.endts ? "已解除" : "未解除";
  610. ele.alarmTypeName =
  611. ele.alarmType === "booststation"
  612. ? "升压站"
  613. : ele.alarmType === "windturbine"
  614. ? "风机"
  615. : ele.alarmType === "inverter"
  616. ? "光伏"
  617. : "";
  618. ele.endtsName = ele.endts > 0 ? formatTime(ele.endts) : "--";
  619. });
  620. state.tableData = data?.ls;
  621. } else {
  622. state.tableData = new Array(5).fill({
  623. tbName: null,
  624. alarmId: "SQ_0125",
  625. alarmType: "windturbine",
  626. characteristic: "报警",
  627. components: "BPQ",
  628. confirmed: false,
  629. description: "变频器故障27",
  630. deviceId: "SXJ_KGDL_XWT_F_WT_0014_EQ",
  631. devicename: "14号风机",
  632. deviceType: "windturbine",
  633. enabled: true,
  634. lineid: "SXJ_KGDL_XWTF01_LN",
  635. linename: "一号风机线",
  636. modelId: "SEC-W02B-1250kW",
  637. projectid: "SXJ_KGDL_XWTF01_EG",
  638. projectname: "一期项目",
  639. rank: 3,
  640. resettable: false,
  641. stationid: "",
  642. stationname: "13风电场",
  643. subcomponents: "NULL",
  644. suffix: null,
  645. tagid: "FD-YYXWT-ShangQi.140623F1412MDL01BF399DB0122SP01RAW00",
  646. triggertype: 1463,
  647. uniformcode: "BJ0001",
  648. superTableName: null,
  649. ts: 1718160795000,
  650. val: 1,
  651. oval: null,
  652. endts: 0,
  653. timelong: 0,
  654. name: null,
  655. nemCode: "状态码1463",
  656. faultCause: "13.7s>信号<=14.2s",
  657. resolvent: "输入端142功率上升延迟300s",
  658. wpName: "13风电场",
  659. code: "#14",
  660. wpId: null,
  661. faultType: null,
  662. id: "sxj_kgdl_xwt_f_wt_0014_eq_sq_0125",
  663. });
  664. }
  665. };
  666. //报警类型变化
  667. const typechange = () => {
  668. state.alarmId = "";
  669. state.deviceId = "";
  670. state.isshowwindturbineName = state.typeVal == "booststation" ? false : true;
  671. };
  672. // 批量导出
  673. const export2Excel = async () => {
  674. let params = {
  675. pageNum: query.page,
  676. pageSize: query.limit,
  677. alarmType: state.typeVal,
  678. stationId: state.stationId,
  679. deviceId: state.typeVal == "booststation" ? "" : state.deviceId,
  680. modelId: state.modelId,
  681. components: state.components,
  682. description: state.description,
  683. begin: state.dateTime[0],
  684. end: state.dateTime[1],
  685. };
  686. if (state.dateTime[1] - state.dateTime[0] > 6 * 24 * 60 * 60 * 1000) {
  687. this.$message({
  688. message: "导出时间范围不能大于7天",
  689. type: "warning",
  690. });
  691. } else {
  692. let tableHeader = [];
  693. let tableKey = [];
  694. // const { data } = await alarm_history(params);
  695. const data = { ls: state?.tableData || [] };
  696. if (state.isshowwindturbineName) {
  697. tableHeader = state.tableHeader.map((item) => item.title);
  698. tableKey = state.tableHeader.map((item) => item.code);
  699. } else {
  700. tableHeader = state.tableHeader1.map((item) => item.title);
  701. tableKey = state.tableHeader1.map((item) => item.code);
  702. }
  703. const stationName =
  704. stationList.value.find((ele) => {
  705. return ele.id === state.stationId;
  706. })?.name || "";
  707. const fileName = `${stationName} ${state.dateTime[0]} ~ ${state.dateTime[1]} 数据表`;
  708. outExportExcel(
  709. tableHeader,
  710. tableKey,
  711. data.ls.map((item) => {
  712. return {
  713. ...item,
  714. ts: formatTime(item.ts),
  715. rank: tableFilter(item.rank),
  716. alarmTypeName:
  717. item.alarmType === "booststation"
  718. ? "升压站"
  719. : item.alarmType === "windturbine"
  720. ? "风机"
  721. : item.alarmType === "inverter"
  722. ? "光伏"
  723. : "",
  724. endtsName: item.endts > 0 ? formatTime(item.endts) : "--",
  725. isCloseName: item.endts ? "已解除" : "未解除",
  726. confirmed: item.confirmed ? "是" : "否",
  727. };
  728. }),
  729. fileName
  730. );
  731. ElMessage.success(`导出成功!`);
  732. }
  733. };
  734. // 分页导航
  735. const handlePageChange = (val) => {
  736. query.page = val;
  737. getAlarmHistoryt();
  738. };
  739. // 时间格式化
  740. const formatTime = (val) => {
  741. return dayjs(val).format("YYYY-MM-DD HH:mm:ss");
  742. };
  743. // 格式化
  744. const obj = {
  745. 1: "低级",
  746. 2: "低中级",
  747. 3: "中级",
  748. 4: "中高级",
  749. 5: "高级",
  750. booststation: "升压站",
  751. inverter: "光伏",
  752. windturbine: "风机",
  753. };
  754. const messageTypeObj = {
  755. 1: "触发",
  756. 3: "解除",
  757. };
  758. const tableFilter = (val) => {
  759. return obj[val];
  760. };
  761. const messageTypeFilter = (val) => {
  762. return messageTypeObj[val];
  763. };
  764. </script>
  765. <style scoped lang="less">
  766. p {
  767. padding: 0;
  768. margin: 0;
  769. }
  770. .history-warning {
  771. height: calc(100% - 40px);
  772. padding: 0 20px;
  773. padding-bottom: 10px;
  774. .form-wrapper ::v-deep {
  775. display: flex;
  776. flex-direction: column;
  777. padding-top: 10px;
  778. position: relative;
  779. .search-wrapper {
  780. display: flex;
  781. align-items: center;
  782. font-size: 14px;
  783. font-family: Microsoft YaHei;
  784. font-weight: 400;
  785. color: #b3b3b3;
  786. margin-bottom: 10px;
  787. .search-item {
  788. display: flex;
  789. margin-right: 10px;
  790. max-width: 450px;
  791. align-items: center;
  792. .label {
  793. margin-right: 10px;
  794. text-align: right;
  795. white-space: nowrap;
  796. // width: 60px;
  797. }
  798. .search-content {
  799. flex: 1;
  800. }
  801. }
  802. }
  803. .btns {
  804. display: flex;
  805. justify-content: flex-end;
  806. margin-right: 10px;
  807. position: absolute;
  808. right: 80px;
  809. top: 13px;
  810. }
  811. .buttons {
  812. background-color: rgba(5, 187, 76, 0.2);
  813. border: 1px solid #3b6c53;
  814. color: #b3b3b3;
  815. font-size: 14px;
  816. &:hover {
  817. background-color: rgba(5, 187, 76, 0.5);
  818. color: #ffffff;
  819. }
  820. }
  821. }
  822. .table-wrapper {
  823. height: calc(100% - 60px);
  824. width: calc(100% - 20px);
  825. .leftContent {
  826. width: 242px;
  827. height: 41px;
  828. display: flex;
  829. align-items: center;
  830. background: url("~@/assets/imgs/title_left_bg.png") no-repeat;
  831. span {
  832. font-size: 16px;
  833. font-family: Microsoft YaHei;
  834. font-weight: 400;
  835. color: #05bb4c;
  836. margin-left: 25px;
  837. }
  838. }
  839. .warpperTable :deep {
  840. .el-table__body-wrapper{
  841. height: 100%;
  842. overflow-y: auto;
  843. }
  844. }
  845. .pagination-wrapper :deep {
  846. text-align: right;
  847. margin-top: 10px;
  848. }
  849. }
  850. }
  851. </style>