fix: bug#16436

This commit is contained in:
XieYongHong 2023-07-16 00:01:42 +08:00
parent be7b1bd283
commit 89b4fbdbfe
3 changed files with 24 additions and 13 deletions

View File

@ -77,7 +77,7 @@ const monacoValue = ref()
const handleExport = async () => {
try {
downloadObject(
JSON.parse(value.value),
JSON.parse(monacoValue.value),
`${props.type === 'device'
? instanceStore.current?.name
: productStore.current?.name
@ -92,6 +92,7 @@ const handleExport = async () => {
const handleConvertMetadata = (key: Key) => {
if (key === 'alink') {
value.value = '';
monacoValue.value = '';
if (metadata) {
convertMetadata('to', 'alink', JSON.parse(metadata.value)).then(res => {
if (res.status === 200) {
@ -158,12 +159,14 @@ watch(
loading.value = false
instanceStore.setCurrent(resp.result)
value.value = resp.result.metadata
hideVirtualRule(resp.result.metadata)
});
} else {
productDetail(id as string).then((resp) => {
loading.value = false
productStore.setCurrent(resp.result)
value.value = resp.result.metadata
hideVirtualRule(resp.result.metadata)
});
}
}

View File

@ -199,7 +199,7 @@ const operateLimits = (mdata: DeviceMetadata) => {
return { ...item, sortsIndex: index };
});
(obj?.properties || []).map((item, index) => {
if (item.expands?.virtualRule) {
if (item.expands?.source === 'rule') {
hasVirtualRule.value = true
item.expands = omit(item.expands, ['virtualRule'])
}
@ -275,10 +275,12 @@ const handleImport = async () => {
if (resp.success) {
onlyMessage('导入成功')
if (hasVirtualRule.value) {
Modal.info({
title: '导入数据存在虚拟属性,请及时添加虚拟属性计算规则。',
okText: '确认'
})
setTimeout(() => {
Modal.info({
title: '导入数据存在虚拟属性,请及时添加虚拟属性计算规则。',
okText: '确认'
})
}, 300)
}
}
if (props?.type === 'device') {

View File

@ -47,7 +47,8 @@ const formTouchOff = () => {
*/
const checkDeviceDelete = async () => {
const item = _data.value.branches![props.branchesName].then[props.thenName].actions[props.name].device
const proResp = await queryProductList({ terms: [{ terms: [{ column: 'id', termType: 'eq', value: item!.productId }]}]})
const proResp = await queryProductList({ terms: [{ column: 'id', termType: 'eq', value: item!.productId }]})
if (proResp.success && (proResp.result as any)?.total === 0 && item && item.productId) { //
_data.value.branches![props.branchesName].then[props.thenName].actions[props.name].device!.productId = undefined
formTouchOff()
@ -56,6 +57,7 @@ const checkDeviceDelete = async () => {
const productDetail = proResp?.result?.data?.[0]
let metadata = JSON.parse(productDetail?.metadata || '{}')
if (item?.selector === 'fixed') {
let hasDevice = false
if (item!.selectorValues) {
@ -136,9 +138,11 @@ const checkDeviceDelete = async () => {
}
}
if (item!.message!.messageType === 'READ_PROPERTY') {
if (item!.message!.messageType === 'READ_PROPERTY' && item!.message!.properties && metadata.properties) {
let hasProperties = false
if (item!.message!.properties && metadata.properties.length) {
console.log('checkDeviceDelete',item!.message!.properties, metadata)
if (item!.message!.properties && metadata.properties?.length) {
const propertiesKey = item!.message!.properties?.[0]
hasProperties = metadata.properties?.some((item: any) => item.id === propertiesKey)
}
@ -150,11 +154,11 @@ const checkDeviceDelete = async () => {
}
}
if (item!.message!.messageType === 'WRITE_PROPERTY') {
console.log('WRITE_PROPERTY',item, metadata)
if (item!.message!.messageType === 'WRITE_PROPERTY' && item!.message!.properties && metadata.properties) {
let hasProperties = false
const propertiesKey = Object.keys(item!.message!.properties!)?.[0]
if (item!.message!.properties && metadata.properties.length) {
if (item!.message!.properties && metadata.properties?.length) {
hasProperties = metadata.properties?.some((item: any) => item.id === propertiesKey)
}
if (!hasProperties) {
@ -165,6 +169,7 @@ const checkDeviceDelete = async () => {
}
// -
const _value = item!.message!.properties?.[propertiesKey]
console.log('WRITE_PROPERTY',_value)
if(_value.source === 'upper') {
const _params = {
branch: props.thenName,
@ -181,7 +186,7 @@ const checkDeviceDelete = async () => {
}
}
if (item!.message!.messageType === 'INVOKE_FUNCTION') {
if (item!.message!.messageType === 'INVOKE_FUNCTION' && item!.message!.functionId && metadata.functions) {
const functionId = item!.message!.functionId
let hasFunctions = false
if (functionId && metadata.functions.length) {
@ -315,6 +320,7 @@ const checkNoticeDelete = async () => {
const check = () => {
const _executor = _data.value.branches![props.branchesName].then[props.thenName].actions[props.name]?.executor
console.log('check', _executor)
if (_executor === 'device' && _data.value.branches![props.branchesName].then[props.thenName].actions[props.name]?.device) { //
checkDeviceDelete()
} else if (_executor === 'notify' && _data.value.branches![props.branchesName].then[props.thenName].actions[props.name]?.notify) {