Prechádzať zdrojové kódy

人员列表获取公司信息、新增人员获取公司报错

Reiskuchen 5 rokov pred
rodič
commit
f2373b2121
2 zmenil súbory, kde vykonal 51 pridanie a 18 odobranie
  1. 1 1
      ys_vue/src/port.js
  2. 50 17
      ys_vue/src/views/project/staff.vue

+ 1 - 1
ys_vue/src/port.js

@@ -79,7 +79,7 @@ export default {
         addCompany: '/company/add',  //(公司)
         companyList: '/company/list',
         delCompany: '/company/delete',
-        companys: '/company/getCompanyList', //创建账号所获取的公司列表
+        companys: '/company/getCompanyList', //创建账号所获取的公司列表
         comps: '/company/getCompanys', //创建模具获取的(资产方)公司列表
         addCompanyListToProject: '/company/addCompanyListToProject', //项目分配生产方公司列表
         relationList: '/company/relationList', //建立关联公司时的公司列表

+ 50 - 17
ys_vue/src/views/project/staff.vue

@@ -6,7 +6,7 @@
                 <el-col :span="3">
                     <el-form-item>
                         <el-select v-model="filters.companyId" clearable filterable placeholder="请选择公司">
-                            <el-option v-for="item in company" :key="item.id" :label="item.companyName" :value="item.id">
+                            <el-option v-for="item in allCompanies" :key="item.id" :label="item.companyName" :value="item.id">
                             </el-option>
                         </el-select>
                     </el-form-item>
@@ -162,6 +162,8 @@
                 user: JSON.parse(sessionStorage.getItem('user')),
                 company: [],
                 projects: [],
+                //搜索用 涉及到的所有公司
+                allCompanies: [],
 
 				list: [],
 				total: 0,
@@ -220,12 +222,38 @@
 			}
 		},
 		methods: {
-            // 获取基础数据
+            //获取基础数据
             getMsg(){
                 this.http.post(this.port.project.projectByUser, {}, 
                 res => {
                     if (res.code == "ok") {
                         this.projects = res.data;
+                        //再获取一下公司列表
+                        this.getAllCompanies();
+                    } else {
+                        this.$message({
+                            message: res.msg,
+                            type: 'error'
+                        });
+                    }
+                }, error => {
+                    this.$message({
+                        message: error,
+                        type: 'error'
+                    });
+                });
+            },
+
+            //获取所有公司
+            getAllCompanies(){
+                this.allCompanies = [];
+                this.http.post(this.port.base.companys, {
+                    id: this.user.id,
+                    parentId: this.user.parentId
+                }, res => {
+                    if (res.code == "ok") {
+                        this.allCompanies = res.data;
+                        console.log(this.allCompanies);
                     } else {
                         this.$message({
                             message: res.msg,
@@ -240,7 +268,7 @@
                 })
             },
 
-            //  分页
+            //分页
 			handleCurrentChange(val) {
 				this.page = val;
 				this.getUsers();
@@ -410,23 +438,28 @@
             
             //修改
             choseProject() {
-                this.http.post(this.port.base.getCompanyByPro, {
-                    projectId: this.addForm.projectIds
-                }, res => {
-                    if (res.code == "ok") {
-                        this.company = res.data;
-                    } else {
+                if(this.addForm.projectIds == ""){
+                    this.company = [];
+                    this.addForm.companyId = null;
+                }else{
+                    this.http.post(this.port.base.getCompanyByPro, {
+                        projectId: this.addForm.projectIds
+                    }, res => {
+                        if (res.code == "ok") {
+                            this.company = res.data;
+                        } else {
+                            this.$message({
+                                message: res.msg,
+                                type: 'error'
+                            });
+                        }
+                    }, error => {
                         this.$message({
-                            message: res.msg,
+                            message: error,
                             type: 'error'
                         });
-                    }
-                }, error => {
-                    this.$message({
-                        message: error,
-                        type: 'error'
-                    });
-                })
+                    })
+                }
             },
 
             //邀请