fix: 按钮权限调整

This commit is contained in:
caiyuchao
2025-08-13 15:39:09 +08:00
parent c401195986
commit ef6da4f3c6
5 changed files with 24 additions and 18 deletions

View File

@@ -1,13 +1,16 @@
<script lang="ts" setup> <script lang="ts" setup>
import { computed, onMounted, ref } from 'vue'; import { computed, onMounted, ref } from 'vue';
import { useAccess } from '@vben/access';
import { Page } from '@vben/common-ui'; import { Page } from '@vben/common-ui';
import { Button, Card, message, Space } from 'ant-design-vue'; import { Button, Card, message, Space } from 'ant-design-vue';
import { useVbenForm } from '#/adapter/form'; import { useVbenForm } from '#/adapter/form';
import { getAlertPage, updateAlert } from '#/api/alert/alert'; import { getAlertPage, updateAlert } from '#/api/alert/alert';
import { getUserPage } from '#/api/system/user'; import { getSimpleUserList } from '#/api/system/user';
const { hasAccessByCodes } = useAccess();
// 表单数据 // 表单数据
const formData = ref({ const formData = ref({
@@ -48,6 +51,10 @@ const formSchema = computed(() => [
mode: 'multiple', mode: 'multiple',
allowClear: true, allowClear: true,
showSearch: true, showSearch: true,
fieldNames: {
label: 'nickname',
value: 'id',
},
filterOption: (input: string, option: any) => { filterOption: (input: string, option: any) => {
return option?.label?.toLowerCase().includes(input.toLowerCase()); return option?.label?.toLowerCase().includes(input.toLowerCase());
}, },
@@ -140,15 +147,7 @@ function handleReset() {
async function loadUserList() { async function loadUserList() {
try { try {
// 参考部门管理界面的做法使用getUserPage接口 // 参考部门管理界面的做法使用getUserPage接口
const { list } = await getUserPage({ userOptions.value = await getSimpleUserList();
pageNo: 1,
pageSize: 100, // 获取前100个用户
});
userOptions.value = list.map((user) => ({
label: user.nickname || user.username,
value: user.id,
}));
} catch {} } catch {}
} }
@@ -182,7 +181,13 @@ onMounted(async () => {
<Form /> <Form />
<div class="mt-4 flex justify-end"> <div class="mt-4 flex justify-end">
<Space> <Space>
<Button type="primary" @click="handleSubmit">保存</Button> <Button
type="primary"
@click="handleSubmit"
v-if="hasAccessByCodes(['license:alert:update'])"
>
保存
</Button>
<Button @click="handleReset"> 重置 </Button> <Button @click="handleReset"> 重置 </Button>
</Space> </Space>
</div> </div>

View File

@@ -139,7 +139,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
label: $t('ui.actionTitle.import', [$t('customer.customer')]), label: $t('ui.actionTitle.import', [$t('customer.customer')]),
type: 'primary', type: 'primary',
icon: ACTION_ICON.UPLOAD, icon: ACTION_ICON.UPLOAD,
auth: ['license:customer:export'], auth: ['license:customer:import'],
onClick: handleImport, onClick: handleImport,
}, },
]" ]"

View File

@@ -172,7 +172,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
label: $t('license.applyAction', ['License']), label: $t('license.applyAction', ['License']),
type: 'primary', type: 'primary',
icon: ACTION_ICON.ADD, icon: ACTION_ICON.ADD,
auth: ['license:license:create'], auth: ['license:license:apply'],
onClick: onCreate, onClick: onCreate,
}, },
{ {
@@ -186,7 +186,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
label: $t('ui.actionTitle.import', ['License']), label: $t('ui.actionTitle.import', ['License']),
type: 'primary', type: 'primary',
icon: ACTION_ICON.UPLOAD, icon: ACTION_ICON.UPLOAD,
auth: ['license:license:export'], auth: ['license:license:import'],
onClick: handleImport, onClick: handleImport,
}, },
]" ]"
@@ -199,6 +199,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
{ {
label: $t('license.detail'), label: $t('license.detail'),
type: 'link', type: 'link',
auth: ['license:license:query'],
onClick: onDetail.bind(null, row), onClick: onDetail.bind(null, row),
}, },
{ {
@@ -231,7 +232,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
label: $t('license.reapply'), label: $t('license.reapply'),
type: 'link', type: 'link',
ifShow: row.status === 3, ifShow: row.status === 3,
auth: ['license:license:query'], auth: ['license:license:reapply'],
onClick: onReapply.bind(null, row), onClick: onReapply.bind(null, row),
}, },
{ {

View File

@@ -465,7 +465,7 @@ export function useGridColumns(
{ {
code: 'progress', code: 'progress',
text: $t('project.progress'), text: $t('project.progress'),
show: hasAccessByCodes(['license:project:update']), show: hasAccessByCodes(['license:project:comment']),
}, },
{ {
code: 'delete', code: 'delete',

View File

@@ -174,7 +174,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
label: $t('ui.actionTitle.import', [$t('project.project')]), label: $t('ui.actionTitle.import', [$t('project.project')]),
type: 'primary', type: 'primary',
icon: ACTION_ICON.UPLOAD, icon: ACTION_ICON.UPLOAD,
auth: ['license:project:export'], auth: ['license:project:import'],
onClick: handleImport, onClick: handleImport,
}, },
]" ]"