<style scoped>
  .expand-row{
      margin-bottom: 16px;
  }
</style>
<template>
  <div>
    <Table style="margin: 1px" height="360" :columns="columns2" :data="tablelist">
      <template slot-scope="{ row }" slot="text">
        {{row.text}}
        <Tag style="margin-left:10px" color="purple" v-if="row.type_icon">{{row.type_icon}}</Tag>
      </template>
      <template slot-scope="{ row }" slot="buttons">
        <Button type="success" class="mr5" size="small" @click="handle(row)">办理</Button>
      </template>
    </Table>
  </div>
</template>
<script>
import { itemtodolistForCSC } from '@/api/mainv3'
export default {
  props: {
    params: Object
  },
  data () {
    return {
      text: '',
      loadData: true,
      columns2: [
        { title: '事项名称', slot: 'text', width: 600 },
        { title: '级别', key: 'type_name', align: 'center', width: 150 },
        { title: '操作', align: 'center', className: 'nopadding', slot: 'buttons' }
      ],
      tablelist: []
    }
  },
  watch: {
  },
  methods: {
    async getList () {
      let params = this.params
      let temp1 = []
      let temp2 = []
      let temp3 = []
      itemtodolistForCSC().then(ret => {
        if (ret.data.errcode === 0) {
          console.log('@@@@@@')
          let array = []
          array = ret.data.data[2].datalist || []
          array.forEach(element => {
            if (element.text.indexOf('低收入住房困难家庭（廉租住房）') !== -1) {
              temp1.push(element)
            }
            if (element.text.indexOf('公共租赁住房') !== -1) {
              temp2.push(element)
            }
            if (element.text.indexOf('住宅房屋租赁') !== -1) {
              temp3.push(element)
            }
          })
          this.loadData = false
        } else {
          this.loadData = true
        }
        if (params.row.text === '公共租赁住房') {
          this.tablelist = temp2
        } else if (params.row.text === '低收入住房困难家庭（廉租住房）') {
          this.tablelist = temp1
        } else if (params.row.text === '住宅房屋租赁') {
          this.tablelist = temp3
        }
      })
    },
    handle (item) {
      this.$emit('handleItem', item)
    }
  },
  mounted () {
    this.getList()
  }
}
</script>
