统一甲屿云命名体系
This commit is contained in:
@@ -0,0 +1,295 @@
|
||||
<template>
|
||||
<div class="after-sales">
|
||||
<a-page-header v-if="!isMobile" title="售后处理" sub-title="处理客户退款与售后申请" />
|
||||
|
||||
<section v-else class="admin-page-intro">
|
||||
<span class="admin-page-intro__eyebrow">售后</span>
|
||||
<h1 class="admin-page-intro__title">售后处理</h1>
|
||||
<div class="admin-page-intro__meta">
|
||||
<span class="admin-page-chip">申请 {{ pagination.total }}</span>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<a-card :bordered="false">
|
||||
<template #title v-if="isMobile">售后列表</template>
|
||||
|
||||
<AdminFilterPanel :active-count="activeFilterCount">
|
||||
<a-select
|
||||
v-model:value="statusFilter"
|
||||
:options="statusOptions"
|
||||
style="width: 160px"
|
||||
@change="reload"
|
||||
/>
|
||||
<a-button @click="resetFilters">重置筛选</a-button>
|
||||
</AdminFilterPanel>
|
||||
|
||||
<a-table
|
||||
v-if="!isMobile"
|
||||
:columns="columns"
|
||||
:data-source="visibleAfterSales"
|
||||
:loading="loading"
|
||||
:pagination="pagination"
|
||||
row-key="id"
|
||||
:scroll="{ x: 'max-content' }"
|
||||
@change="handleTableChange"
|
||||
>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'status'">
|
||||
<a-tag :color="statusColor(record.status)">{{ statusText(record.status) }}</a-tag>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'amount'">¥{{ money(record.refundAmount) }}</template>
|
||||
<template v-else-if="column.key === 'actions'">
|
||||
<a-space>
|
||||
<a-button type="link" size="small" @click="currentAfterSale = record as AfterSaleVO">查看</a-button>
|
||||
<a-button v-if="record.status === 'PENDING'" type="primary" size="small" @click="openAudit(record as AfterSaleVO, 'approve')">通过</a-button>
|
||||
<a-button v-if="record.status === 'PENDING'" danger size="small" @click="openAudit(record as AfterSaleVO, 'reject')">驳回</a-button>
|
||||
</a-space>
|
||||
</template>
|
||||
</template>
|
||||
</a-table>
|
||||
|
||||
<AdminMobileCardList v-else :items="visibleAfterSales" empty-description="暂无售后申请">
|
||||
<template #item="{ item }">
|
||||
<article class="admin-mobile-card">
|
||||
<div class="admin-mobile-card__head">
|
||||
<div class="admin-mobile-card__body">
|
||||
<div class="admin-mobile-card__title">{{ item.afterSaleNo || `售后 ${item.id}` }}</div>
|
||||
<div class="admin-mobile-card__subtitle">订单 {{ item.orderId }} · {{ item.createTime || '-' }}</div>
|
||||
</div>
|
||||
<a-tag :color="statusColor(item.status)">{{ statusText(item.status) }}</a-tag>
|
||||
</div>
|
||||
<div class="admin-mobile-card__rows">
|
||||
<div class="admin-mobile-card__row">
|
||||
<span>类型</span>
|
||||
<strong>{{ typeText(item.type) }}</strong>
|
||||
</div>
|
||||
<div class="admin-mobile-card__row">
|
||||
<span>退款金额</span>
|
||||
<strong>¥{{ money(item.refundAmount) }}</strong>
|
||||
</div>
|
||||
<div class="admin-mobile-card__row">
|
||||
<span>原因</span>
|
||||
<strong>{{ item.reason || '-' }}</strong>
|
||||
</div>
|
||||
</div>
|
||||
<div class="admin-mobile-card__actions">
|
||||
<a-button size="small" @click="currentAfterSale = item">查看</a-button>
|
||||
<a-button v-if="item.status === 'PENDING'" type="primary" size="small" @click="openAudit(item, 'approve')">通过</a-button>
|
||||
<a-button v-if="item.status === 'PENDING'" danger size="small" @click="openAudit(item, 'reject')">驳回</a-button>
|
||||
</div>
|
||||
</article>
|
||||
</template>
|
||||
</AdminMobileCardList>
|
||||
</a-card>
|
||||
|
||||
<AdminResponsiveModal
|
||||
v-model:open="detailOpen"
|
||||
title="售后详情"
|
||||
:desktop-width="760"
|
||||
:footer="null"
|
||||
@cancel="currentAfterSale = null"
|
||||
>
|
||||
<a-descriptions v-if="currentAfterSale" bordered :column="1" size="small">
|
||||
<a-descriptions-item label="售后单号">{{ currentAfterSale.afterSaleNo || '-' }}</a-descriptions-item>
|
||||
<a-descriptions-item label="订单ID">{{ currentAfterSale.orderId }}</a-descriptions-item>
|
||||
<a-descriptions-item label="订单项ID">{{ currentAfterSale.orderItemId || '-' }}</a-descriptions-item>
|
||||
<a-descriptions-item label="用户ID">{{ currentAfterSale.userId || '-' }}</a-descriptions-item>
|
||||
<a-descriptions-item label="类型">{{ typeText(currentAfterSale.type) }}</a-descriptions-item>
|
||||
<a-descriptions-item label="退款金额">¥{{ money(currentAfterSale.refundAmount) }}</a-descriptions-item>
|
||||
<a-descriptions-item label="状态">{{ statusText(currentAfterSale.status) }}</a-descriptions-item>
|
||||
<a-descriptions-item label="申请原因">{{ currentAfterSale.reason || '-' }}</a-descriptions-item>
|
||||
<a-descriptions-item label="审核原因">{{ currentAfterSale.auditReason || '-' }}</a-descriptions-item>
|
||||
<a-descriptions-item label="申请时间">{{ currentAfterSale.createTime || '-' }}</a-descriptions-item>
|
||||
</a-descriptions>
|
||||
</AdminResponsiveModal>
|
||||
|
||||
<AdminResponsiveModal
|
||||
v-model:open="auditOpen"
|
||||
:title="auditAction === 'approve' ? '通过售后' : '驳回售后'"
|
||||
:desktop-width="620"
|
||||
:confirm-loading="auditing"
|
||||
@ok="submitAudit"
|
||||
@cancel="closeAudit"
|
||||
>
|
||||
<a-form layout="vertical">
|
||||
<a-alert
|
||||
v-if="auditTarget"
|
||||
class="audit-alert"
|
||||
type="info"
|
||||
show-icon
|
||||
:message="`${auditTarget.afterSaleNo || auditTarget.id} · 退款 ¥${money(auditTarget.refundAmount)}`"
|
||||
:description="auditTarget.reason || '暂无申请原因'"
|
||||
/>
|
||||
<a-form-item label="处理备注">
|
||||
<a-textarea v-model:value="auditReason" :rows="4" :maxlength="300" placeholder="填写给客户和门店留痕的处理说明" />
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</AdminResponsiveModal>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, reactive, ref } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { message } from 'ant-design-vue'
|
||||
import { adminAfterSaleApi, type AfterSaleVO } from '@/api/admin'
|
||||
import { runWithGlobalLoading } from '@/utils/action-loading'
|
||||
import { useAdminViewport } from '@/composables/useAdminViewport'
|
||||
import AdminMobileCardList from '@/components/admin/AdminMobileCardList.vue'
|
||||
import AdminFilterPanel from '@/components/admin/AdminFilterPanel.vue'
|
||||
import AdminResponsiveModal from '@/components/admin/AdminResponsiveModal.vue'
|
||||
|
||||
const { isMobile } = useAdminViewport()
|
||||
const route = useRoute()
|
||||
const loading = ref(false)
|
||||
const auditing = ref(false)
|
||||
const statusFilter = ref('all')
|
||||
const afterSales = ref<AfterSaleVO[]>([])
|
||||
const currentAfterSale = ref<AfterSaleVO | null>(null)
|
||||
const auditOpen = ref(false)
|
||||
const auditTarget = ref<AfterSaleVO | null>(null)
|
||||
const auditAction = ref<'approve' | 'reject'>('approve')
|
||||
const auditReason = ref('')
|
||||
|
||||
const pagination = reactive({
|
||||
current: 1,
|
||||
pageSize: 10,
|
||||
total: 0,
|
||||
showSizeChanger: true,
|
||||
showTotal: (total: number) => `共 ${total} 条`
|
||||
})
|
||||
|
||||
const detailOpen = computed({
|
||||
get: () => !!currentAfterSale.value,
|
||||
set: value => { if (!value) currentAfterSale.value = null }
|
||||
})
|
||||
|
||||
const activeFilterCount = computed(() => statusFilter.value === 'all' ? 0 : 1)
|
||||
|
||||
const visibleAfterSales = computed(() => {
|
||||
const orderId = route.query.orderId
|
||||
if (!orderId) {
|
||||
return afterSales.value
|
||||
}
|
||||
return afterSales.value.filter(item => String(item.orderId) === String(orderId))
|
||||
})
|
||||
|
||||
const statusOptions = [
|
||||
{ label: '全部状态', value: 'all' },
|
||||
{ label: '待处理', value: 'PENDING' },
|
||||
{ label: '已通过', value: 'APPROVED' },
|
||||
{ label: '已驳回', value: 'REJECTED' }
|
||||
]
|
||||
|
||||
const columns = [
|
||||
{ title: '售后单号', dataIndex: 'afterSaleNo', key: 'afterSaleNo' },
|
||||
{ title: '订单ID', dataIndex: 'orderId', key: 'orderId', width: 110 },
|
||||
{ title: '用户ID', dataIndex: 'userId', key: 'userId', width: 110 },
|
||||
{ title: '类型', dataIndex: 'type', key: 'type', width: 110 },
|
||||
{ title: '退款金额', key: 'amount', width: 120 },
|
||||
{ title: '状态', key: 'status', width: 110 },
|
||||
{ title: '申请时间', dataIndex: 'createTime', key: 'createTime', width: 180 },
|
||||
{ title: '操作', key: 'actions', width: 190 }
|
||||
]
|
||||
|
||||
const money = (value?: number) => Number(value || 0).toFixed(2)
|
||||
const typeText = (type?: string) => {
|
||||
if (type === 'REFUND') return '退款'
|
||||
if (type === 'AFTER_SALE') return '售后'
|
||||
return type || '-'
|
||||
}
|
||||
const statusText = (status?: string) => {
|
||||
if (status === 'PENDING') return '待处理'
|
||||
if (status === 'APPROVED') return '已通过'
|
||||
if (status === 'REJECTED') return '已驳回'
|
||||
return status || '-'
|
||||
}
|
||||
const statusColor = (status?: string) => {
|
||||
if (status === 'PENDING') return 'orange'
|
||||
if (status === 'APPROVED') return 'green'
|
||||
if (status === 'REJECTED') return 'red'
|
||||
return 'default'
|
||||
}
|
||||
|
||||
const loadAfterSales = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
const result = await adminAfterSaleApi.listAfterSales({
|
||||
status: statusFilter.value === 'all' ? undefined : statusFilter.value,
|
||||
page: pagination.current,
|
||||
size: pagination.pageSize
|
||||
})
|
||||
afterSales.value = result.list || []
|
||||
pagination.total = result.total || 0
|
||||
} catch (error) {
|
||||
console.error('加载售后失败:', error)
|
||||
message.error('加载售后失败')
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const reload = () => {
|
||||
pagination.current = 1
|
||||
void loadAfterSales()
|
||||
}
|
||||
|
||||
const resetFilters = () => {
|
||||
statusFilter.value = 'all'
|
||||
reload()
|
||||
}
|
||||
|
||||
const handleTableChange = (pag: any) => {
|
||||
pagination.current = pag.current || 1
|
||||
pagination.pageSize = pag.pageSize || pagination.pageSize
|
||||
void loadAfterSales()
|
||||
}
|
||||
|
||||
const openAudit = (record: AfterSaleVO, action: 'approve' | 'reject') => {
|
||||
auditTarget.value = record
|
||||
auditAction.value = action
|
||||
auditReason.value = ''
|
||||
auditOpen.value = true
|
||||
}
|
||||
|
||||
const closeAudit = () => {
|
||||
auditOpen.value = false
|
||||
auditTarget.value = null
|
||||
auditReason.value = ''
|
||||
}
|
||||
|
||||
const submitAudit = async () => {
|
||||
if (!auditTarget.value) return
|
||||
auditing.value = true
|
||||
try {
|
||||
await runWithGlobalLoading(async () => {
|
||||
const payload = { auditReason: auditReason.value.trim() || undefined }
|
||||
if (auditAction.value === 'approve') {
|
||||
await adminAfterSaleApi.approveAfterSale(auditTarget.value!.id, payload)
|
||||
} else {
|
||||
await adminAfterSaleApi.rejectAfterSale(auditTarget.value!.id, payload)
|
||||
}
|
||||
await loadAfterSales()
|
||||
})
|
||||
message.success('售后已处理')
|
||||
closeAudit()
|
||||
} catch (error: any) {
|
||||
console.error('处理售后失败:', error)
|
||||
message.error(error?.message || '处理售后失败')
|
||||
} finally {
|
||||
auditing.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(loadAfterSales)
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.after-sales {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.audit-alert {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user