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 @@
+
+
+
+
+
+
reload()" />
+
+ 下发
+
+
+
+
+
+
+
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[] = [
- 查看参数
+ {{ buttonText || '查看参数' }}
diff --git a/src/views/device-manage/device/components/composables/useDeviceInfo.ts b/src/views/device-manage/device/components/composables/useDeviceInfo.ts
index 6340930f..7c431724 100644
--- a/src/views/device-manage/device/components/composables/useDeviceInfo.ts
+++ b/src/views/device-manage/device/components/composables/useDeviceInfo.ts
@@ -3,9 +3,9 @@ import { Tag } from 'ant-design-vue'
import { useRoute } from 'vue-router'
import { useAsyncState } from '@vueuse/core'
import MqttParamsModal from '../MqttParamsModal.vue'
-import ReportExampleModal from '../ReportExampleModal.vue'
+import MessageModal from '../MessageModal.vue'
import type { DescItem } from '@/components/Description'
-import { getDeviceDetail } from '@/api/device-manage/device'
+import { getDeviceDetail, getReportExample } from '@/api/device-manage/device'
import { usePermission } from '@/hooks/web/usePermission'
export function useDeviceInfo() {
@@ -68,9 +68,8 @@ export function useDeviceInfo() {
field: 'report',
label: '上报示例',
show: () => hasPermission('device_report_example'),
- render: () => h(ReportExampleModal, {
- productId: data.value!.productId,
- deviceSn: data.value!.deviceSn,
+ render: () => h(MessageModal, {
+ request: () => getReportExample(data.value!.productId, data.value!.deviceSn),
}),
},
{
diff --git a/src/views/device-manage/device/components/index.ts b/src/views/device-manage/device/components/index.ts
index a8661495..ad99ff8c 100644
--- a/src/views/device-manage/device/components/index.ts
+++ b/src/views/device-manage/device/components/index.ts
@@ -1,2 +1,3 @@
export { default as DeviceInfo } from './DeviceInfo.vue'
export { default as TopicList } from './TopicList.vue'
+export { default as CloudCommand } from './CloudCommand.vue'
diff --git a/src/views/device-manage/device/detail.vue b/src/views/device-manage/device/detail.vue
index ea3cd020..194006a9 100644
--- a/src/views/device-manage/device/detail.vue
+++ b/src/views/device-manage/device/detail.vue
@@ -1,6 +1,6 @@