<template>
  <div class="app-container">
    <!-- 搜索区域 -->
    <div class="filter-container">
      <span>图片标题:</span>
      <el-input
        v-model="listQuery.imageTitle"
        placeholder="文章标题"
        style="width: 200px"
        class="filter-item"
        @keyup.enter.native="getList"
      />
      <span>审核状态:</span>
      <el-select
        v-model="listQuery.lowerAuditStatus"
        placeholder="审核状态"
        clearable
        style="width: 200px"
        class="filter-item"
        @change="getList"
      >
        <el-option label="全部" value="" />
        <el-option label="待审核" :value="2" />
        <el-option label="审核通过" :value="0" />
        <el-option label="审核未通过" :value="1" />
      </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="序号" type="index" width="80" align="center" />
      <el-table-column label="图片标题" prop="imageTitle" align="center" />
      <el-table-column label="审核状态" width="150px" align="center">
        <template slot-scope="{ row }">
          <el-tag v-if="row.imageAuditStatus === 0" size="small" type="danger">审核未通过</el-tag>
          <el-tag v-if="row.imageAuditStatus === 1" size="small" type="success">审核通过</el-tag>
          <el-tag v-if="row.imageAuditStatus === 2" size="small" type="warning">待审核</el-tag>
        </template>
      </el-table-column>
      <el-table-column label="审核时间" width="250px" align="center">
        <template slot-scope="{row}">
          <span v-if="row.imageAuditStatus!==2">{{ row.auditTime | formatTime }}</span>
          <span v-else>—</span>
        </template>
      </el-table-column>

      <el-table-column label="审核人" align="center" width="200px">
        <template slot-scope="{row}">
          <span v-if="row.imageAuditStatus!==2">{{ row.auditBy }}</span>
          <span v-else>—</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" width="150px" align="center">
        <template slot-scope="{row}">
          <el-button
            type="warning"
            size="mini"
            style="margin-right:5px"
            icon="el-icon-s-check"
            @click="$_navigationTo(`/review/doc/image/detail?imageId=${row.imageId}`)"
          >审核</el-button>
        </template>
      </el-table-column>
    </el-table>
    <!-- 表格区域END -->
  </div>
</template>

<script>
import Mock from 'mockjs'
import { formatDate } from '@/utils'
export default {
  filters: {
    formatTime(time) {
      if (!time) {
        return ''
      }
      return formatDate(time, 'yyyy-MM-DD HH:mm:ss')
    }
  },
  data() {
    return {
      listLoading: false,
      listQuery: {
        pageNum: 0, // 页码
        pageSize: 20, // 分页大小
        imageTitle: '', // 供应商类型
        lowerAuditStatus: '' // 审核状态
      },
      list: []
    }
  },
  created() {
    this.getList()
  },
  methods: {
    // 获取列表数据
    getList() {
      const count = 10
      const list = []

      for (let i = 0; i < count; i++) {
        list.push(Mock.mock({
          imageId: '@natural',
          imageTitle: '@ctitle(5,10)', // 供应商名称
          imageAuditStatus: '@natural(0,2)', // 审核状态
          auditTime: '@date("yy-MM-dd hh:mm:ss")',
          auditBy: '@cname(2,6)'
        }))
      }
      this.list = list
    }
  }
}
</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;
  }
}
.el-table .cell {
  overflow: visible;
}
.el-badge{
  margin: 0 6px;
}
</style>
