Browse Source

chore: 按钮权限添加

main
刘凯 1 year ago
parent
commit
d7db0e30ed
  1. 21
      src/views/device-manage/group/components/GroupList.vue
  2. 12
      src/views/device-manage/group/index.vue

21
src/views/device-manage/group/components/GroupList.vue

@ -7,6 +7,7 @@ import GroupFormModal from './GroupFormModal.vue'
import { useModal } from '@/components/Modal'
import { deleteDevicegroup, getDeviceGroupTree } from '@/api/device-manage/group'
import { useMessage } from '@/hooks/web/useMessage'
import { usePermission } from '@/hooks/web/usePermission'
defineProps<{ selectedGroupId: string | undefined }>()
const emit = defineEmits(['update:selectedGroupId'])
@ -35,16 +36,19 @@ watch(selectedKeys, (keys, oldKeys) => {
emit('update:selectedGroupId', value)
})
const { hasPermission } = usePermission()
</script>
<template>
<div rounded="6px" px="10px" pt="12px" pb="6px" border-box bg-white min-w="360px">
<div>
<div flex="~ items-center justify-between" h="35px">
<a-button size="small" @click="openModal()">
<a-button v-if="hasPermission('device_group_add')" size="small" @click="openModal()">
<PlusOutlined />
添加根分组
</a-button>
<span v-else /> <!-- ghost -->
<a-button size="small" @click="execute">
<SyncOutlined />
@ -61,9 +65,20 @@ watch(selectedKeys, (keys, oldKeys) => {
</div>
<Space>
<span class="i-ant-design:plus-outlined" title="添加子分组" @click="openModal(true, { parentId: data.id })" />
<span class="i-ant-design:edit-outlined" title="编辑分组" @click="openModal(true, { id: data.id })" />
<span
v-if="hasPermission('device_group_add')"
class="i-ant-design:plus-outlined"
title="添加子分组"
@click="openModal(true, { parentId: data.id })"
/>
<span
v-if="hasPermission('device_group_edit')"
class="i-ant-design:edit-outlined"
title="编辑分组"
@click="openModal(true, { id: data.id })"
/>
<Popconfirm
v-if="hasPermission('device_group_delete')"
title="是否要删除数据?"
:class="[data.hasChildren ? 'text-gray-300 cursor-not-allowed' : '']"
:disabled="data.hasChildren"

12
src/views/device-manage/group/index.vue

@ -9,6 +9,9 @@ import { useMessage } from '@/hooks/web/useMessage'
import { getDeviceListByGroup, unbindingDeviceFromGroup } from '@/api/device-manage/group'
import { useDrawer } from '@/components/Drawer'
import { noop } from '@/utils'
import { usePermission } from '@/hooks/web/usePermission'
const { hasPermission } = usePermission()
const [register, { getSelectRowKeys, reload }] = useTable({
async api(params) {
@ -34,6 +37,7 @@ const [register, { getSelectRowKeys, reload }] = useTable({
width: 210,
title: '操作',
dataIndex: 'action',
auth: ['device_group_unbinding', 'device_group_device_view'],
},
})
@ -79,13 +83,13 @@ function handleUnbindingDivice(id?: string) {
<div flex="~">
<GroupList v-model:selectedGroupId="selectedGroupId" my="12px" ml="12px" />
<BasicTable flex="1" @register="register">
<template #tableTitle>
<template v-if="hasPermission(['device_group_binding', 'device_group_unbinding'])" #tableTitle>
<Space>
<a-button @click="handleBindingDivice">
<a-button v-if="hasPermission('device_group_binding')" @click="handleBindingDivice">
<LinkOutlined />
批量绑定设备
</a-button>
<a-button @click="handleUnbindingDivice()">
<a-button v-if="hasPermission('device_group_unbinding')" @click="handleUnbindingDivice()">
<DisconnectOutlined />
批量解绑设备
</a-button>
@ -99,11 +103,13 @@ function handleUnbindingDivice(id?: string) {
{
icon: 'i-ant-design:file-search-outlined',
label: '设备详情',
auth: 'device_group_device_view',
onClick: () => $router.push(`/device-manage/device/detail/${record.id}`),
},
{
icon: 'i-ant-design:edit-outlined',
label: '解绑设备',
auth: 'device_group_unbinding',
popConfirm: {
title: '是否要解绑该设备?',
placement: 'left',

Loading…
Cancel
Save