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

View File

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

View File

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