Jelajahi Sumber

feat: 消息管理模块添加功能权限

qindao 1 tahun lalu
induk
melakukan
4ec5759ee7

+ 2 - 2
src/components/Table/src/components/TableActionIcons.vue

@@ -4,10 +4,10 @@
       <div v-for="item in props.actionIcons" :key="item.label" @click="handleClick(item)"
         :class="[item.disabled ? 'table__action--disabled' : 'table__action--enabled']">
         <el-tooltip :content="item.label" effect="light">
-          <el-icon v-if="props.style === 'icon'" :color="props.color" :size="props.size">
+          <el-icon v-if="props.style === 'icon'" :color="props.color" :size="props.size" >
             <component :is="item.icon" />
           </el-icon>
-          <img v-if="props.style === 'img'" :src="item.icon" :style="{ width: `${props.size}px` }" />
+          <img v-if="props.style === 'img' && item.ifShow !== false" :src="item.icon" :style="{ width: `${props.size}px` }" />
         </el-tooltip>
       </div>
     </el-space>

+ 14 - 19
src/views/cameras/nvrlist/NvrList.vue

@@ -115,30 +115,25 @@ 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: actions
+      actionIcons: [
+        {
+          label: '修改',
+          icon: editIcon,
+          onClick: handleEdit.bind(null, record.row),
+          ifShow: userStore.checkPermission(PERM_DEVICE.NVR_EDIT)
+        },
+        {
+          label: '删除',
+          icon: deleteIcon,
+          onClick: handleDelete.bind(null, record.row),
+          ifShow: userStore.checkPermission(PERM_DEVICE.NVR_DELETE)
+        }
+      ]
     });
   },
 });

+ 6 - 3
src/views/message/alarmMessages/alarmMessages.vue

@@ -6,6 +6,7 @@
       type="primary"
       @click="createAlarm"
       style="margin-top: 24px; margin-bottom: 16px; width: 138px"
+      v-permission="{ action: [PERM_NOTICE.ALARM_ADD] }"
     >
       <img src="./img/create.png" style="margin-top: -1px; margin-right: 5px" /><span
         >新建报警配置</span
@@ -45,6 +46,7 @@
           <el-switch
             v-model="scope.row.status"
             @click="updateStatus(scope.row.id, scope.row.status)"
+            v-permission="{ action: [PERM_NOTICE.ALARM_ENABLE] }"
           />
         </template>
       </el-table-column>
@@ -55,13 +57,13 @@
         <template #default="scope">
           <div class="operation">
             <el-tooltip class="box-item" effect="light" content="查看" placement="bottom">
-              <img src="./img/view.png" @click="handleView(scope.row.id)" />
+              <img src="./img/view.png" @click="handleView(scope.row.id)"  />
             </el-tooltip>
             <el-tooltip class="box-item" effect="light" content="编辑" placement="bottom">
-              <img src="./img/edit.png" @click="handleEdit(scope.row.id)" />
+              <img src="./img/edit.png" @click="handleEdit(scope.row.id)" v-permission="{ action: [PERM_NOTICE.ALARM_EDIT] }"/>
             </el-tooltip>
             <el-tooltip class="box-item" effect="light" content="删除" placement="bottom">
-              <img src="./img/delete.png" @click="handleDelete(scope.row.id)" />
+              <img src="./img/delete.png" @click="handleDelete(scope.row.id)" v-permission="{ action: [PERM_NOTICE.ALARM_DELETE] }" />
             </el-tooltip>
           </div>
         </template>
@@ -111,6 +113,7 @@
   import { useAlarmDataList } from './hook/index';
   import { storeToRefs } from 'pinia';
   import { useRouter } from 'vue-router';
+  import { PERM_NOTICE } from '@/types/permission/constants';
 
   const router = useRouter();
   const useAlarmDataListFun = useAlarmDataList();

+ 10 - 1
src/views/message/persongroup/UserGroup.vue

@@ -26,7 +26,7 @@
         @page-size-change="handlePageSizeChange"
       >
         <template #tableTitle>
-          <el-button type="primary" @click="handleCreateGroup">
+          <el-button type="primary" @click="handleCreateGroup"  v-permission="{ action: [PERM_NOTICE.PERSONNEL_ADD] }">
             <img src="./img/create.png" style="margin-right: 8px" />新建人员分组
           </el-button>
         </template>
@@ -91,6 +91,10 @@
   import deleteIcon from '@/assets/images/reportmessage/delete.png';
   import { ElMessage, ElMessageBox } from 'element-plus';
   import { messageTypeName } from '@/views/message/constant';
+  import { PERM_NOTICE } from '@/types/permission/constants';
+  import { useUserStore } from '@/store/modules/user';
+
+  const userStore = useUserStore();
   const drawer = ref(false);
   const drawerTitle = ref<string>('新建人员分组');
   const handleCreateGroup = () => {
@@ -104,6 +108,7 @@
   const errorVisible = ref<boolean>(false);
   const showAll = ref<boolean>(false);
   const refGroup = ref<Array<{ type: number; statisticType: number; messageType: number }>>();
+ 
   const actionColumn: BasicColumn = reactive({
     width: 224,
     title: '操作',
@@ -126,11 +131,14 @@
             label: '编辑',
             icon: editIcon,
             onClick: handleEdit.bind(null, record.row),
+            ifShow: userStore.checkPermission(PERM_NOTICE.PERSONNEL_ADD)
+
           },
           {
             label: '删除',
             icon: deleteIcon,
             onClick: handleDelete.bind(null, record.row),
+            ifShow: userStore.checkPermission(PERM_NOTICE.PERSONNEL_DELETE)
           },
         ],
       });
@@ -190,6 +198,7 @@
   onMounted(() => {
     getUserGroup();
   });
+
 </script>
 
 <style lang="scss" scoped>

+ 7 - 1
src/views/message/reportmessage/components/Form.vue

@@ -16,7 +16,7 @@
       ref="tableRef"
     >
       <template #tableTitle>
-        <el-button type="primary" :icon="Plus" @click="CreateReport(type)">新建报表配置</el-button>
+        <el-button type="primary" :icon="Plus" @click="CreateReport(type)" v-permission="{ action: [PERM_NOTICE.REPORT_ADD] }" >新建报表配置</el-button>
       </template>
       <template #empty>
         <div class="empty-content flex flex-col items-center">
@@ -51,7 +51,10 @@
   import { storeToRefs } from 'pinia';
   import useFormList from '../store/useFormList';
   import { deleteReportConfig } from '@/api/message/report-message';
+  import { PERM_NOTICE } from '@/types/permission/constants';
+  import { useUserStore } from '@/store/modules/user';
 
+  const userStore = useUserStore();
   const formStore = useFormList();
   const { getForm } = formStore;
   const { type, formList } = storeToRefs(formStore);
@@ -73,6 +76,7 @@
             label: '推送记录',
             icon: logIcon,
             onClick: handleLog.bind(null, record.row),
+           
           },
           {
             label: '查看',
@@ -83,11 +87,13 @@
             label: '编辑',
             icon: editIcon,
             onClick: handleEdit.bind(null, record.row),
+            ifShow: userStore.checkPermission(PERM_NOTICE.REPORT_EDIT) 
           },
           {
             label: '删除',
             icon: deleteIcon,
             onClick: handleDelete.bind(null, record.row),
+            ifShow: userStore.checkPermission(PERM_NOTICE.REPORT_DELETE) 
           },
         ],
       });

+ 7 - 1
src/views/message/reportmessage/overviewColumns.ts

@@ -4,10 +4,15 @@ import { ElSwitch } from 'element-plus';
 import { pushChannelName, recipientTypeName, statusName, statisticTypeName } from '../constant';
 import { storeToRefs } from 'pinia';
 import useFormList from './store/useFormList';
+import { updateStatus, updateStatusParams } from '@/api/message/report-message';
+import { PERM_NOTICE } from '@/types/permission/constants';
+import { useUserStore } from '@/store/modules/user';
+
+const userStore = useUserStore();
 const formStore = useFormList();
 const { type } = storeToRefs(formStore);
 const { getForm } = formStore;
-import { updateStatus, updateStatusParams } from '@/api/message/report-message';
+
 export const reportDataCol: BasicColumn[] = [
   {
     label: '报表周期',
@@ -46,6 +51,7 @@ export const reportDataCol: BasicColumn[] = [
   {
     label: '是否启用',
     prop: 'status',
+    ifShow: userStore.checkPermission(PERM_NOTICE.REPORT_ENABLE), 
     render(record) {
       return h(
         ElSwitch,

+ 8 - 5
src/views/system/user/user.vue

@@ -9,7 +9,7 @@
     <el-card>
       <template #header>
         <el-space align="center">
-          <el-button @click="openAddAdminDrawer" v-if="!isSysTenant && isCanAddTenant">
+          <el-button @click="openAddAdminDrawer" v-if="!isSysTenant && isCanAddTenant && hasAddPermission()">
             <template #icon>
               <el-icon>
                 <Plus />
@@ -17,7 +17,7 @@
             </template>
             添加租户管理员
           </el-button>
-          <el-button type="primary" @click="openAddSingleDrawer">
+          <el-button type="primary" @click="openAddSingleDrawer" v-permission="{ action: [PERM_USER.ACCOUNT_ADD] }">
             <template #icon>
               <el-icon>
                 <Plus />
@@ -95,13 +95,13 @@
           <template #default="scope">
             <el-space v-if="scope.row.roleType !== RoleTypeEnum.SUPER_ADMIN">
               <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.ACCOUNT_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.ACCOUNT_DELETE] }">
                   <div><img :src="deleteIcon" class="el-tooltip__trigger"></div>
                 </div>
-                <div class="el-space__item" v-if="visibleRestPassBtn(scope.row.roleType)" @click="handleResetCode(scope.row)">
+                <div class="el-space__item" v-if="visibleRestPassBtn(scope.row.roleType) && hasResetPasswordPermission()" @click="handleResetCode(scope.row)" >
                   <div class="tooltip__password">重置密码</div>
                 </div>
               </div>
@@ -149,6 +149,7 @@
   import editIcon from '@/assets/images/reportmessage/edit.png';
   import deleteIcon from '@/assets/images/reportmessage/delete.png';
   import { SYS_TENANT_ID } from '@/utils/useTargetTenantIdSetting';
+  import { PERM_USER } from '@/types/permission/constants';
 
   const userStore = useUserStore();
   const { getUserInfo } = storeToRefs(userStore);
@@ -170,6 +171,8 @@
     loadPageData();
   }
 
+  const hasResetPasswordPermission = () => userStore.checkPermission(PERM_USER.ACCOUNT_RESET_PASSWORD);
+  const hasAddPermission = () => userStore.checkPermission(PERM_USER.ACCOUNT_ADD);
   // 当前用户类型
   const currrentRoleType = getUserInfo.value.roleType;
   const currrentTenantId = getUserInfo.value.tenantId;