safecomponent.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606
  1. <template>
  2. <!-- @click="clickAlarmItem" -->
  3. <div class="safeCom">
  4. <div class="safeCom_head">
  5. <i
  6. :class="['iconfont', iconfonts()]"
  7. style="font-size: 24px; margin-right: 10px"
  8. ></i>
  9. <div style="display: flex; justify-content: space-between; width: 100%">
  10. <div class="safeCom_title">{{ title }}</div>
  11. <div
  12. style="font-size: 14px; position: relative; right: 35px; top: 15px"
  13. >
  14. <!-- 共{{ alarmList.length }}/{{ fullTableData.length }}条 -->
  15. {{ alarmList.length }}条
  16. </div>
  17. </div>
  18. </div>
  19. <el-table
  20. :data="alarmList"
  21. style="width: 100%"
  22. height="calc(100% - 100px)"
  23. stripe
  24. >
  25. <el-table-column
  26. prop="tsName"
  27. label="时间"
  28. width="120"
  29. show-overflow-tooltip
  30. align="center"
  31. />
  32. <el-table-column
  33. prop="wpName"
  34. label="场站"
  35. align="center"
  36. width="180"
  37. show-overflow-tooltip
  38. />
  39. <el-table-column
  40. v-if="deviceType != 'booststation'"
  41. align="center"
  42. prop="code"
  43. label="设备"
  44. width="80"
  45. show-overflow-tooltip
  46. />
  47. <el-table-column
  48. :prop="alarmType === 'custom' ? 'characteristic' : 'description'"
  49. align="center"
  50. label="信息"
  51. show-overflow-tooltip
  52. />
  53. <el-table-column
  54. prop="faultCause"
  55. label="故障原因"
  56. align="left"
  57. show-overflow-tooltip
  58. >
  59. <template #default="{ row }">
  60. {{ row.faultCause == "NULL" ? "--" : row.faultCause }}
  61. </template>
  62. </el-table-column>
  63. <el-table-column
  64. prop=""
  65. label="解除时间"
  66. align="center"
  67. width="220"
  68. show-overflow-tooltip
  69. >
  70. <template #default="scope">
  71. <span>{{ scope.row.endts || scope.row.closeTime || "--" }}</span>
  72. </template>
  73. </el-table-column>
  74. <!-- <el-table-column
  75. label="状态"
  76. width="75"
  77. align="center"
  78. show-overflow-tooltip
  79. >
  80. <template #default="scope">
  81. <span
  82. :style="`color:${
  83. scope.row.isClose
  84. ? 'var(--el-color-success)'
  85. : 'var(--el-color-danger)'
  86. }`"
  87. >{{ scope.row.isClose ? "已解除" : "未解除" }}</span
  88. >
  89. </template>
  90. </el-table-column> -->
  91. <el-table-column
  92. label="是否解除"
  93. width="120"
  94. align="center"
  95. show-overflow-tooltip
  96. >
  97. <template #default="scope">
  98. <span
  99. :style="`color:${
  100. scope.row.isClose
  101. ? 'var(--el-color-success)'
  102. : 'var(--el-color-danger)'
  103. }`"
  104. >{{ scope.row.isClose ? "已解除" : "未解除" }}</span
  105. >
  106. </template>
  107. </el-table-column>
  108. <el-table-column label="操作" width="100" align="center">
  109. <template #default="scope">
  110. <el-button
  111. type="text"
  112. style="color: #1890ff !important"
  113. size="small"
  114. @click="confirm(scope.row)"
  115. >确认本条</el-button
  116. >
  117. </template>
  118. </el-table-column>
  119. </el-table>
  120. <div style="margin-top: 10px; display: flex; justify-content: end;">
  121. <el-button type="primary" plain @click="confirmAll"
  122. >确认所有报警</el-button
  123. >
  124. </div>
  125. <el-dialog
  126. v-model="showDialog"
  127. top="50px"
  128. width="90%"
  129. modal-class="alarmDialog"
  130. :show-close="true"
  131. draggable
  132. @close="
  133. () => {
  134. stopUpdate = false;
  135. }
  136. "
  137. >
  138. <template #title>
  139. <div class="dialog-title">
  140. <div class="title">{{ title }}</div>
  141. </div>
  142. </template>
  143. <el-card>
  144. <el-table
  145. :data="dialogTableData"
  146. style="width: 100%"
  147. height="620px"
  148. border
  149. stripe
  150. >
  151. <el-table-column
  152. prop="fullTsName"
  153. label="时间"
  154. width="220"
  155. align="center"
  156. show-overflow-tooltip
  157. />
  158. <el-table-column
  159. prop="wpName"
  160. label="场站"
  161. width="180"
  162. align="center"
  163. show-overflow-tooltip
  164. />
  165. <el-table-column
  166. prop="code"
  167. label="设备"
  168. width="100"
  169. align="center"
  170. show-overflow-tooltip
  171. />
  172. <!-- <el-table-column
  173. prop="characteristic"
  174. label="特征"
  175. width="100"
  176. show-overflow-tooltip
  177. /> -->
  178. <el-table-column label="描述" align="left">
  179. <template #default="scope">
  180. <span
  181. class="alertDescCursor"
  182. @click="goToAlertDescPage(scope.row)"
  183. >{{
  184. alarmType === "custom"
  185. ? scope.row.characteristic
  186. : scope.row.description || "--"
  187. }}</span
  188. >
  189. </template>
  190. </el-table-column>
  191. <el-table-column
  192. prop="faultCause"
  193. label="故障原因"
  194. align="left"
  195. show-overflow-tooltip
  196. >
  197. <template #default="{ row }">
  198. {{ row.faultCause == "NULL" ? "--" : row.faultCause }}
  199. </template>
  200. </el-table-column>
  201. <el-table-column
  202. prop=""
  203. label="解除时间"
  204. align="center"
  205. width="220"
  206. show-overflow-tooltip
  207. >
  208. <template #default="scope">
  209. <span>{{ scope.row.endts || scope.row.closeTime || "--" }}</span>
  210. </template>
  211. </el-table-column>
  212. <!-- <el-table-column
  213. prop="resolvent"
  214. label="解决方法"
  215. show-overflow-tooltip
  216. /> -->
  217. <!-- <el-table-column label="级别" width="100" show-overflow-tooltip>
  218. <template #default="scope">
  219. <el-tag
  220. class="ml-2"
  221. :type="
  222. scope.row.lv === 5
  223. ? 'danger'
  224. : scope.row.lv === 4
  225. ? 'warning'
  226. : 'info'
  227. "
  228. >{{ scope.row.lvName }}</el-tag
  229. >
  230. </template>
  231. </el-table-column> -->
  232. <el-table-column
  233. label="是否解除"
  234. width="120"
  235. align="center"
  236. show-overflow-tooltip
  237. >
  238. <template #default="scope">
  239. <span
  240. :style="`color:${
  241. scope.row.isClose
  242. ? 'var(--el-color-success)'
  243. : 'var(--el-color-danger)'
  244. }`"
  245. >{{ scope.row.isClose ? "已解除" : "未解除" }}</span
  246. >
  247. </template>
  248. </el-table-column>
  249. <el-table-column label="操作" width="100" align="center">
  250. <template #default="scope">
  251. <el-button
  252. type="text"
  253. style="color: #1890ff !important"
  254. size="small"
  255. @click="confirm(scope.row)"
  256. >确认本条</el-button
  257. >
  258. </template>
  259. </el-table-column>
  260. </el-table>
  261. </el-card>
  262. <template #footer>
  263. <el-button type="primary" plain @click="confirmAll"
  264. >确认所有报警</el-button
  265. >
  266. </template>
  267. </el-dialog>
  268. </div>
  269. </template>
  270. <script>
  271. import { confirmAlart } from "@/api/zhbj/index.js";
  272. import { alarm_history } from "@/api/zhbj/index.js";
  273. import dayjs from "dayjs";
  274. export default {
  275. props: {
  276. title: {
  277. type: String,
  278. default: () => {
  279. return "";
  280. },
  281. },
  282. deviceType: {
  283. type: String,
  284. default: () => {
  285. return "";
  286. },
  287. },
  288. alarmType: {
  289. type: String,
  290. default: () => {
  291. return "";
  292. },
  293. },
  294. },
  295. data() {
  296. return {
  297. alarmList: [],
  298. iconfontsObj: {
  299. booststation: "iconIOTtubiao_huabanfuben",
  300. windturbine: "iconfengji",
  301. custom: "iconzidingyi",
  302. inverter: "iconzidingyi",
  303. },
  304. showDialog: false,
  305. dialogTableData: [],
  306. fullTableData: [],
  307. stopUpdate: false,
  308. timer: null
  309. };
  310. },
  311. created() {
  312. },
  313. mounted() {
  314. this.getAlarmHistory();
  315. this.timer = setInterval(() => {
  316. this.getAlarmHistory();
  317. }, 60000);
  318. },
  319. unmounted() {
  320. clearInterval(this.timer);
  321. this.timer = null;
  322. },
  323. methods: {
  324. iconfonts() {
  325. return this.iconfontsObj[this.deviceType];
  326. },
  327. //查历史报警
  328. getAlarmHistory() {
  329. let params = {
  330. pageNum: 1,
  331. pageSize: 30,
  332. alarmId: "",
  333. alarmType: "custom",
  334. deviceType: "windturbine",
  335. stationid: "",
  336. deviceid: "",
  337. modelId: "",
  338. components: "",
  339. description: "",
  340. isclose: false,
  341. // begin: dayjs().add(-1, "hour").format("YYYY-MM-DD HH:mm:ss"),//获取当前时间的前一天的相同时间
  342. begin: dayjs().startOf('day').format("YYYY-MM-DD HH:mm:ss"), //获取当天 0 点
  343. end: dayjs().format("YYYY-MM-DD HH:mm:ss"),
  344. };
  345. if (params.alarmType == "windturbine") {
  346. // params.stationid = "SXJ_KGDL_DJY_FDC_STA";
  347. params.stationid = "";
  348. } else if (params.alarmType == "inverter") {
  349. params.stationid = "SXJ_KGDL_JR_GDC_STA";
  350. }
  351. alarm_history(params, 12000).then(res => {
  352. if (res?.data?.ls?.length > 0) {
  353. let alarmList = [];
  354. this.alarmList = [];
  355. res.data.ls.forEach((ele) => {
  356. ele.tsName = dayjs(ele.ts).format("MM-DD HH-mm-ss")
  357. alarmList.push(ele);
  358. });
  359. alarmList.sort((a, b) => {
  360. return b.ts - a.ts;
  361. });
  362. this.alarmList = alarmList;
  363. console.log("alarmList===>>>>", this.alarmList);
  364. }
  365. })
  366. },
  367. initWarningList() {
  368. if (this.$store.state.warningList?.length > 0) {
  369. let alarmList = [];
  370. this.alarmList = [];
  371. // let fullTableData = [];
  372. let dialogTableData = [];
  373. this.$store.state.warningList.forEach((ele) => {
  374. if (
  375. this.deviceType === ele.deviceType &&
  376. this.alarmType === ele.alarmType
  377. ) {
  378. alarmList?.length < this.$store.state.warningListLimitLength &&
  379. alarmList.push(ele);
  380. dialogTableData?.length < 50 && dialogTableData.push(ele);
  381. // fullTableData.push(ele);
  382. }
  383. });
  384. alarmList.sort((a, b) => {
  385. return b.ts - a.ts;
  386. });
  387. dialogTableData.sort((a, b) => {
  388. return b.ts - a.ts;
  389. });
  390. // fullTableData.sort((a, b) => {
  391. // return b.ts - a.ts;
  392. // });
  393. this.alarmList = alarmList;
  394. console.log("warningList===>>>>", this.$store.state.warningList);
  395. // console.log("dialogTableData===>>>>", dialogTableData);
  396. // console.log("alarmList===>>>>", this.alarmList);
  397. if (!this.stopUpdate) {
  398. this.dialogTableData = dialogTableData;
  399. }
  400. // this.fullTableData = fullTableData;
  401. }
  402. // else {
  403. // this.alarmList = [
  404. // {
  405. // tsName: "06-11 12:00:00",
  406. // wpName: "风电场1",
  407. // deviceName: "#36",
  408. // description: "变频器报告电网已接入",
  409. // isClose: true,
  410. // },
  411. // {
  412. // tsName: "06-11 12:00:00",
  413. // wpName: "风电场2",
  414. // deviceName: "#58",
  415. // description: "风机等待运行就绪",
  416. // isClose: false,
  417. // }
  418. // ];
  419. // }
  420. },
  421. clickAlarmItem() {
  422. this.showDialog = true;
  423. },
  424. confirm(alarmItem) {
  425. this.stopUpdate = true;
  426. this.$confirm("您确定要执行此操作吗?", "提示", {
  427. confirmButtonText: "确定",
  428. cancelButtonText: "取消",
  429. type: "warning",
  430. })
  431. .then(() => {
  432. confirmAlart([alarmItem])
  433. .then((res) => {
  434. if (res.code === 200) {
  435. this.BASE.showMsg({
  436. type: "success",
  437. msg: `${this.title}确认成功`,
  438. });
  439. this.$store.commit("removeWarningList", alarmItem);
  440. }
  441. this.stopUpdate = false;
  442. })
  443. .catch(() => {
  444. this.BASE.showMsg({
  445. msg: "确认失败,请重试",
  446. });
  447. });
  448. })
  449. .catch(() => {
  450. this.stopUpdate = false;
  451. });
  452. },
  453. confirmAll() {
  454. this.stopUpdate = true;
  455. if (!this?.dialogTableData?.length) {
  456. this.BASE.showMsg({
  457. type: "error",
  458. msg: "暂无报警可进行确认",
  459. });
  460. } else {
  461. this.$confirm("您确定要执行此操作吗?", "提示", {
  462. confirmButtonText: "确定",
  463. cancelButtonText: "取消",
  464. type: "warning",
  465. })
  466. .then(() => {
  467. confirmAlart(this.dialogTableData)
  468. .then((res) => {
  469. if (res.code === 200) {
  470. this.BASE.showMsg({
  471. type: "success",
  472. msg: `全部${this.title}确认成功`,
  473. });
  474. this.$store.commit("removeWarningList", this.dialogTableData);
  475. }
  476. this.stopUpdate = false;
  477. })
  478. .catch(() => {
  479. this.BASE.showMsg({
  480. msg: "确认失败,请重试",
  481. });
  482. });
  483. })
  484. .catch(() => {
  485. this.stopUpdate = false;
  486. });
  487. }
  488. },
  489. goToAlertDescPage(alertItem) {
  490. if (this.alarmType == "custom") {
  491. this.$router.push({
  492. path: "/integratedAlarm/customWarning",
  493. query: {
  494. deviceId: alertItem.deviceId,
  495. alarmId: alertItem.alarmId,
  496. modelId: alertItem.modelId,
  497. },
  498. });
  499. } else if (this.alarmType == "booststation") {
  500. this.$router.push({
  501. path: "/integratedAlarm/historyWarning",
  502. query: {
  503. deviceId: alertItem.wpName,
  504. alarmId: alertItem.alarmId,
  505. deviceType: this.deviceType,
  506. },
  507. });
  508. } else {
  509. this.$router.push({
  510. path: "/integratedAlarm/historyWarning",
  511. query: {
  512. deviceId: alertItem.deviceId,
  513. alarmId: alertItem.alarmId,
  514. deviceType: this.deviceType,
  515. modelId: alertItem.modelId,
  516. },
  517. });
  518. }
  519. },
  520. },
  521. watch: {
  522. "$store.state.warningList.length"(value) {
  523. this.initWarningList();
  524. },
  525. },
  526. };
  527. </script>
  528. <style lang="less" scoped>
  529. .safeCom {
  530. width: 100%;
  531. height: 100%;
  532. cursor: pointer;
  533. .safeCom_head {
  534. height: 50px;
  535. display: flex;
  536. align-items: center;
  537. border-bottom: 1.5px solid rgb(221, 221, 221);
  538. .safeCom_title {
  539. font-size: 24px;
  540. text-align: center;
  541. }
  542. .safeCom_fifter {
  543. flex: 1;
  544. }
  545. }
  546. }
  547. .currentAlartDialogHeader {
  548. display: flex;
  549. justify-content: space-between;
  550. align-items: center;
  551. }
  552. </style>
  553. <style lang="scss">
  554. .safeCom {
  555. .el-table__header-wrapper {
  556. background: #132347 !important;
  557. }
  558. }
  559. .alarmDialog {
  560. .el-dialog__body {
  561. height: 700px;
  562. max-height: 700ox;
  563. padding: 0;
  564. overflow: hidden;
  565. .el-card {
  566. width: calc(100% - 40px);
  567. height: calc(100% - 40px);
  568. margin: 20px;
  569. .alertDescCursor {
  570. cursor: pointer;
  571. transition: 0.2s;
  572. &:hover {
  573. color: var(--el-color-primary);
  574. text-decoration: underline;
  575. transition: 0.2s;
  576. }
  577. }
  578. }
  579. .confirmAllBtn {
  580. position: absolute;
  581. right: 20px;
  582. top: 20px;
  583. }
  584. }
  585. }
  586. </style>