feat(iot):优化 device 的权限校验

pull/345/head
YunaiV 2026-05-18 12:28:21 +08:00
parent cfb1f8401e
commit 81b4690998
2 changed files with 11 additions and 2 deletions

View File

@ -400,7 +400,6 @@ onMounted(async () => {
type: 'primary', type: 'primary',
icon: 'ant-design:folder-add-outlined', icon: 'ant-design:folder-add-outlined',
auth: ['iot:device:update'], auth: ['iot:device:update'],
ifShow: isListView,
disabled: isEmpty(checkedIds), disabled: isEmpty(checkedIds),
onClick: handleAddToGroup, onClick: handleAddToGroup,
}, },
@ -410,7 +409,6 @@ onMounted(async () => {
danger: true, danger: true,
icon: ACTION_ICON.DELETE, icon: ACTION_ICON.DELETE,
auth: ['iot:device:delete'], auth: ['iot:device:delete'],
ifShow: isListView,
disabled: isEmpty(checkedIds), disabled: isEmpty(checkedIds),
onClick: handleDeleteBatch, onClick: handleDeleteBatch,
}, },
@ -463,17 +461,20 @@ onMounted(async () => {
{ {
label: $t('common.detail'), label: $t('common.detail'),
type: 'link', type: 'link',
auth: ['iot:device:query'],
onClick: openDetail.bind(null, row.id!), onClick: openDetail.bind(null, row.id!),
}, },
{ {
label: '日志', label: '日志',
type: 'link', type: 'link',
auth: ['iot:device:message-query'],
onClick: openModel.bind(null, row.id!), onClick: openModel.bind(null, row.id!),
}, },
{ {
label: $t('common.edit'), label: $t('common.edit'),
type: 'link', type: 'link',
icon: ACTION_ICON.EDIT, icon: ACTION_ICON.EDIT,
auth: ['iot:device:update'],
onClick: handleEdit.bind(null, row), onClick: handleEdit.bind(null, row),
}, },
{ {
@ -481,6 +482,7 @@ onMounted(async () => {
type: 'link', type: 'link',
danger: true, danger: true,
icon: ACTION_ICON.DELETE, icon: ACTION_ICON.DELETE,
auth: ['iot:device:delete'],
popConfirm: { popConfirm: {
title: $t('ui.actionMessage.deleteConfirm', [row.deviceName]), title: $t('ui.actionMessage.deleteConfirm', [row.deviceName]),
confirm: handleDelete.bind(null, row), confirm: handleDelete.bind(null, row),

View File

@ -5,6 +5,7 @@ import type { IotDeviceApi } from '#/api/iot/device/device';
import { onMounted, ref } from 'vue'; import { onMounted, ref } from 'vue';
import { useAccess } from '@vben/access';
import { DICT_TYPE } from '@vben/constants'; import { DICT_TYPE } from '@vben/constants';
import { IconifyIcon } from '@vben/icons'; import { IconifyIcon } from '@vben/icons';
@ -47,6 +48,8 @@ const emit = defineEmits<{
productDetail: [productId: number]; productDetail: [productId: number];
}>(); }>();
const { hasAccessByCodes } = useAccess();
const loading = ref(false); const loading = ref(false);
const list = ref<IotDeviceApi.Device[]>([]); const list = ref<IotDeviceApi.Device[]>([]);
const total = ref(0); const total = ref(0);
@ -184,6 +187,7 @@ onMounted(() => {
<!-- 按钮组 --> <!-- 按钮组 -->
<div class="action-buttons"> <div class="action-buttons">
<Button <Button
v-if="hasAccessByCodes(['iot:device:update'])"
size="small" size="small"
class="action-btn action-btn-edit" class="action-btn action-btn-edit"
@click="emit('edit', item)" @click="emit('edit', item)"
@ -192,6 +196,7 @@ onMounted(() => {
编辑 编辑
</Button> </Button>
<Button <Button
v-if="hasAccessByCodes(['iot:device:query'])"
size="small" size="small"
class="action-btn action-btn-detail" class="action-btn action-btn-detail"
@click="emit('detail', item.id!)" @click="emit('detail', item.id!)"
@ -200,6 +205,7 @@ onMounted(() => {
详情 详情
</Button> </Button>
<Button <Button
v-if="hasAccessByCodes(['iot:device:message-query'])"
size="small" size="small"
class="action-btn action-btn-data" class="action-btn action-btn-data"
@click="emit('model', item.id!)" @click="emit('model', item.id!)"
@ -208,6 +214,7 @@ onMounted(() => {
数据 数据
</Button> </Button>
<Popconfirm <Popconfirm
v-if="hasAccessByCodes(['iot:device:delete'])"
:title="`确认删除设备 ${item.deviceName} 吗?`" :title="`确认删除设备 ${item.deviceName} 吗?`"
@confirm="emit('delete', item)" @confirm="emit('delete', item)"
> >