fix: 修复白名单切换和空间成员名字问题

This commit is contained in:
sudoooooo 2024-08-07 22:07:00 +08:00
parent 6fb337633c
commit c5698ad631
6 changed files with 38 additions and 11 deletions

View File

@ -373,6 +373,16 @@ export class WorkspaceController {
workspaceList.map((item) => item._id.toString()),
);
// 查询成员姓名
const userList = await this.userService.getUserListByIds({
idList: workspaceMemberList.map((member) => member.userId),
});
const userInfoMap = userList.reduce((pre, cur) => {
const id = cur._id.toString();
pre[id] = cur;
return pre;
}, {});
const temp: Record<string, WorkspaceMember[]> = {};
const list = workspaceList.map(
(item: Workspace & { members: WorkspaceMember[] }) => {
@ -381,7 +391,8 @@ export class WorkspaceController {
},
);
workspaceMemberList.forEach((member) => {
workspaceMemberList.forEach((member: WorkspaceMember) => {
(member as any).username = userInfoMap[member.userId.toString()].username;
temp[member.workspaceId.toString()].push(member);
});

View File

@ -152,7 +152,7 @@ export class WorkspaceMemberService {
order: {
_id: -1,
},
select: ['_id', 'userId', 'username', 'role', 'workspaceId'],
select: ['_id', 'userId', 'role', 'workspaceId'],
});
}
}

View File

@ -46,8 +46,8 @@ import setterLoader from '@/materials/setters/setterLoader'
import { FORM_CHANGE_EVENT_KEY } from '@/materials/setters/constant'
interface Props {
formConfigList: Array<any>
moduleConfig: any
formConfigList: Array<any> //
moduleConfig: any // schema
customComponents?: Record<string, Component>
}
@ -83,9 +83,11 @@ const init = ref<boolean>(true)
const components = shallowRef<any>(props.customComponents || {})
const handleFormChange = (data: any, formConfig: any) => {
//
if (_isFunction(formConfig?.valueSetter)) {
const resultData = formConfig.valueSetter(data)
//
if (Array.isArray(resultData)) {
resultData.forEach((item) => {
emit(FORM_CHANGE_EVENT_KEY, item)
@ -125,7 +127,7 @@ const normalizationValues = (configList: Array<any> = []) => {
.map((item: any) => {
return {
...item,
value: formatValue({ item, moduleConfig: props.moduleConfig }) //
value: formatValue({ item, moduleConfig: props.moduleConfig }) //
}
})
}
@ -170,14 +172,13 @@ const registerComponents = async (formFieldData: any) => {
}
watch(
() => props.formConfigList,
() => props.formConfigList, //
async (newVal: Array<any>) => {
init.value = true
if (!newVal || !newVal.length) {
return
}
await registerComponents(newVal)
init.value = false
formFieldData.value = normalizationValues(newVal)
@ -189,7 +190,7 @@ watch(
)
watch(
() => props.moduleConfig,
() => props.moduleConfig, // schema
() => {
// value
if (init.value) {

View File

@ -66,7 +66,7 @@ const getSpaceMenus = async () => {
label: v.name,
children: members?.map((v) => ({
id: v.userId,
label: v.role
label: v.username
}))
})
})

View File

@ -53,7 +53,21 @@ export default {
label: '白名单',
value: 'CUSTOM'
}
]
],
// 批量修改value
valueSetter(data) {
return [
data,
{
key: 'whitelistTip', // 切换tab清空名单登录提示语
value: ''
},
{
key: 'whitelist', // 切换tab清空名单列表
value: []
}
]
}
},
white_placeholder: {
key: 'whitelistTip',

View File

@ -50,7 +50,7 @@ export const useWorkSpaceStore = defineStore('workSpace', () => {
const res: any = await getSpaceListReq(params)
if (res.code === CODE_MAP.SUCCESS) {
const { list } = res.data
const { list, count } = res.data
const workSpace = list.map((item: SpaceDetail) => {
return {
id: item._id,
@ -58,6 +58,7 @@ export const useWorkSpaceStore = defineStore('workSpace', () => {
}
})
workSpaceList.value = list
workSpaceListTotal.value = count
spaceMenus.value[1].children = workSpace
} else {
ElMessage.error('getSpaceList' + res.errmsg)