Skip to content

Commit 066607a

Browse files
committed
【代码评审】工作流:新发起页的优化
1 parent d052356 commit 066607a

File tree

4 files changed

+65
-45
lines changed

4 files changed

+65
-45
lines changed

src/components/UserSelectForm/index.vue

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
<el-col :span="17" :offset="1">
1717
<el-transfer
1818
v-model="selectedUserIdList"
19+
:titles="['未选', '已选']"
1920
filterable
2021
filter-placeholder="搜索成员"
2122
:data="userList"
@@ -28,8 +29,9 @@
2829
:disabled="formLoading || !selectedUserIdList?.length"
2930
type="primary"
3031
@click="submitForm"
31-
>确 定</el-button
3232
>
33+
确 定
34+
</el-button>
3335
<el-button @click="dialogVisible = false">取 消</el-button>
3436
</template>
3537
</Dialog>
@@ -44,57 +46,70 @@ const emit = defineEmits<{
4446
confirm: [id: any, userList: any[]]
4547
}>()
4648
const { t } = useI18n() // 国际
49+
const message = useMessage() // 消息弹窗
50+
4751
const deptList = ref<Tree[]>([]) // 部门树形结构化
4852
const userList: any = ref([]) // 用户列表
49-
const message = useMessage() // 消息弹窗
5053
const selectedUserIdList: any = ref([]) // 选中的用户列表
5154
const dialogVisible = ref(false) // 弹窗的是否展示
5255
const formLoading = ref(false) // 表单的加载中
53-
const activityId = ref() // 主键id
56+
const activityId = ref() // 关联的主键编号 TODO @goldenzqqq:这个 activityId 有没可能不传递。在使用 @submitForm="xxx()" 时,传递的参数。目的是,更加解耦一些。
5457
5558
/** 打开弹窗 */
56-
const open = async (id, selectedList?) => {
59+
const open = async (id: number, selectedList?: any[]) => {
5760
activityId.value = id
61+
// 重置表单
5862
resetForm()
63+
64+
// 加载相关数据
5965
deptList.value = handleTree(await DeptApi.getSimpleDeptList())
6066
await getUserList()
61-
selectedUserIdList.value = selectedList?.map((item) => item.id)
62-
// 修改时,设置数据
67+
// 设置选中的用户列表
68+
selectedUserIdList.value = selectedList?.map((item: any) => item.id)
69+
70+
// 设置可见
6371
dialogVisible.value = true
6472
}
6573
66-
/* 获取用户列表 */
67-
const getUserList = async (deptId?) => {
74+
/** 获取用户列表 */
75+
const getUserList = async (deptId?: number) => {
6876
try {
6977
// @ts-ignore
78+
// TODO @芋艿:替换到 simple List
7079
const data = await UserApi.getUserPage({ pageSize: 100, pageNo: 1, deptId })
7180
userList.value = data.list
7281
} finally {
7382
}
7483
}
7584
85+
/** 提交选择 */
7686
const submitForm = async () => {
7787
// 提交请求
7888
formLoading.value = true
7989
try {
8090
message.success(t('common.updateSuccess'))
8191
dialogVisible.value = false
82-
const emitUserList = userList.value.filter((user) => selectedUserIdList.value.includes(user.id))
92+
const emitUserList = userList.value.filter((user: any) =>
93+
selectedUserIdList.value.includes(user.id)
94+
)
8395
// 发送操作成功的事件
8496
emit('confirm', activityId.value, emitUserList)
8597
} finally {
8698
formLoading.value = false
8799
}
88100
}
101+
102+
/** 重置表单 */
89103
const resetForm = () => {
90104
deptList.value = []
91105
userList.value = []
92106
selectedUserIdList.value = []
93107
}
94108
95109
/** 处理部门被点击 */
96-
const handleNodeClick = async (row: { [key: string]: any }) => {
110+
const handleNodeClick = (row: { [key: string]: any }) => {
97111
getUserList(row.id)
98112
}
113+
99114
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
100115
</script>

src/views/bpm/processInstance/create/ProcessDefinitionDetail.vue

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
<el-col :span="6" :offset="1">
2626
<!-- 流程时间线 -->
27+
<!-- TODO @芋艿:selectUserConfirm 调整一下,改成 activityNodes 里面的东西。 -->
2728
<ProcessInstanceTimeline
2829
ref="timelineRef"
2930
:activity-nodes="activityNodes"
@@ -89,6 +90,8 @@ defineOptions({ name: 'ProcessDefinitionDetail' })
8990
const props = defineProps<{
9091
selectProcessDefinition: any
9192
}>()
93+
const emit = defineEmits(['cancel'])
94+
9295
const { push, currentRoute } = useRouter() // 路由
9396
const message = useMessage() // 消息弹窗
9497
const { delView } = useTagsViewStore() // 视图操作
@@ -103,12 +106,10 @@ const fApi = ref<ApiAttrs>()
103106
const startUserSelectTasks: any = ref([]) // 发起人需要选择审批人的用户任务列表
104107
const startUserSelectAssignees = ref({}) // 发起人选择审批人的数据
105108
const bpmnXML: any = ref(null) // BPMN 数据
106-
const simpleJson = ref<string|undefined>() // Simple 设计器数据 json 格式
107-
/** 当前的Tab */
108-
const activeTab = ref('form')
109-
const emit = defineEmits(['cancel'])
110-
// 审批节点信息
111-
const activityNodes = ref<ProcessInstanceApi.ApprovalNodeInfo[]>([])
109+
const simpleJson = ref<string | undefined>() // Simple 设计器数据 json 格式
110+
111+
const activeTab = ref('form') // 当前的 Tab
112+
const activityNodes = ref<ProcessInstanceApi.ApprovalNodeInfo[]>([]) // 审批节点信息
112113
113114
/** 设置表单信息、获取流程图数据 **/
114115
const initProcessInfo = async (row: any, formVariables?: any) => {

src/views/bpm/processInstance/create/index.vue

Lines changed: 32 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<!-- 第一步,通过流程定义的列表,选择对应的流程 -->
33
<template v-if="!selectProcessDefinition">
44
<el-input
5-
v-model="currentSearchKey"
5+
v-model="searchName"
66
class="!w-50% mb-15px"
77
placeholder="请输入流程名称"
88
clearable
@@ -48,6 +48,7 @@
4848
v-for="definition in definitions"
4949
:key="definition.id"
5050
:content="definition.description"
51+
:disabled="!definition.description || definition.description.trim().length === 0"
5152
placement="top"
5253
>
5354
<el-card
@@ -93,20 +94,22 @@ defineOptions({ name: 'BpmProcessInstanceCreate' })
9394
const { proxy } = getCurrentInstance() as any
9495
const route = useRoute() // 路由
9596
const message = useMessage() // 消息
96-
const currentSearchKey = ref('') // 当前搜索关键字
97-
const processInstanceId: any = route.query.processInstanceId
97+
98+
const searchName = ref('') // 当前搜索关键字
99+
const processInstanceId: any = route.query.processInstanceId // 流程实例编号。场景:重新发起时
98100
const loading = ref(true) // 加载中
99101
const categoryList: any = ref([]) // 分类的列表
100102
const categoryActive: any = ref({}) // 选中的分类
101103
const processDefinitionList = ref([]) // 流程定义的列表
104+
102105
/** 查询列表 */
103106
const getList = async () => {
104107
loading.value = true
105108
try {
106109
// 所有流程分类数据
107110
await getCategoryList()
108111
// 所有流程定义数据
109-
await getDefinitionList()
112+
await getProcessDefinitionList()
110113
111114
// 如果 processInstanceId 非空,说明是重新发起
112115
if (processInstanceId?.length > 0) {
@@ -129,20 +132,21 @@ const getList = async () => {
129132
}
130133
}
131134
132-
// 获取所有流程分类数据
135+
/** 获取所有流程分类数据 */
133136
const getCategoryList = async () => {
134137
try {
135138
// 流程分类
136139
categoryList.value = await CategoryApi.getCategorySimpleList()
140+
// 选中首个分类
137141
if (categoryList.value.length > 0) {
138142
categoryActive.value = categoryList.value[0]
139143
}
140144
} finally {
141145
}
142146
}
143147
144-
// 获取所有流程定义数据
145-
const getDefinitionList = async () => {
148+
/** 获取所有流程定义数据 */
149+
const getProcessDefinitionList = async () => {
146150
try {
147151
// 流程定义
148152
processDefinitionList.value = await DefinitionApi.getProcessDefinitionList({
@@ -157,38 +161,25 @@ const getDefinitionList = async () => {
157161
/** 搜索流程 */
158162
const filteredProcessDefinitionList = ref([]) // 用于存储搜索过滤后的流程定义
159163
const handleQuery = () => {
160-
if (currentSearchKey.value.trim()) {
164+
if (searchName.value.trim()) {
161165
// 如果有搜索关键字,进行过滤
162166
filteredProcessDefinitionList.value = processDefinitionList.value.filter(
163-
(definition: any) =>
164-
definition.name.toLowerCase().includes(currentSearchKey.value.toLowerCase()) // 假设搜索依据是流程定义的名称
167+
(definition: any) => definition.name.toLowerCase().includes(searchName.value.toLowerCase()) // 假设搜索依据是流程定义的名称
165168
)
166169
} else {
167170
// 如果没有搜索关键字,恢复所有数据
168171
filteredProcessDefinitionList.value = processDefinitionList.value
169172
}
170173
}
171174
172-
// 流程定义的分组
175+
/** 流程定义的分组 */
173176
const processDefinitionGroup: any = computed(() => {
174177
if (!processDefinitionList.value?.length) return {}
175178
return groupBy(filteredProcessDefinitionList.value, 'category')
176179
})
177180
178-
// ========== 表单相关 ==========
179-
const selectProcessDefinition = ref() // 选择的流程定义
180-
const processDefinitionDetailRef = ref()
181-
182-
/** 处理选择流程的按钮操作 **/
183-
const handleSelect = async (row, formVariables?) => {
184-
// 设置选择的流程
185-
selectProcessDefinition.value = row
186-
// 初始化流程定义详情
187-
await nextTick()
188-
processDefinitionDetailRef.value?.initProcessInfo(row, formVariables)
189-
}
190-
// 左侧分类切换
191-
const handleCategoryClick = (category) => {
181+
/** 左侧分类切换 */
182+
const handleCategoryClick = (category: any) => {
192183
categoryActive.value = category
193184
const categoryRef = proxy.$refs[`category-${category.code}`] // 获取点击分类对应的 DOM 元素
194185
if (categoryRef?.length) {
@@ -200,9 +191,22 @@ const handleCategoryClick = (category) => {
200191
}
201192
}
202193
203-
// 通过分类code获取对应的名称
204-
const getCategoryName = (categoryCode) => {
205-
return categoryList.value?.find((ctg) => ctg.code === categoryCode)?.name
194+
/** 通过分类 code 获取对应的名称 */
195+
const getCategoryName = (categoryCode: string) => {
196+
return categoryList.value?.find((ctg: any) => ctg.code === categoryCode)?.name
197+
}
198+
199+
// ========== 表单相关 ==========
200+
const selectProcessDefinition = ref() // 选择的流程定义
201+
const processDefinitionDetailRef = ref()
202+
203+
/** 处理选择流程的按钮操作 **/
204+
const handleSelect = async (row, formVariables?) => {
205+
// 设置选择的流程
206+
selectProcessDefinition.value = row
207+
// 初始化流程定义详情
208+
await nextTick()
209+
processDefinitionDetailRef.value?.initProcessInfo(row, formVariables)
206210
}
207211
208212
/** 初始化 */

src/views/bpm/processInstance/detail/ProcessInstanceTimeline.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ const handleSelectUser = (activityId, selectedList) => {
283283
const emit = defineEmits<{
284284
selectUserConfirm: [id: any, userList: any[]]
285285
}>()
286-
const customApprover: any = ref({})
286+
const customApprover: any = ref({}) // key:activityId,value:用户列表 TODO 芋艿:变量改下
287287
// 选择完成
288288
const handleUserSelectConfirm = (activityId, userList) => {
289289
customApprover.value[activityId] = userList || []

0 commit comments

Comments
 (0)