CMVR-IOT-UI/src/views/flow/nodes/common/startNode.vue

158 lines
3.5 KiB
Vue
Raw Normal View History

2025-09-22 15:42:11 +08:00
<template>
2025-11-17 14:54:32 +08:00
<div class="node__container" :class="props.model.id">
2025-09-22 15:42:11 +08:00
<keep-alive>
2026-04-15 10:59:17 +08:00
<NodeState :state="nodeOperatingStatus" :runtimes="runtimes" ref="nodeStateRef">
2025-09-22 15:42:11 +08:00
<template #input>
<JsonViewer :value="inputJsonData" copyable boxed sort theme="light" />
</template>
<!-- <template #output>
<JsonViewer :value="outputJsonData" copyable boxed sort theme="light" />
</template> -->
</NodeState>
</keep-alive>
<div class="title__container">
<div class="title">
2025-11-17 14:54:32 +08:00
<div class="left">
<img src="../../icon/start.svg" alt="" />
<span class="text">Start</span>
</div>
2025-09-22 15:42:11 +08:00
</div>
<div class="subTitle">工作流的起始节点,用于设定启动工作流需要的信息</div>
</div>
</div>
</template>
<script setup>
2026-04-14 17:22:08 +08:00
import { ref, onMounted, onUnmounted } from "vue";
2025-09-22 15:42:11 +08:00
import NodeState from "../../components/NodeState.vue";
import "vue3-json-viewer/dist/index.css";
import { emitter } from "@/utils/eventBus";
const props = defineProps({
model: Object,
properties: Object,
});
const emits = defineEmits(["contentChange"]);
const nodeOperatingStatus = ref("NORMAL");
2026-04-14 17:22:08 +08:00
const runtimes = ref(0);
2025-09-22 15:42:11 +08:00
const inputJsonData = ref({});
const outputJsonData = ref({});
2026-04-15 10:59:17 +08:00
const nodeStateRef = ref(null);
const closePopover = () => {
if (nodeStateRef.value) {
nodeStateRef.value.closePopover();
}
}
2025-09-22 15:42:11 +08:00
onMounted(() => {
emitter.on("changeNodeState", (data) => {
if (data.nodeId === props.model.id) {
nodeOperatingStatus.value = data.status;
2026-04-14 17:22:08 +08:00
if (data.endTime && data.startTime) {
runtimes.value = data.endTime - data.startTime;
}
2025-09-22 15:42:11 +08:00
let inputData = {};
let output = {};
try {
inputData = JSON.parse(data.paramsIn) || {};
output = JSON.parse(data.paramsOut) || {};
} catch (error) {
inputData = data.paramsIn || {};
output = data.paramsOut || {};
}
inputJsonData.value = inputData;
outputJsonData.value = output;
emits("contentChange");
}
});
emitter.on("contentChange", (data) => {
if (data.id === props.model.id) {
nodeOperatingStatus.value = "NORMAL";
inputJsonData.value = {};
outputJsonData.value = {};
emits("contentChange");
}
});
2026-04-13 10:31:55 +08:00
emitter.on("setProperties", (data) => {
if (data.id === props.model.id) {
emits("contentChange");
2025-09-22 15:42:11 +08:00
}
2026-04-13 10:31:55 +08:00
});
});
2025-09-22 15:42:11 +08:00
2025-11-17 14:54:32 +08:00
2025-09-22 15:42:11 +08:00
onUnmounted(() => {
emitter.off("changeNodeState");
emitter.off("contentChange");
2026-04-13 10:31:55 +08:00
emitter.off("setProperties");
2025-09-22 15:42:11 +08:00
});
2026-04-15 10:59:17 +08:00
defineExpose({ closePopover })
2025-09-22 15:42:11 +08:00
</script>
<style lang="scss" scoped>
.node__container {
width: 100%;
height: auto;
.title__container {
.title {
display: flex;
align-items: center;
2025-11-17 14:54:32 +08:00
justify-content: space-between;
2025-09-22 15:42:11 +08:00
2025-11-17 14:54:32 +08:00
.left {
img {
width: 24px;
height: 24px;
}
2025-09-22 15:42:11 +08:00
2025-11-17 14:54:32 +08:00
.text {
font-size: 16px;
font-weight: bold;
margin-left: 12px;
}
2025-09-22 15:42:11 +08:00
}
2025-11-17 17:32:33 +08:00
.right {
.el-button {
border: none;
font-size: 24px;
}
}
2025-09-22 15:42:11 +08:00
}
.subTitle {
color: #737a87;
font-size: 12px;
margin: 8px 0;
}
}
}
</style>
<style lang="scss">
.popover__container {
min-width: 300px !important;
.params__container {
margin-bottom: 12px;
.paramsTitle {
color: #0c0d0e;
font-size: 14px;
font-weight: 500;
}
}
}
</style>