潘志宝
2024-11-22 df90c0c5cfa4de114798015b92120ad8ba8b4826
提交 | 用户 | 时间
30566d 1 <template>
H 2   <!-- 搜索 -->
3   <el-drawer
4     direction="rtl"
5     v-model="visible"
6     @close="handleClose"
7     size="60%">
8     <div class="mod-dev__camera" style="padding: 10px;">
aed8e1 9       <el-form
H 10         class="-mb-15px"
11         :model="queryParams"
12         ref="queryFormRef"
13         :inline="true"
14         label-width="68px"
15       >
16         <el-form-item label="监控区域" prop="code">
17           <el-input
18             v-model="queryParams.location"
19             placeholder="请输入监控区域"
20             clearable
21             @keyup.enter="handleQuery"
22             class="!w-240px"
23           />
24         </el-form-item>
25         <el-form-item>
26           <el-button @click="handleQuery">
27             <Icon icon="ep:search" class="mr-5px"/>
28             搜索
29           </el-button>
30           <el-button @click="resetQuery">
31             <Icon icon="ep:refresh" class="mr-5px"/>
32             重置
33           </el-button>
30566d 34           <el-button
H 35             type="primary"
aed8e1 36             plain
H 37             @click="openForm('create')"
30566d 38           >
aed8e1 39             <Icon icon="ep:plus" class="mr-5px"/>
H 40             新增
30566d 41           </el-button>
H 42           <el-button
aed8e1 43             type="success"
H 44             plain
45             @click="handleExport"
46             :loading="exportLoading"
47             v-hasPermi="['dev:camera:export']"
30566d 48           >
aed8e1 49             <Icon icon="ep:download" class="mr-5px"/>
H 50             导出
30566d 51           </el-button>
aed8e1 52         </el-form-item>
H 53       </el-form>
54
55       <!-- 列表 -->
56       <el-table v-loading="loading" :data="list">
57         <el-table-column label="编码" align="center" prop="code" width="80"/>
58         <el-table-column label="抓图方式" align="center" prop="captureType" width="80">
59           <template #default="scope">
60             <dict-tag :type="DICT_TYPE.CAPTURE_TYPE" :value="scope.row.captureType"/>
61           </template>
62         </el-table-column>
63         <el-table-column label="通道" align="center" prop="channel" width="80"/>
64         <el-table-column label="监控区域" align="center" prop="location"/>
65         <el-table-column label="备注" align="center" prop="remark" width="200"/>
66         <el-table-column label="操作" align="center" min-width="110" fixed="right">
67           <template #default="scope">
68             <el-button
69               link
70               type="primary"
71               @click="openForm('update', scope.row.id)"
72             >
73               编辑
74             </el-button>
75             <el-button
76               link
77               type="danger"
78               @click="handleDelete(scope.row.id)"
79             >
80               删除
81             </el-button>
82             <el-button
83               link
84               type="success"
85               @click="imageHandle(scope.row.id)"
86               v-hasPermi="['video:image:query']"
87             >
88               查看截图
89             </el-button>
90           </template>
91         </el-table-column>
92       </el-table>
93       <!-- 分页 -->
94       <Pagination
95         :total="total"
96         v-model:page="queryParams.pageNo"
97         v-model:limit="queryParams.pageSize"
98         @pagination="getList"
99       />
30566d 100     </div>
H 101   </el-drawer>
102
103   <!-- 表单弹窗:添加/修改 -->
aed8e1 104   <NvrCameraForm ref="formRef" @success="getList"/>
30566d 105
aed8e1 106   <CameraImage ref="imageFormRef"/>
30566d 107
H 108 </template>
109 <script lang="ts" setup>
110 import download from '@/utils/download'
1ae890 111 import * as CameraApi from '@/api/data/video/camera'
H 112 import NvrCameraForm from './NvrCameraForm.vue'
c3e84e 113 import {DICT_TYPE} from "@/utils/dict";
aed8e1 114 import CameraImage from "../camera/CameraImage.vue";
30566d 115
1ae890 116 defineOptions({name: 'NvrCamera'})
30566d 117
H 118 const message = useMessage() // 消息弹窗
119 const {t} = useI18n() // 国际化
120
121 const loading = ref(true) // 列表的加载中
122 const total = ref(0) // 列表的总页数
123 const list = ref([]) // 列表的数据
124
125 const nvrId = ref('') //录像机id
126
127 const queryParams = reactive({
128   pageNo: 1,
129   pageSize: 10,
130   nvrId: '',
131   location: undefined,
132   status: undefined
133 })
134 const queryFormRef = ref() // 搜索的表单
135 const exportLoading = ref(false) // 导出的加载中
136
137 const visible = ref(false)
138
139 /** 打开弹窗 */
140 const open = async (nvr_id: string) => {
141   visible.value = true
142   nvrId.value = nvr_id
143   queryParams.nvrId = nvr_id
144   await getList()
145 }
146
aed8e1 147 defineExpose({open}) // 提供 open 方法,用于打开弹窗
30566d 148
H 149 /** 查询列表 */
150 const getList = async () => {
151   loading.value = true
152   try {
153     const data = await CameraApi.getCameraPage(queryParams)
154     list.value = data.list
155     total.value = data.total
156   } finally {
157     loading.value = false
158   }
159 }
160
aed8e1 161 /** 查看截图 */
H 162 const imageFormRef = ref()
163 const imageHandle = (id: string) => {
164   imageFormRef.value.open(id)
165 }
166
30566d 167 /** 搜索按钮操作 */
H 168 const handleQuery = () => {
169   queryParams.pageNo = 1
170   getList()
171 }
172
173 /** 重置按钮操作 */
174 const resetQuery = () => {
aed8e1 175   queryParams.location = undefined
30566d 176   handleQuery()
H 177 }
178
179 /** 添加/修改操作 */
180 const formRef = ref()
181 const openForm = (type: string, id?: number) => {
182   formRef.value.open(type, id, nvrId.value)
183 }
184
185 /** 删除按钮操作 */
186 const handleDelete = async (id: number) => {
187   try {
188     // 删除的二次确认
189     await message.delConfirm()
190     // 发起删除
191     await CameraApi.deleteCamera(id)
192     message.success(t('common.delSuccess'))
193     // 刷新列表
194     await getList()
195   } catch {
196   }
197 }
198
199 /** 导出按钮操作 */
200 const handleExport = async () => {
201   try {
202     // 导出的二次确认
203     await message.exportConfirm()
204     // 发起导出
205     exportLoading.value = true
206     const data = await CameraApi.exportCamera(queryParams)
207     download.excel(data, '摄像头列表.xls')
208   } catch {
209   } finally {
210     exportLoading.value = false
211   }
212 }
213
214 const handleClose = () => {
215   queryFormRef.value.resetFields()
216   visible.value = false
217 }
218
219 /** 初始化 **/
220 onMounted(async () => {
221   await getList()
222 })
223 </script>