Kaynağa Gözat

NVR页面按钮权限控制

lfeish 1 yıl önce
ebeveyn
işleme
ea5bbbe081
1 değiştirilmiş dosya ile 24 ekleme ve 13 silme
  1. 24 13
      src/views/cameras/nvrlist/NvrList.vue

+ 24 - 13
src/views/cameras/nvrlist/NvrList.vue

@@ -16,7 +16,7 @@
         }" :striped="true" ref="tableRef" @page-num-change="handlePageNumChange"
         @page-size-change="handlePageSizeChange">
         <template #tableTitle>
-          <el-button type="primary" @click="openCreateDrawer" :icon="Plus">添加</el-button>
+          <el-button type="primary" @click="openCreateDrawer" :icon="Plus" v-permission="{ action: [PERM_DEVICE.NVR_ADD] }">添加</el-button>
         </template>
         <template #empty>
           <div class="empty-content flex flex-col items-center">
@@ -42,6 +42,8 @@ import { columns } from './overviewColumns';
 import { BasicTable, TableActionIcons, BasicColumn } from '@/components/Table';
 import CreateDrawer from './components/CreateDrawer.vue';
 import { deleteNVRListItem, getNVRList, NVRListItemAll } from '@/api/camera/camera-nvr';
+import { PERM_DEVICE } from '@/types/permission/constants';
+import { useUserStore } from '@/store/modules/user';
 
 const nvrList = ref<NVRListItemAll[]>([]);
 const total = ref(0);
@@ -103,6 +105,8 @@ const handleDelete = (row) => {
     })
 };
 
+const userStore = useUserStore();
+
 //操作列
 const actionColumn: BasicColumn = reactive({
   width: 200,
@@ -111,23 +115,30 @@ const actionColumn: BasicColumn = reactive({
   key: 'action',
   fixed: 'right',
   render(record) {
+    const actions: any[] = [];
+
+    if (userStore.checkPermission(PERM_DEVICE.NVR_EDIT)) {
+      actions.push({
+        label: '修改',
+        icon: editIcon,
+        onClick: handleEdit.bind(null, record.row),
+      });
+    }
+
+    if (userStore.checkPermission(PERM_DEVICE.NVR_DELETE)) {
+      actions.push({
+        label: '删除',
+        icon: deleteIcon,
+        onClick: handleDelete.bind(null, record.row),
+      });
+    }
+
     return h(TableActionIcons as any, {
       space: 20,
       color: '#629bf9',
       style: 'img',
       size: 16,
-      actionIcons: [
-        {
-          label: '修改',
-          icon: editIcon,
-          onClick: handleEdit.bind(null, record.row),
-        },
-        {
-          label: '删除',
-          icon: deleteIcon,
-          onClick: handleDelete.bind(null, record.row),
-        },
-      ],
+      actionIcons: actions
     });
   },
 });