<template>
  <div>
    <el-button type="primary" @click="handleAdd" v-if="hasAdd">申请新的活动</el-button>
    <div style="height: 20px"></div>
    <table-list :remote="remote" :columns="columns" ref="tableList"></table-list>
  </div>
</template>

<script>
import listMixins from '../../mixins/list'

export default {
  mixins: [listMixins],
  data() {
    return {
      columns: [
        { prop: 'form.symposium_name', label: '活动名称' },
        { prop: 'form.symposium_time', label: '活动时间' },
        { prop: 'form.symposium_lecturer', label: '主讲人' },
        { prop: 'status_name', label: '审批状态' },
        { prop: 'approve_time1', label: '审批时间' },
        { prop: 'remark1', label: '审批备注' },
        {
          label: '操作',
          attrs: { width: '200' },
          buttons: [
            {
              label: '查看报告',
              isShow(row) {
                return row.form.reportscount !== '0'
              },
              onClick: row => {
                this.$router.push({
                  path: `/app/affairs-hall/view-report/${row.form.id}`
                })
                // this.$router.push({ name: 'activityReportView', query: { id: row.form.id } })
              }
            },
            {
              label: '上传报告',
              isShow(row) {
                const isPass = [1, 2, 4].includes(row.status)
                return isPass && row.form.reportscount === '0'
              },
              onClick: row => {
                this.$router.push({
                  path: `/app/affairs-hall/upload-report/${row.form.id}/-1`
                })

                // this.$router.push({ name: 'activityReportEdit', query: { id: row.form.id } })
              }
            },
            {
              label: '查看',
              isShow(row) {
                return row.status !== -1
              },
              onClick: row => {
                this.$router.push({ name: 'activityView', params: { id: row.id }, query: { id: row.affair_id } })
              }
            },
            {
              label: '编辑',
              isShow(row) {
                return row.status === -1
              },
              onClick: row => {
                this.$router.push({ name: 'activityEdit', params: { id: row.id }, query: { id: row.affair_id } })
              }
            },
            {
              label: '删除',
              isShow(row) {
                return row.status === -1
              },
              onClick: row => {
                this.handleRemove(row)
              }
            }
          ]
        }
      ]
    }
  },
  methods: {
    // 新增
    handleAdd() {
      this.$router.push({ name: 'activityAdd', query: { id: this.affairId } })
    }
  }
}
</script>
