<template>
  <div>
    <el-drawer
      :show-close="false"
      :title="curObj.id ? '编辑楼盘摇号信息' : '新增楼盘摇号信息'"
      :wrapper-closable="false"
      :close-on-press-escape="false"
      :visible.sync="isShow"
      size="960px"
      custom-class="xl-drawer"
      direction="rtl"
    >
      <table-list
        :list-loading="listLoading"
        :data="tableData2"
        :columns="listConfig"
        :current-page="currentPage"
        :page-size="pageSize"
        :total-records="totalRecords"
        @currentChange="pageHandle"
        :isAdd="true"
        @add="openLEPopup"
      />
      <div class="xl-form">
        <div class="xl-form-footer fixed" style="width:960px;padding-top: 20px;border-top: 1px solid #dcdcdc;right:0;">
          <el-button class="xl-form-btn t2" @click="close">关 闭</el-button>
        </div>
      </div>
    </el-drawer>
    <lottery-edit
      :isShow="isLEShow"
      :curObj="cObj"
      @close="closeLEPopup"
    />
  </div>
</template>
<script>
import baseTable from '_m/baseTable.js'
import LotteryEdit from './LotteryEdit'
export default {
  components: {
    LotteryEdit
  },
  mixins: [baseTable],
  props: {
    isShow: Boolean,
    curObj: Object
  },
  inject: ['parentData'],
  data() {
    return {
      apiStr: 'house.admpricelist',
      searchForm: {},
      noCreated: true,
      isLEShow: false,
      cObj: {},
    }
  },
  computed: {
    tableData2() {
      const arr = [...this.tableData, {a: '第一期', b1: '2021-05-20', b2: '2021-06-10', c: '#12栋共计192套'}]
      arr.map(item => {
      })
      return arr
    }
  },
  mounted() {
    this.listConfig = {
      rows: [
        { label: '期数', prop: 'a'},
        { label: '摇号中标题', prop: 'c'},
        { label: '开始时间', prop: 'b1'},
        { label: '结束时间', prop: 'b2'},
        { label: '摇号结果标题', prop: 'd'},
        { label: '操作', width: 120, type: 'handle2', operations:
          [
            { label: '编辑', func: this.openLEPopup, btnType: 'primary' },
            { label: '删除', func: this.delHandle, btnType: 'danger' },
          ]
        }
      ]
    }
  },
  watch: {
    isShow: function(val) {
      if (val) {
        // this.$api.house.admestatelotterydetail({estate_id: this.curObj.estate_id}).then(res => {
        //   console.log(res)
        // })
      }
    },
  },
  methods: {
    delHandle(row) {
      this.$msg(`您确定要删除该楼盘吗？`, 'confirm', () => {
        this.$api.house.admpricedel({
          id: row.id,
        }).then(data => {
          this.$msgs(`已删除！`)
          this.fetchData()
        })
      }, null, true)
    },
    openLEPopup(row) {
      this.cObj = {...this.curObj}
      // if (row && row.id) {
      //   this.cObj = row
      // } else {
      //   this.cObj = {}
      // }
      this.isLEShow = true
    },
    closeLEPopup(obj) {
      this.isLEShow = false
      if (obj) {
        this.fetchData()
      }
    },
    close(str) {
      this.$emit('close')
    }
  }
}
</script>
<style lang="scss" scoped>
</style>
