功能:新增下一阶段运营能力和生产部署

This commit is contained in:
xiaowang
2026-05-24 18:09:11 +08:00
parent 8116abc9b5
commit 1d077d4089
157 changed files with 9206 additions and 74 deletions
+178 -3
View File
@@ -9,6 +9,22 @@
</header>
<main class="content">
<section class="growth-panel">
<div>
<strong>{{ growthSummary.levelName || '成长会员' }}</strong>
<span>成长值 {{ growthSummary.growthValue ?? 0 }} · 预约 {{ growthSummary.appointmentCount ?? 0 }} 次 · 评价 {{ growthSummary.reviewCount ?? 0 }} 次</span>
</div>
<a-button size="small" @click="loadGrowthSummary">刷新</a-button>
</section>
<section v-if="myAfterSales.length" class="after-sale-panel">
<div class="after-sale-panel__title">我的售后</div>
<div v-for="item in myAfterSales.slice(0, 3)" :key="item.id" class="after-sale-row">
<span>{{ item.afterSaleNo || `售后 ${item.id}` }}</span>
<strong>{{ afterSaleStatusText(item.status) }}</strong>
</div>
</section>
<section v-if="orders.length" class="filter-panel">
<a-input v-model:value="filters.keyword" allow-clear placeholder="搜索订单号、作品、美甲师" />
<div class="filter-row">
@@ -102,6 +118,9 @@
<div class="footer">
<span>总计:¥{{ order.actualAmount.toFixed(2) }}</span>
<div class="footer-actions">
<a-button v-if="canPreparePayment(order)" size="small" @click="preparePayment(order)">准备支付</a-button>
<a-button v-if="canMockPay(order)" size="small" type="primary" @click="mockPay(order)">模拟支付</a-button>
<a-button v-if="canApplyAfterSale(order)" size="small" @click="openAfterSaleModal(order)">申请售后</a-button>
<a-button v-if="hasRebookableItems(order)" size="small" type="primary" @click="rebookOrder(order)">复刻同款</a-button>
<a-button v-if="order.status === 1" size="small" danger @click="cancelOrder(order.id)">取消订单</a-button>
</div>
@@ -152,6 +171,39 @@
</a-form-item>
</a-form>
</a-modal>
<a-modal
v-model:open="afterSaleModalOpen"
title="申请售后"
:confirm-loading="afterSaleSubmitting"
@ok="submitAfterSale"
@cancel="closeAfterSaleModal"
>
<a-form layout="vertical">
<a-form-item label="订单">
<a-input :value="activeAfterSaleOrder?.orderNo || ''" disabled />
</a-form-item>
<a-form-item label="订单项">
<a-select v-model:value="afterSaleForm.orderItemId" allow-clear placeholder="可选,默认整单">
<a-select-option v-for="item in activeAfterSaleOrder?.items || []" :key="item.id" :value="item.id">
{{ item.productTitle }}
</a-select-option>
</a-select>
</a-form-item>
<a-form-item label="类型" required>
<a-select v-model:value="afterSaleForm.type">
<a-select-option value="REFUND">退款</a-select-option>
<a-select-option value="AFTER_SALE">售后</a-select-option>
</a-select>
</a-form-item>
<a-form-item label="退款金额">
<a-input-number v-model:value="afterSaleForm.refundAmount" :min="0" :step="0.01" style="width: 100%" />
</a-form-item>
<a-form-item label="原因" required>
<a-textarea v-model:value="afterSaleForm.reason" :rows="4" :maxlength="300" placeholder="请说明申请原因" />
</a-form-item>
</a-form>
</a-modal>
</div>
</template>
@@ -166,8 +218,8 @@ import { LeftOutlined } from '@ant-design/icons-vue'
import { message, Modal } from 'ant-design-vue'
import { fileApi } from '../api/index'
import { cartApi } from '../api/cart'
import { orderApi } from '../api/order'
import type { OrderArtistChangeRequestVO, OrderArtistReviewVO } from '../api/order'
import { afterSaleApi, growthApi, orderApi, paymentApi } from '../api/order'
import type { AfterSaleVO, GrowthSummaryVO, OrderArtistChangeRequestVO, OrderArtistReviewVO } from '../api/order'
import { userApi } from '@/api/user'
import type { IdType } from '@/utils/id'
import { runWithGlobalLoading } from '@/utils/action-loading'
@@ -186,6 +238,8 @@ const updateCartCount = inject<() => Promise<void>>('updateCartCount', async ()
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
const orders = ref<any[]>([])
const myAfterSales = ref<AfterSaleVO[]>([])
const growthSummary = ref<GrowthSummaryVO>({})
/**
* Purpose: imageIdCache supports OrderView.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.
@@ -228,6 +282,9 @@ const activeReview = ref<OrderArtistReviewVO | null>(null)
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
const rejectModalOpen = ref(false)
const afterSaleModalOpen = ref(false)
const afterSaleSubmitting = ref(false)
const activeAfterSaleOrder = ref<any | null>(null)
/**
* Purpose: changeProcessing supports OrderView.vue by holding or executing the change processing 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.
@@ -265,6 +322,13 @@ const rejectForm = reactive({
rejectReason: ''
})
const afterSaleForm = reactive({
orderItemId: undefined as IdType | undefined,
type: 'REFUND',
reason: '',
refundAmount: 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()
@@ -305,6 +369,18 @@ const statusClass = (status: number) => {
return 'cancelled'
}
const isOrderPaid = (order: any) => String(order.paymentStatus || '').toUpperCase() === 'PAID'
const canPreparePayment = (order: any) => Number(order.status) === 1 && !isOrderPaid(order)
const canMockPay = (order: any) => Number(order.status) === 1 && String(order.paymentStatus || '').toUpperCase() === 'PAYING'
const canApplyAfterSale = (order: any) => Number(order.status) === 2 || isOrderPaid(order)
const afterSaleStatusText = (status?: string) => {
if (status === 'PENDING') return '待处理'
if (status === 'APPROVED') return '已通过'
if (status === 'REJECTED') return '已驳回'
return status || '-'
}
/**
* Purpose: sameId supports OrderView.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.
@@ -474,6 +550,95 @@ const resetFilters = () => {
filters.maxAmount = undefined
}
const loadGrowthSummary = async () => {
try {
growthSummary.value = await growthApi.getSummary()
} catch (error) {
console.error('加载成长摘要失败:', error)
growthSummary.value = {}
}
}
const loadMyAfterSales = async () => {
try {
const result = await afterSaleApi.listMy({ page: 1, size: 20 })
myAfterSales.value = result.list || []
} catch (error) {
console.error('加载售后列表失败:', error)
myAfterSales.value = []
}
}
const preparePayment = async (order: any) => {
try {
await runWithGlobalLoading(async () => {
await paymentApi.prepareOrderPayment(order.id)
await loadOrders()
})
message.success('支付单已准备,可继续模拟支付')
} catch (error: any) {
message.error(error?.message || '准备支付失败')
}
}
const mockPay = async (order: any) => {
try {
await runWithGlobalLoading(async () => {
await paymentApi.mockSuccess(order.id)
await loadOrders()
})
message.success('模拟支付成功')
} catch (error: any) {
message.error(error?.message || '模拟支付失败')
}
}
const openAfterSaleModal = (order: any) => {
activeAfterSaleOrder.value = order
const firstItem = (order.items || [])[0]
afterSaleForm.orderItemId = firstItem?.id
afterSaleForm.type = 'REFUND'
afterSaleForm.reason = ''
afterSaleForm.refundAmount = Number(order.actualAmount || order.totalAmount || 0)
afterSaleModalOpen.value = true
}
const closeAfterSaleModal = () => {
afterSaleModalOpen.value = false
activeAfterSaleOrder.value = null
afterSaleForm.orderItemId = undefined
afterSaleForm.type = 'REFUND'
afterSaleForm.reason = ''
afterSaleForm.refundAmount = undefined
}
const submitAfterSale = async () => {
if (!activeAfterSaleOrder.value) return
if (!afterSaleForm.reason.trim()) {
message.warning('请填写售后原因')
return
}
afterSaleSubmitting.value = true
try {
await runWithGlobalLoading(async () => {
await afterSaleApi.apply({
orderId: activeAfterSaleOrder.value.id,
orderItemId: afterSaleForm.orderItemId,
type: afterSaleForm.type,
reason: afterSaleForm.reason.trim(),
refundAmount: afterSaleForm.refundAmount
})
await loadMyAfterSales()
})
message.success('售后申请已提交')
closeAfterSaleModal()
} catch (error: any) {
message.error(error?.message || '提交售后失败')
} finally {
afterSaleSubmitting.value = false
}
}
const normalizeRebookQuantity = (quantity: unknown) => {
const value = Number(quantity)
return Number.isFinite(value) && value > 0 ? Math.max(1, Math.floor(value)) : 1
@@ -803,7 +968,10 @@ const cancelOrder = (orderId: IdType) => {
})
}
onMounted(loadOrders)
onMounted(async () => {
await Promise.all([loadGrowthSummary(), loadMyAfterSales()])
await loadOrders()
})
</script>
<style scoped>
@@ -812,6 +980,13 @@ onMounted(loadOrders)
.header h1 { margin: 0; font-size: 18px; color: var(--text-primary); }
.placeholder { width: 40px; height: 40px; }
.content { padding: 15px; }
.growth-panel, .after-sale-panel { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 12px; padding: 12px; border: 1px solid var(--theme-border); border-radius: 14px; background: var(--theme-card-bg); box-shadow: 0 14px 34px rgba(122, 67, 88, 0.08); }
.growth-panel div { display: grid; gap: 4px; min-width: 0; }
.growth-panel strong, .after-sale-panel__title { color: var(--text-primary); font-weight: 700; }
.growth-panel span { color: var(--text-secondary); font-size: 13px; }
.after-sale-panel { display: grid; }
.after-sale-row { display: flex; justify-content: space-between; gap: 8px; color: var(--text-secondary); font-size: 13px; }
.after-sale-row strong { color: var(--theme-primary); }
.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); }
.filter-row { display: flex; gap: 8px; align-items: center; }
.filter-select, .filter-date, .filter-number { flex: 1; min-width: 0; }