EnterList.vue 3.1 KB
<template>
  <div>
    <a-card title="入驻申请" :bordered="false">
      <template #extra>
        <a-space>
          <a-select v-model:value="filterStatus" placeholder="状态" allowClear style="width:120px" @change="loadList">
            <a-select-option :value="0">未处理</a-select-option>
            <a-select-option :value="1">已通过</a-select-option>
            <a-select-option :value="-1">已拒绝</a-select-option>
          </a-select>
          <a-select v-model:value="filterType" placeholder="类型" allowClear style="width:120px" @change="loadList">
            <a-select-option :value="1">商家入驻</a-select-option>
            <a-select-option :value="2">骑手入驻</a-select-option>
            <a-select-option :value="3">商务合作</a-select-option>
          </a-select>
        </a-space>
      </template>
      <a-table :dataSource="list" :columns="columns" :loading="loading" rowKey="id" :pagination="false">
        <template #bodyCell="{ column, record }">
          <template v-if="column.key === 'type'">
            <a-tag>{{ typeMap[record.type] }}</a-tag>
          </template>
          <template v-if="column.key === 'status'">
            <a-tag :color="record.status === 1 ? 'green' : record.status === -1 ? 'red' : 'orange'">
              {{ statusMap[record.status] }}
            </a-tag>
          </template>
          <template v-if="column.key === 'action'">
            <a-space v-if="record.status === 0">
              <a-popconfirm title="确认通过?" @confirm="handle(record.id, 1)">
                <a style="color:green">通过</a>
              </a-popconfirm>
              <a-popconfirm title="确认拒绝?" @confirm="handle(record.id, -1)">
                <a style="color:red">拒绝</a>
              </a-popconfirm>
            </a-space>
            <span v-else>-</span>
          </template>
        </template>
      </a-table>
    </a-card>
  </div>
</template>

<script setup lang="ts">
import { ref, onMounted } from 'vue'
import { message } from 'ant-design-vue'
import { merchantApi } from '@/api'

const loading = ref(false)
const list = ref<any[]>([])
const filterStatus = ref<number | undefined>()
const filterType = ref<number | undefined>()

const typeMap: Record<number, string> = { 1: '商家入驻', 2: '骑手入驻', 3: '商务合作' }
const statusMap: Record<number, string> = { 0: '未处理', 1: '已通过', [-1]: '已拒绝' }

const columns = [
  { title: 'ID', dataIndex: 'id', width: 80 },
  { title: '联系人', dataIndex: 'name' },
  { title: '手机', dataIndex: 'mobile' },
  { title: '店铺名', dataIndex: 'storeName' },
  { title: '类型', key: 'type' },
  { title: '状态', key: 'status' },
  { title: '操作', key: 'action' },
]

async function loadList() {
  loading.value = true
  try {
    const res: any = await merchantApi.enterList({ status: filterStatus.value, type: filterType.value, page: 1 })
    list.value = res.data
  } finally { loading.value = false }
}

async function handle(id: number, status: number) {
  await merchantApi.handleEnter(id, status)
  message.success('操作成功')
  loadList()
}

onMounted(loadList)
</script>