|
@@ -2,9 +2,13 @@
|
|
|
<div class="branch-node-wrapper">
|
|
|
<div class="branch-node-container">
|
|
|
<div class="branch-node-add" @click="addCondition">添加条件</div>
|
|
|
- <div class="branch-node-item" v-for="(item, index) in currentNode.conditionNodes" :key="index">
|
|
|
+ <div
|
|
|
+ class="branch-node-item"
|
|
|
+ v-for="(item, index) in currentNode.conditionNodes"
|
|
|
+ :key="index"
|
|
|
+ >
|
|
|
<template v-if="index == 0">
|
|
|
- <div class="branch-line-first-top"></div>
|
|
|
+ <div class="branch-line-first-top"> </div>
|
|
|
<div class="branch-line-first-bottom"></div>
|
|
|
</template>
|
|
|
<template v-if="index + 1 == currentNode.conditionNodes?.length">
|
|
@@ -15,13 +19,14 @@
|
|
|
<div class="node-container">
|
|
|
<div class="node-box" :class="{ 'node-config-error': !item.showText }">
|
|
|
<div class="branch-node-title-container">
|
|
|
- <div v-if="showInputs[index]">
|
|
|
+ <div v-if="showInputs[index]">
|
|
|
<input
|
|
|
type="text"
|
|
|
- class="input-max-width editable-title-input"
|
|
|
+ class="input-max-width editable-title-input"
|
|
|
@blur="blurEvent(index)"
|
|
|
- v-mountedFocus
|
|
|
- v-model="item.name" />
|
|
|
+ v-mountedFocus
|
|
|
+ v-model="item.name"
|
|
|
+ />
|
|
|
</div>
|
|
|
<div v-else class="branch-title" @click="clickEvent(index)"> {{ item.name }} </div>
|
|
|
<div class="branch-priority"> 优先级{{ index + 1 }} </div>
|
|
@@ -36,19 +41,27 @@
|
|
|
</div>
|
|
|
<div class="node-toolbar" v-if="index + 1 !== currentNode.conditionNodes?.length">
|
|
|
<div class="toolbar-icon">
|
|
|
- <Icon color="#0089ff" icon="ep:circle-close-filled" :size="18" @click="deleteCondition(index)" />
|
|
|
+ <Icon
|
|
|
+ color="#0089ff"
|
|
|
+ icon="ep:circle-close-filled"
|
|
|
+ :size="18"
|
|
|
+ @click="deleteCondition(index)"
|
|
|
+ />
|
|
|
</div>
|
|
|
</div>
|
|
|
- <div
|
|
|
+ <div
|
|
|
class="branch-node-move move-node-left"
|
|
|
- v-if="index != 0 && index + 1 !== currentNode.conditionNodes?.length" @click="moveNode(index, -1)">
|
|
|
+ v-if="index != 0 && index + 1 !== currentNode.conditionNodes?.length"
|
|
|
+ @click="moveNode(index, -1)"
|
|
|
+ >
|
|
|
<Icon icon="ep:arrow-left" />
|
|
|
</div>
|
|
|
|
|
|
- <div
|
|
|
+ <div
|
|
|
class="branch-node-move move-node-right"
|
|
|
v-if="currentNode.conditionNodes && index < currentNode.conditionNodes.length - 2"
|
|
|
- @click="moveNode(index, 1)">
|
|
|
+ @click="moveNode(index, 1)"
|
|
|
+ >
|
|
|
<Icon icon="ep:arrow-right" />
|
|
|
</div>
|
|
|
</div>
|
|
@@ -57,11 +70,12 @@
|
|
|
</div>
|
|
|
<ConditionNodeConfig :node-index="index" :condition-node="item" :ref="item.id" />
|
|
|
<!-- 递归显示子节点 -->
|
|
|
- <ProcessNodeTree
|
|
|
- v-if="item && item.childNode"
|
|
|
- :parent-node="item"
|
|
|
- v-model:flow-node="item.childNode"
|
|
|
- @find:recursive-find-parent-node="recursiveFindParentNode"/>
|
|
|
+ <ProcessNodeTree
|
|
|
+ v-if="item && item.childNode"
|
|
|
+ :parent-node="item"
|
|
|
+ v-model:flow-node="item.childNode"
|
|
|
+ @find:recursive-find-parent-node="recursiveFindParentNode"
|
|
|
+ />
|
|
|
</div>
|
|
|
</div>
|
|
|
<NodeHandler v-if="currentNode" v-model:child-node="currentNode.childNode" />
|
|
@@ -91,25 +105,32 @@ const props = defineProps({
|
|
|
})
|
|
|
// 定义事件,更新父组件
|
|
|
const emits = defineEmits<{
|
|
|
- 'update:modelValue': [node: SimpleFlowNode | undefined],
|
|
|
- 'find:parentNode': [nodeList: SimpleFlowNode[], nodeType: number],
|
|
|
- 'find:recursiveFindParentNode': [nodeList: SimpleFlowNode[], curentNode: SimpleFlowNode, nodeType: number]
|
|
|
+ 'update:modelValue': [node: SimpleFlowNode | undefined]
|
|
|
+ 'find:parentNode': [nodeList: SimpleFlowNode[], nodeType: number]
|
|
|
+ 'find:recursiveFindParentNode': [
|
|
|
+ nodeList: SimpleFlowNode[],
|
|
|
+ curentNode: SimpleFlowNode,
|
|
|
+ nodeType: number
|
|
|
+ ]
|
|
|
}>()
|
|
|
|
|
|
const currentNode = ref<SimpleFlowNode>(props.flowNode)
|
|
|
// const conditionNodes = computed(() => currentNode.value.conditionNodes);
|
|
|
|
|
|
-watch(() => props.flowNode, (newValue) => {
|
|
|
- currentNode.value = newValue;
|
|
|
-});
|
|
|
-
|
|
|
+watch(
|
|
|
+ () => props.flowNode,
|
|
|
+ (newValue) => {
|
|
|
+ currentNode.value = newValue
|
|
|
+ }
|
|
|
+)
|
|
|
|
|
|
const showInputs = ref<boolean[]>([])
|
|
|
// 失去焦点
|
|
|
const blurEvent = (index: number) => {
|
|
|
showInputs.value[index] = false
|
|
|
- const conditionNode = currentNode.value.conditionNodes?.at(index) as SimpleFlowNode;
|
|
|
- conditionNode.name = conditionNode.name || getDefaultConditionNodeName(index, conditionNode.attributes?.defaultFlow)
|
|
|
+ const conditionNode = currentNode.value.conditionNodes?.at(index) as SimpleFlowNode
|
|
|
+ conditionNode.name =
|
|
|
+ conditionNode.name || getDefaultConditionNodeName(index, conditionNode.attributes?.defaultFlow)
|
|
|
}
|
|
|
|
|
|
// 点击条件名称
|
|
@@ -118,13 +139,13 @@ const clickEvent = (index: number) => {
|
|
|
}
|
|
|
|
|
|
const conditionNodeConfig = (nodeId: string) => {
|
|
|
- const conditionNode = proxy.$refs[nodeId][0];
|
|
|
+ const conditionNode = proxy.$refs[nodeId][0]
|
|
|
conditionNode.open()
|
|
|
}
|
|
|
|
|
|
// 新增条件
|
|
|
const addCondition = () => {
|
|
|
- const conditionNodes = currentNode.value.conditionNodes;
|
|
|
+ const conditionNodes = currentNode.value.conditionNodes
|
|
|
if (conditionNodes) {
|
|
|
const len = conditionNodes.length
|
|
|
let lastIndex = len - 1
|
|
@@ -146,7 +167,7 @@ const addCondition = () => {
|
|
|
|
|
|
// 删除条件
|
|
|
const deleteCondition = (index: number) => {
|
|
|
- const conditionNodes = currentNode.value.conditionNodes;
|
|
|
+ const conditionNodes = currentNode.value.conditionNodes
|
|
|
if (conditionNodes) {
|
|
|
conditionNodes.splice(index, 1)
|
|
|
if (conditionNodes.length == 1) {
|
|
@@ -161,10 +182,12 @@ const deleteCondition = (index: number) => {
|
|
|
const moveNode = (index: number, to: number) => {
|
|
|
// -1 :向左 1: 向右
|
|
|
if (currentNode.value.conditionNodes) {
|
|
|
- currentNode.value.conditionNodes[index] = currentNode.value.conditionNodes.splice(index + to,
|
|
|
- 1, currentNode.value.conditionNodes[index])[0]
|
|
|
+ currentNode.value.conditionNodes[index] = currentNode.value.conditionNodes.splice(
|
|
|
+ index + to,
|
|
|
+ 1,
|
|
|
+ currentNode.value.conditionNodes[index]
|
|
|
+ )[0]
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
// 递归从父节点中查询匹配的节点
|
|
|
const recursiveFindParentNode = (
|
|
@@ -181,7 +204,6 @@ const recursiveFindParentNode = (
|
|
|
// 条件节点 (NodeType.CONDITION_NODE) 比较特殊。需要调用其父节点条件分支节点(NodeType.EXCLUSIVE_NODE) 继续查找
|
|
|
emits('find:parentNode', nodeList, nodeType)
|
|
|
}
|
|
|
-
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped></style>
|