safecomponent.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470
  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="center"
  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="center">
  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="center"
  145. show-overflow-tooltip
  146. />
  147. <el-table-column
  148. prop=""
  149. label="报警解除时间"
  150. align="center"
  151. width="220"
  152. show-overflow-tooltip
  153. >
  154. <template #default="scope">
  155. <span>{{ scope.row.endts || scope.row.closeTime }}</span>
  156. </template>
  157. </el-table-column>
  158. <!-- <el-table-column
  159. prop="resolvent"
  160. label="报警解决方法"
  161. show-overflow-tooltip
  162. /> -->
  163. <!-- <el-table-column label="级别" width="100" show-overflow-tooltip>
  164. <template #default="scope">
  165. <el-tag
  166. class="ml-2"
  167. :type="
  168. scope.row.lv === 5
  169. ? 'danger'
  170. : scope.row.lv === 4
  171. ? 'warning'
  172. : 'info'
  173. "
  174. >{{ scope.row.lvName }}</el-tag
  175. >
  176. </template>
  177. </el-table-column> -->
  178. <el-table-column
  179. label="报警是否解除"
  180. width="120"
  181. align="center"
  182. show-overflow-tooltip
  183. >
  184. <template #default="scope">
  185. <span
  186. :style="`color:${
  187. scope.row.isClose
  188. ? 'var(--el-color-success)'
  189. : 'var(--el-color-danger)'
  190. }`"
  191. >{{ scope.row.isClose ? "已解除" : "未解除" }}</span
  192. >
  193. </template>
  194. </el-table-column>
  195. <el-table-column label="操作" width="100" align="center">
  196. <template #default="scope">
  197. <el-button
  198. type="text"
  199. style="color: #05bb4c"
  200. size="small"
  201. @click="confirm(scope.row)"
  202. >确认本条</el-button
  203. >
  204. </template>
  205. </el-table-column>
  206. </el-table>
  207. </el-card>
  208. <template #footer>
  209. <el-button
  210. type="info"
  211. plain
  212. @click="confirmAll"
  213. :disabled="!dialogTableData.length"
  214. >确认所有报警</el-button
  215. >
  216. </template>
  217. </el-dialog>
  218. </div>
  219. </template>
  220. <script>
  221. import { confirmAlart } from "@/api/zhbj/index.js";
  222. export default {
  223. props: {
  224. title: {
  225. type: String,
  226. default: () => {
  227. return "";
  228. },
  229. },
  230. deviceType: {
  231. type: String,
  232. default: () => {
  233. return "";
  234. },
  235. },
  236. alarmType: {
  237. type: String,
  238. default: () => {
  239. return "";
  240. },
  241. },
  242. },
  243. data() {
  244. return {
  245. alarmList: [],
  246. iconfontsObj: {
  247. booststation: "iconIOTtubiao_huabanfuben",
  248. windturbine: "iconfengji",
  249. custom: "iconzidingyi",
  250. inverter: "iconzidingyi",
  251. },
  252. showDialog: false,
  253. dialogTableData: [],
  254. fullTableData: [],
  255. stopUpdate: false,
  256. };
  257. },
  258. created() {
  259. this.initWarningList();
  260. },
  261. methods: {
  262. iconfonts() {
  263. return this.iconfontsObj[this.deviceType];
  264. },
  265. initWarningList() {
  266. let alarmList = [];
  267. // let fullTableData = [];
  268. let dialogTableData = [];
  269. this.$store.state.warningList.forEach((ele) => {
  270. if (
  271. this.deviceType === ele.deviceType &&
  272. this.alarmType === ele.alarmType
  273. ) {
  274. alarmList?.length < this.$store.state.warningListLimitLength &&
  275. alarmList.push(ele);
  276. dialogTableData?.length < 50 && dialogTableData.push(ele);
  277. // fullTableData.push(ele);
  278. }
  279. });
  280. alarmList.sort((a, b) => {
  281. return b.ts - a.ts;
  282. });
  283. dialogTableData.sort((a, b) => {
  284. return b.ts - a.ts;
  285. });
  286. // fullTableData.sort((a, b) => {
  287. // return b.ts - a.ts;
  288. // });
  289. this.alarmList = alarmList;
  290. if (!this.stopUpdate) {
  291. this.dialogTableData = dialogTableData;
  292. }
  293. // this.fullTableData = fullTableData;
  294. },
  295. clickAlarmItem() {
  296. this.showDialog = true;
  297. },
  298. confirm(alarmItem) {
  299. this.stopUpdate = true;
  300. this.$confirm("您确定要执行此操作吗?", "提示", {
  301. confirmButtonText: "确定",
  302. cancelButtonText: "取消",
  303. type: "warning",
  304. })
  305. .then(() => {
  306. confirmAlart([alarmItem])
  307. .then((res) => {
  308. if (res.code === 200) {
  309. this.BASE.showMsg({
  310. type: "success",
  311. msg: `${this.title}确认成功`,
  312. });
  313. this.$store.commit("removeWarningList", alarmItem);
  314. }
  315. this.stopUpdate = false;
  316. })
  317. .catch(() => {
  318. this.BASE.showMsg({
  319. msg: "确认失败,请重试",
  320. });
  321. });
  322. })
  323. .catch(() => {
  324. this.stopUpdate = false;
  325. });
  326. },
  327. confirmAll() {
  328. this.stopUpdate = true;
  329. this.$confirm("您确定要执行此操作吗?", "提示", {
  330. confirmButtonText: "确定",
  331. cancelButtonText: "取消",
  332. type: "warning",
  333. })
  334. .then(() => {
  335. confirmAlart(this.dialogTableData)
  336. .then((res) => {
  337. if (res.code === 200) {
  338. this.BASE.showMsg({
  339. type: "success",
  340. msg: `全部${this.title}确认成功`,
  341. });
  342. this.$store.commit("removeWarningList", this.dialogTableData);
  343. }
  344. this.stopUpdate = false;
  345. })
  346. .catch(() => {
  347. this.BASE.showMsg({
  348. msg: "确认失败,请重试",
  349. });
  350. });
  351. })
  352. .catch(() => {
  353. this.stopUpdate = false;
  354. });
  355. },
  356. goToAlertDescPage(alertItem) {
  357. if (this.alarmType == "custom") {
  358. this.$router.push({
  359. path: "/integratedAlarm/safe/customWarning",
  360. query: {
  361. deviceId: alertItem.deviceId,
  362. alarmId: alertItem.alarmId,
  363. modelId: alertItem.modelId,
  364. },
  365. });
  366. } else if (this.alarmType == "booststation") {
  367. this.$router.push({
  368. path: "/integratedAlarm/safe/historyWarning",
  369. query: {
  370. deviceId: alertItem.wpName,
  371. alarmId: alertItem.alarmId,
  372. deviceType: this.deviceType,
  373. },
  374. });
  375. } else {
  376. this.$router.push({
  377. path: "/integratedAlarm/safe/historyWarning",
  378. query: {
  379. deviceId: alertItem.deviceId,
  380. alarmId: alertItem.alarmId,
  381. deviceType: this.deviceType,
  382. modelId: alertItem.modelId,
  383. },
  384. });
  385. }
  386. },
  387. },
  388. watch: {
  389. "$store.state.warningList.length"() {
  390. this.initWarningList();
  391. },
  392. },
  393. };
  394. </script>
  395. <style lang="less" scoped>
  396. .safeCom {
  397. width: 100%;
  398. height: calc(100% - 20px);
  399. cursor: pointer;
  400. .safeCom_head {
  401. height: 50px;
  402. display: flex;
  403. align-items: center;
  404. border-bottom: 1.5px solid rgb(221, 221, 221);
  405. .safeCom_title {
  406. font-size: 24px;
  407. text-align: center;
  408. }
  409. .safeCom_fifter {
  410. flex: 1;
  411. }
  412. }
  413. }
  414. .currentAlartDialogHeader {
  415. display: flex;
  416. justify-content: space-between;
  417. align-items: center;
  418. }
  419. </style>
  420. <style lang="scss">
  421. .alarmDialog {
  422. .el-dialog__body {
  423. height: 700px;
  424. max-height: 700ox;
  425. padding: 0;
  426. overflow: hidden;
  427. .el-card {
  428. width: calc(100% - 40px);
  429. height: calc(100% - 40px);
  430. margin: 20px;
  431. .alertDescCursor {
  432. cursor: pointer;
  433. transition: 0.2s;
  434. &:hover {
  435. color: var(--el-color-primary);
  436. text-decoration: underline;
  437. transition: 0.2s;
  438. }
  439. }
  440. }
  441. .confirmAllBtn {
  442. position: absolute;
  443. right: 20px;
  444. top: 20px;
  445. }
  446. }
  447. }
  448. </style>
  449. <style lang="scss">
  450. .alarmDialog {
  451. z-index: 1100 !important;
  452. }
  453. </style>