<!--
  @description: app菜单列表
  @Modifier: zxl
  @routerPath:
  @date: 2020-2-20-14:56
-->
<template>
  <div>
    <table-crud
      ref="tableCrud"
      :search-form.sync="searchForm"
      search-label-width="100px"
      :menu="true"
      @on-load="loadData"
    >
      <template v-slot:header>
        反馈信息
      </template>
      <template v-slot:search="search">
        <el-form-item label="用户名称" prop="userName">
          <el-input v-model.trim="searchForm.userName" placeholder="请输入" @keyup.enter.native="search.onSearch" />
        </el-form-item>
        <el-form-item label="真实姓名" prop="realName">
          <el-input v-model.trim="searchForm.realName" placeholder="请输入" @keyup.enter.native="search.onSearch" />
        </el-form-item>
      </template>
      <!--      <template v-slot:menuLeft>
        <el-button type="primary" @click="addMenu">
          新增
        </el-button>
      </template>-->
      <template v-slot:GXTable>
        <el-table
          ref="smallTable"
          v-loading="loading"
          :data="tableData"
        >
          <el-table-column
            type="index"
            label="序号"
            align="center"
            width="60"
          />
          <el-table-column
            header-align="center"
            prop="feedback"
            label="意见反馈"
            min-width="230"
          />
          <el-table-column
            header-align="center"
            prop="phone"
            label="联系电话"
            min-width="180"
            align="center"
          />

          <!--
          <el-table-column
            header-align="center"
            prop="createUser"
            label="创建人"
            min-width="180"
            align="center"
          />
-->

          <el-table-column
            header-align="center"
            prop="userName"
            label="用户名称"
            min-width="180"
            align="center"
          />
          <el-table-column
            header-align="center"
            prop="realName"
            label="真实姓名"
            min-width="180"
            align="center"
          />
          <el-table-column
            header-align="center"
            prop="createTime"
            label="创建时间"
            min-width="180"
            align="center"
          />
          <el-table-column label="操作" align="center" width="125">
            <template slot-scope="scope">
              <el-link
                type="primary"
                @click="toDetail(scope.row)"
              >
                [查看详情]
              </el-link>
            </template>
          </el-table-column>
        </el-table>
      </template>
    </table-crud>

    <!--    <platform-add-dialog v-if="dialogData.flag" :dialog-data="dialogData" @change="callBack" />-->
    <feedback-detail-dialog v-if="dialogData.flag" :dialog-data="dialogData" />
  </div>
</template>

<script>

/* 混合开发方法-参数字段*/
import { filterDictText } from '../../../assets/js/utils'
import { queryFeedbackListPage } from '../../../api/appManagement/feedback'
import feedbackDetailDialog from './feedbackDetail-dialog'
export default {
  components: {
    feedbackDetailDialog
  },
  data() {
    return {
      loading: true,
      searchForm: {
        userName: '', // 用户名称
        realName: ''// 真实姓名
      },
      tableData: [],
      dialogData: {
        flag: false,
        row: null
      }
    }
  },
  created() {
    this.initGroup()
  },
  methods: {
    filterDictText, // 字典值替换文本通用方法
    // 字典请求
    initGroup() {
      this.$store.dispatch('getGroupType', ['appType', 'appCategory']).then((data) => {
        // 遍历key存储相应的数据
        for (const key in data.bidTypeData) {
          /* 是否有数据*/
          if (data.bidTypeData[key]) {
            this[key] = data.bidTypeData[key]
          }
        }
      })
    },
    // 获取数据
    loadData(params, callback) {
      queryFeedbackListPage(params).then(response => {
        this.tableData = response.data.records
        this.loading = false
        callback(response.data.total)
      }).catch(() => {
        this.loading = false
      })
    },
    addMenu() {
      this.dialogData.row = null
      this.dialogData.flag = true
    },
    toDetail(row) {
      this.dialogData.row = row
      this.dialogData.flag = true
    },
    toDel(row, index) {
      this.$confirm('确认是否删除该条数据？', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        confirmButtonClass: 'confirmBtn',
        cancelButtonClass: 'cancelBtn',
        type: 'warning'
      }).then(() => {
        /*    delAppPlatformConfig({ id: row.id }).then(res => {
          this.tableData.splice(index, 1)
        }).catch(() => {
        })*/
      }).catch(() => {
      })
    },
    // 详情
    handleDetail(row) {

    },
    // 操作回调
    callBack() {
      this.$refs.tableCrud.onSearchChange()
    }
  }
}
</script>

<style lang="less" scoped>
.img_pic {
  max-height: 50px;
}
</style>
