-
+
- {{ spaceType === SpaceType.Group ? '团队空间' : currentTeamSpace?.name || '问卷列表' }}
+ {{ tableTitle }}
创建团队空间
-
+
+
+ 创建分组
+
+
团队管理
@@ -26,7 +35,7 @@
class="btn create-btn"
type="default"
@click="onCreate"
- v-if="spaceType !== SpaceType.Group"
+ v-if="workSpaceId || groupId"
>
创建问卷
@@ -38,7 +47,7 @@
:data="surveyList"
:total="surveyTotal"
@refresh="fetchSurveyList"
- v-if="spaceType !== SpaceType.Group"
+ v-if="workSpaceId || groupId"
>
+
+
@@ -66,10 +89,13 @@ import { storeToRefs } from 'pinia'
import { useRouter } from 'vue-router'
import BaseList from './components/BaseList.vue'
import SpaceList from './components/SpaceList.vue'
+import GroupList from './components/GroupList.vue'
import SliderBar from './components/SliderBar.vue'
import SpaceModify from './components/SpaceModify.vue'
+import GroupModify from './components/GroupModify.vue'
import TopNav from '@/management/components/TopNav.vue'
-import { SpaceType } from '@/management/utils/workSpace'
+import { MenuType } from '@/management/utils/workSpace'
+
import { useWorkSpaceStore } from '@/management/stores/workSpace'
import { useSurveyListStore } from '@/management/stores/surveyList'
import { type IWorkspace } from '@/management/utils/workSpace'
@@ -78,14 +104,39 @@ const workSpaceStore = useWorkSpaceStore()
const surveyListStore = useSurveyListStore()
const { surveyList, surveyTotal } = storeToRefs(surveyListStore)
-const { spaceMenus, workSpaceId, spaceType, workSpaceList, workSpaceListTotal } =
+const { spaceMenus, workSpaceId, groupId, menuType, workSpaceList, workSpaceListTotal, groupList, groupListTotal } =
storeToRefs(workSpaceStore)
const router = useRouter()
+const tableTitle = computed(() => {
+ if(menuType.value === MenuType.PersonalGroup && !groupId.value) {
+ return '我的空间'
+ } else if (menuType.value === MenuType.SpaceGroup && !workSpaceId.value) {
+ return '团队空间'
+ } else {
+ return currentTeamSpace.value?.name || '问卷列表';
+ }
+})
+
+const activeValue = computed(() => {
+ if(workSpaceId.value !== '') {
+ return workSpaceId.value
+ } else if(groupId.value !== '') {
+ return groupId.value
+ } else if(menuType.value === MenuType.PersonalGroup) {
+ return MenuType.PersonalGroup
+ } else if(menuType.value === MenuType.SpaceGroup) {
+ return MenuType.SpaceGroup
+ } else {
+ return ''
+ }
+})
+
const loading = ref(false)
const spaceListRef = ref
(null)
const spaceLoading = ref(false)
+const groupLoading = ref(false)
const fetchSpaceList = async (params?: any) => {
spaceLoading.value = true
@@ -94,24 +145,39 @@ const fetchSpaceList = async (params?: any) => {
spaceLoading.value = false
}
-const handleSpaceSelect = (id: SpaceType | string) => {
- if (id === spaceType.value || id === workSpaceId.value) {
+const fetchGroupList = async (params?: any) => {
+ groupLoading.value = true
+ workSpaceStore.changeWorkSpace('')
+ workSpaceStore.getGroupList(params)
+ groupLoading.value = false
+}
+
+const handleSpaceSelect = (id: MenuType | string) => {
+ if (groupId.value === id || workSpaceId.value === id) {
return void 0
}
-
+ let parentMenu = undefined
switch (id) {
- case SpaceType.Personal:
- workSpaceStore.changeSpaceType(SpaceType.Personal)
+ case MenuType.PersonalGroup:
+ workSpaceStore.changeMenuType(MenuType.PersonalGroup)
workSpaceStore.changeWorkSpace('')
+ fetchGroupList()
break
- case SpaceType.Group:
- workSpaceStore.changeSpaceType(SpaceType.Group)
+ case MenuType.SpaceGroup:
+ workSpaceStore.changeMenuType(MenuType.SpaceGroup)
workSpaceStore.changeWorkSpace('')
fetchSpaceList()
break
default:
- workSpaceStore.changeSpaceType(SpaceType.Teamwork)
- workSpaceStore.changeWorkSpace(id)
+ parentMenu = spaceMenus.value.find((parent: any) => parent.children.find((children: any) => children.id.toString() === id))
+ if(parentMenu != undefined) {
+ workSpaceStore.changeMenuType(parentMenu.id)
+ if(parentMenu.id === MenuType.PersonalGroup) {
+ workSpaceStore.changeGroup(id)
+ } else if (parentMenu.id === MenuType.SpaceGroup) {
+ workSpaceStore.changeWorkSpace(id)
+ }
+ }
break
}
fetchSurveyList()
@@ -133,6 +199,7 @@ const fetchSurveyList = async (params?: any) => {
}
onMounted(() => {
+ fetchGroupList()
fetchSpaceList()
fetchSurveyList()
})
@@ -168,7 +235,7 @@ const onCloseModifyInTeamWork = (data: IWorkspace) => {
}
}
-const onCloseModify = (type: string) => {
+const onCloseSpaceModify = (type: string) => {
showSpaceModify.value = false
if (type === 'update' && spaceListRef.value) {
fetchSpaceList()
@@ -179,6 +246,20 @@ const onSpaceCreate = () => {
modifyType.value = 'add'
showSpaceModify.value = true
}
+
+// 分组
+
+const showGroupModify = ref(false)
+
+const onCloseGroupModify = () => {
+ showGroupModify.value = false
+ fetchGroupList()
+}
+
+const onGroupCreate = () => {
+ showGroupModify.value = true
+}
+
const onCreate = () => {
router.push('/create')
}
diff --git a/web/src/management/stores/surveyList.ts b/web/src/management/stores/surveyList.ts
index 7d403af6..fcd885ef 100644
--- a/web/src/management/stores/surveyList.ts
+++ b/web/src/management/stores/surveyList.ts
@@ -6,7 +6,7 @@ import 'element-plus/theme-chalk/src/message.scss'
import { CODE_MAP } from '@/management/api/base'
import { getSurveyList as getSurveyListReq } from '@/management/api/survey'
-
+import { GroupState } from '@/management/utils/workSpace'
import { useWorkSpaceStore } from './workSpace'
import {
@@ -150,7 +150,8 @@ export const useSurveyListStore = defineStore('surveyList', () => {
pageSize: payload?.pageSize || 10, // 默认一页10条
filter: filterString,
order: orderString,
- workspaceId: workSpaceStore.workSpaceId
+ workspaceId: workSpaceStore.workSpaceId,
+ groupId: workSpaceStore.groupId === GroupState.All ? '' : workSpaceStore.groupId
}
const res: any = await getSurveyListReq(params)
diff --git a/web/src/management/stores/workSpace.ts b/web/src/management/stores/workSpace.ts
index 9469bc02..1d3c95c3 100644
--- a/web/src/management/stores/workSpace.ts
+++ b/web/src/management/stores/workSpace.ts
@@ -10,11 +10,16 @@ import {
updateSpace as updateSpaceReq,
deleteSpace as deleteSpaceReq,
getSpaceList as getSpaceListReq,
- getSpaceDetail as getSpaceDetailReq
+ getSpaceDetail as getSpaceDetailReq,
+ createGroup,
+ getGroupList as getGroupListReq,
+ updateGroup as updateGroupReq,
+ deleteGroup as deleteGroupReq
} from '@/management/api/space'
-import { SpaceType } from '@/management/utils/workSpace'
-import { type SpaceDetail, type SpaceItem, type IWorkspace } from '@/management/utils/workSpace'
+import { GroupState, MenuType } from '@/management/utils/workSpace'
+import { type SpaceDetail, type SpaceItem, type IWorkspace, type IGroup, type GroupItem, } from '@/management/utils/workSpace'
+
import { useSurveyListStore } from './surveyList'
@@ -24,16 +29,18 @@ export const useWorkSpaceStore = defineStore('workSpace', () => {
{
icon: 'icon-wodekongjian',
name: '我的空间',
- id: SpaceType.Personal
+ id: MenuType.PersonalGroup,
+ children: []
},
{
icon: 'icon-tuanduikongjian',
name: '团队空间',
- id: SpaceType.Group,
+ id: MenuType.SpaceGroup,
children: []
}
])
- const spaceType = ref(SpaceType.Personal)
+ const menuType = ref(MenuType.PersonalGroup)
+ const groupId = ref('')
const workSpaceId = ref('')
const spaceDetail = ref(null)
const workSpaceList = ref([])
@@ -50,7 +57,8 @@ export const useWorkSpaceStore = defineStore('workSpace', () => {
const workSpace = list.map((item: SpaceDetail) => {
return {
id: item._id,
- name: item.name
+ name: item.name,
+ total: item.surveyTotal
}
})
workSpaceList.value = list
@@ -78,12 +86,19 @@ export const useWorkSpaceStore = defineStore('workSpace', () => {
}
}
- function changeSpaceType(id: SpaceType) {
- spaceType.value = id
+ function changeMenuType(id: MenuType) {
+ menuType.value = id
}
function changeWorkSpace(id: string) {
workSpaceId.value = id
+ groupId.value = ''
+ surveyListStore.resetSearch()
+ }
+
+ function changeGroup(id: string) {
+ groupId.value = id
+ workSpaceId.value = ''
surveyListStore.resetSearch()
}
@@ -126,21 +141,130 @@ export const useWorkSpaceStore = defineStore('workSpace', () => {
function setSpaceDetail(data: null | SpaceDetail) {
spaceDetail.value = data
}
+
+ // 分组
+ const groupList = ref([])
+ const groupAllList = ref([])
+ const groupListTotal = ref(0)
+ const groupDetail = ref(null)
+ async function addGroup(params: IGroup) {
+ const { name } = params
+ const res: any = await createGroup({ name })
+
+ if (res.code === CODE_MAP.SUCCESS) {
+ ElMessage.success('添加成功')
+ } else {
+ ElMessage.error('createGroup code err' + res.errmsg)
+ }
+ }
+
+ async function updateGroup(params: Required) {
+ const { _id, name } = params
+ const res: any = await updateGroupReq({ _id, name })
+
+ if (res?.code === CODE_MAP.SUCCESS) {
+ ElMessage.success('更新成功')
+ } else {
+ ElMessage.error(res?.errmsg)
+ }
+ }
+
+ async function getGroupList(params = { curPage: 1 }) {
+ try {
+ const res: any = await getGroupListReq(params)
+ if (res.code === CODE_MAP.SUCCESS) {
+ const { list, allList, total, notTotal } = res.data
+ let allTotal = notTotal
+ const group = list.map((item: GroupItem) => {
+ allTotal += item.surveyTotal
+ return {
+ id: item._id,
+ name: item.name,
+ total: item.surveyTotal,
+ }
+ })
+ group.unshift({
+ id: GroupState.All,
+ name: '全部' ,
+ total: allTotal
+ }, {
+ id: GroupState.Not,
+ name: '未分组' ,
+ total: notTotal
+ })
+ allList.unshift({
+ _id: '',
+ name: '未分组'
+ })
+ groupList.value = list
+ groupListTotal.value = total
+ spaceMenus.value[0].children = group
+ groupAllList.value = allList
+ } else {
+ ElMessage.error('getGroupList' + res.errmsg)
+ }
+ } catch (err) {
+ ElMessage.error('getGroupList' + err)
+ }
+ }
+
+ function getGroupDetail(id: string) {
+ try {
+ const data = groupList.value.find((item: GroupItem) => item._id === id)
+ if(data != undefined) {
+ groupDetail.value = data
+ } else {
+ ElMessage.error('groupDetail 未找到分组')
+ }
+ } catch (err) {
+ ElMessage.error('groupDetail' + err)
+ }
+ }
+
+ function setGroupDetail(data: null | GroupItem) {
+ groupDetail.value = data
+ }
+
+ async function deleteGroup(id: string) {
+ try {
+ const res: any = await deleteGroupReq(id)
+
+ if (res.code === CODE_MAP.SUCCESS) {
+ ElMessage.success('删除成功')
+ } else {
+ ElMessage.error(res.errmsg)
+ }
+ } catch (err: any) {
+ ElMessage.error(err)
+ }
+ }
return {
+ menuType,
spaceMenus,
- spaceType,
+ groupId,
workSpaceId,
spaceDetail,
workSpaceList,
workSpaceListTotal,
getSpaceList,
getSpaceDetail,
- changeSpaceType,
+ changeMenuType,
changeWorkSpace,
+ changeGroup,
addSpace,
deleteSpace,
updateSpace,
- setSpaceDetail
+ setSpaceDetail,
+ groupList,
+ groupAllList,
+ groupListTotal,
+ groupDetail,
+ addGroup,
+ updateGroup,
+ getGroupList,
+ getGroupDetail,
+ setGroupDetail,
+ deleteGroup
}
})
diff --git a/web/src/management/utils/workSpace.ts b/web/src/management/utils/workSpace.ts
index 654cfd2a..ac0cc95f 100644
--- a/web/src/management/utils/workSpace.ts
+++ b/web/src/management/utils/workSpace.ts
@@ -7,9 +7,15 @@ export interface MenuItem {
id: string
name: string
icon?: string
+ total?: Number
children?: MenuItem[]
}
+export type IGroup = {
+ _id?: string
+ name: string
+}
+
export type IWorkspace = {
_id?: string
name: string
@@ -29,6 +35,7 @@ export interface SpaceDetail {
name: string
currentUserId?: string
description: string
+ surveyTotal: number
members: IMember[]
}
@@ -49,16 +56,30 @@ export interface ICollaborator {
permissions: Array
}
-export enum SpaceType {
- Personal = 'personal',
- Group = 'group',
- Teamwork = 'teamwork'
+export type GroupItem = {
+ _id: string,
+ name: string,
+ createdAt: string
+ updatedAt?: string
+ ownerId: string
+ surveyTotal: number
}
+
+export enum MenuType {
+ PersonalGroup = 'personalGroup',
+ SpaceGroup = 'spaceGroup',
+}
+
export enum UserRole {
Admin = 'admin',
Member = 'user'
}
+export enum GroupState {
+ All = 'all',
+ Not = 'nogrouped'
+}
+
// 定义角色标签映射对象
export const roleLabels: Record = {
[UserRole.Admin]: '管理员',
From f01465aa6cd753e25dd58c014b33238aaba32a4a Mon Sep 17 00:00:00 2001
From: dayou <853094838@qq.com>
Date: Thu, 31 Oct 2024 21:40:32 +0800
Subject: [PATCH 7/7] =?UTF-8?q?fix:=20=20=E8=A7=A3=E5=86=B3=E5=86=B2?=
=?UTF-8?q?=E7=AA=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
web/src/management/pages/list/index.vue | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/web/src/management/pages/list/index.vue b/web/src/management/pages/list/index.vue
index cf349025..6ed71124 100644
--- a/web/src/management/pages/list/index.vue
+++ b/web/src/management/pages/list/index.vue
@@ -219,7 +219,7 @@ const onSetGroup = async () => {
}
const onCloseModifyInTeamWork = (data: IWorkspace) => {
- if (spaceType.value === SpaceType.Teamwork) {
+ if (activeValue.value === MenuType.SpaceGroup) {
const currentData = workSpaceList.value.find((item) => item._id === data._id)
if (currentData) {
currentData.name = data.name