소스 검색

表格添加权限

zhaoke 2 년 전
부모
커밋
07819e9ce9
2개의 변경된 파일70개의 추가작업 그리고 17개의 파일을 삭제
  1. 62 3
      src/components/Table/index.vue
  2. 8 14
      src/views/BasicsData/views/airlineCompany/airlineCompanyInfo.vue

+ 62 - 3
src/components/Table/index.vue

@@ -12,7 +12,14 @@
         <div v-if="isStatus || isStatuser" class="vStatus">
           <slot name="header" />
         </div>
-        <el-button v-if="isBtn" size="small" @click="handleAdd" plain type="primary">新增</el-button>
+        <template v-if="isBtn">
+          <template v-if="isAuth">
+            <el-button v-if="btnAuthAdd" size="small" @click="handleAdd" plain type="primary">新增</el-button>
+          </template>
+          <template v-else>
+            <el-button size="small" @click="handleAdd" plain type="primary">新增</el-button>
+          </template>
+        </template>
       </div>
       <template v-if="tableData.length">
         <div>
@@ -86,8 +93,18 @@
                       </template>
                     </template>
                     <!-- <el-button class="hrefBtn" type="text" @click="handleHerf(scope.row)" size="small">跳转</el-button> -->
-                    <el-button type="text" @click="handleEdit(scope.row)" size="small" class="rmScs">编辑</el-button>
-                    <el-button class="rmSc" type="text" @click="handleRemove(scope.row)" size="small">删除</el-button>
+                    <template v-if="isAuth">
+                      <el-button v-if="btnAuthEdit" type="text" @click="handleEdit(scope.row)" size="small" class="rmScs">编辑</el-button>
+                    </template>
+                    <template v-else>
+                      <el-button type="text" @click="handleEdit(scope.row)" size="small" class="rmScs">编辑</el-button>
+                    </template>
+                    <template v-if="isAuth">
+                      <el-button v-if="btnAuthDel" class="rmSc" type="text" @click="handleRemove(scope.row)" size="small">删除</el-button>
+                    </template>
+                    <template v-else>
+                      <el-button class="rmSc" type="text" @click="handleRemove(scope.row)" size="small">删除</el-button>
+                    </template>
                     <el-button class="rmScs" v-if="withColumnSet" type="text" size="small" @click="handleColumnSet(scope.row)">列设置</el-button>
                     <el-button class="rmScs" v-if="withItemSet" type="text" size="small" @click="handleItemSet(scope.row)">数据项</el-button>
                     <el-button class="rmScser" v-if="withlodSet" type="text" size="small" @click="handlelodSet(scope.row)">航站设置</el-button>
@@ -296,6 +313,26 @@ export default {
       type: Boolean,
       default: false,
     },
+    //新增按钮权限
+    authAdd: {
+      type: String,
+      default: "",
+    },
+    //编辑按钮权限
+    authEdit: {
+      type: String,
+      default: "",
+    },
+    //删除按钮权限
+    authDel: {
+      type: String,
+      default: "",
+    },
+    //是否启用权限按钮
+    isAuth: {
+      type: Boolean,
+      default: false,
+    },
   },
   components: { Dialog, NoData },
   data() {
@@ -325,6 +362,7 @@ export default {
       tableOptions: {}, //弹框-下来数据缓存
       tableArrs: [], //重组table-表头下拉
       proAll: false, //重组时-所有请求是否都完成
+      roles: JSON.parse(sessionStorage.getItem("userAuthList")) ?? [],
     };
   },
   computed: {
@@ -366,6 +404,27 @@ export default {
         return flag;
       });
     },
+    btnAuthAdd() {
+      if (this.roles.includes(this.authAdd)) {
+        return true;
+      } else {
+        return false;
+      }
+    },
+    btnAuthEdit() {
+      if (this.roles.includes(this.authEdit)) {
+        return true;
+      } else {
+        return false;
+      }
+    },
+    btnAuthDel() {
+      if (this.roles.includes(this.authDel)) {
+        return true;
+      } else {
+        return false;
+      }
+    },
   },
   watch: {
     dataContent: {

+ 8 - 14
src/views/BasicsData/views/airlineCompany/airlineCompanyInfo.vue

@@ -16,6 +16,10 @@
         :minHeight="70"
         width="800px"
         :isStatuser="true"
+        :isAuth="true"
+        authAdd="ss_aim_add"
+        authEdit="ss_aim_cardEdit"
+        authDel="ss_aim_cardDelete"
         tableHeight="685"
       >
         <template v-slot:header>
@@ -34,11 +38,7 @@ import Dialog from "@/layout/components/Dialog/index.vue";
 import { findarrays } from "@/utils/validate";
 import { GeneralDataReception, Query } from "@/api/dataIntegration";
 import DataTable from "@/components/Table";
-import {
-  AirlinesInquiry,
-  DelAirlines,
-  AddAirlines,
-} from "@/api/SystemSettings";
+import { AirlinesInquiry, DelAirlines, AddAirlines } from "@/api/SystemSettings";
 export default {
   name: "AirportInfo",
   components: { Search, Dialog, DataTable },
@@ -81,12 +81,8 @@ export default {
       rules: {
         //新增机场信息表单验证
         Name: [{ required: true, message: "请输入航司简称", trigger: "blur" }],
-        FullName: [
-          { required: true, message: "请输入航司全称", trigger: "blur" },
-        ],
-        Code2: [
-          { required: true, message: "请输入航司二字码", trigger: "blur" },
-        ],
+        FullName: [{ required: true, message: "请输入航司全称", trigger: "blur" }],
+        Code2: [{ required: true, message: "请输入航司二字码", trigger: "blur" }],
       },
     };
   },
@@ -98,9 +94,7 @@ export default {
       if (this.searchInfo) {
         return this.arr.filter((data) => {
           return Object.keys(data).some((key) => {
-            return (
-              String(data[key]).toLowerCase().indexOf(this.searchInfo) > -1
-            );
+            return String(data[key]).toLowerCase().indexOf(this.searchInfo) > -1;
           });
         });
       }