parent
576d6d32f3
commit
dd1d9ccbe6
|
@ -83,7 +83,7 @@
|
||||||
</template>
|
</template>
|
||||||
<template #other="{ data }">
|
<template #other="{ data }">
|
||||||
<j-tooltip
|
<j-tooltip
|
||||||
v-if="target === 'device' && productNoEdit.id?.includes?.(data.record._sortIndex)"
|
v-if="target === 'device' && productNoEdit.id?.includes?.(data.record.id)"
|
||||||
title="继承自产品物模型的数据不支持修改"
|
title="继承自产品物模型的数据不支持修改"
|
||||||
>
|
>
|
||||||
<!-- <ModelButton :disabled="true"/>-->
|
<!-- <ModelButton :disabled="true"/>-->
|
||||||
|
@ -96,9 +96,9 @@
|
||||||
v-else
|
v-else
|
||||||
v-model:value="data.record.expands"
|
v-model:value="data.record.expands"
|
||||||
:id="data.record.id"
|
:id="data.record.id"
|
||||||
:disabled="target === 'device' && productNoEdit.id?.includes?.(data.record._sortIndex)"
|
:disabled="target === 'device' && productNoEdit.id?.includes?.(data.record.id)"
|
||||||
:record="data.record"
|
:record="data.record"
|
||||||
:tooltip="target === 'device' && productNoEdit.id?.includes?.(data.record._sortIndex) ? {
|
:tooltip="target === 'device' && productNoEdit.id?.includes?.(data.record.id) ? {
|
||||||
title: '继承自产品物模型的数据不支持删除',
|
title: '继承自产品物模型的数据不支持删除',
|
||||||
} : undefined"
|
} : undefined"
|
||||||
:type="data.record.valueType.type"
|
:type="data.record.valueType.type"
|
||||||
|
@ -161,12 +161,12 @@
|
||||||
},
|
},
|
||||||
getPopupContainer: getPopupContainer
|
getPopupContainer: getPopupContainer
|
||||||
}"
|
}"
|
||||||
|
:disabled="target === 'device' && productNoEdit.id?.includes?.(data.record.id)"
|
||||||
:tooltip="{
|
:tooltip="{
|
||||||
placement: 'topRight',
|
placement: 'topRight',
|
||||||
getPopupContainer: getPopupContainer,
|
getPopupContainer: getPopupContainer,
|
||||||
title: target === 'device' && productNoEdit.id?.includes?.(data.record._sortIndex) ? '继承自产品物模型的数据不支持删除' :'删除',
|
title: target === 'device' && productNoEdit.id?.includes?.(data.record.id) ? '继承自产品物模型的数据不支持删除' :'删除',
|
||||||
}"
|
}"
|
||||||
:disabled="target === 'device' && productNoEdit.id?.includes?.(data.record._sortIndex)"
|
|
||||||
>
|
>
|
||||||
<AIcon type="DeleteOutlined" />
|
<AIcon type="DeleteOutlined" />
|
||||||
</PermissionButton>
|
</PermissionButton>
|
||||||
|
|
|
@ -136,9 +136,10 @@ export const typeSelectChange = (type: string) => {
|
||||||
return obj
|
return obj
|
||||||
}
|
}
|
||||||
|
|
||||||
const isExtendsProdcut = (index: string, productKeys: string, type: string) => {
|
const isExtendsProduct = (id: string, productKeys: string, type: string) => {
|
||||||
|
if (!id) return false
|
||||||
const vailKeys = productKeys[type] || []
|
const vailKeys = productKeys[type] || []
|
||||||
if (vailKeys.includes(index)) {
|
if (vailKeys.includes(id)) {
|
||||||
onlyMessage('继承自产品物模型的数据不支持修改', 'warning')
|
onlyMessage('继承自产品物模型的数据不支持修改', 'warning')
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -176,11 +177,11 @@ export const useColumns = (type?: MetadataType, target?: 'device' | 'product', n
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
doubleClick(record) {
|
doubleClick(record) {
|
||||||
if (isExtendsProdcut(record._sortIndex, productNoEdit?.value, 'id')) {
|
if (isExtendsProduct(record.id, productNoEdit?.value, 'id')) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
const ids = (noEdit?.value?.id || []) as any[]
|
const ids = (noEdit?.value?.id || []) as any[]
|
||||||
return !ids.includes(record._sortIndex)
|
return !ids.includes(record.id)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -199,7 +200,7 @@ export const useColumns = (type?: MetadataType, target?: 'device' | 'product', n
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
doubleClick(record) {
|
doubleClick(record) {
|
||||||
if (isExtendsProdcut(record._sortIndex, productNoEdit?.value, 'name')) {
|
if (isExtendsProduct(record.id, productNoEdit?.value, 'name')) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
|
@ -219,7 +220,7 @@ export const useColumns = (type?: MetadataType, target?: 'device' | 'product', n
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
doubleClick(record) {
|
doubleClick(record) {
|
||||||
if (isExtendsProdcut(record._sortIndex, productNoEdit?.value, 'expands')) {
|
if (isExtendsProduct(record.id, productNoEdit?.value, 'expands')) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
|
@ -266,7 +267,7 @@ export const useColumns = (type?: MetadataType, target?: 'device' | 'product', n
|
||||||
dataIndex: 'description',
|
dataIndex: 'description',
|
||||||
type: 'text',
|
type: 'text',
|
||||||
doubleClick(record) {
|
doubleClick(record) {
|
||||||
if (isExtendsProdcut(record._sortIndex, productNoEdit?.value, 'description')) {
|
if (isExtendsProduct(record.id, productNoEdit?.value, 'description')) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
|
@ -294,7 +295,7 @@ export const useColumns = (type?: MetadataType, target?: 'device' | 'product', n
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
doubleClick(record) {
|
doubleClick(record) {
|
||||||
return !isExtendsProdcut(record._sortIndex, productNoEdit?.value, 'async');
|
return !isExtendsProduct(record.id, productNoEdit?.value, 'async');
|
||||||
|
|
||||||
},
|
},
|
||||||
control(newValue, oldValue) {
|
control(newValue, oldValue) {
|
||||||
|
@ -349,7 +350,7 @@ export const useColumns = (type?: MetadataType, target?: 'device' | 'product', n
|
||||||
}]
|
}]
|
||||||
},
|
},
|
||||||
doubleClick(record) {
|
doubleClick(record) {
|
||||||
return !isExtendsProdcut(record._sortIndex, productNoEdit?.value, 'output');
|
return !isExtendsProduct(record.id, productNoEdit?.value, 'output');
|
||||||
},
|
},
|
||||||
control(newValue, oldValue) {
|
control(newValue, oldValue) {
|
||||||
if (newValue && !oldValue) {
|
if (newValue && !oldValue) {
|
||||||
|
@ -365,7 +366,7 @@ export const useColumns = (type?: MetadataType, target?: 'device' | 'product', n
|
||||||
dataIndex: 'description',
|
dataIndex: 'description',
|
||||||
type: 'text',
|
type: 'text',
|
||||||
doubleClick(record) {
|
doubleClick(record) {
|
||||||
if (isExtendsProdcut(record._sortIndex, productNoEdit?.value, 'description')) {
|
if (isExtendsProduct(record.id, productNoEdit?.value, 'description')) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
|
@ -404,7 +405,7 @@ export const useColumns = (type?: MetadataType, target?: 'device' | 'product', n
|
||||||
},
|
},
|
||||||
width: 230,
|
width: 230,
|
||||||
doubleClick(record) {
|
doubleClick(record) {
|
||||||
if (isExtendsProdcut(record._sortIndex, productNoEdit?.value, 'valueType')) {
|
if (isExtendsProduct(record.id, productNoEdit?.value, 'valueType')) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
|
@ -425,7 +426,7 @@ export const useColumns = (type?: MetadataType, target?: 'device' | 'product', n
|
||||||
if (record.expands.source === 'rule') {
|
if (record.expands.source === 'rule') {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return !isExtendsProdcut(record._sortIndex, productNoEdit?.value, 'expands')
|
return !isExtendsProduct(record.id, productNoEdit?.value, 'expands')
|
||||||
},
|
},
|
||||||
form: {
|
form: {
|
||||||
required: true,
|
required: true,
|
||||||
|
@ -438,7 +439,6 @@ export const useColumns = (type?: MetadataType, target?: 'device' | 'product', n
|
||||||
const values = dataSource.find((item, index) => index === fieldIndex)
|
const values = dataSource.find((item, index) => index === fieldIndex)
|
||||||
const virtualRule = values.expands?.virtualRule
|
const virtualRule = values.expands?.virtualRule
|
||||||
const source = value.source
|
const source = value.source
|
||||||
const ids = (noEdit?.value?.id || []) as any[]
|
|
||||||
console.log(source, value)
|
console.log(source, value)
|
||||||
if (source) {
|
if (source) {
|
||||||
if (source === 'device' && !value.type?.length) {
|
if (source === 'device' && !value.type?.length) {
|
||||||
|
@ -512,7 +512,7 @@ export const useColumns = (type?: MetadataType, target?: 'device' | 'product', n
|
||||||
}]
|
}]
|
||||||
},
|
},
|
||||||
doubleClick(record) {
|
doubleClick(record) {
|
||||||
if (isExtendsProdcut(record._sortIndex, productNoEdit?.value, 'valueType')) {
|
if (isExtendsProduct(record.id, productNoEdit?.value, 'valueType')) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
|
@ -534,7 +534,7 @@ export const useColumns = (type?: MetadataType, target?: 'device' | 'product', n
|
||||||
name: TagsType
|
name: TagsType
|
||||||
},
|
},
|
||||||
doubleClick(record) {
|
doubleClick(record) {
|
||||||
if (isExtendsProdcut(record._sortIndex, productNoEdit?.value, 'readType')) {
|
if (isExtendsProduct(record.id, productNoEdit?.value, 'readType')) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
|
@ -568,7 +568,7 @@ export const useColumns = (type?: MetadataType, target?: 'device' | 'product', n
|
||||||
dataIndex: 'description',
|
dataIndex: 'description',
|
||||||
type: 'text',
|
type: 'text',
|
||||||
doubleClick(record) {
|
doubleClick(record) {
|
||||||
if (isExtendsProdcut(record._sortIndex, productNoEdit?.value, 'description')) {
|
if (isExtendsProduct(record.id, productNoEdit?.value, 'description')) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
|
|
|
@ -21,50 +21,51 @@ const useMetadata = (type: 'device' | 'product', key?: MetadataType, ): {
|
||||||
|
|
||||||
const handleMetadata = (_metadataStr: string) => {
|
const handleMetadata = (_metadataStr: string) => {
|
||||||
const _metadata = JSON.parse(_metadataStr || '{}')
|
const _metadata = JSON.parse(_metadataStr || '{}')
|
||||||
const newMetadata = (key ? _metadata?.[key] || [] : []) as DeviceMetadata[]
|
const newMetadata = (key ? _metadata?.[key] || [] : []) as any[]
|
||||||
|
|
||||||
|
|
||||||
metadata.value = newMetadata as any
|
metadata.value = newMetadata as any
|
||||||
|
|
||||||
const indexKeys = newMetadata.map((item, index) => index)
|
const ids = newMetadata.map((item) => item.id)
|
||||||
noEdit.value = {}
|
noEdit.value = {}
|
||||||
productNoEdit.value = {}
|
productNoEdit.value = {}
|
||||||
noEdit.value.id = indexKeys
|
noEdit.value.id = ids
|
||||||
|
|
||||||
if (key === 'properties') {
|
if (key === 'properties') {
|
||||||
noEdit.value.source = indexKeys
|
noEdit.value.source = ids
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type === 'device' && instanceCurrent.value.productMetadata) {
|
if (type === 'device' && instanceCurrent.value.productMetadata) {
|
||||||
const productMetadata: any = JSON.parse(instanceCurrent.value.productMetadata)
|
const productMetadata: any = JSON.parse(instanceCurrent.value.productMetadata)
|
||||||
const metaArray = key ? productMetadata[key] : []
|
const metaArray = key ? productMetadata[key] : []
|
||||||
const productIndexKeys = metaArray?.map((item:any, index: number) => index) || []
|
const productIds = metaArray?.map((item:any) => item.id) || []
|
||||||
productNoEdit.value.ids = metaArray?.map((item: any) => item.id) || []
|
// productNoEdit.value.ids = metaArray?.map((item: any) => item.id) || []
|
||||||
productNoEdit.value.id = productIndexKeys
|
productNoEdit.value.ids = productIds
|
||||||
productNoEdit.value.name = productIndexKeys
|
productNoEdit.value.id = productIds
|
||||||
|
productNoEdit.value.name = productIds
|
||||||
if (key === 'properties') {
|
if (key === 'properties') {
|
||||||
productNoEdit.value.valueType = productIndexKeys
|
productNoEdit.value.valueType = productIds
|
||||||
productNoEdit.value.expands = productIndexKeys
|
productNoEdit.value.expands = productIds
|
||||||
}
|
}
|
||||||
|
|
||||||
if (key === 'functions') {
|
if (key === 'functions') {
|
||||||
productNoEdit.value.async = productIndexKeys
|
productNoEdit.value.async = productIds
|
||||||
productNoEdit.value.inputs = productIndexKeys
|
productNoEdit.value.inputs = productIds
|
||||||
productNoEdit.value.output = productIndexKeys
|
productNoEdit.value.output = productIds
|
||||||
productNoEdit.value.description = productIndexKeys
|
productNoEdit.value.description = productIds
|
||||||
}
|
}
|
||||||
|
|
||||||
if (key === 'events') {
|
if (key === 'events') {
|
||||||
productNoEdit.value.expands = productIndexKeys
|
productNoEdit.value.expands = productIds
|
||||||
productNoEdit.value.outInput = productIndexKeys
|
productNoEdit.value.outInput = productIds
|
||||||
productNoEdit.value.properties = productIndexKeys
|
productNoEdit.value.properties = productIds
|
||||||
productNoEdit.value.description = productIndexKeys
|
productNoEdit.value.description = productIds
|
||||||
}
|
}
|
||||||
|
|
||||||
if (key === 'tags') {
|
if (key === 'tags') {
|
||||||
productNoEdit.value.valueType = productIndexKeys
|
productNoEdit.value.valueType = productIds
|
||||||
productNoEdit.value.readType = productIndexKeys
|
productNoEdit.value.readType = productIds
|
||||||
productNoEdit.value.description = productIndexKeys
|
productNoEdit.value.description = productIds
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue