safecomponent.vue 13 KB

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