Commit 0686d4eaa612770617276e0496d9ddda9f326fba

Authored by loveumiko
1 parent 5cfe086b

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

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