<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"
    />
    <popup-edit
      :isShow="isDtlShow"
      :curObj="curObj"
      @close="closePopup"
    />
  </div>
</template>
<script>
import { arrToObj } from '@/utils'
import SearchForm from './components/searchForm/Charlist'
import PopupEdit from './components/popup/Charlist'
import baseTable from '_m/baseTable.js'
export default {
  name: 'Index',
  components: {
    SearchForm,
    PopupEdit,
  },
  provide() {
    return {
      parentData: this
    }
  },
  mixins: [baseTable],
  data() {
    return {
      apiStr: 'other.admlotterycharlist',
      searchForm: null,
      isDtlShow: false,
      // noCreated: true,
      curObj: {},
    }
  },
  computed: {
    tableData2() {
      const arr = [...this.tableData]
      arr.map(item => {
        if (item.total === 0 && item.name !== '春') {
          item.total = '999'
        }
      })
      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>
