fix: 优化插件映射传参
This commit is contained in:
parent
c2ad03d526
commit
5dcba5e4aa
|
@ -21,6 +21,13 @@ export const detail = (id: string) => get(`/plugin/driver/${id}`)
|
|||
*/
|
||||
export const getProductsById = (id: string) => get(`/plugin/driver/${id}/products`)
|
||||
|
||||
/**
|
||||
*
|
||||
* @param type product:产品;device:设备
|
||||
* @param pluginId 设备接入id
|
||||
* @param internalId 产品或者设备id
|
||||
* @param externalId 映射id
|
||||
*/
|
||||
export const savePluginData = (type: string, pluginId: string, internalId: string, externalId: string ) => patch(`/plugin/mapping/${type}/${pluginId}/${internalId}`, externalId, { headers: {'Content-Type': "text/plain"}})
|
||||
|
||||
export const getPluginData = (type: string, pluginId: string, internalId: string ) => get(`/plugin/mapping/${type}/${pluginId}/${internalId}`)
|
||||
|
|
|
@ -30,10 +30,6 @@ const props = defineProps({
|
|||
type: String,
|
||||
default: undefined
|
||||
},
|
||||
channelId: {
|
||||
type: String,
|
||||
default: undefined
|
||||
},
|
||||
id: {
|
||||
type: String,
|
||||
default: undefined
|
||||
|
@ -49,7 +45,7 @@ const handleOk = async () => {
|
|||
if (checkKey.value) {
|
||||
const res = await savePluginData(
|
||||
'device',
|
||||
props.channelId!,
|
||||
props.accessId!,
|
||||
route.params.id as string,
|
||||
checkKey.value
|
||||
).catch(() => ({ success: false }))
|
||||
|
|
|
@ -110,7 +110,6 @@
|
|||
<InkingModal
|
||||
v-if='inkingVisible'
|
||||
:id='inklingDeviceId'
|
||||
:channelId='channelId'
|
||||
:accessId='instanceStore.current.accessId'
|
||||
@cancel="inkingVisible = false"
|
||||
@submit='saveInkling'
|
||||
|
@ -158,7 +157,7 @@ const queryInkling = () => {
|
|||
queryPluginAccessDetail(instanceStore.current?.accessId).then(async res => {
|
||||
if (res.success) {
|
||||
channelId.value = res.result.channelId
|
||||
const pluginRes = await getPluginData('device', res.result.channelId, instanceStore.current?.id)
|
||||
const pluginRes = await getPluginData('device',instanceStore.current?.accessId, instanceStore.current?.id)
|
||||
if (pluginRes.success) {
|
||||
inklingDeviceId.value = pluginRes.result?.externalId
|
||||
}
|
||||
|
|
|
@ -680,7 +680,7 @@ const getData = async (accessId?: string) => {
|
|||
if (productStore.current?.accessProvider === 'plugin_gateway') {
|
||||
queryPluginAccessDetail(_accessId).then(async res => { //
|
||||
if (res.success) {
|
||||
const pluginRes = await getPluginData('product', res.result.channelId, productStore.current?.id)
|
||||
const pluginRes = await getPluginData('product', _accessId, productStore.current?.id)
|
||||
const resp = await getProductByPluginId(res.result.channelId).catch(() => ({ success: false, result: []}))
|
||||
if (resp.success) {
|
||||
productTypes.value = resp.result.map(item => {
|
||||
|
@ -761,7 +761,7 @@ const updateAccessData = async (id: string, values: any) => {
|
|||
if (access.value?.provider === "plugin_gateway") {
|
||||
await savePluginData(
|
||||
'product',
|
||||
access.value?.channelId,
|
||||
access.value?.id,
|
||||
productStore.current.id,
|
||||
productData.id
|
||||
).catch(() => ({}))
|
||||
|
|
|
@ -136,7 +136,7 @@ const updateAccessData = async (id: string, values: any, metadata: string) => {
|
|||
if (props.access?.provider === 'plugin_gateway') {
|
||||
await savePluginData(
|
||||
'product',
|
||||
props.access.channelId,
|
||||
props.access.id,
|
||||
props.data.id,
|
||||
props.data.productTypeId
|
||||
).catch(() => ({}))
|
||||
|
|
|
@ -124,7 +124,6 @@ const getMetadataMapData = () => {
|
|||
}
|
||||
|
||||
const search = (value: string) => {
|
||||
console.log(value)
|
||||
if (value) {
|
||||
dataSource.value = dataSourceCache.value.filter((item: any) => {
|
||||
return !!item.name?.includes(value)
|
||||
|
@ -161,7 +160,7 @@ const getPluginMetadata = (): Promise<{ properties: any[]}> => {
|
|||
queryPluginAccessDetail(productDetail.value?.accessId!).then(async res => {
|
||||
if (res.success) {
|
||||
const _channelId = (res.result as any)!.channelId
|
||||
const pluginRes = await getPluginData('product', _channelId, productDetail.value?.id).catch(() => ({ success: false, result: {}}))
|
||||
const pluginRes = await getPluginData('product', productDetail.value?.accessId, productDetail.value?.id).catch(() => ({ success: false, result: {}}))
|
||||
const resp = await getProductByPluginId(_channelId).catch(() => ({ success: false, result: []}))
|
||||
if (resp.success) {
|
||||
const _item = (resp.result as any[])?.find((item: any) => item.id === (pluginRes?.result as any)?.externalId)
|
||||
|
|
Loading…
Reference in New Issue