Skip to content

Commit 2c11228

Browse files
committed
仿钉钉流程设计- bug 修复
1 parent 538ad86 commit 2c11228

File tree

10 files changed

+215
-379
lines changed

10 files changed

+215
-379
lines changed

src/components/SimpleProcessDesignerV2/src/NodeHandler.vue

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ import {
4747
NodeType,
4848
NODE_DEFAULT_NAME,
4949
ApproveMethodType,
50-
RejectHandlerType,
51-
CandidateStrategy
50+
RejectHandlerType
5251
} from './consts'
5352
import { generateUUID } from '@/utils'
5453
defineOptions({
@@ -80,15 +79,13 @@ const addNode = (type: number) => {
8079
showText: '',
8180
type: NodeType.USER_TASK_NODE,
8281
approveMethod: ApproveMethodType.RRANDOM_SELECT_ONE_APPROVE,
83-
candidateStrategy: CandidateStrategy.USER,
8482
// 超时处理
8583
rejectHandler: {
8684
type: RejectHandlerType.FINISH_PROCESS
8785
},
8886
timeoutHandler: {
8987
enable: false
9088
},
91-
9289
childNode: props.childNode
9390
}
9491
emits('update:childNode', data)
@@ -99,9 +96,6 @@ const addNode = (type: number) => {
9996
name: NODE_DEFAULT_NAME.get(NodeType.COPY_TASK_NODE) as string,
10097
showText: '',
10198
type: NodeType.COPY_TASK_NODE,
102-
candidateStrategy: CandidateStrategy.USER,
103-
candidateParam: undefined,
104-
fieldsPermission: undefined,
10599
childNode: props.childNode
106100
}
107101
emits('update:childNode', data)

src/components/SimpleProcessDesignerV2/src/ProcessNodeTree.vue

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,19 @@
33
<StartEventNode
44
v-if="currentNode && currentNode.type === NodeType.START_EVENT_NODE"
55
:flow-node="currentNode"
6-
@update:model-value="handleModelValueUpdate"
76
/>
87
<!-- 审批节点 -->
98
<UserTaskNode
109
v-if="currentNode && currentNode.type === NodeType.USER_TASK_NODE"
1110
:flow-node="currentNode"
12-
@update:model-value="handleModelValueUpdate"
11+
@update:flow-node="handleModelValueUpdate"
1312
@find:parent-node="findFromParentNode"
1413
/>
1514
<!-- 抄送节点 -->
1615
<CopyTaskNode
1716
v-if="currentNode && currentNode.type === NodeType.COPY_TASK_NODE"
1817
:flow-node="currentNode"
19-
@update:model-value="handleModelValueUpdate"
18+
@update:flow-node="handleModelValueUpdate"
2019
/>
2120
<!-- 条件节点 -->
2221
<ExclusiveNode
@@ -25,8 +24,8 @@
2524
@update:model-value="handleModelValueUpdate"
2625
@find:parent-node="findFromParentNode"
2726
/>
28-
<!-- 并行节点 -->
29-
<ParallelNode
27+
<!-- 并行节点 -->
28+
<ParallelNode
3029
v-if="currentNode && currentNode.type === NodeType.PARALLEL_NODE_FORK"
3130
:flow-node="currentNode"
3231
@update:model-value="handleModelValueUpdate"
@@ -36,7 +35,7 @@
3635
<ProcessNodeTree
3736
v-if="currentNode && currentNode.childNode"
3837
v-model:flow-node="currentNode.childNode"
39-
:parent-node= "currentNode"
38+
:parent-node="currentNode"
4039
@find:recursive-find-parent-node="recursiveFindParentNode"
4140
/>
4241

@@ -65,11 +64,14 @@ const props = defineProps({
6564
}
6665
})
6766
const emits = defineEmits<{
68-
'update:flowNode',
69-
'find:recursiveFindParentNode': [nodeList: SimpleFlowNode[], curentNode: SimpleFlowNode, nodeType: number]
67+
'update:flowNode': [node: SimpleFlowNode | undefined]
68+
'find:recursiveFindParentNode': [
69+
nodeList: SimpleFlowNode[],
70+
curentNode: SimpleFlowNode,
71+
nodeType: number
72+
]
7073
}>()
7174
72-
7375
const currentNode = ref<SimpleFlowNode>(props.flowNode)
7476
7577
// 重要:监控节点变化. 重新绘制节点
@@ -79,16 +81,12 @@ watch(
7981
currentNode.value = newValue
8082
}
8183
)
82-
84+
// 用于删除节点
8385
const handleModelValueUpdate = (updateValue) => {
84-
console.log('Process Node Tree handleModelValueUpdate', updateValue)
8586
emits('update:flowNode', updateValue)
8687
}
8788
88-
const findFromParentNode = (
89-
nodeList: SimpleFlowNode[],
90-
nodeType: number
91-
) => {
89+
const findFromParentNode = (nodeList: SimpleFlowNode[], nodeType: number) => {
9290
emits('find:recursiveFindParentNode', nodeList, props.parentNode, nodeType)
9391
}
9492

src/components/SimpleProcessDesignerV2/src/SimpleProcessDesigner.vue

Lines changed: 24 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,29 @@
1515
</div>
1616
</div>
1717
<div class="scale-container" :style="`transform: scale(${scaleValue / 100});`">
18-
<ProcessNodeTree v-if="processNodeTree" v-model:flow-node="processNodeTree" />
18+
<ProcessNodeTree v-if="processNodeTree" v-model:flow-node="processNodeTree" />
1919
</div>
2020
</div>
2121
<Dialog v-model="errorDialogVisible" title="保存失败" width="400" :fullscreen="false">
2222
<div class="mb-2">以下节点内容不完善,请修改后保存</div>
23-
<div class="mb-3 b-rounded-1 bg-gray-100 p-2 line-height-normal" v-for="(item, index) in errorNodes" :key="index">
24-
{{ item.name }} : {{ NODE_DEFAULT_TEXT.get(item.type) }}
23+
<div
24+
class="mb-3 b-rounded-1 bg-gray-100 p-2 line-height-normal"
25+
v-for="(item, index) in errorNodes"
26+
:key="index"
27+
>
28+
{{ item.name }} : {{ NODE_DEFAULT_TEXT.get(item.type) }}
2529
</div>
2630
<template #footer>
27-
<el-button type="primary" @click="errorDialogVisible = false" >知道了</el-button>
31+
<el-button type="primary" @click="errorDialogVisible = false">知道了</el-button>
2832
</template>
2933
</Dialog>
3034
</div>
3135
</template>
3236

3337
<script setup lang="ts">
34-
import ProcessNodeTree from './ProcessNodeTree.vue';
38+
import ProcessNodeTree from './ProcessNodeTree.vue'
3539
import { updateBpmSimpleModel, getBpmSimpleModel } from '@/api/bpm/simple'
36-
import { SimpleFlowNode, NodeType,NODE_DEFAULT_TEXT } from './consts'
40+
import { SimpleFlowNode, NodeType, NODE_DEFAULT_TEXT } from './consts'
3741
3842
defineOptions({
3943
name: 'SimpleProcessDesigner'
@@ -44,33 +48,11 @@ const props = defineProps({
4448
modelId: String
4549
})
4650
const message = useMessage() // 国际化
47-
const processNodeTree = ref<SimpleFlowNode>({
48-
name: '开始',
49-
type: NodeType.START_EVENT_NODE,
50-
id: 'StartEvent_1',
51-
childNode: {
52-
id: 'EndEvent_1',
53-
name: '结束',
54-
type: NodeType.END_EVENT_NODE
55-
}
56-
})
57-
58-
// const rootNode = ref<SimpleFlowNode>({
59-
// name: '开始',
60-
// type: NodeType.START_EVENT_NODE,
61-
// id: 'StartEvent_1'
62-
// })
63-
64-
// const childNode = ref<SimpleFlowNode>({
65-
// id: 'EndEvent_1',
66-
// name: '结束',
67-
// type: NodeType.END_EVENT_NODE
68-
// })
51+
const processNodeTree = ref<SimpleFlowNode | undefined>()
6952
7053
const errorDialogVisible = ref(false)
7154
let errorNodes: SimpleFlowNode[] = []
7255
const saveSimpleFlowModel = async () => {
73-
console.log('processNodeTree===>', processNodeTree.value)
7456
if (!props.modelId) {
7557
message.error('缺少模型 modelId 编号')
7658
return
@@ -79,7 +61,7 @@ const saveSimpleFlowModel = async () => {
7961
validateNode(processNodeTree.value, errorNodes)
8062
if (errorNodes.length > 0) {
8163
errorDialogVisible.value = true
82-
return;
64+
return
8365
}
8466
const data = {
8567
id: props.modelId,
@@ -93,7 +75,6 @@ const saveSimpleFlowModel = async () => {
9375
} else {
9476
message.alert('修改失败')
9577
}
96-
9778
}
9879
// 校验节点设置。 暂时以 showText 为空 未节点错误配置
9980
const validateNode = (node: SimpleFlowNode | undefined, errorNodes: SimpleFlowNode[]) => {
@@ -158,10 +139,19 @@ const zoomIn = () => {
158139
onMounted(async () => {
159140
const result = await getBpmSimpleModel(props.modelId)
160141
if (result) {
161-
console.log('the result is ', result)
162142
processNodeTree.value = result
163-
// rootNode.value = result
164-
// childNode.value = result.childNode
143+
} else {
144+
// 初始值
145+
processNodeTree.value = {
146+
name: '开始',
147+
type: NodeType.START_EVENT_NODE,
148+
id: 'StartEvent_1',
149+
childNode: {
150+
id: 'EndEvent_1',
151+
name: '结束',
152+
type: NodeType.END_EVENT_NODE
153+
}
154+
}
165155
}
166156
})
167157
</script>

src/components/SimpleProcessDesignerV2/src/nodes-config/CopyTaskNodeConfig.vue

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
class="config-editable-input"
1515
@blur="blurEvent()"
1616
v-mountedFocus
17-
v-model="currentNode.name"
18-
:placeholder="currentNode.name"
17+
v-model="configForm.name"
18+
:placeholder="configForm.name"
1919
/>
2020
<div v-else class="node-name"
21-
>{{ currentNode.name }}
21+
>{{ configForm.name }}
2222
<Icon class="ml-1" icon="ep:edit-pen" :size="16" @click="clickIcon()"
2323
/></div>
2424

@@ -223,8 +223,15 @@ const props = defineProps({
223223
})
224224
// 是否可见
225225
const settingVisible = ref(false)
226-
// 当前节点信息
226+
// 当前节点
227227
const currentNode = ref<SimpleFlowNode>(props.flowNode)
228+
// 监控节点变化
229+
watch(
230+
() => props.flowNode,
231+
(newValue) => {
232+
currentNode.value = newValue
233+
}
234+
)
228235
const roleOptions = inject<Ref<RoleApi.RoleVO[]>>('roleList') // 角色列表
229236
const postOptions = inject<Ref<PostApi.PostVO[]>>('postList') // 岗位列表
230237
const userOptions = inject<Ref<UserApi.UserVO[]>>('userList') // 用户列表
@@ -247,13 +254,14 @@ const activeTabName = ref('user')
247254
const formRef = ref() // 表单 Ref
248255
249256
const configForm = ref<any>({
257+
name: NODE_DEFAULT_NAME.get(NodeType.COPY_TASK_NODE),
250258
candidateParamArray: [],
251259
candidateStrategy: CandidateStrategy.USER,
252260
fieldsPermission: []
253261
})
254262
// 表单校验规则
255263
const formRules = reactive({
256-
candidateStrategy: [{ required: true }],
264+
candidateStrategy: [{ required: true, message: '抄送人设置不能为空', trigger: 'change' }],
257265
candidateParamArray: [{ required: true, message: '选项不能为空', trigger: 'blur' }]
258266
})
259267
@@ -269,6 +277,7 @@ const saveConfig = async () => {
269277
if (!valid) return false
270278
const showText = getShowText()
271279
if (!showText) return false
280+
currentNode.value.name = configForm.value.name
272281
currentNode.value.candidateParam = configForm.value.candidateParamArray?.join(',')
273282
currentNode.value.candidateStrategy = configForm.value.candidateStrategy
274283
currentNode.value.showText = showText
@@ -280,11 +289,10 @@ const saveConfig = async () => {
280289
const open = () => {
281290
settingVisible.value = true
282291
}
283-
// 修改当前编辑的节点, 由父组件传过来
292+
// 设置抄送节点
284293
const setCurrentNode = (node: SimpleFlowNode) => {
285-
currentNode.value = node
286-
configForm.value.fieldsPermission =
287-
cloneDeep(node.fieldsPermission) || getDefaultFieldsPermission(formFields?.value)
294+
configForm.value.name = node.name
295+
// 抄送人设置
288296
configForm.value.candidateStrategy = node.candidateStrategy
289297
const strCandidateParam = node?.candidateParam
290298
if (node.candidateStrategy === CandidateStrategy.EXPRESSION) {
@@ -294,6 +302,9 @@ const setCurrentNode = (node: SimpleFlowNode) => {
294302
configForm.value.candidateParamArray = strCandidateParam.split(',').map((item) => +item)
295303
}
296304
}
305+
// 表单字段权限
306+
configForm.value.fieldsPermission =
307+
cloneDeep(node.fieldsPermission) || getDefaultFieldsPermission(formFields?.value)
297308
}
298309
299310
defineExpose({ open, setCurrentNode }) // 暴露方法给父组件
@@ -387,16 +398,9 @@ const clickIcon = () => {
387398
// 输入框失去焦点
388399
const blurEvent = () => {
389400
showInput.value = false
390-
currentNode.value.name =
391-
currentNode.value.name || (NODE_DEFAULT_NAME.get(NodeType.COPY_TASK_NODE) as string)
401+
configForm.value.name =
402+
configForm.value.name || (NODE_DEFAULT_NAME.get(NodeType.COPY_TASK_NODE) as string)
392403
}
393404
</script>
394405

395-
<style lang="scss" scoped>
396-
// ::v-deep(.el-divider--horizontal) {
397-
// display: block;
398-
// height: 1px;
399-
// margin: 0;
400-
// border-top: 1px var(--el-border-color) var(--el-border-style);
401-
// }
402-
</style>
406+
<style lang="scss" scoped></style>

0 commit comments

Comments
 (0)