<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" />
                    </el-col>
                    <el-col :span="12">
                        <signature :user="user" />
                    </el-col>
                </el-row>
              </div>
              <ul class="list-group list-group-striped list-top">

                <li class="list-group-item">
                  <svg-icon icon-class="group" />归属部门
                  <div class="pull-right" v-if="user.parentId">{{ user.parentName }}</div>
                </li>
                <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">{{ 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 userAvatar from "./userAvatar";
  import resetPwd from "./resetPwd";
  import { getProfile } from "@/api/system/basicInfo";
  import basicData from './basicData.vue';
  import signature from './signature.vue'

  export default {
    name: "Profile",
    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>
