From 335c5d3b23337b4f3de9f7bf988caf1eeffa235c Mon Sep 17 00:00:00 2001 From: K <1175047471@qq.com> Date: Fri, 8 Mar 2024 16:53:50 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BA=91=E7=AB=AF=E4=B8=8B=E5=8F=91?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/device-manage/device/cloud-command.ts | 18 +++++ src/api/device-manage/device/types.ts | 4 + .../device/components/CloudCommand.vue | 79 +++++++++++++++++++ ...eportExampleModal.vue => MessageModal.vue} | 12 +-- .../components/composables/useDeviceInfo.ts | 9 +-- .../device-manage/device/components/index.ts | 1 + src/views/device-manage/device/detail.vue | 6 +- 7 files changed, 116 insertions(+), 13 deletions(-) create mode 100644 src/api/device-manage/device/cloud-command.ts create mode 100644 src/views/device-manage/device/components/CloudCommand.vue rename src/views/device-manage/device/components/{ReportExampleModal.vue => MessageModal.vue} (78%) diff --git a/src/api/device-manage/device/cloud-command.ts b/src/api/device-manage/device/cloud-command.ts new file mode 100644 index 00000000..ebe0c129 --- /dev/null +++ b/src/api/device-manage/device/cloud-command.ts @@ -0,0 +1,18 @@ +import type { GetCloudCommandLogsParams } from './types' +import { defHttp } from '@/utils/http/axios' + +export function getCloudCommandLogs(params: GetCloudCommandLogsParams) { + return defHttp.get({ + url: '/cloud/logPage', + params, + }) +} + +export function getMessageContent(id: string) { + return defHttp.get({ + url: '/cloud/message', + params: { + id, + }, + }) +} diff --git a/src/api/device-manage/device/types.ts b/src/api/device-manage/device/types.ts index 4c76ccd6..1efea4b4 100644 --- a/src/api/device-manage/device/types.ts +++ b/src/api/device-manage/device/types.ts @@ -21,3 +21,7 @@ export interface DevicePropertie { value: string sort: number } + +export interface GetCloudCommandLogsParams extends PageParam { + messageType?: number +} diff --git a/src/views/device-manage/device/components/CloudCommand.vue b/src/views/device-manage/device/components/CloudCommand.vue new file mode 100644 index 00000000..95397e94 --- /dev/null +++ b/src/views/device-manage/device/components/CloudCommand.vue @@ -0,0 +1,79 @@ + + + diff --git a/src/views/device-manage/device/components/ReportExampleModal.vue b/src/views/device-manage/device/components/MessageModal.vue similarity index 78% rename from src/views/device-manage/device/components/ReportExampleModal.vue rename to src/views/device-manage/device/components/MessageModal.vue index ce7c09cb..80e595a3 100644 --- a/src/views/device-manage/device/components/ReportExampleModal.vue +++ b/src/views/device-manage/device/components/MessageModal.vue @@ -3,15 +3,17 @@ import { h, ref } from 'vue' import { Modal } from 'ant-design-vue' import { EyeOutlined } from '@ant-design/icons-vue' import { useAsyncState } from '@vueuse/core' -import { getReportExample } from '@/api/device-manage/device' import type { DescItem } from '@/components/Description' import { Description } from '@/components/Description' import { JsonPreview } from '@/components/CodeEditor' import { noop } from '@/utils' -const props = defineProps<{ productId: string, deviceSn: string }>() +const props = defineProps<{ + buttonText?: string + request: (...args: any[]) => Promise<{ topic: string, message: string }> +}>() -const { state, execute, isLoading } = useAsyncState(() => getReportExample(props.productId, props.deviceSn), undefined, { immediate: false }) +const { state, execute, isLoading } = useAsyncState(props.request, undefined, { immediate: false }) const open = ref(false) function handleOpen() { @@ -29,7 +31,7 @@ const schema: DescItem[] = [ field: 'topic', }, { - label: '上报示例', + label: '内容', field: 'message', render(value) { let content = value @@ -48,7 +50,7 @@ const schema: DescItem[] = [