diff --git a/src/api/device/product.ts b/src/api/device/product.ts index 4d34b3ba..d8c10cab 100644 --- a/src/api/device/product.ts +++ b/src/api/device/product.ts @@ -202,3 +202,13 @@ export const getMetadataConfig = (params: { dataType: string; }; }) => server.get[]>(`/device/product/${params.deviceId}/config-metadata/${params.metadata.type}/${params.metadata.id}/${params.metadata.dataType}`) + +export const getMetadataDeviceConfig = (params: { + deviceId: string; + metadata: { + type: MetadataType | 'property'; + id: string; + dataType: string; + }; +}) => server.get[]>(`/device/instance/${params.deviceId}/config-metadata/${params.metadata.type}/${params.metadata.id}/${params.metadata.dataType}`) + diff --git a/src/views/device/components/Metadata/Base/Edit/BaseForm.vue b/src/views/device/components/Metadata/Base/Edit/BaseForm.vue index cf298395..7660b5b7 100644 --- a/src/views/device/components/Metadata/Base/Edit/BaseForm.vue +++ b/src/views/device/components/Metadata/Base/Edit/BaseForm.vue @@ -64,7 +64,8 @@ import { PropType } from 'vue'; import ExpandsForm from './ExpandsForm.vue'; import ValueTypeForm from './ValueTypeForm.vue' import { useProductStore } from '@/store/product'; -import { getMetadataConfig } from '@/api/device/product' +import { useInstanceStore } from'@/store/instance' +import { getMetadataConfig, getMetadataDeviceConfig } from '@/api/device/product' import JsonParam from '@/components/Metadata/JsonParam/index.vue' import { EventLevel, ExpandsTypeList } from '@/views/device/data'; import { useMetadataStore } from '@/store/metadata'; @@ -97,22 +98,24 @@ if (props.modelType === 'events' || props.modelType === 'tags') { } const productStore = useProductStore() +const deviceStore = useInstanceStore() const config = ref[]>([]) const asyncOtherConfig = debounce(async () => { - if (props.type !== 'product') return + const { valueType, id } = props.value const { type } = valueType || {} - const productId = productStore.current?.id + const productId = props.type === 'product' ? productStore.current?.id : deviceStore.current.id if (!productId || !id || !type) return - const resp = await getMetadataConfig({ + const params: any = { deviceId: productId, metadata: { id, type: 'property', dataType: type, }, - }) + } + const resp = props.type === 'product' ? await getMetadataConfig(params) : await getMetadataDeviceConfig(params) if (resp.status === 200) { config.value = resp.result } diff --git a/yarn.lock b/yarn.lock index 35c00ff5..dd3db463 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3823,10 +3823,10 @@ jetlinks-store@^0.0.3: resolved "https://registry.npmjs.org/jetlinks-store/-/jetlinks-store-0.0.3.tgz" integrity sha512-AZf/soh1hmmwjBZ00fr1emuMEydeReaI6IBTGByQYhTmK1Zd5pQAxC7WLek2snRAn/HHDgJfVz2hjditKThl6Q== -jetlinks-ui-components@^1.0.16: - version "1.0.16" - resolved "https://registry.jetlinks.cn/jetlinks-ui-components/-/jetlinks-ui-components-1.0.16.tgz#bdb65385a30a121065322e5156c13080c8328080" - integrity sha512-R3oE8tpXW4oaNSCeGXRK++paNJiHYDO89Id3YqzIVX6/bWMItOWrEU6JT4iPA9uYkPTfsYHxnG5qZRloLnpiZw== +jetlinks-ui-components@^1.0.18: + version "1.0.20" + resolved "https://registry.jetlinks.cn/jetlinks-ui-components/-/jetlinks-ui-components-1.0.20.tgz#ca8df39e35e99cf0e124029609a8fc25f7f97b24" + integrity sha512-McGHwvkwEKrb1Bp9EZzpQN3YQe790fkO0Z03pGsil+bZrZ7xqiEywESZtW3MIIRWo/6u+zwNQr4L4/ohvXRCpA== dependencies: "@vueuse/core" "^9.12.0" "@vueuse/router" "^9.13.0"