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

chore: 新增权限控制

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