<template>
  <div class="suggestList-page">
    <person-title>当前位置 :: 投诉建议 >> <em>用户反馈</em></person-title>
    <div class="suggestList-list">
      <el-table
        :data="suggestList"
        style="width: 100%">
        <el-table-column
          label="提交时间"
          width="180">
          <template slot-scope="scope">
            <span v-text="timeChange(scope.row.cCreateTime)"></span>
          </template>
        </el-table-column>
        <el-table-column
          prop="cName"
          label="提交人"
          width="180">
        </el-table-column>
        <el-table-column
          prop="cPhone"
          label="联系方式"
          width="180">
        </el-table-column>
        <el-table-column
          prop="cContent"
          label="内容">
        </el-table-column>
      </el-table>
    </div>
  </div>
</template>

<script>
import axios from 'axios'
import {getComplaint} from '../../api/complaint'
import {formData} from '../../unit/formDate'

export default {
  data () {
    return {
      suggestList: []
    }
  },
  created () {
    this.getSuggestList()
  },
  methods: {
    timeChange (time) {
      return formData(time, 'yyyy-MM-dd hh:mm:ss')
    },
    getSuggestList () {
      let loading = this.$loading({lock: true, text: '玩命加载中...'})
      getComplaint().then(res => {
        let data = res.data
        console.log(data.msg)
        if (data.success) {
          this.suggestList = data.data.list
          if (this.suggestList.length === 0) {
            this.$message({
              type: 'info',
              message: '内容为空'
            })
          }
          loading.close()
        } else {
          if (data.msg === '查询结果为空!') {
            this.$message({
              type: 'info',
              message: data.msg
            })
          } else {
            this.$message({
              type: 'error',
              message: data.msg
            })
          }
        }
      })
      loading.close()
    }
  }

}
</script>

<style>

</style>
