瀏覽代碼

Merge branch 'all-v4-liufei' into 'all-v4'

1. 角色管理页面、组织管理页面、NVR页面添加按钮权限控制 2. 修复角色创建相关bug

See merge request skyeye/skyeye_frontend/skyeye-admin!304
Fei Liu 1 年之前
父節點
當前提交
de6a1c868d

+ 4 - 3
src/views/auth/dept/dept.vue

@@ -3,7 +3,7 @@
     <el-card :bordered="false" class="proCard">
      <template #header>
         <el-space align="center">
-          <el-button type="primary" @click="openCreateDrawer">
+          <el-button type="primary" @click="openCreateDrawer" v-permission="{ action: [PERM_USER.DEPT_ADD] }">
             <template #icon>
               <el-icon>
                 <FileAddOutlined />
@@ -23,10 +23,10 @@
           <template #default="scope">
             <el-space>
               <div class="el-space el-space--horizontal">
-                <div class="el-space__item" @click="handleEdit(scope.row)">
+                <div class="el-space__item" @click="handleEdit(scope.row)" v-permission="{ action: [PERM_USER.DEPT_EDIT] }">
                   <div><img :src="editIcon" class="el-tooltip__trigger" /></div>
                 </div>
-                <div class="el-space__item" @click="handleDelete(scope.row)">
+                <div class="el-space__item" @click="handleDelete(scope.row)" v-permission="{ action: [PERM_USER.DEPT_DELETE] }">
                   <div><img :src="deleteIcon" class="el-tooltip__trigger" /></div>
                 </div>
               </div>
@@ -65,6 +65,7 @@
   import type { DeptTreeItem } from '@/types/dept/type';
   import editIcon from '@/assets/images/reportmessage/edit.png';
   import deleteIcon from '@/assets/images/reportmessage/delete.png';
+  import { PERM_USER } from '@/types/permission/constants';
 
   const globSetting = useGlobSetting();
   const disableDepartmentEdit = globSetting.disableDepartmentEdit;

+ 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
     });
   },
 });

+ 1 - 0
src/views/system/role/components/RoleDrawer.vue

@@ -132,6 +132,7 @@
 
     const api = isEditing.value ? editRole : createRole;
     try {
+      await formInstance.value?.validate();
       await api(toRaw(formData));
       drawerOpened.value = false;
       ElMessage.success('提交成功');

+ 6 - 3
src/views/system/role/role.vue

@@ -15,7 +15,9 @@
 
     <el-card>
       <template #header>
-        <el-button type="primary" @click="openDrawer()">添加角色</el-button>
+        <el-button type="primary" @click="openDrawer()" v-permission="{ action: [PERM_USER.ROLE_ADD] }">
+          添加角色
+        </el-button>
       </template>
 
       <el-table height="calc(100vh - 340px)" :data="roleList">
@@ -26,8 +28,8 @@
         <el-table-column label="操作" width="160">
           <template #default="{ row }">
             <el-space>
-              <el-button type="primary" :icon="Edit" text @click="openDrawer(row)" />
-              <el-button :icon="Delete" text @click="deleteRole(row.id)" />
+              <el-button type="primary" :icon="Edit" text @click="openDrawer(row)" v-permission="{ action: [PERM_USER.ROLE_EDIT] }" />
+              <el-button :icon="Delete" text @click="deleteRole(row.id)" v-permission="{ action: [PERM_USER.ROLE_DELETE] }"  />
             </el-space>
           </template>
         </el-table-column>
@@ -58,6 +60,7 @@
   import useRolesQuery from './hooks/useRolesQuery';
   import { Role } from '@/types/role/type';
   import { deleteRole as _deleteRole } from '@/api/system/role';
+  import { PERM_USER } from '@/types/permission/constants';
 
   const { roleList, total, queryRolesPage, requestParams } = useRolesQuery();