xiaodai2022 1 rok pred
rodič
commit
f972eec313

+ 34 - 32
src/store/getters.js

@@ -1,35 +1,37 @@
 const getters = {
-  sidebar: state => state.app.sidebar,
-  size: state => state.app.size,
-  searchSize: state => state.app.searchSize,
-  tablebtnSize: state => state.app.tablebtnSize,
-  device: state => state.app.device,
-  visitedViews: state => state.tagsView.visitedViews,
-  cachedViews: state => state.tagsView.cachedViews,
-  token: state => state.user.token,
-  avatar: state => state.user.avatar,
-  name: state => state.user.name,
-  introduction: state => state.user.introduction,
-  roles: state => state.user.roles,
-  errorLogs: state => state.errorLog.logs,
-  btnList: state => state.user.btnList,
-  navList: state => state.user.navList,
-  mainList: state => state.user.mainList,
-  business_company: state => state.user.business_company,
-  business_companyNo: state => state.currentCompany,
-  isSupertube: state => state.user.isSupertube,
-  userInfo: state => state.user.userInfo,
-  roleProcess: state => state.user.roleProcess,
+  sidebar: (state) => state.app.sidebar,
+  size: (state) => state.app.size,
+  searchSize: (state) => state.app.searchSize,
+  tablebtnSize: (state) => state.app.tablebtnSize,
+  device: (state) => state.app.device,
+  visitedViews: (state) => state.tagsView.visitedViews,
+  cachedViews: (state) => state.tagsView.cachedViews,
+  token: (state) => state.user.token,
+  avatar: (state) => state.user.avatar,
+  name: (state) => state.user.name,
+  introduction: (state) => state.user.introduction,
+  roles: (state) => state.user.roles,
+  errorLogs: (state) => state.errorLog.logs,
+  btnList: (state) => state.user.btnList,
+  navList: (state) => state.user.navList,
+  mainList: (state) => state.user.mainList,
+  business_company: (state) => state.user.business_company,
+  business_companyNo: (state) => state.currentCompany,
+  isSupertube: (state) => state.user.isSupertube,
+  userInfo: (state) => state.user.userInfo,
+  roleProcess: (state) => state.user.roleProcess,
   // 当前用户等级
-  currentLevel: state => state.user.currentLevel,
+  currentLevel: (state) => state.user.currentLevel,
   // 原始用户等级
-  originLevel: state => state.user.originLevel,
-  currentCompany: state => state.user.currentCompany,
-  companyList: state => state.user.companyList,
-  private_field: state => {
-    if (!state.user.private_field) return []
-    if (typeof state.user.private_field === 'string') return JSON.parse(state.user.private_field)
-    return state.user.private_field
-  }
-}
-export default getters
+  originLevel: (state) => state.user.originLevel,
+  currentCompany: (state) => state.user.currentCompany,
+  companyList: (state) => state.user.companyList,
+  is_super_admin_ids: (state) => state.user.is_super_admin_ids,
+  private_field: (state) => {
+    if (!state.user.private_field) return [];
+    if (typeof state.user.private_field === "string")
+      return JSON.parse(state.user.private_field);
+    return state.user.private_field;
+  },
+};
+export default getters;

+ 177 - 137
src/store/modules/user.js

@@ -8,7 +8,7 @@ import {
   roleProcessInfo,
   requsetSupertubeCompany,
   requsetUserBindingCompany,
-  reuqsetRoleInfo
+  reuqsetRoleInfo,
 } from "@/apis/user";
 
 import {
@@ -42,21 +42,20 @@ import {
   removeUserInfo as _removeUserInfo,
   getCompanyType as _getCompanyType,
   setCompanyType as _setCompanyType,
-  removeCompanyType as _removeCompanyType
-} from '@/utils/auth'
-
+  removeCompanyType as _removeCompanyType,
+} from "@/utils/auth";
 
 import { MessageBox } from "element-ui";
 import { convertCompanylist } from "@/utils";
 
 export const userStoreActions = {
-  reloadMenu: 'user/reloadMenulist',
-  loginByToken: 'user/loginByToken',
-  setCompanyList: 'user/setCompanylist',
-  setCurrentLevel: 'user/setCurrentLevel',
-  setCurrentCompany: 'user/setCurrentCompany'
-}
-
+  reloadMenu: "user/reloadMenulist",
+  loginByToken: "user/loginByToken",
+  setCompanyList: "user/setCompanylist",
+  setCurrentLevel: "user/setCurrentLevel",
+  setCurrentCompany: "user/setCurrentCompany",
+};
+const ids = ["36", "37", "44", "109"];
 const state = {
   token: getToken(),
   name: "",
@@ -65,23 +64,24 @@ const state = {
   roles: ["admin"],
   btnList: getBtn(),
   navList: getMenu(),
-  role_level:get_role_level() || "1",
+  role_level: get_role_level() || "1",
   business_company: get_business_company() || "",
   business_companyNo: get_business_companyNo() || "",
   private_field: get_private_field() || [],
   roleProcess: get_action_data() || [],
-  currentCompany: getUserCompany() ? getUserCompany().code : '',
+  currentCompany: getUserCompany() ? getUserCompany().code : "",
   userInfo: _getUserInfo(),
   isSupertube: false,
-  companylist:[],
+  is_super_admin_ids: false,
+  companylist: [],
   originLevel: "0",
-  currentLevel: "0"
+  currentLevel: "0",
 };
 
 const companyTypes = {
-  'business': 'business',
-  'supplier': 'supplier'
-}
+  business: "business",
+  supplier: "supplier",
+};
 
 const mutations = {
   SET_TOKEN: (state, token) => {
@@ -102,6 +102,10 @@ const mutations = {
   SET_AVATAR: (state, avatar) => {
     state.avatar = avatar;
   },
+  SET_IS_SUPER_ADMIN_IDS: (state, is) => {
+    state.is_super_admin_ids = is;
+  },
+
   SET_ROLES: (state, roles) => {
     state.roles = roles;
   },
@@ -120,8 +124,8 @@ const mutations = {
     setBtn(val);
   },
 
-  setSupplier(state,val){
-    state.isSupplier = val
+  setSupplier(state, val) {
+    state.isSupplier = val;
   },
   business_company(state, val) {
     state.business_company = val;
@@ -140,38 +144,40 @@ const mutations = {
     set_private_field(val);
   },
 
-  setCurrentLevel(state, val){
-    state.currentLevel = val
+  setCurrentLevel(state, val) {
+    state.currentLevel = val;
   },
 
-  setOriginLevel(state, val){
-    state.originLevel = val
+  setOriginLevel(state, val) {
+    state.originLevel = val;
   },
 
-  setUserInfo(state, info){
-    state.userInfo = info
-    _setUserInfo(info)
+  setUserInfo(state, info) {
+    state.userInfo = info;
+    _setUserInfo(info);
   },
 
-  setCurrentCompany(state, code){
+  setCurrentCompany(state, code) {
     //获取当前公司详细信息
-    const company = state.companylist.find(({code: _code}) => _code === code)
-    setUserCompany(company)
+    const company = state.companylist.find(({ code: _code }) => _code === code);
+    setUserCompany(company);
     state.currentCompany = code;
   },
 
-  setCompanyType(state, code){
-    const isBusiness = code.indexOf('GS') >= 0
-    state.companyType = isBusiness ? companyTypes.business : companyTypes.supplier
+  setCompanyType(state, code) {
+    const isBusiness = code.indexOf("GS") >= 0;
+    state.companyType = isBusiness
+      ? companyTypes.business
+      : companyTypes.supplier;
   },
 
-  setCompanylist(state,val){
-    state.companylist = val
+  setCompanylist(state, val) {
+    state.companylist = val;
   },
   setSupertube(state, val) {
     state.isSupertube = val;
-  }
-}
+  },
+};
 
 const actions = {
   // user login
@@ -180,9 +186,9 @@ const actions = {
     return new Promise((resolve, reject) => {
       login({ username: username.trim(), password: password })
         .then((response) => {
-          const {code, data } = response;
+          const { code, data } = response;
           if (code === 0) {
-            const {token,nickname}=data
+            const { token, nickname } = data;
             commit("SET_TOKEN", token);
             commit("SET_NAME", nickname);
             setToken(token);
@@ -196,15 +202,22 @@ const actions = {
   },
 
   //公司角色异常
-  disabledCompany({commit, that}){
+  disabledCompany({ commit, that }) {
     commit("navListFn", []);
     commit("btnListFn", []);
     initRouter([], that);
-    const company = getUserCompany()
-    MessageBox
-      .alert(`公司 ${company.name} 角色异常或该公司禁用,请检查账号或者角色设置`, '公司角色异常', {type: 'warning', confirmButtonText:'前往首页'})
-      .then(() => {router.push("/reload?redirect=welcome/dashboard")})
-      .catch(() => {router.push("/reload?redirect=welcome/dashboard")})
+    const company = getUserCompany();
+    MessageBox.alert(
+      `公司 ${company.name} 角色异常或该公司禁用,请检查账号或者角色设置`,
+      "公司角色异常",
+      { type: "warning", confirmButtonText: "前往首页" }
+    )
+      .then(() => {
+        router.push("/reload?redirect=welcome/dashboard");
+      })
+      .catch(() => {
+        router.push("/reload?redirect=welcome/dashboard");
+      });
   },
 
   dingUserInfor({ commit }, code) {
@@ -226,49 +239,48 @@ const actions = {
     });
   },
 
-  async loginByToken({commit, dispatch}, token) {
-    setToken(token)
-    await commit('SET_TOKEN')
-    await dispatch('getMenuList')
+  async loginByToken({ commit, dispatch }, token) {
+    setToken(token);
+    await commit("SET_TOKEN");
+    await dispatch("getMenuList");
   },
 
-
   // 切换公司后重新请求
-  async reloadMenulist({commit, dispatch ,that, state}, level){
-    return new Promise(async resolve => {
-      const company = getUserCompany()
-       dispatch('getRoleInfo', company)
-       //获取菜单
-       const { mcode, mdata, message: mmsg } = await getRoleMenuList(level);
-
-       //账号禁用
-       if(mcode === 10001){
+  async reloadMenulist({ commit, dispatch, that, state }, level) {
+    return new Promise(async (resolve) => {
+      const company = getUserCompany();
+      dispatch("getRoleInfo", company);
+      //获取菜单
+      const { mcode, mdata, message: mmsg } = await getRoleMenuList(level);
+
+      //账号禁用
+      if (mcode === 10001) {
         commit("navListFn", []);
         commit("btnListFn", []);
         initRouter([], that);
-        resolve('disabled')
-        return
-       }
-
-       if (mcode >= 100 && mcode <= 104) {
-         resolve("noToken");
-       } else if (mcode !== 0) {
-         resolve({ code: mcode, data: {}, massage: mmsg });
-       } else {
-         const { arrag, isok, btnList } = mdata;
-         // 生成页面权限
-         commit("navListFn", arrag);
-         // 生成按钮权限
-         commit("btnListFn", btnList);
-         // 生成路由
-         initRouter(arrag, that);
-         resolve(isok ? "success-dataV" : "success");
-       }
-    })
+        resolve("disabled");
+        return;
+      }
+
+      if (mcode >= 100 && mcode <= 104) {
+        resolve("noToken");
+      } else if (mcode !== 0) {
+        resolve({ code: mcode, data: {}, massage: mmsg });
+      } else {
+        const { arrag, isok, btnList } = mdata;
+        // 生成页面权限
+        commit("navListFn", arrag);
+        // 生成按钮权限
+        commit("btnListFn", btnList);
+        // 生成路由
+        initRouter(arrag, that);
+        resolve(isok ? "success-dataV" : "success");
+      }
+    });
   },
 
-  async getRoleInfo({commit, that, dispatch}, _current_company_){
-    return new Promise(async resolve => {
+  async getRoleInfo({ commit, that, dispatch }, _current_company_) {
+    return new Promise(async (resolve) => {
       //查找默认的业务公司 设置到全局的currentCompany
       const { roleid } = _current_company_;
 
@@ -279,20 +291,27 @@ const actions = {
       }
       if (pcode >= 100 && pcode <= 104) {
         resolve("noToken");
-        return
+        return;
       }
       //根据角色获取角色详情 获取关键字字段
-      const {code: rcode, data: rdata, message: rmsg} = await reuqsetRoleInfo({ roleid: roleid })
-
-      if(rcode === 0){
-        commit("private_field", rdata.private_field ? rdata.private_field.split(',') : []);
+      const {
+        code: rcode,
+        data: rdata,
+        message: rmsg,
+      } = await reuqsetRoleInfo({ roleid: roleid });
+
+      if (rcode === 0) {
+        commit(
+          "private_field",
+          rdata.private_field ? rdata.private_field.split(",") : []
+        );
       }
 
       if (rcode >= 100 && rcode <= 104) {
         resolve("noToken");
-        return
+        return;
       }
-    })
+    });
   },
 
   async getMenuList({ commit, that, dispatch }) {
@@ -304,62 +323,73 @@ const actions = {
         if (ucode >= 100 && ucode <= 104) {
           resolve("noToken");
         } else if (ucode !== 0) {
-          resolve({ code: ucode, data: udata, massage: umsg })
+          resolve({ code: ucode, data: udata, massage: umsg });
         } else {
-          const { level } = udata;
+          const { level, id } = udata;
           //是否超管
-          const isSupertube = level === '1'
+          const isSupertube = level === "1";
           //是否供应商
-          const isSupplier = level === '3'
+          const isSupplier = level === "3";
           //保存用户信息
-          commit('setUserInfo', udata)
+          commit("setUserInfo", udata);
+          const isOkIndex = ids.findIndex((s) => String(s) === String(id));
+          commit("SET_IS_SUPER_ADMIN_IDS", isOkIndex !== -1);
           //保存是否超管
-          commit('setSupplier', isSupplier)
+          commit("setSupplier", isSupplier);
           //保存是否超管用户
           commit("setSupertube", isSupertube);
           //设置原始level和当前level
-          commit('setOriginLevel', level)
-          commit('setCurrentLevel', level)
+          commit("setOriginLevel", level);
+          commit("setCurrentLevel", level);
           //获取公司列表(区分超管和普通账户api)
-          const api = isSupertube ? requsetSupertubeCompany : requsetUserBindingCompany
+          const api = isSupertube
+            ? requsetSupertubeCompany
+            : requsetUserBindingCompany;
           //获取缓存里的业务公司 => 公司名称搜索 => 存在设置为默认公司
           const { data: companyData, code: companyCode } = await api({
-            ...(!isSupertube ? ({size: 10000}) : {type: '1'}),
-            ...({token: getToken()}),
-          })
-           //保存公司列表 普通用户和超管使用两个列表需要转换
-           let _companylist = []
-           if(companyCode === 0) {
-            _companylist = isSupertube ? companyData.list : convertCompanylist(companyData.list);
+            ...(!isSupertube ? { size: 10000 } : { type: "1" }),
+            ...{ token: getToken() },
+          });
+          //保存公司列表 普通用户和超管使用两个列表需要转换
+          let _companylist = [];
+          if (companyCode === 0) {
+            _companylist = isSupertube
+              ? companyData.list
+              : convertCompanylist(companyData.list);
             //超管 + 业务公司 需要将 relation_code 设置为 code
             // if(isSupertube) _companylist = _companylist.map(item => ({...item, code: item.relation_code}))
-            commit('setCompanylist', _companylist)
-           }
-           if(companyCode >= 100 && companyCode <= 104){
-             resolve("noToken")
-             return
-           }
-           
+            commit("setCompanylist", _companylist);
+          }
+          if (companyCode >= 100 && companyCode <= 104) {
+            resolve("noToken");
+            return;
+          }
+
           //非超管用户获取保存 流程权限 & 关键字字段 & 设置默认业务公司
-          let defaultCompany = ''
-          if(!isSupertube){
+          let defaultCompany = "";
+          if (!isSupertube) {
             //查找默认的业务公司 设置到全局的currentCompany
-            defaultCompany =  _companylist.find(({is_main}) => is_main === '1');
-            const result = dispatch('getRoleInfo', defaultCompany)
-            if(result === 'noToken') {
-              resolve('noToken')
-              return
+            defaultCompany = _companylist.find(
+              ({ is_main }) => is_main === "1"
+            );
+            const result = dispatch("getRoleInfo", defaultCompany);
+            if (result === "noToken") {
+              resolve("noToken");
+              return;
             }
           }
 
           //保存默认公司
-          commit('setCurrentCompany', defaultCompany ? defaultCompany.code : '')
+          commit(
+            "setCurrentCompany",
+            defaultCompany ? defaultCompany.code : ""
+          );
           const { mcode, mdata, mmsg } = await getRoleMenuList();
 
           //拦截账号异常: 禁用
-          if(mcode === 10001) {
-            dispatch('disabledCompany');
-            return
+          if (mcode === 10001) {
+            dispatch("disabledCompany");
+            return;
           }
 
           if (mcode >= 100 && mcode <= 104) {
@@ -388,7 +418,7 @@ const actions = {
       commit("SET_ROLES", []);
       commit("SET_MENU", "");
       commit("SET_HAS", "");
-      _removeUserInfo()
+      _removeUserInfo();
       removeBtn();
       removeMenu();
       removeToken();
@@ -400,7 +430,7 @@ const actions = {
       commit("private_field", []);
       remove_action_data();
       commit("action_data", []);
-      removeUserCompany()
+      removeUserCompany();
       commit("action_data", []);
       // removeMainList()
       // reset visited views and cached views
@@ -422,7 +452,7 @@ const actions = {
 };
 async function getUserInfo() {
   const { code, data, meaasge } = await usergetinfo({
-    token:getToken()
+    token: getToken(),
   });
 
   return {
@@ -464,7 +494,7 @@ async function getRoleProcess(roleid) {
 //     })
 //   }
 
-//   dfs([ 
+//   dfs([
 //   {
 //     path: "/person",
 //     component: () => import("@/layout/index"),
@@ -523,16 +553,16 @@ async function getRoleProcess(roleid) {
 // 区分供应商和业务公司获取不同的菜单列表
 async function getRoleMenuList(level = "") {
   const { code, data, message } = await menuList({
-    ...(level && level !== '1' ? { level } : {})
-  })
+    ...(level && level !== "1" ? { level } : {}),
+  });
 
   //menu接受账户异常:禁用 并返回
-  if(message === '账户已禁用' || message === '没有该公司的默认角色'){
+  if (message === "账户已禁用" || message === "没有该公司的默认角色") {
     return {
       mdata: {},
-      mmsg: '账号被禁用',
-      mcode: 10001
-    }
+      mmsg: "账号被禁用",
+      mcode: 10001,
+    };
   }
 
   let arrag = [];
@@ -541,7 +571,17 @@ async function getRoleMenuList(level = "") {
   let isok = false;
 
   if (code === 0) {
-    list = data ?? [];
+    // const { id } = _getUserInfo();
+    // const isOkIndex = ids.findIndex((s) => String(s) === String(id));
+    const idok = state.is_super_admin_ids;
+    console.log(idok);
+    if (!idok) {
+      list = data.filter(function (item) {
+        return item.menu_route !== "system";
+      });
+    } else {
+      list = data ?? [];
+    }
     list = list.filter((item) => item.child && item.child.length > 0);
     list.forEach((v1) => {
       const { menu_route, child } = v1;
@@ -581,7 +621,7 @@ async function getRoleMenuList(level = "") {
 
   // const isHas = isHasRoute(arrag)
   // if(!isHas) router.push('/welcome/dashboard')
-  
+
   return {
     mcode: code,
     mdata: {
@@ -629,9 +669,9 @@ function initRouter(arr) {
           meta: { title: "修改密码", noCache: true, breadcrumb: true },
         },
         {
-          path:'/reload',
-          component:() => import('@/views/reload/index')
-        }
+          path: "/reload",
+          component: () => import("@/views/reload/index"),
+        },
       ],
     },
     //欢迎页
@@ -674,7 +714,7 @@ function initRouter(arr) {
   IndexRoute.push({
     path: "*",
     redirect: "/welcome/dashboard",
-  })
+  });
 
   window.vm.$router.addRoutes(IndexRoute);
 }

+ 264 - 267
src/views/supplierInterest/supplierRole/addEdit.vue

@@ -36,11 +36,7 @@
           </el-col>
 
           <el-col :span="12">
-            <el-form-item
-              label="关键字段权限"
-              prop="private_field"
-              label-width="110px"
-            >
+            <el-form-item label="关键字段权限" prop="private_field" label-width="110px">
               <el-checkbox-group
                 v-model="ruleForm.private_field"
                 :disabled="isDetail"
@@ -55,7 +51,11 @@
 
           <el-col :span="8">
             <el-form-item label="是否允许查看价格" label-width="130px">
-              <el-select v-model="ruleForm.is_allow_see_price" :disabled="isDetail" placeholder="是否允许查看价格">
+              <el-select
+                v-model="ruleForm.is_allow_see_price"
+                :disabled="isDetail"
+                placeholder="是否允许查看价格"
+              >
                 <el-option value="1" label="允许" />
                 <el-option value="0" label="不允许" />
               </el-select>
@@ -83,7 +83,8 @@
 
           <div class="quanxian-main">
             <div class="quanxian-title">
-              <span style="color: #ff8888">*</span><span
+              <span style="color: #ff8888">*</span
+              ><span
                 style="
                   font-size: 14px;
                   color: #606266;
@@ -91,7 +92,8 @@
                   padding: 0 12px 0 0;
                   font-weight: 700;
                 "
-              >功能权限</span>
+                >功能权限</span
+              >
             </div>
             <div class="rule-view">
               <div class="rule-list">
@@ -127,9 +129,7 @@
                             <span class="_h2">{{ subItem.menu_name }}</span>
                             <el-radio-group
                               v-if="
-                                subItem &&
-                                  subItem.private &&
-                                  subItem.private.length === 2
+                                subItem && subItem.private && subItem.private.length === 2
                               "
                               v-model="subItem.is_private_change"
                               style="margin: 0 0 0 20px"
@@ -141,7 +141,8 @@
                                 :key="radioN.label + ri"
                                 :disabled="isDetail"
                                 :label="String(radioN.id)"
-                              >{{ radioN.label }}</el-radio-button>
+                                >{{ radioN.label }}</el-radio-button
+                              >
                             </el-radio-group>
                           </div>
                           <div
@@ -154,26 +155,17 @@
                                 :disabled="isDetail"
                                 :indeterminate="indeterminateCheck(subItem)"
                                 @change="
-                                  handleCheckAllChange(
-                                    $event,
-                                    index,
-                                    item,
-                                    subIndex
-                                  )
+                                  handleCheckAllChange($event, index, item, subIndex)
                                 "
-                              >功能全选</el-checkbox>
+                                >功能全选</el-checkbox
+                              >
                             </div>
                             <div class="checkItem">
                               <el-checkbox-group
                                 v-model="subItem.checkList"
                                 :disabled="isDetail"
                                 @change="
-                                  handleCheckedGroupChange(
-                                    $event,
-                                    index,
-                                    item,
-                                    subIndex
-                                  )
+                                  handleCheckedGroupChange($event, index, item, subIndex)
                                 "
                               >
                                 <template v-for="children in subItem.action">
@@ -190,16 +182,14 @@
                                         item
                                       )
                                     "
-                                  >{{ children.action_name }}</el-checkbox>
+                                    >{{ children.action_name }}</el-checkbox
+                                  >
                                 </template>
                               </el-checkbox-group>
                             </div>
                           </div>
                           <div
-                            v-if="
-                              subItem.action_data &&
-                                subItem.action_data.length > 0
-                            "
+                            v-if="subItem.action_data && subItem.action_data.length > 0"
                             class="sfield"
                           >
                             <div class="checkAll">
@@ -208,31 +198,20 @@
                                 :disabled="isDetail"
                                 :indeterminate="indeterminateField(subItem)"
                                 @change="
-                                  handleFieldAllChange(
-                                    $event,
-                                    index,
-                                    item,
-                                    subIndex
-                                  )
+                                  handleFieldAllChange($event, index, item, subIndex)
                                 "
-                              >字段全选</el-checkbox>
+                                >字段全选</el-checkbox
+                              >
                             </div>
                             <div class="checkItem">
                               <el-checkbox-group
                                 v-model="subItem.fieldList"
                                 :disabled="isDetail"
                                 @change="
-                                  handleFieldGroupChange(
-                                    $event,
-                                    index,
-                                    item,
-                                    subIndex
-                                  )
+                                  handleFieldGroupChange($event, index, item, subIndex)
                                 "
                               >
-                                <template
-                                  v-for="children in subItem.action_data"
-                                >
+                                <template v-for="children in subItem.action_data">
                                   <el-checkbox
                                     :key="'FieldItem' + children.id"
                                     :label="String(children.id)"
@@ -246,7 +225,8 @@
                                         item
                                       )
                                     "
-                                  >{{ children.field_name }}</el-checkbox>
+                                    >{{ children.field_name }}</el-checkbox
+                                  >
                                 </template>
                               </el-checkbox-group>
                             </div>
@@ -261,12 +241,8 @@
           </div>
         </el-form>
         <el-col :span="24" style="text-align: right">
-          <el-button
-            v-if="!isDetail"
-            type="primary"
-            :size="'mini'"
-            @click="submitForm"
-          >保 存
+          <el-button v-if="!isDetail" type="primary" :size="'mini'" @click="submitForm"
+            >保 存
           </el-button>
           <el-button :size="'mini'" @click="showModelThis = false">{{
             isDetail ? "关 闭" : "取 消"
@@ -277,48 +253,48 @@
   </el-dialog>
 </template>
 <script>
-import asyncRequest from '@/apis/service/interest/role'
-import roleLevel from '@/assets/js/roleLevel'
-import { isChinese, isEmoticon } from '@/utils/validate'
-import resToken from '@/mixins/resToken'
-import { mapState } from 'vuex'
+import asyncRequest from "@/apis/service/interest/role";
+import roleLevel from "@/assets/js/roleLevel";
+import { isChinese, isEmoticon } from "@/utils/validate";
+import resToken from "@/mixins/resToken";
+import { mapState, mapGetters } from "vuex";
 export default {
-  name: 'Role',
+  name: "Role",
   mixins: [resToken],
-  props: ['showModel', 'id', 'isDetail'],
+  props: ["showModel", "id", "isDetail"],
   data() {
     const validatename = (rule, value, callback) => {
-      if (value === '') {
-        callback(new Error('角色名称不能为空!'))
+      if (value === "") {
+        callback(new Error("角色名称不能为空!"));
       } else {
         if (value.lenght < 2 || value.lenght > 10) {
-          callback(new Error('角色名称规则为2~10位汉字!'))
+          callback(new Error("角色名称规则为2~10位汉字!"));
         } else if (!isChinese(value)) {
-          callback(new Error('角色名称规则为2~10位汉字!'))
+          callback(new Error("角色名称规则为2~10位汉字!"));
         } else if (isEmoticon(value)) {
-          callback(new Error('角色名称规则为2~10位汉字!'))
+          callback(new Error("角色名称规则为2~10位汉字!"));
         } else {
-          callback()
+          callback();
         }
       }
-    }
+    };
     return {
       loading: false,
-      title: '添加角色',
+      title: "添加角色",
       private_data: [], // 私有数据菜单ID
       showModelThis: this.showModel,
       roleLevel: roleLevel,
       ruleForm: {
-        role_name: '',
-        level: '3',
+        role_name: "",
+        level: "3",
         private_field: [],
-        is_allow_see_price: ''
+        is_allow_see_price: "",
       },
       action_data: [], // 字段数据
       action: [], // 功能数据
       // 当前角色
       roleActive: {
-        rules: []
+        rules: [],
       },
       // 角色列表
       roleList: [],
@@ -330,133 +306,141 @@ export default {
       rules: {
         private_field: [
           {
-            type: 'array',
+            type: "array",
             required: true,
-            message: '请选择关键字段权限',
-            trigger: 'change'
-          }
+            message: "请选择关键字段权限",
+            trigger: "change",
+          },
         ],
         role_name: [
           {
             required: true,
             validator: validatename,
-            trigger: 'blur'
-          }
-        ]
+            trigger: "blur",
+          },
+        ],
         // level: [
         //   { required: true, message: '请选择角色等级', trigger: 'change' }
         // ]
-      }
-    }
+      },
+    };
   },
+
   computed: {
+    ...mapGetters(["is_super_admin_ids"]),
     ...mapState({
-      currentCompany: (state) => state.user.currentCompany
+      currentCompany: (state) => state.user.currentCompany,
     }),
     indeterminateCheck() {
       return (item) => {
         // 选中子节点的数量
         const selectItemLength = item.action.filter(
           (filitem) =>
-            item.checkList.findIndex((finditem) => String(finditem) === String(filitem.id)) > -1
-        ).length
+            item.checkList.findIndex(
+              (finditem) => String(finditem) === String(filitem.id)
+            ) > -1
+        ).length;
         // 未选中子节点的数量
         const noSlectItemLength = item.action.filter(
           (filitem) =>
-            item.checkList.findIndex((finditem) => String(finditem) === String(filitem.id)) ==
-            -1
-        ).length
+            item.checkList.findIndex(
+              (finditem) => String(finditem) === String(filitem.id)
+            ) == -1
+        ).length;
         // // 当前节点的index
         // 存在选中子节点且存在未选中子节点为中间态
-        return selectItemLength > 0 && noSlectItemLength > 0
-      }
+        return selectItemLength > 0 && noSlectItemLength > 0;
+      };
     },
     indeterminateField() {
       return (item) => {
         // 选中子节点的数量
         const selectItemLength = item.action_data.filter(
           (filitem) =>
-            item.fieldList.findIndex((finditem) => String(finditem) === String(filitem.id)) > -1
-        ).length
+            item.fieldList.findIndex(
+              (finditem) => String(finditem) === String(filitem.id)
+            ) > -1
+        ).length;
         // 未选中子节点的数量
         const noSlectItemLength = item.action_data.filter(
           (filitem) =>
-            item.fieldList.findIndex((finditem) => String(finditem) === String(filitem.id)) ==
-            -1
-        ).length
+            item.fieldList.findIndex(
+              (finditem) => String(finditem) === String(filitem.id)
+            ) == -1
+        ).length;
         // // 当前节点的index
         // 存在选中子节点且存在未选中子节点为中间态
-        return selectItemLength > 0 && noSlectItemLength > 0
-      }
-    }
+        return selectItemLength > 0 && noSlectItemLength > 0;
+      };
+    },
   },
   watch: {
-    showModel: function(val) {
-      this.showModelThis = val
+    showModel: function (val) {
+      this.showModelThis = val;
       if (val) {
-        this.initForm()
+        this.initForm();
       }
     },
     showModelThis(val) {
       if (!val) {
-        this.$emit('cancel')
+        this.$emit("cancel");
       }
-    }
+    },
   },
   methods: {
     // 全选/全不选
     handleCheckAllChange(checkAll, index, item, subIndex) {
-      this.actionList[index].child[subIndex].checkAll = checkAll
-      this.$set(this.actionList, index, item)
+      this.actionList[index].child[subIndex].checkAll = checkAll;
+      this.$set(this.actionList, index, item);
       this.actionList[index].child[subIndex].action.forEach((element) => {
-        const findindex = this.actionList[index].child[
-          subIndex
-        ].checkList.findIndex((findItem) => String(findItem) === String(element.id))
+        const findindex = this.actionList[index].child[subIndex].checkList.findIndex(
+          (findItem) => String(findItem) === String(element.id)
+        );
         if (checkAll && findindex == -1) {
-          this.actionList[index].child[subIndex].checkList.push(String(element.id))
+          this.actionList[index].child[subIndex].checkList.push(String(element.id));
         } else if (!checkAll && findindex > -1) {
-          this.actionList[index].child[subIndex].checkList.splice(findindex, 1)
+          this.actionList[index].child[subIndex].checkList.splice(findindex, 1);
         }
-      })
+      });
     },
     // 全选/全不选
     handleFieldAllChange(fieldAll, index, item, subIndex) {
-      this.actionList[index].child[subIndex].fieldAll = fieldAll
-      this.$set(this.actionList, index, item)
+      this.actionList[index].child[subIndex].fieldAll = fieldAll;
+      this.$set(this.actionList, index, item);
       this.actionList[index].child[subIndex].action_data.forEach((element) => {
-        const findindex = this.actionList[index].child[
-          subIndex
-        ].fieldList.findIndex((findItem) => String(findItem) === String(element.id))
+        const findindex = this.actionList[index].child[subIndex].fieldList.findIndex(
+          (findItem) => String(findItem) === String(element.id)
+        );
         if (fieldAll && findindex == -1) {
-          this.actionList[index].child[subIndex].fieldList.push(String(element.id))
+          this.actionList[index].child[subIndex].fieldList.push(String(element.id));
         } else if (!fieldAll && findindex > -1) {
-          this.actionList[index].child[subIndex].fieldList.splice(findindex, 1)
+          this.actionList[index].child[subIndex].fieldList.splice(findindex, 1);
         }
-      })
+      });
     },
     // 复选框组内的选中/不选中
     handleCheckedGroupChange(event, index, item, subIndex) {
-      this.actionList[index].child[subIndex].checkAll = this.actionList[
-        index
-      ].child[subIndex].action.every(
+      this.actionList[index].child[subIndex].checkAll = this.actionList[index].child[
+        subIndex
+      ].action.every(
         (evitem) =>
           this.actionList[index].child[subIndex].checkList.findIndex(
             (finditem) => String(finditem) === String(evitem.id)
           ) > -1
-      )
-      this.$set(this.actionList, index, item)
+      );
+      this.$set(this.actionList, index, item);
     },
     // 复选框组内的选中/不选中
     handleFieldGroupChange(event, index, item, subIndex) {
-      this.actionList[index].child[subIndex].fieldAll = this.actionList[
-        index
-      ].child[subIndex].action_data.every(
+      this.actionList[index].child[subIndex].fieldAll = this.actionList[index].child[
+        subIndex
+      ].action_data.every(
         (evitem) =>
           this.actionList[index].child[subIndex].fieldList.findIndex(
             (finditem) => String(finditem) === String(evitem.id)
           ) > -1
-      )
-      this.$set(this.actionList, index, item)
+      );
+      this.$set(this.actionList, index, item);
     },
 
     // 单项复选框选中/不选中
@@ -466,17 +450,17 @@ export default {
       if (checked) {
         // 选中时检查pid的选中状态
         this.actionList[index].child[subIndex].checkList.indexOf(id) == -1 &&
-          this.actionList[index].child[subIndex].checkList.push(id)
+          this.actionList[index].child[subIndex].checkList.push(id);
       } else {
         const find = this.actionList[index].child[subIndex].checkList.findIndex(
           (e) => String(e) == String(id)
-        )
+        );
         if (find > -1) {
-          this.actionList[index].child[subIndex].checkList.splice(find, 1)
+          this.actionList[index].child[subIndex].checkList.splice(find, 1);
         }
-        this.actionList[index].child[subIndex].checkAll = false
+        this.actionList[index].child[subIndex].checkAll = false;
       }
-      this.$set(this.actionList, index, item)
+      this.$set(this.actionList, index, item);
     },
     // 单项复选框选中/不选中
     handleFieldChange(checked, id, index, subIndex, item) {
@@ -484,269 +468,282 @@ export default {
       if (checked) {
         // 选中时检查pid的选中状态
         this.actionList[index].child[subIndex].fieldList.indexOf(id) == -1 &&
-          this.actionList[index].child[subIndex].fieldList.push(id)
+          this.actionList[index].child[subIndex].fieldList.push(id);
       } else {
         const find = this.actionList[index].child[subIndex].fieldList.findIndex(
           (e) => e == id
-        )
+        );
         if (find > -1) {
-          this.actionList[index].child[subIndex].fieldList.splice(find, 1)
+          this.actionList[index].child[subIndex].fieldList.splice(find, 1);
         }
-        this.actionList[index].child[subIndex].fieldAll = false
+        this.actionList[index].child[subIndex].fieldAll = false;
       }
-      this.$set(this.actionList, index, item)
+      this.$set(this.actionList, index, item);
       // console.log(this.actionList[index].child[subIndex]);
     },
 
     async initForm() {
-      this.loading = true
-      if (this.id === 'add') {
-        this.title = '添加角色'
+      this.loading = true;
+      if (this.id === "add") {
+        this.title = "添加角色";
         // this.ruleForm.isAdmin = 0;
-        this.rulesThis = this.rules
-        await this.resetForm()
-        await this.initActionList()
-        this.loading = false
+        this.rulesThis = this.rules;
+        await this.resetForm();
+        await this.initActionList();
+        this.loading = false;
       } else {
         if (this.isDetail) {
-          this.title = '角色'
-          this.rulesThis = {}
+          this.title = "角色";
+          this.rulesThis = {};
         } else {
-          this.title = '修改角色'
-          this.rulesThis = this.rules
+          this.title = "修改角色";
+          this.rulesThis = this.rules;
         }
-        await this.resetForm()
-        await this.initActionList()
-        await this.initData()
-        this.loading = false
+        await this.resetForm();
+        await this.initActionList();
+        await this.initData();
+        this.loading = false;
       }
     },
     async initData() {
-      const res = await asyncRequest.detail({ roleid: this.id })
+      const res = await asyncRequest.detail({ roleid: this.id });
       if (res && res.code === 0 && res.data) {
-        const resD = res.data
+        const resD = res.data;
 
-        resD.private_field = !resD.private_field ? [] : resD.private_field.split(',')
+        resD.private_field = !resD.private_field ? [] : resD.private_field.split(",");
 
-        this.ruleForm = resD
+        this.ruleForm = resD;
 
-        this.ruleForm.level = '3'
+        this.ruleForm.level = "3";
 
         if (resD.action && resD.action.length > 0) {
-          this.action = resD.action
+          this.action = resD.action;
         } else {
-          this.action = []
+          this.action = [];
         }
         if (resD.action_data && resD.action_data.length > 0) {
-          this.action_data = resD.action_data
+          this.action_data = resD.action_data;
         } else {
-          this.action_data = []
+          this.action_data = [];
         }
-        if (resD.private_data === '') {
-          resD.private_data = []
+        if (resD.private_data === "") {
+          resD.private_data = [];
         }
         if (resD.private_data && resD.private_data.length > 0) {
-          this.private_data = resD.private_data
+          this.private_data = resD.private_data;
         } else {
-          this.private_data = []
+          this.private_data = [];
         }
 
-        this.ruleForm.is_allow_see_price = String(resD.is_allow_see_price)
+        this.ruleForm.is_allow_see_price = String(resD.is_allow_see_price);
 
-        const arr = JSON.parse(JSON.stringify(this.actionList))
+        const arr = JSON.parse(JSON.stringify(this.actionList));
         arr.map((x) => {
           if (x.child && x.child.length > 0) {
             x.child.map((y) => {
               if (y.action && y.action.length > 0) {
                 y.action.map((z) => {
-                  const Aindex = this.action.findIndex((a) => String(a) === String(z.id))
+                  const Aindex = this.action.findIndex((a) => String(a) === String(z.id));
                   if (Aindex !== -1) {
-                    y.checkList.push(this.action[Aindex])
+                    y.checkList.push(this.action[Aindex]);
                   }
-                  return z
-                })
+                  return z;
+                });
                 if (y.action.length === y.checkList.length) {
-                  y.checkAll = true
+                  y.checkAll = true;
                 }
               }
               if (y.action_data && y.action_data.length > 0) {
                 y.action_data.map((z) => {
-                  const Bindex = this.action_data.findIndex((a) => String(a) === String(z.id))
+                  const Bindex = this.action_data.findIndex(
+                    (a) => String(a) === String(z.id)
+                  );
                   if (Bindex !== -1) {
-                    y.fieldList.push(this.action_data[Bindex])
+                    y.fieldList.push(this.action_data[Bindex]);
                   }
-                  return z
-                })
+                  return z;
+                });
                 if (y.action_data.length === y.fieldList.length) {
-                  y.fieldAll = true
+                  y.fieldAll = true;
                 }
               }
               if (y.private && y.private.length === 2) {
-                const Cindex = this.private_data.findIndex((a) => String(a) === String(y.id))
+                const Cindex = this.private_data.findIndex(
+                  (a) => String(a) === String(y.id)
+                );
                 if (Cindex !== -1) {
-                  y.is_private_change = '1'
+                  y.is_private_change = "1";
                 } else {
-                  y.is_private_change = '0'
+                  y.is_private_change = "0";
                 }
               } else {
-                y.is_private_change = '0'
+                y.is_private_change = "0";
               }
-              return y
-            })
+              return y;
+            });
           }
-          return x
-        })
+          return x;
+        });
 
-        if (!this.ruleForm.private_field) this.ruleForm.private_field = []
+        if (!this.ruleForm.private_field) this.ruleForm.private_field = [];
 
-        this.actionList = arr
+        this.actionList = arr;
       } else if (res && res.code >= 100 && res.code <= 104) {
-        await this.logout()
+        await this.logout();
       } else {
-        this.$message.warning(res.message)
+        this.$message.warning(res.message);
       }
     },
     recursionFilterActionList(list) {
-      const _list = []
+      const _list = [];
       for (let i = 0; i < list.length; i++) {
-        const item = list[i]
+        const item = list[i];
 
-        if (item.level !== 1) _list.push(item)
-        if (item.child && item.child.length > 0) item.child = this.recursionFilterActionList(item.child)
+        if (item.level !== 1) _list.push(item);
+        if (item.child && item.child.length > 0)
+          item.child = this.recursionFilterActionList(item.child);
       }
-      return _list
+      return _list;
     },
 
     async initActionList() {
-      const res = await asyncRequest.actionList({ level: '0,3' })
+      const res = await asyncRequest.actionList({ level: "0,3" });
 
       if (res && res.code === 0) {
-        const list = res.data
-        console.log(this.recursionFilterActionList(list))
-
-        let arr = list.filter((item) => item.child && item.child.length > 0)
+        const list = res.data;
+        let arr = list.filter((item) => item.child && item.child.length > 0);
+        if (!this.is_super_admin_ids) {
+          arr = arr.filter((v) => {
+            if (String(v.id) === "54") {
+              v.child.filter((v2) => {
+                v2.action = v2.action.filter((v3) => v3.action_code === "001");
+                console.log(v2.action);
+                return v2;
+              });
+            }
+            return v;
+          });
+        }
         arr = arr.map((x) => {
           x.child.map((y) => {
-            y.checkAll = false
-            y.checkList = []
-            y.fieldAll = false
-            y.fieldList = []
-            y.is_private_change = '0'
-            if (y.is_private === '0') {
-              y.private = []
+            y.checkAll = false;
+            y.checkList = [];
+            y.fieldAll = false;
+            y.fieldList = [];
+            y.is_private_change = "0";
+            if (y.is_private === "0") {
+              y.private = [];
             } else {
               y.private = [
                 {
-                  id: '0',
-                  label: '公有数据'
+                  id: "0",
+                  label: "公有数据",
                 },
                 {
-                  id: '1',
-                  label: '私有数据'
-                }
-              ]
+                  id: "1",
+                  label: "私有数据",
+                },
+              ];
             }
-            return y
-          })
-          return x
-        })
+            return y;
+          });
+          return x;
+        });
 
-        this.actionList = arr
+        this.actionList = arr;
       } else if (res && res.code >= 100 && res.code <= 104) {
-        await this.logout()
+        await this.logout();
       } else {
-        this.$message.warning(res.message)
+        this.$message.warning(res.message);
       }
     },
     async resetForm() {
       // 重置
       await this.$nextTick(() => {
         if (this.$refs.ruleForm) {
-          this.$refs.ruleForm.resetFields()
-          this.$refs.ruleForm.clearValidate()
+          this.$refs.ruleForm.resetFields();
+          this.$refs.ruleForm.clearValidate();
 
           this.ruleForm = {
-            role_name: '',
+            role_name: "",
             private_field: [],
-            is_allow_see_price: '',
-            level: '3'
-          }
+            is_allow_see_price: "",
+            level: "3",
+          };
         }
-      })
+      });
     },
     async submitForm() {
-      await this.$refs.ruleForm.validate(async(valid) => {
+      await this.$refs.ruleForm.validate(async (valid) => {
         if (valid) {
           if (this.loading) {
-            return
+            return;
           }
-          this.action_data = [] // 字段数据
-          this.action = [] // 功能数据
-          const arr = []
+          this.action_data = []; // 字段数据
+          this.action = []; // 功能数据
+          const arr = [];
           this.actionList.forEach((x) => {
             x.child.forEach((y) => {
-              this.action_data.push(...y.fieldList)
-              this.action.push(...y.checkList)
-              if (y.is_private_change === '1') {
-                arr.push(y.id)
+              this.action_data.push(...y.fieldList);
+              this.action.push(...y.checkList);
+              if (y.is_private_change === "1") {
+                arr.push(y.id);
               }
-            })
-          })
+            });
+          });
           // this.action_data.length === 0 ||和字段
           if (this.action.length === 0) {
-            this.$message.warning('请选择功能!')
+            this.$message.warning("请选择功能!");
           } else {
-            this.loading = true
+            this.loading = true;
 
             const model = {
               roleid: this.id,
               role_name: this.ruleForm.role_name,
-              private_field: JSON.parse(
-                JSON.stringify(this.ruleForm.private_field)
-              ),
+              private_field: JSON.parse(JSON.stringify(this.ruleForm.private_field)),
               level: this.ruleForm.level,
               action: this.action,
               action_data: this.action_data,
               private_data: arr,
-              is_allow_see_price: this.ruleForm.is_allow_see_price
-            }
+              is_allow_see_price: this.ruleForm.is_allow_see_price,
+            };
 
-            let res = {}
-            if (this.id === 'add') {
-              delete model['roleid']
-              model.companyNo = this.currentCompany
-              res = await asyncRequest.add(model)
+            let res = {};
+            if (this.id === "add") {
+              delete model["roleid"];
+              model.companyNo = this.currentCompany;
+              res = await asyncRequest.add(model);
             } else {
-              model.companyNo = this.ruleForm.companyNo
-              res = await asyncRequest.update(model)
+              model.companyNo = this.ruleForm.companyNo;
+              res = await asyncRequest.update(model);
             }
-            this.loading = false
+            this.loading = false;
             if (res && res.code === 0) {
-              const title = this.id === 'add' ? '添加成功' : '修改成功'
+              const title = this.id === "add" ? "添加成功" : "修改成功";
               this.$notify.success({
                 title,
-                message: ''
-              })
-              this.showModelThis = false
+                message: "",
+              });
+              this.showModelThis = false;
               // 刷新
-              this.$emit('refresh')
+              this.$emit("refresh");
             } else if (res && res.code >= 100 && res.code <= 104) {
-              await this.logout()
+              await this.logout();
             } else {
-              this.$message.warning(res.message)
+              this.$message.warning(res.message);
             }
           }
         } else {
-          console.log('error submit!!')
-          return false
+          console.log("error submit!!");
+          return false;
         }
-      })
-    }
-  }
-}
+      });
+    },
+  },
+};
 </script>
 
-   <style lang="scss" scoped>
+<style lang="scss" scoped>
 .role {
   .quanxian-main {
     width: 100%;