diff --git a/src/api/area/areaHouse.ts b/src/api/area/areaHouse.ts index 48fbc1a..46ae211 100644 --- a/src/api/area/areaHouse.ts +++ b/src/api/area/areaHouse.ts @@ -34,6 +34,14 @@ export function editBindDevice(data: any) { }) } +export function getDevice(params: any) { + return request({ + url: '/admin/areaHouse/getDevice', + method: 'get', + params + }) +} + /** * 删除房间绑定设备 */ diff --git a/src/api/device/deviceManage.ts b/src/api/device/deviceManage.ts index 3b7dba4..7a2542d 100644 --- a/src/api/device/deviceManage.ts +++ b/src/api/device/deviceManage.ts @@ -1,5 +1,18 @@ import request from "/@/utils/request" +export function cameraPage(query: any) { + return request({ + url: '/admin/deviceManage/cameraPage', + method: 'post', + params: { + current: query.current, + size: query.size, + }, + data: query + }) +} + + export function fetchList(query: any) { return request({ url: '/admin/deviceManage/page', diff --git a/src/views/area/_components/bindCameraForm.vue b/src/views/area/_components/bindCameraForm.vue index a9d019e..106075f 100644 --- a/src/views/area/_components/bindCameraForm.vue +++ b/src/views/area/_components/bindCameraForm.vue @@ -5,7 +5,12 @@ - + + + + + + @@ -50,6 +55,7 @@ const form = reactive({ // 定义校验规则 const dataRules = ref({ name: [{ required: true, message: '房间名不能为空', trigger: 'change' }], + uniqueCode: [{ required: true, message: '唯一编码不能为空', trigger: 'change' }], deviceId: [{ required: true, message: '设备不能为空', trigger: 'change' }], }) @@ -63,17 +69,14 @@ const openDialog = (areaHouseId: string, bindId?: string) => { dataFormRef.value?.resetFields(); }); // 获取areaHouse信息 - if (areaHouseId) { - form.areaHouseId = areaHouseId - getareaHouseData(areaHouseId) - } + if (areaHouseId) form.areaHouseId = areaHouseId + getareaHouseDeviceData(bindId, areaHouseId) }; // 提交 const onSubmit = async () => { const valid = await dataFormRef.value.validate().catch(() => { }); if (!valid) return false; - try { loading.value = true; form.id ? await AreaHouseApi.editBindDevice(form) : await AreaHouseApi.bindDevice(form); @@ -89,13 +92,23 @@ const onSubmit = async () => { // 初始化表单数据 -const getareaHouseData = async (id: string) => { +const getareaHouseDeviceData = async (bindId: any, areaHouseId: any) => { // 获取数据 loading.value = true try { - const { data } = await AreaHouseApi.getObj(id) - if (data) { - form.name = data.name + if (bindId) { + // 房间设备绑定详情 + const { data: houseDeviceRes } = await AreaHouseApi.getDevice({ id: bindId }) + if (houseDeviceRes) { + form.name = houseDeviceRes.houseName + form.uniqueCode = houseDeviceRes.uniqueCode + form.deviceId = houseDeviceRes.deviceId + } + } else if (areaHouseId) { + const { data: houseRes } = await AreaHouseApi.getObj(areaHouseId) + if (houseRes) { + form.name = houseRes.name + } } } catch (error: any) { console.error(error); diff --git a/src/views/area/_components/bindCameraTable.vue b/src/views/area/_components/bindCameraTable.vue index 9722456..697ccad 100644 --- a/src/views/area/_components/bindCameraTable.vue +++ b/src/views/area/_components/bindCameraTable.vue @@ -1,8 +1,8 @@ @@ -61,6 +68,8 @@ \ No newline at end of file diff --git a/src/views/device/deviceManage/index.vue b/src/views/device/deviceManage/index.vue index 83b529e..8750bd7 100644 --- a/src/views/device/deviceManage/index.vue +++ b/src/views/device/deviceManage/index.vue @@ -103,7 +103,7 @@ import { useMessage, useMessageBox } from "/@/hooks/message"; import { useDict } from '/@/hooks/dict'; // 引入组件 -const FormDialog = defineAsyncComponent(() => import('./form.vue')); +const FormDialog = defineAsyncComponent(() => import('../components/deviceForm.vue')); const PreviewVideo = defineAsyncComponent(() => import("../components/preview-video/index.vue")); // 定义查询字典 const { device_category, is_sync, is_nline, dh_device_manufacturer } = useDict("device_category", "is_sync", "is_nline", "dh_device_manufacturer")