feat: list模块优化

This commit is contained in:
sudoooooo 2024-07-09 11:36:18 +08:00
parent 33f18742dd
commit 64a1caf0dd
9 changed files with 162 additions and 136 deletions

View File

@ -42,7 +42,7 @@ import { ElMessage } from 'element-plus'
import 'element-plus/theme-chalk/src/message.scss' import 'element-plus/theme-chalk/src/message.scss'
import { createSurvey } from '@/management/api/survey' import { createSurvey } from '@/management/api/survey'
import { SURVEY_TYPE_LIST } from '../types' import { SURVEY_TYPE_LIST } from '../types'
import { useTeamSpaceStore } from '@/management/stores/teamSpace' import { useWorkSpaceStore } from '@/management/stores/workSpace'
interface Props { interface Props {
selectType?: string selectType?: string
@ -52,7 +52,7 @@ const props = withDefaults(defineProps<Props>(), {
selectType: 'normal' selectType: 'normal'
}) })
const teamSpaceStore = useTeamSpaceStore() const workSpaceStore = useWorkSpaceStore()
const ruleForm = ref<any>(null) const ruleForm = ref<any>(null)
const state = reactive({ const state = reactive({
@ -92,8 +92,8 @@ const submit = () => {
surveyType: selectType, surveyType: selectType,
...state.form ...state.form
} }
if (teamSpaceStore.workSpaceId) { if (workSpaceStore.workSpaceId) {
payload.workspaceId = teamSpaceStore.workSpaceId payload.workspaceId = workSpaceStore.workSpaceId
} }
const res: any = await createSurvey(payload) const res: any = await createSurvey(payload)
if (res?.code === 200 && res?.data?.id) { if (res?.code === 200 && res?.data?.id) {

View File

@ -123,7 +123,7 @@ import EmptyIndex from '@/management/components/EmptyIndex.vue'
import { CODE_MAP } from '@/management/api/base' import { CODE_MAP } from '@/management/api/base'
import { QOP_MAP } from '@/management/utils/constant.ts' import { QOP_MAP } from '@/management/utils/constant.ts'
import { deleteSurvey } from '@/management/api/survey' import { deleteSurvey } from '@/management/api/survey'
import { useTeamSpaceStore } from '@/management/stores/teamSpace' import { useWorkSpaceStore } from '@/management/stores/workSpace'
import { useSurveyListStore } from '@/management/stores/surveyList' import { useSurveyListStore } from '@/management/stores/surveyList'
import ModifyDialog from './ModifyDialog.vue' import ModifyDialog from './ModifyDialog.vue'
import TagModule from './TagModule.vue' import TagModule from './TagModule.vue'
@ -144,8 +144,8 @@ import {
} from '@/management/config/listConfig' } from '@/management/config/listConfig'
const surveyListStore = useSurveyListStore() const surveyListStore = useSurveyListStore()
const teamSpaceStore = useTeamSpaceStore() const workSpaceStore = useWorkSpaceStore()
const { workSpaceId } = storeToRefs(teamSpaceStore) const { workSpaceId } = storeToRefs(workSpaceStore)
const router = useRouter() const router = useRouter()
const props = defineProps({ const props = defineProps({
loading: { loading: {
@ -433,7 +433,7 @@ const onSelectChange = (selectKey, selectValue) => {
onReflush() onReflush()
} }
const onButtonChange = (effectKey, effectValue) => { const onButtonChange = (effectKey, effectValue) => {
surveyListStore.reserButtonValueMap() surveyListStore.resetButtonValueMap()
surveyListStore.changeButtonValueMap(effectKey, effectValue) surveyListStore.changeButtonValueMap(effectKey, effectValue)
onReflush() onReflush()
} }

View File

@ -18,9 +18,9 @@
import { computed } from 'vue' import { computed } from 'vue'
import { type IMember, type ListItem } from '@/management/utils/types/workSpace' import { type IMember, type ListItem } from '@/management/utils/types/workSpace'
import OperationSelect from './OperationSelect.vue' import OperationSelect from './OperationSelect.vue'
import { useTeamSpaceStore } from '@/management/stores/teamSpace' import { useWorkSpaceStore } from '@/management/stores/workSpace'
const teamSpaceStore = useTeamSpaceStore() const workSpaceStore = useWorkSpaceStore()
const props = withDefaults( const props = withDefaults(
defineProps<{ defineProps<{
members: IMember[] members: IMember[]
@ -43,7 +43,7 @@ const list = computed({
} }
}) })
const currentUserId = computed(() => { const currentUserId = computed(() => {
return teamSpaceStore.spaceDetail?.currentUserId return workSpaceStore.spaceDetail?.currentUserId
}) })
const handleRemove = (index: number) => { const handleRemove = (index: number) => {
list.value.splice(index, 1) list.value.splice(index, 1)

View File

@ -77,11 +77,11 @@ import { get, map } from 'lodash-es'
import { spaceListConfig } from '@/management/config/listConfig' import { spaceListConfig } from '@/management/config/listConfig'
import SpaceModify from './SpaceModify.vue' import SpaceModify from './SpaceModify.vue'
import { UserRole } from '@/management/utils/types/workSpace' import { UserRole } from '@/management/utils/types/workSpace'
import { useTeamSpaceStore } from '@/management/stores/teamSpace' import { useWorkSpaceStore } from '@/management/stores/workSpace'
const showSpaceModify = ref(false) const showSpaceModify = ref(false)
const modifyType = ref('edit') const modifyType = ref('edit')
const teamSpaceStore = useTeamSpaceStore() const workSpaceStore = useWorkSpaceStore()
const fields = ['name', 'surveyTotal', 'memberTotal', 'owner', 'createDate'] const fields = ['name', 'surveyTotal', 'memberTotal', 'owner', 'createDate']
const fieldList = computed(() => { const fieldList = computed(() => {
return map(fields, (f) => { return map(fields, (f) => {
@ -89,17 +89,17 @@ const fieldList = computed(() => {
}) })
}) })
const dataList = computed(() => { const dataList = computed(() => {
return teamSpaceStore.teamSpaceList return workSpaceStore.workSpaceList
}) })
const isAdmin = (id: string) => { const isAdmin = (id: string) => {
return ( return (
teamSpaceStore.teamSpaceList.find((item: any) => item._id === id)?.currentUserRole === workSpaceStore.workSpaceList.find((item: any) => item._id === id)?.currentUserRole ===
UserRole.Admin UserRole.Admin
) )
} }
const handleModify = async (id: string) => { const handleModify = async (id: string) => {
await teamSpaceStore.getSpaceDetail(id) await workSpaceStore.getSpaceDetail(id)
modifyType.value = 'edit' modifyType.value = 'edit'
showSpaceModify.value = true showSpaceModify.value = true
} }
@ -115,15 +115,15 @@ const handleDelete = (id: string) => {
} }
) )
.then(async () => { .then(async () => {
await teamSpaceStore.deleteSpace(id) await workSpaceStore.deleteSpace(id)
await teamSpaceStore.getSpaceList() await workSpaceStore.getSpaceList()
}) })
.catch(() => {}) .catch(() => {})
} }
const onCloseModify = () => { const onCloseModify = () => {
showSpaceModify.value = false showSpaceModify.value = false
teamSpaceStore.getSpaceList() workSpaceStore.getSpaceList()
} }
// const handleCurrentChange = (current) => { // const handleCurrentChange = (current) => {

View File

@ -1,7 +1,21 @@
<template> <template>
<el-dialog class="base-dialog-root" :model-value="visible" width="40%" :title="formTitle" @close="onClose"> <el-dialog
<el-form class="base-form-root" ref="ruleForm" :model="formModel" :rules="rules" label-position="top" size="large" class="base-dialog-root"
@submit.prevent :disabled="formDisabled"> :model-value="visible"
width="40%"
:title="formTitle"
@close="onClose"
>
<el-form
class="base-form-root"
ref="ruleForm"
:model="formModel"
:rules="rules"
label-position="top"
size="large"
@submit.prevent
:disabled="formDisabled"
>
<el-form-item label="团队空间名称" prop="name"> <el-form-item label="团队空间名称" prop="name">
<el-input v-model="formModel.name" /> <el-input v-model="formModel.name" />
</el-form-item> </el-form-item>
@ -9,7 +23,11 @@
<el-input v-model="formModel.description" /> <el-input v-model="formModel.description" />
</el-form-item> </el-form-item>
<el-form-item label="添加成员" prop="members"> <el-form-item label="添加成员" prop="members">
<MemberSelect :members="formModel.members" @select="handleMemberSelect" @change="handleMembersChange" /> <MemberSelect
:members="formModel.members"
@select="handleMemberSelect"
@change="handleMembersChange"
/>
</el-form-item> </el-form-item>
</el-form> </el-form>
@ -32,9 +50,9 @@ import 'element-plus/theme-chalk/src/message.scss'
import { QOP_MAP } from '@/management/utils/constant' import { QOP_MAP } from '@/management/utils/constant'
import MemberSelect from './MemberSelect.vue' import MemberSelect from './MemberSelect.vue'
import { type IMember, type IWorkspace, UserRole } from '@/management/utils/types/workSpace' import { type IMember, type IWorkspace, UserRole } from '@/management/utils/types/workSpace'
import { useTeamSpaceStore } from '@/management/stores/teamSpace' import { useWorkSpaceStore } from '@/management/stores/workSpace'
const teamSpaceStore = useTeamSpaceStore() const workSpaceStore = useWorkSpaceStore()
const emit = defineEmits(['on-close-codify', 'onFocus', 'change', 'blur']) const emit = defineEmits(['on-close-codify', 'onFocus', 'change', 'blur'])
const props = defineProps({ const props = defineProps({
type: String, type: String,
@ -69,11 +87,11 @@ const rules = {
] ]
} }
const spaceDetail = computed(() => { const spaceDetail = computed(() => {
return teamSpaceStore.spaceDetail return workSpaceStore.spaceDetail
}) })
const formDisabled = computed(() => { const formDisabled = computed(() => {
return spaceDetail.value?._id return spaceDetail.value?._id
? teamSpaceStore.teamSpaceList.find((item: any) => item._id === spaceDetail.value?._id) ? workSpaceStore.workSpaceList.find((item: any) => item._id === spaceDetail.value?._id)
?.currentUserRole !== UserRole.Admin ?.currentUserRole !== UserRole.Admin
: false : false
}) })
@ -91,7 +109,7 @@ const onClose = () => {
members: [] as IMember[] members: [] as IMember[]
} }
// //
teamSpaceStore.setSpaceDetail(null) workSpaceStore.setSpaceDetail(null)
emit('on-close-codify') emit('on-close-codify')
} }
@ -126,10 +144,10 @@ const handleMembersChange = (val: IMember[]) => {
formModel.value.members = val formModel.value.members = val
} }
const handleUpdate = async () => { const handleUpdate = async () => {
await teamSpaceStore.updateSpace(formModel.value) await workSpaceStore.updateSpace(formModel.value)
} }
const handleAdd = async () => { const handleAdd = async () => {
await teamSpaceStore.addSpace(formModel.value) await workSpaceStore.addSpace(formModel.value)
} }
</script> </script>

View File

@ -68,15 +68,15 @@ import SliderBar from './components/SliderBar.vue'
import SpaceModify from './components/SpaceModify.vue' import SpaceModify from './components/SpaceModify.vue'
import { SpaceType } from '@/management/utils/types/workSpace' import { SpaceType } from '@/management/utils/types/workSpace'
import { useUserStore } from '@/management/stores/user' import { useUserStore } from '@/management/stores/user'
import { useTeamSpaceStore } from '@/management/stores/teamSpace' import { useWorkSpaceStore } from '@/management/stores/workSpace'
import { useSurveyListStore } from '@/management/stores/surveyList' import { useSurveyListStore } from '@/management/stores/surveyList'
const userStore = useUserStore() const userStore = useUserStore()
const teamSpaceStore = useTeamSpaceStore() const workSpaceStore = useWorkSpaceStore()
const surveyListStore = useSurveyListStore() const surveyListStore = useSurveyListStore()
const { surveyList, surveyTotal } = storeToRefs(surveyListStore) const { surveyList, surveyTotal } = storeToRefs(surveyListStore)
const { spaceMenus, workSpaceId, spaceType } = storeToRefs(teamSpaceStore) const { spaceMenus, workSpaceId, spaceType } = storeToRefs(workSpaceStore)
const router = useRouter() const router = useRouter()
const userInfo = computed(() => { const userInfo = computed(() => {
return userStore.userInfo return userStore.userInfo
@ -87,25 +87,25 @@ const activeIndex = ref('1')
const handleSpaceSelect = (id: any) => { const handleSpaceSelect = (id: any) => {
if (id === SpaceType.Personal) { if (id === SpaceType.Personal) {
// //
if (teamSpaceStore.spaceType === SpaceType.Personal) { if (workSpaceStore.spaceType === SpaceType.Personal) {
return return
} }
teamSpaceStore.changeSpaceType(SpaceType.Personal) workSpaceStore.changeSpaceType(SpaceType.Personal)
teamSpaceStore.changeWorkSpace('') workSpaceStore.changeWorkSpace('')
} else if (id === SpaceType.Group) { } else if (id === SpaceType.Group) {
// //
if (teamSpaceStore.spaceType === SpaceType.Group) { if (workSpaceStore.spaceType === SpaceType.Group) {
return return
} }
teamSpaceStore.changeSpaceType(SpaceType.Group) workSpaceStore.changeSpaceType(SpaceType.Group)
teamSpaceStore.changeWorkSpace('') workSpaceStore.changeWorkSpace('')
} else if (!Object.values(SpaceType).includes(id)) { } else if (!Object.values(SpaceType).includes(id)) {
// //
if (teamSpaceStore.workSpaceId === id) { if (workSpaceStore.workSpaceId === id) {
return return
} }
teamSpaceStore.changeSpaceType(SpaceType.Teamwork) workSpaceStore.changeSpaceType(SpaceType.Teamwork)
teamSpaceStore.changeWorkSpace(id) workSpaceStore.changeWorkSpace(id)
} }
fetchSurveyList() fetchSurveyList()
@ -115,7 +115,7 @@ onMounted(() => {
fetchSurveyList() fetchSurveyList()
}) })
const fetchSpaceList = () => { const fetchSpaceList = () => {
teamSpaceStore.getSpaceList() workSpaceStore.getSpaceList()
} }
const fetchSurveyList = async (params?: any) => { const fetchSurveyList = async (params?: any) => {
if (!params) { if (!params) {

View File

@ -37,7 +37,7 @@ export default {
spaceType: SpaceType.Personal, spaceType: SpaceType.Personal,
workSpaceId: '', workSpaceId: '',
spaceDetail: null, spaceDetail: null,
teamSpaceList: [], workSpaceList: [],
// 列表管理 // 列表管理
surveyList: [], surveyList: [],
surveyTotal: 0, surveyTotal: 0,
@ -52,7 +52,7 @@ export default {
} }
}, },
getters: { getters: {
listFliter(state) { listFilter(state) {
return [ return [
{ {
comparator: '', comparator: '',
@ -96,25 +96,25 @@ export default {
} }
}, },
mutations: { mutations: {
updateSpaceMenus(state, teamSpace) { updateSpaceMenus(state, workSpace) {
// 更新空间列表下的团队空间 // 更新空间列表下的团队空间
set(state, 'spaceMenus[1].children', teamSpace) set(state, 'spaceMenus[1].children', workSpace)
}, },
changeSpaceType(state, spaceType) { changeSpaceType(state, spaceType) {
state.spaceType = spaceType state.spaceType = spaceType
}, },
changeWorkSpace(state, workSpaceId) { changeWorkSpace(state, workSpaceId) {
// 切换空间清除筛选条件 // 切换空间清除筛选条件
this.commit('list/reserSelectValueMap') this.commit('list/resetSelectValueMap')
this.commit('list/reserButtonValueMap') this.commit('list/resetButtonValueMap')
this.commit('list/setSearchVal', '') this.commit('list/setSearchVal', '')
state.workSpaceId = workSpaceId state.workSpaceId = workSpaceId
}, },
setSpaceDetail(state, data) { setSpaceDetail(state, data) {
state.spaceDetail = data state.spaceDetail = data
}, },
setTeamSpaceList(state, data) { setWorkSpaceList(state, data) {
state.teamSpaceList = data state.workSpaceList = data
}, },
setSurveyList(state, list) { setSurveyList(state, list) {
state.surveyList = list state.surveyList = list
@ -125,7 +125,7 @@ export default {
setSearchVal(state, data) { setSearchVal(state, data) {
state.searchVal = data state.searchVal = data
}, },
reserSelectValueMap(state) { resetSelectValueMap(state) {
state.selectValueMap = { state.selectValueMap = {
surveyType: '', surveyType: '',
'curStatus.status': '' 'curStatus.status': ''
@ -134,7 +134,7 @@ export default {
changeSelectValueMap(state, { key, value }) { changeSelectValueMap(state, { key, value }) {
state.selectValueMap[key] = value state.selectValueMap[key] = value
}, },
reserButtonValueMap(state) { resetButtonValueMap(state) {
state.buttonValueMap = { state.buttonValueMap = {
'curStatus.date': '', 'curStatus.date': '',
createDate: -1 createDate: -1
@ -151,14 +151,14 @@ export default {
if (res.code === CODE_MAP.SUCCESS) { if (res.code === CODE_MAP.SUCCESS) {
const { list } = res.data const { list } = res.data
const teamSpace = list.map((item) => { const workSpace = list.map((item) => {
return { return {
id: item._id, id: item._id,
name: item.name name: item.name
} }
}) })
commit('setTeamSpaceList', list) commit('setWorkSpaceList', list)
commit('updateSpaceMenus', teamSpace) commit('updateSpaceMenus', workSpace)
} else { } else {
ElMessage.error('getSpaceList' + res.errmsg) ElMessage.error('getSpaceList' + res.errmsg)
} }
@ -221,7 +221,7 @@ export default {
}, },
async getSurveyList({ state, getters, commit }, payload) { async getSurveyList({ state, getters, commit }, payload) {
const filterString = JSON.stringify( const filterString = JSON.stringify(
getters.listFliter.filter((item) => { getters.listFilter.filter((item) => {
return item.condition[0].value return item.condition[0].value
}) })
) )

View File

@ -1,74 +1,13 @@
import { CODE_MAP } from '@/management/api/base'
import { ElMessage } from 'element-plus' import { ElMessage } from 'element-plus'
import 'element-plus/theme-chalk/src/message.scss' import 'element-plus/theme-chalk/src/message.scss'
import { getSurveyList as getSurveyListReq } from '@/management/api/survey'
import { defineStore } from 'pinia' import { defineStore } from 'pinia'
import { useTeamSpaceStore } from './teamSpace'
import { CODE_MAP } from '@/management/api/base'
import { getSurveyList as getSurveyListReq } from '@/management/api/survey'
import { useWorkSpaceStore } from './workSpace'
import { ref, computed } from 'vue' import { ref, computed } from 'vue'
export const useSurveyListStore = defineStore('surveyList', () => {
const surveyList = ref([])
const surveyTotal = ref(0)
const {
searchVal,
selectValueMap,
buttonValueMap,
listFilter,
listOrder,
resetSearch,
resetSelectValueMap,
resetButtonValueMap,
changeSelectValueMap,
changeButtonValueMap
} = useSearchSurvey()
const teamSpaceStore = useTeamSpaceStore()
async function getSurveyList(payload: { curPage?: number; pageSize?: number }) {
const filterString = JSON.stringify(
listFilter.value.filter((item) => {
return item.condition[0].value
})
)
const orderString = JSON.stringify(listOrder.value)
try {
const params = {
curPage: payload?.curPage || 1,
pageSize: payload?.pageSize || 10, // 默认一页10条
filter: filterString,
order: orderString,
workspaceId: teamSpaceStore.workSpaceId
}
const res: any = await getSurveyListReq(params)
if (res.code === CODE_MAP.SUCCESS) {
surveyList.value = res.data.data
surveyTotal.value = res.data.count
} else {
ElMessage.error(res.errmsg)
}
} catch (error) {
ElMessage.error('getSurveyList status' + error)
}
}
return {
surveyList,
surveyTotal,
searchVal,
selectValueMap,
buttonValueMap,
listFliter: listFilter,
listOrder,
resetSearch,
getSurveyList,
resetSelectValueMap,
resetButtonValueMap,
changeSelectValueMap,
changeButtonValueMap
}
})
function useSearchSurvey() { function useSearchSurvey() {
const searchVal = ref('') const searchVal = ref('')
const selectValueMap = ref<Record<string, any>>({ const selectValueMap = ref<Record<string, any>>({
@ -117,7 +56,7 @@ function useSearchSurvey() {
const listOrder = computed(() => { const listOrder = computed(() => {
return Object.entries(buttonValueMap.value) return Object.entries(buttonValueMap.value)
.filter(([, effectValue]) => effectValue) .filter(([, effectValue]) => effectValue)
.reduce((prev: { field: string, value: string | number }[], item) => { .reduce((prev: { field: string; value: string | number }[], item) => {
const [effectKey, effectValue] = item const [effectKey, effectValue] = item
prev.push({ field: effectKey, value: effectValue }) prev.push({ field: effectKey, value: effectValue })
return prev return prev
@ -165,3 +104,66 @@ function useSearchSurvey() {
changeButtonValueMap changeButtonValueMap
} }
} }
export const useSurveyListStore = defineStore('surveyList', () => {
const surveyList = ref([])
const surveyTotal = ref(0)
const {
searchVal,
selectValueMap,
buttonValueMap,
listFilter,
listOrder,
resetSearch,
resetSelectValueMap,
resetButtonValueMap,
changeSelectValueMap,
changeButtonValueMap
} = useSearchSurvey()
const workSpaceStore = useWorkSpaceStore()
async function getSurveyList(payload: { curPage?: number; pageSize?: number }) {
const filterString = JSON.stringify(
listFilter.value.filter((item) => {
return item.condition[0].value
})
)
const orderString = JSON.stringify(listOrder.value)
try {
const params = {
curPage: payload?.curPage || 1,
pageSize: payload?.pageSize || 10, // 默认一页10条
filter: filterString,
order: orderString,
workspaceId: workSpaceStore.workSpaceId
}
const res: any = await getSurveyListReq(params)
if (res.code === CODE_MAP.SUCCESS) {
surveyList.value = res.data.data
surveyTotal.value = res.data.count
} else {
ElMessage.error(res.errmsg)
}
} catch (error) {
ElMessage.error('getSurveyList status' + error)
}
}
return {
surveyList,
surveyTotal,
searchVal,
selectValueMap,
buttonValueMap,
listFilter: listFilter,
listOrder,
resetSearch,
getSurveyList,
resetSelectValueMap,
resetButtonValueMap,
changeSelectValueMap,
changeButtonValueMap
}
})

View File

@ -1,3 +1,9 @@
import { defineStore } from 'pinia'
import { ref } from 'vue'
import { ElMessage } from 'element-plus'
import 'element-plus/theme-chalk/src/message.scss'
import { CODE_MAP } from '@/management/api/base'
import { import {
createSpace, createSpace,
updateSpace as updateSpaceReq, updateSpace as updateSpaceReq,
@ -5,16 +11,16 @@ import {
getSpaceList as getSpaceListReq, getSpaceList as getSpaceListReq,
getSpaceDetail as getSpaceDetailReq getSpaceDetail as getSpaceDetailReq
} from '@/management/api/space' } from '@/management/api/space'
import { CODE_MAP } from '@/management/api/base'
import { SpaceType } from '@/management/utils/types/workSpace' import { SpaceType } from '@/management/utils/types/workSpace'
import { defineStore } from 'pinia' import {
import { ref } from 'vue' type SpaceDetail,
import { ElMessage } from 'element-plus' type SpaceItem,
type IWorkspace
} from '@/management/utils/types/workSpace'
import { useSurveyListStore } from './surveyList' import { useSurveyListStore } from './surveyList'
import { type SpaceDetail, type SpaceItem, type IWorkspace } from '@/management/utils/types/workSpace'
export const useWorkSpaceStore = defineStore('workSpace', () => {
export const useTeamSpaceStore = defineStore('teamSpace', () => {
// list空间 // list空间
const spaceMenus = ref([ const spaceMenus = ref([
{ {
@ -32,7 +38,7 @@ export const useTeamSpaceStore = defineStore('teamSpace', () => {
const spaceType = ref(SpaceType.Personal) const spaceType = ref(SpaceType.Personal)
const workSpaceId = ref('') const workSpaceId = ref('')
const spaceDetail = ref<SpaceDetail | null>(null) const spaceDetail = ref<SpaceDetail | null>(null)
const teamSpaceList = ref<SpaceItem[]>([]) const workSpaceList = ref<SpaceItem[]>([])
const surveyListStore = useSurveyListStore() const surveyListStore = useSurveyListStore()
@ -42,14 +48,14 @@ export const useTeamSpaceStore = defineStore('teamSpace', () => {
if (res.code === CODE_MAP.SUCCESS) { if (res.code === CODE_MAP.SUCCESS) {
const { list } = res.data const { list } = res.data
const teamSpace = list.map((item: SpaceDetail) => { const workSpace = list.map((item: SpaceDetail) => {
return { return {
id: item._id, id: item._id,
name: item.name name: item.name
} }
}) })
teamSpaceList.value = list workSpaceList.value = list
spaceMenus.value[1].children = teamSpace spaceMenus.value[1].children = workSpace
} else { } else {
ElMessage.error('getSpaceList' + res.errmsg) ElMessage.error('getSpaceList' + res.errmsg)
} }
@ -126,7 +132,7 @@ export const useTeamSpaceStore = defineStore('teamSpace', () => {
spaceType, spaceType,
workSpaceId, workSpaceId,
spaceDetail, spaceDetail,
teamSpaceList, workSpaceList,
getSpaceList, getSpaceList,
getSpaceDetail, getSpaceDetail,
changeSpaceType, changeSpaceType,