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[] = [