Z 1 год назад
Родитель
Сommit
c8934f269a

+ 3 - 0
qiankun_config/store.js

@@ -18,6 +18,9 @@ export default function (state) {
   if (state.user?.info) {
     store.commit('user/setUserInfo', state.user.info);
   }
+  if (state.user?.authorityDept) {
+    store.dispatch('user/getCurrentUserAuthorityDept');
+  }
 }
 
 export const createMutationObserve = ({ modules = [] }) => {

+ 12 - 1
src/api/login/index.js

@@ -41,4 +41,15 @@ export async function getCode (code) {
     return res.data.data;
   }
   return Promise.reject(new Error(res.data.message));
-}
+}
+/**
+ * 获取当前登陆用户数据权限部门数据
+ * @param
+ */
+export async function getCurrentUserAuthorityDeptAPI () {
+  const res = await request.post('/main/user/getCurrentUserAuthorityDepts');
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}

+ 75 - 0
src/components/authSelection/index.vue

@@ -0,0 +1,75 @@
+<template>
+  <div>
+    <ele-tree-select
+      clearable
+      :data="deptTreeList"
+      v-model="selectVal"
+      valueKey="id"
+      labelKey="name"
+      :show-checkbox="true"
+      :check-strictly="true"
+      multiple
+      collapseTags
+      filterable
+      placeholder="请选择"
+      default-expand-all
+    />
+  </div>
+</template>
+<script>
+  import { mapGetters } from 'vuex';
+
+  export default {
+    name: 'index',
+    model: {
+      prop: 'value',
+      event: 'updateVal'
+    },
+    props: {
+      value: {
+        type: [String, Array],
+        default: ''
+      },
+      dataType: {
+        type: String,
+        default: 'String'
+      }
+    },
+    data() {
+      return {
+        deptTreeList: []
+      };
+    },
+    computed: {
+      ...mapGetters(['user']),
+      selectVal: {
+        set(val) {
+          switch (this.dataType) {
+            case 'Array':
+              this.$emit('updateVal', val);
+              break;
+            default:
+              this.$emit('updateVal', val.join(','));
+          }
+        },
+        get() {
+          switch (this.dataType) {
+            case 'Array':
+              return this.value || [];
+            default:
+              return this.value ? this.value.split(',') : [];
+          }
+        }
+      }
+    },
+    mounted() {
+      this.deptTreeList = this.$util.toTreeData({
+        data: this.user?.authorityDept?.groupList || [],
+        idField: 'id',
+        parentIdField: 'parentId'
+      });
+    }
+  };
+</script>
+
+<style scoped lang="scss"></style>

+ 2 - 0
src/main.js

@@ -12,7 +12,9 @@ import i18n from './i18n';
 import './styles/index.scss';
 import DictSelection from '@/components/Dict/DictSelection';
 import HeaderTitle from '@/components/header-title';
+import authSelection from '@/components/authSelection';
 Vue.component('HeaderTitle', HeaderTitle);
+Vue.component('authSelection', authSelection);
 
 // // register globally
 import '@/icons';

+ 12 - 1
src/store/modules/user.js

@@ -6,6 +6,7 @@ import { USER_MENUS } from '@/config/setting';
 import { getResourcesTree } from '@/api/layout';
 import { SYSTEM_NAME } from '@/config/setting';
 import Vue from 'vue';
+import {getCurrentUserAuthorityDeptAPI} from "@/api/login";
 const formatRouter = (list) => {
   let menuList = []; // menuType
   let authorities = [];
@@ -48,7 +49,9 @@ export default {
     // 当前登录用户的权限路由
     authoritiesRouter: [],
     // 当前登录用户的角色
-    roles: []
+    roles: [],
+    // 当前登录用户的数据权限部门数据
+    authorityDept: {}
   },
   mutations: {
     // 设置登录用户的信息
@@ -70,9 +73,17 @@ export default {
     // 设置登录用户的角色
     setRoles (state, roles) {
       state.roles = roles;
+    },
+    // 当前登录用户的数据权限部门数据
+    setAuthorityDept(state, info) {
+      state.authorityDept = info;
     }
   },
   actions: {
+    async getCurrentUserAuthorityDept({ commit }) {
+      const info = await getCurrentUserAuthorityDeptAPI();
+      commit('setAuthorityDept', info);
+    },
     /**
      * 请求用户信息、权限、角色、菜单
      */

+ 5 - 0
src/views/inspectionClassify/components/user-search.vue

@@ -19,6 +19,11 @@
 
         </el-form-item>
       </el-col>
+      <el-col v-bind="styleResponsive ?{ lg: 6, md: 12 } : { span: 6 }">
+        <el-form-item label="组织机构:">
+          <auth-selection data-type="Array" v-model="where.deptIds" style="width: 100%"></auth-selection>
+        </el-form-item>
+      </el-col>
       <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 6 }">
         <el-form-item label-width="50px">
           <el-button type="primary" icon="el-icon-search" class="ele-btn-icon" @click="search" size="small">

+ 13 - 8
src/views/inspectionStandard/components/search.vue

@@ -2,36 +2,41 @@
 <template>
   <el-form label-width="77px" class="ele-form-search" @keyup.enter.native="search" @submit.native.prevent>
     <el-row :gutter="15">
-      <el-col v-bind="styleResponsive ? { lg: 5, md: 10 } : { span: 4}">
+      <el-col v-bind="styleResponsive ? { lg: 6, md: 10 } : { span: 6}">
         <el-form-item label="标准名称:">
           <el-input clearable v-model="where.name" placeholder="请输入" />
         </el-form-item>
       </el-col>
 
-      <el-col v-bind="styleResponsive ? { lg: 5, md: 10 } : { span: 4}">
+      <el-col v-bind="styleResponsive ? { lg: 6, md: 10 } : { span: 6}">
         <el-form-item label="标准代码:">
           <el-input clearable v-model="where.standardCode" placeholder="请输入" />
         </el-form-item>
       </el-col>
 
-      <el-col v-bind="styleResponsive ? { lg: 5, md: 10 } : { span: 4}">
+      <el-col v-bind="styleResponsive ? { lg: 6, md: 10 } : { span: 6}">
         <el-form-item label="标准类型:">
           <DictSelection dictName="质检标准类型" v-model="where.type"></DictSelection>
         </el-form-item>
       </el-col>
 
 
-     
 
-      <el-col v-bind="styleResponsive ? { lg: 5, md: 10 } : { span: 4}">
-        <el-form-item label="状态:">
-          <el-select v-model="where.status" class="m-2" placeholder="请选择" size="large">
+
+      <el-col v-bind="styleResponsive ? { lg: 6, md: 10 } : { span: 6}">
+        <el-form-item label="状态:" >
+          <el-select v-model="where.status" class="m-2" placeholder="请选择" size="large" style="width: 100%">
             <el-option label="停用" :value="0" />
             <el-option label="启用" :value="1" />
           </el-select>
         </el-form-item>
       </el-col>
-      <el-col v-bind="styleResponsive ? { lg: 4, md: 10 } : { span: 4}">
+      <el-col v-bind="styleResponsive ?{ lg: 6, md: 12 } : { span: 6 }">
+        <el-form-item label="组织机构:">
+          <auth-selection data-type="Array" v-model="where.deptIds" style="width: 100%"></auth-selection>
+        </el-form-item>
+      </el-col>
+      <el-col style="display: flex;justify-content: flex-end" v-bind="styleResponsive ? { lg: 18, md: 18 } : { span: 18}">
         <div class="ele-form-actions">
           <el-button type="primary" icon="el-icon-search" class="ele-btn-icon" @click="search">
             查询

+ 1 - 0
src/views/login/index.vue

@@ -180,6 +180,7 @@
               this.$store.commit('user/setUserInfo', res.data);
               this.loading = false;
               this.$message.success(res.message);
+              this.$store.dispatch('user/getCurrentUserAuthorityDept');
               this.goHome();
             })
             .catch((e) => {