feat: 物模型-功能定义、事件定义添加【其它配置】

feat: 物模型-功能定义、事件定义添加【其它配置】
This commit is contained in:
XieYongHong 2024-05-31 17:15:18 +08:00 committed by GitHub
parent 251c7b982b
commit e3cc42c747
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 55 additions and 5 deletions

View File

@ -125,8 +125,9 @@
:id="data.record.id" :id="data.record.id"
:disabled="target === 'device' && productNoEdit.id?.includes?.(data.record.id)" :disabled="target === 'device' && productNoEdit.id?.includes?.(data.record.id)"
:record="data.record" :record="data.record"
:type="data.record.valueType.type" :type="type === 'properties' ? data.record.valueType?.type : 'object'"
:has-permission="`${permission}:update`" :has-permission="`${permission}:update`"
:medataType="type"
:tooltip="target === 'device' && productNoEdit.id?.includes?.(data.record.id) ? { :tooltip="target === 'device' && productNoEdit.id?.includes?.(data.record.id) ? {
title: '继承自产品物模型的数据不支持删除', title: '继承自产品物模型的数据不支持删除',
} : undefined" } : undefined"

View File

@ -277,6 +277,23 @@ export const useColumns = (type?: MetadataType, target?: 'device' | 'product', n
return false return false
}, },
}, },
{
title: '其它配置',
dataIndex: 'other',
width: 100,
control(newValue, oldValue) {
if (!oldValue) {
return true
} else if (newValue && oldValue) {
// 仅留下存储和指标值
const keys = ['source', 'type', 'virtualRule', 'required']
const newObj = omit(cloneDeep(newValue.expands), keys)
const oldObj = omit(cloneDeep(oldValue.expands), keys)
return JSON.stringify(newObj) !== JSON.stringify(oldObj)
}
return false
},
},
{ {
title: '说明', title: '说明',
dataIndex: 'description', dataIndex: 'description',
@ -379,6 +396,23 @@ export const useColumns = (type?: MetadataType, target?: 'device' | 'product', n
return false return false
}, },
}, },
{
title: '其它配置',
dataIndex: 'other',
width: 100,
control(newValue, oldValue) {
if (!oldValue) {
return true
} else if (newValue && oldValue) {
// 仅留下存储和指标值
const keys = ['source', 'type', 'virtualRule', 'required']
const newObj = omit(cloneDeep(newValue.expands), keys)
const oldObj = omit(cloneDeep(oldValue.expands), keys)
return JSON.stringify(newObj) !== JSON.stringify(oldObj)
}
return false
},
},
{ {
title: '说明', title: '说明',
dataIndex: 'description', dataIndex: 'description',

View File

@ -131,6 +131,10 @@ const props = defineProps({
type: Object, type: Object,
default: () => ({}), default: () => ({}),
}, },
medataType: {
type: String,
default: undefined
},
hasPermission: String, hasPermission: String,
tooltip: Object, tooltip: Object,
}); });
@ -189,10 +193,20 @@ const columns = ref([
}, },
]); ]);
const getType = () => {
const _typeMap = {
'propertys': 'property',
'functions': 'function',
'events': 'event',
'tags': 'tag',
}
return _typeMap[props.type] || 'property'
}
const getConfig = async () => { const getConfig = async () => {
const id = const id =
type === 'product' ? productStore.current?.id : deviceStore.current.id; type === 'product' ? productStore.current?.id : deviceStore.current.id;
console.log(props.id, id, props);
if (!props.id || !id || !props.type) return; if (!props.id || !id || !props.type) return;
@ -212,7 +226,7 @@ const getConfig = async () => {
deviceId: id, deviceId: id,
metadata: { metadata: {
id: props.id, id: props.id,
type: 'property', type: getType(),
dataType: props.type, dataType: props.type,
}, },
}; };
@ -267,6 +281,7 @@ const confirm = () => {
const visibleChange = (e: boolean) => { const visibleChange = (e: boolean) => {
visible.value = e; visible.value = e;
console.log('visibleChange',e)
if (e) { if (e) {
configValue.value = omit(props.value, [ configValue.value = omit(props.value, [
'source', 'source',

View File

@ -135,7 +135,7 @@ const hideVirtualRule = (metadata: string) => {
const _metadata = JSON.parse(metadata || '{}') const _metadata = JSON.parse(metadata || '{}')
if (_metadata.properties) { if (_metadata.properties) {
_metadata.properties = _metadata.properties.map((item: any) => { _metadata.properties = _metadata.properties.map((item: any) => {
if (item.expands.virtualRule) { if (item.expands?.virtualRule) {
item.expands = cloneDeep(omit(item.expands, ['virtualRule'])) item.expands = cloneDeep(omit(item.expands, ['virtualRule']))
} }
return item return item