2026-05-13 12:43:01 +08:00
|
|
|
|
<template>
|
|
|
|
|
|
<div class="orders">
|
|
|
|
|
|
<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>
|
|
|
|
|
|
<p class="admin-page-intro__subtitle">
|
|
|
|
|
|
手机端不再默认展示横向大表格,而是把筛选、状态和处理按钮压到单列卡片里。
|
|
|
|
|
|
</p>
|
|
|
|
|
|
<div class="admin-page-intro__meta">
|
|
|
|
|
|
<span class="admin-page-chip">订单 {{ filteredOrders.length }}</span>
|
|
|
|
|
|
<span class="admin-page-chip">{{ canProcessOrders ? '可处理订单' : '查看模式' }}</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
|
|
<a-card :bordered="false">
|
|
|
|
|
|
<template #title v-if="isMobile">
|
|
|
|
|
|
订单列表
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<template #extra>
|
|
|
|
|
|
<div class="admin-toolbar" :class="{ 'admin-toolbar--stacked': isMobile }">
|
|
|
|
|
|
<a-input-search
|
|
|
|
|
|
v-model:value="keyword"
|
|
|
|
|
|
class="admin-toolbar__grow"
|
|
|
|
|
|
placeholder="搜索订单号、用户 ID 或优惠券"
|
2026-05-21 18:43:59 +08:00
|
|
|
|
@search="loadOrders"
|
2026-05-13 12:43:01 +08:00
|
|
|
|
/>
|
|
|
|
|
|
<a-select
|
|
|
|
|
|
v-model:value="statusFilter"
|
|
|
|
|
|
:options="statusOptions"
|
|
|
|
|
|
:style="isMobile ? { width: '100%' } : { width: '160px' }"
|
2026-05-21 18:43:59 +08:00
|
|
|
|
@change="loadOrders"
|
2026-05-13 12:43:01 +08:00
|
|
|
|
/>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
2026-05-21 18:43:59 +08:00
|
|
|
|
<div class="admin-filter-bar">
|
|
|
|
|
|
<a-select
|
|
|
|
|
|
v-model:value="shopFilter"
|
|
|
|
|
|
:allow-clear="currentUserType === 4"
|
|
|
|
|
|
placeholder="所属店铺"
|
|
|
|
|
|
style="width: 180px"
|
|
|
|
|
|
:loading="shopLoading"
|
|
|
|
|
|
:disabled="currentUserType !== 4 && !!currentUserInfo?.shopId"
|
|
|
|
|
|
@change="loadOrders"
|
|
|
|
|
|
>
|
|
|
|
|
|
<a-select-option
|
|
|
|
|
|
v-for="shop in shopList"
|
|
|
|
|
|
:key="shop.id"
|
|
|
|
|
|
:value="getShopOptionValue(shop)"
|
|
|
|
|
|
>
|
|
|
|
|
|
{{ shop.shopName }}
|
|
|
|
|
|
</a-select-option>
|
|
|
|
|
|
</a-select>
|
|
|
|
|
|
<a-input v-model:value="artistKeyword" allow-clear placeholder="美甲师" style="width: 160px" @pressEnter="noop" />
|
|
|
|
|
|
<a-input v-model:value="userKeyword" allow-clear placeholder="用户ID/客户" style="width: 160px" @pressEnter="noop" />
|
|
|
|
|
|
<a-range-picker v-model:value="createRange" value-format="YYYY-MM-DD HH:mm:ss" show-time />
|
|
|
|
|
|
<a-range-picker v-model:value="appointmentRange" value-format="YYYY-MM-DD HH:mm:ss" show-time />
|
|
|
|
|
|
<a-input-number v-model:value="minAmount" :min="0" placeholder="最低金额" style="width: 120px" />
|
|
|
|
|
|
<a-input-number v-model:value="maxAmount" :min="0" placeholder="最高金额" style="width: 120px" />
|
|
|
|
|
|
<a-button @click="resetFilters">重置筛选</a-button>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
2026-05-13 12:43:01 +08:00
|
|
|
|
<a-table v-if="!isMobile" :columns="columns" :data-source="filteredOrders" :loading="loading" row-key="id">
|
|
|
|
|
|
<template #bodyCell="{ column, record }">
|
|
|
|
|
|
<template v-if="column.key === 'status'">
|
|
|
|
|
|
<a-tag :color="statusColor(record.status)">{{ record.statusText }}</a-tag>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<template v-else-if="column.key === 'totalAmount'">
|
|
|
|
|
|
¥{{ record.totalAmount.toFixed(2) }}
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<template v-else-if="column.key === 'actualAmount'">
|
|
|
|
|
|
¥{{ record.actualAmount.toFixed(2) }}
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<template v-else-if="column.key === 'actions'">
|
|
|
|
|
|
<a-space>
|
|
|
|
|
|
<a-button type="link" size="small" @click="currentOrder = record">查看</a-button>
|
2026-05-24 18:09:11 +08:00
|
|
|
|
<a-button
|
|
|
|
|
|
v-if="canManagePayments && record.paymentStatus !== 'PAID'"
|
|
|
|
|
|
type="link"
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
@click="openManualPay(record)"
|
|
|
|
|
|
>
|
|
|
|
|
|
手动确认支付
|
|
|
|
|
|
</a-button>
|
|
|
|
|
|
<a-button
|
|
|
|
|
|
v-if="canViewAfterSales"
|
|
|
|
|
|
type="link"
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
@click="openAfterSales(record)"
|
|
|
|
|
|
>
|
|
|
|
|
|
售后
|
|
|
|
|
|
</a-button>
|
2026-05-13 12:43:01 +08:00
|
|
|
|
<a-button
|
|
|
|
|
|
v-if="record.status === 1 && canProcessOrders"
|
|
|
|
|
|
type="primary"
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
@click="process(record.id, 2)"
|
|
|
|
|
|
>
|
|
|
|
|
|
确认完成
|
|
|
|
|
|
</a-button>
|
|
|
|
|
|
<a-button
|
|
|
|
|
|
v-if="record.status === 1 && canProcessOrders && !isArtist"
|
|
|
|
|
|
danger
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
@click="process(record.id, 3)"
|
|
|
|
|
|
>
|
|
|
|
|
|
取消订单
|
|
|
|
|
|
</a-button>
|
|
|
|
|
|
</a-space>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</a-table>
|
|
|
|
|
|
|
|
|
|
|
|
<AdminMobileCardList v-else :items="filteredOrders" 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.orderNo }}</div>
|
|
|
|
|
|
<div class="admin-mobile-card__subtitle">
|
|
|
|
|
|
用户 {{ item.userId }} · {{ item.createTime }}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<a-tag :color="statusColor(item.status)">{{ item.statusText }}</a-tag>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="admin-mobile-card__rows">
|
|
|
|
|
|
<div class="admin-mobile-card__row">
|
|
|
|
|
|
<span>总金额</span>
|
|
|
|
|
|
<strong>¥{{ item.totalAmount.toFixed(2) }}</strong>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="admin-mobile-card__row">
|
|
|
|
|
|
<span>实付金额</span>
|
|
|
|
|
|
<strong>¥{{ item.actualAmount.toFixed(2) }}</strong>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="admin-mobile-card__row">
|
|
|
|
|
|
<span>优惠券</span>
|
|
|
|
|
|
<strong>{{ item.couponName || '无' }}</strong>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="admin-mobile-card__row">
|
|
|
|
|
|
<span>预约项目</span>
|
|
|
|
|
|
<strong>{{ item.items?.length || 0 }} 个</strong>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="admin-mobile-card__actions">
|
|
|
|
|
|
<a-button size="small" @click="currentOrder = item">查看详情</a-button>
|
2026-05-24 18:09:11 +08:00
|
|
|
|
<a-button
|
|
|
|
|
|
v-if="canManagePayments && item.paymentStatus !== 'PAID'"
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
@click="openManualPay(item)"
|
|
|
|
|
|
>
|
|
|
|
|
|
确认支付
|
|
|
|
|
|
</a-button>
|
|
|
|
|
|
<a-button
|
|
|
|
|
|
v-if="canViewAfterSales"
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
@click="openAfterSales(item)"
|
|
|
|
|
|
>
|
|
|
|
|
|
售后
|
|
|
|
|
|
</a-button>
|
2026-05-13 12:43:01 +08:00
|
|
|
|
<a-button
|
|
|
|
|
|
v-if="item.status === 1 && canProcessOrders"
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
type="primary"
|
|
|
|
|
|
@click="process(item.id, 2)"
|
|
|
|
|
|
>
|
|
|
|
|
|
完成
|
|
|
|
|
|
</a-button>
|
|
|
|
|
|
<a-button
|
|
|
|
|
|
v-if="item.status === 1 && canProcessOrders && !isArtist"
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
danger
|
|
|
|
|
|
@click="process(item.id, 3)"
|
|
|
|
|
|
>
|
|
|
|
|
|
取消
|
|
|
|
|
|
</a-button>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</article>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</AdminMobileCardList>
|
|
|
|
|
|
</a-card>
|
|
|
|
|
|
|
|
|
|
|
|
<AdminResponsiveModal
|
|
|
|
|
|
v-model:open="detailVisible"
|
|
|
|
|
|
title="订单详情"
|
|
|
|
|
|
:desktop-width="860"
|
|
|
|
|
|
@cancel="currentOrder = null"
|
|
|
|
|
|
>
|
|
|
|
|
|
<template v-if="currentOrder">
|
|
|
|
|
|
<a-descriptions :column="isMobile ? 1 : 2" bordered size="small">
|
|
|
|
|
|
<a-descriptions-item label="订单编号">{{ currentOrder.orderNo }}</a-descriptions-item>
|
|
|
|
|
|
<a-descriptions-item label="用户ID">{{ currentOrder.userId }}</a-descriptions-item>
|
|
|
|
|
|
<a-descriptions-item label="订单总额">¥{{ currentOrder.totalAmount.toFixed(2) }}</a-descriptions-item>
|
|
|
|
|
|
<a-descriptions-item label="实付金额">¥{{ currentOrder.actualAmount.toFixed(2) }}</a-descriptions-item>
|
|
|
|
|
|
<a-descriptions-item label="优惠券">{{ currentOrder.couponName || '无' }}</a-descriptions-item>
|
|
|
|
|
|
<a-descriptions-item label="订单状态">{{ currentOrder.statusText }}</a-descriptions-item>
|
|
|
|
|
|
<a-descriptions-item label="创建时间" :span="isMobile ? 1 : 2">{{ currentOrder.createTime }}</a-descriptions-item>
|
|
|
|
|
|
</a-descriptions>
|
|
|
|
|
|
|
|
|
|
|
|
<a-divider>订单项目</a-divider>
|
|
|
|
|
|
|
|
|
|
|
|
<a-table
|
|
|
|
|
|
v-if="!isMobile"
|
|
|
|
|
|
:columns="itemColumns"
|
|
|
|
|
|
:data-source="currentOrder.items"
|
|
|
|
|
|
row-key="id"
|
|
|
|
|
|
:pagination="false"
|
|
|
|
|
|
>
|
|
|
|
|
|
<template #bodyCell="{ column, record }">
|
|
|
|
|
|
<template v-if="column.key === 'price'">¥{{ record.price.toFixed(2) }}</template>
|
|
|
|
|
|
<template v-else-if="column.key === 'totalPrice'">¥{{ (record.price * record.quantity).toFixed(2) }}</template>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</a-table>
|
|
|
|
|
|
|
|
|
|
|
|
<div v-else class="detail-items">
|
|
|
|
|
|
<article v-for="item in currentOrder.items" :key="item.id" class="admin-mobile-card">
|
|
|
|
|
|
<div class="admin-mobile-card__title">{{ item.productTitle }}</div>
|
|
|
|
|
|
<div class="admin-mobile-card__subtitle">{{ item.artistName || '未指定美甲师' }}</div>
|
|
|
|
|
|
<div class="admin-mobile-card__rows">
|
|
|
|
|
|
<div class="admin-mobile-card__row">
|
|
|
|
|
|
<span>预约时间</span>
|
|
|
|
|
|
<strong>{{ item.appointmentTime || '--' }}</strong>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="admin-mobile-card__row">
|
|
|
|
|
|
<span>单价</span>
|
|
|
|
|
|
<strong>¥{{ item.price.toFixed(2) }}</strong>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="admin-mobile-card__row">
|
|
|
|
|
|
<span>数量</span>
|
|
|
|
|
|
<strong>{{ item.quantity }}</strong>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="admin-mobile-card__row">
|
|
|
|
|
|
<span>小计</span>
|
|
|
|
|
|
<strong>¥{{ (item.price * item.quantity).toFixed(2) }}</strong>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</article>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</AdminResponsiveModal>
|
2026-05-24 18:09:11 +08:00
|
|
|
|
|
|
|
|
|
|
<AdminResponsiveModal
|
|
|
|
|
|
v-model:open="manualPayOpen"
|
|
|
|
|
|
title="手动确认支付"
|
|
|
|
|
|
:desktop-width="560"
|
|
|
|
|
|
:confirm-loading="manualPayLoading"
|
|
|
|
|
|
@ok="submitManualPay"
|
|
|
|
|
|
@cancel="closeManualPay"
|
|
|
|
|
|
>
|
|
|
|
|
|
<a-form layout="vertical">
|
|
|
|
|
|
<a-alert
|
|
|
|
|
|
v-if="manualPayOrder"
|
|
|
|
|
|
class="order-action-alert"
|
|
|
|
|
|
type="warning"
|
|
|
|
|
|
show-icon
|
|
|
|
|
|
:message="manualPayOrder.orderNo"
|
|
|
|
|
|
:description="`将把订单标记为已支付,实付金额 ¥${moneyText(manualPayOrder.actualAmount || manualPayOrder.totalAmount)}`"
|
|
|
|
|
|
/>
|
|
|
|
|
|
<a-form-item label="确认备注">
|
|
|
|
|
|
<a-textarea v-model:value="manualPayRemark" :rows="3" :maxlength="200" placeholder="例如:线下现金已核验" />
|
|
|
|
|
|
</a-form-item>
|
|
|
|
|
|
</a-form>
|
|
|
|
|
|
</AdminResponsiveModal>
|
2026-05-13 12:43:01 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
2026-05-18 09:46:11 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* OrdersView page script.
|
|
|
|
|
|
* Call guide: the template binds the reactive state below, and the methods are triggered by button clicks, lifecycle hooks, or router events.
|
|
|
|
|
|
*/
|
2026-05-13 12:43:01 +08:00
|
|
|
|
import { computed, onMounted, ref } from 'vue'
|
|
|
|
|
|
import { message } from 'ant-design-vue'
|
2026-05-24 18:09:11 +08:00
|
|
|
|
import { useRouter } from 'vue-router'
|
2026-05-23 18:44:57 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* Purpose: Shop supports OrdersView.vue by holding or executing the shop page or API role.
|
|
|
|
|
|
* Usage: import, call, read, or update this type from the owning page/module while preserving the surrounding loading and permission flow.
|
|
|
|
|
|
*/
|
2026-05-21 18:43:59 +08:00
|
|
|
|
import { adminOrderApi, adminShopApi, type Shop } from '@/api/admin'
|
2026-05-13 12:43:01 +08:00
|
|
|
|
import { usePermission } from '@/utils/permission'
|
|
|
|
|
|
import type { IdType } from '@/utils/id'
|
|
|
|
|
|
import { sameId } from '@/utils/id'
|
|
|
|
|
|
import { runWithGlobalLoading } from '@/utils/action-loading'
|
|
|
|
|
|
import { useAdminViewport } from '@/composables/useAdminViewport'
|
|
|
|
|
|
import AdminMobileCardList from '@/components/admin/AdminMobileCardList.vue'
|
|
|
|
|
|
import AdminResponsiveModal from '@/components/admin/AdminResponsiveModal.vue'
|
|
|
|
|
|
|
|
|
|
|
|
const { isMobile } = useAdminViewport()
|
2026-05-24 18:09:11 +08:00
|
|
|
|
const router = useRouter()
|
2026-05-23 18:44:57 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* Purpose: orders supports OrdersView.vue by holding or executing the orders page or API role.
|
|
|
|
|
|
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
|
|
|
|
|
*/
|
2026-05-13 12:43:01 +08:00
|
|
|
|
const orders = ref<any[]>([])
|
2026-05-18 09:46:11 +08:00
|
|
|
|
/** loading is a reactive state variable used by the template and event handlers. */
|
2026-05-13 12:43:01 +08:00
|
|
|
|
const loading = ref(false)
|
2026-05-23 18:44:57 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* Purpose: shopLoading supports OrdersView.vue by holding or executing the shop loading page or API role.
|
|
|
|
|
|
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
|
|
|
|
|
*/
|
2026-05-21 18:43:59 +08:00
|
|
|
|
const shopLoading = ref(false)
|
2026-05-23 18:44:57 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* Purpose: currentOrder supports OrdersView.vue by holding or executing the current order page or API role.
|
|
|
|
|
|
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
|
|
|
|
|
*/
|
2026-05-13 12:43:01 +08:00
|
|
|
|
const currentOrder = ref<any | null>(null)
|
2026-05-24 18:09:11 +08:00
|
|
|
|
const manualPayOpen = ref(false)
|
|
|
|
|
|
const manualPayLoading = ref(false)
|
|
|
|
|
|
const manualPayOrder = ref<any | null>(null)
|
|
|
|
|
|
const manualPayRemark = ref('')
|
2026-05-23 18:44:57 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* Purpose: currentUserType supports OrdersView.vue by holding or executing the current user type page or API role.
|
|
|
|
|
|
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
|
|
|
|
|
*/
|
2026-05-13 12:43:01 +08:00
|
|
|
|
const currentUserType = ref<number | null>(null)
|
2026-05-23 18:44:57 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* Purpose: currentUserInfo supports OrdersView.vue by holding or executing the current user info page or API role.
|
|
|
|
|
|
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
|
|
|
|
|
*/
|
2026-05-21 18:43:59 +08:00
|
|
|
|
const currentUserInfo = (() => {
|
|
|
|
|
|
try {
|
|
|
|
|
|
const cached = localStorage.getItem('adminUserInfo') || sessionStorage.getItem('adminUserInfo')
|
|
|
|
|
|
return cached ? JSON.parse(cached) : null
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
console.error('获取当前用户信息失败', error)
|
|
|
|
|
|
return null
|
|
|
|
|
|
}
|
|
|
|
|
|
})()
|
2026-05-18 09:46:11 +08:00
|
|
|
|
/** keyword is a reactive state variable used by the template and event handlers. */
|
2026-05-13 12:43:01 +08:00
|
|
|
|
const keyword = ref('')
|
2026-05-23 18:44:57 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* Purpose: statusFilter supports OrdersView.vue by holding or executing the status filter page or API role.
|
|
|
|
|
|
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
|
|
|
|
|
*/
|
2026-05-13 12:43:01 +08:00
|
|
|
|
const statusFilter = ref<'all' | string>('all')
|
2026-05-23 18:44:57 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* Purpose: shopList supports OrdersView.vue by holding or executing the shop list page or API role.
|
|
|
|
|
|
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
|
|
|
|
|
*/
|
2026-05-21 18:43:59 +08:00
|
|
|
|
const shopList = ref<Shop[]>([])
|
2026-05-23 18:44:57 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* Purpose: shopFilter supports OrdersView.vue by holding or executing the shop filter page or API role.
|
|
|
|
|
|
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
|
|
|
|
|
*/
|
2026-05-21 18:43:59 +08:00
|
|
|
|
const shopFilter = ref<string | undefined>()
|
2026-05-23 18:44:57 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* Purpose: artistKeyword supports OrdersView.vue by holding or executing the artist keyword page or API role.
|
|
|
|
|
|
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
|
|
|
|
|
*/
|
2026-05-21 18:43:59 +08:00
|
|
|
|
const artistKeyword = ref('')
|
2026-05-23 18:44:57 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* Purpose: userKeyword supports OrdersView.vue by holding or executing the user keyword page or API role.
|
|
|
|
|
|
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
|
|
|
|
|
*/
|
2026-05-21 18:43:59 +08:00
|
|
|
|
const userKeyword = ref('')
|
2026-05-23 18:44:57 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* Purpose: createRange supports OrdersView.vue by holding or executing the create range page or API role.
|
|
|
|
|
|
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
|
|
|
|
|
*/
|
2026-05-21 18:43:59 +08:00
|
|
|
|
const createRange = ref<[string, string] | undefined>()
|
2026-05-23 18:44:57 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* Purpose: appointmentRange supports OrdersView.vue by holding or executing the appointment range page or API role.
|
|
|
|
|
|
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
|
|
|
|
|
*/
|
2026-05-21 18:43:59 +08:00
|
|
|
|
const appointmentRange = ref<[string, string] | undefined>()
|
2026-05-23 18:44:57 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* Purpose: minAmount supports OrdersView.vue by holding or executing the min amount page or API role.
|
|
|
|
|
|
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
|
|
|
|
|
*/
|
2026-05-21 18:43:59 +08:00
|
|
|
|
const minAmount = ref<number | undefined>()
|
2026-05-23 18:44:57 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* Purpose: maxAmount supports OrdersView.vue by holding or executing the max amount page or API role.
|
|
|
|
|
|
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
|
|
|
|
|
*/
|
2026-05-21 18:43:59 +08:00
|
|
|
|
const maxAmount = ref<number | undefined>()
|
2026-05-13 12:43:01 +08:00
|
|
|
|
const { hasPermission, loadUserPermissions } = usePermission()
|
|
|
|
|
|
|
2026-05-18 09:46:11 +08:00
|
|
|
|
/** detailVisible is a reactive state variable used by the template and event handlers. */
|
2026-05-13 12:43:01 +08:00
|
|
|
|
const detailVisible = computed({
|
|
|
|
|
|
get: () => !!currentOrder.value,
|
|
|
|
|
|
set: value => { if (!value) currentOrder.value = null }
|
|
|
|
|
|
})
|
2026-05-18 09:46:11 +08:00
|
|
|
|
/** canProcessOrders is a reactive state variable used by the template and event handlers. */
|
2026-05-13 12:43:01 +08:00
|
|
|
|
const canProcessOrders = computed(() => hasPermission('order:process'))
|
2026-05-24 18:09:11 +08:00
|
|
|
|
const canManagePayments = computed(() => hasPermission('payment:manage'))
|
|
|
|
|
|
const canViewAfterSales = computed(() => hasPermission('after_sale:view'))
|
2026-05-18 09:46:11 +08:00
|
|
|
|
/** isArtist is a reactive state variable used by the template and event handlers. */
|
2026-05-13 12:43:01 +08:00
|
|
|
|
const isArtist = computed(() => currentUserType.value === 3)
|
2026-05-23 18:44:57 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* Purpose: statusOptions supports OrdersView.vue by holding or executing the status options page or API role.
|
|
|
|
|
|
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
|
|
|
|
|
*/
|
2026-05-13 12:43:01 +08:00
|
|
|
|
const statusOptions = [
|
|
|
|
|
|
{ label: '全部状态', value: 'all' },
|
|
|
|
|
|
{ label: '待处理', value: '1' },
|
|
|
|
|
|
{ label: '已完成', value: '2' },
|
|
|
|
|
|
{ label: '已取消', value: '3' }
|
|
|
|
|
|
]
|
|
|
|
|
|
|
2026-05-18 09:46:11 +08:00
|
|
|
|
/** filteredOrders is a reactive state variable used by the template and event handlers. */
|
2026-05-13 12:43:01 +08:00
|
|
|
|
const filteredOrders = computed(() => {
|
|
|
|
|
|
const keywordValue = keyword.value.trim().toLowerCase()
|
|
|
|
|
|
return orders.value.filter(order => {
|
|
|
|
|
|
const matchStatus = statusFilter.value === 'all' || String(order.status) === String(statusFilter.value)
|
|
|
|
|
|
if (!matchStatus) {
|
|
|
|
|
|
return false
|
|
|
|
|
|
}
|
2026-05-21 18:43:59 +08:00
|
|
|
|
const actualAmount = Number(order.actualAmount ?? order.totalAmount ?? 0)
|
|
|
|
|
|
if (minAmount.value !== undefined && actualAmount < minAmount.value) return false
|
|
|
|
|
|
if (maxAmount.value !== undefined && actualAmount > maxAmount.value) return false
|
|
|
|
|
|
if (!matchText(userKeyword.value, [order.userId, order.userNickname, order.customerName, order.customerPhone])) return false
|
|
|
|
|
|
if (!matchText(artistKeyword.value, (order.items || []).map((item: any) => item.artistName || item.artistId))) return false
|
|
|
|
|
|
if (!matchRange(order.createTime, createRange.value)) return false
|
|
|
|
|
|
if (!matchRange((order.items || [])[0]?.appointmentTime, appointmentRange.value, (order.items || []).map((item: any) => item.appointmentTime))) return false
|
2026-05-13 12:43:01 +08:00
|
|
|
|
if (!keywordValue) {
|
|
|
|
|
|
return true
|
|
|
|
|
|
}
|
|
|
|
|
|
const haystack = [
|
|
|
|
|
|
order.orderNo,
|
|
|
|
|
|
order.userId,
|
|
|
|
|
|
order.couponName,
|
|
|
|
|
|
...(order.items || []).map((item: any) => `${item.productTitle || ''} ${item.artistName || ''}`)
|
|
|
|
|
|
].join(' ').toLowerCase()
|
|
|
|
|
|
return haystack.includes(keywordValue)
|
|
|
|
|
|
})
|
|
|
|
|
|
})
|
|
|
|
|
|
|
2026-05-23 18:44:57 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* Purpose: matchText supports OrdersView.vue by holding or executing the match text page or API role.
|
|
|
|
|
|
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
|
|
|
|
|
*/
|
2026-05-21 18:43:59 +08:00
|
|
|
|
const matchText = (needle: string, values: any[]) => {
|
|
|
|
|
|
const normalized = needle.trim().toLowerCase()
|
|
|
|
|
|
if (!normalized) return true
|
|
|
|
|
|
return values.some(value => String(value ?? '').toLowerCase().includes(normalized))
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-23 18:44:57 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* Purpose: matchRange supports OrdersView.vue by holding or executing the match range page or API role.
|
|
|
|
|
|
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
|
|
|
|
|
*/
|
2026-05-21 18:43:59 +08:00
|
|
|
|
const matchRange = (value: string | undefined, range?: [string, string], candidates?: string[]) => {
|
|
|
|
|
|
if (!range?.length) return true
|
|
|
|
|
|
const values = candidates?.length ? candidates : [value]
|
|
|
|
|
|
const start = new Date(range[0]).getTime()
|
|
|
|
|
|
const end = new Date(range[1]).getTime()
|
|
|
|
|
|
return values.some(item => {
|
|
|
|
|
|
if (!item) return false
|
|
|
|
|
|
const time = new Date(item).getTime()
|
|
|
|
|
|
return time >= start && time <= end
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-23 18:44:57 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* Purpose: resetFilters supports OrdersView.vue by holding or executing the reset filters page or API role.
|
|
|
|
|
|
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
|
|
|
|
|
*/
|
2026-05-21 18:43:59 +08:00
|
|
|
|
const resetFilters = () => {
|
|
|
|
|
|
keyword.value = ''
|
|
|
|
|
|
statusFilter.value = 'all'
|
|
|
|
|
|
shopFilter.value = currentUserType.value !== 4 ? normalizeShopId(currentUserInfo?.shopId) : undefined
|
|
|
|
|
|
artistKeyword.value = ''
|
|
|
|
|
|
userKeyword.value = ''
|
|
|
|
|
|
createRange.value = undefined
|
|
|
|
|
|
appointmentRange.value = undefined
|
|
|
|
|
|
minAmount.value = undefined
|
|
|
|
|
|
maxAmount.value = undefined
|
|
|
|
|
|
void loadOrders()
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-23 18:44:57 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* Purpose: columns supports OrdersView.vue by holding or executing the columns page or API role.
|
|
|
|
|
|
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
|
|
|
|
|
*/
|
2026-05-13 12:43:01 +08:00
|
|
|
|
const columns = [
|
|
|
|
|
|
{ title: '订单编号', dataIndex: 'orderNo', key: 'orderNo' },
|
|
|
|
|
|
{ title: '用户ID', dataIndex: 'userId', key: 'userId', width: 100 },
|
|
|
|
|
|
{ title: '订单总额', key: 'totalAmount', width: 120 },
|
|
|
|
|
|
{ title: '实付金额', key: 'actualAmount', width: 120 },
|
|
|
|
|
|
{ title: '优惠券', dataIndex: 'couponName', key: 'couponName', width: 140 },
|
|
|
|
|
|
{ title: '状态', key: 'status', width: 100 },
|
|
|
|
|
|
{ title: '创建时间', dataIndex: 'createTime', key: 'createTime', width: 180 },
|
|
|
|
|
|
{ title: '操作', key: 'actions', width: 180 }
|
|
|
|
|
|
]
|
|
|
|
|
|
|
2026-05-23 18:44:57 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* Purpose: itemColumns supports OrdersView.vue by holding or executing the item columns page or API role.
|
|
|
|
|
|
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
|
|
|
|
|
*/
|
2026-05-13 12:43:01 +08:00
|
|
|
|
const itemColumns = [
|
|
|
|
|
|
{ title: '商品ID', dataIndex: 'productId', key: 'productId', width: 100 },
|
|
|
|
|
|
{ title: '商品名称', dataIndex: 'productTitle', key: 'productTitle' },
|
|
|
|
|
|
{ title: '美甲师', dataIndex: 'artistName', key: 'artistName', width: 120 },
|
|
|
|
|
|
{ title: '预约时间', dataIndex: 'appointmentTime', key: 'appointmentTime', width: 180 },
|
|
|
|
|
|
{ title: '单价', key: 'price', width: 100 },
|
|
|
|
|
|
{ title: '数量', dataIndex: 'quantity', key: 'quantity', width: 80 },
|
|
|
|
|
|
{ title: '总价', key: 'totalPrice', width: 100 }
|
|
|
|
|
|
]
|
|
|
|
|
|
|
2026-05-18 09:46:11 +08:00
|
|
|
|
/** statusColor is a local helper used by this page script. */
|
2026-05-13 12:43:01 +08:00
|
|
|
|
const statusColor = (status: number) => {
|
|
|
|
|
|
if (status === 1) return 'orange'
|
|
|
|
|
|
if (status === 2) return 'green'
|
|
|
|
|
|
if (status === 3) return 'red'
|
|
|
|
|
|
return 'default'
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-24 18:09:11 +08:00
|
|
|
|
const moneyText = (value?: number) => Number(value || 0).toFixed(2)
|
|
|
|
|
|
|
2026-05-23 18:44:57 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* Purpose: normalizeUserType supports OrdersView.vue by holding or executing the normalize user type page or API role.
|
|
|
|
|
|
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
|
|
|
|
|
*/
|
2026-05-21 18:43:59 +08:00
|
|
|
|
const normalizeUserType = (value: unknown) => {
|
|
|
|
|
|
const type = Number(value)
|
|
|
|
|
|
return Number.isFinite(type) ? type : null
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-18 09:46:11 +08:00
|
|
|
|
/** resolveCurrentUserType is a local helper used by this page script. */
|
2026-05-13 12:43:01 +08:00
|
|
|
|
const resolveCurrentUserType = () => {
|
2026-05-21 18:43:59 +08:00
|
|
|
|
currentUserType.value = normalizeUserType(currentUserInfo?.type)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-23 18:44:57 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* Purpose: normalizeShopId supports OrdersView.vue by holding or executing the normalize shop id page or API role.
|
|
|
|
|
|
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
|
|
|
|
|
*/
|
2026-05-21 18:43:59 +08:00
|
|
|
|
const normalizeShopId = (value: unknown) => {
|
|
|
|
|
|
if (value === undefined || value === null || value === '') {
|
|
|
|
|
|
return undefined
|
2026-05-13 12:43:01 +08:00
|
|
|
|
}
|
2026-05-21 18:43:59 +08:00
|
|
|
|
return String(value)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-23 18:44:57 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* Purpose: getShopOptionValue supports OrdersView.vue by holding or executing the get shop option value page or API role.
|
|
|
|
|
|
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
|
|
|
|
|
*/
|
2026-05-21 18:43:59 +08:00
|
|
|
|
const getShopOptionValue = (shop: Shop) => normalizeShopId((shop as any).id) || ''
|
|
|
|
|
|
|
2026-05-23 18:44:57 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* Purpose: loadShopOptions supports OrdersView.vue by holding or executing the load shop options page or API role.
|
|
|
|
|
|
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
|
|
|
|
|
*/
|
2026-05-21 18:43:59 +08:00
|
|
|
|
const loadShopOptions = async () => {
|
|
|
|
|
|
shopLoading.value = true
|
2026-05-13 12:43:01 +08:00
|
|
|
|
try {
|
2026-05-21 18:43:59 +08:00
|
|
|
|
shopList.value = await adminShopApi.listAllShops() as unknown as Shop[]
|
|
|
|
|
|
if (currentUserType.value !== 4 && currentUserInfo?.shopId) {
|
|
|
|
|
|
shopFilter.value = normalizeShopId(currentUserInfo.shopId)
|
|
|
|
|
|
}
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
console.error('获取店铺列表失败:', error)
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
shopLoading.value = false
|
2026-05-13 12:43:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-18 09:46:11 +08:00
|
|
|
|
/** loadOrders is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
2026-05-13 12:43:01 +08:00
|
|
|
|
const loadOrders = async () => {
|
|
|
|
|
|
loading.value = true
|
|
|
|
|
|
try {
|
2026-05-21 18:43:59 +08:00
|
|
|
|
const scopedShopId = shopFilter.value || (currentUserType.value !== 4 ? normalizeShopId(currentUserInfo?.shopId) : undefined)
|
|
|
|
|
|
const result = await adminOrderApi.listOrders({
|
|
|
|
|
|
page: 1,
|
|
|
|
|
|
size: 1000,
|
|
|
|
|
|
keyword: keyword.value || undefined,
|
|
|
|
|
|
status: statusFilter.value === 'all' ? undefined : Number(statusFilter.value),
|
|
|
|
|
|
shopId: scopedShopId
|
|
|
|
|
|
}) as unknown as { list?: any[] }
|
|
|
|
|
|
orders.value = result.list || []
|
2026-05-13 12:43:01 +08:00
|
|
|
|
} catch {
|
|
|
|
|
|
message.error('获取订单列表失败')
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
loading.value = false
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-18 09:46:11 +08:00
|
|
|
|
/** process is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
2026-05-13 12:43:01 +08:00
|
|
|
|
const process = async (orderId: IdType, status: number) => {
|
|
|
|
|
|
try {
|
|
|
|
|
|
await runWithGlobalLoading(async () => {
|
2026-05-21 18:43:59 +08:00
|
|
|
|
await adminOrderApi.updateOrderStatus(orderId, status)
|
2026-05-13 12:43:01 +08:00
|
|
|
|
await loadOrders()
|
|
|
|
|
|
})
|
|
|
|
|
|
message.success('操作成功')
|
|
|
|
|
|
if (sameId(currentOrder.value?.id, orderId)) {
|
|
|
|
|
|
currentOrder.value = orders.value.find(order => sameId(order.id, orderId)) || null
|
|
|
|
|
|
}
|
|
|
|
|
|
} catch {
|
|
|
|
|
|
message.error('操作失败')
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-24 18:09:11 +08:00
|
|
|
|
const openManualPay = (order: any) => {
|
|
|
|
|
|
manualPayOrder.value = order
|
|
|
|
|
|
manualPayRemark.value = ''
|
|
|
|
|
|
manualPayOpen.value = true
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const closeManualPay = () => {
|
|
|
|
|
|
manualPayOpen.value = false
|
|
|
|
|
|
manualPayOrder.value = null
|
|
|
|
|
|
manualPayRemark.value = ''
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const submitManualPay = async () => {
|
|
|
|
|
|
if (!manualPayOrder.value) return
|
|
|
|
|
|
manualPayLoading.value = true
|
|
|
|
|
|
try {
|
|
|
|
|
|
await runWithGlobalLoading(async () => {
|
|
|
|
|
|
await adminOrderApi.manualConfirmPayment(manualPayOrder.value.id, manualPayRemark.value.trim() || undefined)
|
|
|
|
|
|
await loadOrders()
|
|
|
|
|
|
})
|
|
|
|
|
|
message.success('支付已确认')
|
|
|
|
|
|
closeManualPay()
|
|
|
|
|
|
} catch (error: any) {
|
|
|
|
|
|
console.error('手动确认支付失败:', error)
|
|
|
|
|
|
message.error(error?.message || '手动确认支付失败')
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
manualPayLoading.value = false
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const openAfterSales = (order: any) => {
|
|
|
|
|
|
router.push({
|
|
|
|
|
|
path: '/admin/after-sales',
|
|
|
|
|
|
query: { orderId: String(order.id) }
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-18 09:46:11 +08:00
|
|
|
|
/** noop is a local helper used by this page script. */
|
2026-05-13 12:43:01 +08:00
|
|
|
|
const noop = () => {}
|
|
|
|
|
|
|
|
|
|
|
|
onMounted(async () => {
|
|
|
|
|
|
resolveCurrentUserType()
|
|
|
|
|
|
await loadUserPermissions()
|
2026-05-21 18:43:59 +08:00
|
|
|
|
await loadShopOptions()
|
2026-05-13 12:43:01 +08:00
|
|
|
|
await loadOrders()
|
|
|
|
|
|
})
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
|
.orders {
|
|
|
|
|
|
padding: 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.detail-items {
|
|
|
|
|
|
display: grid;
|
|
|
|
|
|
gap: 12px;
|
|
|
|
|
|
}
|
2026-05-21 18:43:59 +08:00
|
|
|
|
|
|
|
|
|
|
.admin-filter-bar {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
flex-wrap: wrap;
|
|
|
|
|
|
gap: 10px;
|
|
|
|
|
|
margin-bottom: 16px;
|
|
|
|
|
|
}
|
2026-05-24 18:09:11 +08:00
|
|
|
|
|
|
|
|
|
|
.order-action-alert {
|
|
|
|
|
|
margin-bottom: 16px;
|
|
|
|
|
|
}
|
2026-05-13 12:43:01 +08:00
|
|
|
|
</style>
|