safecomponent.vue 12 KB

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