scorpio 2 years ago
parent
commit
0635e887a7
3 changed files with 63 additions and 4 deletions
  1. 8 0
      src/api/system/index.js
  2. 14 2
      src/page/login.vue
  3. 41 2
      src/views/home/component/dash.vue

+ 8 - 0
src/api/system/index.js

@@ -16,6 +16,14 @@ export default {
   getDeptLazy(params) {
     return fetch('/blade-system/dept/lazy-list', params)
   },
+  /**
+   * 全部机构
+   * @param params
+   * @returns {Promise | Promise<unknown>}
+   */
+  getDeptList(params) {
+    return fetch('/blade-system/dept/list', params)
+  },
   /**
    * 获取公司
    * @param params

+ 14 - 2
src/page/login.vue

@@ -303,6 +303,7 @@ export default {
               setToken(res.access_token)
               this.user.setUserInfo({ name: res.real_name })
               this.getInfo()
+              this.menus()
             }
           })
         } else {
@@ -326,7 +327,6 @@ export default {
             res.data.typeName = '服务商'
           }
           this.user.setUserInfo(res.data)
-          this.$router.replace('/')
         }
       })
     },
@@ -377,13 +377,25 @@ export default {
                 clearInterval(this.time)
                 setToken(res.access_token)
                 this.getInfo()
-                this.$router.replace('/')
+                this.menus()
               }
             })
           }
         }
       })
     },
+    menus() {
+      this.$api.common.getMenus().then(res => {
+        if (res.code === 200 && res.data.length > 0) {
+          const first = res.data[0]
+          if (first.children.length > 0) {
+            this.$router.replace(first.children[0].path)
+          } else {
+            this.$router.replace(first.path)
+          }
+        }
+      })
+    },
     loginTest(type) {
       if (type === 1) {
         this.form.name = 'admin001'

+ 41 - 2
src/views/home/component/dash.vue

@@ -252,7 +252,7 @@
           ref="form"
           :model="projectForm"
           class="lab mt-20"
-          label-width="100px"
+          label-width="120px"
           :rules="rules"
         >
           <div class="flex flex-center flex-col mr-20">
@@ -263,6 +263,22 @@
                 placeholder="输入项目名称"
               />
             </el-form-item>
+            <el-form-item
+              v-if="user.info.type === 4"
+              class="full-width"
+              label="项目所属机构"
+              prop="dept"
+            >
+              <el-autocomplete
+                v-model="projectForm.dept"
+                :fetch-suggestions="querySearch"
+                :trigger-on-focus="false"
+                clearable
+                class="full-width"
+                @input="deptInput"
+                placeholder="输入项目所属机构"
+              />
+            </el-form-item>
             <el-form-item
               class="full-width"
               label="项目总投"
@@ -580,6 +596,9 @@ export default {
       },
       rules: {
         name: [{ required: true, message: '请输入项目名称', trigger: 'blur' }],
+        dept: [
+          { required: true, message: '请选择项目所属机构', trigger: 'blur' }
+        ],
         projectType: [
           {
             required: true,
@@ -607,7 +626,8 @@ export default {
       projectStageQuery: {},
       selectList: [],
       dev: false,
-      dataType: 'project'
+      dataType: 'project',
+      deptList: []
     }
   },
   created() {
@@ -1009,6 +1029,25 @@ export default {
         previewType: 2
       }
       this.$router.push({ query: dataIds, path: '/home/excel' })
+    },
+    querySearch(key, callback) {
+      this.$api.system
+        .getDeptList({ deptCategory: 3, fullName: key })
+        .then(res => {
+          if (res.code === 200) {
+            console.log(res)
+            this.deptList = res.data.map(ele => {
+              return { value: ele.deptName, id: ele.id }
+            })
+            callback(this.deptList)
+          }
+        })
+    },
+    deptInput(res) {
+      const tmp = this.deptList.find(ele => ele.value === res)
+      if (tmp) {
+        this.projectForm.createDept = tmp.id
+      }
     }
   }
 }