Explorar el Código

新增组织机构查询

Z hace 1 año
padre
commit
7a8494ce39

+ 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 = [] }) => {

+ 11 - 0
src/api/login/index.js

@@ -32,3 +32,14 @@ export async function getCaptcha () {
   }
   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 - 1
src/main.js

@@ -12,8 +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);
 
 
 

+ 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);
+    },
     /**
      * 请求用户信息、权限、角色、菜单
      */

+ 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) => {

+ 7 - 3
src/views/materialPlan/components/materialPlan-search.vue

@@ -18,15 +18,19 @@
           </el-select>
         </el-form-item>
       </el-col>
-      <el-col v-bind="styleResponsive ? { lg: 7, md: 12 } : { span: 7 }">
+      <el-col v-bind="styleResponsive ? { lg: 5, md: 12 } : { span: 5 }">
         <el-form-item label="创建时间:">
           <el-date-picker class="w100" v-model="where.createTime" type="daterange" range-separator="至"
             start-placeholder="开始日期" end-placeholder="结束日期" value-format="yyyy-MM-dd HH:mm:ss">
           </el-date-picker>
         </el-form-item>
       </el-col>
-
-      <el-col v-bind="styleResponsive ? { lg: 5, md: 12 } : { span: 5 }">
+      <el-col v-bind="styleResponsive ? { lg: 5, md: 6 } : { span: 5 }">
+        <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: 4, md: 12 } : { span: 4 }">
         <div class="ele-form-actions">
           <el-button type="primary" icon="el-icon-search" class="ele-btn-icon" @click="search">
             查询

+ 7 - 1
src/views/productionPlan/components/productionPlan-search.vue

@@ -151,6 +151,11 @@
             : { span: activeName == 'first' ? 24 : 6 }
         "
       >
+        <el-col v-bind="styleResponsive ? { lg: 6, md: 6 } : { 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>
         <div class="ele-form-actions">
           <el-button
             type="primary"
@@ -181,6 +186,7 @@
         model: '',
         brandNo: '',
         planType: '',
+        deptIds: [],
         releaseTime: [],
         deliveryTime: [],
         formingTime: [],
@@ -219,7 +225,7 @@
       search () {
         const where = { ...this.where };
         for (const key in where) {
-          if (Array.isArray(where[key])) {
+          if (Array.isArray(where[key])&&key!=='deptIds') {
             where[`${key}End`] = where[key][1];
             where[key] = where[key][0];
           }

+ 8 - 2
src/views/saleOrder/components/order-search.vue

@@ -75,7 +75,7 @@
           <el-input v-model="where.productName" placeholder="请输入"></el-input>
         </el-form-item>
       </el-col>
-      
+
     </el-row>
     <el-row :gutter="15">
       <el-col v-bind="styleResponsive ? { lg: 12, md: 12 } : { span: 12 }">
@@ -85,7 +85,13 @@
           </el-date-picker>
         </el-form-item>
       </el-col>
-      <el-col v-bind="styleResponsive ? { lg: 12, md: 12 } : { span: 12 }">
+      <el-col v-bind="styleResponsive ? { lg: 6, md: 6 } : { 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: 6 } : { span: 6 }">
         <div class="ele-form-actions">
           <el-button type="primary" icon="el-icon-search" class="ele-btn-icon" @click="search">
             查询

+ 8 - 3
src/views/workOrder/components/order-search.vue

@@ -29,7 +29,7 @@
       </el-col>
       <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 6 }">
         <el-form-item label="状态:">
-          <el-select v-model="where.status" placeholder="请选择">
+          <el-select v-model="where.status" placeholder="请选择" style="width: 100%">
             <el-option v-for="item in statusOpt" :key="item.value" :label="item.label" :value="item.value">
             </el-option>
           </el-select>
@@ -53,7 +53,7 @@
 
 
 
-      <el-col v-bind="styleResponsive ? { lg: 9, md: 12 } : { span: 9 }">
+      <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 6 }">
         <el-form-item label="创建时间:">
           <el-date-picker class="w100" v-model="where.createTime" type="daterange" range-separator="至"
             start-placeholder="开始日期" end-placeholder="结束日期" value-format="yyyy-MM-dd HH:mm:ss"
@@ -61,6 +61,11 @@
           </el-date-picker>
         </el-form-item>
       </el-col>
+      <el-col v-bind="styleResponsive ? { lg: 6, md: 6 } : { 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="0px">
           <el-button type="primary" icon="el-icon-search" class="ele-btn-icon" @click="search">
@@ -110,7 +115,7 @@ export default {
   },
   watch: {},
   created() {
-   
+
    },
   methods: {
     /* 搜索 */