7 changed files with 116 additions and 13 deletions
@ -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, |
||||
}, |
||||
}) |
||||
} |
@ -0,0 +1,79 @@
|
||||
<script lang="ts" setup> |
||||
import { computed, h, ref } from 'vue' |
||||
import { CloudSyncOutlined } from '@ant-design/icons-vue' |
||||
import { Alert, Segmented } from 'ant-design-vue' |
||||
import MessageModal from './MessageModal.vue' |
||||
import { BasicTable, useTable } from '@/components/Table' |
||||
import { getCloudCommandLogs, getMessageContent } from '@/api/device-manage/device/cloud-command' |
||||
|
||||
const commandTypes = [ |
||||
{ |
||||
label: '命令下发', |
||||
value: 2, |
||||
desc: '如果设备所属产品定义了命令功能,则您可以通过应用调用平台接口或者操作 “下发” 按钮下发命令,当前MQTT设备仅支持同步命令下发,NB设备仅支持异步命令下发。', |
||||
}, |
||||
{ |
||||
label: '属性下发', |
||||
value: 1, |
||||
desc: '属性下发依赖产品模型,平台会以异步方式(属性下发后无需等待设备侧回复相应)下发消息给设备,当前仅MQTT设备支持属性下发。', |
||||
}, |
||||
{ |
||||
label: '消息下发', |
||||
value: 3, |
||||
desc: '消息下发不依赖产品模型,平台会以异步方式(消息下发后无需等待设备侧回复相应)下发消息给设备,当前仅MQTT设备支持消息下发。', |
||||
}, |
||||
] |
||||
const currentCommandType = ref(2) |
||||
const currentCommandTypeDesc = computed(() => commandTypes.find(item => item.value === currentCommandType.value)?.desc) |
||||
|
||||
const [register, { reload }] = useTable({ |
||||
api: params => getCloudCommandLogs({ ...params, messageType: currentCommandType.value }), |
||||
columns: [ |
||||
{ |
||||
title: '追踪 ID', |
||||
dataIndex: 'traceId', |
||||
}, |
||||
{ |
||||
title: '内容', |
||||
width: 200, |
||||
dataIndex: 'messageId', |
||||
customRender({ value }) { |
||||
return value && h(MessageModal, { |
||||
buttonText: '查看', |
||||
request: () => getMessageContent(value), |
||||
}) |
||||
}, |
||||
}, |
||||
{ |
||||
title: '主题', |
||||
dataIndex: 't', |
||||
}, |
||||
{ |
||||
title: '创建时间', |
||||
dataIndex: 'createTime', |
||||
}, |
||||
], |
||||
bordered: true, |
||||
inset: true, |
||||
canResize: false, |
||||
}) |
||||
</script> |
||||
|
||||
<template> |
||||
<div> |
||||
<div flex="~ items-center gap-12px" mb="12px"> |
||||
<Segmented v-model:value="currentCommandType" :options="commandTypes" @change="() => reload()" /> |
||||
<a-button type="primary"> |
||||
<CloudSyncOutlined />下发 |
||||
</a-button> |
||||
<Alert |
||||
type="info" |
||||
show-icon |
||||
class="py-4px text-13px" |
||||
:message="currentCommandTypeDesc" |
||||
/> |
||||
</div> |
||||
|
||||
<BasicTable @register="register" /> |
||||
</div> |
||||
</template> |
@ -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' |
||||
|
Loading…
Reference in new issue