<template>
  <a-card :body-style="{padding: '24px 32px'}" :bordered='false'>

    <div class='back' @click='backPage'>
      <a-icon type='rollback' />
      <div class='label'>返回</div>
    </div>
    <div style='display: flex;margin-bottom: 20px'>
      <span style='width: 20px;display: block;font-size: 25px;color: #1890ff;font-weight: bold;'>|</span>
      <span style='display: block;margin-top: 11px;font-size: 15px'>访客详情</span>
    </div>
    <a-form-model :model='form' :label-col='labelCol' :wrapper-col='wrapperCol'>
      <a-row>
        <a-col :span='10'>
          <a-form-item :labelCol='labelCol' :wrapperCol='wrapperCol' label='地区'>
            {{ form.userName }}
          </a-form-item>
        </a-col>
        <a-col :span='10'>
          <a-form-item :labelCol='labelCol' :wrapperCol='wrapperCol' label='园区'>
            {{ form.tenantName }}
          </a-form-item>
        </a-col>
      </a-row>
      <a-row>
        <a-col :span='10'>
          <a-form-item :labelCol='labelCol' :wrapperCol='wrapperCol' label='被访单位'>
            {{ form.customerName }}
          </a-form-item>
        </a-col>
      </a-row>
      <a-row>
        <a-col :span='10'>
          <a-form-item :labelCol='labelCol' :wrapperCol='wrapperCol' label='被访人员'>
            {{ form.userName }}
          </a-form-item>
        </a-col>
        <a-col :span='10'>
          <a-form-item :labelCol='labelCol' :wrapperCol='wrapperCol' label='被访人联系方式'>
            {{ form.userMobile }}
          </a-form-item>
        </a-col>
      </a-row>
      <a-row>
        <a-col :span='10'>
          <a-form-item :labelCol='labelCol' :wrapperCol='wrapperCol' label='来访人照片'>
            <img :src='baseUrl + form.photo' style='max-width: 80px; max-height: 80px'>
          </a-form-item>
        </a-col>
      </a-row>
      <a-row>
        <a-col :span='10'>
          <a-form-item :labelCol='labelCol' :wrapperCol='wrapperCol' label='来访人姓名'>
            {{ form.name }}
          </a-form-item>
        </a-col>
        <a-col :span='10'>
          <a-form-item :labelCol='labelCol' :wrapperCol='wrapperCol' label='来访人联系方式'>
            {{ form.phone }}
          </a-form-item>
        </a-col>
      </a-row>
      <a-row>
        <a-col :span='10'>
          <a-form-item :labelCol='labelCol' :wrapperCol='wrapperCol' label='到访时间'>
            {{ form.visitTime }}
          </a-form-item>
        </a-col>
        <a-col :span='10'>
          <a-form-item :labelCol='labelCol' :wrapperCol='wrapperCol' label='身份证类型'>
            {{ form.cardType }}
          </a-form-item>
        </a-col>
      </a-row>
      <a-row>
        <a-col :span='10'>
          <a-form-item :labelCol='labelCol' :wrapperCol='wrapperCol' label='离开时间'>
            {{ form.leaveTime }}
          </a-form-item>
        </a-col>
        <a-col :span='10'>
          <a-form-item :labelCol='labelCol' :wrapperCol='wrapperCol' label='身份证号'>
            {{ form.cardNo }}
          </a-form-item>
        </a-col>
      </a-row>
      <a-row>
        <a-col :span='10'>
          <a-form-item :labelCol='labelCol' :wrapperCol='wrapperCol' label='来访事由'>
            {{ form.visitContent }}
          </a-form-item>
        </a-col>
      </a-row>
      <a-row>
        <a-col :span='10'>
          <a-form-item :labelCol='labelCol' :wrapperCol='wrapperCol' label='审核人'>
            {{ form.updateBy }}
          </a-form-item>
        </a-col>
        <a-col :span='10'>
          <a-form-item :labelCol='labelCol' :wrapperCol='wrapperCol' label='审批时间'>
            {{ form.updateTime }}
          </a-form-item>
        </a-col>
      </a-row>
    </a-form-model>
    <div style='display: flex;margin-bottom: 20px'>
      <span style='width: 20px;display: block;font-size: 25px;color: #1890ff;font-weight: bold;'>|</span>
      <span style='display: block;margin-top: 11px;font-size: 15px'>进出记录</span>
    </div>
    <a-table
      class='dataTable'
      :columns='columns'
      :data-source='recordList'
      size='default'
      ref='table'
      bordered
    >
    </a-table>
  </a-card>
</template>

<script>
import { STable } from '@/components'
import { get, personList } from '@/api/admin/meeting/reservation'
import { getVisitorPersonId,getRecordByReservationId } from '@/api/admin/meeting/visitorPerson'




export default {
  name: 'reservationInfo',
  components: {
    STable
  },
  data() {
    return {
      baseUrl: process.env.VUE_APP_API_BASE_URL,
      labelCol: { span: 12 },
      wrapperCol: { span: 10 },
      form: {
        roomContent: {}
      },
      queryParam: {
        reservationId: this.$route.query.id
      },
      columns: [
        {
          title: '姓名',
          dataIndex: 'userName'
        },
        {
          title: '联系方式',
          dataIndex: 'userPhone'
        },
        {
          title: '进场时间',
          dataIndex: 'createTime'
        },
      ],
      recordList:[],
      dataList: [
        {
          name: 'wqc'
        }
      ],
      // 加载数据方法 必须为 Promise 对象
      loadData: parameter => {
        return personList(Object.assign(parameter, this.queryParam))
      },
      actualNum : null,
      attainNum : null
    }
  },
  created() {
    this.getDetail()
    this.getRecordByReservationId()
    personList({
      reservationId: this.$route.query.id
    }).then(res => {
      this.actualNum = res.actualNum
      this.attainNum = res.attainNum
    })
  },
  methods: {
    getRecordByReservationId(){
      getRecordByReservationId(this.$route.query.id).then(res => {
        this.recordList = res.data
      })
    },

    getDetail() {
      getVisitorPersonId(this.$route.query.id).then(res => {
        console.log('getDetail', res)
        this.form = res
        console.log(this.form)
      })
    },
    backPage() {
      this.$router.back()
    }
  }
}
</script>

<style scoped>
.back {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding-right: 100px;
  cursor: pointer;
}

.back .label {
  margin-left: 4px;
}

.recordHeadView {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 1000px;
  margin: 14px auto;
  color: black;
}

.recordHeadView .shidarenshu {
  margin-left: 50px;
}

.recordHeadView .search {
  display: flex;
  justify-content: center;
  align-items: center;
}

.recordHeadView .search .searchInput {
  flex: 1;
}

.dataTable {
  width: 1000px;
  margin: 0 auto;
}

</style>