Browse Source

fix(device): 消息下发参数传递错误

main
刘凯 1 year ago
parent
commit
7ae9ca1624
  1. 3
      src/api/device-manage/device/index.ts
  2. 9
      src/api/product/topic.ts
  3. 2
      src/api/product/types.ts
  4. 6
      src/views/device-manage/device/components/SendCommandModal.vue

3
src/api/device-manage/device/index.ts

@ -1,4 +1,5 @@
import type { Device, DevicePropertie, GetDeviceListParams } from './types' import type { Device, DevicePropertie, GetDeviceListParams } from './types'
import type { Topic } from '@/api/product/types'
import { defHttp } from '@/utils/http/axios' import { defHttp } from '@/utils/http/axios'
export function getDeviceList(params: GetDeviceListParams) { export function getDeviceList(params: GetDeviceListParams) {
@ -51,7 +52,7 @@ export function getDeviceProperties(modelId: string, deviceSn: string) {
} }
export function getDeviceTopicList(params: PageParam & { deviceId: string }) { export function getDeviceTopicList(params: PageParam & { deviceId: string }) {
return defHttp.get({ return defHttp.get<PageResult<Topic>>({
url: '/device/topic/page', url: '/device/topic/page',
params, params,
}) })

9
src/api/product/topic.ts

@ -27,12 +27,3 @@ export function deleteTopic(id: string) {
url: `/product/topic/remove?id=${id}`, url: `/product/topic/remove?id=${id}`,
}) })
} }
export function getAllTopics(productId: string) {
return defHttp.get<Topic[]>({
url: '/product/topic/list',
params: {
productId,
},
})
}

2
src/api/product/types.ts

@ -30,7 +30,7 @@ export enum TopicType {
Custom = 2, Custom = 2,
} }
export interface GetTopicListPrams { export interface GetTopicListPrams extends PageParam {
productId?: string productId?: string
topicCategory?: TopicType topicCategory?: TopicType
} }

6
src/views/device-manage/device/components/SendCommandModal.vue

@ -3,10 +3,10 @@ import { BasicModal, useModalInner } from '@/components/Modal'
import type { FormSchema, FormSchemaInner, Rule } from '@/components/Form' import type { FormSchema, FormSchemaInner, Rule } from '@/components/Form'
import { BasicForm, useForm } from '@/components/Form' import { BasicForm, useForm } from '@/components/Form'
import { CloudCommandType } from '@/api/device-manage/device/types' import { CloudCommandType } from '@/api/device-manage/device/types'
import { getAllTopics } from '@/api/product/topic'
import { sendCommandToDevice, sendMessageToDevice } from '@/api/device-manage/device/cloud-command' import { sendCommandToDevice, sendMessageToDevice } from '@/api/device-manage/device/cloud-command'
import CodeEditor from '@/components/CodeEditor/src/CodeEditor.vue' import CodeEditor from '@/components/CodeEditor/src/CodeEditor.vue'
import { getAllModelAttributes } from '@/api/product/model' import { getAllModelAttributes } from '@/api/product/model'
import { getDeviceTopicList } from '@/api/device-manage/device'
import { ModelAttributeDataTypesEnum, type SimpleAttribute } from '@/api/product/types' import { ModelAttributeDataTypesEnum, type SimpleAttribute } from '@/api/product/types'
import { useMessage } from '@/hooks/web/useMessage' import { useMessage } from '@/hooks/web/useMessage'
@ -109,8 +109,8 @@ const MessageSchemas: FormSchema[] = [
required: true, required: true,
component: 'ApiSelect', component: 'ApiSelect',
componentProps: { componentProps: {
api: () => getAllTopics(productId!), api: async () => (await getDeviceTopicList({ deviceId, current: 1, size: 500 })).records,
valueField: 'id', valueField: 'topic',
labelField: 'topic', labelField: 'topic',
}, },
}, },

Loading…
Cancel
Save