securityAlarmInfo.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. <template>
  2. <div class="securityAlarmInfo">
  3. <a-row style="height: 100%">
  4. <a-col :span="4" style="height: 800px">
  5. <security-device-select :tree-data="treeData"/>
  6. </a-col>
  7. <a-col :span="20" style="height: 100%;padding: 15px">
  8. <div class="securityAlarmInfo-query">
  9. <Query :show="['time']" :query-data.sync="formData" :search="search">
  10. <template #extraItem>
  11. <a-form-model-item label="告警类型">
  12. <a-select v-model="formData.type" defaultValue="" style="width: 150px">
  13. <a-select-option value="">全部</a-select-option>
  14. <a-select-option value="unline">设备离线</a-select-option>
  15. <a-select-option value="fumes">烟雾告警</a-select-option>
  16. <a-select-option value="fire">火焰告警</a-select-option>
  17. <a-select-option value="trespass">非法闯入</a-select-option>
  18. <a-select-option value="violation">违规行为</a-select-option>
  19. </a-select>
  20. </a-form-model-item>
  21. <a-form-model-item label="处理情况">
  22. <a-select v-model="formData.state" defaultValue="" style="width: 120px">
  23. <a-select-option value="">全部</a-select-option>
  24. <a-select-option value="1">已处理</a-select-option>
  25. <a-select-option value="0">待处理</a-select-option>
  26. </a-select>
  27. </a-form-model-item>
  28. </template>
  29. </Query>
  30. </div>
  31. <div class="securityAlarmInfo-list">
  32. <a-table :rowKey="(record, index) => index"
  33. :columns="columns"
  34. :data-source="tableData"
  35. >
  36. <template #level="text">
  37. <span v-if="text==1" style="color: #ffbf6b">一般告警</span>
  38. <span v-if="text==2" style="color: #d26e64">重要告警</span>
  39. <span v-if="text==3" style="color: #b83023">紧急告警</span>
  40. </template>
  41. <template #type="text">
  42. <span v-if="text=='fire'" style="color: #ffbf6b">火焰告警</span>
  43. <span v-if="text=='fumes'" style="color: #d26e64">烟雾告警</span>
  44. <span v-if="text=='unline'" style="color: #b83023">设备离线</span>
  45. <span v-if="text=='trespass'" style="color: #b83023">非法闯入</span>
  46. <span v-if="text=='violation'" style="color: #b83023">违规行为</span>
  47. </template>
  48. <template #operation="text, record">
  49. <a-button type="link" v-if="record.state!=1" @click="dealAlarm(record)">确认处理</a-button>
  50. <span v-if="record.state==1" style="color: #3CC2AC">已处理</span>
  51. <a-button type="link" @click="viewDetail(record)">查看详情</a-button>
  52. </template>
  53. </a-table>
  54. </div>
  55. </a-col>
  56. </a-row>
  57. <!--告警详情-->
  58. <a-modal class="securityPersonMoreDetail" v-if="showDetail"
  59. :visible="true"
  60. :width="800"
  61. :footer="null"
  62. @cancel="handleCancel"
  63. >
  64. <div>告警详情</div>
  65. <a-divider/>
  66. <div style="width: 100%;height: 100%">
  67. <div style="height: 250px;width: 100%">
  68. <img width="100%" height="100%"
  69. src="/test"/>
  70. </div>
  71. <div style="margin-top: 20px">
  72. <a-descriptions :column="3" size="small">
  73. <a-descriptions-item label="监控点">
  74. {{ currItem.area }}
  75. </a-descriptions-item>
  76. <a-descriptions-item label="告警区域">
  77. {{ currItem.source }}
  78. </a-descriptions-item>
  79. <a-descriptions-item label="告警类型">
  80. <span v-if="currItem.type=='fire'" style="color: #ffbf6b">火焰告警</span>
  81. <span v-if="currItem.type=='fumes'" style="color: #d26e64">烟雾告警</span>
  82. <span v-if="currItem.type=='unline'" style="color: #b83023">设备离线</span>
  83. <span v-if="currItem.type=='trespass'" style="color: #b83023">非法闯入</span>
  84. <span v-if="currItem.type=='violation'" style="color: #b83023">违规行为</span>
  85. </a-descriptions-item>
  86. <a-descriptions-item label="告警时间">
  87. {{ currItem.time }}
  88. </a-descriptions-item>
  89. <a-descriptions-item label="告警级别">
  90. <span v-if="currItem.level==1">一般告警</span>
  91. <span v-if="currItem.level==2">重要告警</span>
  92. <span v-if="currItem.level==3">紧急告警</span>
  93. </a-descriptions-item>
  94. <a-descriptions-item label="准确率">
  95. 98%
  96. </a-descriptions-item>
  97. </a-descriptions>
  98. </div>
  99. </div>
  100. </a-modal>
  101. </div>
  102. </template>
  103. <script>
  104. import SecurityDeviceSelect from "@/components/security/common/securityDeviceSelect.vue";
  105. import TimeRange from "@/components/common/timeRange.vue";
  106. import Query from "@/components/common/query.vue";
  107. import apiSecurityCamera from "@/api/security/apiSecurityCamera";
  108. import moment from "@/utils/moment_set";
  109. export default {
  110. data() {
  111. let range = this.$util.dateUtil.getNearlyMonthRange();
  112. return {
  113. showDetail: false,
  114. formData: {
  115. type: '',
  116. state: '',
  117. timeRange: range
  118. },
  119. treeData: [],
  120. currItem: {},
  121. oriTableData: [],
  122. tableData: [
  123. {
  124. time: '2023-05-16 08:43:01',
  125. area: '一层大厅',
  126. level: 2,
  127. source: '一层大厅东南角1号球机',
  128. type: 'trespass',
  129. state: 1,
  130. },
  131. {
  132. time: '2023-05-14 12:31:45',
  133. area: '一层大厅',
  134. level: 1,
  135. source: '一层大厅东南角1号球机',
  136. type: 'fumes',
  137. state: 1,
  138. },
  139. {
  140. time: '2023-05-07 15:44:11',
  141. area: '一层大厅',
  142. level: 2,
  143. source: '一层大厅东南角1号球机',
  144. type: 'trespass',
  145. state: 1,
  146. },
  147. ],
  148. columns: [
  149. {
  150. title: '告警时间',
  151. dataIndex: 'time',
  152. key: 'time'
  153. },
  154. {
  155. title: '告警区域',
  156. dataIndex: 'area',
  157. key: 'area'
  158. },
  159. {
  160. title: '告警级别',
  161. dataIndex: 'level',
  162. key: 'level',
  163. scopedSlots: {customRender: 'level'},
  164. },
  165. {
  166. title: '告警来源',
  167. dataIndex: 'source',
  168. key: 'source'
  169. },
  170. {
  171. title: '告警类型',
  172. dataIndex: 'type',
  173. key: 'type',
  174. scopedSlots: {customRender: 'type'},
  175. },
  176. {
  177. title: '操作',
  178. dataIndex: 'operation',
  179. key: 'operation',
  180. minWidth: 220,
  181. align: 'center',
  182. scopedSlots: {customRender: 'operation'},
  183. }
  184. ]
  185. }
  186. },
  187. components: {
  188. Query,
  189. SecurityDeviceSelect,
  190. TimeRange,
  191. },
  192. mounted() {
  193. this.getCameraList()
  194. },
  195. methods: {
  196. getCameraList() {
  197. let app = this;
  198. apiSecurityCamera.getCameraList().then(res => {
  199. res.forEach(item => {
  200. item.title = item.deviceName;
  201. item.key = item.deviceId;
  202. item.slots = {icon: 'camera',};
  203. })
  204. res.sort((a, b) => {
  205. if (a.title > b.title) {
  206. return 1
  207. } else {
  208. return -1
  209. }
  210. })
  211. this.treeData = res;
  212. app.genData();
  213. })
  214. },
  215. dealAlarm(val) {
  216. val.state = 1;
  217. this.$forceUpdate();
  218. },
  219. viewDetail(val) {
  220. this.showDetail = true;
  221. this.currItem = val
  222. },
  223. handleCancel() {
  224. this.showDetail = false
  225. },
  226. search() {
  227. this.tableData = this.oriTableData.filter(item=>{
  228. if (this.formData.type && this.formData.type!='' && item.type!=this.formData.type) {
  229. return false;
  230. }
  231. if (this.formData.state && this.formData.state!='' && item.state!=this.formData.state) {
  232. return false;
  233. }
  234. if (this.formData.timeRange && this.formData.timeRange.startDate && this.formData.timeRange.endDate) {
  235. let start = this.formData.timeRange.startDate;
  236. let end = this.formData.timeRange.endDate;
  237. let curr = this.$moment(item.time);
  238. let flag = curr.isSameOrAfter(start) && curr.isSameOrBefore(end);
  239. if (!flag) {
  240. return false
  241. }
  242. }
  243. return true;
  244. })
  245. },
  246. randomDate() {
  247. let startDate = this.$moment().startOf('month').toDate();
  248. let endDate = new Date();
  249. let date = new Date(+startDate + Math.random() * (endDate - startDate));
  250. let hour = 0 + Math.random() * (23 - 0) | 0;
  251. let minute = 0 + Math.random() * (59 - 0) | 0;
  252. let second = 0 + Math.random() * (59 - 0) | 0;
  253. date.setHours(hour);
  254. date.setMinutes(minute);
  255. date.setSeconds(second);
  256. return date;
  257. },
  258. randomCamera() {
  259. let index = Math.floor(Math.random() * this.treeData.length);
  260. return this.treeData[index].title;
  261. },
  262. genData() {
  263. this.tableData = [];
  264. for (let i = 0; i < 35; i++) {
  265. let deviceName = this.randomCamera();
  266. let time = this.$moment(this.randomDate()).format("YYYY/MM/DD HH:mm:ss")
  267. let obj = {
  268. time: time,
  269. area: 'B2',
  270. level: 1,
  271. source: deviceName,
  272. type: 'unline',
  273. state: 0,
  274. }
  275. this.tableData.push(obj);
  276. }
  277. this.tableData.sort((a, b) => {
  278. if (a.time > b.time) {
  279. return -1;
  280. }
  281. return 1;
  282. });
  283. this.oriTableData = JSON.parse(JSON.stringify(this.tableData))
  284. }
  285. }
  286. }
  287. </script>
  288. <style lang="less" scoped>
  289. .securityAlarmInfo {
  290. width: 100%;
  291. height: auto;
  292. padding: 15px;
  293. background-color: #ffffff;
  294. .securityAlarmInfo-list {
  295. margin: 15px 0px;
  296. }
  297. }
  298. </style>