<template>
  <el-row :gutter="20">
    <el-col :span="12">
      <div>用户列表</div>
      <el-table :data="userList" >
        <el-table-column prop="nickName" label="用户" width="180"></el-table-column>
        <el-table-column prop="deptId" label="部门" :formatter="findDep" width="180"></el-table-column>
      </el-table>
    </el-col>
  </el-row>

  <!-- <div>
用户管理
  </div>-->
</template>
<script scoped>
export default {
  data() {
    return {
      userList: [],
      depList: []
    };
  },
  created() {
    this.$fetch("manageBase/dept/select").then(response => {
      this.depList = response.data;
    });
    this.$fetch("manageBase/user/list", 1, 10).then(response => {
      console.log(response);
      this.userList = response.data.list;
    });
  },
  methods: {
    findDep(row, column) {
      console.log(row);
      console.log(row.deptId);
      if (row.deptId) {
        console.log("进入判断", row.deptId);
        this.depList.forEach(item => {
          console.log(item.code);
          console.log(row.deptId);
          if (item.code == row.deptId) {
            return item.name;
          } else {
            return "";
          }
        });
      } else if (row.deptId == 0) {
        return "全部";
      } else {
        return "";
      }
    }
  }
};
</script>
<style scope>
</style>


