Commit cb975689122a77f737456b2a882d0c97fa26069d
Merge branch 'perf/template-mode-device-query' into 'main_dev'
Perf/template mode device query See merge request yunteng/thingskit-scada!193
Showing
6 changed files
with
35 additions
and
5 deletions
@@ -24,6 +24,7 @@ export interface ConfigurationContentType { | @@ -24,6 +24,7 @@ export interface ConfigurationContentType { | ||
24 | productIds?: string[] | 24 | productIds?: string[] |
25 | isTemplate?: string | number | 25 | isTemplate?: string | number |
26 | productAndDevice?: ProductAndDevice[] | 26 | productAndDevice?: ProductAndDevice[] |
27 | + templateId?: string | ||
27 | } | 28 | } |
28 | 29 | ||
29 | export interface ConfigurationContentListItemType { | 30 | export interface ConfigurationContentListItemType { |
@@ -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 = '/configuration/center/getListByConfigurationId', | ||
22 | } | 24 | } |
23 | 25 | ||
24 | export interface GenModbusCommandType { | 26 | export interface GenModbusCommandType { |
@@ -132,3 +134,8 @@ export const getDeviceInfo = (deviceId: string) => { | @@ -132,3 +134,8 @@ export const getDeviceInfo = (deviceId: string) => { | ||
132 | ) | 134 | ) |
133 | } | 135 | } |
134 | 136 | ||
137 | +export const getListByConfigurationId = (configurationId: string) => { | ||
138 | + return defHttp.post({ | ||
139 | + url: `${Api.GET_LIST_BY_CONFIGURATION_ID}?configurationId=${configurationId}`, | ||
140 | + }) | ||
141 | +} |
@@ -12,16 +12,20 @@ import { BasicTable, TableAction, useTable } from '@/components/Table' | @@ -12,16 +12,20 @@ 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' |
19 | import { useJsonParse } from '@/hooks/business/useJSONParse' | 19 | import { useJsonParse } from '@/hooks/business/useJSONParse' |
20 | import type { DeviceCommandListItemType, MouseDownEventDataType } from '@/api/node/model' | 20 | import type { DeviceCommandListItemType, MouseDownEventDataType } from '@/api/node/model' |
21 | import type { ProductAndDevice } from '@/api/content/model' | 21 | import type { ProductAndDevice } from '@/api/content/model' |
22 | +import { useParseParams } from '@/core/LoadData' | ||
22 | 23 | ||
23 | const props = defineProps<{ event: EventTypeEnum }>() | 24 | const props = defineProps<{ event: EventTypeEnum }>() |
24 | 25 | ||
26 | +const params = useParseParams() | ||
27 | +const { configurationId } = params | ||
28 | + | ||
25 | const contentDataStore = useContentDataStore() | 29 | const contentDataStore = useContentDataStore() |
26 | const validateTable = ref<boolean>(false) | 30 | const validateTable = ref<boolean>(false) |
27 | 31 | ||
@@ -73,7 +77,7 @@ async function getDeviceList() { | @@ -73,7 +77,7 @@ async function getDeviceList() { | ||
73 | const organizationId = window.useParseParams().organizationId | 77 | const organizationId = window.useParseParams().organizationId |
74 | if (!organizationId) return | 78 | if (!organizationId) return |
75 | const productIds = unref(contentDataStore.getProductIds) | 79 | const productIds = unref(contentDataStore.getProductIds) |
76 | - const result = await getListByDeviceProfileIds({ deviceProfileIds: productIds || [], organizationId }) | 80 | + const result = unref(contentDataStore.getIsTemplateLink) ? await getListByConfigurationId(configurationId!) : await getListByDeviceProfileIds({ deviceProfileIds: productIds || [], organizationId }) |
77 | deviceList.value = result.map(item => ({ | 81 | deviceList.value = result.map(item => ({ |
78 | ...item, | 82 | ...item, |
79 | label: item.alias || item.name, | 83 | 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' |
@@ -7,10 +7,14 @@ import { ContentDataFieldsEnum, ContentDataFieldsNameEnum, DataTypeEnum } from ' | @@ -7,10 +7,14 @@ import { ContentDataFieldsEnum, ContentDataFieldsNameEnum, DataTypeEnum } from ' | ||
7 | import { useContentDataStoreWithOut } from '@/store/modules/contentData' | 7 | import { useContentDataStoreWithOut } from '@/store/modules/contentData' |
8 | import type { ProductAndDevice } from '@/api/content/model' | 8 | import type { ProductAndDevice } from '@/api/content/model' |
9 | import { ControlComponentEnum } from '@/core/Library/packages/Control' | 9 | import { ControlComponentEnum } from '@/core/Library/packages/Control' |
10 | +import { useParseParams } from '@/core/LoadData' | ||
10 | 11 | ||
11 | const contentDataStore = useContentDataStoreWithOut() | 12 | const contentDataStore = useContentDataStoreWithOut() |
12 | export const formSchemas = (componentKey?: string): FormSchema[] => { | 13 | export const formSchemas = (componentKey?: string): FormSchema[] => { |
13 | const isTemplate = contentDataStore.isTemplate // 判断是否是模板组态 | 14 | const isTemplate = contentDataStore.isTemplate // 判断是否是模板组态 |
15 | + const isTemplateLink = contentDataStore.getIsTemplateLink | ||
16 | + const params = useParseParams() | ||
17 | + const { configurationId } = params | ||
14 | return [ | 18 | return [ |
15 | { | 19 | { |
16 | field: ContentDataFieldsEnum.DEVICE_PROFILE_ID, | 20 | field: ContentDataFieldsEnum.DEVICE_PROFILE_ID, |
@@ -47,7 +51,10 @@ export const formSchemas = (componentKey?: string): FormSchema[] => { | @@ -47,7 +51,10 @@ export const formSchemas = (componentKey?: string): FormSchema[] => { | ||
47 | if (!organizationId) return | 51 | if (!organizationId) return |
48 | return { | 52 | return { |
49 | showSearch: true, | 53 | showSearch: true, |
50 | - api: getListByDeviceProfileIds, | 54 | + api: async (params: Recordable) => { |
55 | + if (isTemplateLink) return await getListByConfigurationId(configurationId!) | ||
56 | + return await getListByDeviceProfileIds(params) | ||
57 | + }, | ||
51 | params: { | 58 | params: { |
52 | deviceProfileIds: unref(contentDataStore.getProductIds), | 59 | deviceProfileIds: unref(contentDataStore.getProductIds), |
53 | organizationId, | 60 | organizationId, |
@@ -46,9 +46,10 @@ export function useContentData() { | @@ -46,9 +46,10 @@ export function useContentData() { | ||
46 | const result = mode === PageModeEnum.SHARE ? await shareModeBootstrap() : await getContent() | 46 | const result = mode === PageModeEnum.SHARE ? await shareModeBootstrap() : await getContent() |
47 | 47 | ||
48 | if (result) { | 48 | if (result) { |
49 | - const { productAndDevice, nodelist, isTemplate } = result | 49 | + const { productAndDevice, nodelist, isTemplate, templateId } = result |
50 | if (nodelist) contentDataStore.saveContentData(nodelist) | 50 | if (nodelist) contentDataStore.saveContentData(nodelist) |
51 | if (isTemplate) contentDataStore.setIsTemplate(isTemplate) | 51 | if (isTemplate) contentDataStore.setIsTemplate(isTemplate) |
52 | + if (templateId) contentDataStore.setIsTemplateLink(templateId) | ||
52 | if (productAndDevice) contentDataStore.setProductAndDevice(productAndDevice) | 53 | if (productAndDevice) contentDataStore.setProductAndDevice(productAndDevice) |
53 | } | 54 | } |
54 | return result | 55 | return result |
@@ -23,6 +23,8 @@ interface ContentDataStoreType { | @@ -23,6 +23,8 @@ interface ContentDataStoreType { | ||
23 | diveceDetailMap: Record<string, DeviceList> | 23 | diveceDetailMap: Record<string, DeviceList> |
24 | hasDesignAuth?: boolean | 24 | hasDesignAuth?: boolean |
25 | hasPerviewAuth?: boolean | 25 | hasPerviewAuth?: boolean |
26 | + isTemplateLink?: boolean | ||
27 | + | ||
26 | } | 28 | } |
27 | 29 | ||
28 | export const useContentDataStore = defineStore('app-content-data', { | 30 | export const useContentDataStore = defineStore('app-content-data', { |
@@ -36,6 +38,7 @@ export const useContentDataStore = defineStore('app-content-data', { | @@ -36,6 +38,7 @@ export const useContentDataStore = defineStore('app-content-data', { | ||
36 | diveceDetailMap: {}, | 38 | diveceDetailMap: {}, |
37 | hasDesignAuth: true, | 39 | hasDesignAuth: true, |
38 | hasPerviewAuth: true, | 40 | hasPerviewAuth: true, |
41 | + isTemplateLink: true, | ||
39 | }), | 42 | }), |
40 | actions: { | 43 | actions: { |
41 | 44 | ||
@@ -61,6 +64,10 @@ export const useContentDataStore = defineStore('app-content-data', { | @@ -61,6 +64,10 @@ export const useContentDataStore = defineStore('app-content-data', { | ||
61 | this.isTemplate = string | 64 | this.isTemplate = string |
62 | }, | 65 | }, |
63 | 66 | ||
67 | + setIsTemplateLink(string?: string) { | ||
68 | + this.isTemplateLink = !!string | ||
69 | + }, | ||
70 | + | ||
64 | setProductAndDevice(list: ProductAndDevice[]) { | 71 | setProductAndDevice(list: ProductAndDevice[]) { |
65 | this.productAndDevice = list | 72 | this.productAndDevice = list |
66 | this.doBuildDeviceMap() | 73 | this.doBuildDeviceMap() |
@@ -103,6 +110,9 @@ export const useContentDataStore = defineStore('app-content-data', { | @@ -103,6 +110,9 @@ export const useContentDataStore = defineStore('app-content-data', { | ||
103 | getIsTemplate(): number | null | string | undefined { | 110 | getIsTemplate(): number | null | string | undefined { |
104 | return this.isTemplate | 111 | return this.isTemplate |
105 | }, | 112 | }, |
113 | + getIsTemplateLink(): boolean { | ||
114 | + return !!this.isTemplateLink | ||
115 | + }, | ||
106 | }, | 116 | }, |
107 | }) | 117 | }) |
108 | 118 |