safecomponent.vue 16 KB

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