Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 空间协作功能 #181

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions web/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,9 @@ module.exports = {
],
parserOptions: {
ecmaVersion: 'latest'
},
rules: {
'no-empty-pattern': 'off',
'vue/multi-word-component-names': 'off'
}
}
5 changes: 5 additions & 0 deletions web/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ declare module 'vue' {
ElFormItem: typeof import('element-plus/es')['ElFormItem']
ElInput: typeof import('element-plus/es')['ElInput']
ElInputNumber: typeof import('element-plus/es')['ElInputNumber']
ElMenu: typeof import('element-plus/es')['ElMenu']
ElMenuItem: typeof import('element-plus/es')['ElMenuItem']
ElMenuItemGroup: typeof import('element-plus/es')['ElMenuItemGroup']
ElOption: typeof import('element-plus/es')['ElOption']
ElPagination: typeof import('element-plus/es')['ElPagination']
ElPopover: typeof import('element-plus/es')['ElPopover']
Expand All @@ -27,6 +30,7 @@ declare module 'vue' {
ElRadioGroup: typeof import('element-plus/es')['ElRadioGroup']
ElRow: typeof import('element-plus/es')['ElRow']
ElSelect: typeof import('element-plus/es')['ElSelect']
ElSelectV2: typeof import('element-plus/es')['ElSelectV2']
ElSlider: typeof import('element-plus/es')['ElSlider']
ElSwitch: typeof import('element-plus/es')['ElSwitch']
ElTable: typeof import('element-plus/es')['ElTable']
Expand All @@ -44,6 +48,7 @@ declare module 'vue' {
IEpDelete: typeof import('~icons/ep/delete')['default']
IEpLoading: typeof import('~icons/ep/loading')['default']
IEpMinus: typeof import('~icons/ep/minus')['default']
IEpMore: typeof import('~icons/ep/more')['default']
IEpPlus: typeof import('~icons/ep/plus')['default']
IEpQuestionFilled: typeof import('~icons/ep/question-filled')['default']
IEpRank: typeof import('~icons/ep/rank')['default']
Expand Down
67 changes: 67 additions & 0 deletions web/src/management/api/space.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import axios from './base'

// 空间
export const createSpace = ({ name, description, members }: any) => {
return axios.post('/workspace', { name, description, members })
}

export const updateSpace = ({ workspaceId, name, description, members }: any) => {
return axios.post(`/workspace/${workspaceId}`, { name, description, members })
}

export const spaceList = () => {
return axios.get('/workspace')
}

export const spaceDetail = (workspaceId: string) => {
return axios.get(`/workspace/${workspaceId}`)
}

export const spaceDelete = (workspaceId: string) => {
return axios.delete(`/workspace/${workspaceId}`)
}

export const getUserList = (username: string) => {
return axios.get(`/user/getUserList`, {
params: {
username
}
})
}

// 协作权限列表
export const getPermissionList = () => {
return axios.get('collaborator/getPermissionList')
}

export const collaboratorBatchSave = ({ surveyId, collaborators }: any) => {
return axios.post('collaborator/batchSave', {
surveyId,
collaborators
})
}

// 添加协作人
export const addCollaborator = ({ surveyId, userId, permissions }: any) => {
return axios.post('collaborator', {
surveyId,
userId,
permissions
})
}
// 更新问卷协作信息
export const updateCollaborator = ({ surveyId, userId, permissions }: any) => {
return axios.post('collaborator/changeUserPermission', {
surveyId,
userId,
permissions
})
}
// 获取问卷协作信息
export const getCollaborator = (surveyId: string) => {
return axios.get(`collaborator`, {
params: {
surveyId
}
})
}
5 changes: 3 additions & 2 deletions web/src/management/api/survey.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import axios from './base'

export const getSurveyList = ({ curPage, filter, order }) => {
export const getSurveyList = ({ curPage, filter, order, workspaceId }) => {
return axios.get('/survey/getList', {
params: {
pageSize: 10,
curPage,
filter,
order
order,
workspaceId
}
})
}
Expand Down
32 changes: 30 additions & 2 deletions web/src/management/components/LeftMenu.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
<template>
<div class="nav">
<LogoIcon />
<RouterLink v-for="(tab, index) in tabs" :key="index" class="tab-btn" :to="tab.to" replace>
<RouterLink
v-for="(tab, index) in currentTabs"
:key="index"
class="tab-btn"
:to="tab.to"
replace
>
<div class="icon">
<i class="iconfont" :class="tab.icon"></i>
</div>
Expand All @@ -11,8 +17,13 @@
</template>

<script setup>
import LogoIcon from './LogoIcon.vue'
import { computed } from 'vue'
import { useStore } from 'vuex'

import LogoIcon from './LogoIcon.vue'
import { SurveyPermissions } from '@/management/utils/types/workSpace.ts'
const store = useStore()
// console.log({metaData: store.state.edit.schema.metaData})
const tabs = [
{
text: '编辑问卷',
Expand All @@ -36,6 +47,23 @@ const tabs = [
}
}
]
const currentTabs = computed(() => {
const { isCollaborated = true, currentPermission = [] } =
store.state.edit?.schema?.metaData || {}
if (!isCollaborated) {
return tabs
} else {
// 如果没有问卷管理权限,则隐藏问卷编辑和投放菜单
if (currentPermission.includes(SurveyPermissions.SurveyManage)) {
return tabs.slice(0, 2)
}
// 如果没有数据分析权限,则隐藏数据分析菜单
if (currentPermission.includes(SurveyPermissions.DataManage)) {
return tabs.slice(2, 3)
}
return []
}
})
</script>
<style lang="scss" scoped>
.nav {
Expand Down
11 changes: 8 additions & 3 deletions web/src/management/pages/create/components/CreateForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
<script setup lang="ts">
import { ref, reactive, computed, toRefs } from 'vue'
import { useRouter } from 'vue-router'
import { useStore } from 'vuex'
import { ElMessage } from 'element-plus'
import 'element-plus/theme-chalk/src/message.scss'

Expand Down Expand Up @@ -78,7 +79,7 @@ const checkForm = (fn: Function) => {
}

const router = useRouter()

const store = useStore()
const submit = () => {
if (!state.canSubmit) {
return
Expand All @@ -89,10 +90,14 @@ const submit = () => {
return
}
state.canSubmit = false
const res:any = await createSurvey({
const payload: any = {
surveyType: selectType,
...state.form
})
}
if (store.state.list.workSpaceId) {
payload.workspaceId = store.state.list.workSpaceId
}
const res: any = await createSurvey(payload)
if (res?.code === 200 && res?.data?.id) {
const id = res.data.id
router.push({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
</div>
</template>
<script setup lang="ts">
import { defineProps, computed, inject, ref, type ComputedRef } from 'vue'
import { computed, inject, ref, type ComputedRef } from 'vue'
import { ConditionNode, RuleNode } from '@/common/logicEngine/RuleBuild'
import { qAbleList } from '@/management/utils/constant.js'
import { cleanRichText } from '@/common/xss'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<div class="video">
<video
class="custom-video"
:poster="bannerConf.bannerConfigpostImg"
:poster="bannerConf.bannerConfig.postImg"
preload="auto"
controls
:src="bannerConf.bannerConfig.videoLink"
Expand Down
Loading