<template>
  <ai-detail class="detail">
    <template slot="title">
      <ai-title title="活动详情" isShowBack isShowBottomBorder @onBackClick="cancel(false)">
      </ai-title>
    </template>
    <template slot="content">
      <ai-card title="基本信息">
        <template #content>
          <ai-wrapper
            label-width="120px">
            <ai-info-item label="活动标题" :value="info.title"></ai-info-item>
            <ai-info-item label="活动内容" isLine>
              <AiArticle :value="info.content"></AiArticle>
            </ai-info-item>
            <ai-info-item label="附件" isLine>
              <AiFileList :fileList="info.files"></AiFileList>
            </ai-info-item>
          </ai-wrapper>
        </template>
      </ai-card>
      <ai-card title="报名列表">
        <template #content>
          <ai-table
            :tableData="tableData"
            :col-configs="colConfigs"
            :total="total"
            style="margin-top: 6px;"
            :current.sync="search.current"
            :size.sync="search.size"
            @getList="getList">
            <!-- <el-table-column slot="options" width="90px" fixed="right" label="操作" align="center">
              <template slot-scope="{ row }">
                <div class="table-options">
                  <el-button type="text" @click="toAdd(row.id)">编辑</el-button>
                </div>
              </template>
            </el-table-column> -->
          </ai-table>
        </template>
      </ai-card>
    </template>
  </ai-detail>
</template>

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

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

    data () {
      return {
        colConfigs: [
          { prop: 'userName',  label: '姓名', align: 'left', width: '200px' },
          { prop: 'userPhone', label: '手机号', align: 'center' },
          { prop: 'createTime', label: '报名时间', align: 'center' }
        ],
        search: {
          size: 10,
          current: 1
        },
        tableData: [],
        total: 0,
        info: {}
      }
    },

    created () {
      this.getInfo()
      this.getList()
    },

    methods: {
      getList() {
        this.instance.post(`/app/appactivityinfo/signUpList?activityId=${this.params.id}`, null, {
          params: {
            ...this.search
          }
        }).then(res => {
          if (res.code == 0) {
            this.tableData = res.data.records
            this.total = res.data.total
          }
        })
      },

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

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

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