fix: 修改物模型规则调试

This commit is contained in:
wangshuaiswim 2023-03-09 17:39:17 +08:00
parent e7630bc7e2
commit 9cd78db1f6
1 changed files with 26 additions and 13 deletions

View File

@ -15,7 +15,7 @@
<a-table :columns="columns" :data-source="property" :pagination="false" bordered size="small"> <a-table :columns="columns" :data-source="property" :pagination="false" bordered size="small">
<template #bodyCell="{ column, record, index }"> <template #bodyCell="{ column, record, index }">
<template v-if="column.key === 'id'"> <template v-if="column.key === 'id'">
<a-input v-model:value="record.id" size="small"></a-input> <j-auto-complete :options="options" v-model:value="record.id" size="small" width="130px"/>
</template> </template>
<template v-if="column.key === 'current'"> <template v-if="column.key === 'current'">
<a-input v-model:value="record.current" size="small"></a-input> <a-input v-model:value="record.current" size="small"></a-input>
@ -58,8 +58,8 @@
</div> </div>
<div class="log"> <div class="log">
<a-descriptions> <a-descriptions>
<a-descriptions-item v-for="item in ruleEditorStore.state.log" :label="moment(item.time).format('HH:mm:ss')" :key="item.time" <a-descriptions-item v-for="item in ruleEditorStore.state.log" :label="moment(item.time).format('HH:mm:ss')"
:span="3"> :key="item.time" :span="3">
<a-tooltip placement="top" :title="item.content"> <a-tooltip placement="top" :title="item.content">
{{ item.content }} {{ item.content }}
</a-tooltip> </a-tooltip>
@ -78,6 +78,7 @@ import { message } from 'ant-design-vue';
import { useRuleEditorStore } from '@/store/ruleEditor'; import { useRuleEditorStore } from '@/store/ruleEditor';
import moment from 'moment'; import moment from 'moment';
import { getWebSocket } from '@/utils/websocket'; import { getWebSocket } from '@/utils/websocket';
import { PropertyMetadata } from '@/views/device/Product/typings';
const props = defineProps({ const props = defineProps({
@ -143,17 +144,17 @@ const runScript = () => {
return; return;
} }
ws.value = getWebSocket(`virtual-property-debug-${props.id}-${new Date().getTime()}`, ws.value = getWebSocket(`virtual-property-debug-${props.id}-${new Date().getTime()}`,
'/virtual-property-debug', '/virtual-property-debug',
{ {
virtualId: `${virtualIdRef.value}-virtual-id`, virtualId: `${virtualIdRef.value}-virtual-id`,
property: props.id, property: props.id,
virtualRule: { virtualRule: {
...props.virtualRule, ...props.virtualRule,
}, },
properties: _properties || [], properties: _properties || [],
}) })
ws.value.subscribe((data: any) => { ws.value.subscribe((data: any) => {
ruleEditorStore.state.log.push({ time: new Date().getTime(), content: JSON.stringify(data.payload) }); ruleEditorStore.state.log.push({ time: new Date().getTime(), content: JSON.stringify(data.payload) });
}) })
} }
const beginAction = () => { const beginAction = () => {
@ -175,6 +176,18 @@ onUnmounted(() => {
ws.value.unsubscribe?.(); ws.value.unsubscribe?.();
} }
}) })
const options = ref<{ label: string, value: string }[]>()
const getProperty = () => {
const metadata = productStore.current.metadata || '{}';
const _p: PropertyMetadata[] = JSON.parse(metadata).properties || [];
options.value = _p.filter((p) => p.id !== props.id).map((item) => ({
label: item.name,
value: item.id,
}));
console.log(options.value)
}
getProperty()
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>
.debug-container { .debug-container {