feat(afterSale): 售后详情弹窗排版优化 & 批量操作按钮颜色调整

- 售后详情: 新增related关联数据展示(订单/运单/店铺), 操作状态栏, 订单操作日志
- 售后详情: 详细描述移出表格防撑开, 移除角色组/处理结果/完成时间字段
- 售后列表: 批量完成按钮改为warning橙色, 批量关闭改为danger红色
- 售后列表: 处理下拉增加等待反馈选项
- API类型: AfterSale接口补充related等关联数据类型
- 工具栏组件: resolveButtonStyle支持显式type覆盖 & 按钮key强制样式映射
This commit is contained in:
liufumingren 2026-08-11 17:47:48 +08:00
parent 797256463f
commit 91105102bf
4 changed files with 466 additions and 30 deletions

View File

@ -40,6 +40,7 @@ export interface AfterSale {
role_group: AfterSaleRoleGroup | null
resolution: string | null
resolved_at: string | null
followup_at: string | null
// 仓库理赔
claim_needed: 0 | 1
@ -63,8 +64,120 @@ export interface AfterSale {
receiving_id: number | null
receiving_no: string | null
// 关联详情(detail 接口返回)
related?: AfterSaleRelated
created_at: string
updated_at: string
deleted_at: string | null
started_at: string | null
completed_at: string | null
}
// ==================== 关联数据类型 ====================
/** 关联订单 - 收货人 */
export interface RelatedRecipient {
name: string
tel: string
mobile: string
email: string
zip_code: string
country: string
province: string
city: string
district: string
town: string
address: string
}
/** 关联订单 - 商品条码 */
export interface RelatedItemBarcode {
id: number
barcode: string
}
/** 关联订单 - 商品行 */
export interface RelatedOrderItem {
id: number
order_line_no: string
item_code: string
item_name: string
sku_property: string
quantity: number
locked_quantity: number
is_batch_mgmt: string
is_shelf_life_mgmt: string
is_images: string
store_id: number
packing_requirements: string
stock_unit: string
image_url: string[]
barcodes: RelatedItemBarcode[]
plan_qty: number
stock_id: number
order_item_id: number
order_id: number
}
/** 关联订单 */
export interface RelatedOrder {
id: number
delivery_order_code: string
warehouse_id: number
store_id: number
items_weight: number
wave_id: number
wave_no: string
source_platform_code: string
source_platform_name: string
source_order_codes: string
sync_status: string
inspection_status: string
storage_status: string
post_status: string
print_status: string
pick_status: string
pack_status: string
intercept_status: string
items_count: number
items_total: number
recipient: RelatedRecipient | null
sender: any
items: RelatedOrderItem[]
pack_videos: any[]
}
/** 关联运单 */
export interface RelatedWaybill {
id: number
waybill_code: string
order_id: number
logistics_code: string
logistics_name: string
logistics_interface_id: number
logistics_interface_name: string
status: number
is_back: string
is_intercept: string
warehouse_id: number
create_at: string
}
/** 关联店铺合同 */
export interface RelatedStoreContract {
contract_id: number
store_remask: string
warehouse_remask: string
store_use_status: number
warehouse_use_status: number
}
/** 售后关联数据 */
export interface AfterSaleRelated {
order?: RelatedOrder | null
waybill?: RelatedWaybill | null
store_contract?: RelatedStoreContract | null
}
/** 售后步骤对象 */
@ -164,9 +277,30 @@ export interface AfterSaleExportParams {
sort?: { sortField?: string; sortOrder?: 'asc' | 'desc' }
}
/** 导出进度查询参数 */
export interface AfterSaleExportTaskProgressParams {
task_id: string
/** 批量设置待反馈参数 */
export interface AfterSaleBatchSetPendingFeedbackParams {
ids: number[]
remark?: string
}
/** 批量设置待反馈结果项 */
export interface AfterSaleBatchSetPendingFeedbackFailedItem {
id: number
reason: string
}
/** 批量关闭/完结参数 */
export interface AfterSaleBatchCloseParams {
ids: number[]
status: 'completed' | 'closed'
resolution?: string
remark?: string
}
/** 批量关闭/完结结果项 */
export interface AfterSaleBatchCloseFailedItem {
id: number
reason: string
}
// ==================== API 方法 ====================
@ -335,3 +469,33 @@ export function afterSaleWorkCount(): Promise<any> {
isSystemApi: true
} as any)
}
/** 2.12 批量设置待反馈 afterSale.batchSetPendingFeedback */
export function afterSaleBatchSetPendingFeedback(data: AfterSaleBatchSetPendingFeedbackParams) {
return request({
url: '/system',
method: 'post',
params: {
method: 'afterSale.batchSetPendingFeedback',
v,
timestamp: Date.now()
},
data,
isSystemApi: true
} as any)
}
/** 2.13 批量关闭/完结 afterSale.batchClose */
export function afterSaleBatchClose(data: AfterSaleBatchCloseParams) {
return request({
url: '/system',
method: 'post',
params: {
method: 'afterSale.batchClose',
v,
timestamp: Date.now()
},
data,
isSystemApi: true
} as any)
}

View File

@ -60,6 +60,7 @@
<div v-if="detail && detail.status !== 'completed' && detail.status !== 'cancelled' && detail.status !== 'closed'" class="detail-handle-bar">
<div class="handle-row">
<el-select v-model="handleStatus" size="small" style="width:110px" placeholder="状态">
<el-option label="等待反馈" value="pending_feedback" />
<el-option label="处理中" value="processing" />
<el-option label="已完成" value="completed" />
<el-option label="已关闭" value="closed" />
@ -77,7 +78,7 @@
</div>
</div>
<!-- 右侧:基本信息 + 关联单据 + 理赔 -->
<!-- 右侧:基本信息 + 关联数据 + 理赔 -->
<div class="detail-right">
<!-- 基本信息 -->
<el-card class="info-card" shadow="never">
@ -93,30 +94,108 @@
<el-tag size="small" :type="typeTagType(detail.type)">{{ typeLabel(detail.type) }}</el-tag>
</el-descriptions-item>
<el-descriptions-item label="子类型">{{ subTypeLabel(detail.sub_type) }}</el-descriptions-item>
<el-descriptions-item label="标题" :span="2">{{ detail.title }}</el-descriptions-item>
<el-descriptions-item label="标题" :span="2">{{ detail.title || '-' }}</el-descriptions-item>
<el-descriptions-item label="优先级">{{ detail.priority }}</el-descriptions-item>
<el-descriptions-item label="角色组">
<el-tag v-if="detail.role_group" size="small" :type="roleGroupTagType(detail.role_group)">{{ roleGroupLabel(detail.role_group) }}</el-tag>
<span v-else>-</span>
</el-descriptions-item>
<el-descriptions-item v-if="detail.description" label="详细描述" :span="2">{{ detail.description }}</el-descriptions-item>
<el-descriptions-item label="处理结果" :span="2">{{ detail.resolution || '-' }}</el-descriptions-item>
<el-descriptions-item label="货主">{{ detail.related?.store_contract?.store_remask || '-' }}</el-descriptions-item>
<el-descriptions-item label="开始处理">{{ detail.started_at || '-' }}</el-descriptions-item>
<el-descriptions-item label="完结时间">{{ detail.resolved_at || '-' }}</el-descriptions-item>
<el-descriptions-item label="创建时间">{{ detail.created_at }}</el-descriptions-item>
<el-descriptions-item label="更新时间" :span="2">{{ detail.updated_at }}</el-descriptions-item>
</el-descriptions>
<!-- 详细描述(移出表格,防止撑开行高) -->
<div v-if="detail.description" class="desc-block">
<span class="desc-label">详细描述</span>
<div class="desc-text">{{ detail.description }}</div>
</div>
</el-card>
<!-- 关联运单 -->
<el-card v-if="detail.related?.waybill" class="info-card" shadow="never">
<template #header><span class="card-title">关联运单</span></template>
<el-descriptions :column="2" border size="small">
<el-descriptions-item label="运单号">{{ detail.related.waybill.waybill_code }}</el-descriptions-item>
<el-descriptions-item label="物流公司">{{ detail.related.waybill.logistics_name }}</el-descriptions-item>
<el-descriptions-item label="物流接口">{{ detail.related.waybill.logistics_interface_name }}</el-descriptions-item>
<el-descriptions-item label="是否退回">{{ detail.related.waybill.is_back === 'Y' ? '是' : '否' }}</el-descriptions-item>
<el-descriptions-item label="是否拦截">{{ detail.related.waybill.is_intercept === 'Y' ? '是' : '否' }}</el-descriptions-item>
<el-descriptions-item label="创建时间">{{ detail.related.waybill.create_at }}</el-descriptions-item>
</el-descriptions>
</el-card>
<!-- 关联单据 -->
<el-card v-if="hasRelatedDocs" class="info-card" shadow="never">
<template #header><span class="card-title">关联单据</span></template>
<el-descriptions :column="1" border size="small">
<el-descriptions-item v-if="detail.waybill_no" label="运单号">{{ detail.waybill_no }}</el-descriptions-item>
<el-descriptions-item v-if="detail.order_delivery_no" label="发货订单号">{{ detail.order_delivery_no }}</el-descriptions-item>
<el-descriptions-item v-if="detail.entry_order_no" label="入库单号">{{ detail.entry_order_no }}</el-descriptions-item>
<el-descriptions-item v-if="detail.order_stockout_no" label="出库单号">{{ detail.order_stockout_no }}</el-descriptions-item>
<el-descriptions-item v-if="detail.receiving_no" label="收货单号">{{ detail.receiving_no }}</el-descriptions-item>
<!-- 关联订单 -->
<el-card v-if="detail.related?.order" class="info-card" shadow="never">
<template #header>
<div class="card-header">
<span class="card-title">关联订单</span>
<el-tag size="small" type="info">{{ detail.related.order.source_platform_name }}</el-tag>
</div>
</template>
<!-- 订单基本信息 -->
<el-descriptions :column="2" border size="small" class="sub-desc">
<el-descriptions-item label="外部订单号" :span="2">{{ detail.related.order.delivery_order_code }}</el-descriptions-item>
<el-descriptions-item label="平台单号" :span="2">{{ detail.related.order.source_order_codes }}</el-descriptions-item>
<el-descriptions-item label="商品总数">{{ detail.related.order.items_total }}</el-descriptions-item>
<el-descriptions-item label="总重(g)">{{ detail.related.order.items_weight }}</el-descriptions-item>
</el-descriptions>
<!-- 操作状态 -->
<div class="status-bar">
<el-tag size="small" :type="orderOpTag(detail.related.order.sync_status)">{{ orderOpLabel('sync', detail.related.order.sync_status) }}</el-tag>
<el-tag size="small" :type="orderOpTag(detail.related.order.storage_status)">{{ orderOpLabel('storage', detail.related.order.storage_status) }}</el-tag>
<el-tag size="small" :type="orderOpTag(detail.related.order.print_status)">{{ orderOpLabel('print', detail.related.order.print_status) }}</el-tag>
<el-tag size="small" :type="orderOpTag(detail.related.order.pick_status)">{{ orderOpLabel('pick', detail.related.order.pick_status) }}</el-tag>
<el-tag size="small" :type="orderOpTag(detail.related.order.pack_status)">{{ orderOpLabel('pack', detail.related.order.pack_status) }}</el-tag>
<el-tag size="small" :type="orderOpTag(detail.related.order.post_status)">{{ orderOpLabel('post', detail.related.order.post_status) }}</el-tag>
<el-tag size="small" :type="orderOpTag(detail.related.order.intercept_status)">{{ orderOpLabel('intercept', detail.related.order.intercept_status) }}</el-tag>
</div>
<!-- 收货信息 -->
<div v-if="detail.related.order.recipient" class="recipient-box">
<div class="recipient-title">收货信息</div>
<div class="recipient-name">{{ detail.related.order.recipient.name }} {{ detail.related.order.recipient.mobile || detail.related.order.recipient.tel }}</div>
<div class="recipient-addr">{{ detail.related.order.recipient.province }}{{ detail.related.order.recipient.city }}{{ detail.related.order.recipient.district }}{{ detail.related.order.recipient.town }} {{ detail.related.order.recipient.address }}</div>
</div>
<!-- 商品明细 -->
<div class="items-section">
<div class="items-title">商品明细({{ detail.related.order.items?.length || 0 }} 种)</div>
<div v-for="(item, idx) in detail.related.order.items" :key="idx" class="order-item-row">
<el-image
v-if="item.image_url?.[0]"
:src="item.image_url[0]"
:preview-src-list="item.image_url"
fit="cover"
class="item-thumb"
/>
<div class="item-info">
<div class="item-name">{{ item.item_name }}</div>
<div class="item-meta">
<span>SKU: {{ item.item_code }}</span>
<span v-if="item.sku_property">规格: {{ item.sku_property }}</span>
<span>数量: {{ item.plan_qty ?? item.quantity }} {{ item.stock_unit }}</span>
</div>
<div v-if="item.packing_requirements" class="item-pack">包装要求: {{ item.packing_requirements }}</div>
<div v-if="item.barcodes?.length" class="item-barcodes">
<el-tag v-for="bc in item.barcodes" :key="bc.id" size="small" type="info" class="barcode-tag">{{ bc.barcode }}</el-tag>
</div>
</div>
</div>
</div>
<!-- 订单操作日志 -->
<div class="order-log-section">
<el-button size="small" text type="primary" :loading="orderLogLoading" @click="toggleOrderLogs">
{{ orderLogVisible ? '收起操作日志' : '查看操作日志' }}
</el-button>
<div v-if="orderLogVisible" class="order-log-list">
<template v-if="orderLogs.length > 0">
<div v-for="log in orderLogs" :key="log.id" class="log-item">
<div class="log-header">
<el-tag size="small" type="info">{{ log.operation_name || log.operation_code }}</el-tag>
<span class="log-time">{{ log.created_at }}</span>
</div>
<div v-if="log.message" class="log-msg">{{ log.message }}</div>
<div v-if="log.operator_name" class="log-operator">{{ log.operator_name }}</div>
</div>
</template>
<el-empty v-else description="暂无操作日志" :image-size="48" />
</div>
</div>
</el-card>
<!-- 理赔信息 -->
@ -164,7 +243,7 @@
</template>
<script setup lang="ts">
import { ref, computed, watch } from 'vue'
import { ref, watch } from 'vue'
import { ElMessage } from 'element-plus'
import { Plus, Refresh } from '@element-plus/icons-vue'
import {
@ -172,7 +251,9 @@ import {
afterSaleHandleWorkOrder,
type AfterSale,
type AfterSaleStep,
type AfterSaleRelated,
} from '@/api/afterSale/index'
import { orderQueryOrderLogList, type OrderLogListItem } from '@/api/order.index/orderindex'
import { getCOSUploadConfig, uploadSuccessNotify } from '@/api/index/index'
import {
AFTER_SALE_TYPE_MAP, AFTER_SALE_TYPE_TAG_MAP, AFTER_SALE_SUB_TYPE_MAP,
@ -200,11 +281,49 @@ const claimStatusTagType = (c: string) => CLAIM_STATUS_TAG_MAP[c] ?? 'info'
const parseOperatorName = (s: string) => { try { const o = JSON.parse(s); return o.name || o.id || '-' } catch { return s || '-' } }
const statusTimelineType = (s: any) => ({ pending: 'warning', processing: 'primary', completed: 'success', closed: 'info' } as any)[s] ?? 'info'
// ==================== 订单操作状态映射 ====================
const ORDER_OP_LABELS: Record<string, Record<string, string>> = {
sync: { padding: '未同步', pedding: '未同步', pending: '未同步', fin: '已同步', error: '错误', none: '未同步' },
inspection: { none: '未审核', pending: '待审核', padding: '审核中', fin: '审核通过', reject: '审核驳回' },
storage: { none: '未分配储位', padding: '分配中', fin: '已分配储位', error: '错误' },
print: { none: '未打印', padding: '打印中', fin: '已打印' },
pick: { none: '未拣货', padding: '拣货中', fin: '已拣货' },
pack: { none: '未打包', padding: '打包中', fin: '已打包' },
post: { none: '未分配运单号', padding: '分配中', fin: '已分配运单号', timeout: '超时', error: '错误' },
intercept:{ none: '未拦截', pending: '待拦截', success: '已拦截' },
}
const ORDER_OP_TAGS: Record<string, string> = {
fin: 'success', padding: 'warning', pedding: 'warning', pending: 'warning',
none: 'info', error: 'danger', timeout: 'danger', reject: 'danger', success: 'success',
}
function orderOpLabel(cat: string, val: string) { return ORDER_OP_LABELS[cat]?.[val] ?? val ?? '-' }
function orderOpTag(val: string) { return ORDER_OP_TAGS[val] ?? 'info' }
// 数据
const loading = ref(false)
const detail = ref<AfterSale | null>(null)
const steps = ref<AfterSaleStep[]>([])
const hasRelatedDocs = computed(() => !!(detail.value?.waybill_no || detail.value?.order_delivery_no || detail.value?.entry_order_no || detail.value?.order_stockout_no || detail.value?.receiving_no))
// ==================== 订单操作日志 ====================
const orderLogVisible = ref(false)
const orderLogLoading = ref(false)
const orderLogs = ref<OrderLogListItem[]>([])
async function toggleOrderLogs() {
if (orderLogVisible.value) { orderLogVisible.value = false; return }
orderLogVisible.value = true
if (orderLogs.value.length > 0) return
const orderId = detail.value?.related?.order?.id
if (!orderId) return
orderLogLoading.value = true
try {
const res: any = await orderQueryOrderLogList({ id: orderId })
if (res && (res.flag === 'success' || res.code === 1 || res.code === 200 || res.code === 20000)) {
orderLogs.value = (res.list ?? res.data?.list ?? []) as OrderLogListItem[]
}
} catch { /* ignore */ }
finally { orderLogLoading.value = false }
}
async function fetchDetail() {
if (!props.afterSaleId) return
@ -213,8 +332,13 @@ async function fetchDetail() {
const res: any = await afterSaleDetail(props.afterSaleId)
if (res && (res.flag === 'success' || res.code === 1 || res.code === 200 || res.code === 20000)) {
const data = res.data ?? res
detail.value = data.after_sale ?? null
steps.value = data.steps ?? []
const as: AfterSale | null = data.after_sale ?? null
if (as) {
// related 可能在 after_sale 内部,也可能在 data 顶层
as.related = (as as any).related ?? (data.related as AfterSaleRelated | undefined)
}
detail.value = as
steps.value = (data.steps ?? []) as AfterSaleStep[]
} else { ElMessage.error(res?.message || '获取失败') }
} catch { ElMessage.error('获取失败') }
finally { loading.value = false }
@ -223,7 +347,7 @@ async function fetchDetail() {
watch(() => props.afterSaleId, (id) => { if (id) fetchDetail() }, { immediate: true })
// 明细加载后同步状态默认值(处理下拉框无 pending 选项,统一默认为 processing)
const HANDLE_STATUS_OPTIONS = ['processing', 'completed', 'closed']
const HANDLE_STATUS_OPTIONS = ['pending_feedback', 'processing', 'completed', 'closed']
watch(detail, (d) => {
if (d) {
handleStatus.value = HANDLE_STATUS_OPTIONS.includes(d.status) ? d.status : 'processing'
@ -232,6 +356,7 @@ watch(detail, (d) => {
function resetState() {
detail.value = null; steps.value = []
orderLogVisible.value = false; orderLogs.value = []
}
// 子操作弹窗 refs
@ -342,10 +467,21 @@ async function submitHandle() {
flex: 1; min-width: 0; overflow-y: auto; max-height: 65vh;
}
.desc-block {
margin-top: 10px; padding: 0 12px 10px;
}
.desc-label { font-size: 13px; color: #909399; margin-bottom: 4px; display: block; }
.desc-text {
max-height: 100px; overflow-y: auto; word-break: break-all; white-space: pre-wrap;
font-size: 13px; color: #303133; line-height: 1.5; padding: 6px 8px;
background: #fafafa; border-radius: 4px; border: 1px solid #ebeef5;
}
.info-card { margin-bottom: 10px; }
.info-card:last-child { margin-bottom: 0; }
.info-card :deep(.el-card__header) { padding: 8px 16px; }
.card-title { font-size: 14px; font-weight: 600; }
.card-header { display: flex; align-items: center; gap: 8px; }
.section-title {
font-size: 14px; font-weight: 600; padding: 8px 16px; background: #fafafa;
border: 1px solid #ebeef5; border-radius: 4px 4px 0 0; flex-shrink: 0;
@ -377,4 +513,53 @@ h4 { margin: 0 0 10px; font-size: 14px; }
position: absolute; top: -2px; right: -2px; width: 16px; height: 16px; background: #f56c6c; color: #fff;
border-radius: 50%; font-size: 12px; line-height: 16px; text-align: center;
}
/* ========== 关联订单:收货信息 ========== */
.recipient-box {
margin-top: 10px; padding: 10px 12px; background: #f5f7fa; border-radius: 6px;
border: 1px solid #e4e7ed;
}
.recipient-title { font-size: 13px; font-weight: 600; color: #303133; margin-bottom: 4px; }
.recipient-name { font-size: 14px; font-weight: 500; color: #303133; }
.recipient-addr { font-size: 12px; color: #909399; margin-top: 2px; line-height: 1.5; }
/* ========== 关联订单:商品明细 ========== */
.items-section { margin-top: 10px; }
.items-title { font-size: 13px; font-weight: 600; color: #303133; margin-bottom: 8px; padding-bottom: 6px; border-bottom: 1px solid #ebeef5; }
.order-item-row {
display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px dashed #ebeef5;
align-items: flex-start;
}
.order-item-row:last-child { border-bottom: none; }
.item-thumb {
width: 72px; height: 72px; border-radius: 6px; flex-shrink: 0;
border: 1px solid #e4e7ed; background: #fafafa;
}
.item-info { flex: 1; min-width: 0; }
.item-name { font-size: 14px; font-weight: 500; color: #303133; margin-bottom: 4px; }
.item-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: #909399; margin-bottom: 4px; }
.item-pack { font-size: 12px; color: #e6a23c; margin-top: 2px; }
.item-barcodes { margin-top: 4px; display: flex; flex-wrap: wrap; gap: 4px; }
.barcode-tag { font-size: 11px; }
/* ========== 小描述块间距 ========== */
.sub-desc { margin-bottom: 0; }
/* ========== 订单操作状态栏 ========== */
.status-bar {
margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px;
padding: 8px 10px; background: #fafafa; border-radius: 6px; border: 1px solid #ebeef5;
}
/* ========== 订单操作日志 ========== */
.order-log-section { margin-top: 10px; border-top: 1px solid #ebeef5; padding-top: 8px; }
.order-log-list { margin-top: 8px; max-height: 200px; overflow-y: auto; }
.log-item {
padding: 6px 8px; border-bottom: 1px dashed #ebeef5; font-size: 13px;
}
.log-item:last-child { border-bottom: none; }
.log-header { display: flex; align-items: center; gap: 8px; margin-bottom: 2px; }
.log-time { font-size: 12px; color: #909399; }
.log-msg { color: #606266; margin-top: 2px; line-height: 1.4; }
.log-operator { font-size: 12px; color: #909399; margin-top: 2px; }
</style>

View File

@ -118,6 +118,78 @@ export const STEP_STATUS_TAG_MAP: Record<number, string> = {
// 售后列表页 - 配置
// ============================================================
// -------------------- 子类型按主类型分组 --------------------
export const SUB_TYPE_OPTIONS_BY_TYPE: Record<string, { label: string; value: string }[]> = {
order: [
{ label: '破损', value: 'damage' },
{ label: '少发', value: 'missing_item' },
{ label: '错发', value: 'mis_shipment' },
{ label: '错品', value: 'wrong_sku' },
{ label: '质量问题', value: 'quality_issue' },
{ label: '发货延迟', value: 'delivery_delay' },
{ label: '物流异常', value: 'logistics_issue' },
{ label: '客户拒收', value: 'rejected' },
{ label: '拦截', value: 'intercept' },
{ label: '核实签收', value: 'verify_delivery' },
{ label: '催件', value: 'urge' },
{ label: '多发', value: 'extra_item' },
{ label: '改地址', value: 'change_address' },
{ label: '换快递', value: 'change_carrier' },
{ label: '重量异常', value: 'weight_issue' },
{ label: '运费争议', value: 'freight_issue' },
{ label: '其他', value: 'other' },
],
receiving: [
{ label: '少货', value: 'shortage' },
{ label: '破损', value: 'damage' },
{ label: '错品', value: 'wrong_sku' },
{ label: '质量问题', value: 'quality_issue' },
{ label: '其他', value: 'other' },
],
entry: [
{ label: '少货', value: 'shortage' },
{ label: '破损', value: 'damage' },
{ label: '错品', value: 'wrong_sku' },
{ label: '质量问题', value: 'quality_issue' },
{ label: '其他', value: 'other' },
],
stockout: [
{ label: '退货异常', value: 'return_issue' },
{ label: '错发', value: 'wrong_outbound' },
{ label: '少发', value: 'shortage' },
{ label: '其他', value: 'other' },
],
}
/** 根据主类型获取子类型选项,未选类型时返回全部 */
export function getSubTypeOptions(type?: string): { label: string; value: string }[] {
if (type && SUB_TYPE_OPTIONS_BY_TYPE[type]) {
return SUB_TYPE_OPTIONS_BY_TYPE[type]
}
// 返回全部(去重)
const seen = new Set<string>()
const all: { label: string; value: string }[] = []
for (const arr of Object.values(SUB_TYPE_OPTIONS_BY_TYPE)) {
for (const item of arr) {
if (!seen.has(item.value)) {
seen.add(item.value)
all.push(item)
}
}
}
return all
}
/** 根据已选主类型动态生成 availableFields(用于 ScanBox 级联筛选) */
export function getAfterSaleAvailableFields(typeFilter?: string): typeof afterSaleAvailableFields {
return afterSaleAvailableFields.map(field => {
if (field.value === 'sub_type') {
return { ...field, options: getSubTypeOptions(typeFilter) }
}
return field
})
}
// -------------------- ScanBox 筛选字段 --------------------
export const afterSaleAvailableFields = [
{
@ -263,6 +335,9 @@ export const afterSaleColumns = [
export const afterSaleToolbarButtons: ToolbarButtonConfig[] = [
{ key: 'refresh', label: '刷新', category: 'refresh', size: 'small', loadingKey: 'loading', action: 'refresh' },
{ key: 'columnConfig', label: '字段设置', category: 'setting', size: 'small', action: 'openColumnConfigPanel' },
{ key: 'batchPendingFeedback', label: '设为待反馈', category: 'action', size: 'small', type: 'warning', loadingKey: 'batchPendingFeedbackLoading', action: 'batchSetPendingFeedback' },
{ key: 'batchComplete', label: '批量完成', category: 'action', size: 'small', type: 'warning', loadingKey: 'batchCompleteLoading', action: 'batchComplete' },
{ key: 'batchClose', label: '批量关闭', category: 'action', size: 'small', type: 'danger', loadingKey: 'batchCloseLoading', action: 'batchClose' },
{ key: 'export', label: '导出', category: 'action', size: 'small', type: 'success', loadingKey: 'exportLoading', action: 'handleExport' },
]

View File

@ -138,13 +138,25 @@ function emitAction(action: ToolbarButtonConfig['action']) {
emit('action', action)
}
/** 按钮 key → 强制样式覆盖(绕过模块缓存) */
const BUTTON_STYLE_OVERRIDE: Record<string, { type: string; plain: boolean }> = {
batchComplete: { type: 'warning', plain: false },
batchClose: { type: 'danger', plain: false },
}
/** 根据 category 或 type/plain 解析按钮样式 */
function resolveButtonStyle(button: ToolbarButtonConfig): { type: string; plain: boolean } {
// 优先检查强制覆盖
const override = BUTTON_STYLE_OVERRIDE[button.key]
if (override) return override
switch (button.category) {
case 'refresh': return { type: 'primary', plain: false } // 蓝底白字
case 'setting': return { type: 'default', plain: false } // 白底黑字
case 'action': return { type: 'primary', plain: true } // 白底蓝边框蓝字
case 'cancel': return { type: 'danger', plain: false } // 红底白字
case 'refresh': return { type: 'primary', plain: false }
case 'setting': return { type: 'default', plain: false }
case 'action':
if (button.type) return { type: button.type, plain: false }
return { type: 'primary', plain: true }
case 'cancel': return { type: 'danger', plain: false }
default: return { type: button.type || 'default', plain: !!button.plain }
}
}