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
| ... | ... | @@ -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 = '/configuration/center/getListByConfigurationId', | |
| 22 | 24 | } |
| 23 | 25 | |
| 24 | 26 | export interface GenModbusCommandType { |
| ... | ... | @@ -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 | 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' |
| 19 | 19 | import { useJsonParse } from '@/hooks/business/useJSONParse' |
| 20 | 20 | import type { DeviceCommandListItemType, MouseDownEventDataType } from '@/api/node/model' |
| 21 | 21 | import type { ProductAndDevice } from '@/api/content/model' |
| 22 | +import { useParseParams } from '@/core/LoadData' | |
| 22 | 23 | |
| 23 | 24 | const props = defineProps<{ event: EventTypeEnum }>() |
| 24 | 25 | |
| 26 | +const params = useParseParams() | |
| 27 | +const { configurationId } = params | |
| 28 | + | |
| 25 | 29 | const contentDataStore = useContentDataStore() |
| 26 | 30 | const validateTable = ref<boolean>(false) |
| 27 | 31 | |
| ... | ... | @@ -73,7 +77,7 @@ async function getDeviceList() { |
| 73 | 77 | const organizationId = window.useParseParams().organizationId |
| 74 | 78 | if (!organizationId) return |
| 75 | 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 | 81 | deviceList.value = result.map(item => ({ |
| 78 | 82 | ...item, |
| 79 | 83 | 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' |
| ... | ... | @@ -7,10 +7,14 @@ import { ContentDataFieldsEnum, ContentDataFieldsNameEnum, DataTypeEnum } from ' |
| 7 | 7 | import { useContentDataStoreWithOut } from '@/store/modules/contentData' |
| 8 | 8 | import type { ProductAndDevice } from '@/api/content/model' |
| 9 | 9 | import { ControlComponentEnum } from '@/core/Library/packages/Control' |
| 10 | +import { useParseParams } from '@/core/LoadData' | |
| 10 | 11 | |
| 11 | 12 | const contentDataStore = useContentDataStoreWithOut() |
| 12 | 13 | export const formSchemas = (componentKey?: string): FormSchema[] => { |
| 13 | 14 | const isTemplate = contentDataStore.isTemplate // 判断是否是模板组态 |
| 15 | + const isTemplateLink = contentDataStore.getIsTemplateLink | |
| 16 | + const params = useParseParams() | |
| 17 | + const { configurationId } = params | |
| 14 | 18 | return [ |
| 15 | 19 | { |
| 16 | 20 | field: ContentDataFieldsEnum.DEVICE_PROFILE_ID, |
| ... | ... | @@ -47,7 +51,10 @@ export const formSchemas = (componentKey?: string): FormSchema[] => { |
| 47 | 51 | if (!organizationId) return |
| 48 | 52 | return { |
| 49 | 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 | 58 | params: { |
| 52 | 59 | deviceProfileIds: unref(contentDataStore.getProductIds), |
| 53 | 60 | organizationId, | ... | ... |
| ... | ... | @@ -46,9 +46,10 @@ export function useContentData() { |
| 46 | 46 | const result = mode === PageModeEnum.SHARE ? await shareModeBootstrap() : await getContent() |
| 47 | 47 | |
| 48 | 48 | if (result) { |
| 49 | - const { productAndDevice, nodelist, isTemplate } = result | |
| 49 | + const { productAndDevice, nodelist, isTemplate, templateId } = result | |
| 50 | 50 | if (nodelist) contentDataStore.saveContentData(nodelist) |
| 51 | 51 | if (isTemplate) contentDataStore.setIsTemplate(isTemplate) |
| 52 | + if (templateId) contentDataStore.setIsTemplateLink(templateId) | |
| 52 | 53 | if (productAndDevice) contentDataStore.setProductAndDevice(productAndDevice) |
| 53 | 54 | } |
| 54 | 55 | return result | ... | ... |
| ... | ... | @@ -23,6 +23,8 @@ interface ContentDataStoreType { |
| 23 | 23 | diveceDetailMap: Record<string, DeviceList> |
| 24 | 24 | hasDesignAuth?: boolean |
| 25 | 25 | hasPerviewAuth?: boolean |
| 26 | + isTemplateLink?: boolean | |
| 27 | + | |
| 26 | 28 | } |
| 27 | 29 | |
| 28 | 30 | export const useContentDataStore = defineStore('app-content-data', { |
| ... | ... | @@ -36,6 +38,7 @@ export const useContentDataStore = defineStore('app-content-data', { |
| 36 | 38 | diveceDetailMap: {}, |
| 37 | 39 | hasDesignAuth: true, |
| 38 | 40 | hasPerviewAuth: true, |
| 41 | + isTemplateLink: true, | |
| 39 | 42 | }), |
| 40 | 43 | actions: { |
| 41 | 44 | |
| ... | ... | @@ -61,6 +64,10 @@ export const useContentDataStore = defineStore('app-content-data', { |
| 61 | 64 | this.isTemplate = string |
| 62 | 65 | }, |
| 63 | 66 | |
| 67 | + setIsTemplateLink(string?: string) { | |
| 68 | + this.isTemplateLink = !!string | |
| 69 | + }, | |
| 70 | + | |
| 64 | 71 | setProductAndDevice(list: ProductAndDevice[]) { |
| 65 | 72 | this.productAndDevice = list |
| 66 | 73 | this.doBuildDeviceMap() |
| ... | ... | @@ -103,6 +110,9 @@ export const useContentDataStore = defineStore('app-content-data', { |
| 103 | 110 | getIsTemplate(): number | null | string | undefined { |
| 104 | 111 | return this.isTemplate |
| 105 | 112 | }, |
| 113 | + getIsTemplateLink(): boolean { | |
| 114 | + return !!this.isTemplateLink | |
| 115 | + }, | |
| 106 | 116 | }, |
| 107 | 117 | }) |
| 108 | 118 | ... | ... |