<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/Userlist'
import PopupEdit from './components/popup/IndexEdit'
import baseTable from '_m/baseTable.js'
export default {
  name: 'Index',
  components: {
    SearchForm,
    PopupEdit,
  },
  provide() {
    return {
      parentData: this
    }
  },
  mixins: [baseTable],
  data() {
    return {
      apiStr: 'other.admlotteryuserlist',
      searchForm: null,
      isDtlShow: false,
      // noCreated: true,
      curObj: {},
    }
  },
  computed: {
    tableData2() {
      const arr = [...this.tableData]
      arr.map(item => {})
      return arr
    }
  },
  created() {},
  mounted() {
    this.listConfig = {
      rows: [
        { label: '用户ID', prop: 'id' },
        { label: '手机号', prop: 'phone' },
        { label: 'openid', prop: 'openid' },
        { label: '可抽卡数', prop: 'lucky1_num' },
        { label: '集满套数', prop: 'lucky2_num' },
        { label: '已中奖', prop: 'is_lottery', type: 'tag', tags: arrToObj(this.$dictData.sys_yesno) },
        { label: '江', prop: 'jiang' },
        { label: '投', prop: 'tou' },
        { label: '青', prop: 'qing' },
        { label: '云', prop: 'yun' },
        { label: '春', prop: 'chun' },
        { label: '天', prop: 'tian' },

        { label: '创建时间', prop: 'create_at' },
        // { label: '操作', width: 200, type: 'handle2', operations:
        //   [
        //     { label: '保存排序', func: this.saveHandle, btnType: 'success' },
        //     { label: '编辑', func: this.openPopup, btnType: 'primary' },
        //     { label: '删除', func: this.delHandle, btnType: 'danger' },
        //   ]
        // }
      ]
    }
  },
  methods: {
    saveHandle (row) {
      this.$api.house.admoldhousesortedit({
        id: row.id,
        sort: row.sort,
      }).then(data => {
        this.$msgs(`已保存！`)
        this.fetchData()
      })
    },
    delHandle(row) {
      this.$msg(`您确定要删除该楼盘吗？`, 'confirm', () => {
        this.$api.house.admoldhousedel({
          id: row.id,
          status: 2
        }).then(data => {
          this.$msgs(`已删除！`)
          this.fetchData()
        })
      }, null, true)
    },
    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>
