2026-03-19 14:43:57 +08:00
|
|
|
|
<template>
|
2026-03-19 20:19:41 +08:00
|
|
|
|
<div class="page">
|
2026-03-19 14:43:57 +08:00
|
|
|
|
<header class="header">
|
2026-03-19 20:19:41 +08:00
|
|
|
|
<a-button type="text" @click="router.back()">
|
2026-03-19 14:43:57 +08:00
|
|
|
|
<LeftOutlined :style="{ fontSize: '20px' }" />
|
|
|
|
|
|
</a-button>
|
|
|
|
|
|
<h1>美甲师订单</h1>
|
2026-05-21 18:43:59 +08:00
|
|
|
|
<a-button v-if="showCalendarEntry" type="link" @click="router.push('/artist-calendar')">日历</a-button>
|
|
|
|
|
|
<div v-else class="placeholder" />
|
2026-03-19 14:43:57 +08:00
|
|
|
|
</header>
|
|
|
|
|
|
|
2026-03-19 20:19:41 +08:00
|
|
|
|
<main class="content">
|
2026-05-18 09:46:11 +08:00
|
|
|
|
<section v-if="orders.length" class="filter-panel">
|
|
|
|
|
|
<a-input v-model:value="filters.keyword" allow-clear placeholder="搜索订单号、客户、作品" />
|
|
|
|
|
|
<div class="filter-row">
|
|
|
|
|
|
<a-select v-model:value="filters.source" class="filter-select" placeholder="订单来源">
|
|
|
|
|
|
<a-select-option value="all">全部来源</a-select-option>
|
|
|
|
|
|
<a-select-option value="SERVICE">客户预约我的订单</a-select-option>
|
|
|
|
|
|
<a-select-option value="SELF">我下的订单</a-select-option>
|
|
|
|
|
|
<a-select-option value="BOTH">两者都有</a-select-option>
|
|
|
|
|
|
</a-select>
|
|
|
|
|
|
<a-select v-model:value="filters.status" class="filter-select" placeholder="订单状态">
|
|
|
|
|
|
<a-select-option value="all">全部状态</a-select-option>
|
|
|
|
|
|
<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>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="filter-row">
|
|
|
|
|
|
<a-date-picker v-model:value="filters.date" class="filter-date" popup-class-name="yumi-date-picker-panel" placeholder="预约日期" />
|
|
|
|
|
|
<a-input-number v-model:value="filters.minAmount" class="filter-number" :min="0" placeholder="最低金额" />
|
|
|
|
|
|
<a-input-number v-model:value="filters.maxAmount" class="filter-number" :min="0" placeholder="最高金额" />
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="filter-actions">
|
|
|
|
|
|
<span>共 {{ filteredOrders.length }} / {{ orders.length }} 个订单</span>
|
|
|
|
|
|
<a-button @click="resetFilters">重置</a-button>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
2026-03-19 20:19:41 +08:00
|
|
|
|
<a-empty v-if="!orders.length" description="暂无订单">
|
2026-05-13 12:43:01 +08:00
|
|
|
|
<a-button type="primary" @click="handleRefreshClick">刷新</a-button>
|
2026-03-19 14:43:57 +08:00
|
|
|
|
</a-empty>
|
2026-05-18 09:46:11 +08:00
|
|
|
|
<a-empty v-else-if="!filteredOrders.length" description="没有符合条件的订单">
|
|
|
|
|
|
<a-button @click="resetFilters">清空筛选</a-button>
|
|
|
|
|
|
</a-empty>
|
2026-03-19 20:19:41 +08:00
|
|
|
|
|
2026-05-18 09:46:11 +08:00
|
|
|
|
<a-card
|
|
|
|
|
|
v-for="order in filteredOrders"
|
|
|
|
|
|
:key="order.id"
|
2026-05-21 18:43:59 +08:00
|
|
|
|
:ref="(el: any) => setOrderRef(order.id, el)"
|
2026-05-18 09:46:11 +08:00
|
|
|
|
class="order-card"
|
|
|
|
|
|
:class="{ 'is-target': isTargetOrder(order.id) }"
|
|
|
|
|
|
>
|
2026-03-19 20:19:41 +08:00
|
|
|
|
<div class="order-head">
|
2026-05-18 09:46:11 +08:00
|
|
|
|
<div class="order-title">
|
|
|
|
|
|
<span>订单号:{{ order.orderNo }}</span>
|
|
|
|
|
|
<span v-if="order.artistOrderSourceText" class="source-tag" :class="sourceClass(order.artistOrderSource)">
|
|
|
|
|
|
{{ order.artistOrderSourceText }}
|
|
|
|
|
|
</span>
|
|
|
|
|
|
</div>
|
2026-03-19 20:19:41 +08:00
|
|
|
|
<span class="status" :class="statusClass(order.status)">{{ order.statusText }}</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
2026-05-13 12:43:01 +08:00
|
|
|
|
<div class="customer-meta">
|
|
|
|
|
|
<span>预约用户:{{ order.customerNickname || '用户' }}</span>
|
|
|
|
|
|
<span v-if="order.customerPhoneMasked">联系电话:{{ order.customerPhoneMasked }}</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
2026-03-19 20:19:41 +08:00
|
|
|
|
<div v-for="item in order.items" :key="item.id" class="item">
|
|
|
|
|
|
<div class="thumb">
|
|
|
|
|
|
<img v-if="item.productImage" :src="item.productImage" :alt="item.productTitle" />
|
|
|
|
|
|
<span v-else>{{ item.productTitle[0] }}</span>
|
2026-03-19 14:43:57 +08:00
|
|
|
|
</div>
|
2026-03-19 20:19:41 +08:00
|
|
|
|
<div class="main">
|
|
|
|
|
|
<div class="title">{{ item.productTitle }}</div>
|
|
|
|
|
|
<div class="line">¥{{ item.price.toFixed(2) }} x {{ item.quantity }}</div>
|
|
|
|
|
|
<div v-if="item.appointmentTime" class="line appointment">预约时间:{{ item.appointmentTime }}</div>
|
2026-05-23 15:16:40 +08:00
|
|
|
|
<div v-if="pendingArtistChangeForItem(order, item)" class="change-status">
|
|
|
|
|
|
改派申请处理中:{{ pendingArtistChangeForItem(order, item)?.requestedArtistName || '新美甲师' }}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div v-else-if="canRequestArtistChange(order, item)" class="change-action">
|
|
|
|
|
|
<span>需要更换服务美甲师</span>
|
|
|
|
|
|
<a-button size="small" @click="openArtistChangeModal(order, item)">申请改派</a-button>
|
|
|
|
|
|
</div>
|
2026-03-19 14:43:57 +08:00
|
|
|
|
</div>
|
2026-03-19 20:19:41 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div class="footer">
|
|
|
|
|
|
<span>当前项目合计:¥{{ order.actualAmount.toFixed(2) }}</span>
|
2026-05-18 09:46:11 +08:00
|
|
|
|
<a-button v-if="canComplete(order)" size="small" type="primary" @click="completeOrder(order.id)">
|
2026-03-19 20:19:41 +08:00
|
|
|
|
完成服务
|
|
|
|
|
|
</a-button>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</a-card>
|
|
|
|
|
|
</main>
|
2026-05-23 15:16:40 +08:00
|
|
|
|
|
|
|
|
|
|
<a-modal
|
|
|
|
|
|
v-model:open="artistChangeModalOpen"
|
|
|
|
|
|
title="申请改派"
|
|
|
|
|
|
:confirm-loading="artistChangeSubmitting"
|
|
|
|
|
|
@ok="submitArtistChangeRequest"
|
|
|
|
|
|
@cancel="closeArtistChangeModal"
|
|
|
|
|
|
>
|
|
|
|
|
|
<a-form layout="vertical">
|
|
|
|
|
|
<a-form-item label="当前美甲师">
|
|
|
|
|
|
<span>{{ artistChangeOptions?.currentArtistName || activeArtistChangeItem?.artistName || '未分配' }}</span>
|
|
|
|
|
|
</a-form-item>
|
|
|
|
|
|
<a-form-item label="新美甲师" required>
|
|
|
|
|
|
<a-select
|
|
|
|
|
|
v-model:value="artistChangeForm.requestedArtistId"
|
|
|
|
|
|
:loading="artistChangeOptionsLoading"
|
|
|
|
|
|
placeholder="请选择新的美甲师"
|
|
|
|
|
|
>
|
|
|
|
|
|
<a-select-option
|
|
|
|
|
|
v-for="artist in selectableArtistOptions"
|
|
|
|
|
|
:key="String(artist.artistId)"
|
|
|
|
|
|
:value="artist.artistId"
|
|
|
|
|
|
>
|
|
|
|
|
|
{{ artist.artistName }}
|
|
|
|
|
|
</a-select-option>
|
|
|
|
|
|
</a-select>
|
|
|
|
|
|
</a-form-item>
|
|
|
|
|
|
<a-form-item label="改派原因" required>
|
|
|
|
|
|
<a-textarea v-model:value="artistChangeForm.reason" :rows="4" :maxlength="300" placeholder="请说明申请改派的原因" />
|
|
|
|
|
|
</a-form-item>
|
|
|
|
|
|
</a-form>
|
|
|
|
|
|
</a-modal>
|
2026-03-19 14:43:57 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
2026-05-18 09:46:11 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* ArtistOrderView page script.
|
|
|
|
|
|
* Call guide: the template binds the reactive state below, and the methods are triggered by button clicks, lifecycle hooks, or router events.
|
|
|
|
|
|
*/
|
|
|
|
|
|
import { computed, nextTick, onMounted, reactive, ref } from 'vue'
|
|
|
|
|
|
import { useRoute, useRouter } from 'vue-router'
|
2026-03-19 14:43:57 +08:00
|
|
|
|
import { LeftOutlined } from '@ant-design/icons-vue'
|
|
|
|
|
|
import { message, Modal } from 'ant-design-vue'
|
2026-05-21 18:43:59 +08:00
|
|
|
|
import { userApi } from '@/api/user'
|
2026-03-19 14:43:57 +08:00
|
|
|
|
import { fileApi } from '../api/index'
|
2026-03-19 20:19:41 +08:00
|
|
|
|
import { orderApi } from '../api/order'
|
2026-05-23 15:16:40 +08:00
|
|
|
|
import type { OrderArtistChangeOptionsVO, OrderArtistChangeRequestVO } from '../api/order'
|
2026-03-27 14:55:41 +08:00
|
|
|
|
import type { IdType } from '@/utils/id'
|
2026-05-13 12:43:01 +08:00
|
|
|
|
import { runWithGlobalLoading } from '@/utils/action-loading'
|
2026-03-19 14:43:57 +08:00
|
|
|
|
|
2026-05-23 18:44:57 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* Purpose: router supports ArtistOrderView.vue by holding or executing the router 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-03-19 14:43:57 +08:00
|
|
|
|
const router = useRouter()
|
2026-05-23 18:44:57 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* Purpose: route supports ArtistOrderView.vue by holding or executing the route 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-18 09:46:11 +08:00
|
|
|
|
const route = useRoute()
|
2026-05-23 18:44:57 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* Purpose: orders supports ArtistOrderView.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-03-19 14:43:57 +08:00
|
|
|
|
const orders = ref<any[]>([])
|
2026-05-23 18:44:57 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* Purpose: imageIdCache supports ArtistOrderView.vue by holding or executing the image id cache 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-03-19 14:43:57 +08:00
|
|
|
|
const imageIdCache = ref<Record<string, string>>({})
|
2026-05-23 18:44:57 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* Purpose: orderRefs supports ArtistOrderView.vue by holding or executing the order refs 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-18 09:46:11 +08:00
|
|
|
|
const orderRefs = ref<Record<string, any>>({})
|
2026-05-23 18:44:57 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* Purpose: showCalendarEntry supports ArtistOrderView.vue by holding or executing the show calendar entry 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 showCalendarEntry = ref(false)
|
2026-05-23 18:44:57 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* Purpose: currentUserId supports ArtistOrderView.vue by holding or executing the current user 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-23 15:16:40 +08:00
|
|
|
|
const currentUserId = ref<IdType>()
|
2026-05-23 18:44:57 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* Purpose: artistChangeModalOpen supports ArtistOrderView.vue by holding or executing the artist change modal open 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-23 15:16:40 +08:00
|
|
|
|
const artistChangeModalOpen = ref(false)
|
2026-05-23 18:44:57 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* Purpose: artistChangeSubmitting supports ArtistOrderView.vue by holding or executing the artist change submitting 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-23 15:16:40 +08:00
|
|
|
|
const artistChangeSubmitting = ref(false)
|
2026-05-23 18:44:57 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* Purpose: artistChangeOptionsLoading supports ArtistOrderView.vue by holding or executing the artist change options 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-23 15:16:40 +08:00
|
|
|
|
const artistChangeOptionsLoading = ref(false)
|
2026-05-23 18:44:57 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* Purpose: artistChangeOptions supports ArtistOrderView.vue by holding or executing the artist change 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-23 15:16:40 +08:00
|
|
|
|
const artistChangeOptions = ref<OrderArtistChangeOptionsVO | null>(null)
|
2026-05-23 18:44:57 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* Purpose: activeArtistChangeOrder supports ArtistOrderView.vue by holding or executing the active artist change 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-23 15:16:40 +08:00
|
|
|
|
const activeArtistChangeOrder = ref<any | null>(null)
|
2026-05-23 18:44:57 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* Purpose: activeArtistChangeItem supports ArtistOrderView.vue by holding or executing the active artist change item 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-23 15:16:40 +08:00
|
|
|
|
const activeArtistChangeItem = ref<any | null>(null)
|
2026-05-23 18:44:57 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* Purpose: filters supports ArtistOrderView.vue by holding or executing the 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-18 09:46:11 +08:00
|
|
|
|
const filters = reactive({
|
|
|
|
|
|
keyword: '',
|
|
|
|
|
|
source: 'all',
|
|
|
|
|
|
status: 'all' as 'all' | number,
|
|
|
|
|
|
date: null as any,
|
|
|
|
|
|
minAmount: undefined as number | undefined,
|
|
|
|
|
|
maxAmount: undefined as number | undefined
|
|
|
|
|
|
})
|
2026-05-23 18:44:57 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* Purpose: artistChangeForm supports ArtistOrderView.vue by holding or executing the artist change form 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-23 15:16:40 +08:00
|
|
|
|
const artistChangeForm = reactive({
|
|
|
|
|
|
requestedArtistId: undefined as IdType | undefined,
|
|
|
|
|
|
reason: ''
|
|
|
|
|
|
})
|
2026-03-19 14:43:57 +08:00
|
|
|
|
|
2026-05-18 09:46:11 +08:00
|
|
|
|
/** filteredOrders is a reactive state variable used by the template and event handlers. */
|
|
|
|
|
|
const filteredOrders = computed(() => {
|
|
|
|
|
|
const keyword = filters.keyword.trim().toLowerCase()
|
|
|
|
|
|
const targetDate = filters.date?.format?.('YYYY-MM-DD')
|
|
|
|
|
|
return orders.value.filter(order => {
|
|
|
|
|
|
if (filters.source !== 'all' && order.artistOrderSource !== filters.source) return false
|
|
|
|
|
|
if (filters.status !== 'all' && order.status !== filters.status) return false
|
|
|
|
|
|
const amount = Number(order.actualAmount || 0)
|
|
|
|
|
|
if (filters.minAmount !== undefined && amount < filters.minAmount) return false
|
|
|
|
|
|
if (filters.maxAmount !== undefined && amount > filters.maxAmount) return false
|
|
|
|
|
|
const items = order.items || []
|
|
|
|
|
|
if (targetDate && !items.some((item: any) => String(item.appointmentTime || '').slice(0, 10) === targetDate)) {
|
|
|
|
|
|
return false
|
|
|
|
|
|
}
|
|
|
|
|
|
if (keyword) {
|
|
|
|
|
|
const haystack = [
|
|
|
|
|
|
order.orderNo,
|
|
|
|
|
|
order.statusText,
|
|
|
|
|
|
order.artistOrderSourceText,
|
|
|
|
|
|
order.customerNickname,
|
|
|
|
|
|
order.customerPhoneMasked,
|
|
|
|
|
|
...items.flatMap((item: any) => [item.productTitle, item.appointmentTime])
|
|
|
|
|
|
].filter(Boolean).join(' ').toLowerCase()
|
|
|
|
|
|
if (!haystack.includes(keyword)) return false
|
|
|
|
|
|
}
|
|
|
|
|
|
return true
|
|
|
|
|
|
})
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
/** targetOrderId is a local helper used by this page script. */
|
|
|
|
|
|
const targetOrderId = () => String(route.query.orderId || '')
|
|
|
|
|
|
/** isTargetOrder is a local helper used by this page script. */
|
|
|
|
|
|
const isTargetOrder = (orderId: IdType) => targetOrderId() === String(orderId)
|
|
|
|
|
|
|
|
|
|
|
|
/** setOrderRef is a local helper used by this page script. */
|
|
|
|
|
|
const setOrderRef = (orderId: IdType, el: any) => {
|
|
|
|
|
|
if (!el) return
|
|
|
|
|
|
orderRefs.value[String(orderId)] = el
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** scrollToTargetOrder is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
|
|
|
|
|
const scrollToTargetOrder = async () => {
|
|
|
|
|
|
const id = targetOrderId()
|
|
|
|
|
|
if (!id) return
|
|
|
|
|
|
await nextTick()
|
|
|
|
|
|
const target = orderRefs.value[id]?.$el || orderRefs.value[id]
|
|
|
|
|
|
target?.scrollIntoView?.({ behavior: 'smooth', block: 'center' })
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** statusClass is a local helper used by this page script. */
|
2026-03-19 20:19:41 +08:00
|
|
|
|
const statusClass = (status: number) => {
|
|
|
|
|
|
if (status === 1) return 'pending'
|
|
|
|
|
|
if (status === 2) return 'completed'
|
|
|
|
|
|
return 'cancelled'
|
2026-03-19 14:43:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-18 09:46:11 +08:00
|
|
|
|
/** sourceClass is a local helper used by this page script. */
|
|
|
|
|
|
const sourceClass = (source?: string) => {
|
|
|
|
|
|
if (source === 'SELF') return 'source-self'
|
|
|
|
|
|
if (source === 'BOTH') return 'source-both'
|
|
|
|
|
|
return 'source-service'
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-23 18:44:57 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* Purpose: sameId supports ArtistOrderView.vue by holding or executing the same 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-23 15:16:40 +08:00
|
|
|
|
const sameId = (left: unknown, right: unknown) => {
|
|
|
|
|
|
return left !== undefined && left !== null && right !== undefined && right !== null && String(left) === String(right)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-23 18:44:57 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* Purpose: pendingArtistChangeForItem supports ArtistOrderView.vue by holding or executing the pending artist change for item 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-23 15:16:40 +08:00
|
|
|
|
const pendingArtistChangeForItem = (order: any, item: any): OrderArtistChangeRequestVO | undefined => {
|
|
|
|
|
|
const itemValue = item?.pendingArtistChangeRequest as OrderArtistChangeRequestVO | undefined
|
|
|
|
|
|
if (itemValue) return itemValue
|
|
|
|
|
|
const orderValue = order?.pendingArtistChangeRequest as OrderArtistChangeRequestVO | undefined
|
|
|
|
|
|
if (!orderValue) return undefined
|
|
|
|
|
|
return sameId(orderValue.orderItemId, item.id) || (order.items || []).length === 1 ? orderValue : undefined
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-18 09:46:11 +08:00
|
|
|
|
/** canComplete is a local helper used by this page script. */
|
|
|
|
|
|
const canComplete = (order: any) => {
|
|
|
|
|
|
return order.status === 1 && order.artistOrderSource !== 'SELF'
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-23 18:44:57 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* Purpose: canRequestArtistChange supports ArtistOrderView.vue by holding or executing the can request artist change 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-23 15:16:40 +08:00
|
|
|
|
const canRequestArtistChange = (order: any, item: any) => {
|
|
|
|
|
|
const assignedToCurrentUser = !currentUserId.value || !item.artistId || sameId(item.artistId, currentUserId.value)
|
|
|
|
|
|
return order.status === 1 && item.id && assignedToCurrentUser && !pendingArtistChangeForItem(order, item)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-23 18:44:57 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* Purpose: selectableArtistOptions supports ArtistOrderView.vue by holding or executing the selectable artist 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-23 15:16:40 +08:00
|
|
|
|
const selectableArtistOptions = computed(() => {
|
|
|
|
|
|
const options = artistChangeOptions.value?.artists || []
|
|
|
|
|
|
return options.filter(artist => !sameId(artist.artistId, artistChangeOptions.value?.currentArtistId))
|
|
|
|
|
|
})
|
|
|
|
|
|
|
2026-05-18 09:46:11 +08:00
|
|
|
|
/** resetFilters is a local helper used by this page script. */
|
|
|
|
|
|
const resetFilters = () => {
|
|
|
|
|
|
filters.keyword = ''
|
|
|
|
|
|
filters.source = 'all'
|
|
|
|
|
|
filters.status = 'all'
|
|
|
|
|
|
filters.date = null
|
|
|
|
|
|
filters.minAmount = undefined
|
|
|
|
|
|
filters.maxAmount = undefined
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** loadOrders is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
2026-03-19 20:19:41 +08:00
|
|
|
|
const loadOrders = async () => {
|
|
|
|
|
|
try {
|
|
|
|
|
|
orders.value = (await orderApi.getArtistOrders() as unknown as any[]) || []
|
|
|
|
|
|
for (const order of orders.value) {
|
|
|
|
|
|
for (const item of order.items || []) {
|
|
|
|
|
|
const match = item.productImage?.replace(/<[^>]*>/g, '').match(/\/api\/file\/get\/(\d+)/)
|
|
|
|
|
|
if (!match?.[1]) continue
|
|
|
|
|
|
const imageId = match[1]
|
|
|
|
|
|
try {
|
2026-03-27 14:55:41 +08:00
|
|
|
|
if (!imageIdCache.value[imageId]) imageIdCache.value[imageId] = await fileApi.getSignedUrl(imageId) as any
|
2026-03-19 20:19:41 +08:00
|
|
|
|
item.productImage = imageIdCache.value[imageId]
|
|
|
|
|
|
} catch {
|
|
|
|
|
|
item.productImage = ''
|
2026-03-19 14:43:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2026-05-18 09:46:11 +08:00
|
|
|
|
await scrollToTargetOrder()
|
2026-03-19 20:19:41 +08:00
|
|
|
|
} catch {
|
|
|
|
|
|
message.error('获取订单列表失败')
|
2026-03-19 14:43:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-21 18:43:59 +08:00
|
|
|
|
/** loadCalendarAccess is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
|
|
|
|
|
const loadCalendarAccess = async () => {
|
|
|
|
|
|
showCalendarEntry.value = false
|
|
|
|
|
|
try {
|
|
|
|
|
|
const currentUser = await userApi.getUserInfo()
|
2026-05-23 15:16:40 +08:00
|
|
|
|
currentUserId.value = currentUser.id
|
2026-05-21 18:43:59 +08:00
|
|
|
|
if (currentUser.type === 3) {
|
|
|
|
|
|
showCalendarEntry.value = true
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
if (currentUser.type === 2) {
|
|
|
|
|
|
const artistInfo = await userApi.getNailArtistInfo(currentUser.id).catch(() => null)
|
|
|
|
|
|
showCalendarEntry.value = Number(artistInfo?.participateProduction) === 1
|
|
|
|
|
|
}
|
|
|
|
|
|
} catch {
|
2026-05-23 15:16:40 +08:00
|
|
|
|
currentUserId.value = undefined
|
2026-05-21 18:43:59 +08:00
|
|
|
|
showCalendarEntry.value = false
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-18 09:46:11 +08:00
|
|
|
|
/** handleRefreshClick 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 handleRefreshClick = async () => {
|
|
|
|
|
|
await runWithGlobalLoading(() => loadOrders())
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-23 18:44:57 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* Purpose: openArtistChangeModal supports ArtistOrderView.vue by holding or executing the open artist change modal 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-23 15:16:40 +08:00
|
|
|
|
const openArtistChangeModal = async (order: any, item: any) => {
|
|
|
|
|
|
if (!canRequestArtistChange(order, item)) return
|
|
|
|
|
|
activeArtistChangeOrder.value = order
|
|
|
|
|
|
activeArtistChangeItem.value = item
|
|
|
|
|
|
artistChangeOptions.value = null
|
|
|
|
|
|
artistChangeForm.requestedArtistId = undefined
|
|
|
|
|
|
artistChangeForm.reason = ''
|
|
|
|
|
|
artistChangeModalOpen.value = true
|
|
|
|
|
|
artistChangeOptionsLoading.value = true
|
|
|
|
|
|
try {
|
|
|
|
|
|
artistChangeOptions.value = await orderApi.getArtistChangeOptions(order.id, item.id)
|
|
|
|
|
|
if (!selectableArtistOptions.value.length) {
|
|
|
|
|
|
message.warning('暂无可改派的美甲师')
|
|
|
|
|
|
}
|
|
|
|
|
|
} catch {
|
|
|
|
|
|
message.error('获取可改派美甲师失败')
|
|
|
|
|
|
closeArtistChangeModal()
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
artistChangeOptionsLoading.value = false
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-23 18:44:57 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* Purpose: closeArtistChangeModal supports ArtistOrderView.vue by holding or executing the close artist change modal 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-23 15:16:40 +08:00
|
|
|
|
const closeArtistChangeModal = () => {
|
|
|
|
|
|
artistChangeModalOpen.value = false
|
|
|
|
|
|
activeArtistChangeOrder.value = null
|
|
|
|
|
|
activeArtistChangeItem.value = null
|
|
|
|
|
|
artistChangeOptions.value = null
|
|
|
|
|
|
artistChangeForm.requestedArtistId = undefined
|
|
|
|
|
|
artistChangeForm.reason = ''
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-23 18:44:57 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* Purpose: submitArtistChangeRequest supports ArtistOrderView.vue by holding or executing the submit artist change request 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-23 15:16:40 +08:00
|
|
|
|
const submitArtistChangeRequest = async () => {
|
|
|
|
|
|
if (!activeArtistChangeOrder.value || !activeArtistChangeItem.value) return
|
|
|
|
|
|
if (!artistChangeForm.requestedArtistId) {
|
|
|
|
|
|
message.warning('请选择新的美甲师')
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
const reason = artistChangeForm.reason.trim()
|
|
|
|
|
|
if (!reason) {
|
|
|
|
|
|
message.warning('请填写改派原因')
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
if (sameId(artistChangeForm.requestedArtistId, artistChangeOptions.value?.currentArtistId)) {
|
|
|
|
|
|
message.warning('新美甲师不能与当前美甲师相同')
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
artistChangeSubmitting.value = true
|
|
|
|
|
|
try {
|
|
|
|
|
|
await orderApi.requestArtistChange({
|
|
|
|
|
|
orderId: activeArtistChangeOrder.value.id,
|
|
|
|
|
|
orderItemId: activeArtistChangeItem.value.id,
|
|
|
|
|
|
requestedArtistId: artistChangeForm.requestedArtistId,
|
|
|
|
|
|
reason
|
|
|
|
|
|
})
|
|
|
|
|
|
message.success('改派申请已提交')
|
|
|
|
|
|
closeArtistChangeModal()
|
|
|
|
|
|
await loadOrders()
|
|
|
|
|
|
} catch {
|
|
|
|
|
|
message.error('提交改派申请失败')
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
artistChangeSubmitting.value = false
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-18 09:46:11 +08:00
|
|
|
|
/** completeOrder is a local helper used by this page script. */
|
2026-03-27 14:55:41 +08:00
|
|
|
|
const completeOrder = (orderId: IdType) => {
|
2026-03-19 14:43:57 +08:00
|
|
|
|
Modal.confirm({
|
|
|
|
|
|
title: '确认完成服务',
|
2026-03-19 20:19:41 +08:00
|
|
|
|
content: '确定要完成这个订单吗?',
|
2026-03-19 14:43:57 +08:00
|
|
|
|
onOk: async () => {
|
|
|
|
|
|
try {
|
2026-05-13 12:43:01 +08:00
|
|
|
|
await runWithGlobalLoading(async () => {
|
|
|
|
|
|
await orderApi.completeArtistOrder(orderId)
|
|
|
|
|
|
await loadOrders()
|
|
|
|
|
|
})
|
2026-03-19 14:43:57 +08:00
|
|
|
|
message.success('订单已完成')
|
2026-05-13 12:43:01 +08:00
|
|
|
|
} catch (error: any) {
|
2026-03-19 14:43:57 +08:00
|
|
|
|
message.error('完成订单失败')
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-21 18:43:59 +08:00
|
|
|
|
onMounted(async () => {
|
|
|
|
|
|
await Promise.all([loadCalendarAccess(), loadOrders()])
|
|
|
|
|
|
})
|
2026-03-19 14:43:57 +08:00
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
2026-05-21 18:43:59 +08:00
|
|
|
|
.page { min-height: 100vh; padding-top: 60px; background: linear-gradient(rgba(255, 255, 255, 0.68), rgba(255, 255, 255, 0.92)), var(--theme-background-image), var(--theme-page-bg); background-size: cover, cover, auto; background-position: center top; 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: 10px 15px; background: rgba(255, 255, 255, 0.92); border-bottom: 1px solid var(--theme-border); backdrop-filter: blur(14px); }
|
|
|
|
|
|
.header h1 { margin: 0; font-size: 18px; color: var(--text-primary); }
|
2026-03-19 20:19:41 +08:00
|
|
|
|
.placeholder { width: 40px; height: 40px; }
|
|
|
|
|
|
.content { padding: 15px; }
|
2026-05-21 18:43:59 +08:00
|
|
|
|
.filter-panel { display: grid; gap: 10px; margin-bottom: 12px; padding: 12px; border-radius: 14px; background: var(--theme-card-bg); border: 1px solid var(--theme-border); box-shadow: 0 14px 34px rgba(122, 67, 88, 0.08); }
|
2026-05-18 09:46:11 +08:00
|
|
|
|
.filter-row { display: flex; gap: 8px; align-items: center; }
|
|
|
|
|
|
.filter-select, .filter-date, .filter-number { flex: 1; min-width: 0; }
|
2026-05-21 18:43:59 +08:00
|
|
|
|
.filter-actions { display: flex; align-items: center; justify-content: space-between; color: var(--text-secondary); font-size: 12px; }
|
|
|
|
|
|
.order-card { margin-bottom: 12px; border-radius: 14px; border: 1px solid var(--theme-border); background: var(--theme-card-bg); box-shadow: 0 14px 34px rgba(122, 67, 88, 0.08); }
|
|
|
|
|
|
.order-card.is-target { border-color: var(--theme-primary); box-shadow: 0 0 0 2px rgba(198, 89, 125, .16); }
|
2026-03-19 20:19:41 +08:00
|
|
|
|
.order-head, .footer { display: flex; align-items: center; justify-content: space-between; }
|
2026-05-21 18:43:59 +08:00
|
|
|
|
.order-head { margin-bottom: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--theme-border); }
|
2026-05-18 09:46:11 +08:00
|
|
|
|
.order-title { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
|
|
|
|
|
|
.source-tag { padding: 3px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; }
|
2026-05-21 18:43:59 +08:00
|
|
|
|
.source-service { background: var(--theme-primary-soft); color: var(--theme-primary); }
|
|
|
|
|
|
.source-self { background: var(--theme-primary-soft); color: var(--theme-accent); }
|
|
|
|
|
|
.source-both { background: var(--theme-primary-soft); color: var(--theme-primary); }
|
|
|
|
|
|
.customer-meta { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-bottom: 12px; color: var(--text-secondary); font-size: 13px; }
|
2026-03-19 20:19:41 +08:00
|
|
|
|
.status { padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
|
2026-05-21 18:43:59 +08:00
|
|
|
|
.pending { background: var(--theme-primary-soft); color: var(--theme-primary); }
|
|
|
|
|
|
.completed { background: var(--theme-primary-soft); color: var(--theme-primary); }
|
|
|
|
|
|
.cancelled { background: var(--theme-primary-soft); color: var(--theme-accent); }
|
2026-03-19 20:19:41 +08:00
|
|
|
|
.item { display: flex; gap: 12px; margin-bottom: 12px; }
|
2026-05-21 18:43:59 +08:00
|
|
|
|
.thumb { width: 60px; height: 60px; border-radius: 10px; overflow: hidden; display: flex; align-items: center; justify-content: center; background: var(--theme-primary-soft); color: var(--theme-primary); }
|
2026-03-19 20:19:41 +08:00
|
|
|
|
.thumb img { width: 100%; height: 100%; object-fit: cover; }
|
|
|
|
|
|
.main { flex: 1; }
|
2026-05-21 18:43:59 +08:00
|
|
|
|
.title { font-weight: 600; color: var(--text-primary); }
|
|
|
|
|
|
.line { margin-top: 4px; color: var(--text-secondary); font-size: 13px; }
|
|
|
|
|
|
.appointment { color: var(--theme-primary); }
|
2026-05-23 15:16:40 +08:00
|
|
|
|
.change-status { margin-top: 8px; padding: 8px 10px; border-radius: 8px; background: var(--theme-primary-soft); color: var(--theme-primary); font-size: 13px; }
|
|
|
|
|
|
.change-action { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; padding: 8px 10px; border-radius: 8px; background: var(--theme-primary-soft); color: var(--theme-primary); font-size: 13px; }
|
2026-05-21 18:43:59 +08:00
|
|
|
|
|
|
|
|
|
|
:deep(.ant-btn-primary) { background: var(--theme-primary); border-color: var(--theme-primary); }
|
|
|
|
|
|
:deep(.ant-btn-link) { color: var(--theme-primary); }
|
2026-03-24 09:50:55 +08:00
|
|
|
|
|
2026-03-24 09:59:52 +08:00
|
|
|
|
@media (min-width: 992px) {
|
|
|
|
|
|
.content {
|
|
|
|
|
|
max-width: 980px;
|
|
|
|
|
|
margin: 0 auto;
|
|
|
|
|
|
padding: 24px;
|
2026-03-24 09:50:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2026-03-19 14:43:57 +08:00
|
|
|
|
</style>
|