diff --git a/src/api/device.ts b/src/api/device.ts index fc5a495..eab5ef1 100644 --- a/src/api/device.ts +++ b/src/api/device.ts @@ -61,7 +61,7 @@ export function createDevice(data: DeviceCreateRecord) { return axios.post(`/api/rest/device`, data); } -// 修改 +// 编辑 export function updateDevice(data: DeviceUpdateRecord) { return axios.patch(`/api/rest/device/${data.id}`, data); } diff --git a/src/api/product.ts b/src/api/product.ts index 7554b52..f527438 100644 --- a/src/api/product.ts +++ b/src/api/product.ts @@ -57,7 +57,7 @@ export function createProduct(data: ProductCreateRecord) { return axios.post(`/api/rest/product`, data); } -// 修改 +// 编辑 export function updateProduct(data: ProductUpdateRecord) { return axios.patch(`/api/rest/product/${data.id}`, data); } diff --git a/src/components/message-box/index.vue b/src/components/message-box/index.vue index df0542f..474c0de 100644 --- a/src/components/message-box/index.vue +++ b/src/components/message-box/index.vue @@ -78,7 +78,7 @@ } } - // 修改消息状态 + // 编辑消息状态 async function readMessage(data: MessageListType) { const ids = data.map((item) => item.messageId); await useMessageStore.setMessageStatus(ids); @@ -104,7 +104,7 @@ const list = getUnreadList(type); return list.length ? `(${list.length})` : ``; }; - // 修改已读状态 + // 编辑已读状态 const handleItemClick = (items: MessageListType) => { if (renderList.value.length) readMessage([...items]); }; diff --git a/src/router/routes/modules/iot.ts b/src/router/routes/modules/iot.ts index 33bbe27..70d8e4d 100644 --- a/src/router/routes/modules/iot.ts +++ b/src/router/routes/modules/iot.ts @@ -73,6 +73,19 @@ const IOT: AppRouteRecordRaw = { permissions: ['iot:device:query'], }, }, + { + path: 'cardDevice/:id', + name: 'cardDeviceDetail', + component: () => + import('@/views/iot/deviceCard/components/device-detail.vue'), + meta: { + locale: '设备详情', + title: '设备详情', + requiresAuth: true, + showInMenu: false, + permissions: ['iot:device:query'], + }, + }, { path: 'product/tsl/:id', name: 'productTsl', diff --git a/src/views/iot/device/components/device-detail.vue b/src/views/iot/device/components/device-detail.vue index 661f1a6..05bd629 100644 --- a/src/views/iot/device/components/device-detail.vue +++ b/src/views/iot/device/components/device-detail.vue @@ -41,7 +41,7 @@ style="padding-top: 20px" > - + 基本信息 diff --git a/src/views/iot/device/components/device-edit.vue b/src/views/iot/device/components/device-edit.vue index 4ffeeb8..f613e82 100644 --- a/src/views/iot/device/components/device-edit.vue +++ b/src/views/iot/device/components/device-edit.vue @@ -17,7 +17,7 @@ @click="handleClick" > - 修改 + 编辑 - + 取消 - 确定确定 @@ -319,7 +318,7 @@ const res = await updateDevice(formData.value); if (res.status === 200) { Message.success({ - content: '修改成功', + content: '编辑成功', duration: 5 * 1000, }); emit('refresh'); diff --git a/src/views/iot/device/index.vue b/src/views/iot/device/index.vue index ec19e55..2ec657e 100644 --- a/src/views/iot/device/index.vue +++ b/src/views/iot/device/index.vue @@ -30,13 +30,20 @@ - + + @search="handleSearch" + > + {{ + item.name + }} + @@ -163,6 +170,9 @@ + @@ -224,7 +234,7 @@ import useTableOption from '@/hooks/table-option'; import { Message } from '@arco-design/web-vue'; import { useRouter } from 'vue-router'; - import { deleteDevice, DeviceRecord, queryDeviceList } from '@/api/device'; + import { deleteDevice, DeviceRecord, queryDeviceByName, queryDeviceList } from '@/api/device'; import DeviceEdit from '@/views/iot/device/components/device-edit.vue'; const generateFormModel = () => { @@ -296,14 +306,7 @@ value: 'false', }, ]); - const productOptions = computed(() => { - return [ - { - label: '全部', - value: '', - }, - ]; - }); + const options = ref([]); // 获取设备列表 const fetchData = async (params = { size: 10, current: 1 }) => { @@ -327,6 +330,30 @@ } as unknown as DeviceRecord); }; + // 搜索 + const handleSearch = (value: any) => { + if (value) { + loading.value = true; + options.value = []; + window.setTimeout(async () => { + const res = await queryDeviceByName({ + name: value, + page: 1, + size: 5, + }); + options.value = res.data.records.map((item: any) => { + return { + id: item.id, + name: item.name, + }; + }); + loading.value = false; + }, 1000); + } else { + options.value = []; + } + }; + // 分页发生改变 const onPageChange = (current: number) => { pagination.value.page = current; diff --git a/src/views/iot/deviceCard/components/card-wrap.vue b/src/views/iot/deviceCard/components/card-wrap.vue index 2f99997..c02196c 100644 --- a/src/views/iot/deviceCard/components/card-wrap.vue +++ b/src/views/iot/deviceCard/components/card-wrap.vue @@ -81,10 +81,12 @@ default: '', }, }); + const emit = defineEmits(['search']); + // 打开详情 function openDetail(id: number): void { const url = router.resolve({ - name: 'deviceDetail', + name: 'cardDeviceDetail', params: { id }, }).href; router.push(url); @@ -97,6 +99,7 @@ content: '删除成功', duration: 5 * 1000, }); + emit('search'); } }; diff --git a/src/views/iot/deviceCard/components/device-detail.vue b/src/views/iot/deviceCard/components/device-detail.vue index 79b60f8..77e9ce3 100644 --- a/src/views/iot/deviceCard/components/device-detail.vue +++ b/src/views/iot/deviceCard/components/device-detail.vue @@ -40,7 +40,7 @@ style="padding-top: 20px" > - + 基本信息 diff --git a/src/views/iot/deviceCard/components/device-edit.vue b/src/views/iot/deviceCard/components/device-edit.vue index edc4ae0..5b8e668 100644 --- a/src/views/iot/deviceCard/components/device-edit.vue +++ b/src/views/iot/deviceCard/components/device-edit.vue @@ -35,7 +35,7 @@ @click="handleClick" > - 修改 + 编辑