<template>
  <ai-detail isHasSidebar>
    <template slot="title">
      <ai-title title="社区管理详情" isShowBack isShowBottomBorder @onBackClick="cancel(false)">
      </ai-title>
    </template>
    <template slot="content">
      <AiSidebar :tabTitle="tabList" v-model="currIndex"></AiSidebar>
      <div v-show="currIndex === 0">
        <ai-card title="基本信息" v-show="currIndex === 0">
          <template #content>
            <ai-wrapper
              label-width="120px">
              <ai-info-item label="管理对象" :value="info.name"></ai-info-item>
              <ai-info-item label="对象类型" :value="dict.getLabel('EP_registerInfoType', info.infoType)"></ai-info-item>
              <ai-info-item label="身份证" :value="info.idNumber"></ai-info-item>
              <ai-info-item label="手机号" :value="info.phone"></ai-info-item>
              <ai-info-item label="所属地区" :value="info.areaName" isLine></ai-info-item>
              <ai-info-item label="居家状态" :value="dict.getLabel('EP_homeStatus2', info.homeStatus)"></ai-info-item>
              <ai-info-item label="隔离时间" :value="info.quarantineBeginTime ? info.quarantineBeginTime.split(' ')[0] + ' - ' + info.quarantineEndTime.split(' ')[0] : ''"></ai-info-item>
              <ai-info-item label="隔离策略 " :value="dict.getLabel('EP_quarantineStrategy', info.quarantineStrategy)"></ai-info-item>
              <ai-info-item label="管控人" :value="info.controllerUserName"></ai-info-item>
              <ai-info-item label="联系方式" :value="info.controllerUserPhone"></ai-info-item>
              <ai-info-item label="管理内容" isLine :value="info.controllerContent"></ai-info-item>
              <ai-info-item label="图片" isLine>
                <ai-uploader
                  :instance="instance"
                  :value="info.fileList"
                  disabled
                  :limit="9">
                </ai-uploader>
              </ai-info-item>
            </ai-wrapper>
          </template>
        </ai-card>
      </div>
      <div v-show="currIndex === 1">
        <ai-card title="核酸详情">
          <template #content>
            <ai-table
              :isShowPagination="false"
              tableSize="small"
              border
              :tableData="info.nucleicAcidSamplingList"
              :col-configs="colConfigs"
              @getList="() => {}">
            </ai-table>
          </template>
        </ai-card>
      </div>
    </template>
  </ai-detail>
</template>

<script>
  export default {
    name: 'Detail',

    props: {
      instance: Function,
      dict: Object,
      params: Object
    },

    data () {
      return {
        total: 0,
        info: {},
        search: {
          current: 1,
          size: 10
        },
        currIndex: 0,
        colConfigs: [
          { prop: 'createUserName', label: '采样人', align: 'center' },
          { prop: 'createUserPhone', label: '联系方式', align: 'center'},
          { prop: 'createTime', label: '采样时间', align: 'center' }
        ],
        tabList: ['基本信息', '核酸详情']
      }
    },

    created () {
      if (this.params && this.params.id) {
        this.id = this.params.id
        this.$dict.load(['EP_CM_status', 'EP_registerInfoType', 'EP_homeStatus2', 'EP_quarantineStrategy']).then(() => {
          this.getInfo(this.params.id)
        })

        this.getList()
      }
    },

    methods: {
      getInfo (id) {
        this.instance.post(`/app/appepidemicpreventioncommunitymanagement/queryDetailById?id=${id}`).then(res => {
          if (res.code === 0) {
            this.info = res.data
          }
        })
      },

      getList () {
        this.instance.post(`/app/appepidemicunusuallog/list`, null, {
          params: {
            ...this.search,
            recordId: this.params.id
          }
        }).then(res => {
          if (res.code == 0) {
            this.tableData = res.data.records
            this.total = res.data.total
          }
        })
      },

      cancel () {
        this.$emit('change', {
          type: 'List',
          isRefresh: true
        })
      }
    }
  }
</script>

<style scoped lang="scss">
  .color-0{
    color: #42D784;
  }
  .color-1{
    color: #f46;
  }
  .color-2{
    color: #1365DD;
  }
</style>
