【代码评审】工作流:新发起页的优化

pull/582/head
YunaiV 2024-11-08 23:01:23 +08:00
parent d052356ff0
commit 066607ab08
4 changed files with 65 additions and 45 deletions

View File

@ -16,6 +16,7 @@
<el-col :span="17" :offset="1">
<el-transfer
v-model="selectedUserIdList"
:titles="['未选', '已选']"
filterable
filter-placeholder="搜索成员"
:data="userList"
@ -28,8 +29,9 @@
:disabled="formLoading || !selectedUserIdList?.length"
type="primary"
@click="submitForm"
> </el-button
>
</el-button>
<el-button @click="dialogVisible = false"> </el-button>
</template>
</Dialog>
@ -44,48 +46,60 @@ const emit = defineEmits<{
confirm: [id: any, userList: any[]]
}>()
const { t } = useI18n() //
const message = useMessage() //
const deptList = ref<Tree[]>([]) //
const userList: any = ref([]) //
const message = useMessage() //
const selectedUserIdList: any = ref([]) //
const dialogVisible = ref(false) //
const formLoading = ref(false) //
const activityId = ref() // id
const activityId = ref() // TODO @goldenzqqq activityId 使 @submitForm="xxx()"
/** 打开弹窗 */
const open = async (id, selectedList?) => {
const open = async (id: number, selectedList?: any[]) => {
activityId.value = id
//
resetForm()
//
deptList.value = handleTree(await DeptApi.getSimpleDeptList())
await getUserList()
selectedUserIdList.value = selectedList?.map((item) => item.id)
//
//
selectedUserIdList.value = selectedList?.map((item: any) => item.id)
//
dialogVisible.value = true
}
/* 获取用户列表 */
const getUserList = async (deptId?) => {
/** 获取用户列表 */
const getUserList = async (deptId?: number) => {
try {
// @ts-ignore
// TODO @ simple List
const data = await UserApi.getUserPage({ pageSize: 100, pageNo: 1, deptId })
userList.value = data.list
} finally {
}
}
/** 提交选择 */
const submitForm = async () => {
//
formLoading.value = true
try {
message.success(t('common.updateSuccess'))
dialogVisible.value = false
const emitUserList = userList.value.filter((user) => selectedUserIdList.value.includes(user.id))
const emitUserList = userList.value.filter((user: any) =>
selectedUserIdList.value.includes(user.id)
)
//
emit('confirm', activityId.value, emitUserList)
} finally {
formLoading.value = false
}
}
/** 重置表单 */
const resetForm = () => {
deptList.value = []
userList.value = []
@ -93,8 +107,9 @@ const resetForm = () => {
}
/** 处理部门被点击 */
const handleNodeClick = async (row: { [key: string]: any }) => {
const handleNodeClick = (row: { [key: string]: any }) => {
getUserList(row.id)
}
defineExpose({ open }) // open
</script>

View File

@ -24,6 +24,7 @@
<el-col :span="6" :offset="1">
<!-- 流程时间线 -->
<!-- TODO @芋艿selectUserConfirm 调整一下改成 activityNodes 里面的东西 -->
<ProcessInstanceTimeline
ref="timelineRef"
:activity-nodes="activityNodes"
@ -89,6 +90,8 @@ defineOptions({ name: 'ProcessDefinitionDetail' })
const props = defineProps<{
selectProcessDefinition: any
}>()
const emit = defineEmits(['cancel'])
const { push, currentRoute } = useRouter() //
const message = useMessage() //
const { delView } = useTagsViewStore() //
@ -103,12 +106,10 @@ const fApi = ref<ApiAttrs>()
const startUserSelectTasks: any = ref([]) //
const startUserSelectAssignees = ref({}) //
const bpmnXML: any = ref(null) // BPMN
const simpleJson = ref<string|undefined>() // Simple json
/** 当前的Tab */
const activeTab = ref('form')
const emit = defineEmits(['cancel'])
//
const activityNodes = ref<ProcessInstanceApi.ApprovalNodeInfo[]>([])
const simpleJson = ref<string | undefined>() // Simple json
const activeTab = ref('form') // Tab
const activityNodes = ref<ProcessInstanceApi.ApprovalNodeInfo[]>([]) //
/** 设置表单信息、获取流程图数据 **/
const initProcessInfo = async (row: any, formVariables?: any) => {

View File

@ -2,7 +2,7 @@
<!-- 第一步通过流程定义的列表选择对应的流程 -->
<template v-if="!selectProcessDefinition">
<el-input
v-model="currentSearchKey"
v-model="searchName"
class="!w-50% mb-15px"
placeholder="请输入流程名称"
clearable
@ -48,6 +48,7 @@
v-for="definition in definitions"
:key="definition.id"
:content="definition.description"
:disabled="!definition.description || definition.description.trim().length === 0"
placement="top"
>
<el-card
@ -93,12 +94,14 @@ defineOptions({ name: 'BpmProcessInstanceCreate' })
const { proxy } = getCurrentInstance() as any
const route = useRoute() //
const message = useMessage() //
const currentSearchKey = ref('') //
const processInstanceId: any = route.query.processInstanceId
const searchName = ref('') //
const processInstanceId: any = route.query.processInstanceId //
const loading = ref(true) //
const categoryList: any = ref([]) //
const categoryActive: any = ref({}) //
const processDefinitionList = ref([]) //
/** 查询列表 */
const getList = async () => {
loading.value = true
@ -106,7 +109,7 @@ const getList = async () => {
//
await getCategoryList()
//
await getDefinitionList()
await getProcessDefinitionList()
// processInstanceId
if (processInstanceId?.length > 0) {
@ -129,11 +132,12 @@ const getList = async () => {
}
}
//
/** 获取所有流程分类数据 */
const getCategoryList = async () => {
try {
//
categoryList.value = await CategoryApi.getCategorySimpleList()
//
if (categoryList.value.length > 0) {
categoryActive.value = categoryList.value[0]
}
@ -141,8 +145,8 @@ const getCategoryList = async () => {
}
}
//
const getDefinitionList = async () => {
/** 获取所有流程定义数据 */
const getProcessDefinitionList = async () => {
try {
//
processDefinitionList.value = await DefinitionApi.getProcessDefinitionList({
@ -157,11 +161,10 @@ const getDefinitionList = async () => {
/** 搜索流程 */
const filteredProcessDefinitionList = ref([]) //
const handleQuery = () => {
if (currentSearchKey.value.trim()) {
if (searchName.value.trim()) {
//
filteredProcessDefinitionList.value = processDefinitionList.value.filter(
(definition: any) =>
definition.name.toLowerCase().includes(currentSearchKey.value.toLowerCase()) //
(definition: any) => definition.name.toLowerCase().includes(searchName.value.toLowerCase()) //
)
} else {
//
@ -169,12 +172,30 @@ const handleQuery = () => {
}
}
//
/** 流程定义的分组 */
const processDefinitionGroup: any = computed(() => {
if (!processDefinitionList.value?.length) return {}
return groupBy(filteredProcessDefinitionList.value, 'category')
})
/** 左侧分类切换 */
const handleCategoryClick = (category: any) => {
categoryActive.value = category
const categoryRef = proxy.$refs[`category-${category.code}`] // DOM
if (categoryRef?.length) {
const scrollWrapper = proxy.$refs.scrollWrapper //
const categoryOffsetTop = categoryRef[0].offsetTop
//
scrollWrapper.scrollTo({ top: categoryOffsetTop, behavior: 'smooth' })
}
}
/** 通过分类 code 获取对应的名称 */
const getCategoryName = (categoryCode: string) => {
return categoryList.value?.find((ctg: any) => ctg.code === categoryCode)?.name
}
// ========== ==========
const selectProcessDefinition = ref() //
const processDefinitionDetailRef = ref()
@ -187,23 +208,6 @@ const handleSelect = async (row, formVariables?) => {
await nextTick()
processDefinitionDetailRef.value?.initProcessInfo(row, formVariables)
}
//
const handleCategoryClick = (category) => {
categoryActive.value = category
const categoryRef = proxy.$refs[`category-${category.code}`] // DOM
if (categoryRef?.length) {
const scrollWrapper = proxy.$refs.scrollWrapper //
const categoryOffsetTop = categoryRef[0].offsetTop
//
scrollWrapper.scrollTo({ top: categoryOffsetTop, behavior: 'smooth' })
}
}
// code
const getCategoryName = (categoryCode) => {
return categoryList.value?.find((ctg) => ctg.code === categoryCode)?.name
}
/** 初始化 */
onMounted(() => {

View File

@ -283,7 +283,7 @@ const handleSelectUser = (activityId, selectedList) => {
const emit = defineEmits<{
selectUserConfirm: [id: any, userList: any[]]
}>()
const customApprover: any = ref({})
const customApprover: any = ref({}) // keyactivityIdvalue TODO
//
const handleUserSelectConfirm = (activityId, userList) => {
customApprover.value[activityId] = userList || []