提交 93e4e3c3 authored 作者: 王鹏飞's avatar 王鹏飞

chore: 新增权限控制

上级 b4be7f62
......@@ -5,6 +5,12 @@ export function getUser() {
return httpRequest.get('/api/lab/v1/common/permission/role')
}
// 获取旅程的数据使用状态(是否使用公共数据)
// true 是学员且使用公共数据(学员不能自己创建数据) false 学员可以自己创建数据
export function checkDataStatus() {
return httpRequest.get('/api/lab/v1/experiment/itinerary/check-data-status')
}
// 退出登录
export function logout() {
return httpRequest.get('/api/passport/rest/logout')
......
......@@ -114,7 +114,7 @@ function handleView(row: Group) {
<AppList v-bind="listOptions" ref="appList" @selection-change="handleSelectionChange">
<template #header-buttons>
<el-space>
<el-dropdown>
<el-dropdown v-permission="['experiment_group_create_dynamic_group', 'experiment_group_create_static_group']">
<el-button type="primary" :icon="Plus">新建</el-button>
<template #dropdown>
<el-dropdown-menu>
......@@ -129,6 +129,7 @@ function handleView(row: Group) {
:icon="Delete"
:disabled="!multipleSelection.length"
@click="handleRemove(multipleSelection)"
v-permission="'experiment_group_delete'"
>删除</el-button
>
</el-space>
......@@ -139,8 +140,16 @@ function handleView(row: Group) {
<template #table-x="{ row }">
<el-button type="primary" plain @click="handleView(row)">查看</el-button>
<el-button type="primary" plain @click="handleUpdate(row)">编辑</el-button>
<el-button type="primary" plain @click="handleRemove([row])">删除</el-button>
<el-button
type="primary"
plain
@click="handleUpdate(row)"
v-permission="['experiment_group_create_dynamic_group', 'experiment_group_update_static_group']"
>编辑</el-button
>
<el-button type="primary" plain @click="handleRemove([row])" v-permission="'experiment_group_delete'"
>删除</el-button
>
</template>
</AppList>
</AppCard>
......
......@@ -34,7 +34,9 @@ function handleRemove(row: LabelType) {
</script>
<template>
<el-button type="primary" style="width: 100%" @click="handleAdd">添加标签类型</el-button>
<el-button type="primary" style="width: 100%" @click="handleAdd" v-permission="'experiment_tag_type_create'"
>添加标签类型</el-button
>
<div class="label-type-total">
<h4>全部标签</h4>
<p>{{ labelCount }}</p>
......@@ -54,8 +56,12 @@ function handleRemove(row: LabelType) {
</svg>
<p>{{ item.name }}</p>
<div class="label-type-actions">
<el-icon class="label-type-item__edit" @click="handleUpdate(item)"><Edit /></el-icon>
<el-icon class="label-type-item__remove" @click="handleRemove(item)"><Delete /></el-icon>
<el-icon class="label-type-item__edit" @click="handleUpdate(item)" v-permission="'experiment_tag_type_update'"
><Edit
/></el-icon>
<el-icon class="label-type-item__remove" @click="handleRemove(item)" v-permission="'experiment_tag_type_delete'"
><Delete
/></el-icon>
</div>
</li>
</ul>
......
......@@ -117,9 +117,9 @@ function handleRule(row: Label) {
<div class="label-left"><LabelType></LabelType></div>
<AppList v-bind="listOptions" ref="appList" class="label-right">
<template #header-buttons>
<el-space>
<el-button type="primary" :icon="Plus" @click="handleAdd">新建</el-button>
</el-space>
<el-button type="primary" :icon="Plus" @click="handleAdd" v-permission="'experiment_tag_create'"
>新建</el-button
>
</template>
<template #filter-user>
<SelectUser v-model="listParams.updated_operator" placeholder="更新人" @change="handleRefresh"></SelectUser>
......@@ -128,8 +128,12 @@ function handleRule(row: Label) {
<template #table-x="{ row }">
<el-button type="primary" plain @click="handleRule(row)">规则</el-button>
<el-button type="primary" plain @click="handleView(row)">查看</el-button>
<el-button type="primary" plain @click="handleUpdate(row)">编辑</el-button>
<el-button type="primary" plain @click="handleRemove(row)">删除</el-button>
<el-button type="primary" plain @click="handleUpdate(row)" v-permission="'experiment_tag_update'"
>编辑</el-button
>
<el-button type="primary" plain @click="handleRemove(row)" v-permission="'experiment_tag_delete'"
>删除</el-button
>
</template>
</AppList>
</div>
......
......@@ -92,6 +92,7 @@ function handleSelectionChange(selection: MaterialProp[]) {
const handleRemove = function (row: { id: string }) {
deleteMembers(row.id)
}
const handleRemoves = function () {
const ids = multipleSelection
.reduce((a: any, b: any) => {
......@@ -103,7 +104,7 @@ const handleRemoves = function () {
}
const deleteMembers = function (ids: string) {
deleteMaterial({ id: ids }).then(res => {
deleteMaterial({ id: ids }).then(() => {
ElMessage({ message: '删除成功', type: 'success' })
handleRefresh()
})
......@@ -115,7 +116,13 @@ const deleteMembers = function (ids: string) {
<AppList v-bind="listOptions" ref="appList" @selection-change="handleSelectionChange">
<template #header-buttons>
<el-space>
<el-button type="primary" :icon="Plus" @click="handleAdd">新建</el-button>
<el-button
type="primary"
:icon="Plus"
@click="handleAdd"
v-permission="'v1-experiment-marketing-material-create'"
>新建</el-button
>
<!-- <el-button type="danger" plain :icon="Delete" :disabled="!multipleSelection.length" @click="handleRemoves()"
>删除</el-button
> -->
......@@ -123,8 +130,20 @@ const deleteMembers = function (ids: string) {
</template>
<template #table-x="{ row }">
<el-button type="primary" plain @click="handleView(row)">查看</el-button>
<el-button type="primary" plain @click="handleEdit(row)">编辑</el-button>
<el-button type="primary" plain @click="handleRemove(row)">删除</el-button>
<el-button
type="primary"
plain
@click="handleEdit(row)"
v-permission="'v1-experiment-marketing-material-update'"
>编辑</el-button
>
<el-button
type="primary"
plain
@click="handleRemove(row)"
v-permission="'v1-experiment-marketing-material-delete'"
>删除</el-button
>
</template>
</AppList>
<UpdateMaterialDialog
......@@ -132,7 +151,6 @@ const deleteMembers = function (ids: string) {
:data="currentRow"
@update="handleRefresh()"
v-if="updateVisible"
v-model="updateVisible"
></UpdateMaterialDialog>
v-model="updateVisible"></UpdateMaterialDialog>
</AppCard>
</template>
......@@ -92,6 +92,7 @@ function handleSelectionChange(selection: MaterialProp[]) {
const handleRemove = function (row: { id: string }) {
deleteMembers(row.id)
}
const handleRemoves = function () {
const ids = multipleSelection
.reduce((a: any, b: any) => {
......@@ -103,7 +104,7 @@ const handleRemoves = function () {
}
const deleteMembers = function (ids: string) {
deleteMaterial({ id: ids }).then(res => {
deleteMaterial({ id: ids }).then(() => {
ElMessage({ message: '删除成功', type: 'success' })
handleRefresh()
})
......@@ -115,7 +116,13 @@ const deleteMembers = function (ids: string) {
<AppList v-bind="listOptions" ref="appList" @selection-change="handleSelectionChange">
<template #header-buttons>
<el-space>
<el-button type="primary" :icon="Plus" @click="handleAdd">新建</el-button>
<el-button
type="primary"
:icon="Plus"
@click="handleAdd"
v-permission="'v1-experiment-marketing-material-create'"
>新建</el-button
>
<!-- <el-button type="danger" plain :icon="Delete" :disabled="!multipleSelection.length" @click="handleRemoves()"
>删除</el-button
> -->
......@@ -123,8 +130,20 @@ const deleteMembers = function (ids: string) {
</template>
<template #table-x="{ row }">
<el-button type="primary" plain @click="handleView(row)">查看</el-button>
<el-button type="primary" plain @click="handleEdit(row)">编辑</el-button>
<el-button type="primary" plain @click="handleRemove(row)">删除</el-button>
<el-button
type="primary"
plain
@click="handleEdit(row)"
v-permission="'v1-experiment-marketing-material-update'"
>编辑</el-button
>
<el-button
type="primary"
plain
@click="handleRemove(row)"
v-permission="'v1-experiment-marketing-material-delete'"
>删除</el-button
>
</template>
</AppList>
<UpdateMaterialDialog
......@@ -132,7 +151,6 @@ const deleteMembers = function (ids: string) {
:data="currentRow"
@update="handleRefresh()"
v-if="updateVisible"
v-model="updateVisible"
></UpdateMaterialDialog>
v-model="updateVisible"></UpdateMaterialDialog>
</AppCard>
</template>
......@@ -92,6 +92,7 @@ function handleSelectionChange(selection: MaterialProp[]) {
const handleRemove = function (row: { id: string }) {
deleteMembers(row.id)
}
const handleRemoves = function () {
const ids = multipleSelection
.reduce((a: any, b: any) => {
......@@ -103,7 +104,7 @@ const handleRemoves = function () {
}
const deleteMembers = function (ids: string) {
deleteMaterial({ id: ids }).then(res => {
deleteMaterial({ id: ids }).then(() => {
ElMessage({ message: '删除成功', type: 'success' })
handleRefresh()
})
......@@ -115,7 +116,13 @@ const deleteMembers = function (ids: string) {
<AppList v-bind="listOptions" ref="appList" @selection-change="handleSelectionChange">
<template #header-buttons>
<el-space>
<el-button type="primary" :icon="Plus" @click="handleAdd">新建</el-button>
<el-button
type="primary"
:icon="Plus"
@click="handleAdd"
v-permission="'v1-experiment-marketing-material-create'"
>新建</el-button
>
<!-- <el-button type="danger" plain :icon="Delete" :disabled="!multipleSelection.length" @click="handleRemoves()"
>删除</el-button
> -->
......@@ -123,8 +130,20 @@ const deleteMembers = function (ids: string) {
</template>
<template #table-x="{ row }">
<el-button type="primary" plain @click="handleView(row)">查看</el-button>
<el-button type="primary" plain @click="handleEdit(row)">编辑</el-button>
<el-button type="primary" plain @click="handleRemove(row)">删除</el-button>
<el-button
type="primary"
plain
@click="handleEdit(row)"
v-permission="'v1-experiment-marketing-material-update'"
>编辑</el-button
>
<el-button
type="primary"
plain
@click="handleRemove(row)"
v-permission="'v1-experiment-marketing-material-delete'"
>删除</el-button
>
</template>
</AppList>
<UpdateMaterialDialog
......@@ -132,7 +151,6 @@ const deleteMembers = function (ids: string) {
:data="currentRow"
@update="handleRefresh()"
v-if="updateVisible"
v-model="updateVisible"
></UpdateMaterialDialog>
v-model="updateVisible"></UpdateMaterialDialog>
</AppCard>
</template>
......@@ -92,6 +92,7 @@ function handleSelectionChange(selection: MaterialProp[]) {
const handleRemove = function (row: { id: string }) {
deleteMembers(row.id)
}
const handleRemoves = function () {
const ids = multipleSelection
.reduce((a: any, b: any) => {
......@@ -103,7 +104,7 @@ const handleRemoves = function () {
}
const deleteMembers = function (ids: string) {
deleteMaterial({ id: ids }).then(res => {
deleteMaterial({ id: ids }).then(() => {
ElMessage({ message: '删除成功', type: 'success' })
handleRefresh()
})
......@@ -115,7 +116,13 @@ const deleteMembers = function (ids: string) {
<AppList v-bind="listOptions" ref="appList" @selection-change="handleSelectionChange">
<template #header-buttons>
<el-space>
<el-button type="primary" :icon="Plus" @click="handleAdd">新建</el-button>
<el-button
type="primary"
:icon="Plus"
@click="handleAdd"
v-permission="'v1-experiment-marketing-material-create'"
>新建</el-button
>
<!-- <el-button type="danger" plain :icon="Delete" :disabled="!multipleSelection.length" @click="handleRemoves()"
>删除</el-button
> -->
......@@ -123,8 +130,20 @@ const deleteMembers = function (ids: string) {
</template>
<template #table-x="{ row }">
<el-button type="primary" plain @click="handleView(row)">查看</el-button>
<el-button type="primary" plain @click="handleEdit(row)">编辑</el-button>
<el-button type="primary" plain @click="handleRemove(row)">删除</el-button>
<el-button
type="primary"
plain
@click="handleEdit(row)"
v-permission="'v1-experiment-marketing-material-update'"
>编辑</el-button
>
<el-button
type="primary"
plain
@click="handleRemove(row)"
v-permission="'v1-experiment-marketing-material-delete'"
>删除</el-button
>
</template>
</AppList>
<UpdateMaterialDialog
......@@ -132,7 +151,6 @@ const deleteMembers = function (ids: string) {
:data="currentRow"
@update="handleRefresh()"
v-if="updateVisible"
v-model="updateVisible"
></UpdateMaterialDialog>
v-model="updateVisible"></UpdateMaterialDialog>
</AppCard>
</template>
......@@ -92,6 +92,7 @@ function handleSelectionChange(selection: MaterialProp[]) {
const handleRemove = function (row: { id: string }) {
deleteMembers(row.id)
}
const handleRemoves = function () {
const ids = multipleSelection
.reduce((a: any, b: any) => {
......@@ -103,7 +104,7 @@ const handleRemoves = function () {
}
const deleteMembers = function (ids: string) {
deleteMaterial({ id: ids }).then(res => {
deleteMaterial({ id: ids }).then(() => {
ElMessage({ message: '删除成功', type: 'success' })
handleRefresh()
})
......@@ -115,7 +116,13 @@ const deleteMembers = function (ids: string) {
<AppList v-bind="listOptions" ref="appList" @selection-change="handleSelectionChange">
<template #header-buttons>
<el-space>
<el-button type="primary" :icon="Plus" @click="handleAdd">新建</el-button>
<el-button
type="primary"
:icon="Plus"
@click="handleAdd"
v-permission="'v1-experiment-marketing-material-create'"
>新建</el-button
>
<!-- <el-button type="danger" plain :icon="Delete" :disabled="!multipleSelection.length" @click="handleRemoves()"
>删除</el-button
> -->
......@@ -123,8 +130,20 @@ const deleteMembers = function (ids: string) {
</template>
<template #table-x="{ row }">
<el-button type="primary" plain @click="handleView(row)">查看</el-button>
<el-button type="primary" plain @click="handleEdit(row)">编辑</el-button>
<el-button type="primary" plain @click="handleRemove(row)">删除</el-button>
<el-button
type="primary"
plain
@click="handleEdit(row)"
v-permission="'v1-experiment-marketing-material-update'"
>编辑</el-button
>
<el-button
type="primary"
plain
@click="handleRemove(row)"
v-permission="'v1-experiment-marketing-material-delete'"
>删除</el-button
>
</template>
</AppList>
<UpdateMaterialDialog
......@@ -132,7 +151,6 @@ const deleteMembers = function (ids: string) {
:data="currentRow"
@update="handleRefresh()"
v-if="updateVisible"
v-model="updateVisible"
></UpdateMaterialDialog>
v-model="updateVisible"></UpdateMaterialDialog>
</AppCard>
</template>
......@@ -92,6 +92,7 @@ function handleSelectionChange(selection: MaterialProp[]) {
const handleRemove = function (row: { id: string }) {
deleteMembers(row.id)
}
const handleRemoves = function () {
const ids = multipleSelection
.reduce((a: any, b: any) => {
......@@ -103,7 +104,7 @@ const handleRemoves = function () {
}
const deleteMembers = function (ids: string) {
deleteMaterial({ id: ids }).then(res => {
deleteMaterial({ id: ids }).then(() => {
ElMessage({ message: '删除成功', type: 'success' })
handleRefresh()
})
......@@ -115,7 +116,13 @@ const deleteMembers = function (ids: string) {
<AppList v-bind="listOptions" ref="appList" @selection-change="handleSelectionChange">
<template #header-buttons>
<el-space>
<el-button type="primary" :icon="Plus" @click="handleAdd">新建</el-button>
<el-button
type="primary"
:icon="Plus"
@click="handleAdd"
v-permission="'v1-experiment-marketing-material-create'"
>新建</el-button
>
<!-- <el-button type="danger" plain :icon="Delete" :disabled="!multipleSelection.length" @click="handleRemoves()"
>删除</el-button
> -->
......@@ -123,8 +130,20 @@ const deleteMembers = function (ids: string) {
</template>
<template #table-x="{ row }">
<el-button type="primary" plain @click="handleView(row)">查看</el-button>
<el-button type="primary" plain @click="handleEdit(row)">编辑</el-button>
<el-button type="primary" plain @click="handleRemove(row)">删除</el-button>
<el-button
type="primary"
plain
@click="handleEdit(row)"
v-permission="'v1-experiment-marketing-material-update'"
>编辑</el-button
>
<el-button
type="primary"
plain
@click="handleRemove(row)"
v-permission="'v1-experiment-marketing-material-delete'"
>删除</el-button
>
</template>
</AppList>
<UpdateMaterialDialog
......@@ -132,7 +151,6 @@ const deleteMembers = function (ids: string) {
:data="currentRow"
@update="handleRefresh()"
v-if="updateVisible"
v-model="updateVisible"
></UpdateMaterialDialog>
v-model="updateVisible"></UpdateMaterialDialog>
</AppCard>
</template>
......@@ -92,6 +92,7 @@ function handleSelectionChange(selection: MaterialProp[]) {
const handleRemove = function (row: { id: string }) {
deleteMembers(row.id)
}
const handleRemoves = function () {
const ids = multipleSelection
.reduce((a: any, b: any) => {
......@@ -103,7 +104,7 @@ const handleRemoves = function () {
}
const deleteMembers = function (ids: string) {
deleteMaterial({ id: ids }).then(res => {
deleteMaterial({ id: ids }).then(() => {
ElMessage({ message: '删除成功', type: 'success' })
handleRefresh()
})
......@@ -115,7 +116,13 @@ const deleteMembers = function (ids: string) {
<AppList v-bind="listOptions" ref="appList" @selection-change="handleSelectionChange">
<template #header-buttons>
<el-space>
<el-button type="primary" :icon="Plus" @click="handleAdd">新建</el-button>
<el-button
type="primary"
:icon="Plus"
@click="handleAdd"
v-permission="'v1-experiment-marketing-material-create'"
>新建</el-button
>
<!-- <el-button type="danger" plain :icon="Delete" :disabled="!multipleSelection.length" @click="handleRemoves()"
>删除</el-button
> -->
......@@ -123,8 +130,20 @@ const deleteMembers = function (ids: string) {
</template>
<template #table-x="{ row }">
<el-button type="primary" plain @click="handleView(row)">查看</el-button>
<el-button type="primary" plain @click="handleEdit(row)">编辑</el-button>
<el-button type="primary" plain @click="handleRemove(row)">删除</el-button>
<el-button
type="primary"
plain
@click="handleEdit(row)"
v-permission="'v1-experiment-marketing-material-update'"
>编辑</el-button
>
<el-button
type="primary"
plain
@click="handleRemove(row)"
v-permission="'v1-experiment-marketing-material-delete'"
>删除</el-button
>
</template>
</AppList>
<UpdateMaterialDialog
......@@ -132,7 +151,6 @@ const deleteMembers = function (ids: string) {
:data="currentRow"
@update="handleRefresh()"
v-if="updateVisible"
v-model="updateVisible"
></UpdateMaterialDialog>
v-model="updateVisible"></UpdateMaterialDialog>
</AppCard>
</template>
......@@ -92,6 +92,7 @@ function handleSelectionChange(selection: MaterialProp[]) {
const handleRemove = function (row: { id: string }) {
deleteMembers(row.id)
}
const handleRemoves = function () {
const ids = multipleSelection
.reduce((a: any, b: any) => {
......@@ -103,7 +104,7 @@ const handleRemoves = function () {
}
const deleteMembers = function (ids: string) {
deleteMaterial({ id: ids }).then(res => {
deleteMaterial({ id: ids }).then(() => {
ElMessage({ message: '删除成功', type: 'success' })
handleRefresh()
})
......@@ -115,7 +116,13 @@ const deleteMembers = function (ids: string) {
<AppList v-bind="listOptions" ref="appList" @selection-change="handleSelectionChange">
<template #header-buttons>
<el-space>
<el-button type="primary" :icon="Plus" @click="handleAdd">新建</el-button>
<el-button
type="primary"
:icon="Plus"
@click="handleAdd"
v-permission="'v1-experiment-marketing-material-create'"
>新建</el-button
>
<!-- <el-button type="danger" plain :icon="Delete" :disabled="!multipleSelection.length" @click="handleRemoves()"
>删除</el-button
> -->
......@@ -123,8 +130,20 @@ const deleteMembers = function (ids: string) {
</template>
<template #table-x="{ row }">
<el-button type="primary" plain @click="handleView(row)">查看</el-button>
<el-button type="primary" plain @click="handleEdit(row)">编辑</el-button>
<el-button type="primary" plain @click="handleRemove(row)">删除</el-button>
<el-button
type="primary"
plain
@click="handleEdit(row)"
v-permission="'v1-experiment-marketing-material-update'"
>编辑</el-button
>
<el-button
type="primary"
plain
@click="handleRemove(row)"
v-permission="'v1-experiment-marketing-material-delete'"
>删除</el-button
>
</template>
</AppList>
<UpdateMaterialDialog
......@@ -132,7 +151,6 @@ const deleteMembers = function (ids: string) {
:data="currentRow"
@update="handleRefresh()"
v-if="updateVisible"
v-model="updateVisible"
></UpdateMaterialDialog>
v-model="updateVisible"></UpdateMaterialDialog>
</AppCard>
</template>
......@@ -197,8 +197,10 @@ const downloadMember = function (isAll?: boolean) {
<AppList v-bind="listOptions" ref="appList" @selection-change="handleSelectionChange">
<template #header-buttons>
<el-space>
<el-button type="primary" :icon="Plus" @click="handleAdd">新建</el-button>
<el-dropdown>
<el-button type="primary" :icon="Plus" @click="handleAdd" v-permission="'v1-experiment-member-create'"
>新建</el-button
>
<el-dropdown v-permission="'v1-experiment-member-download'">
<el-button type="primary" :icon="Download">导出</el-button>
<template #dropdown>
<el-dropdown-menu>
......@@ -207,7 +209,7 @@ const downloadMember = function (isAll?: boolean) {
</el-dropdown-menu>
</template>
</el-dropdown>
<el-dropdown>
<el-dropdown v-permission="['v1-experiment-member-member-upload', 'v1-experiment-member-event-upload']">
<el-button type="primary" :icon="Upload">导入</el-button>
<template #dropdown>
<el-dropdown-menu>
......@@ -217,7 +219,13 @@ const downloadMember = function (isAll?: boolean) {
</template>
</el-dropdown>
<el-button type="primary" @click="progressVisible = true">数据导入进度</el-button>
<el-button type="danger" plain :icon="Delete" :disabled="!multipleSelection.length" @click="handleRemoves()"
<el-button
type="danger"
plain
:icon="Delete"
:disabled="!multipleSelection.length"
@click="handleRemoves()"
v-permission="'v1-experiment-member-delete'"
>删除</el-button
>
</el-space>
......@@ -225,8 +233,12 @@ const downloadMember = function (isAll?: boolean) {
<template #table-x="{ row }">
<el-button type="primary" plain @click="handleImage(row)">画像</el-button>
<el-button type="primary" plain @click="handleView(row)">查看</el-button>
<el-button type="primary" plain @click="handleEdit(row)">编辑</el-button>
<el-button type="primary" plain @click="handleRemove(row)">删除</el-button>
<el-button type="primary" plain @click="handleEdit(row)" v-permission="'v1-experiment-member-update'"
>编辑</el-button
>
<el-button type="primary" plain @click="handleRemove(row)" v-permission="'v1-experiment-member-delete'"
>删除</el-button
>
<el-button type="primary" plain @click="goPage(row)">事件</el-button>
</template>
</AppList>
......
import type { UserType, ProjectType, OrganizationType, RoleType, PermissionType } from '@/types'
import { defineStore } from 'pinia'
import { getUser, logout } from '@/api/base'
import { getUser, logout, checkDataStatus } from '@/api/base'
import { useMapStore } from '@/stores/map'
// 角色信息(1学员;5教师; 6管理员)
......@@ -15,6 +15,7 @@ interface State {
organization: OrganizationType | null
roles: RoleType[]
permissions: PermissionType[]
status: boolean
}
export const useUserStore = defineStore({
......@@ -25,7 +26,8 @@ export const useUserStore = defineStore({
organization: null,
project: null,
roles: [],
permissions: []
permissions: [],
status: false
}),
getters: {
isLogin: state => !!state.user
......@@ -42,6 +44,9 @@ export const useUserStore = defineStore({
this.roles = roles
this.permissions = permissions
await useMapStore().getMapList()
await checkDataStatus().then(res => {
this.status = res.data.status
})
},
async logout() {
await logout()
......
......@@ -4,6 +4,8 @@ import type { DirectiveBinding } from 'vue'
// 判断是否有权限
export function checkPermission(value: string | string[]): boolean {
const userStore = useUserStore()
// true 是学员且使用公共数据(学员不能自己创建数据) false 学员可以自己创建数据
if (userStore.status) return true
const permissions = userStore.permissions
if (Array.isArray(value)) {
return permissions.some(item => value.includes(item.tag))
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论