Commit 0686d4eaa612770617276e0496d9ddda9f326fba

Authored by loveumiko
1 parent 5cfe086b

wip: 新增通过组态id查询设备列表接口

... ... @@ -19,6 +19,8 @@ enum Api {
19 19
20 20 GEN_MODBUS_COMMAND = '/js/modbus',
21 21 GET_DEVICE_DETAIL = '/device/', // 获取设备详情
  22 +
  23 + GET_LIST_BY_CONFIGURATION_ID = '/getListByConfigurationId',
22 24 }
23 25
24 26 export interface GenModbusCommandType {
... ... @@ -132,3 +134,9 @@ export const getDeviceInfo = (deviceId: string) => {
132 134 )
133 135 }
134 136
  137 +export const getListByConfigurationId = (configurationId: string) => {
  138 + return defHttp.get({
  139 + url: Api.GET_LIST_BY_CONFIGURATION_ID,
  140 + params: { configurationId },
  141 + })
  142 +}
... ...
... ... @@ -12,7 +12,7 @@ import { BasicTable, TableAction, useTable } from '@/components/Table'
12 12 import type { EventTypeEnum } from '@/enums/datasource'
13 13 import { CommandWayEnum, CommandWayNameEnum } from '@/enums/commandEnum'
14 14 import { buildUUID } from '@/utils/uuid'
15   -import { getListByDeviceProfileIds } from '@/api/device'
  15 +import { getListByConfigurationId, getListByDeviceProfileIds } from '@/api/device'
16 16 import { useModal } from '@/components/Modal'
17 17 import type { DeviceItemType } from '@/api/device/model'
18 18 import { useContentDataStore } from '@/store/modules/contentData'
... ... @@ -73,7 +73,7 @@ async function getDeviceList() {
73 73 const organizationId = window.useParseParams().organizationId
74 74 if (!organizationId) return
75 75 const productIds = unref(contentDataStore.getProductIds)
76   - const result = unref(contentDataStore.getIsTemplateLink) ? [] : await getListByDeviceProfileIds({ deviceProfileIds: productIds || [], organizationId })
  76 + const result = unref(contentDataStore.getIsTemplateLink) ? await getListByConfigurationId(unref(contentDataStore.configurationId)!) : await getListByDeviceProfileIds({ deviceProfileIds: productIds || [], organizationId })
77 77 deviceList.value = result.map(item => ({
78 78 ...item,
79 79 label: item.alias || item.name,
... ...
1 1 import { toRaw, unref } from 'vue'
2   -import { getDeviceAttributes, getListByDeviceProfileIds } from '@/api/device'
  2 +import { getDeviceAttributes, getListByConfigurationId, getListByDeviceProfileIds } from '@/api/device'
3 3 import type { DeviceItemType, ThingsModelItemType } from '@/api/device/model'
4 4 import type { FormSchema } from '@/components/Form'
5 5 import { ComponentEnum } from '@/components/Form/src/enum'
... ... @@ -12,6 +12,7 @@ const contentDataStore = useContentDataStoreWithOut()
12 12 export const formSchemas = (componentKey?: string): FormSchema[] => {
13 13 const isTemplate = contentDataStore.isTemplate // 判断是否是模板组态
14 14 const isTemplateLink = contentDataStore.getIsTemplateLink
  15 + const configurationId = contentDataStore.configurationId
15 16 return [
16 17 {
17 18 field: ContentDataFieldsEnum.DEVICE_PROFILE_ID,
... ... @@ -49,7 +50,7 @@ export const formSchemas = (componentKey?: string): FormSchema[] => {
49 50 return {
50 51 showSearch: true,
51 52 api: async (params: Recordable) => {
52   - if (isTemplateLink) return []
  53 + if (isTemplateLink) return await getListByConfigurationId(configurationId!)
53 54 return await getListByDeviceProfileIds(params)
54 55 },
55 56 params: {
... ...