Skip to content

Commit b3a97b0

Browse files
committed
fix: 优化Simple设计器接口调用逻辑与去除loading效果
1 parent 8855b77 commit b3a97b0

File tree

1 file changed

+45
-17
lines changed

1 file changed

+45
-17
lines changed

src/components/SimpleProcessDesignerV2/src/SimpleProcessDesigner.vue

Lines changed: 45 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<div v-loading="loading" class="overflow-auto">
2+
<div class="overflow-auto">
33
<SimpleProcessModel
44
ref="simpleProcessModelRef"
55
v-if="processNodeTree"
@@ -56,7 +56,7 @@ const props = defineProps({
5656
required: false
5757
},
5858
// 可发起流程的人员编号
59-
startUserIds : {
59+
startUserIds: {
6060
type: Array,
6161
required: false
6262
},
@@ -75,6 +75,7 @@ const userOptions = ref<UserApi.UserVO[]>([]) // 用户列表
7575
const deptOptions = ref<DeptApi.DeptVO[]>([]) // 部门列表
7676
const deptTreeOptions = ref()
7777
const userGroupOptions = ref<UserGroupApi.UserGroupVO[]>([]) // 用户组列表
78+
const isDataInitialized = ref(false) // 添加标记,用于判断数据是否已初始化
7879
7980
// 添加当前值的引用
8081
const currentValue = ref<SimpleFlowNode | undefined>()
@@ -221,9 +222,32 @@ const validateNode = (node: SimpleFlowNode | undefined, errorNodes: SimpleFlowNo
221222
}
222223
}
223224
224-
onMounted(async () => {
225+
// 初始化数据的方法
226+
const initializeData = async () => {
227+
if (isDataInitialized.value) {
228+
return
229+
}
230+
225231
try {
226232
loading.value = true
233+
234+
// 并行加载所有数据
235+
const [roleList, postList, userList, deptList, userGroupList] = await Promise.all([
236+
RoleApi.getSimpleRoleList(),
237+
PostApi.getSimplePostList(),
238+
UserApi.getSimpleUserList(),
239+
DeptApi.getSimpleDeptList(),
240+
UserGroupApi.getUserGroupSimpleList()
241+
])
242+
243+
// 更新数据
244+
roleOptions.value = roleList
245+
postOptions.value = postList
246+
userOptions.value = userList
247+
deptOptions.value = deptList
248+
deptTreeOptions.value = handleTree(deptList as DeptApi.DeptVO[], 'id')
249+
userGroupOptions.value = userGroupList
250+
227251
// 获取表单字段
228252
if (props.modelId) {
229253
const bpmnModel = await getModel(props.modelId)
@@ -234,21 +258,7 @@ onMounted(async () => {
234258
formFields.value = bpmnForm?.fields
235259
}
236260
}
237-
}
238-
// 获得角色列表
239-
roleOptions.value = await RoleApi.getSimpleRoleList()
240-
// 获得岗位列表
241-
postOptions.value = await PostApi.getSimplePostList()
242-
// 获得用户列表
243-
userOptions.value = await UserApi.getSimpleUserList()
244-
// 获得部门列表
245-
deptOptions.value = await DeptApi.getSimpleDeptList()
246-
deptTreeOptions.value = handleTree(deptOptions.value as DeptApi.DeptVO[], 'id')
247-
// 获取用户组列表
248-
userGroupOptions.value = await UserGroupApi.getUserGroupSimpleList()
249261
250-
// 加载流程数据
251-
if (props.modelId) {
252262
// 获取 SIMPLE 设计器模型
253263
const result = await getBpmSimpleModel(props.modelId)
254264
if (result) {
@@ -261,9 +271,27 @@ onMounted(async () => {
261271
} else {
262272
updateModel()
263273
}
274+
275+
isDataInitialized.value = true
276+
} catch (error) {
277+
console.error('初始化数据失败:', error)
264278
} finally {
265279
loading.value = false
266280
}
281+
}
282+
283+
onMounted(async () => {
284+
await initializeData()
285+
})
286+
287+
// 添加 activated 生命周期钩子
288+
onActivated(() => {
289+
// 组件被激活时,只需要刷新视图
290+
if (isDataInitialized.value) {
291+
refresh()
292+
} else {
293+
initializeData()
294+
}
267295
})
268296
269297
const simpleProcessModelRef = ref()

0 commit comments

Comments
 (0)