fix: 修复白名单切换和空间成员名字问题
This commit is contained in:
parent
6fb337633c
commit
c5698ad631
@ -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);
|
||||
});
|
||||
|
||||
|
@ -152,7 +152,7 @@ export class WorkspaceMemberService {
|
||||
order: {
|
||||
_id: -1,
|
||||
},
|
||||
select: ['_id', 'userId', 'username', 'role', 'workspaceId'],
|
||||
select: ['_id', 'userId', 'role', 'workspaceId'],
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -66,7 +66,7 @@ const getSpaceMenus = async () => {
|
||||
label: v.name,
|
||||
children: members?.map((v) => ({
|
||||
id: v.userId,
|
||||
label: v.role
|
||||
label: v.username
|
||||
}))
|
||||
})
|
||||
})
|
||||
|
@ -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',
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user