<template>
  <section class="hrDetail">
    <ai-detail>
      <ai-title slot="title" title="监测对象详情" isShowBottomBorder isShowBack @onBackClick="back"/>
      <template #content>
        <el-form :model="detail" label-width="130px" label-position="right" size="small">
          <ai-card :title="detail.name||'无名氏'">
            <template #content>
              <div flex class="flex-start">
                <div flex class="half wrap fill">
                  <el-form-item label="身份证号" prop="name">{{ detail.idNumber }}</el-form-item>
                  <el-form-item label="性别" prop="sex">{{ dict.getLabel('sex', detail.sex) }}</el-form-item>
                  <el-form-item label="出生日期" prop="birthday">{{ detail.birthday }}</el-form-item>
                  <el-form-item label="年龄" prop="age">{{ detail.age }}</el-form-item>
                  <el-form-item label="文化程度">{{ dict.getLabel('education', detail.education) }}</el-form-item>
                  <el-form-item label="民族">{{ dict.getLabel('nation', detail.nation) }}</el-form-item>
                  <el-form-item label="政治面貌">{{ dict.getLabel('politicsStatus', detail.politicsStatus) }}</el-form-item>
                  <el-form-item label="在校生状况">{{ dict.getLabel('education', detail.education) }}</el-form-item>
                  <el-form-item label="健康状况">{{ dict.getLabel('education', detail.education) }}</el-form-item>
                  <el-form-item label="务工时间(月)" prop="idNumber">{{ detail.education }}</el-form-item>
                  <el-form-item label="劳动技能">{{ dict.getLabel('education', detail.education) }}</el-form-item>
                  <el-form-item label="务工区域" prop="idNumber">{{ detail.education }}</el-form-item>
                  <el-form-item label="是否参加大病保险">{{ dict.getLabel('yesOrNo', detail.education) }}</el-form-item>
                  <el-form-item label="是否参加基本医保">{{ dict.getLabel('yesOrNo', detail.education) }}</el-form-item>
                  <el-form-item label="享受最低生活保障">{{ dict.getLabel('yesOrNo', detail.education) }}</el-form-item>
                  <el-form-item label="是否参加养老保险">{{ dict.getLabel('yesOrNo', detail.education) }}</el-form-item>
                  <el-form-item label="是否特困供养">{{ dict.getLabel('yesOrNo', detail.education) }}</el-form-item>
                </div>
                <ai-avatar :instance="instance" v-model="detail.photo" :editable="false"/>
              </div>
            </template>
          </ai-card>
          <ai-card title="联络信息">
            <template slot="content">
              <el-form-item label="联系方式" prop="phone">{{ detail.phone }}</el-form-item>
              <el-form-item label="现住址">{{ detail.currentAreaName }}{{ detail.currentAddress }}</el-form-item>
            </template>
          </ai-card>
          <ai-card title="家庭情况">
            <template slot="content">
              <div flex class="half wrap">
                <el-form-item label="是否户主" prop="householdName">
                  {{ dict.getLabel('householdName', detail.householdName) }}
                </el-form-item>
                <template v-if="detail.householdName==1">
                  <el-form-item label="监测对象类型" prop="militaryStatus">
                    {{ dict.getLabel('householdName', detail.householdName) }}
                  </el-form-item>
                  <el-form-item label="是否危房" prop="militaryStatus">
                    {{ dict.getLabel('yesOrNo', detail.householdName) }}
                  </el-form-item>
                  <el-form-item label="是否饮用水安全" prop="militaryStatus">
                    {{ dict.getLabel('yesOrNo', detail.householdName) }}
                  </el-form-item>
                  <el-form-item label="是否搬迁" prop="militaryStatus">
                    {{ dict.getLabel('yesOrNo', detail.householdName) }}
                  </el-form-item>
                </template>
                <template v-if="detail.householdName==0">
                  <el-form-item label="与户主关系">
                    {{ dict.getLabel('householdRelation', detail.householdRelation) }}
                  </el-form-item>
                  <el-form-item label="户主身份证号">{{ detail.householdIdNumber }}</el-form-item>
                </template>
              </div>
            </template>
          </ai-card>
        </el-form>
      </template>
    </ai-detail>
  </section>
</template>

<script>
export default {
  name: "hrDetail",
  props: {
    instance: Function,
    dict: Object,
    permissions: Function
  },
  data() {
    return {
      detail: {}
    }
  },
  methods: {
    back() {
      this.$router.push({})
    },
    getDetail() {
      let {id} = this.$route.query
      id && this.instance.post("/appportaluserenterprise/queryDetailById", null, {
        params: {id}
      }).then(res => {
        if (res?.data) {
          this.detail = res.data
        }
      })
    },
  },
  created() {
    this.getDetail()
  }
}
</script>

<style lang="scss" scoped>
.hrDetail {
  height: 100%;

  .flex-start {
    align-items: flex-start;

    .AiAvatar {
      margin-left: 20px;
    }
  }

  .half {
    align-items: flex-start;

    & > .el-form-item, & > div {
      width: 50%;

      .el-form-item {
        width: 100%;
      }
    }
  }

  .el-date-editor {
    width: 100%;
  }
}
</style>
