<template>
  <ai-detail>
    <template slot="title">
      <ai-title title="详情" isShowBack isShowBottomBorder @onBackClick="cancel(false)">
      </ai-title>
    </template>
    <template slot="content">
      <AiSidebar :tabTitle="tabList" v-model="currIndex"></AiSidebar>
      <ai-card title="基本信息" v-show="currIndex === 0">
        <template #content>
          <ai-wrapper
            label-width="80px">
            <ai-info-item label="添加渠道" value="1231313"></ai-info-item>
            <ai-info-item label="添加渠道" value="1231313"></ai-info-item>
            <ai-info-item label="添加渠道" value="1231313"></ai-info-item>
            <ai-info-item label="添加渠道" value="1231313"></ai-info-item>
            <ai-info-item label="添加渠道" value="1231313"></ai-info-item>
            <ai-info-item label="添加渠道" value="1231313"></ai-info-item>
          </ai-wrapper>
        </template>
      </ai-card>
      <ai-card title="报名情况" v-show="currIndex === 1">
        <template #content>
          <ai-table
            class="detail-table__table"
            :border="true"
            :tableData="tableData"
            :col-configs="colConfigs"
            :total="total"
            :current.sync="search.current"
            :size.sync="search.size"
            :stripe="false"
            @getList="getList">
          </ai-table>
        </template>
      </ai-card>
      <ai-card title="活动动态" v-show="currIndex === 2">
        <template #content>
          <Dynamic :instance="instance" :dict="dict" :id="params.id" v-show="currIndex === 2"></Dynamic>
        </template>
      </ai-card>
    </template>
  </ai-detail>
</template>

<script>
  import Dynamic from './Dynamic'
  export default {
    name: 'Detail',

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

    components: {
      Dynamic
    },

    data () {
      return {
        total: 11,
        info: {},
        id: '',
        search: {
          current: 1,
          size: 10
        },
        currIndex: 0,
        tableData: [],
        colConfigs: [
          {slot: 'userinfo'},
          {prop: 'addWay', label: '客户来源', align: 'center', formart: v => this.dict.getLabel('wxCustomerAddWay', v)},
          {prop: 'createTime', label: '添加时间', align: 'center'}
        ],
        tabList: ['基本信息', '报名情况', '活动动态']
      }
    },

    created () {
      if (this.params && this.params.id) {
        this.id = this.params.id
        this.getInfo(this.params.id)
      }
    },

    methods: {
      getInfo (id) {
        this.instance.post(`/app/appeveryvillagecode/queryDetailById?id=${id}`).then(res => {
          if (res.code === 0) {
            this.form = res.data
            this.form.codeUrl = [{
              url: res.data.codeUrl
            }]
          }
        })
      },

      getList () {

      },

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

<style scoped lang="scss">
</style>
