<template>
  <div>
    <div class="container normal-panel normal-margin">
      <el-descriptions title="用户信息">
          <el-descriptions-item label="账号">{{minaInfo.accountno}}</el-descriptions-item>
          <el-descriptions-item label="账号类型">{{minaInfo.usertypename}}</el-descriptions-item>
          <el-descriptions-item label="状态">
            <span :style="minaInfo.status === 'ACTIVE'?'color:#52C41A':'color:#FF3B30'">{{minaInfo.status === 'ACTIVE'?'启用':minaInfo.status === 'INACTIVE'?'停用':'其他'}}</span>
          </el-descriptions-item>
          <el-descriptions-item label="手机号">{{minaInfo.phonenumber}}</el-descriptions-item>
          <el-descriptions-item label="账号密码">
            ********
          </el-descriptions-item>
      </el-descriptions>
    </div>
    <div class="container normal-panel normal-margin">
      <el-descriptions title="员工信息" :column="6">
          <el-descriptions-item label="编号">{{minaInfo.hrmsg.hrcode?minaInfo.hrmsg.hrcode:'--'}}</el-descriptions-item>
          <el-descriptions-item label="身份证号">{{minaInfo.hrmsg.idcard?minaInfo.hrmsg.idcard:'--'}}</el-descriptions-item>
          <el-descriptions-item label="部门">{{minaInfo.hrmsg.depname?minaInfo.hrmsg.depname:'--'}}</el-descriptions-item>
          <el-descriptions-item label="是否部门负责人">{{minaInfo.hrmsg.isleader === 1?'是':'否'}}</el-descriptions-item>
          <el-descriptions-item label="职位">{{minaInfo.hrmsg.position?minaInfo.hrmsg.position:'--'}}</el-descriptions-item>
          <el-descriptions-item label="办公电话">{{minaInfo.hrmsg.officetelephone?minaInfo.hrmsg.officetelephone:'--'}}</el-descriptions-item>
          <el-descriptions-item label="姓名">{{minaInfo.hrmsg.name?minaInfo.hrmsg.name:'--'}}</el-descriptions-item>
          <el-descriptions-item label="电话">{{minaInfo.hrmsg.phonenumber?minaInfo.hrmsg.phonenumber:'--'}}</el-descriptions-item>
          <el-descriptions-item label="性别">{{minaInfo.hrmsg.sex?minaInfo.hrmsg.sex:'--'}}</el-descriptions-item>
          <el-descriptions-item label="电子邮箱">{{minaInfo.hrmsg.email?minaInfo.hrmsg.email:'--'}}</el-descriptions-item>
      </el-descriptions>
    </div>
    <div class="container normal-panel normal-margin">
      <el-descriptions title="角色信息"></el-descriptions>
      <tableLayout :layout="table_roleinfo" :data="roleData" :opwidth="200" :custom="false">
        <template v-slot:opreation="scope">
          <el-button type="text" size="small" @click="$router.push({path:'/roleDetail',query:{id:scope.data.roleid}})">详 情</el-button>
        </template>
      </tableLayout>
    </div>
  </div>
</template>

<script>
import tableLayout from '../../../components/dynamic-table'

export default {
  components:{
    tableLayout
  },
  data () {
    return {
      minaInfo:{},
      table_userinfo:[],
      table_hrinfo:[],
      table_roleinfo:[],
      list:[],
      hrmsg:[],
      roleData:[]
    }
  },
  methods:{
    async userMian () {
      const res = await this.$api.requested({
        "classname": "webmanage.users.users",
        "method": "query_userMain",
        "content": {
            "userid": this.$route.query.id
        }
      })
      this.minaInfo = res.data
      // 插入用户数据
      let arr = [{
        accountno:res.data.accountno,
        phonenumber:res.data.phonenumber,
        usertypename:res.data.usertypename,
        status:res.data.status
      }]
      this.list = arr
      // 插入人员数据
      if (typeof(res.data.hrmsg) === 'object'){
        res.data.hrmsg.systemname = res.data.name
        let hrmsg = [res.data.hrmsg]
        this.hrmsg = hrmsg
      }
      // 插入角色数据
      this.roleData = res.data.userrole
    }
  },
  mounted () {
    this.userMian()
    // 获取用户信息表结构
    this.table_userinfo = this.tool.tabelCol(this.$route.name).detailUserinfo.tablecols
    // 获取人员表结构
    this.table_hrinfo = this.tool.tabelCol(this.$route.name).detailHrInfo.tablecols
    // 获取角色表结构
    this.table_roleinfo = this.tool.tabelCol(this.$route.name).detailRoleInfo.tablecols
  }
}

</script>
<style>
</style>
<style scoped>
.title{
  height: 20px;
  line-height: 20px;
  font-size: 14px;
  text-indent: 7px;
  font-weight: bold;
  color: #333333;
  margin-bottom: 20px;
  border-left: .3rem solid #3874F6;
}
.mb-40{
  margin-bottom:40px
}
</style>