From c5698ad6314cedcbfaa2a7db25dc1654b2d444bc Mon Sep 17 00:00:00 2001 From: sudoooooo Date: Wed, 7 Aug 2024 22:07:00 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E7=99=BD=E5=90=8D?= =?UTF-8?q?=E5=8D=95=E5=88=87=E6=8D=A2=E5=92=8C=E7=A9=BA=E9=97=B4=E6=88=90?= =?UTF-8?q?=E5=91=98=E5=90=8D=E5=AD=97=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controllers/workspace.controller.ts | 13 ++++++++++++- .../services/workspaceMember.service.ts | 2 +- .../pages/edit/components/SetterField.vue | 13 +++++++------ .../settingModule/components/TeamMemberList.vue | 2 +- .../pages/edit/setterConfig/baseFormConfig.js | 16 +++++++++++++++- web/src/management/stores/workSpace.ts | 3 ++- 6 files changed, 38 insertions(+), 11 deletions(-) diff --git a/server/src/modules/workspace/controllers/workspace.controller.ts b/server/src/modules/workspace/controllers/workspace.controller.ts index b1985490..75da6319 100644 --- a/server/src/modules/workspace/controllers/workspace.controller.ts +++ b/server/src/modules/workspace/controllers/workspace.controller.ts @@ -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 = {}; 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); }); diff --git a/server/src/modules/workspace/services/workspaceMember.service.ts b/server/src/modules/workspace/services/workspaceMember.service.ts index baf9f8b2..2f711963 100644 --- a/server/src/modules/workspace/services/workspaceMember.service.ts +++ b/server/src/modules/workspace/services/workspaceMember.service.ts @@ -152,7 +152,7 @@ export class WorkspaceMemberService { order: { _id: -1, }, - select: ['_id', 'userId', 'username', 'role', 'workspaceId'], + select: ['_id', 'userId', 'role', 'workspaceId'], }); } } diff --git a/web/src/management/pages/edit/components/SetterField.vue b/web/src/management/pages/edit/components/SetterField.vue index 711b1806..76b5d64b 100644 --- a/web/src/management/pages/edit/components/SetterField.vue +++ b/web/src/management/pages/edit/components/SetterField.vue @@ -46,8 +46,8 @@ import setterLoader from '@/materials/setters/setterLoader' import { FORM_CHANGE_EVENT_KEY } from '@/materials/setters/constant' interface Props { - formConfigList: Array - moduleConfig: any + formConfigList: Array // 设置器的配置 + moduleConfig: any // 当前问卷schema customComponents?: Record } @@ -83,9 +83,11 @@ const init = ref(true) const components = shallowRef(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 = []) => { .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) => { 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) { diff --git a/web/src/management/pages/edit/modules/settingModule/components/TeamMemberList.vue b/web/src/management/pages/edit/modules/settingModule/components/TeamMemberList.vue index a1a8c7c7..7489a7ce 100644 --- a/web/src/management/pages/edit/modules/settingModule/components/TeamMemberList.vue +++ b/web/src/management/pages/edit/modules/settingModule/components/TeamMemberList.vue @@ -66,7 +66,7 @@ const getSpaceMenus = async () => { label: v.name, children: members?.map((v) => ({ id: v.userId, - label: v.role + label: v.username })) }) }) diff --git a/web/src/management/pages/edit/setterConfig/baseFormConfig.js b/web/src/management/pages/edit/setterConfig/baseFormConfig.js index d6895faa..4dee2654 100644 --- a/web/src/management/pages/edit/setterConfig/baseFormConfig.js +++ b/web/src/management/pages/edit/setterConfig/baseFormConfig.js @@ -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', diff --git a/web/src/management/stores/workSpace.ts b/web/src/management/stores/workSpace.ts index f9c05c55..15efe540 100644 --- a/web/src/management/stores/workSpace.ts +++ b/web/src/management/stores/workSpace.ts @@ -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)