diff --git a/src/views/system/configuration/components/workloadPermission.vue b/src/views/system/configuration/components/workloadPermission.vue index a7690e0b..c8227cd6 100644 --- a/src/views/system/configuration/components/workloadPermission.vue +++ b/src/views/system/configuration/components/workloadPermission.vue @@ -171,17 +171,35 @@ const leftParams = ref({ }); const leftCheckedData = ref([]); // 更新选中数据 -const leftChangeFun = (data: any) => { +const leftChangeFun = async (data: any) => { if (data.checked) { leftCheckedData.value.push(data.row); } else { leftCheckedData.value = leftCheckedData.value.filter( (item: any) => item.userId !== data.row.userId ); + // 获取取消勾选的负责人关联的用户 + const params = { + userIds: [data.row.userId], + relationType: 1, + }; + const { data: relatedData } = await queryRelatedUserIdsApi(params); + // 从右侧列表中移除这些用户 + if (relatedData && relatedData.length > 0) { + const relatedUserIds = relatedData.map((item: any) => item.userId); + rightCheckedData.value = rightCheckedData.value.filter( + (item: any) => !relatedUserIds.includes(item.userId) + ); + if (leftCheckedData.value.length == 0) { + rightTableDataLoad(); + } + } + // 获取当前左侧勾选用户的关联用户 + getRelatedUserIds(); } }; // 更新全选 -const leftAllChangeFun = (data: any) => { +const leftAllChangeFun = async (data: any) => { if (data.checked) { leftCheckedData.value = [...leftCheckedData.value, ...leftTableRef.value.tableData]; // 根据id去重 @@ -190,9 +208,30 @@ const leftAllChangeFun = (data: any) => { arr.findIndex((i: any) => i.userId === item.userId) === index ); } else { + // 更新左侧表格已选数据 leftCheckedData.value = leftCheckedData.value.filter((item: any) => { return !leftTableRef.value.tableData.some((i: any) => i.userId === item.userId); }); + if (leftCheckedData.value.length > 0) { + // 获取取消勾选的所有负责人关联的用户 + const params = { + userIds: leftTableRef.value.tableData.map((item: any) => item.userId), + relationType: 1, + }; + const { data: relatedData } = await queryRelatedUserIdsApi(params); + // 从右侧列表中移除这些用户 + if (relatedData && relatedData.length > 0) { + const relatedUserIds = relatedData.map((item: any) => item.userId); + rightCheckedData.value = rightCheckedData.value.filter( + (item: any) => !relatedUserIds.includes(item.userId) + ); + } + // 获取当前左侧勾选用户的关联用户并更新 + getRelatedUserIds(); + } else { + rightCheckedData.value = []; + rightTableRef.value.tableRef.clearCheckboxRow(); + } } }; const leftTableDataLoad = () => { @@ -220,7 +259,6 @@ const updateRightCheckData = (data: any) => { (item: any, index: number, arr: any) => arr.findIndex((i: any) => i.userId === item.userId) === index ); - // console.log(rightCheckedData.value, 'rightCheckedData.value'); rightTableDataLoad(); }; @@ -229,8 +267,8 @@ const getRelatedUserIds = async () => { userIds: leftCheckedData.value.map((item: any) => item.userId), relationType: 1, }; + if (params.userIds.length == 0) return; const { data } = await queryRelatedUserIdsApi(params); - console.log(data, 'data'); updateRightCheckData(data); }; watch( @@ -287,7 +325,6 @@ const rightChangeFun = (data: any) => { const rightAllChangeFun = (data: any) => { if (data.checked) { rightCheckedData.value = [...rightCheckedData.value, ...rightTableRef.value.tableData]; - console.log(rightCheckedData.value, 'rightCheckedData.value'); // 根据id去重 rightCheckedData.value = rightCheckedData.value.filter( (item: any, index: number, arr: any) => @@ -300,6 +337,7 @@ const rightAllChangeFun = (data: any) => { } }; const rightTableDataLoad = () => { + rightTableRef.value?.tableRef?.clearCheckboxRow(); nextTick(() => { const selectedKeys = rightCheckedData.value.map((item: any) => item.userId); rightTableRef.value.tableRef.setCheckboxRowKey(selectedKeys, true); // 设置为选中 @@ -331,7 +369,6 @@ const relateConfirm = () => { }); }; const relateFun = async () => { - console.log(leftCheckedData.value, rightCheckedData.value); const params = { userIds: leftCheckedData.value.map((item: any) => item.userId), relatedUserIds: rightCheckedData.value.map((item: any) => item.userId), diff --git a/src/views/system/configuration/index.vue b/src/views/system/configuration/index.vue index 7b9e1c95..07ca4b47 100644 --- a/src/views/system/configuration/index.vue +++ b/src/views/system/configuration/index.vue @@ -24,7 +24,7 @@ - + @@ -38,7 +38,7 @@ import Review from './components/review.vue'; import roleDiscipline from './components/roleDiscipline.vue'; import physicalUnits from './components/physicalUnits.vue'; import workforceAllocation from './components/workforceAllocation.vue'; -// import workloadPermission from './components/workloadPermission.vue'; +import workloadPermission from './components/workloadPermission.vue'; import { ref } from 'vue'; import { getPageStorage, setPageStorage } from '@/utils/common'; @@ -63,10 +63,10 @@ const configList = [ label: '工种配置', value: 'workforceAllocation', }, - // { - // label: '负载权限配置', - // value: 'workloadPermission', - // }, + { + label: '负载权限配置', + value: 'workloadPermission', + }, { label: '其他配置', value: 'other', diff --git a/src/views/task/workLoad/index.vue b/src/views/task/workLoad/index.vue index 51a8c0db..3320cae1 100644 --- a/src/views/task/workLoad/index.vue +++ b/src/views/task/workLoad/index.vue @@ -3,7 +3,7 @@
- + { }, 200); }; -const groupList = ref([]); -const getUserGroupFun = async () => { - if (props.dimension !== 'person') { - return; - } - const res: any = await userQueryGroupApi({ - current: 1, - size: 999, - }); - if (res && res.code === 200) { - groupList.value = res.data.data; - if (groupList.value?.length) { - // 默认选择仿真组 - filterFprmData.userGroupId = - groupList.value.filter((v: any) => v.groupCode === '67-6718')[0]?.id || ''; - if (filterFprmData.userGroupId) { - queryGroupUserListFun(filterFprmData.userGroupId); - } - } - } -}; +// const groupList = ref([]); +// const getUserGroupFun = async () => { +// if (props.dimension !== 'person') { +// return; +// } +// const res: any = await userQueryGroupApi({ +// current: 1, +// size: 999, +// }); +// if (res && res.code === 200) { +// groupList.value = res.data.data; +// if (groupList.value?.length) { +// // 默认选择仿真组 +// filterFprmData.userGroupId = +// groupList.value.filter((v: any) => v.groupCode === '67-6718')[0]?.id || ''; +// if (filterFprmData.userGroupId) { +// queryGroupUserListFun(filterFprmData.userGroupId); +// } +// } +// } +// }; const userList = ref([]); // 获取用户组内成员 -const queryGroupUserListFun = async (id: any) => { - if (!id) { - userList.value = []; - return; - } - const res: any = await userQueryGroupDetailApi({ - id, - current: 1, - size: 999, - }); +// const queryGroupUserListFun = async (id: any) => { +// if (!id) { +// userList.value = []; +// return; +// } +// const res: any = await userQueryGroupDetailApi({ +// id, +// current: 1, +// size: 999, +// }); - if (res && res.code === 200) { - const usrids = res.data.users.data.map((item: any) => { - return item.userId; - }); +// if (res && res.code === 200) { +// const usrids = res.data.users.data.map((item: any) => { +// return item.userId; +// }); - userList.value = res.data.users.data; +// userList.value = res.data.users.data; - return usrids; - } else { - return []; - } -}; +// return usrids; +// } else { +// return []; +// } +// }; const getWorkLoadDataFun = async () => { loading.value = true; Gantt.clearAll(); @@ -328,6 +328,9 @@ const getWorkLoadDataFun = async () => { } } else { param.tag1 = param.projectIdList; + param.userIds = param.userIds.length + ? param.userIds + : userList.value.map((item: any) => item.userId); delete param.projectIdList; } const res: any = await props.api(param); @@ -392,7 +395,7 @@ const formatUserTask = (data: any, time: any) => { }; // 获取用户工作负载信息 -const filterWorkLoadFun = async (flag?: any) => { +const filterWorkLoadFun = async () => { // 判断开始时间和截止时间 const begin = new Date(filterFprmData.beginTime).getTime(); const end = new Date(filterFprmData.endTime).getTime(); @@ -402,11 +405,6 @@ const filterWorkLoadFun = async (flag?: any) => { .add(3, 'months') .format('YYYY-MM-DD HH:mm:ss'); } - - if (flag === 'group') { - filterFprmData.userIds = []; - await queryGroupUserListFun(filterFprmData.userGroupId); - } await refreshGanttFun(); }; @@ -703,11 +701,11 @@ const filterChangeFun = debounce(async () => { await filterWorkLoadFun(); }, 500); // 用户下拉框获取焦点 -const focusUserFun = () => { - if (!filterFprmData.userGroupId) { - ElMessage.warning('请选择用户组后再选择用户进行筛选!'); - } -}; +// const focusUserFun = () => { +// if (!filterFprmData.userGroupId) { +// ElMessage.warning('请选择用户组后再选择用户进行筛选!'); +// } +// }; watch( () => props.filterData, @@ -717,10 +715,36 @@ watch( { deep: true } ); +const getUserList = async () => { + const params = { + userIds: [localStorage.getItem('USER_ID')], + relationType: 1, + }; + const { data: relatedData } = await queryRelatedUserIdsApi(params); + const currentUser = JSON.parse(localStorage.getItem('USER_INFO_DATA') || '{}'); + const userMap = new Map(); + // 添加关联用户 + relatedData?.forEach((item: any) => { + userMap.set(item.userId, { + nickname: item.nickname, + userId: item.userId, + }); + }); + // 添加当前用户 + if (currentUser?.userId) { + userMap.set(currentUser.userId, { + nickname: currentUser.nickname, + userId: currentUser.userId, + }); + } + userList.value = Array.from(userMap.values()); +}; + const isInitialized = ref(false); onMounted(async () => { if (props.dimension === 'person') { - await getUserGroupFun(); + // await getUserGroupFun(); + await getUserList(); filterFprmData.beginTime = dayjs().subtract(3, 'month').format('YYYY-MM-DD HH:mm:ss'); filterFprmData.endTime = dayjs().format('YYYY-MM-DD HH:mm:ss'); } else {