<!--投诉建议查询-->
<template>
  <div class="app-container">
    <el-form ref="queryForm" :inline="true" :model="queryParams" label-width="68px" size="small">
      <el-form-item label="类型">
        <el-select v-model="queryParams.type" clearable>
          <el-option label="服务体验" value="服务体验"/>
          <el-option label="景区建议" value="景区建议"/>
          <el-option label="环境问题" value="环境问题"/>
          <el-option label="治安问题" value="治安问题"/>
          <el-option label="实名举报" value="实名举报"/>
          <el-option label="其他问题" value="其他问题"/>
        </el-select>
      </el-form-item>
      <el-form-item label="提交时间">
        <el-date-picker
          v-model="dateRange"
          end-placeholder="结束日期"
          range-separator="-"
          start-placeholder="开始日期"
          style="width: 240px"
          type="daterange"
          value-format="yyyy-MM-dd"></el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button icon="el-icon-search" size="mini" type="primary" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <el-table v-loading="loading" :data="tableData">
      <el-table-column label="序号" type="index"></el-table-column>
      <el-table-column label="提交时间" prop="createTime"></el-table-column>
      <el-table-column label="联系电话" prop="phone"></el-table-column>
      <el-table-column label="联系人" prop="username"></el-table-column>
      <el-table-column label="类型" prop="type"></el-table-column>
      <el-table-column label="内容" prop="content" width="300"></el-table-column>
      <el-table-column label="附件" width="300">
        <template slot-scope="scope">
          <file-upload v-model="scope.row.file" :disable="true"></file-upload>
        </template>
      </el-table-column>
    </el-table>
    <pagination
      v-show="total>0"
      :limit.sync="queryParams.pageSize"
      :page.sync="queryParams.pageNum"
      :total="total"
      @pagination="getList"/>
  </div>
</template>
<script>
import {page} from '@/api/liandao/complaintSuggestions.js'

export default {
  name: "complaintSuggestions",
  created() {
    this.getList()
  },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 查询参数
      queryParams: {
        type:'',
        pageNum: 1,
        pageSize: 10,
        startTime: undefined,
        endTime: undefined,
      },
      //表格数据
      tableData: [],
      // 总数
      total: 0,
      result: [],
      dateRange: [],
      open: false,
    }
  },
  methods: {
    /** 查询数据列表 */
    getList() {
      this.loading = true;
      if (this.dateRange && this.dateRange.length > 0) {
        this.queryParams.startTime = this.dateRange[0]
        this.queryParams.endTime = this.dateRange[1]
      }
      page(this.queryParams).then(resp => {
          if (resp.code == 200) {
            this.tableData = resp.rows;
            this.total = resp.total;
            this.loading = false;
          }
        }
      );
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.queryParams.startTime = undefined
      this.queryParams.endTime = undefined
      this.queryParams.type = ''
      this.dateRange = []
      this.handleQuery();
    },
  }
}
</script>
