safecomponent.vue 13 KB

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