fix: [BPM 工作流] 节点名称输入框自动获取焦点问题修复
							parent
							
								
									6e3ffb61ef
								
							
						
					
					
						commit
						23a25cb521
					
				|  | @ -1,7 +1,7 @@ | ||||||
| <script setup lang="ts"> | <script setup lang="ts"> | ||||||
| import type { SimpleFlowNode } from '../../consts'; | import type { SimpleFlowNode } from '../../consts'; | ||||||
| 
 | 
 | ||||||
| import { ref, watch } from 'vue'; | import { nextTick, ref, watch } from 'vue'; | ||||||
| 
 | 
 | ||||||
| import { useVbenDrawer } from '@vben/common-ui'; | import { useVbenDrawer } from '@vben/common-ui'; | ||||||
| import { IconifyIcon } from '@vben/icons'; | import { IconifyIcon } from '@vben/icons'; | ||||||
|  | @ -53,8 +53,6 @@ const condition = ref<any>({ | ||||||
|   }, |   }, | ||||||
| }); | }); | ||||||
| 
 | 
 | ||||||
| // 显示名称输入框 |  | ||||||
| const showInput = ref(false); |  | ||||||
| const conditionRef = ref(); | const conditionRef = ref(); | ||||||
| const fieldOptions = useFormFieldsAndStartUser(); // 流程表单字段和发起人字段 | const fieldOptions = useFormFieldsAndStartUser(); // 流程表单字段和发起人字段 | ||||||
| 
 | 
 | ||||||
|  | @ -130,7 +128,18 @@ watch( | ||||||
|     currentNode.value = newValue; |     currentNode.value = newValue; | ||||||
|   }, |   }, | ||||||
| ); | ); | ||||||
| 
 | // 显示名称输入框 | ||||||
|  | const showInput = ref(false); | ||||||
|  | // 输入框的引用 | ||||||
|  | const inputRef = ref<HTMLInputElement | null>(null); | ||||||
|  | // 监听 showInput 的变化,当变为 true 时自动聚焦 | ||||||
|  | watch(showInput, (value) => { | ||||||
|  |   if (value) { | ||||||
|  |     nextTick(() => { | ||||||
|  |       inputRef.value?.focus(); | ||||||
|  |     }); | ||||||
|  |   } | ||||||
|  | }); | ||||||
| function clickIcon() { | function clickIcon() { | ||||||
|   showInput.value = true; |   showInput.value = true; | ||||||
| } | } | ||||||
|  | @ -153,6 +162,7 @@ defineExpose({ open }); // 提供 open 方法,用于打开弹窗 | ||||||
|     <template #title> |     <template #title> | ||||||
|       <div class="flex items-center"> |       <div class="flex items-center"> | ||||||
|         <Input |         <Input | ||||||
|  |           ref="inputRef" | ||||||
|           v-if="showInput" |           v-if="showInput" | ||||||
|           type="text" |           type="text" | ||||||
|           class="mr-2 w-48" |           class="mr-2 w-48" | ||||||
|  |  | ||||||
|  | @ -75,7 +75,7 @@ const [Drawer, drawerApi] = useVbenDrawer({ | ||||||
| const currentNode = useWatchNode(props); | const currentNode = useWatchNode(props); | ||||||
| 
 | 
 | ||||||
| // 节点名称 | // 节点名称 | ||||||
| const { nodeName, showInput, clickIcon, blurEvent } = useNodeName( | const { nodeName, showInput, clickIcon, blurEvent, inputRef } = useNodeName( | ||||||
|   BpmNodeTypeEnum.COPY_TASK_NODE, |   BpmNodeTypeEnum.COPY_TASK_NODE, | ||||||
| ); | ); | ||||||
| 
 | 
 | ||||||
|  | @ -213,6 +213,7 @@ defineExpose({ showCopyTaskNodeConfig }); // 暴露方法给父组件 | ||||||
|       <div class="config-header"> |       <div class="config-header"> | ||||||
|         <Input |         <Input | ||||||
|           v-if="showInput" |           v-if="showInput" | ||||||
|  |           ref="inputRef" | ||||||
|           type="text" |           type="text" | ||||||
|           class="config-editable-input" |           class="config-editable-input" | ||||||
|           @blur="blurEvent()" |           @blur="blurEvent()" | ||||||
|  |  | ||||||
|  | @ -45,7 +45,7 @@ const props = defineProps({ | ||||||
| // 当前节点 | // 当前节点 | ||||||
| const currentNode = useWatchNode(props); | const currentNode = useWatchNode(props); | ||||||
| // 节点名称 | // 节点名称 | ||||||
| const { nodeName, showInput, clickIcon, blurEvent } = useNodeName( | const { nodeName, showInput, clickIcon, blurEvent, inputRef } = useNodeName( | ||||||
|   BpmNodeTypeEnum.DELAY_TIMER_NODE, |   BpmNodeTypeEnum.DELAY_TIMER_NODE, | ||||||
| ); | ); | ||||||
| // 抄送人表单配置 | // 抄送人表单配置 | ||||||
|  | @ -158,6 +158,7 @@ defineExpose({ openDrawer }); // 暴露方法给父组件 | ||||||
|       <div class="flex items-center"> |       <div class="flex items-center"> | ||||||
|         <Input |         <Input | ||||||
|           v-if="showInput" |           v-if="showInput" | ||||||
|  |           ref="inputRef" | ||||||
|           type="text" |           type="text" | ||||||
|           class="mr-2 w-48" |           class="mr-2 w-48" | ||||||
|           @blur="blurEvent()" |           @blur="blurEvent()" | ||||||
|  |  | ||||||
|  | @ -41,7 +41,7 @@ const processNodeTree = inject<Ref<SimpleFlowNode>>('processNodeTree'); | ||||||
| /** 当前节点 */ | /** 当前节点 */ | ||||||
| const currentNode = useWatchNode(props); | const currentNode = useWatchNode(props); | ||||||
| /** 节点名称 */ | /** 节点名称 */ | ||||||
| const { nodeName, showInput, clickIcon, blurEvent } = useNodeName( | const { nodeName, showInput, clickIcon, blurEvent, inputRef } = useNodeName( | ||||||
|   BpmNodeTypeEnum.ROUTER_BRANCH_NODE, |   BpmNodeTypeEnum.ROUTER_BRANCH_NODE, | ||||||
| ); | ); | ||||||
| const routerGroups = ref<RouterSetting[]>([]); | const routerGroups = ref<RouterSetting[]>([]); | ||||||
|  | @ -205,6 +205,7 @@ defineExpose({ openDrawer }); // 暴露方法给父组件 | ||||||
|     <template #title> |     <template #title> | ||||||
|       <div class="flex items-center"> |       <div class="flex items-center"> | ||||||
|         <Input |         <Input | ||||||
|  |           ref="inputRef" | ||||||
|           v-if="showInput" |           v-if="showInput" | ||||||
|           type="text" |           type="text" | ||||||
|           class="mr-2 w-48" |           class="mr-2 w-48" | ||||||
|  |  | ||||||
|  | @ -52,7 +52,7 @@ const deptOptions = inject<Ref<SystemDeptApi.Dept[]>>('deptList'); | ||||||
| // 当前节点 | // 当前节点 | ||||||
| const currentNode = useWatchNode(props); | const currentNode = useWatchNode(props); | ||||||
| // 节点名称 | // 节点名称 | ||||||
| const { nodeName, showInput, clickIcon, blurEvent } = useNodeName( | const { nodeName, showInput, clickIcon, blurEvent, inputRef } = useNodeName( | ||||||
|   BpmNodeTypeEnum.START_USER_NODE, |   BpmNodeTypeEnum.START_USER_NODE, | ||||||
| ); | ); | ||||||
| // 激活的 Tab 标签页 | // 激活的 Tab 标签页 | ||||||
|  | @ -145,8 +145,8 @@ defineExpose({ showStartUserNodeConfig }); | ||||||
|   <Drawer> |   <Drawer> | ||||||
|     <template #title> |     <template #title> | ||||||
|       <div class="config-header"> |       <div class="config-header"> | ||||||
|         <!--    TODO v-mountedFocus 自动聚集 需要迁移一下 --> |  | ||||||
|         <Input |         <Input | ||||||
|  |           ref="inputRef" | ||||||
|           v-if="showInput" |           v-if="showInput" | ||||||
|           type="text" |           type="text" | ||||||
|           class="config-editable-input" |           class="config-editable-input" | ||||||
|  |  | ||||||
|  | @ -72,7 +72,7 @@ const [Drawer, drawerApi] = useVbenDrawer({ | ||||||
| // 当前节点 | // 当前节点 | ||||||
| const currentNode = useWatchNode(props); | const currentNode = useWatchNode(props); | ||||||
| // 节点名称 | // 节点名称 | ||||||
| const { nodeName, showInput, clickIcon, blurEvent } = useNodeName( | const { nodeName, showInput, clickIcon, blurEvent, inputRef } = useNodeName( | ||||||
|   BpmNodeTypeEnum.TRIGGER_NODE, |   BpmNodeTypeEnum.TRIGGER_NODE, | ||||||
| ); | ); | ||||||
| // 触发器表单配置 | // 触发器表单配置 | ||||||
|  | @ -388,6 +388,7 @@ onMounted(() => { | ||||||
|     <template #title> |     <template #title> | ||||||
|       <div class="config-header"> |       <div class="config-header"> | ||||||
|         <Input |         <Input | ||||||
|  |           ref="inputRef" | ||||||
|           v-if="showInput" |           v-if="showInput" | ||||||
|           type="text" |           type="text" | ||||||
|           class="config-editable-input" |           class="config-editable-input" | ||||||
|  |  | ||||||
|  | @ -114,7 +114,7 @@ const [Drawer, drawerApi] = useVbenDrawer({ | ||||||
| }); | }); | ||||||
| 
 | 
 | ||||||
| // 节点名称配置 | // 节点名称配置 | ||||||
| const { nodeName, showInput, clickIcon, blurEvent } = useNodeName( | const { nodeName, showInput, clickIcon, blurEvent, inputRef } = useNodeName( | ||||||
|   BpmNodeTypeEnum.USER_TASK_NODE, |   BpmNodeTypeEnum.USER_TASK_NODE, | ||||||
| ); | ); | ||||||
| 
 | 
 | ||||||
|  | @ -586,6 +586,7 @@ onMounted(() => { | ||||||
|       <div class="config-header"> |       <div class="config-header"> | ||||||
|         <Input |         <Input | ||||||
|           v-if="showInput" |           v-if="showInput" | ||||||
|  |           ref="inputRef" | ||||||
|           type="text" |           type="text" | ||||||
|           class="config-editable-input" |           class="config-editable-input" | ||||||
|           @blur="blurEvent()" |           @blur="blurEvent()" | ||||||
|  |  | ||||||
|  | @ -32,7 +32,7 @@ const readonly = inject<Boolean>('readonly'); | ||||||
| // 监控节点的变化 | // 监控节点的变化 | ||||||
| const currentNode = useWatchNode(props); | const currentNode = useWatchNode(props); | ||||||
| // 节点名称编辑 | // 节点名称编辑 | ||||||
| const { showInput, blurEvent, clickTitle } = useNodeName2( | const { showInput, blurEvent, clickTitle, inputRef } = useNodeName2( | ||||||
|   currentNode, |   currentNode, | ||||||
|   BpmNodeTypeEnum.COPY_TASK_NODE, |   BpmNodeTypeEnum.COPY_TASK_NODE, | ||||||
| ); | ); | ||||||
|  | @ -67,11 +67,12 @@ function deleteNode() { | ||||||
|             <span class="iconfont icon-copy"></span> |             <span class="iconfont icon-copy"></span> | ||||||
|           </div> |           </div> | ||||||
|           <Input |           <Input | ||||||
|  |             ref="inputRef" | ||||||
|             v-if="!readonly && showInput" |             v-if="!readonly && showInput" | ||||||
|             type="text" |             type="text" | ||||||
|             class="editable-title-input" |             class="editable-title-input" | ||||||
|             @blur="blurEvent()" |             @blur="blurEvent()" | ||||||
|             v-model="currentNode.name" |             v-model:value="currentNode.name" | ||||||
|             :placeholder="currentNode.name" |             :placeholder="currentNode.name" | ||||||
|           /> |           /> | ||||||
|           <div v-else class="node-title" @click="clickTitle"> |           <div v-else class="node-title" @click="clickTitle"> | ||||||
|  |  | ||||||
|  | @ -30,7 +30,7 @@ const readonly = inject<Boolean>('readonly'); | ||||||
| // 监控节点的变化 | // 监控节点的变化 | ||||||
| const currentNode = useWatchNode(props); | const currentNode = useWatchNode(props); | ||||||
| // 节点名称编辑 | // 节点名称编辑 | ||||||
| const { showInput, blurEvent, clickTitle } = useNodeName2( | const { showInput, blurEvent, clickTitle, inputRef } = useNodeName2( | ||||||
|   currentNode, |   currentNode, | ||||||
|   BpmNodeTypeEnum.DELAY_TIMER_NODE, |   BpmNodeTypeEnum.DELAY_TIMER_NODE, | ||||||
| ); | ); | ||||||
|  | @ -64,11 +64,12 @@ function deleteNode() { | ||||||
|             <span class="iconfont icon-delay"></span> |             <span class="iconfont icon-delay"></span> | ||||||
|           </div> |           </div> | ||||||
|           <Input |           <Input | ||||||
|  |             ref="inputRef" | ||||||
|             v-if="!readonly && showInput" |             v-if="!readonly && showInput" | ||||||
|             type="text" |             type="text" | ||||||
|             class="editable-title-input" |             class="editable-title-input" | ||||||
|             @blur="blurEvent()" |             @blur="blurEvent()" | ||||||
|             v-model="currentNode.name" |             v-model:value="currentNode.name" | ||||||
|             :placeholder="currentNode.name" |             :placeholder="currentNode.name" | ||||||
|           /> |           /> | ||||||
|           <div v-else class="node-title" @click="clickTitle"> |           <div v-else class="node-title" @click="clickTitle"> | ||||||
|  |  | ||||||
|  | @ -1,7 +1,7 @@ | ||||||
| <script setup lang="ts"> | <script setup lang="ts"> | ||||||
| import type { SimpleFlowNode } from '../../consts'; | import type { SimpleFlowNode } from '../../consts'; | ||||||
| 
 | 
 | ||||||
| import { getCurrentInstance, inject, ref, watch } from 'vue'; | import { getCurrentInstance, inject, nextTick, ref, watch } from 'vue'; | ||||||
| 
 | 
 | ||||||
| import { IconifyIcon } from '@vben/icons'; | import { IconifyIcon } from '@vben/icons'; | ||||||
| import { cloneDeep, buildShortUUID as generateUUID } from '@vben/utils'; | import { cloneDeep, buildShortUUID as generateUUID } from '@vben/utils'; | ||||||
|  | @ -51,9 +51,28 @@ watch( | ||||||
|     currentNode.value = newValue; |     currentNode.value = newValue; | ||||||
|   }, |   }, | ||||||
| ); | ); | ||||||
| 
 | // 条件节点名称输入框引用 | ||||||
|  | const inputRefs = ref<HTMLInputElement[]>([]); | ||||||
|  | // 节点名称输入框显示状态 | ||||||
| const showInputs = ref<boolean[]>([]); | const showInputs = ref<boolean[]>([]); | ||||||
| 
 | 
 | ||||||
|  | // 监听显示状态变化 | ||||||
|  | watch( | ||||||
|  |   showInputs, | ||||||
|  |   (newValues) => { | ||||||
|  |     // 当状态为 true 时, 自动聚焦 | ||||||
|  |     newValues.forEach((value, index) => { | ||||||
|  |       if (value) { | ||||||
|  |         // 当显示状态从 false 变为 true 时, 自动聚焦 | ||||||
|  |         nextTick(() => { | ||||||
|  |           inputRefs.value[index]?.focus(); | ||||||
|  |         }); | ||||||
|  |       } | ||||||
|  |     }); | ||||||
|  |   }, | ||||||
|  |   { deep: true }, | ||||||
|  | ); | ||||||
|  | 
 | ||||||
| // 失去焦点 | // 失去焦点 | ||||||
| function blurEvent(index: number) { | function blurEvent(index: number) { | ||||||
|   showInputs.value[index] = false; |   showInputs.value[index] = false; | ||||||
|  | @ -188,10 +207,15 @@ function recursiveFindParentNode( | ||||||
|               <div class="branch-node-title-container"> |               <div class="branch-node-title-container"> | ||||||
|                 <div v-if="!readonly && showInputs[index]"> |                 <div v-if="!readonly && showInputs[index]"> | ||||||
|                   <Input |                   <Input | ||||||
|  |                     :ref=" | ||||||
|  |                       (el) => { | ||||||
|  |                         inputRefs[index] = el as HTMLInputElement; | ||||||
|  |                       } | ||||||
|  |                     " | ||||||
|                     type="text" |                     type="text" | ||||||
|                     class="editable-title-input" |                     class="editable-title-input" | ||||||
|                     @blur="blurEvent(index)" |                     @blur="blurEvent(index)" | ||||||
|                     v-model="item.name" |                     v-model:value="item.name" | ||||||
|                   /> |                   /> | ||||||
|                 </div> |                 </div> | ||||||
|                 <div v-else class="branch-title" @click="clickEvent(index)"> |                 <div v-else class="branch-title" @click="clickEvent(index)"> | ||||||
|  |  | ||||||
|  | @ -1,7 +1,7 @@ | ||||||
| <script setup lang="ts"> | <script setup lang="ts"> | ||||||
| import type { SimpleFlowNode } from '../../consts'; | import type { SimpleFlowNode } from '../../consts'; | ||||||
| 
 | 
 | ||||||
| import { getCurrentInstance, inject, ref, watch } from 'vue'; | import { getCurrentInstance, inject, nextTick, ref, watch } from 'vue'; | ||||||
| 
 | 
 | ||||||
| import { IconifyIcon } from '@vben/icons'; | import { IconifyIcon } from '@vben/icons'; | ||||||
| import { cloneDeep, buildShortUUID as generateUUID } from '@vben/utils'; | import { cloneDeep, buildShortUUID as generateUUID } from '@vben/utils'; | ||||||
|  | @ -57,8 +57,26 @@ watch( | ||||||
|     currentNode.value = newValue; |     currentNode.value = newValue; | ||||||
|   }, |   }, | ||||||
| ); | ); | ||||||
| 
 | // 条件节点名称输入框引用 | ||||||
|  | const inputRefs = ref<HTMLInputElement[]>([]); | ||||||
|  | // 节点名称输入框显示状态 | ||||||
| const showInputs = ref<boolean[]>([]); | const showInputs = ref<boolean[]>([]); | ||||||
|  | // 监听显示状态变化 | ||||||
|  | watch( | ||||||
|  |   showInputs, | ||||||
|  |   (newValues) => { | ||||||
|  |     // 当状态为 true 时, 自动聚焦 | ||||||
|  |     newValues.forEach((value, index) => { | ||||||
|  |       if (value) { | ||||||
|  |         // 当显示状态从 false 变为 true 时, 自动聚焦 | ||||||
|  |         nextTick(() => { | ||||||
|  |           inputRefs.value[index]?.focus(); | ||||||
|  |         }); | ||||||
|  |       } | ||||||
|  |     }); | ||||||
|  |   }, | ||||||
|  |   { deep: true }, | ||||||
|  | ); | ||||||
| // 失去焦点 | // 失去焦点 | ||||||
| function blurEvent(index: number) { | function blurEvent(index: number) { | ||||||
|   showInputs.value[index] = false; |   showInputs.value[index] = false; | ||||||
|  | @ -192,10 +210,15 @@ function recursiveFindParentNode( | ||||||
|               <div class="branch-node-title-container"> |               <div class="branch-node-title-container"> | ||||||
|                 <div v-if="!readonly && showInputs[index]"> |                 <div v-if="!readonly && showInputs[index]"> | ||||||
|                   <Input |                   <Input | ||||||
|  |                     :ref=" | ||||||
|  |                       (el) => { | ||||||
|  |                         inputRefs[index] = el as HTMLInputElement; | ||||||
|  |                       } | ||||||
|  |                     " | ||||||
|                     type="text" |                     type="text" | ||||||
|                     class="editable-title-input" |                     class="editable-title-input" | ||||||
|                     @blur="blurEvent(index)" |                     @blur="blurEvent(index)" | ||||||
|                     v-model="item.name" |                     v-model:value="item.name" | ||||||
|                   /> |                   /> | ||||||
|                 </div> |                 </div> | ||||||
|                 <div v-else class="branch-title" @click="clickEvent(index)"> |                 <div v-else class="branch-title" @click="clickEvent(index)"> | ||||||
|  |  | ||||||
|  | @ -1,7 +1,7 @@ | ||||||
| <script setup lang="ts"> | <script setup lang="ts"> | ||||||
| import type { SimpleFlowNode } from '../../consts'; | import type { SimpleFlowNode } from '../../consts'; | ||||||
| 
 | 
 | ||||||
| import { inject, ref, watch } from 'vue'; | import { inject, nextTick, ref, watch } from 'vue'; | ||||||
| 
 | 
 | ||||||
| import { IconifyIcon } from '@vben/icons'; | import { IconifyIcon } from '@vben/icons'; | ||||||
| import { buildShortUUID as generateUUID } from '@vben/utils'; | import { buildShortUUID as generateUUID } from '@vben/utils'; | ||||||
|  | @ -46,8 +46,26 @@ watch( | ||||||
|   }, |   }, | ||||||
| ); | ); | ||||||
| 
 | 
 | ||||||
|  | // 条件节点名称输入框引用 | ||||||
|  | const inputRefs = ref<HTMLInputElement[]>([]); | ||||||
|  | // 节点名称输入框显示状态 | ||||||
| const showInputs = ref<boolean[]>([]); | const showInputs = ref<boolean[]>([]); | ||||||
| 
 | // 监听显示状态变化 | ||||||
|  | watch( | ||||||
|  |   showInputs, | ||||||
|  |   (newValues) => { | ||||||
|  |     // 当输入框显示时, 自动聚焦 | ||||||
|  |     newValues.forEach((value, index) => { | ||||||
|  |       if (value) { | ||||||
|  |         // 当显示状态从 false 变为 true 时, 自动聚焦 | ||||||
|  |         nextTick(() => { | ||||||
|  |           inputRefs.value[index]?.focus(); | ||||||
|  |         }); | ||||||
|  |       } | ||||||
|  |     }); | ||||||
|  |   }, | ||||||
|  |   { deep: true }, | ||||||
|  | ); | ||||||
| // 失去焦点 | // 失去焦点 | ||||||
| function blurEvent(index: number) { | function blurEvent(index: number) { | ||||||
|   showInputs.value[index] = false; |   showInputs.value[index] = false; | ||||||
|  | @ -150,10 +168,15 @@ function recursiveFindParentNode( | ||||||
|               <div class="branch-node-title-container"> |               <div class="branch-node-title-container"> | ||||||
|                 <div v-if="showInputs[index]"> |                 <div v-if="showInputs[index]"> | ||||||
|                   <Input |                   <Input | ||||||
|  |                     :ref=" | ||||||
|  |                       (el) => { | ||||||
|  |                         inputRefs[index] = el as HTMLInputElement; | ||||||
|  |                       } | ||||||
|  |                     " | ||||||
|                     type="text" |                     type="text" | ||||||
|                     class="input-max-width editable-title-input" |                     class="input-max-width editable-title-input" | ||||||
|                     @blur="blurEvent(index)" |                     @blur="blurEvent(index)" | ||||||
|                     v-model="item.name" |                     v-model:value="item.name" | ||||||
|                   /> |                   /> | ||||||
|                 </div> |                 </div> | ||||||
|                 <div v-else class="branch-title" @click="clickEvent(index)"> |                 <div v-else class="branch-title" @click="clickEvent(index)"> | ||||||
|  |  | ||||||
|  | @ -33,7 +33,7 @@ const readonly = inject<Boolean>('readonly'); | ||||||
| // 监控节点的变化 | // 监控节点的变化 | ||||||
| const currentNode = useWatchNode(props); | const currentNode = useWatchNode(props); | ||||||
| // 节点名称编辑 | // 节点名称编辑 | ||||||
| const { showInput, blurEvent, clickTitle } = useNodeName2( | const { showInput, blurEvent, clickTitle, inputRef } = useNodeName2( | ||||||
|   currentNode, |   currentNode, | ||||||
|   BpmNodeTypeEnum.ROUTER_BRANCH_NODE, |   BpmNodeTypeEnum.ROUTER_BRANCH_NODE, | ||||||
| ); | ); | ||||||
|  | @ -67,11 +67,12 @@ function deleteNode() { | ||||||
|             <span class="iconfont icon-router"></span> |             <span class="iconfont icon-router"></span> | ||||||
|           </div> |           </div> | ||||||
|           <Input |           <Input | ||||||
|  |             ref="inputRef" | ||||||
|             v-if="!readonly && showInput" |             v-if="!readonly && showInput" | ||||||
|             type="text" |             type="text" | ||||||
|             class="editable-title-input" |             class="editable-title-input" | ||||||
|             @blur="blurEvent()" |             @blur="blurEvent()" | ||||||
|             v-model="currentNode.name" |             v-model:value="currentNode.name" | ||||||
|             :placeholder="currentNode.name" |             :placeholder="currentNode.name" | ||||||
|           /> |           /> | ||||||
|           <div v-else class="node-title" @click="clickTitle"> |           <div v-else class="node-title" @click="clickTitle"> | ||||||
|  |  | ||||||
|  | @ -37,7 +37,7 @@ const tasks = inject<Ref<any[]>>('tasks', ref([])); | ||||||
| // 监控节点变化 | // 监控节点变化 | ||||||
| const currentNode = useWatchNode(props); | const currentNode = useWatchNode(props); | ||||||
| // 节点名称编辑 | // 节点名称编辑 | ||||||
| const { showInput, blurEvent, clickTitle } = useNodeName2( | const { showInput, blurEvent, clickTitle, inputRef } = useNodeName2( | ||||||
|   currentNode, |   currentNode, | ||||||
|   BpmNodeTypeEnum.START_USER_NODE, |   BpmNodeTypeEnum.START_USER_NODE, | ||||||
| ); | ); | ||||||
|  | @ -81,6 +81,7 @@ function nodeClick() { | ||||||
|             <span class="iconfont icon-start-user"></span> |             <span class="iconfont icon-start-user"></span> | ||||||
|           </div> |           </div> | ||||||
|           <Input |           <Input | ||||||
|  |             ref="inputRef" | ||||||
|             v-if="!readonly && showInput" |             v-if="!readonly && showInput" | ||||||
|             type="text" |             type="text" | ||||||
|             class="editable-title-input" |             class="editable-title-input" | ||||||
|  |  | ||||||
|  | @ -35,7 +35,7 @@ const readonly = inject<Boolean>('readonly'); | ||||||
| // 监控节点的变化 | // 监控节点的变化 | ||||||
| const currentNode = useWatchNode(props); | const currentNode = useWatchNode(props); | ||||||
| // 节点名称编辑 | // 节点名称编辑 | ||||||
| const { showInput, blurEvent, clickTitle } = useNodeName2( | const { showInput, blurEvent, clickTitle, inputRef } = useNodeName2( | ||||||
|   currentNode, |   currentNode, | ||||||
|   BpmNodeTypeEnum.TRIGGER_NODE, |   BpmNodeTypeEnum.TRIGGER_NODE, | ||||||
| ); | ); | ||||||
|  | @ -69,11 +69,12 @@ function deleteNode() { | ||||||
|             <span class="iconfont icon-trigger"></span> |             <span class="iconfont icon-trigger"></span> | ||||||
|           </div> |           </div> | ||||||
|           <Input |           <Input | ||||||
|  |             ref="inputRef" | ||||||
|             v-if="!readonly && showInput" |             v-if="!readonly && showInput" | ||||||
|             type="text" |             type="text" | ||||||
|             class="editable-title-input" |             class="editable-title-input" | ||||||
|             @blur="blurEvent()" |             @blur="blurEvent()" | ||||||
|             v-model="currentNode.name" |             v-model:value="currentNode.name" | ||||||
|             :placeholder="currentNode.name" |             :placeholder="currentNode.name" | ||||||
|           /> |           /> | ||||||
|           <div v-else class="node-title" @click="clickTitle"> |           <div v-else class="node-title" @click="clickTitle"> | ||||||
|  |  | ||||||
|  | @ -36,7 +36,7 @@ const tasks = inject<Ref<any[]>>('tasks', ref([])); | ||||||
| // 监控节点变化 | // 监控节点变化 | ||||||
| const currentNode = useWatchNode(props); | const currentNode = useWatchNode(props); | ||||||
| // 节点名称编辑 | // 节点名称编辑 | ||||||
| const { showInput, blurEvent, clickTitle } = useNodeName2( | const { showInput, blurEvent, clickTitle, inputRef } = useNodeName2( | ||||||
|   currentNode, |   currentNode, | ||||||
|   BpmNodeTypeEnum.USER_TASK_NODE, |   BpmNodeTypeEnum.USER_TASK_NODE, | ||||||
| ); | ); | ||||||
|  | @ -87,11 +87,12 @@ function findReturnTaskNodes( | ||||||
|             </span> |             </span> | ||||||
|           </div> |           </div> | ||||||
|           <Input |           <Input | ||||||
|  |             ref="inputRef" | ||||||
|             v-if="!readonly && showInput" |             v-if="!readonly && showInput" | ||||||
|             type="text" |             type="text" | ||||||
|             class="editable-title-input" |             class="editable-title-input" | ||||||
|             @blur="blurEvent()" |             @blur="blurEvent()" | ||||||
|             v-model="currentNode.name" |             v-model:value="currentNode.name" | ||||||
|             :placeholder="currentNode.name" |             :placeholder="currentNode.name" | ||||||
|           /> |           /> | ||||||
|           <div v-else class="node-title" @click="clickTitle"> |           <div v-else class="node-title" @click="clickTitle"> | ||||||
|  |  | ||||||
|  | @ -12,7 +12,7 @@ import type { SystemPostApi } from '#/api/system/post'; | ||||||
| import type { SystemRoleApi } from '#/api/system/role'; | import type { SystemRoleApi } from '#/api/system/role'; | ||||||
| import type { SystemUserApi } from '#/api/system/user'; | import type { SystemUserApi } from '#/api/system/user'; | ||||||
| 
 | 
 | ||||||
| import { inject, ref, toRaw, unref, watch } from 'vue'; | import { inject, nextTick, ref, toRaw, unref, watch } from 'vue'; | ||||||
| 
 | 
 | ||||||
| import { | import { | ||||||
|   BpmNodeTypeEnum, |   BpmNodeTypeEnum, | ||||||
|  | @ -622,6 +622,8 @@ export function useNodeName(nodeType: BpmNodeTypeEnum) { | ||||||
|   const nodeName = ref<string>(); |   const nodeName = ref<string>(); | ||||||
|   // 节点名称输入框
 |   // 节点名称输入框
 | ||||||
|   const showInput = ref(false); |   const showInput = ref(false); | ||||||
|  |   // 输入框的引用
 | ||||||
|  |   const inputRef = ref<HTMLInputElement | null>(null); | ||||||
|   // 点击节点名称编辑图标
 |   // 点击节点名称编辑图标
 | ||||||
|   function clickIcon() { |   function clickIcon() { | ||||||
|     showInput.value = true; |     showInput.value = true; | ||||||
|  | @ -632,9 +634,19 @@ export function useNodeName(nodeType: BpmNodeTypeEnum) { | ||||||
|     nodeName.value = |     nodeName.value = | ||||||
|       nodeName.value || (NODE_DEFAULT_NAME.get(nodeType) as string); |       nodeName.value || (NODE_DEFAULT_NAME.get(nodeType) as string); | ||||||
|   } |   } | ||||||
|  |   // 监听 showInput 的变化,当变为 true 时自动聚焦
 | ||||||
|  |   watch(showInput, (value) => { | ||||||
|  |     if (value) { | ||||||
|  |       nextTick(() => { | ||||||
|  |         inputRef.value?.focus(); | ||||||
|  |       }); | ||||||
|  |     } | ||||||
|  |   }); | ||||||
|  | 
 | ||||||
|   return { |   return { | ||||||
|     nodeName, |     nodeName, | ||||||
|     showInput, |     showInput, | ||||||
|  |     inputRef, | ||||||
|     clickIcon, |     clickIcon, | ||||||
|     blurEvent, |     blurEvent, | ||||||
|   }; |   }; | ||||||
|  | @ -646,11 +658,24 @@ export function useNodeName2( | ||||||
| ) { | ) { | ||||||
|   // 显示节点名称输入框
 |   // 显示节点名称输入框
 | ||||||
|   const showInput = ref(false); |   const showInput = ref(false); | ||||||
|  |   // 输入框的引用
 | ||||||
|  |   const inputRef = ref<HTMLInputElement | null>(null); | ||||||
|  | 
 | ||||||
|  |   // 监听 showInput 的变化,当变为 true 时自动聚焦
 | ||||||
|  |   watch(showInput, (value) => { | ||||||
|  |     if (value) { | ||||||
|  |       nextTick(() => { | ||||||
|  |         inputRef.value?.focus(); | ||||||
|  |       }); | ||||||
|  |     } | ||||||
|  |   }); | ||||||
|  | 
 | ||||||
|   // 节点名称输入框失去焦点
 |   // 节点名称输入框失去焦点
 | ||||||
|   function blurEvent() { |   function blurEvent() { | ||||||
|     showInput.value = false; |     showInput.value = false; | ||||||
|     node.value.name = |     node.value.name = | ||||||
|       node.value.name || (NODE_DEFAULT_NAME.get(nodeType) as string); |       node.value.name || (NODE_DEFAULT_NAME.get(nodeType) as string); | ||||||
|  |     console.warn('node.value.name===>', node.value.name); | ||||||
|   } |   } | ||||||
|   // 点击节点标题进行输入
 |   // 点击节点标题进行输入
 | ||||||
|   function clickTitle() { |   function clickTitle() { | ||||||
|  | @ -658,6 +683,7 @@ export function useNodeName2( | ||||||
|   } |   } | ||||||
|   return { |   return { | ||||||
|     showInput, |     showInput, | ||||||
|  |     inputRef, | ||||||
|     clickTitle, |     clickTitle, | ||||||
|     blurEvent, |     blurEvent, | ||||||
|   }; |   }; | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	 jason
						jason