fix: 下游设备配置添加权限校验

This commit is contained in:
yangsy
2026-01-28 15:57:23 +08:00
parent aa4684273b
commit 9b21beed0f
2 changed files with 10 additions and 0 deletions

View File

@@ -13,7 +13,9 @@ import {
type Station, type Station,
} from '@/apis'; } from '@/apis';
import { SecurityBoxCircuitLinkModal } from '@/components'; import { SecurityBoxCircuitLinkModal } from '@/components';
import { usePermission } from '@/composables';
import { SELECT_DEVICE_FN_INJECTION_KEY } from '@/constants'; import { SELECT_DEVICE_FN_INJECTION_KEY } from '@/constants';
import { PERMISSION_TYPE_LITERALS } from '@/enums';
import { useDeviceStore, useSettingStore } from '@/stores'; import { useDeviceStore, useSettingStore } from '@/stores';
import { parseErrorFeedback } from '@/utils'; import { parseErrorFeedback } from '@/utils';
import { useMutation } from '@tanstack/vue-query'; import { useMutation } from '@tanstack/vue-query';
@@ -40,6 +42,8 @@ const { lineDevices } = storeToRefs(deviceStore);
const settingStore = useSettingStore(); const settingStore = useSettingStore();
const { useLocalDB } = storeToRefs(settingStore); const { useLocalDB } = storeToRefs(settingStore);
const { hasPermission } = usePermission();
const { ndmDevice, station, circuits } = toRefs(props); const { ndmDevice, station, circuits } = toRefs(props);
const showCard = computed(() => !!circuits.value && circuits.value.length > 0); const showCard = computed(() => !!circuits.value && circuits.value.length > 0);
@@ -223,6 +227,7 @@ const onSelectDropdownOption = (key: string, option: DropdownOption) => {
const onContextmenu = (payload: PointerEvent, circuitIndex: number) => { const onContextmenu = (payload: PointerEvent, circuitIndex: number) => {
payload.stopPropagation(); payload.stopPropagation();
payload.preventDefault(); payload.preventDefault();
if (!hasPermission(station.value.code, PERMISSION_TYPE_LITERALS.OPERATION)) return;
const { clientX, clientY } = payload; const { clientX, clientY } = payload;
contextmenu.value = { x: clientX, y: clientY, circuitIndex }; contextmenu.value = { x: clientX, y: clientY, circuitIndex };
showContextmenu.value = true; showContextmenu.value = true;

View File

@@ -1,7 +1,9 @@
<script setup lang="ts"> <script setup lang="ts">
import { detailDeviceApi, updateDeviceApi, type LinkDescription, type NdmDeviceResultVO, type NdmSwitchLinkDescription, type NdmSwitchPortInfo, type NdmSwitchResultVO, type Station } from '@/apis'; import { detailDeviceApi, updateDeviceApi, type LinkDescription, type NdmDeviceResultVO, type NdmSwitchLinkDescription, type NdmSwitchPortInfo, type NdmSwitchResultVO, type Station } from '@/apis';
import { SwitchPortLinkModal } from '@/components'; import { SwitchPortLinkModal } from '@/components';
import { usePermission } from '@/composables';
import { SELECT_DEVICE_FN_INJECTION_KEY } from '@/constants'; import { SELECT_DEVICE_FN_INJECTION_KEY } from '@/constants';
import { PERMISSION_TYPE_LITERALS } from '@/enums';
import { getPortStatusValue, transformPortSpeed } from '@/helpers'; import { getPortStatusValue, transformPortSpeed } from '@/helpers';
import { useDeviceStore, useSettingStore } from '@/stores'; import { useDeviceStore, useSettingStore } from '@/stores';
import { parseErrorFeedback } from '@/utils'; import { parseErrorFeedback } from '@/utils';
@@ -27,6 +29,8 @@ const { lineDevices } = storeToRefs(deviceStore);
const settingStore = useSettingStore(); const settingStore = useSettingStore();
const { useLocalDB } = storeToRefs(settingStore); const { useLocalDB } = storeToRefs(settingStore);
const { hasPermission } = usePermission();
const { ndmDevice, station, ports } = toRefs(props); const { ndmDevice, station, ports } = toRefs(props);
const showCard = computed(() => !!ports.value); const showCard = computed(() => !!ports.value);
@@ -172,6 +176,7 @@ const onSelectDropdownOption = (key: string, option: DropdownOption) => {
const onContextmenu = (payload: PointerEvent, port: NdmSwitchPortInfo) => { const onContextmenu = (payload: PointerEvent, port: NdmSwitchPortInfo) => {
payload.stopPropagation(); payload.stopPropagation();
payload.preventDefault(); payload.preventDefault();
if (!hasPermission(station.value.code, PERMISSION_TYPE_LITERALS.OPERATION)) return;
const { clientX, clientY } = payload; const { clientX, clientY } = payload;
contextmenu.value = { x: clientX, y: clientY, port }; contextmenu.value = { x: clientX, y: clientY, port };
showContextmenu.value = true; showContextmenu.value = true;