alarm-all.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  1. <template>
  2. <div class="alarm-all">
  3. <a-grid :cols="4" :col-gap="20" :row-gap="16" class="grid-demo-grid">
  4. <a-grid-item class="demo-item">
  5. <label>{{ $t('previewList.bjlx') }}</label>
  6. <a-select
  7. v-model="paramObj.AlertType"
  8. allow-clear
  9. :style="{ width: '320px' }"
  10. :placeholder="$t('previewList.qxz')"
  11. >
  12. <a-option
  13. v-for="item in typeAlarmOptions"
  14. :key="item.value"
  15. :value="item.value"
  16. >{{ item.label }}</a-option
  17. >
  18. </a-select>
  19. </a-grid-item>
  20. <a-grid-item class="demo-item">
  21. <label>{{ $t('previewList.bjsj') }}</label>
  22. <a-range-picker
  23. show-time
  24. :time-picker-props="{ defaultValue: ['00:00:00', '00:00:00'] }"
  25. format="YYYY-MM-DD HH:mm:ss"
  26. @ok="onOk"
  27. />
  28. </a-grid-item>
  29. <a-grid-item class="demo-item">
  30. <label>{{ $t('previewList.bjgd') }}</label>
  31. <a-select
  32. v-model="paramObj.Archived"
  33. allow-clear
  34. :style="{ width: '320px' }"
  35. :placeholder="$t('previewList.qxz')"
  36. >
  37. <a-option
  38. v-for="item in alarmArchivingOptions"
  39. :key="item.value"
  40. :value="item.value"
  41. >{{ item.label }}</a-option
  42. >
  43. </a-select>
  44. </a-grid-item>
  45. <a-grid-item class="demo-item">
  46. <a-radio-group
  47. type="button"
  48. :model-value="radioActive"
  49. @change="(v) => (radioActive = v)"
  50. >
  51. <a-radio value="bg">{{ $t('previewList.bg') }}</a-radio>
  52. <a-radio value="gg">{{ $t('previewList.gg') }}</a-radio>
  53. </a-radio-group>
  54. <a-button type="primary" size="small" @click="searchBtn">{{
  55. $t('previewList.cx')
  56. }}</a-button>
  57. </a-grid-item>
  58. </a-grid>
  59. <template v-if="radioActive === 'bg'">
  60. <a-table
  61. :data="alarmData"
  62. :scroll="{ y: '100%' }"
  63. :pagination="false"
  64. :bordered="{ cell: true }"
  65. :loading="loading"
  66. style="height: calc(100% - 114px)"
  67. >
  68. <template #columns>
  69. <a-table-column
  70. :title="$t('previewList.bjlx')"
  71. :ellipsis="true"
  72. :tooltip="true"
  73. data-index="type"
  74. >
  75. </a-table-column>
  76. <a-table-column
  77. :title="$t('previewList.bjsj')"
  78. data-index="timeN"
  79. :width="180"
  80. ></a-table-column>
  81. <a-table-column
  82. :title="$t('previewList.status')"
  83. data-index="status"
  84. :width="150"
  85. :body-cell-style="
  86. (record) => ({
  87. background: record.status ? '#4cd26380' : '#7e2d2d80',
  88. })
  89. "
  90. >
  91. <template #cell="{ record }">
  92. <span>{{
  93. record.status ? $t('previewList.ycl') : $t('previewList.wcl')
  94. }}</span>
  95. </template>
  96. </a-table-column>
  97. <a-table-column
  98. :title="$t('previewList.bjgd')"
  99. data-index="AlarmArchiving"
  100. :width="150"
  101. :body-cell-style="
  102. (record) => ({
  103. background:
  104. record.AlarmArchiving == '0'
  105. ? '#ffb65d80'
  106. : record.AlarmArchiving == '1'
  107. ? '#4cd26380'
  108. : '#7e2d2d80',
  109. })
  110. "
  111. >
  112. <template #cell="{ record }">
  113. <span>{{
  114. record.AlarmArchiving == '0'
  115. ? '未归档'
  116. : record.AlarmArchiving == '1'
  117. ? '正确报警'
  118. : '错误报警'
  119. }}</span>
  120. </template>
  121. </a-table-column>
  122. <!-- <a-table-column
  123. :title="$t('previewList.dqstatus')"
  124. data-index="isRead"
  125. :width="150"
  126. :body-cell-style="
  127. (record) => ({
  128. background: record.isRead ? '' : '#2d4f7e',
  129. })
  130. "
  131. >
  132. <template #cell="{ record }">
  133. <span>{{
  134. record.isRead ? $t('previewList.yd') : $t('previewList.wd')
  135. }}</span>
  136. </template>
  137. </a-table-column> -->
  138. <a-table-column :title="$t('previewList.cz')" :width="150">
  139. <template #cell="{ record }">
  140. <a-button type="text" size="mini" @click="showView(record)">{{
  141. $t('previewList.ck')
  142. }}</a-button>
  143. </template>
  144. </a-table-column>
  145. </template>
  146. </a-table>
  147. </template>
  148. <template v-else>
  149. <a-scrollbar>
  150. <ul class="img-list">
  151. <li
  152. v-for="(item, i) in alarmImgData"
  153. :key="i"
  154. class="img-list-item"
  155. @click="showView(item)"
  156. >
  157. <a-spin v-if="item.imgLoading" dot />
  158. <img :src="item.tImg" @load="() => (item.imgLoading = false)" />
  159. </li>
  160. </ul>
  161. <a-empty v-if="!alarmImgData.length" />
  162. </a-scrollbar>
  163. </template>
  164. <div class="pagination">
  165. <a-pagination
  166. :total="total"
  167. show-total
  168. show-jumper
  169. show-page-size
  170. @change="pageChange"
  171. @page-size-change="pageSizeChange"
  172. />
  173. </div>
  174. <ViewDrawer
  175. ref="viewDrawerRef"
  176. :view-data="viewData"
  177. :guid="guid"
  178. :is-show-cl="true"
  179. @update:view-data="(v) => Object.assign(viewData, v)"
  180. />
  181. </div>
  182. </template>
  183. <script setup lang="ts">
  184. // import dayjs from 'dayjs';
  185. import { useAppStore } from '@/store';
  186. import { ref, reactive, onMounted, provide } from 'vue';
  187. import {
  188. getAlarmImgFiles,
  189. getAlarmLog,
  190. getAlgorithmList,
  191. } from '@/api/system';
  192. import ViewDrawer from './view-drawer.vue';
  193. interface AlarmData {
  194. [key: string]: number | string | boolean;
  195. }
  196. const app = useAppStore();
  197. const props = defineProps<{
  198. guid?: string;
  199. }>();
  200. const viewDrawerRef = ref();
  201. const radioActive = ref<any>('bg');
  202. const paramObj = reactive<{
  203. PageNum: number;
  204. PageSize: number;
  205. AlertType: string;
  206. Archived: string;
  207. StartDate: string | number;
  208. EndDate: string | number;
  209. }>({
  210. PageNum: 1,
  211. PageSize: 10,
  212. AlertType: '',
  213. Archived: '',
  214. StartDate: '',
  215. EndDate: '',
  216. });
  217. const loading = ref(false);
  218. const total = ref(0);
  219. const typeAlarmOptions = ref<any[]>([]);
  220. const alarmArchivingOptions = ref<any[]>([
  221. {
  222. label: '未归档',
  223. value: '0',
  224. },
  225. {
  226. label: '正确报警',
  227. value: '1',
  228. },
  229. {
  230. label: '错误报警',
  231. value: '2',
  232. },
  233. ]);
  234. const viewData = ref<AlarmData>({});
  235. provide('viewData', viewData);
  236. const alarmData = ref<AlarmData[]>([
  237. // {
  238. // type: '行人闯入',
  239. // timeN: dayjs().format('YYYY-MM-DD HH:mm:ss'),
  240. // status: 0,
  241. // isRead: false,
  242. // },
  243. ]);
  244. const alarmImgData = ref<any[]>([
  245. // {
  246. // url: 'https://p1-arco.byteimg.com/tos-cn-i-uwbnlip3yd/a8c8cdb109cb051163646151a4a5083b.png~tplv-uwbnlip3yd-webp.webp',
  247. // time: dayjs().format('YYYY-MM-DD HH:mm:ss'),
  248. // },
  249. ]);
  250. const getList = async () => {
  251. loading.value = true;
  252. alarmImgData.value = [];
  253. try {
  254. const alarmLog = await getAlarmLog(paramObj, { GUID: props.guid });
  255. total.value = alarmLog.data.TotalCount;
  256. const jsonPromises = alarmLog.data.AlarmList.map((v: any) =>
  257. getAlarmImgFiles(v.JsonFile, { GUID: props.guid })
  258. );
  259. Promise.all(jsonPromises)
  260. .then((results) => {
  261. alarmData.value = alarmLog.data.AlarmList.map(
  262. (item: any, i: number) => {
  263. return {
  264. ...item,
  265. type: item.Name,
  266. timeN: item.CreatedAt,
  267. status: +item.HandleStatus,
  268. isRead: false,
  269. img: `${app.ip}/rpc/rabbitMQ/KunPengYun/Files/${item.OriginPicture}&GUID=${props.guid}`,
  270. tImg: `${app.ip}/rpc/rabbitMQ/KunPengYun/Files/${item.Thumbnail}&GUID=${props.guid}`,
  271. imgJson: results[i],
  272. imgLoading: true,
  273. AlarmArchiving: `${item.Archived}`,
  274. };
  275. }
  276. );
  277. alarmImgData.value = alarmData.value;
  278. loading.value = false;
  279. })
  280. .catch(() => {
  281. loading.value = false;
  282. });
  283. } catch (e) {
  284. loading.value = false;
  285. }
  286. };
  287. const onOk = (value: any[], date: any[], dateString: any[]) => {
  288. paramObj.StartDate = new Date(dateString[0]).getTime() / 1000;
  289. paramObj.EndDate = new Date(dateString[1]).getTime() / 1000;
  290. };
  291. const pageChange = (current: number) => {
  292. paramObj.PageNum = current;
  293. getList();
  294. };
  295. const pageSizeChange = (pageSize: number) => {
  296. paramObj.PageSize = pageSize;
  297. getList();
  298. };
  299. const showView = (record: any) => {
  300. viewData.value = record;
  301. viewDrawerRef.value.open();
  302. };
  303. const searchBtn = () => {
  304. getList();
  305. };
  306. onMounted(async () => {
  307. const algorithmList = await getAlgorithmList({}, { GUID: props.guid });
  308. // eslint-disable-next-line no-restricted-syntax, guard-for-in
  309. for (const key in algorithmList.data) {
  310. typeAlarmOptions.value.push({
  311. label: algorithmList.data[key],
  312. value: key,
  313. });
  314. }
  315. getList();
  316. });
  317. </script>
  318. <style lang="less" scoped>
  319. .alarm-all {
  320. display: flex;
  321. flex-direction: column;
  322. height: 100%;
  323. gap: 15px;
  324. .pagination {
  325. display: flex;
  326. justify-content: flex-end;
  327. }
  328. .demo-item {
  329. display: flex;
  330. align-items: center;
  331. gap: 10px;
  332. & > label {
  333. min-width: 65px;
  334. }
  335. &:last-child {
  336. justify-content: flex-end;
  337. }
  338. }
  339. .arco-scrollbar {
  340. height: calc(100% - 114px);
  341. :deep(.arco-scrollbar-container) {
  342. height: 100%;
  343. overflow-y: auto;
  344. }
  345. }
  346. .img-list {
  347. display: grid;
  348. grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  349. grid-template-rows: repeat(auto-fill, 135px);
  350. gap: 15px;
  351. .img-list-item {
  352. width: 100%;
  353. height: 135px;
  354. overflow: hidden;
  355. background-color: #333;
  356. cursor: pointer;
  357. position: relative;
  358. .arco-spin {
  359. position: absolute;
  360. top: 50%;
  361. left: 50%;
  362. transform: translate(-50%, -50%);
  363. }
  364. img {
  365. height: 100%;
  366. width: 100%;
  367. object-fit: cover;
  368. }
  369. }
  370. }
  371. }
  372. </style>