<template>
  <div class="rejected-list">
    <el-table
      v-loading="loading"
      :data="tableData"
      border={false}
      class="custom-table"
      header-row-class-name="custom-header"
      row-class-name="custom-row"
    >
      <el-table-column prop="name" label="商户名称" header-align="center" align="center" />
      <el-table-column prop="contactName" label="联系人" header-align="center" align="center" />
      <el-table-column prop="contactPhone" label="联系电话" header-align="center" align="center" />
      <el-table-column prop="contactEmail" label="联系邮箱" header-align="center" align="center" />
      <el-table-column prop="address" label="地址" header-align="center" align="center" />
      <el-table-column prop="auditAt" label="拒绝时间" header-align="center" align="center" />
      <el-table-column prop="rejectReason" label="拒绝原因" header-align="center" align="center" />
      <el-table-column prop="status" label="状态" header-align="center" align="center">
        <template slot-scope="scope">
          <span :class="['status-tag', scope.row.status === 1 ? 'status-normal' : 'status-block']">
            {{ scope.row.status === 1 ? '正常' : '禁用' }}
          </span>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import { merchantList } from '@/api/merchant'

export default {
  name: 'RejectedList',
  data() {
    return {
      loading: false,
      tableData: []
    }
  },
  created() {
    this.getList()
  },
  methods: {
    async getList() {
      try {
        this.loading = true
        const res = await merchantList({
          auditStatus: 3
        })
        if (res.code === 0) {
          this.tableData = res.data.list || []
        } else {
          this.$message.error(res.message || '获取已拒绝列表失败')
        }
      } catch (error) {
        this.$message.error('获取已拒绝列表失败')
      } finally {
        this.loading = false
      }
    }
  }
}
</script>

<style lang="scss" scoped>
.rejected-list {
  margin-top: 20px;
}
.custom-table {
  background: #fff;
  border: none;
  font-size: 15px;
  ::v-deep .el-table__body-wrapper td,
  ::v-deep .el-table__header-wrapper th {
    border-right: none !important;
    border-left: none !important;
  }
}
.custom-header th {
  background: #f7f8fa !important;
  color: #888;
  font-weight: 500;
  border-bottom: 1px solid #f0f0f0 !important;
  border-top: 1px solid #f0f0f0 !important;
  padding-top: 16px !important;
  padding-bottom: 16px !important;
  height: 56px !important;
  line-height: 24px !important;
}
.custom-row td {
  border-bottom: 1px solid #f0f0f0 !important;
  border-top: none !important;
  padding-top: 14px !important;
  padding-bottom: 14px !important;
  height: 52px !important;
  line-height: 22px !important;
  vertical-align: middle !important;
}
.status-tag {
  display: inline-block;
  padding: 2px 16px;
  border-radius: 16px;
  font-size: 14px;
  font-weight: 500;
}
.status-normal {
  background: #e8f7ea;
  color: #3fc06d;
}
.status-block {
  background: #fbeaea;
  color: #f56c6c;
}
</style>
