【代码评审】工作流:详情界面

This commit is contained in:
YunaiV 2024-11-19 13:18:58 +08:00
parent 3783582b33
commit 6304a8e9b6
2 changed files with 23 additions and 29 deletions

View File

@ -5,7 +5,7 @@
<ContentWrap class="h-1/1">
<el-tree
ref="treeRef"
:data="deptList"
:data="deptTree"
:expand-on-click-node="false"
:props="defaultProps"
default-expand-all
@ -39,7 +39,7 @@
</Dialog>
</template>
<script lang="ts" setup>
import { defaultProps, handleTree } from '@/utils/tree'
import { defaultProps, findTreeNode, handleTree } from '@/utils/tree'
import * as DeptApi from '@/api/system/dept'
import * as UserApi from '@/api/system/user'
@ -49,27 +49,27 @@ const emit = defineEmits<{
}>()
const { t } = useI18n() //
const message = useMessage() //
const deptList = ref<Tree[]>([]) //
const allUserList = ref<UserApi.UserVO[]>([]) //
const deptTree = ref<Tree[]>([]) //
const userList = ref<UserApi.UserVO[]>([]) //
const filteredUserList = ref<UserApi.UserVO[]>([]) //
const selectedUserIdList: any = ref([]) //
const dialogVisible = ref(false) //
const formLoading = ref(false) //
const activityId = ref()
//
/** 计算属性:合并已选择的用户和当前部门过滤后的用户 */
const transferUserList = computed(() => {
//
const selectedUsers = allUserList.value.filter((user: any) =>
// 1.1
const selectedUsers = userList.value.filter((user: any) =>
selectedUserIdList.value.includes(user.id)
)
//
// 1.2
const filteredUnselectedUsers = filteredUserList.value.filter(
(user: any) => !selectedUserIdList.value.includes(user.id)
)
//
// 2.
return [...selectedUsers, ...filteredUnselectedUsers]
})
@ -78,23 +78,15 @@ const open = async (id: number, selectedList?: any[]) => {
activityId.value = id
resetForm()
deptList.value = handleTree(await DeptApi.getSimpleDeptList())
//
await getAllUserList()
//
deptTree.value = handleTree(await DeptApi.getSimpleDeptList())
userList.value = await UserApi.getSimpleUserList()
//
filteredUserList.value = [...allUserList.value]
filteredUserList.value = [...userList.value]
selectedUserIdList.value = selectedList?.map((item: any) => item.id) || []
dialogVisible.value = true
}
/** 获取所有用户列表 */
const getAllUserList = async () => {
try {
// @ts-ignore
const data = await UserApi.getSimpleUserList()
allUserList.value = data
} finally {
}
}
/** 获取部门过滤后的用户列表 */
const getUserList = async (deptId?: number) => {
@ -102,6 +94,7 @@ const getUserList = async (deptId?: number) => {
try {
// @ts-ignore
// TODO @ simple List deptId
// TODO @Zqqq使 deptList deptId userList
const data = await UserApi.getUserPage({ pageSize: 100, pageNo: 1, deptId })
//
filteredUserList.value = data.list
@ -116,7 +109,7 @@ const submitForm = async () => {
message.success(t('common.updateSuccess'))
dialogVisible.value = false
//
const emitUserList = allUserList.value.filter((user: any) =>
const emitUserList = userList.value.filter((user: any) =>
selectedUserIdList.value.includes(user.id)
)
//
@ -127,8 +120,8 @@ const submitForm = async () => {
/** 重置表单 */
const resetForm = () => {
deptList.value = []
allUserList.value = []
deptTree.value = []
userList.value = []
filteredUserList.value = []
selectedUserIdList.value = []
}

View File

@ -174,17 +174,18 @@ const handleQuery = () => {
/** 流程定义的分组 */
const processDefinitionGroup: any = computed(() => {
if (!processDefinitionList.value?.length) return {}
const grouped = groupBy(filteredProcessDefinitionList.value, 'category')
if (!processDefinitionList.value?.length) {
return {}
}
const orderedGroup = {}
const grouped = groupBy(filteredProcessDefinitionList.value, 'category')
// categoryList
const orderedGroup = {}
categoryList.value.forEach((category: any) => {
if (grouped[category.code]) {
orderedGroup[category.code] = grouped[category.code]
}
})
return orderedGroup
})