<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"
      :isAdd="true"
      @add="openPopup"
      :operationsDefaultLength="5"
    />
    <popup-edit
      :isShow="isDtlShow"
      :curObj="curObj"
      @close="closePopup"
    />
  </div>
</template>
<script>
import { arrToObj } from '@/utils'
import SearchForm from './components/searchForm/Prizelist'
import PopupEdit from './components/popup/Prizelist'
import baseTable from '_m/baseTable.js'
export default {
  name: 'Index',
  components: {
    SearchForm,
    PopupEdit,
  },
  provide() {
    return {
      parentData: this
    }
  },
  mixins: [baseTable],
  data() {
    return {
      apiStr: 'other.admlotteryprizelist',
      searchForm: null,
      isDtlShow: false,
      // noCreated: true,
      curObj: {},
    }
  },
  computed: {
    tableData2() {
      const arr = [...this.tableData]
      arr.map(item => {
        item.pri_image = this.IMadd(item.pri_image)
      })
      return arr
    }
  },
  created() {},
  mounted() {
    this.listConfig = {
      rows: [
        { label: '字', prop: 'name' },
        { label: '概率', prop: 'v' },
        { label: '剩余数量', prop: 'total' },
        { label: '操作', width: 80, type: 'handle2', operations:
          [
            { label: '设置', func: this.openPopup, btnType: 'primary' },
          ]
        }
      ]
    }
  },
  methods: {
    openPopup(row) {
      if (row && row.id) {
        this.curObj = row
      } else {
        this.curObj = {}
      }
      this.isDtlShow = true
    },
    closePopup(obj) {
      this.isDtlShow = false
      if (obj) {
        this.fetchData()
      }
    }
  }
}
</script>
