From a1d7e81859f554f3a53680cc35f0f49bf1f77098 Mon Sep 17 00:00:00 2001
From: wwf <1971391498@qq.com>
Date: 星期四, 14 五月 2026 14:37:02 +0800
Subject: [PATCH] 导入项目
---
src/components/SimpleProcessDesignerV2/src/nodes-config/RouterNodeConfig.vue | 201 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 201 insertions(+), 0 deletions(-)
diff --git a/src/components/SimpleProcessDesignerV2/src/nodes-config/RouterNodeConfig.vue b/src/components/SimpleProcessDesignerV2/src/nodes-config/RouterNodeConfig.vue
new file mode 100644
index 0000000..4cf6a84
--- /dev/null
+++ b/src/components/SimpleProcessDesignerV2/src/nodes-config/RouterNodeConfig.vue
@@ -0,0 +1,201 @@
+<template>
+ <el-drawer
+ :append-to-body="true"
+ v-model="settingVisible"
+ :show-close="false"
+ :size="630"
+ :before-close="saveConfig"
+ >
+ <template #header>
+ <div class="config-header">
+ <input
+ v-if="showInput"
+ type="text"
+ class="config-editable-input"
+ @blur="blurEvent()"
+ v-mountedFocus
+ v-model="nodeName"
+ :placeholder="nodeName"
+ />
+ <div v-else class="node-name">
+ {{ nodeName }} <Icon class="ml-1" icon="ep:edit-pen" :size="16" @click="clickIcon()" />
+ </div>
+ <div class="divide-line"></div>
+ </div>
+ </template>
+ <div>
+ <el-form label-position="top">
+ <el-card class="mb-15px" v-for="(item, index) in routerGroups" :key="index">
+ <template #header>
+ <div class="flex flex-items-center">
+ <el-text size="large">璺敱{{ index + 1 }}</el-text>
+ <el-select class="ml-15px" v-model="item.nodeId" style="width: 180px">
+ <el-option
+ v-for="node in nodeOptions"
+ :key="node.value"
+ :label="node.label"
+ :value="node.value"
+ />
+ </el-select>
+ <el-button class="mla" type="danger" link @click="deleteRouterGroup(index)">
+ 鍒犻櫎
+ </el-button>
+ </div>
+ </template>
+ <Condition
+ :ref="($event) => (conditionRef[index] = $event)"
+ v-model="routerGroups[index]"
+ />
+ </el-card>
+ </el-form>
+
+ <el-button class="w-1/1" type="primary" :icon="Plus" @click="addRouterGroup">
+ 鏂板璺敱鍒嗘敮
+ </el-button>
+ </div>
+ <template #footer>
+ <el-divider />
+ <div>
+ <el-button type="primary" @click="saveConfig">纭� 瀹�</el-button>
+ <el-button @click="closeDrawer">鍙� 娑�</el-button>
+ </div>
+ </template>
+ </el-drawer>
+</template>
+<script setup lang="ts">
+import { Plus } from '@element-plus/icons-vue'
+import { SimpleFlowNode, NodeType, ConditionType, RouterSetting } from '../consts'
+import { useWatchNode, useDrawer, useNodeName } from '../node'
+import Condition from './components/Condition.vue'
+
+defineOptions({
+ name: 'RouterNodeConfig'
+})
+const message = useMessage() // 娑堟伅寮圭獥
+const props = defineProps({
+ flowNode: {
+ type: Object as () => SimpleFlowNode,
+ required: true
+ }
+})
+const processNodeTree = inject<Ref<SimpleFlowNode>>('processNodeTree')
+// 鎶藉眽閰嶇疆
+const { settingVisible, closeDrawer, openDrawer } = useDrawer()
+// 褰撳墠鑺傜偣
+const currentNode = useWatchNode(props)
+// 鑺傜偣鍚嶇О
+const { nodeName, showInput, clickIcon, blurEvent } = useNodeName(NodeType.ROUTER_BRANCH_NODE)
+const routerGroups = ref<RouterSetting[]>([])
+const nodeOptions = ref<any>([])
+const conditionRef = ref([])
+
+/** 淇濆瓨閰嶇疆 */
+const saveConfig = async () => {
+ // 鏍¢獙琛ㄥ崟
+ let valid = true
+ for (const item of conditionRef.value) {
+ if (item && !(await item.validate())) {
+ valid = false
+ }
+ }
+ if (!valid) return false
+ const showText = getShowText()
+ if (!showText) return false
+ currentNode.value.name = nodeName.value!
+ currentNode.value.showText = showText
+ currentNode.value.routerGroups = routerGroups.value
+ settingVisible.value = false
+ return true
+}
+// 鏄剧ず璺敱鍒嗘敮鑺傜偣閰嶇疆锛� 鐢辩埗缁勪欢浼犺繃鏉�
+const showRouteNodeConfig = (node: SimpleFlowNode) => {
+ getRouterNode(processNodeTree?.value)
+ routerGroups.value = []
+ nodeName.value = node.name
+ if (node.routerGroups) {
+ routerGroups.value = node.routerGroups
+ }
+}
+
+const getShowText = () => {
+ if (!routerGroups.value || !Array.isArray(routerGroups.value) || routerGroups.value.length <= 0) {
+ message.warning('璇烽厤缃矾鐢憋紒')
+ return ''
+ }
+ for (const route of routerGroups.value) {
+ if (!route.nodeId || !route.conditionType) {
+ message.warning('璇峰畬鍠勮矾鐢遍厤缃」锛�')
+ return ''
+ }
+ if (route.conditionType === ConditionType.EXPRESSION && !route.conditionExpression) {
+ message.warning('璇峰畬鍠勮矾鐢遍厤缃」锛�')
+ return ''
+ }
+ if (route.conditionType === ConditionType.RULE) {
+ for (const condition of route.conditionGroups.conditions) {
+ for (const rule of condition.rules) {
+ if (!rule.leftSide || !rule.rightSide) {
+ message.warning('璇峰畬鍠勮矾鐢遍厤缃」锛�')
+ return ''
+ }
+ }
+ }
+ }
+ }
+ return `${routerGroups.value.length}鏉¤矾鐢卞垎鏀痐
+}
+
+const addRouterGroup = () => {
+ routerGroups.value.push({
+ nodeId: '',
+ conditionType: ConditionType.RULE,
+ conditionExpression: '',
+ conditionGroups: {
+ and: true,
+ conditions: [
+ {
+ and: true,
+ rules: [
+ {
+ opCode: '==',
+ leftSide: '',
+ rightSide: ''
+ }
+ ]
+ }
+ ]
+ }
+ })
+}
+
+const deleteRouterGroup = (index: number) => {
+ routerGroups.value.splice(index, 1)
+}
+
+// 閫掑綊鑾峰彇鎵�鏈夎妭鐐�
+const getRouterNode = (node) => {
+ // TODO 鏈�濂借繕闇�瑕佹弧瓒充互涓嬭姹�
+ // 骞惰鍒嗘敮銆佸寘瀹瑰垎鏀唴閮ㄨ妭鐐逛笉鑳借烦杞埌澶栭儴鑺傜偣
+ // 鏉′欢鍒嗘敮鑺傜偣鍙互鍚戜笂璺宠浆鍒板閮ㄨ妭鐐�
+ while (true) {
+ if (!node) break
+ if (node.type !== NodeType.ROUTER_BRANCH_NODE && node.type !== NodeType.CONDITION_NODE) {
+ nodeOptions.value.push({
+ label: node.name,
+ value: node.id
+ })
+ }
+ if (!node.childNode || node.type === NodeType.END_EVENT_NODE) {
+ break
+ }
+ if (node.conditionNodes && node.conditionNodes.length) {
+ node.conditionNodes.forEach((item) => {
+ getRouterNode(item)
+ })
+ }
+ node = node.childNode
+ }
+}
+
+defineExpose({ openDrawer, showRouteNodeConfig }) // 鏆撮湶鏂规硶缁欑埗缁勪欢
+</script>
--
Gitblit v1.8.0