提交 | 用户 | 时间
|
aed8e1
|
1 |
<template> |
H |
2 |
<el-dialog v-model="dialogVisible" :title="dialogTitle" :close="handleClose" |
|
3 |
style="width: 50%; margin-top: 20px; overflow: auto; z-index: 1"> |
|
4 |
<!-- 列表 --> |
|
5 |
<el-table v-loading="loading" :data="list"> |
|
6 |
<el-table-column |
|
7 |
label="截图时间" |
|
8 |
align="center" |
|
9 |
prop="createDate" |
|
10 |
:formatter="dateFormatter" |
|
11 |
width="200" |
|
12 |
/> |
|
13 |
<el-table-column label="图片路径" align="center" prop="imagePath" width="500" |
|
14 |
:show-overflow-tooltip="true"/> |
|
15 |
<el-table-column label="图片预览" align="center" prop="imageUrl"> |
|
16 |
<template #default="scope"> |
|
17 |
<el-image style="height: 50px; z-index: 1" |
|
18 |
:src="getPreviewUrl(scope.row.imageUrl)" |
|
19 |
:preview-src-list="getPreviewSrcList(scope.row.imageUrl)" fit="cover" |
|
20 |
preview-teleported/> |
|
21 |
</template> |
|
22 |
</el-table-column> |
|
23 |
<el-table-column label="操作" align="center" min-width="60" fixed="right"> |
|
24 |
<template #default="scope"> |
|
25 |
<el-button |
|
26 |
link |
|
27 |
type="danger" |
|
28 |
style="z-index: 1" |
|
29 |
@click="handleDelete(scope.row.id)" |
|
30 |
v-hasPermi="['video:camera:delete']" |
|
31 |
> |
|
32 |
删除 |
|
33 |
</el-button> |
|
34 |
</template> |
|
35 |
</el-table-column> |
|
36 |
</el-table> |
|
37 |
<!-- 分页 --> |
|
38 |
<Pagination |
|
39 |
:total="total" |
|
40 |
v-model:page="queryParams.pageNo" |
|
41 |
v-model:limit="queryParams.pageSize" |
|
42 |
@pagination="open" |
|
43 |
/> |
|
44 |
</el-dialog> |
|
45 |
</template> |
|
46 |
<script lang="ts" setup> |
|
47 |
import * as ImageApi from '@/api/data/video/image' |
|
48 |
import {getPreviewUrl} from "@/api/data/video/image"; |
|
49 |
import {dateFormatter} from "@/utils/formatTime"; |
|
50 |
|
|
51 |
defineOptions({name: 'CameraImage'}) |
|
52 |
|
|
53 |
const message = useMessage() // 消息弹窗 |
|
54 |
const {t} = useI18n() // 国际化 |
|
55 |
const dialogTitle = ref('截图列表') |
|
56 |
const loading = ref(true) // 列表的加载中 |
|
57 |
const total = ref(0) // 列表的总页数 |
|
58 |
const list = ref([]) // 列表的数据 |
|
59 |
const queryParams = reactive({ |
|
60 |
pageNo: 1, |
|
61 |
pageSize: 10, |
|
62 |
id: undefined, |
|
63 |
brand: undefined, |
|
64 |
code: undefined, |
|
65 |
device: undefined, |
|
66 |
cameraId: '', |
|
67 |
imagePath: undefined, |
|
68 |
imageUrl: undefined, |
|
69 |
createDate: undefined, |
|
70 |
}) |
|
71 |
const cameraId = ref('') |
|
72 |
const dialogVisible = ref(false) |
|
73 |
|
|
74 |
/** 查询列表 */ |
|
75 |
const open = async (camera_id: string) => { |
|
76 |
dialogVisible.value = true |
|
77 |
cameraId.value = camera_id |
|
78 |
queryParams.cameraId = camera_id |
|
79 |
loading.value = true |
|
80 |
try { |
|
81 |
const data = await ImageApi.getImagePage(queryParams) |
|
82 |
list.value = data.list |
|
83 |
total.value = data.total |
|
84 |
} finally { |
|
85 |
loading.value = false |
|
86 |
} |
|
87 |
} |
|
88 |
|
|
89 |
defineExpose({open}) // 提供 open 方法,用于打开弹窗 |
|
90 |
|
|
91 |
const handleClose = async () => { |
|
92 |
dialogVisible.value = false |
|
93 |
} |
|
94 |
|
|
95 |
const getPreviewSrcList = (imageUrl: string) => { |
|
96 |
let previewSrcList: string[] = [] |
|
97 |
previewSrcList.push(getPreviewUrl(imageUrl)) |
|
98 |
return previewSrcList |
|
99 |
} |
|
100 |
|
|
101 |
/** 删除按钮操作 */ |
|
102 |
const handleDelete = async (id: number) => { |
|
103 |
try { |
|
104 |
// 删除的二次确认 |
|
105 |
await message.delConfirm() |
|
106 |
// 发起删除 |
|
107 |
await ImageApi.deleteImage(id) |
|
108 |
message.success(t('common.delSuccess')) |
|
109 |
// 刷新列表 |
|
110 |
await open(cameraId.value) |
|
111 |
} catch { |
|
112 |
} |
|
113 |
} |
|
114 |
</script> |