safecomponent.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  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. </div>
  15. </div>
  16. </div>
  17. <el-table :data="alarmList" style="width: 100%" height="calc(100% - 51px)">
  18. <el-table-column
  19. prop="tsName"
  20. label="报警时间"
  21. width="150"
  22. show-overflow-tooltip
  23. />
  24. <el-table-column
  25. prop="lvName"
  26. label="报警等级"
  27. show-overflow-tooltip
  28. />
  29. <el-table-column
  30. prop="alarmName"
  31. label="报警类型"
  32. show-overflow-tooltip
  33. />
  34. <el-table-column
  35. prop="isCloseName"
  36. label="是否解除"
  37. show-overflow-tooltip
  38. />
  39. </el-table>
  40. <el-dialog
  41. v-model="showDialog"
  42. :title="title"
  43. top="50px"
  44. width="75%"
  45. modal-class="alarmDialog"
  46. :show-close="false"
  47. draggable
  48. @closed="
  49. () => {
  50. stopUpdate = false;
  51. }
  52. "
  53. >
  54. <el-card>
  55. <el-table
  56. :data="dialogTableData"
  57. style="width: 100%"
  58. height="420px"
  59. border
  60. >
  61. <el-table-column
  62. prop="tsName"
  63. label="报警时间"
  64. width="150"
  65. show-overflow-tooltip
  66. />
  67. <el-table-column
  68. prop="code"
  69. label="报警设备"
  70. show-overflow-tooltip
  71. />
  72. <el-table-column
  73. prop="alarmName"
  74. label="报警类型"
  75. show-overflow-tooltip
  76. />
  77. <el-table-column
  78. prop="characteristic"
  79. label="报警特征"
  80. show-overflow-tooltip
  81. />
  82. <el-table-column
  83. prop="isCloseName"
  84. label="报警是否解除"
  85. show-overflow-tooltip
  86. />
  87. <el-table-column
  88. prop="faultCause"
  89. label="报警故障原因"
  90. show-overflow-tooltip
  91. />
  92. <el-table-column
  93. prop="resolvent"
  94. label="报警解决方法"
  95. show-overflow-tooltip
  96. />
  97. <el-table-column label="操作">
  98. <template #default="scope">
  99. <el-button type="text" size="small" @click="confirm(scope.row)"
  100. >确认本条</el-button
  101. >
  102. </template>
  103. </el-table-column>
  104. </el-table>
  105. </el-card>
  106. <el-button class="confirmAllBtn" type="info" plain @click="confirmAll"
  107. >确认所有报警</el-button
  108. >
  109. </el-dialog>
  110. </div>
  111. </template>
  112. <script>
  113. export default {
  114. props: {
  115. title: {
  116. type: String,
  117. default: () => {
  118. return "";
  119. },
  120. },
  121. deviceType: {
  122. type: String,
  123. default: () => {
  124. return "";
  125. },
  126. },
  127. alarmType: {
  128. type: String,
  129. default: () => {
  130. return "";
  131. },
  132. },
  133. },
  134. data() {
  135. return {
  136. alarmList: [],
  137. iconfontsObj: {
  138. booststation: "iconIOTtubiao_huabanfuben",
  139. windturbine: "iconfengji",
  140. custom: "iconzidingyi",
  141. inverter: "iconzidingyi",
  142. },
  143. showDialog: false,
  144. dialogTableData: [],
  145. fullTableData: [],
  146. stopUpdate: false,
  147. };
  148. },
  149. created() {
  150. this.initWarningList();
  151. },
  152. methods: {
  153. iconfonts() {
  154. return this.iconfontsObj[this.deviceType];
  155. },
  156. initWarningList() {
  157. let alarmList = [];
  158. let fullTableData = [];
  159. let dialogTableData = [];
  160. this.$store.state.warningList.forEach((ele) => {
  161. if (
  162. this.deviceType === ele.deviceType &&
  163. this.alarmType === ele.alarmType
  164. ) {
  165. alarmList?.length < this.$store.state.warningListLimitLength &&
  166. alarmList.push(ele);
  167. dialogTableData?.length < 50 && dialogTableData.push(ele);
  168. fullTableData.push(ele);
  169. }
  170. });
  171. alarmList.sort((a, b) => {
  172. return b.ts - a.ts;
  173. });
  174. dialogTableData.sort((a, b) => {
  175. return b.ts - a.ts;
  176. });
  177. fullTableData.sort((a, b) => {
  178. return b.ts - a.ts;
  179. });
  180. this.alarmList = alarmList;
  181. if (!this.stopUpdate) {
  182. this.dialogTableData = dialogTableData;
  183. }
  184. this.fullTableData = fullTableData;
  185. },
  186. clickAlarmItem() {
  187. this.showDialog = true;
  188. },
  189. confirm(alarmItem) {
  190. this.stopUpdate = true;
  191. this.$confirm("您确定要执行此操作吗?", "提示", {
  192. confirmButtonText: "确定",
  193. cancelButtonText: "取消",
  194. type: "warning",
  195. })
  196. .then(() => {
  197. confirmAlart([alarmItem]).then((res) => {
  198. if (res.code === 200) {
  199. this.BASE.showMsg({
  200. type: "success",
  201. msg: `${this.title}确认成功`,
  202. });
  203. this.$store.commit("removeWarning", alarmItem);
  204. this.playAudioEffect();
  205. }
  206. this.stopUpdate = false;
  207. });
  208. })
  209. .catch(() => {
  210. this.stopUpdate = false;
  211. });
  212. },
  213. confirmAll() {
  214. this.stopUpdate = true;
  215. this.$confirm("您确定要执行此操作吗?", "提示", {
  216. confirmButtonText: "确定",
  217. cancelButtonText: "取消",
  218. type: "warning",
  219. })
  220. .then(() => {
  221. confirmAlart(this.dialogTableData).then((res) => {
  222. if (res.code === 200) {
  223. this.BASE.showMsg({
  224. type: "success",
  225. msg: `全部${this.title}确认成功`,
  226. });
  227. this.$store.commit("removeWarning", this.dialogTableData);
  228. this.playAudioEffect();
  229. }
  230. this.stopUpdate = false;
  231. });
  232. })
  233. .catch(() => {
  234. this.stopUpdate = false;
  235. });
  236. },
  237. },
  238. watch: {
  239. "$store.state.warningList.length"() {
  240. this.initWarningList();
  241. },
  242. },
  243. };
  244. </script>
  245. <style lang="scss" scoped>
  246. .safeCom {
  247. width: 100%;
  248. height: calc(100% - 20px);
  249. cursor: pointer;
  250. .safeCom_head {
  251. height: 50px;
  252. display: flex;
  253. align-items: center;
  254. border-bottom: 1.5px solid rgb(221, 221, 221);
  255. .safeCom_title {
  256. font-size: 24px;
  257. text-align: center;
  258. }
  259. .safeCom_fifter {
  260. flex: 1;
  261. }
  262. }
  263. }
  264. .currentAlartDialogHeader {
  265. display: flex;
  266. justify-content: space-between;
  267. align-items: center;
  268. }
  269. </style>
  270. <style lang="scss">
  271. .alarmDialog {
  272. .el-dialog__body {
  273. height: 500px;
  274. max-height: 500px;
  275. padding: 0;
  276. overflow: hidden;
  277. .el-card {
  278. width: calc(100% - 40px);
  279. height: calc(100% - 40px);
  280. margin: 20px;
  281. }
  282. .confirmAllBtn {
  283. position: absolute;
  284. right: 20px;
  285. top: 20px;
  286. }
  287. }
  288. }
  289. </style>
  290. <style lang="scss" >
  291. .alarmDialog {
  292. z-index: 5100 !important;
  293. }
  294. </style>