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

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

View File

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

View File

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

View File

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