<template>
  <div class="app-container">
    <el-row class="center-row" :gutter="20">
      <el-col :span="12" :xs="24">
        <el-card style="margin-top: 50px;">
          <div slot="header" class="clearfix">
            <span>个人信息</span>
          </div>
          <div>
            <div class="text-center">
              <userAvatar/>
            </div>
            <ul class="list-group list-group-striped">
              <li class="list-group-item">
                <svg-icon icon-class="user"/>
                用户名称
                <div class="pull-right">{{ user.userName }}</div>
              </li>
              <li class="list-group-item">
                <svg-icon icon-class="phone"/>
                手机号码
                <div class="pull-right">{{ user.phonenumber }}</div>
              </li>
              <li class="list-group-item">
                <svg-icon icon-class="email"/>
                用户邮箱
                <div class="pull-right">{{ user.email }}</div>
              </li>
              <li class="list-group-item">
                <svg-icon icon-class="tree"/>
                所属部门
                <div v-if="user.dept" class="pull-right">{{ user.dept.deptName }} / {{ postGroup }}</div>
              </li>
              <li class="list-group-item">
                <svg-icon icon-class="peoples"/>
                职位
                <div class="pull-right">{{ roleGroup }}</div>
              </li>
              <li class="list-group-item">
                <svg-icon icon-class="date"/>
                创建日期
                <div class="pull-right">{{ user.createTime }}</div>
              </li>
            </ul>
          </div>
        </el-card>
      </el-col>
    </el-row>
  </div>
</template>
<script>
import {getUserProfile} from "@/api/system/user";
import userAvatar from "/src/views/system/user/profile/userAvatar";
import userInfo from "/src/views/system/user/profile/userInfo";
import resetPwd from "/src/views/system/user/profile/resetPwd";

export default {
  name: "Profile",
  components: {userAvatar, userInfo, resetPwd},
  data() {
    return {
      user: {},
      roleGroup: {},
      postGroup: {},
      activeTab: "userinfo"
    };
  },
  created() {
    this.getUser();
  },
  methods: {
    getUser() {
      getUserProfile().then(response => {
        this.user = response.data.sysUser;
        this.roleGroup = response.data.roleGroup;
        this.postGroup = response.data.postGroup;
      });
    }
  }
};
</script>


<style scoped>
.app-container {
  padding: 20px;
  display: flex;
  justify-content: center;
}

.center-row {
  width: 100%;
  display: flex;
  justify-content: center;
}

.box-card {
  border: 1px solid #dcdfe6;
}

.text-center {
  text-align: center;
}

.list-group-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
</style>
