功能:完善门店能力与用户安全配置

This commit is contained in:
xiaowang
2026-05-18 10:04:57 +08:00
parent 4563dd2538
commit 3797938616
356 changed files with 24983 additions and 1858 deletions
+147 -6
View File
@@ -5,17 +5,58 @@
<LeftOutlined :style="{ fontSize: '20px' }" />
</a-button>
<h1>美甲师订单</h1>
<div class="placeholder" />
<a-button type="link" @click="router.push('/artist-calendar')">日历</a-button>
</header>
<main class="content">
<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>
<a-empty v-if="!orders.length" description="暂无订单">
<a-button type="primary" @click="handleRefreshClick">刷新</a-button>
</a-empty>
<a-empty v-else-if="!filteredOrders.length" description="没有符合条件的订单">
<a-button @click="resetFilters">清空筛选</a-button>
</a-empty>
<a-card v-for="order in orders" :key="order.id" class="order-card">
<a-card
v-for="order in filteredOrders"
:key="order.id"
:ref="el => setOrderRef(order.id, el)"
class="order-card"
:class="{ 'is-target': isTargetOrder(order.id) }"
>
<div class="order-head">
<span>订单号:{{ order.orderNo }}</span>
<div class="order-title">
<span>订单号:{{ order.orderNo }}</span>
<span v-if="order.artistOrderSourceText" class="source-tag" :class="sourceClass(order.artistOrderSource)">
{{ order.artistOrderSourceText }}
</span>
</div>
<span class="status" :class="statusClass(order.status)">{{ order.statusText }}</span>
</div>
@@ -38,7 +79,7 @@
<div class="footer">
<span>当前项目合计:¥{{ order.actualAmount.toFixed(2) }}</span>
<a-button v-if="order.status === 1" size="small" type="primary" @click="completeOrder(order.id)">
<a-button v-if="canComplete(order)" size="small" type="primary" @click="completeOrder(order.id)">
完成服务
</a-button>
</div>
@@ -48,8 +89,12 @@
</template>
<script setup lang="ts">
import { onMounted, ref } from 'vue'
import { useRouter } from 'vue-router'
/**
* 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'
import { LeftOutlined } from '@ant-design/icons-vue'
import { message, Modal } from 'ant-design-vue'
import { fileApi } from '../api/index'
@@ -58,15 +103,98 @@ import type { IdType } from '@/utils/id'
import { runWithGlobalLoading } from '@/utils/action-loading'
const router = useRouter()
const route = useRoute()
const orders = ref<any[]>([])
const imageIdCache = ref<Record<string, string>>({})
const orderRefs = ref<Record<string, any>>({})
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
})
/** 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. */
const statusClass = (status: number) => {
if (status === 1) return 'pending'
if (status === 2) return 'completed'
return 'cancelled'
}
/** 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'
}
/** canComplete is a local helper used by this page script. */
const canComplete = (order: any) => {
return order.status === 1 && order.artistOrderSource !== 'SELF'
}
/** 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. */
const loadOrders = async () => {
try {
orders.value = (await orderApi.getArtistOrders() as unknown as any[]) || []
@@ -83,15 +211,18 @@ const loadOrders = async () => {
}
}
}
await scrollToTargetOrder()
} catch {
message.error('获取订单列表失败')
}
}
/** handleRefreshClick is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
const handleRefreshClick = async () => {
await runWithGlobalLoading(() => loadOrders())
}
/** completeOrder is a local helper used by this page script. */
const completeOrder = (orderId: IdType) => {
Modal.confirm({
title: '确认完成服务',
@@ -119,9 +250,19 @@ onMounted(loadOrders)
.header h1 { margin: 0; font-size: 18px; }
.placeholder { width: 40px; height: 40px; }
.content { padding: 15px; }
.filter-panel { display: grid; gap: 10px; margin-bottom: 12px; padding: 12px; border-radius: 8px; background: #fff; }
.filter-row { display: flex; gap: 8px; align-items: center; }
.filter-select, .filter-date, .filter-number { flex: 1; min-width: 0; }
.filter-actions { display: flex; align-items: center; justify-content: space-between; color: #888; font-size: 12px; }
.order-card { margin-bottom: 12px; border-radius: 12px; }
.order-card.is-target { border-color: #d9955d; box-shadow: 0 0 0 2px rgba(217, 149, 93, .22); }
.order-head, .footer { display: flex; align-items: center; justify-content: space-between; }
.order-head { margin-bottom: 12px; padding-bottom: 10px; border-bottom: 1px solid #f0f0f0; }
.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; }
.source-service { background: #e6f4ff; color: #1677ff; }
.source-self { background: #f9f0ff; color: #722ed1; }
.source-both { background: #fff7e6; color: #d46b08; }
.customer-meta { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-bottom: 12px; color: #666; font-size: 13px; }
.status { padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pending { background: #fff7e6; color: #fa8c16; }