EnterList.vue
3.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<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>