148 lines
7.8 KiB
Vue
148 lines
7.8 KiB
Vue
<script setup lang="ts">
|
||
import { computed, onMounted, ref } from 'vue'
|
||
import { useRoute, useRouter } from 'vue-router'
|
||
import { LeftOutlined } from '@ant-design/icons-vue'
|
||
import { message } from 'ant-design-vue'
|
||
import { afterSaleApi, orderApi } from '../api/order'
|
||
import type { AfterSaleVO, OrderArtistChangeRequestVO, OrderArtistReviewVO } from '../api/order'
|
||
|
||
const route = useRoute()
|
||
const router = useRouter()
|
||
const loading = ref(false)
|
||
const order = ref<any | null>(null)
|
||
const reviews = ref<OrderArtistReviewVO[]>([])
|
||
const changes = ref<OrderArtistChangeRequestVO[]>([])
|
||
const afterSales = ref<AfterSaleVO[]>([])
|
||
|
||
const orderId = computed(() => String(route.query.orderId || route.params.id || ''))
|
||
const items = computed(() => Array.isArray(order.value?.items) ? order.value.items : [])
|
||
const firstAppointment = computed(() => items.value.map((item: any) => item.appointmentTime).find(Boolean))
|
||
|
||
const formatTime = (value?: string) => value ? String(value).replace('T', ' ').slice(0, 16) : '--'
|
||
const latestChangeText = computed(() => {
|
||
const latest = changes.value.slice().sort((left: any, right: any) => String(right.updateTime || right.createTime || '').localeCompare(String(left.updateTime || left.createTime || '')))[0] as any
|
||
return latest ? (latest.statusText || latest.status || '改派记录') : '暂无改派'
|
||
})
|
||
|
||
const nodes = computed(() => {
|
||
const current = order.value || {}
|
||
const status = Number(current.status)
|
||
return [
|
||
{ key: 'created', title: '订单创建', desc: formatTime(current.createTime), done: true, active: false },
|
||
{ key: 'appointment', title: '预约确认', desc: formatTime(firstAppointment.value), done: Boolean(firstAppointment.value), active: status === 1 },
|
||
{ key: 'artist', title: '服务安排', desc: latestChangeText.value, done: changes.value.length > 0 || items.value.some((item: any) => item.artistName), active: changes.value.some(item => item.status === 'PENDING') },
|
||
{ key: 'service', title: status === 3 ? '订单取消' : status === 4 ? '服务中' : '服务完成', desc: formatTime(current.completeTime || current.cancelTime || current.updateTime), done: status === 2 || status === 3, active: status === 2 || status === 3 || status === 4 },
|
||
{ key: 'after-sale', title: '售后/评价', desc: afterSales.value.length ? `${afterSales.value.length} 条售后` : (reviews.value.length ? `${reviews.value.length} 条评价` : '暂无记录'), done: afterSales.value.length > 0 || reviews.value.length > 0, active: afterSales.value.some(item => item.status === 'PENDING') || reviews.value.some(item => !item.rating) }
|
||
]
|
||
})
|
||
|
||
const loadProgress = async () => {
|
||
if (!orderId.value) return
|
||
loading.value = true
|
||
try {
|
||
const [detail, reviewList, changeList, afterSalePage] = await Promise.all([
|
||
orderApi.getOrderDetail(orderId.value),
|
||
orderApi.getOrderReviews(orderId.value).catch(() => []),
|
||
orderApi.getOrderArtistChangeRequests(orderId.value).catch(() => []),
|
||
afterSaleApi.listMy({ page: 1, size: 50 }).catch(() => ({ list: [] }))
|
||
])
|
||
order.value = detail
|
||
reviews.value = reviewList || []
|
||
changes.value = changeList || []
|
||
afterSales.value = ((afterSalePage as any)?.list || []).filter((item: AfterSaleVO) => String(item.orderId) === orderId.value)
|
||
} catch (error: any) {
|
||
order.value = null
|
||
message.error(error?.message || '服务进度加载失败')
|
||
} finally {
|
||
loading.value = false
|
||
}
|
||
}
|
||
|
||
onMounted(loadProgress)
|
||
</script>
|
||
|
||
<template>
|
||
<div class="progress-page">
|
||
<header class="header">
|
||
<a-button type="text" @click="router.back()">
|
||
<LeftOutlined />
|
||
</a-button>
|
||
<h1>服务进度</h1>
|
||
<a-button type="link" @click="loadProgress">刷新</a-button>
|
||
</header>
|
||
|
||
<main class="content">
|
||
<section class="hero-card">
|
||
<span>进度追踪</span>
|
||
<h2>{{ order?.orderNo || (orderId ? `订单 ${orderId}` : '选择订单') }}</h2>
|
||
<p>{{ order?.shopName || '查看预约、服务、评价与售后节点' }}</p>
|
||
</section>
|
||
|
||
<a-spin :spinning="loading">
|
||
<a-empty v-if="!orderId" description="缺少订单参数">
|
||
<a-button type="primary" @click="router.push('/orders')">选择订单</a-button>
|
||
</a-empty>
|
||
|
||
<template v-else>
|
||
<section class="progress-list">
|
||
<article v-for="node in nodes" :key="node.key" :class="{ done: node.done, active: node.active }">
|
||
<i />
|
||
<div>
|
||
<strong>{{ node.title }}</strong>
|
||
<span>{{ node.desc }}</span>
|
||
</div>
|
||
</article>
|
||
</section>
|
||
|
||
<section v-if="items.length" class="section-card">
|
||
<h3>项目进度</h3>
|
||
<p v-for="item in items" :key="item.id">
|
||
{{ item.productTitle || '预约项目' }}:{{ item.artistName || '待安排美甲师' }},{{ formatTime(item.appointmentTime) }}
|
||
</p>
|
||
</section>
|
||
|
||
<section v-if="changes.length" class="section-card">
|
||
<h3>改派记录</h3>
|
||
<p v-for="item in changes" :key="item.id">{{ item.statusText || item.status }}:{{ item.reason || item.timeImpactText || '已记录' }}</p>
|
||
</section>
|
||
|
||
<section v-if="afterSales.length" class="section-card">
|
||
<h3>售后记录</h3>
|
||
<p v-for="item in afterSales" :key="item.id">{{ item.afterSaleNo || item.id }}:{{ item.status || '-' }}</p>
|
||
</section>
|
||
|
||
<div class="actions">
|
||
<a-button @click="router.push(`/orders/${orderId}`)">订单详情</a-button>
|
||
<a-button type="primary" @click="router.push({ path: '/after-sale/apply', query: { orderId } })">申请售后</a-button>
|
||
</div>
|
||
</template>
|
||
</a-spin>
|
||
</main>
|
||
</div>
|
||
</template>
|
||
|
||
<style scoped>
|
||
.progress-page { min-height: 100vh; padding-top: 60px; background: var(--theme-page-bg); color: var(--text-primary); }
|
||
.header { position: fixed; top: 0; left: 0; right: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; height: 60px; padding: 9px 14px; background: color-mix(in srgb, var(--theme-card-bg) 92%, transparent); border-bottom: 1px solid var(--theme-border); backdrop-filter: blur(14px); }
|
||
.header h1 { margin: 0; font-size: 18px; }
|
||
.content { padding: 16px 14px 32px; }
|
||
.hero-card, .section-card, .progress-list { border: 1px solid var(--theme-border); border-radius: 20px; background: color-mix(in srgb, var(--theme-card-bg) 88%, transparent); box-shadow: 0 18px 44px rgba(74, 68, 63, 0.08); }
|
||
.hero-card { padding: 22px; margin-bottom: 14px; background: var(--theme-gradient-soft); }
|
||
.hero-card span { color: var(--theme-primary); font-size: 12px; font-weight: 700; letter-spacing: .05em; }
|
||
.hero-card h2 { margin: 10px 0 6px; font-size: 21px; }
|
||
.hero-card p { margin: 0; color: var(--text-secondary); line-height: 1.6; }
|
||
.progress-list { display: grid; gap: 0; overflow: hidden; }
|
||
.progress-list article { display: flex; gap: 12px; padding: 16px; border-top: 1px solid var(--theme-border); }
|
||
.progress-list article:first-child { border-top: 0; }
|
||
.progress-list i { width: 14px; height: 14px; margin-top: 3px; border-radius: 999px; background: var(--theme-border); box-shadow: 0 0 0 5px var(--theme-primary-soft); }
|
||
.progress-list article.done i, .progress-list article.active i { background: var(--theme-primary); }
|
||
.progress-list strong, .progress-list span { display: block; }
|
||
.progress-list span, .section-card p { margin-top: 6px; color: var(--text-secondary); line-height: 1.6; }
|
||
.section-card { margin-top: 14px; padding: 16px; }
|
||
.section-card h3 { margin: 0 0 10px; font-size: 17px; }
|
||
.section-card p { margin: 8px 0 0; }
|
||
.actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
|
||
:deep(.ant-btn-primary) { background: var(--theme-primary); border-color: var(--theme-primary); }
|
||
:deep(.ant-btn-link) { color: var(--theme-primary); }
|
||
</style>
|