<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"
      :isAdd="true"
      @add="openPopup"
    >
    </table-list>
    <popup-edit
      :isShow="isDtlShow"
      :curObj="curObj"
      @close="closePopup"
    />
  </div>
</template>
<script>
import { arrToObj } from '@/utils'
import SearchForm from './components/searchForm/Index'
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: 'house.admlandlist',
      searchForm: null,
      isDtlShow: false,
      curObj: {}
    }
  },
  computed: {
    tableData2() {
      const arr = [...this.tableData]
      arr.map(item => {
      })
      return arr
    }
  },
  created() {},
  mounted() {
    this.listConfig = {
      rows: [
        { label: '土拍图', prop: 'pri_image', type: 'img' },
        { label: '地块编号', prop: 'no' },
        { label: '区域', prop: 'area_type', type: 'tag', tags: arrToObj(this.$dictData.area_type) }, 
        { label: '竞得单位', prop: 'company' },
        { label: '成交日期', prop: 'deal_time' },
        { label: '成交价(万元/亩)', prop: 'final_price' },
        { label: '成交楼面价(元)', prop: 'floor_price' },
        { label: '起拍价(万元/亩)', prop: 'start_total_price' },
        { label: '起拍单价(元)', prop: 'start_unit_price' },
        { label: '溢价率(%)', prop: 'premium_rate' },
        { label: '出让面积(亩)', prop: 'sell_area' },
        { label: '建筑面积(㎡)', prop: 'built_area' },
        { label: '出让年限(年)', prop: 'sell_ownership' },
        { label: '用途', prop: 'purpose' },
        { label: '容积率', prop: 'plot_ratio' },
        { label: '操作', width: 120, type: 'handle2', operations:
          [
            { label: '编辑', func: this.openPopup, btnType: 'primary' },
            { label: '删除', func: this.delHandle, btnType: 'danger' },
          ]
        }
      ]
    }
  },
  methods: {
    delHandle(row) {
      this.$msg(`您确定要删除该文章吗？`, 'confirm', () => {
        this.$api.house.admlanddel({
          id: row.id,
        }).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>
<style lang="scss" scoped>
.scoped-link {
  color: #2d8cf0;
  text-decoration: underline;
}
</style>

