safecomponent.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549
  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="dialogTableData"
  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="deviceName"
  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. export default {
  272. props: {
  273. title: {
  274. type: String,
  275. default: () => {
  276. return "";
  277. },
  278. },
  279. deviceType: {
  280. type: String,
  281. default: () => {
  282. return "";
  283. },
  284. },
  285. alarmType: {
  286. type: String,
  287. default: () => {
  288. return "";
  289. },
  290. },
  291. },
  292. data() {
  293. return {
  294. alarmList: [],
  295. iconfontsObj: {
  296. booststation: "iconIOTtubiao_huabanfuben",
  297. windturbine: "iconfengji",
  298. custom: "iconzidingyi",
  299. inverter: "iconzidingyi",
  300. },
  301. showDialog: false,
  302. dialogTableData: [],
  303. fullTableData: [],
  304. stopUpdate: false,
  305. };
  306. },
  307. created() {
  308. this.initWarningList();
  309. },
  310. methods: {
  311. iconfonts() {
  312. return this.iconfontsObj[this.deviceType];
  313. },
  314. initWarningList() {
  315. if (this.$store.state.warningList?.length > 0) {
  316. let alarmList = [];
  317. this.alarmList = [];
  318. // let fullTableData = [];
  319. let dialogTableData = [];
  320. this.$store.state.warningList.forEach((ele) => {
  321. if (
  322. this.deviceType === ele.deviceType &&
  323. this.alarmType === ele.alarmType
  324. ) {
  325. alarmList?.length < this.$store.state.warningListLimitLength &&
  326. alarmList.push(ele);
  327. dialogTableData?.length < 50 && dialogTableData.push(ele);
  328. // fullTableData.push(ele);
  329. }
  330. });
  331. alarmList.sort((a, b) => {
  332. return b.ts - a.ts;
  333. });
  334. dialogTableData.sort((a, b) => {
  335. return b.ts - a.ts;
  336. });
  337. // fullTableData.sort((a, b) => {
  338. // return b.ts - a.ts;
  339. // });
  340. this.alarmList = alarmList;
  341. console.log("alarmList===>>>>", this.alarmList);
  342. if (!this.stopUpdate) {
  343. this.dialogTableData = dialogTableData;
  344. }
  345. // this.fullTableData = fullTableData;
  346. }
  347. // else {
  348. // this.alarmList = [
  349. // {
  350. // tsName: "06-11 12:00:00",
  351. // wpName: "风电场1",
  352. // deviceName: "#36",
  353. // description: "变频器报告电网已接入",
  354. // isClose: true,
  355. // },
  356. // {
  357. // tsName: "06-11 12:00:00",
  358. // wpName: "风电场2",
  359. // deviceName: "#58",
  360. // description: "风机等待运行就绪",
  361. // isClose: false,
  362. // }
  363. // ];
  364. // }
  365. },
  366. clickAlarmItem() {
  367. this.showDialog = true;
  368. },
  369. confirm(alarmItem) {
  370. this.stopUpdate = true;
  371. this.$confirm("您确定要执行此操作吗?", "提示", {
  372. confirmButtonText: "确定",
  373. cancelButtonText: "取消",
  374. type: "warning",
  375. })
  376. .then(() => {
  377. confirmAlart([alarmItem])
  378. .then((res) => {
  379. if (res.code === 200) {
  380. this.BASE.showMsg({
  381. type: "success",
  382. msg: `${this.title}确认成功`,
  383. });
  384. this.$store.commit("removeWarningList", alarmItem);
  385. }
  386. this.stopUpdate = false;
  387. })
  388. .catch(() => {
  389. this.BASE.showMsg({
  390. msg: "确认失败,请重试",
  391. });
  392. });
  393. })
  394. .catch(() => {
  395. this.stopUpdate = false;
  396. });
  397. },
  398. confirmAll() {
  399. this.stopUpdate = true;
  400. if (!this?.dialogTableData?.length) {
  401. this.BASE.showMsg({
  402. type: "error",
  403. msg: "暂无报警可进行确认",
  404. });
  405. } else {
  406. this.$confirm("您确定要执行此操作吗?", "提示", {
  407. confirmButtonText: "确定",
  408. cancelButtonText: "取消",
  409. type: "warning",
  410. })
  411. .then(() => {
  412. confirmAlart(this.dialogTableData)
  413. .then((res) => {
  414. if (res.code === 200) {
  415. this.BASE.showMsg({
  416. type: "success",
  417. msg: `全部${this.title}确认成功`,
  418. });
  419. this.$store.commit("removeWarningList", this.dialogTableData);
  420. }
  421. this.stopUpdate = false;
  422. })
  423. .catch(() => {
  424. this.BASE.showMsg({
  425. msg: "确认失败,请重试",
  426. });
  427. });
  428. })
  429. .catch(() => {
  430. this.stopUpdate = false;
  431. });
  432. }
  433. },
  434. goToAlertDescPage(alertItem) {
  435. if (this.alarmType == "custom") {
  436. this.$router.push({
  437. path: "/integratedAlarm/customWarning",
  438. query: {
  439. deviceId: alertItem.deviceId,
  440. alarmId: alertItem.alarmId,
  441. modelId: alertItem.modelId,
  442. },
  443. });
  444. } else if (this.alarmType == "booststation") {
  445. this.$router.push({
  446. path: "/integratedAlarm/historyWarning",
  447. query: {
  448. deviceId: alertItem.wpName,
  449. alarmId: alertItem.alarmId,
  450. deviceType: this.deviceType,
  451. },
  452. });
  453. } else {
  454. this.$router.push({
  455. path: "/integratedAlarm/historyWarning",
  456. query: {
  457. deviceId: alertItem.deviceId,
  458. alarmId: alertItem.alarmId,
  459. deviceType: this.deviceType,
  460. modelId: alertItem.modelId,
  461. },
  462. });
  463. }
  464. },
  465. },
  466. watch: {
  467. "$store.state.warningList.length"(value) {
  468. this.initWarningList();
  469. },
  470. },
  471. };
  472. </script>
  473. <style lang="less" scoped>
  474. .safeCom {
  475. width: 100%;
  476. height: 100%;
  477. cursor: pointer;
  478. .safeCom_head {
  479. height: 50px;
  480. display: flex;
  481. align-items: center;
  482. border-bottom: 1.5px solid rgb(221, 221, 221);
  483. .safeCom_title {
  484. font-size: 24px;
  485. text-align: center;
  486. }
  487. .safeCom_fifter {
  488. flex: 1;
  489. }
  490. }
  491. }
  492. .currentAlartDialogHeader {
  493. display: flex;
  494. justify-content: space-between;
  495. align-items: center;
  496. }
  497. </style>
  498. <style lang="scss">
  499. .safeCom {
  500. .el-table__header-wrapper {
  501. background: #132347 !important;
  502. }
  503. }
  504. .alarmDialog {
  505. .el-dialog__body {
  506. height: 700px;
  507. max-height: 700ox;
  508. padding: 0;
  509. overflow: hidden;
  510. .el-card {
  511. width: calc(100% - 40px);
  512. height: calc(100% - 40px);
  513. margin: 20px;
  514. .alertDescCursor {
  515. cursor: pointer;
  516. transition: 0.2s;
  517. &:hover {
  518. color: var(--el-color-primary);
  519. text-decoration: underline;
  520. transition: 0.2s;
  521. }
  522. }
  523. }
  524. .confirmAllBtn {
  525. position: absolute;
  526. right: 20px;
  527. top: 20px;
  528. }
  529. }
  530. }
  531. </style>