houzhongjian
2024-11-06 1ae890a97b92470ad7c163615873091622c1c8ae
提交 | 用户 | 时间
30566d 1 <template>
H 2   <!-- 搜索 -->
3   <ContentWrap>
4     <el-form
5       class="-mb-15px"
6       :model="queryParams"
7       ref="queryFormRef"
8       :inline="true"
1ae890 9       label-width="40px"
30566d 10     >
H 11       <el-form-item label="品牌" prop="status">
12         <el-select
13           v-model="queryParams.brand"
14           placeholder="品牌"
15           clearable
1ae890 16           class="!w-140px"
30566d 17         >
H 18           <el-option
19             v-for="dict in getIntDictOptions(DICT_TYPE.CAMERA_BRAND)"
20             :key="dict.value"
21             :label="dict.label"
22             :value="dict.value"
23           />
24         </el-select>
25       </el-form-item>
1ae890 26       <el-form-item label="编码" prop="code">
30566d 27         <el-input
H 28           v-model="queryParams.code"
1ae890 29           placeholder="请输入编码"
30566d 30           clearable
H 31           @keyup.enter="handleQuery"
1ae890 32           class="!w-140px"
30566d 33         />
H 34       </el-form-item>
1ae890 35       <el-form-item label="IP" prop="ip">
30566d 36         <el-input
H 37           v-model="queryParams.ip"
38           placeholder="请输入IP"
39           clearable
40           @keyup.enter="handleQuery"
1ae890 41           class="!w-140px"
30566d 42         />
H 43       </el-form-item>
44       <el-form-item label="名称" prop="name">
45         <el-input
46           v-model="queryParams.name"
47           placeholder="请输入名称"
48           clearable
49           @keyup.enter="handleQuery"
1ae890 50           class="!w-140px"
30566d 51         />
H 52       </el-form-item>
53       <el-form-item>
54         <el-button @click="handleQuery">
55           <Icon icon="ep:search" class="mr-5px" />
56           搜索
57         </el-button>
58         <el-button @click="resetQuery">
59           <Icon icon="ep:refresh" class="mr-5px" />
60           重置
61         </el-button>
62         <el-button
63           type="primary"
64           plain
65           @click="openForm('create')"
1ae890 66           v-hasPermi="['video:nvr:save']"
30566d 67         >
H 68           <Icon icon="ep:plus" class="mr-5px" />
69           新增
70         </el-button>
71         <el-button
72           type="success"
73           plain
74           @click="handleExport"
75           :loading="exportLoading"
1ae890 76           v-hasPermi="['video:nvr:export']"
30566d 77         >
H 78           <Icon icon="ep:download" class="mr-5px" />
79           导出
80         </el-button>
81       </el-form-item>
82     </el-form>
83   </ContentWrap>
84
85   <!-- 列表 -->
86   <ContentWrap>
87     <el-table v-loading="loading" :data="list">
88       <el-table-column label="品牌" align="center" prop="brand" width="80">
89         <template #default="scope">
90           <dict-tag :type="DICT_TYPE.CAMERA_BRAND" :value="scope.row.brand" />
91         </template>
92       </el-table-column>
93       <el-table-column label="编码" align="center" prop="code" width="100"/>
94       <el-table-column label="名称" align="center" prop="name"/>
95       <el-table-column label="IP" align="center" prop="ip" />
96       <el-table-column label="端口" align="center" prop="port" width="100"/>
97       <el-table-column label="用户名" align="center" prop="username" width="100"/>
98       <el-table-column label="状态" prop="status" width="80">
99         <template #default="scope">
100           <dict-tag :type="DICT_TYPE.NVR_ONLINE_STATUS" :value="scope.row.status" />
101         </template>
102       </el-table-column>
103       <el-table-column label="位置" align="center" prop="position" />
104       <el-table-column label="备注" align="center" prop="remark" width="150"/>
105       <el-table-column label="操作" align="center" min-width="110" fixed="right">
106         <template #default="scope">
107           <el-button
108             link
109             type="primary"
110             @click="openForm('update', scope.row.id)"
1ae890 111             v-hasPermi="['video:nvr:update']"
30566d 112           >
H 113             编辑
114           </el-button>
115           <el-button
116             link
117             type="danger"
118             @click="handleDelete(scope.row.id)"
1ae890 119             v-hasPermi="['video:nvr:delete']"
30566d 120           >
H 121             删除
122           </el-button>
1ae890 123           <el-button link type="success" size="small" @click="cameraHandle(scope.row.id)">摄像头</el-button>
30566d 124         </template>
H 125       </el-table-column>
126     </el-table>
127     <!-- 分页 -->
128     <Pagination
129       :total="total"
130       v-model:page="queryParams.pageNo"
131       v-model:limit="queryParams.pageSize"
132       @pagination="getList"
133     />
134   </ContentWrap>
135
136   <!-- 表单弹窗:添加/修改 -->
137   <NvrForm ref="formRef" @success="getList" />
138
139   <!-- 弹窗, 摄像头 -->
1ae890 140   <NvrCamera ref="videoCameraRef"/>
30566d 141
H 142 </template>
143 <script lang="ts" setup>
144 import {DICT_TYPE, getIntDictOptions} from '@/utils/dict'
145   import download from '@/utils/download'
1ae890 146   import * as NvrApi from '@/api/data/video/nvr'
30566d 147   import NvrForm from './NvrForm.vue'
1ae890 148   import NvrCamera from './NvrCamera.vue'
30566d 149
H 150   defineOptions({name: 'Nvr'})
151
152   const message = useMessage() // 消息弹窗
153   const {t} = useI18n() // 国际化
154
155   const loading = ref(true) // 列表的加载中
156   const total = ref(0) // 列表的总页数
157   const list = ref([]) // 列表的数据
158   const queryParams = reactive({
159     pageNo: 1,
160     pageSize: 10,
161     brand: undefined,
162     ip: undefined,
163     code: undefined,
164     name: undefined,
165     status: undefined
166   })
167   const queryFormRef = ref() // 搜索的表单
168   const exportLoading = ref(false) // 导出的加载中
169
1ae890 170   const videoCameraRef = ref()
30566d 171
H 172   /** 查询列表 */
173   const getList = async () => {
174     loading.value = true
175     try {
176       const data = await NvrApi.getNvrPage(queryParams)
177       list.value = data.list
178       total.value = data.total
179     } finally {
180       loading.value = false
181     }
182   }
183
184   const cameraHandle = (id: string) => {
185     // devCameraVisible.value = true
1ae890 186     videoCameraRef.value.open(id)
30566d 187   }
H 188
189   /** 搜索按钮操作 */
190   const handleQuery = () => {
191     queryParams.pageNo = 1
192     getList()
193   }
194
195   /** 重置按钮操作 */
196   const resetQuery = () => {
197     queryFormRef.value.resetFields()
198     handleQuery()
199   }
200
201   /** 添加/修改操作 */
202   const formRef = ref()
203   const openForm = (type: string, id?: number) => {
204     formRef.value.open(type, id)
205   }
206
207   /** 删除按钮操作 */
208   const handleDelete = async (id: number) => {
209     try {
210       // 删除的二次确认
211       await message.delConfirm()
212       // 发起删除
213       await NvrApi.deleteNvr(id)
214       message.success(t('common.delSuccess'))
215       // 刷新列表
216       await getList()
217     } catch {
218     }
219   }
220
221   /** 导出按钮操作 */
222   const handleExport = async () => {
223     try {
224       // 导出的二次确认
225       await message.exportConfirm()
226       // 发起导出
227       exportLoading.value = true
228       const data = await NvrApi.exportNvr(queryParams)
229       download.excel(data, '录像机列表.xls')
230     } catch {
231     } finally {
232       exportLoading.value = false
233     }
234   }
235
236   /** 初始化 **/
237   onMounted(async () => {
238     await getList()
239   })
240 </script>