<template>
  <div class="app-container">
    <search-form
      :list-loading="listLoading"
      @change="searchHandle"
    />
    <table-list
      :list-loading="listLoading"
      :data="tableData2"
      :columns="listConfig"
      :current-page="currentPage"
      :page-size="pageSize"
      :total-records="totalRecords"
      @currentChange="pageHandle"
      @sizeChange="sizeChange"
    />
  </div>
</template>
<script>
import { arrToObj } from '@/utils'
import SearchForm from './components/searchForm/Prizeulist'
import baseTable from '_m/baseTable.js'
export default {
  name: 'Index',
  components: {
    SearchForm,
  },
  provide() {
    return {
      parentData: this
    }
  },
  mixins: [baseTable],
  data() {
    return {
      apiStr: 'other.admlotteryprizeuserlist',
      searchForm: null,
      isDtlShow: false,
      // noCreated: true,
      curObj: {},
    }
  },
  computed: {
    tableData2() {
      const arr = [...this.tableData]
      arr.map(item => {
        if (item.is_handle == 1) item.isEd = true
      })
      return arr
    }
  },
  created() {},
  mounted() {
    this.listConfig = {
      rows: [
        { label: '手机号', prop: 'phone' },
        { label: '已核销', prop: 'is_handle', type: 'tag', tags: arrToObj(this.$dictData.sys_yesno) },
        { label: '奖品', prop: 'prize' },
        { label: 'openid', prop: 'openid' },
        { label: '用户id', prop: 'user_id' },
        { label: '创建时间', prop: 'create_at' },
        { label: '操作', width: 80, type: 'handle2', operations:
          [
            { label: '核销', func: this.dealHandle, btnType: 'primary', hide: 'isEd' },
          ]
        }
      ]
    }
  },
  methods: {
    dealHandle (row) {
      this.$msg(`确定核销${row.phone}吗？`, 'confirm', () => {
        this.$api.other.admlotteryprixchange({
          id: row.id
        }).then(data => {
          this.$msgs(`已核销！`)
          this.fetchData()
        })
      }, null, true)
    },
  }
}
</script>
