<template>
  <div class="app-container">
    <el-row :gutter="20">
      <el-col :span="8" :xs="24">
        <el-card class="box-card">
          <div slot="header" class="clearfix">
            <span>个人信息</span>
          </div>
          <div>
            <div class="text-center list-top">
              <el-row>
                <el-col :span="12">
                  <userAvatar :user="user"/>
                  <br/>
                  <b>头 像</b>
                </el-col>
                <el-col :span="12">
                  <signature :user="user"/>
                  <br/>
                  <b>签 名</b>
                </el-col>
              </el-row>
            </div>
            <ul class="list-group list-group-striped list-top">
              <li class="list-group-item">
                <svg-icon icon-class="tree"/>
                所属部门
                <div class="pull-right" v-if="user.deptName">{{ user.deptName }}</div>
              </li>
              <li class="list-group-item">
                <svg-icon icon-class="date"/>
                岗位
                <div class="pull-right">{{ postGroup }}</div>
              </li>
              <li class="list-group-item">
                <svg-icon icon-class="peoples"/>
                角色
                <div class="pull-right" style="word-wrap: break-word;">{{ roleGroup }}</div>
              </li>
            </ul>
          </div>
        </el-card>
      </el-col>
      <el-col :span="16" :xs="24">
        <el-card>
          <div slot="header" class="clearfix">
            <span>基本资料</span>
          </div>
          <el-tabs v-model="activeTab">
            <el-tab-pane label="基本资料" name="userinfo">
              <basicData :user="user"/>
            </el-tab-pane>
            <el-tab-pane label="修改密码" name="resetPwd">
              <resetPwd/>
            </el-tab-pane>
          </el-tabs>
        </el-card>
      </el-col>
    </el-row>
  </div>
</template>

<script>


import {getProfile} from "@/api/smartSchool/personWork/basicInfo";

import userAvatar from "./components/profile/userAvatar";
import resetPwd from "./components/profile/resetPwd";
import basicData from './components/profile/basicData.vue';
import signature from './components/profile/signature.vue'

export default {
  name: "BasicInfo",
  components: {userAvatar, basicData, resetPwd, signature},
  data() {
    return {
      user: {},
      roleGroup: {},
      postGroup: {},
      activeTab: "userinfo"
    };
  },
  created() {
    this.getUser();
  },
  methods: {
    getUser() {
      getProfile().then(response => {
        this.user = response.data;
        this.roleGroup = response.roleGroup;
        this.postGroup = response.postGroup;
      });
    },

  }
};
</script>

<style lang="scss" scoped>
.list-top {
  padding-top: 43px;
}
</style>
