safecomponent.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474
  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. iconfontsObj: {
  251. booststation: "iconIOTtubiao_huabanfuben",
  252. windturbine: "iconfengji",
  253. custom: "iconzidingyi",
  254. inverter: "iconzidingyi",
  255. },
  256. showDialog: false,
  257. dialogTableData: [],
  258. fullTableData: [],
  259. stopUpdate: false,
  260. };
  261. },
  262. created() {
  263. this.initWarningList();
  264. },
  265. methods: {
  266. iconfonts() {
  267. return this.iconfontsObj[this.deviceType];
  268. },
  269. initWarningList() {
  270. let alarmList = [];
  271. // let fullTableData = [];
  272. let dialogTableData = [];
  273. this.$store.state.warningList.forEach((ele) => {
  274. if (
  275. this.deviceType === ele.deviceType &&
  276. this.alarmType === ele.alarmType
  277. ) {
  278. alarmList?.length < this.$store.state.warningListLimitLength &&
  279. alarmList.push(ele);
  280. dialogTableData?.length < 50 && dialogTableData.push(ele);
  281. // fullTableData.push(ele);
  282. }
  283. });
  284. alarmList.sort((a, b) => {
  285. return b.ts - a.ts;
  286. });
  287. dialogTableData.sort((a, b) => {
  288. return b.ts - a.ts;
  289. });
  290. // fullTableData.sort((a, b) => {
  291. // return b.ts - a.ts;
  292. // });
  293. this.alarmList = alarmList;
  294. if (!this.stopUpdate) {
  295. this.dialogTableData = dialogTableData;
  296. }
  297. // this.fullTableData = fullTableData;
  298. },
  299. clickAlarmItem() {
  300. this.showDialog = true;
  301. },
  302. confirm(alarmItem) {
  303. this.stopUpdate = true;
  304. this.$confirm("您确定要执行此操作吗?", "提示", {
  305. confirmButtonText: "确定",
  306. cancelButtonText: "取消",
  307. type: "warning",
  308. })
  309. .then(() => {
  310. confirmAlart([alarmItem])
  311. .then((res) => {
  312. if (res.code === 200) {
  313. this.BASE.showMsg({
  314. type: "success",
  315. msg: `${this.title}确认成功`,
  316. });
  317. this.$store.commit("removeWarningList", alarmItem);
  318. }
  319. this.stopUpdate = false;
  320. })
  321. .catch(() => {
  322. this.BASE.showMsg({
  323. msg: "确认失败,请重试",
  324. });
  325. });
  326. })
  327. .catch(() => {
  328. this.stopUpdate = false;
  329. });
  330. },
  331. confirmAll() {
  332. this.stopUpdate = true;
  333. this.$confirm("您确定要执行此操作吗?", "提示", {
  334. confirmButtonText: "确定",
  335. cancelButtonText: "取消",
  336. type: "warning",
  337. })
  338. .then(() => {
  339. confirmAlart(this.dialogTableData)
  340. .then((res) => {
  341. if (res.code === 200) {
  342. this.BASE.showMsg({
  343. type: "success",
  344. msg: `全部${this.title}确认成功`,
  345. });
  346. this.$store.commit("removeWarningList", this.dialogTableData);
  347. }
  348. this.stopUpdate = false;
  349. })
  350. .catch(() => {
  351. this.BASE.showMsg({
  352. msg: "确认失败,请重试",
  353. });
  354. });
  355. })
  356. .catch(() => {
  357. this.stopUpdate = false;
  358. });
  359. },
  360. goToAlertDescPage(alertItem) {
  361. if (this.alarmType == "custom") {
  362. this.$router.push({
  363. path: "/integratedAlarm/safe/customWarning",
  364. query: {
  365. deviceId: alertItem.deviceId,
  366. alarmId: alertItem.alarmId,
  367. modelId: alertItem.modelId,
  368. },
  369. });
  370. } else if (this.alarmType == "booststation") {
  371. this.$router.push({
  372. path: "/integratedAlarm/safe/historyWarning",
  373. query: {
  374. deviceId: alertItem.wpName,
  375. alarmId: alertItem.alarmId,
  376. deviceType: this.deviceType,
  377. },
  378. });
  379. } else {
  380. this.$router.push({
  381. path: "/integratedAlarm/safe/historyWarning",
  382. query: {
  383. deviceId: alertItem.deviceId,
  384. alarmId: alertItem.alarmId,
  385. deviceType: this.deviceType,
  386. modelId: alertItem.modelId,
  387. },
  388. });
  389. }
  390. },
  391. },
  392. watch: {
  393. "$store.state.warningList.length"() {
  394. this.initWarningList();
  395. },
  396. },
  397. };
  398. </script>
  399. <style lang="less" scoped>
  400. .safeCom {
  401. width: 100%;
  402. height: calc(100% - 20px);
  403. cursor: pointer;
  404. .safeCom_head {
  405. height: 50px;
  406. display: flex;
  407. align-items: center;
  408. border-bottom: 1.5px solid rgb(221, 221, 221);
  409. .safeCom_title {
  410. font-size: 24px;
  411. text-align: center;
  412. }
  413. .safeCom_fifter {
  414. flex: 1;
  415. }
  416. }
  417. }
  418. .currentAlartDialogHeader {
  419. display: flex;
  420. justify-content: space-between;
  421. align-items: center;
  422. }
  423. </style>
  424. <style lang="scss">
  425. .alarmDialog {
  426. .el-dialog__body {
  427. height: 700px;
  428. max-height: 700ox;
  429. padding: 0;
  430. overflow: hidden;
  431. .el-card {
  432. width: calc(100% - 40px);
  433. height: calc(100% - 40px);
  434. margin: 20px;
  435. .alertDescCursor {
  436. cursor: pointer;
  437. transition: 0.2s;
  438. &:hover {
  439. color: var(--el-color-primary);
  440. text-decoration: underline;
  441. transition: 0.2s;
  442. }
  443. }
  444. }
  445. .confirmAllBtn {
  446. position: absolute;
  447. right: 20px;
  448. top: 20px;
  449. }
  450. }
  451. }
  452. </style>
  453. <style lang="scss">
  454. .alarmDialog {
  455. z-index: 1100 !important;
  456. }
  457. </style>