feat: btn permission

pull/3/head
xingyuv 2023-03-24 11:44:08 +08:00
parent 2572e1db8a
commit e3ca40287b
3 changed files with 14 additions and 5 deletions

View File

@ -109,6 +109,7 @@ export const usePermissionStore = defineStore('app-permission', {
let routes: AppRouteRecordRaw[] = [] let routes: AppRouteRecordRaw[] = []
const roleList = toRaw(userStore.getRoleList) || [] const roleList = toRaw(userStore.getRoleList) || []
const userInfo = toRaw(userStore.getUserInfo) || {}
const { permissionMode = projectSetting.permissionMode } = appStore.getProjectConfig const { permissionMode = projectSetting.permissionMode } = appStore.getProjectConfig
// 路由过滤器 在 函数filter 作为回调传入遍历使用 // 路由过滤器 在 函数filter 作为回调传入遍历使用
@ -237,6 +238,11 @@ export const usePermissionStore = defineStore('app-permission', {
break break
} }
// 从用户中获取权限
if (userInfo) {
this.setPermCodeList(userInfo.permissions)
}
patchHomeAffix(routes) patchHomeAffix(routes)
return routes return routes
} }

View File

@ -12,7 +12,6 @@ import { createPost, getPost, updatePost } from '@/api/system/post'
const emit = defineEmits(['success', 'register']) const emit = defineEmits(['success', 'register'])
const isUpdate = ref(true) const isUpdate = ref(true)
const rowId = ref()
const [registerForm, { setFieldsValue, resetFields, validate }] = useForm({ const [registerForm, { setFieldsValue, resetFields, validate }] = useForm({
labelWidth: 100, labelWidth: 100,
@ -29,7 +28,6 @@ const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data
if (unref(isUpdate)) { if (unref(isUpdate)) {
const res = await getPost(data.record.id) const res = await getPost(data.record.id)
rowId.value = res.id
setFieldsValue({ ...res }) setFieldsValue({ ...res })
} }
}) })

View File

@ -2,18 +2,23 @@
<div> <div>
<BasicTable @register="registerTable"> <BasicTable @register="registerTable">
<template #toolbar> <template #toolbar>
<a-button type="primary" :preIcon="IconEnum.ADD" @click="handleCreate"> {{ t('action.create') }} </a-button> <a-button type="primary" v-auth="['system:post:create']" :preIcon="IconEnum.ADD" @click="handleCreate">
<a-button type="warning" :preIcon="IconEnum.EXPORT" @click="handleExport"> {{ t('action.export') }} </a-button> {{ t('action.create') }}
</a-button>
<a-button type="warning" v-auth="['system:post:export']" :preIcon="IconEnum.EXPORT" @click="handleExport">
{{ t('action.export') }}
</a-button>
</template> </template>
<template #bodyCell="{ column, record }"> <template #bodyCell="{ column, record }">
<template v-if="column.key === 'action'"> <template v-if="column.key === 'action'">
<TableAction <TableAction
:actions="[ :actions="[
{ icon: IconEnum.EDIT, label: t('action.edit'), onClick: handleEdit.bind(null, record) }, { icon: IconEnum.EDIT, label: t('action.edit'), auth: 'system:post:update', onClick: handleEdit.bind(null, record) },
{ {
icon: IconEnum.DELETE, icon: IconEnum.DELETE,
color: 'error', color: 'error',
label: t('action.delete'), label: t('action.delete'),
auth: 'system:post:delete',
popConfirm: { popConfirm: {
title: t('common.delMessage'), title: t('common.delMessage'),
placement: 'left', placement: 'left',