<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"
    >
    </table-list>
  </div>
</template>
<script>
import { arrToObj } from '@/utils'
import SearchForm from './components/searchForm/Index'
import baseTable from '_m/baseTable.js'
export default {
  name: 'sys',
  components: {
    SearchForm,
  },
  provide() {
    return {
      parentData: this
    }
  },
  mixins: [baseTable],
  data() {
    return {
      apiStr: 'user.admfeedbacklist',
      searchForm: null,
      isDtlShow: false,
      curObj: {}
    }
  },
  computed: {
    tableData2() {
      const arr = [...this.tableData]
      arr.map(item => {
        const curImg = (item.images || '').split(',')
        console.log(curImg)
        item.img1 = curImg[0] || ''
        item.img2 = curImg[1] || ''
        item.img3 = curImg[2] || ''
        if (item.is_dispose === '1') item.deal1 = true
      })
      return arr
    }
  },
  created() {},
  mounted() {
    this.listConfig = {
      rows: [
        { label: '楼盘名称', prop: 'estate_name' },
        { label: '反馈图1', prop: 'img1', type: 'img' },
        { label: '反馈图2', prop: 'img2', type: 'img' },
        { label: '反馈图3', prop: 'img3', type: 'img' },
        { label: '反馈内容', prop: 'feedback_count', fullShow: true, minWidth: '300' },
        { label: '类型', prop: 'feedback_type', fullShow: true, type: 'flag', flags: arrToObj(this.$dictData.feedback_type) }, 
        { label: '已处理', prop: 'is_dispose', type: 'tag', tags: arrToObj(this.$dictData.sys_yesno) }, 
        { label: '联系方式', prop: 'contact' },
        { label: '微信昵称', prop: 'nickname' },
        { label: '微信头像', prop: 'avatar', type: 'img' },
        { label: '操作', width: 150, type: 'handle2', operations:
          [
            { label: '标记已处理', func: this.dealHandle, btnType: 'primary', hide: 'deal1' },
            { label: '删除', func: this.delHandle, btnType: 'danger' },
          ]
        }
      ]
    }
  },
  methods: {
    dealHandle (row) {
      this.$msg(`您确定要标记成已处理吗`, 'confirm', () => {
        this.$api.user.admfeedbackdispose({
          id: row.id,
          is_dispose: 1,
        }).then(data => {
          this.$msgs(`已处理！`)
          this.fetchData()
        })
      }, null, true)
    },
    delHandle(row) {
      this.$msg(`您确定要删除该文章吗？`, 'confirm', () => {
        this.$api.user.admfeedbackdel({
          id: row.id,
        }).then(data => {
          this.$msgs(`已删除！`)
          this.fetchData()
        })
      }, null, true)
    },
  }
}
</script>
<style lang="scss" scoped>
</style>

