start
This commit is contained in:
@@ -0,0 +1,229 @@
|
||||
<template>
|
||||
<PageBreadcrumb title="工作台" subtitle="首页" />
|
||||
|
||||
<div class="container-xxl">
|
||||
<BRow class="g-3">
|
||||
<BCol md="6" xl="3" v-for="item in statCards" :key="item.label">
|
||||
<RouterLink :to="item.to" class="text-reset text-decoration-none">
|
||||
<BCard no-body class="h-100">
|
||||
<BCardBody>
|
||||
<div class="d-flex align-items-center justify-content-between">
|
||||
<div>
|
||||
<p class="text-muted mb-1">{{ item.label }}</p>
|
||||
<h2 class="mb-0 fw-semibold">{{ item.value }}</h2>
|
||||
</div>
|
||||
<div class="avatar-lg d-flex align-items-center justify-content-center rounded-circle" :class="`bg-${item.variant}-subtle text-${item.variant}`">
|
||||
<Icon :icon="item.icon" class="fs-28" />
|
||||
</div>
|
||||
</div>
|
||||
<p class="mb-0 mt-3 fs-12 text-muted">{{ item.hint }}</p>
|
||||
</BCardBody>
|
||||
</BCard>
|
||||
</RouterLink>
|
||||
</BCol>
|
||||
</BRow>
|
||||
|
||||
<BRow class="g-3 mt-1">
|
||||
<BCol xl="8">
|
||||
<BCard no-body class="h-100">
|
||||
<BCardHeader class="d-flex justify-content-between align-items-center">
|
||||
<h5 class="card-title mb-0">近期订单</h5>
|
||||
<RouterLink to="/orders" class="btn btn-sm btn-light">
|
||||
查看全部
|
||||
<Icon icon="arrow-right" class="ms-1" />
|
||||
</RouterLink>
|
||||
</BCardHeader>
|
||||
|
||||
<div v-if="loading" class="text-center py-5">
|
||||
<BSpinner variant="primary" />
|
||||
</div>
|
||||
|
||||
<BTable
|
||||
v-else
|
||||
show-empty
|
||||
empty-text="暂无订单"
|
||||
:items="recent"
|
||||
:fields="recentFields"
|
||||
thead-class="bg-light align-middle bg-opacity-25 thead-sm"
|
||||
hover
|
||||
responsive
|
||||
class="table table-custom table-nowrap table-centered mb-0 w-100"
|
||||
>
|
||||
<template #head()="data">
|
||||
<span class="text-uppercase fs-xxs">{{ data.label }}</span>
|
||||
</template>
|
||||
|
||||
<template #cell(patient)="{ item }">
|
||||
<div>
|
||||
<RouterLink :to="`/orders/${item._id}`" class="fw-semibold link-reset">
|
||||
{{ item.patient?.name || '未填写' }}
|
||||
</RouterLink>
|
||||
<p class="text-muted mb-0 fs-12">{{ item.patient?.mobile || '-' }}</p>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template #cell(schedule)="{ item }">
|
||||
<div>{{ formatDate(item.schedule?.date) }}</div>
|
||||
<p class="text-muted mb-0 fs-12">{{ item.schedule?.startTime || '未指定时间' }}</p>
|
||||
</template>
|
||||
|
||||
<template #cell(hospital)="{ item }">
|
||||
<div>{{ item.hospital?.name || '-' }}</div>
|
||||
<p class="text-muted mb-0 fs-12">{{ item.hospital?.department || '未填写科室' }}</p>
|
||||
</template>
|
||||
|
||||
<template #cell(payment)="{ item }">
|
||||
<div>{{ formatMoney(item.payment?.totalFee) }}</div>
|
||||
<span class="badge fs-xxs" :class="`badge-soft-${PAYMENT_VARIANTS[item.payment?.status || 'unpaid']}`">
|
||||
{{ PAYMENT_LABELS[item.payment?.status || 'unpaid'] }}
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<template #cell(status)="{ item }">
|
||||
<span class="badge fs-xxs" :class="`badge-soft-${STATUS_VARIANTS[item.status || 'pending']}`">
|
||||
{{ STATUS_LABELS[item.status || 'pending'] }}
|
||||
</span>
|
||||
<span v-if="item.cancelStatus === 'requested'" class="badge fs-xxs badge-soft-danger ms-1">取消申请</span>
|
||||
</template>
|
||||
</BTable>
|
||||
</BCard>
|
||||
</BCol>
|
||||
|
||||
<BCol xl="4">
|
||||
<BCard no-body class="h-100">
|
||||
<BCardHeader class="d-flex justify-content-between align-items-center">
|
||||
<h5 class="card-title mb-0">待处理取消申请</h5>
|
||||
<span class="badge badge-soft-danger">{{ summary.cancelRequested }}</span>
|
||||
</BCardHeader>
|
||||
|
||||
<div v-if="loading" class="text-center py-5">
|
||||
<BSpinner variant="primary" />
|
||||
</div>
|
||||
|
||||
<div v-else-if="!cancelRequests.length" class="text-center text-muted py-5">
|
||||
<Icon icon="circle-check" class="fs-32 mb-2" />
|
||||
<p class="mb-0">暂无待处理申请</p>
|
||||
</div>
|
||||
|
||||
<div v-else class="list-group list-group-flush">
|
||||
<RouterLink
|
||||
v-for="item in cancelRequests"
|
||||
:key="item._id"
|
||||
:to="`/orders/${item._id}`"
|
||||
class="list-group-item list-group-item-action"
|
||||
>
|
||||
<div class="d-flex justify-content-between align-items-start">
|
||||
<div>
|
||||
<h6 class="mb-1">{{ item.patient?.name || '未填写' }}</h6>
|
||||
<p class="text-muted mb-1 fs-12">
|
||||
{{ formatDate(item.schedule?.date) }} {{ item.schedule?.startTime || '' }}
|
||||
</p>
|
||||
<p class="text-muted mb-0 fs-12 text-truncate" style="max-width: 220px">
|
||||
原因:{{ item.cancelReason || '未填写' }}
|
||||
</p>
|
||||
</div>
|
||||
<Icon icon="chevron-right" class="text-muted mt-1" />
|
||||
</div>
|
||||
</RouterLink>
|
||||
</div>
|
||||
</BCard>
|
||||
</BCol>
|
||||
</BRow>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, reactive, ref } from 'vue'
|
||||
import { escortApi } from '~/api/escort'
|
||||
import PageBreadcrumb from '~/components/PageBreadcrumb.vue'
|
||||
import Icon from '~/components/wrappers/Icon.vue'
|
||||
import type { EscortRecord } from '~/types/api'
|
||||
import {
|
||||
PAYMENT_LABELS,
|
||||
PAYMENT_VARIANTS,
|
||||
STATUS_LABELS,
|
||||
STATUS_VARIANTS,
|
||||
formatDate,
|
||||
formatMoney,
|
||||
today,
|
||||
} from '~/utils/format'
|
||||
|
||||
const loading = ref(true)
|
||||
const recent = ref<EscortRecord[]>([])
|
||||
const cancelRequests = ref<EscortRecord[]>([])
|
||||
|
||||
const summary = reactive({
|
||||
today: 0,
|
||||
pending: 0,
|
||||
cancelRequested: 0,
|
||||
unpaid: 0,
|
||||
})
|
||||
|
||||
const statCards = computed(() => [
|
||||
{
|
||||
label: '今日预约订单',
|
||||
value: summary.today,
|
||||
hint: '按预约就诊日期统计',
|
||||
icon: 'calendar-event',
|
||||
variant: 'primary',
|
||||
to: `/orders?appointmentDate=${today()}`,
|
||||
},
|
||||
{
|
||||
label: '待确认订单',
|
||||
value: summary.pending,
|
||||
hint: '等待平台确认接单',
|
||||
icon: 'clock-hour-4',
|
||||
variant: 'warning',
|
||||
to: '/orders?status=pending',
|
||||
},
|
||||
{
|
||||
label: '待处理取消申请',
|
||||
value: summary.cancelRequested,
|
||||
hint: '用户已提交取消,等待审核',
|
||||
icon: 'alert-triangle',
|
||||
variant: 'danger',
|
||||
to: '/orders?cancelStatus=requested',
|
||||
},
|
||||
{
|
||||
label: '未支付订单',
|
||||
value: summary.unpaid,
|
||||
hint: '需要跟进收款',
|
||||
icon: 'credit-card',
|
||||
variant: 'info',
|
||||
to: '/orders?paymentStatus=unpaid',
|
||||
},
|
||||
])
|
||||
|
||||
const recentFields = [
|
||||
{ key: 'patient', label: '就诊人' },
|
||||
{ key: 'schedule', label: '预约时间' },
|
||||
{ key: 'hospital', label: '就诊医院' },
|
||||
{ key: 'payment', label: '金额 / 支付' },
|
||||
{ key: 'status', label: '状态' },
|
||||
]
|
||||
|
||||
const load = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
const [todayRes, pendingRes, cancelRes, unpaidRes, recentRes, cancelListRes] = await Promise.all([
|
||||
escortApi.list({ page: 1, pageSize: 1, appointmentDate: today() }),
|
||||
escortApi.list({ page: 1, pageSize: 1, status: 'pending' }),
|
||||
escortApi.list({ page: 1, pageSize: 1, cancelStatus: 'requested' }),
|
||||
escortApi.list({ page: 1, pageSize: 1, paymentStatus: 'unpaid' }),
|
||||
escortApi.list({ page: 1, pageSize: 8 }),
|
||||
escortApi.list({ page: 1, pageSize: 5, cancelStatus: 'requested' }),
|
||||
])
|
||||
|
||||
summary.today = todayRes.total
|
||||
summary.pending = pendingRes.total
|
||||
summary.cancelRequested = cancelRes.total
|
||||
summary.unpaid = unpaidRes.total
|
||||
recent.value = recentRes.records
|
||||
cancelRequests.value = cancelListRes.records
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(load)
|
||||
</script>
|
||||
Reference in New Issue
Block a user