<template>
  <div class="app-container">
    <!-- 搜索区域 -->
    <div class="filter-container">
      <span>机构名称:</span>
      <el-input
        v-model="listQuery.clubName"
        placeholder="机构名称"
        style="width: 200px"
        class="filter-item"
        @keyup.enter.native="getList"
      />
      <span>手机号:</span>
      <el-input v-model="listQuery.mobile" placeholder="手机号" style="width: 200px;" class="filter-item" @keyup.enter.native="handleFilter" />
      <span>处理状态:</span>
      <el-select
        v-model="listQuery.handleStatus"
        placeholder="处理状态"
        clearable
        style="width: 200px"
        class="filter-item"
        @change="getList"
      >
        <el-option label="全部" value="" />
        <el-option label="已处理" :value="1" />
        <el-option label="未处理" :value="0" />
      </el-select>
      <el-button type="primary" icon="el-icon-search" @click="getList">查询</el-button>
    </div>
    <!-- 搜索区域END -->
    <!-- 表格区域 -->
    <el-table
      v-loading="listLoading"
      :data="list"
      style="width: 100%"
      border
      fit
      highlight-current-row
      cell-class-name="table-cell"
    >
      <el-table-column label="序号" :index="indexMethod" type="index" width="80" align="center" />
      <el-table-column type="expand" width="50">
        <template slot-scope="{row}">
          <el-form label-position="left" class="table-expand" label-width="110px">
            <el-form-item label="机构名称：">
              <span>{{ row.clubName }}</span>
            </el-form-item>
            <el-form-item label="手机号：">
              <span>{{ row.mobile }}</span>
            </el-form-item>
            <el-form-item label="提交时间：">
              <span>{{ row.commitTime | formatTime }}</span>
            </el-form-item>
            <el-form-item label="处理状态：">
              <span>
                <el-tag v-if="row.handleStatus === 0" size="small" type="danger">未处理</el-tag>
                <el-tag v-if="row.handleStatus === 1" size="small" type="success">已处理</el-tag>
              </span>
            </el-form-item>
            <el-form-item label="反馈内容：">
              <span style="overflow-wrap:anywhere;text-align:justify">{{ row.content }}</span>
            </el-form-item>
            <el-form-item label="处理结果：">
              <span>{{ row.handleResult }}</span>
            </el-form-item>
          </el-form>
        </template>
      </el-table-column>
      <el-table-column label="机构名称" prop="clubName" align="center" />
      <el-table-column label="手机号" prop="mobile" width="120" align="center" />
      <el-table-column label="反馈内容" prop="content" align="center">
        <template slot-scope="{row}">
          <span class="content">{{ row.content }}</span>
        </template>
      </el-table-column>
      <el-table-column label="提交时间" width="180px" align="center">
        <template slot-scope="{row}">
          <span v-if="row.auditStatus!==2">{{ row.commitTime | formatTime }}</span>
          <span v-else>—</span>
        </template>
      </el-table-column>
      <el-table-column label="处理状态" width="100px" align="center">
        <template slot-scope="{ row }">
          <el-tag v-if="row.handleStatus === 0" size="small" type="danger">未处理</el-tag>
          <el-tag v-if="row.handleStatus === 1" size="small" type="success">已处理</el-tag>
        </template>
      </el-table-column>
      <el-table-column label="处理结果" prop="handleResult" align="center">
        <template slot-scope="{row}">
          <span v-if="row.handleStatus === 1" class="content">{{ row.handleResult }}</span>
          <span v-else>—</span>
        </template>
      </el-table-column>
      <el-table-column label="处理时间" width="180px" align="center">
        <template slot-scope="{row}">
          <span v-if="row.handleStatus === 1">{{ row.handleTime | formatTime }}</span>
          <span v-else>—</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" width="120px" align="center">
        <template slot-scope="{row}">
          <el-button type="primary" size="mini" style="margin-right:5px" icon="el-icon-edit" @click="$_navigationTo(`/feedback/detail?feedbackId=${row.feedbackId}`)">处理</el-button>
        </template>
      </el-table-column>
    </el-table>
    <!-- 表格区域END -->
    <!-- 页码 -->
    <pagination v-show="total > 0" :total="total" :page.sync="listQuery.pageNum" :limit.sync="listQuery.pageSize" @pagination="getList(listQuery)" />
  </div>
</template>

<script>
import Pagination from '@/components/Pagination'
import { formatDate } from '@/utils'
import { mapGetters } from 'vuex'
import { getFeedbackList } from '@/api/auth'
export default {
  components: { Pagination },
  filters: {
    formatTime(time) {
      if (!time) {
        return ''
      }
      return formatDate(time, 'yyyy-MM-DD HH:mm:ss')
    }
  },
  data() {
    return {
      listLoading: false,
      listQuery: {
        authUserId: '',
        clubName: '',
        handleStatus: '',
        mobile: '',
        pageNum: 1, // 页码
        pageSize: 10 // 分页大小
      },
      total: 0,
      list: []
    }
  },
  computed: {
    ...mapGetters(['authUserId', 'userIdentity', 'proxyInfo'])
  },
  created() {
    this.getList()
  },
  methods: {
    // 获取列表数据
    getList() {
      this.listQuery.authUserId = this.authUserId
      console.log(this.listQuery)
      getFeedbackList(this.listQuery).then(res => {
        console.log(res)
        if (res.code !== 0) return
        this.list = res.data.list
        this.total = res.data.total
      }).catch(err => {
        console.log(err)
      })
    },
    // 初始化预览图片列表
    initPreviewList(list) {
      list.forEach(item => this.srcList.push(item.articleCover))
    },
    indexMethod(index) {
      return index + this.listQuery.pageSize * (this.listQuery.pageNum - 1) + 1
    }
  }
}
</script>

<style lang="scss" scoped>
.filter-container {
  span {
    display: inline-block;
    margin-bottom: 10px;
    vertical-align: middle;
    font-size: 14px;
  }
  .el-button {
    display: inline-block;
    margin-bottom: 10px;
    vertical-align: middle;
  }
  .el-input,
  .el-select {
    margin-right: 10px;
    margin-left: 10px;
  }
}
.content{
  display: block;
  overflow: hidden !important;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.el-table .cell {
  overflow: visible;
}
.el-badge{
  margin: 0 6px;
}
// .table-expand {
//     font-size: 0;
//     padding-left: 130px;
//   }
//   .table-expand label {
//     width: 90px;
//     color: #99a9bf;
//   }
//   .table-expand .el-form-item {
//     margin-right: 0;
//     margin-bottom: 0;
//     width: 30%;
//   }
</style>
