|
|
@@ -3,30 +3,30 @@
|
|
|
<!-- 搜索区域 -->
|
|
|
<div class="search-form">
|
|
|
<el-form :model="queryParams" inline>
|
|
|
- <el-form-item label="设备ID">
|
|
|
- <el-input
|
|
|
- v-model="queryParams.deviceId"
|
|
|
- placeholder="请输入设备ID"
|
|
|
- clearable
|
|
|
- @keyup.enter="handleQuery"
|
|
|
- />
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label="设备名称">
|
|
|
- <el-input
|
|
|
- v-model="queryParams.deviceName"
|
|
|
- placeholder="请输入设备名称"
|
|
|
+ <el-form-item label="机器">
|
|
|
+ <el-select
|
|
|
+ v-model="queryParams.machineId"
|
|
|
+ placeholder="请选择机器"
|
|
|
clearable
|
|
|
- @keyup.enter="handleQuery"
|
|
|
- />
|
|
|
+ @change="handleQuery"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="machine in machineList"
|
|
|
+ :key="machine.machineId"
|
|
|
+ :label="machine.name"
|
|
|
+ :value="machine.machineId"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="在线状态">
|
|
|
+ <el-form-item label="状态">
|
|
|
<el-select
|
|
|
- v-model="queryParams.online"
|
|
|
+ v-model="queryParams.status"
|
|
|
placeholder="请选择"
|
|
|
clearable
|
|
|
+ @change="handleQuery"
|
|
|
>
|
|
|
- <el-option label="在线" :value="true" />
|
|
|
- <el-option label="离线" :value="false" />
|
|
|
+ <el-option label="在线" value="ONLINE" />
|
|
|
+ <el-option label="离线" value="OFFLINE" />
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
<el-form-item>
|
|
|
@@ -41,7 +41,7 @@
|
|
|
<!-- 操作按钮 -->
|
|
|
<div class="table-actions">
|
|
|
<el-button type="primary" :icon="Plus" @click="handleAdd"
|
|
|
- >新增设备</el-button
|
|
|
+ >新增摄像头</el-button
|
|
|
>
|
|
|
<el-button type="success" :icon="Refresh" @click="getList"
|
|
|
>刷新列表</el-button
|
|
|
@@ -49,52 +49,61 @@
|
|
|
</div>
|
|
|
|
|
|
<!-- 数据表格 -->
|
|
|
- <el-table v-loading="loading" :data="deviceList" border>
|
|
|
+ <el-table v-loading="loading" :data="filteredList" border>
|
|
|
<el-table-column type="index" label="序号" width="60" align="center" />
|
|
|
<el-table-column
|
|
|
- prop="deviceId"
|
|
|
- label="设备ID"
|
|
|
- min-width="180"
|
|
|
+ prop="cameraId"
|
|
|
+ label="摄像头ID"
|
|
|
+ min-width="120"
|
|
|
show-overflow-tooltip
|
|
|
/>
|
|
|
<el-table-column
|
|
|
- prop="deviceName"
|
|
|
- label="设备名称"
|
|
|
- min-width="150"
|
|
|
+ prop="name"
|
|
|
+ label="名称"
|
|
|
+ min-width="120"
|
|
|
show-overflow-tooltip
|
|
|
/>
|
|
|
<el-table-column
|
|
|
- prop="manufacturer"
|
|
|
- label="厂商"
|
|
|
- min-width="120"
|
|
|
+ prop="ip"
|
|
|
+ label="IP地址"
|
|
|
+ min-width="130"
|
|
|
show-overflow-tooltip
|
|
|
/>
|
|
|
+ <el-table-column prop="port" label="端口" width="80" align="center" />
|
|
|
<el-table-column
|
|
|
- prop="hostAddress"
|
|
|
- label="地址"
|
|
|
- min-width="150"
|
|
|
+ prop="brand"
|
|
|
+ label="品牌"
|
|
|
+ min-width="100"
|
|
|
show-overflow-tooltip
|
|
|
/>
|
|
|
<el-table-column
|
|
|
- prop="channelCount"
|
|
|
- label="通道数"
|
|
|
- width="80"
|
|
|
- align="center"
|
|
|
+ prop="machineName"
|
|
|
+ label="所属机器"
|
|
|
+ min-width="100"
|
|
|
+ show-overflow-tooltip
|
|
|
/>
|
|
|
- <el-table-column prop="online" label="状态" width="80" align="center">
|
|
|
+ <el-table-column prop="capability" label="能力" width="100" align="center">
|
|
|
<template #default="{ row }">
|
|
|
- <el-tag :type="row.online ? 'success' : 'danger'">
|
|
|
- {{ row.online ? "在线" : "离线" }}
|
|
|
+ <el-tag :type="row.capability === 'ptz_enabled' ? 'success' : 'info'">
|
|
|
+ {{ row.capability === 'ptz_enabled' ? 'PTZ' : '仅切换' }}
|
|
|
</el-tag>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
- <el-table-column
|
|
|
- prop="registerTime"
|
|
|
- label="注册时间"
|
|
|
- width="160"
|
|
|
- align="center"
|
|
|
- />
|
|
|
- <el-table-column label="操作" width="280" align="center" fixed="right">
|
|
|
+ <el-table-column prop="status" label="状态" width="80" align="center">
|
|
|
+ <template #default="{ row }">
|
|
|
+ <el-tag :type="row.status === 'ONLINE' ? 'success' : 'danger'">
|
|
|
+ {{ row.status === 'ONLINE' ? '在线' : '离线' }}
|
|
|
+ </el-tag>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="enabled" label="启用" width="80" align="center">
|
|
|
+ <template #default="{ row }">
|
|
|
+ <el-tag :type="row.enabled ? 'success' : 'info'">
|
|
|
+ {{ row.enabled ? '是' : '否' }}
|
|
|
+ </el-tag>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="操作" width="260" align="center" fixed="right">
|
|
|
<template #default="{ row }">
|
|
|
<el-button
|
|
|
type="primary"
|
|
|
@@ -104,11 +113,11 @@
|
|
|
>通道</el-button
|
|
|
>
|
|
|
<el-button
|
|
|
- type="primary"
|
|
|
+ type="success"
|
|
|
link
|
|
|
- :icon="Refresh"
|
|
|
- @click="handleSync(row)"
|
|
|
- >同步</el-button
|
|
|
+ :icon="Connection"
|
|
|
+ @click="handleCheck(row)"
|
|
|
+ >检测</el-button
|
|
|
>
|
|
|
<el-button type="primary" link :icon="Edit" @click="handleEdit(row)"
|
|
|
>编辑</el-button
|
|
|
@@ -124,55 +133,84 @@
|
|
|
</el-table-column>
|
|
|
</el-table>
|
|
|
|
|
|
- <!-- 分页 -->
|
|
|
- <el-pagination
|
|
|
- v-model:current-page="queryParams.pageNum"
|
|
|
- v-model:page-size="queryParams.pageSize"
|
|
|
- :page-sizes="[10, 20, 50, 100]"
|
|
|
- :total="total"
|
|
|
- layout="total, sizes, prev, pager, next, jumper"
|
|
|
- class="pagination"
|
|
|
- @size-change="getList"
|
|
|
- @current-change="getList"
|
|
|
- />
|
|
|
-
|
|
|
<!-- 新增/编辑弹窗 -->
|
|
|
<el-dialog
|
|
|
v-model="dialogVisible"
|
|
|
:title="dialogTitle"
|
|
|
- width="600px"
|
|
|
+ width="650px"
|
|
|
destroy-on-close
|
|
|
>
|
|
|
<el-form ref="formRef" :model="form" :rules="rules" label-width="100px">
|
|
|
- <el-form-item label="设备ID" prop="deviceId">
|
|
|
+ <el-form-item label="摄像头ID" prop="cameraId">
|
|
|
<el-input
|
|
|
- v-model="form.deviceId"
|
|
|
- placeholder="请输入设备ID"
|
|
|
- :disabled="!!form.id"
|
|
|
+ v-model="form.cameraId"
|
|
|
+ placeholder="请输入摄像头ID"
|
|
|
+ :disabled="isEdit"
|
|
|
/>
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="设备名称" prop="deviceName">
|
|
|
- <el-input v-model="form.deviceName" placeholder="请输入设备名称" />
|
|
|
+ <el-form-item label="名称" prop="name">
|
|
|
+ <el-input v-model="form.name" placeholder="请输入名称" />
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="密码" prop="password">
|
|
|
- <el-input
|
|
|
- v-model="form.password"
|
|
|
- type="password"
|
|
|
- placeholder="请输入密码"
|
|
|
- show-password
|
|
|
- />
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label="传输协议" prop="transport">
|
|
|
- <el-select v-model="form.transport" placeholder="请选择">
|
|
|
- <el-option label="UDP" value="UDP" />
|
|
|
- <el-option label="TCP-PASSIVE" value="TCP-PASSIVE" />
|
|
|
+ <el-row :gutter="20">
|
|
|
+ <el-col :span="16">
|
|
|
+ <el-form-item label="IP地址" prop="ip">
|
|
|
+ <el-input v-model="form.ip" placeholder="请输入IP地址" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="端口" prop="port">
|
|
|
+ <el-input-number v-model="form.port" :min="1" :max="65535" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ <el-row :gutter="20">
|
|
|
+ <el-col :span="12">
|
|
|
+ <el-form-item label="用户名" prop="username">
|
|
|
+ <el-input v-model="form.username" placeholder="请输入用户名" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="12">
|
|
|
+ <el-form-item label="密码" prop="password">
|
|
|
+ <el-input
|
|
|
+ v-model="form.password"
|
|
|
+ type="password"
|
|
|
+ placeholder="请输入密码"
|
|
|
+ show-password
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ <el-row :gutter="20">
|
|
|
+ <el-col :span="12">
|
|
|
+ <el-form-item label="品牌" prop="brand">
|
|
|
+ <el-select v-model="form.brand" placeholder="请选择">
|
|
|
+ <el-option label="海康威视" value="hikvision" />
|
|
|
+ <el-option label="大华" value="dahua" />
|
|
|
+ <el-option label="其他" value="other" />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="12">
|
|
|
+ <el-form-item label="能力" prop="capability">
|
|
|
+ <el-select v-model="form.capability" placeholder="请选择">
|
|
|
+ <el-option label="仅切换" value="switch_only" />
|
|
|
+ <el-option label="支持PTZ" value="ptz_enabled" />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ <el-form-item label="所属机器" prop="machineId">
|
|
|
+ <el-select v-model="form.machineId" placeholder="请选择机器" clearable>
|
|
|
+ <el-option
|
|
|
+ v-for="machine in machineList"
|
|
|
+ :key="machine.machineId"
|
|
|
+ :label="machine.name"
|
|
|
+ :value="machine.machineId"
|
|
|
+ />
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="字符集" prop="charset">
|
|
|
- <el-select v-model="form.charset" placeholder="请选择">
|
|
|
- <el-option label="GB2312" value="GB2312" />
|
|
|
- <el-option label="UTF-8" value="UTF-8" />
|
|
|
- </el-select>
|
|
|
+ <el-form-item v-if="isEdit" label="启用状态">
|
|
|
+ <el-switch v-model="form.enabled" />
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
|
<template #footer>
|
|
|
@@ -182,18 +220,45 @@
|
|
|
>
|
|
|
</template>
|
|
|
</el-dialog>
|
|
|
+
|
|
|
+ <!-- 通道弹窗 -->
|
|
|
+ <el-dialog
|
|
|
+ v-model="channelDialogVisible"
|
|
|
+ title="通道列表"
|
|
|
+ width="700px"
|
|
|
+ destroy-on-close
|
|
|
+ >
|
|
|
+ <el-table :data="currentChannels" border>
|
|
|
+ <el-table-column prop="channelId" label="通道ID" min-width="100" />
|
|
|
+ <el-table-column prop="name" label="名称" min-width="100" />
|
|
|
+ <el-table-column prop="rtspUrl" label="RTSP地址" min-width="200" show-overflow-tooltip />
|
|
|
+ <el-table-column prop="defaultView" label="默认视角" width="90" align="center">
|
|
|
+ <template #default="{ row }">
|
|
|
+ <el-tag :type="row.defaultView ? 'success' : 'info'">
|
|
|
+ {{ row.defaultView ? '是' : '否' }}
|
|
|
+ </el-tag>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="status" label="状态" width="80" align="center">
|
|
|
+ <template #default="{ row }">
|
|
|
+ <el-tag :type="row.status === 'ONLINE' ? 'success' : 'danger'">
|
|
|
+ {{ row.status === 'ONLINE' ? '在线' : '离线' }}
|
|
|
+ </el-tag>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ </el-dialog>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
-import { ref, reactive, onMounted, computed } from "vue";
|
|
|
-import { useRouter } from "vue-router";
|
|
|
+import { ref, reactive, onMounted, computed } from 'vue'
|
|
|
import {
|
|
|
ElMessage,
|
|
|
ElMessageBox,
|
|
|
type FormInstance,
|
|
|
- type FormRules,
|
|
|
-} from "element-plus";
|
|
|
+ type FormRules
|
|
|
+} from 'element-plus'
|
|
|
import {
|
|
|
Search,
|
|
|
Refresh,
|
|
|
@@ -201,154 +266,251 @@ import {
|
|
|
View,
|
|
|
Edit,
|
|
|
Delete,
|
|
|
-} from "@element-plus/icons-vue";
|
|
|
+ Connection
|
|
|
+} from '@element-plus/icons-vue'
|
|
|
import {
|
|
|
- listDevice,
|
|
|
- addDevice,
|
|
|
- updateDevice,
|
|
|
- delDevice,
|
|
|
- syncChannel,
|
|
|
-} from "@/api/camera";
|
|
|
-import type { CameraDevice } from "@/types";
|
|
|
+ adminListCameras,
|
|
|
+ adminAddCamera,
|
|
|
+ adminUpdateCamera,
|
|
|
+ adminDeleteCamera,
|
|
|
+ adminCheckCamera
|
|
|
+} from '@/api/camera'
|
|
|
+import { listMachines } from '@/api/machine'
|
|
|
+import type {
|
|
|
+ CameraInfoDTO,
|
|
|
+ ChannelInfoDTO,
|
|
|
+ CameraAddRequest,
|
|
|
+ CameraUpdateRequest,
|
|
|
+ MachineDTO
|
|
|
+} from '@/types'
|
|
|
|
|
|
-const router = useRouter();
|
|
|
-
|
|
|
-const loading = ref(false);
|
|
|
-const submitLoading = ref(false);
|
|
|
-const deviceList = ref<CameraDevice[]>([]);
|
|
|
-const total = ref(0);
|
|
|
-const dialogVisible = ref(false);
|
|
|
-const formRef = ref<FormInstance>();
|
|
|
+const loading = ref(false)
|
|
|
+const submitLoading = ref(false)
|
|
|
+const cameraList = ref<CameraInfoDTO[]>([])
|
|
|
+const machineList = ref<MachineDTO[]>([])
|
|
|
+const dialogVisible = ref(false)
|
|
|
+const channelDialogVisible = ref(false)
|
|
|
+const currentChannels = ref<ChannelInfoDTO[]>([])
|
|
|
+const formRef = ref<FormInstance>()
|
|
|
|
|
|
const queryParams = reactive({
|
|
|
- pageNum: 1,
|
|
|
- pageSize: 10,
|
|
|
- deviceId: "",
|
|
|
- deviceName: "",
|
|
|
- online: undefined as boolean | undefined,
|
|
|
-});
|
|
|
+ machineId: '',
|
|
|
+ status: '' as '' | 'ONLINE' | 'OFFLINE'
|
|
|
+})
|
|
|
+
|
|
|
+const form = reactive<{
|
|
|
+ id?: number
|
|
|
+ cameraId: string
|
|
|
+ name: string
|
|
|
+ ip: string
|
|
|
+ port: number
|
|
|
+ username: string
|
|
|
+ password: string
|
|
|
+ brand: string
|
|
|
+ capability: 'switch_only' | 'ptz_enabled'
|
|
|
+ machineId: string
|
|
|
+ enabled: boolean
|
|
|
+}>({
|
|
|
+ cameraId: '',
|
|
|
+ name: '',
|
|
|
+ ip: '',
|
|
|
+ port: 80,
|
|
|
+ username: 'admin',
|
|
|
+ password: '',
|
|
|
+ brand: 'hikvision',
|
|
|
+ capability: 'switch_only',
|
|
|
+ machineId: '',
|
|
|
+ enabled: true
|
|
|
+})
|
|
|
|
|
|
-const form = reactive<Partial<CameraDevice> & { id?: string }>({
|
|
|
- deviceId: "",
|
|
|
- deviceName: "",
|
|
|
- password: "",
|
|
|
- transport: "UDP",
|
|
|
- charset: "GB2312",
|
|
|
-});
|
|
|
+const isEdit = computed(() => !!form.id)
|
|
|
+const dialogTitle = computed(() => (isEdit.value ? '编辑摄像头' : '新增摄像头'))
|
|
|
|
|
|
-const dialogTitle = computed(() => (form.id ? "编辑设备" : "新增设备"));
|
|
|
+const filteredList = computed(() => {
|
|
|
+ let list = cameraList.value
|
|
|
+ if (queryParams.status) {
|
|
|
+ list = list.filter(item => item.status === queryParams.status)
|
|
|
+ }
|
|
|
+ return list
|
|
|
+})
|
|
|
|
|
|
const rules: FormRules = {
|
|
|
- deviceId: [{ required: true, message: "请输入设备ID", trigger: "blur" }],
|
|
|
- deviceName: [{ required: true, message: "请输入设备名称", trigger: "blur" }],
|
|
|
-};
|
|
|
+ cameraId: [{ required: true, message: '请输入摄像头ID', trigger: 'blur' }],
|
|
|
+ name: [{ required: true, message: '请输入名称', trigger: 'blur' }],
|
|
|
+ ip: [
|
|
|
+ { required: true, message: '请输入IP地址', trigger: 'blur' },
|
|
|
+ {
|
|
|
+ pattern: /^((25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(25[0-5]|2[0-4]\d|[01]?\d\d?)$/,
|
|
|
+ message: '请输入正确的IP地址',
|
|
|
+ trigger: 'blur'
|
|
|
+ }
|
|
|
+ ]
|
|
|
+}
|
|
|
+
|
|
|
+async function getMachines() {
|
|
|
+ try {
|
|
|
+ const res = await listMachines()
|
|
|
+ if (res.code === 200) {
|
|
|
+ machineList.value = res.data
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ console.error('获取机器列表失败', error)
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
async function getList() {
|
|
|
- loading.value = true;
|
|
|
+ loading.value = true
|
|
|
try {
|
|
|
- const res = await listDevice(queryParams);
|
|
|
+ const res = await adminListCameras(queryParams.machineId || undefined)
|
|
|
if (res.code === 200) {
|
|
|
- deviceList.value = res.data.rows;
|
|
|
- total.value = res.data.total;
|
|
|
+ cameraList.value = res.data
|
|
|
}
|
|
|
} finally {
|
|
|
- loading.value = false;
|
|
|
+ loading.value = false
|
|
|
}
|
|
|
}
|
|
|
|
|
|
function handleQuery() {
|
|
|
- queryParams.pageNum = 1;
|
|
|
- getList();
|
|
|
+ getList()
|
|
|
}
|
|
|
|
|
|
function resetQuery() {
|
|
|
- queryParams.pageNum = 1;
|
|
|
- queryParams.deviceId = "";
|
|
|
- queryParams.deviceName = "";
|
|
|
- queryParams.online = undefined;
|
|
|
- getList();
|
|
|
+ queryParams.machineId = ''
|
|
|
+ queryParams.status = ''
|
|
|
+ getList()
|
|
|
}
|
|
|
|
|
|
function handleAdd() {
|
|
|
Object.assign(form, {
|
|
|
id: undefined,
|
|
|
- deviceId: "",
|
|
|
- deviceName: "",
|
|
|
- password: "",
|
|
|
- transport: "UDP",
|
|
|
- charset: "GB2312",
|
|
|
- });
|
|
|
- dialogVisible.value = true;
|
|
|
+ cameraId: '',
|
|
|
+ name: '',
|
|
|
+ ip: '',
|
|
|
+ port: 80,
|
|
|
+ username: 'admin',
|
|
|
+ password: '',
|
|
|
+ brand: 'hikvision',
|
|
|
+ capability: 'switch_only',
|
|
|
+ machineId: '',
|
|
|
+ enabled: true
|
|
|
+ })
|
|
|
+ dialogVisible.value = true
|
|
|
}
|
|
|
|
|
|
-function handleEdit(row: CameraDevice) {
|
|
|
+function handleEdit(row: CameraInfoDTO) {
|
|
|
Object.assign(form, {
|
|
|
- id: row.deviceId,
|
|
|
- ...row,
|
|
|
- });
|
|
|
- dialogVisible.value = true;
|
|
|
+ id: row.id,
|
|
|
+ cameraId: row.cameraId,
|
|
|
+ name: row.name,
|
|
|
+ ip: row.ip,
|
|
|
+ port: row.port,
|
|
|
+ username: row.username,
|
|
|
+ password: '',
|
|
|
+ brand: row.brand,
|
|
|
+ capability: row.capability,
|
|
|
+ machineId: row.machineId || '',
|
|
|
+ enabled: row.enabled
|
|
|
+ })
|
|
|
+ dialogVisible.value = true
|
|
|
}
|
|
|
|
|
|
-function handleChannel(row: CameraDevice) {
|
|
|
- router.push(`/camera/channel/${row.deviceId}`);
|
|
|
+function handleChannel(row: CameraInfoDTO) {
|
|
|
+ currentChannels.value = row.channels || []
|
|
|
+ channelDialogVisible.value = true
|
|
|
}
|
|
|
|
|
|
-async function handleSync(row: CameraDevice) {
|
|
|
+async function handleCheck(row: CameraInfoDTO) {
|
|
|
try {
|
|
|
- const res = await syncChannel(row.deviceId);
|
|
|
+ const res = await adminCheckCamera(row.id)
|
|
|
if (res.code === 200) {
|
|
|
- ElMessage.success("同步成功");
|
|
|
- getList();
|
|
|
+ if (res.data) {
|
|
|
+ ElMessage.success('摄像头连接正常')
|
|
|
+ } else {
|
|
|
+ ElMessage.warning('摄像头连接失败')
|
|
|
+ }
|
|
|
}
|
|
|
} catch (error) {
|
|
|
- console.error("同步失败", error);
|
|
|
+ console.error('检测失败', error)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-async function handleDelete(row: CameraDevice) {
|
|
|
+async function handleDelete(row: CameraInfoDTO) {
|
|
|
try {
|
|
|
await ElMessageBox.confirm(
|
|
|
- `确定要删除设备 "${row.deviceName}" 吗?`,
|
|
|
- "提示",
|
|
|
+ `确定要删除摄像头 "${row.name}" 吗?`,
|
|
|
+ '提示',
|
|
|
{
|
|
|
- type: "warning",
|
|
|
+ type: 'warning'
|
|
|
}
|
|
|
- );
|
|
|
- const res = await delDevice(row.deviceId);
|
|
|
+ )
|
|
|
+ const res = await adminDeleteCamera(row.id)
|
|
|
if (res.code === 200) {
|
|
|
- ElMessage.success("删除成功");
|
|
|
- getList();
|
|
|
+ ElMessage.success('删除成功')
|
|
|
+ getList()
|
|
|
}
|
|
|
} catch (error) {
|
|
|
- if (error !== "cancel") {
|
|
|
- console.error("删除失败", error);
|
|
|
+ if (error !== 'cancel') {
|
|
|
+ console.error('删除失败', error)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
async function handleSubmit() {
|
|
|
- if (!formRef.value) return;
|
|
|
+ if (!formRef.value) return
|
|
|
|
|
|
await formRef.value.validate(async (valid) => {
|
|
|
if (valid) {
|
|
|
- submitLoading.value = true;
|
|
|
+ submitLoading.value = true
|
|
|
try {
|
|
|
- const res = form.id ? await updateDevice(form) : await addDevice(form);
|
|
|
- if (res.code === 200) {
|
|
|
- ElMessage.success(form.id ? "修改成功" : "新增成功");
|
|
|
- dialogVisible.value = false;
|
|
|
- getList();
|
|
|
+ if (isEdit.value) {
|
|
|
+ const updateData: CameraUpdateRequest = {
|
|
|
+ id: form.id!,
|
|
|
+ name: form.name,
|
|
|
+ ip: form.ip,
|
|
|
+ port: form.port,
|
|
|
+ username: form.username,
|
|
|
+ password: form.password || undefined,
|
|
|
+ brand: form.brand,
|
|
|
+ capability: form.capability,
|
|
|
+ machineId: form.machineId || undefined,
|
|
|
+ enabled: form.enabled
|
|
|
+ }
|
|
|
+ const res = await adminUpdateCamera(updateData)
|
|
|
+ if (res.code === 200) {
|
|
|
+ ElMessage.success('修改成功')
|
|
|
+ dialogVisible.value = false
|
|
|
+ getList()
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ const addData: CameraAddRequest = {
|
|
|
+ cameraId: form.cameraId,
|
|
|
+ name: form.name,
|
|
|
+ ip: form.ip,
|
|
|
+ port: form.port,
|
|
|
+ username: form.username,
|
|
|
+ password: form.password || undefined,
|
|
|
+ brand: form.brand,
|
|
|
+ capability: form.capability,
|
|
|
+ machineId: form.machineId || undefined
|
|
|
+ }
|
|
|
+ const res = await adminAddCamera(addData)
|
|
|
+ if (res.code === 200) {
|
|
|
+ ElMessage.success('新增成功')
|
|
|
+ dialogVisible.value = false
|
|
|
+ getList()
|
|
|
+ }
|
|
|
}
|
|
|
} finally {
|
|
|
- submitLoading.value = false;
|
|
|
+ submitLoading.value = false
|
|
|
}
|
|
|
}
|
|
|
- });
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
onMounted(() => {
|
|
|
- getList();
|
|
|
-});
|
|
|
+ getMachines()
|
|
|
+ getList()
|
|
|
+})
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
@@ -366,9 +528,4 @@ onMounted(() => {
|
|
|
.table-actions {
|
|
|
margin-bottom: 15px;
|
|
|
}
|
|
|
-
|
|
|
-.pagination {
|
|
|
- margin-top: 20px;
|
|
|
- justify-content: flex-end;
|
|
|
-}
|
|
|
</style>
|