<!-- 用户中心 -->
<template>
  <div class="view-user-center">
    <div class="view-tit">
      <div class="tit-n"></div>
      <div class="tit-name">账号信息</div>
    </div>
    <div class="view-cnt">
      <div class="cnt-item">
        <div class="item-label">账号名</div>
        <div class="item-data">{{ userInfo.account}}</div>
      </div>
      <div class="cnt-item">
        <div class="item-label">姓名</div>
        <div class="item-data">{{ userInfo.name}}</div>
      </div>
      <div class="cnt-item">
        <div class="item-label">所属机构</div>
        <div class="item-data">{{ userInfo.orgName}}</div>
      </div>
      <div class="cnt-item">
        <div class="item-label">工号</div>
        <div class="item-data">{{ userInfo.employeeNumber}}</div>
      </div>
      <div class="cnt-item">
        <div class="item-label">密码</div>
        <div class="item-data">
          <span>**************</span>
          <!-- <div class="item-btn">修改密码</div> -->
          <el-button
            class="item-btn"
            size="mini"
            type="text"
            icon="el-icon-my-biangeng"
            @click="editHandle">
            {{ $t('table.changePwd') }}
          </el-button>
        </div>

      </div>
    </div>
    <DialogUser v-if="pwdVisile" ref="userRef" :visible.sync="pwdVisile" />
  </div>
</template>

<script>
import { DialogUser } from './components'
export default {
  data() {
    return {
      pwdVisile: false,
      userInfo: {
        id: undefined,
        name: undefined,
        employeeNumber: undefined,
        orgName: undefined,
        account: undefined,
        password: undefined,
      }
    }
  },
  components: { DialogUser },
  methods: {
    editHandle() {
      this.pwdVisile = true
      this.$nextTick(() => {
        this.$refs.userRef.init(this.userInfo, true)
      })
    }
  },
  created() {
    const USER_INFO = JSON.parse(window.localStorage.getItem('USER_INFO'))
    console.log(typeof USER_INFO, USER_INFO);
    Object.keys(this.userInfo).forEach((v) => {
      this.userInfo[v] = USER_INFO.value[v]
    })
    this.editHandle()
  }
}
</script>

<style lang="scss" scoped>
@import '@/styles/mixin.scss';
.view-user-center {
  padding: 20px 40px;
  .view-tit {
    height: 40px;
    font-size: 14px;
    font-family: 'sourceHanSansCN';
    @include flex-left;
    .tit-n {
      width: 3px;
      height: 15px;
      background-color: #3D5596;
      margin-right: 5px;
    }
  }
  .view-cnt {
    width: 40%;
    padding: 20px 0;
    .cnt-item {
      height: 40px;
      // background-color: red;
      font-size: 13px;
      font-family: 'sourceHanSansCN';
      display: flex;
      .item-label {
        width: 100px;
        height: 40px;
        color: #707070;
        @include flex-left;
      }
      .item-data {
        flex: 1;
        color: #212121;
        @include flex-left;
        .item-btn {
          font-family: 'sourceHanSansCN';
          margin-left: 100px;
        }
      }
    }
  }
}
</style>
