- 售后详情: 新增related关联数据展示(订单/运单/店铺), 操作状态栏, 订单操作日志 - 售后详情: 详细描述移出表格防撑开, 移除角色组/处理结果/完成时间字段 - 售后列表: 批量完成按钮改为warning橙色, 批量关闭改为danger红色 - 售后列表: 处理下拉增加等待反馈选项 - API类型: AfterSale接口补充related等关联数据类型 - 工具栏组件: resolveButtonStyle支持显式type覆盖 & 按钮key强制样式映射
566 lines
29 KiB
Vue
566 lines
29 KiB
Vue
<template>
|
||
<el-dialog
|
||
:model-value="visible"
|
||
:title="detail ? `售后明细 - ${detail.after_sale_no}` : '售后明细'"
|
||
width="1100px"
|
||
align-center
|
||
append-to-body
|
||
destroy-on-close
|
||
@update:model-value="$emit('update:visible', $event)"
|
||
@closed="resetState"
|
||
>
|
||
<div v-loading="loading" class="detail-dialog-body">
|
||
<template v-if="detail">
|
||
<!-- 操作按钮 -->
|
||
<div class="detail-actions-bar">
|
||
<el-button size="small" @click="fetchDetail" :loading="loading"><el-icon><Refresh /></el-icon></el-button>
|
||
<el-button v-if="detail.status === 'pending' || detail.status === 'processing'" size="small" type="warning" @click="showTransferDialog">转单</el-button>
|
||
<el-button v-if="detail" size="small" type="success" @click="showClaimDialog">登记理赔</el-button>
|
||
</div>
|
||
|
||
<!-- 左右分栏 -->
|
||
<div class="detail-split">
|
||
<!-- 左侧:处理记录 -->
|
||
<div class="detail-left">
|
||
<!-- 标题固定 -->
|
||
<div class="section-title">处理记录</div>
|
||
<!-- 记录列表可滚动 -->
|
||
<div class="detail-left-scroll">
|
||
<template v-if="steps.length > 0">
|
||
<el-timeline>
|
||
<el-timeline-item v-for="step in steps" :key="step.id" :timestamp="step.completed_at || step.started_at || step.created_at" placement="top" :type="statusTimelineType(step.step_status)">
|
||
<div class="step-item">
|
||
<div class="step-header">
|
||
<el-tag size="small" :type="statusTagType(step.step_status as any)">{{ statusLabel(step.step_status as any) }}</el-tag>
|
||
<span class="step-action">{{ step.action || '未指定操作' }}</span>
|
||
</div>
|
||
<div v-if="step.remark" class="step-remark">{{ step.remark }}</div>
|
||
<div v-if="step.operator_snapshot" class="step-operator">操作人: {{ parseOperatorName(step.operator_snapshot) }}</div>
|
||
<div v-if="step.attachments?.length" class="step-attachments">
|
||
<span v-for="(att, idx) in step.attachments" :key="idx" class="att-item">
|
||
<el-image
|
||
v-if="att.mime_type?.startsWith('image/')"
|
||
:src="att.file_url"
|
||
:preview-src-list="[att.file_url]"
|
||
fit="cover"
|
||
style="width:60px;height:60px;border-radius:4px;cursor:pointer"
|
||
:title="att.file_name"
|
||
/>
|
||
<a v-else :href="att.file_url" target="_blank">{{ att.file_name || `文件${(att as any).id || att.file_id}` }}</a>
|
||
</span>
|
||
</div>
|
||
</div>
|
||
</el-timeline-item>
|
||
</el-timeline>
|
||
</template>
|
||
<el-empty v-else description="暂无处理记录" />
|
||
</div>
|
||
|
||
<!-- 处理工单表单(固定底部) -->
|
||
<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" />
|
||
</el-select>
|
||
<el-input v-model="handleRemark" size="small" placeholder="输入处理备注..." class="remark-input" @keyup.enter="submitHandle" />
|
||
<el-button size="small" @click="triggerFileInput"><el-icon><Plus /></el-icon></el-button>
|
||
<el-button type="primary" size="small" :loading="handleLoading" @click="submitHandle">提交</el-button>
|
||
</div>
|
||
<div v-if="handleFiles.length > 0" class="handle-files-row">
|
||
<span v-for="(f, i) in handleFiles" :key="i" class="file-thumb" @click="removeFile(i)">
|
||
<img :src="f.url" /><span class="file-close">×</span>
|
||
</span>
|
||
</div>
|
||
<input ref="fileInputRef" type="file" accept="image/*" multiple hidden @change="onFilePicked" />
|
||
</div>
|
||
</div>
|
||
|
||
<!-- 右侧:基本信息 + 关联数据 + 理赔 -->
|
||
<div class="detail-right">
|
||
<!-- 基本信息 -->
|
||
<el-card class="info-card" shadow="never">
|
||
<template #header>
|
||
<div class="card-header">
|
||
<span class="card-title">基本信息</span>
|
||
<el-tag :type="statusTagType(detail.status)" size="small">{{ statusLabel(detail.status) }}</el-tag>
|
||
</div>
|
||
</template>
|
||
<el-descriptions :column="2" border size="small">
|
||
<el-descriptions-item label="售后单号" :span="2">{{ detail.after_sale_no }}</el-descriptions-item>
|
||
<el-descriptions-item label="售后类型">
|
||
<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="优先级">{{ detail.priority }}</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>
|
||
<!-- 详细描述(移出表格,防止撑开行高) -->
|
||
<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="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>
|
||
|
||
<!-- 理赔信息 -->
|
||
<el-card v-if="detail.claim_needed || detail.carrier_claim_needed" class="info-card" shadow="never">
|
||
<template #header><span class="card-title">理赔信息</span></template>
|
||
<el-row :gutter="20">
|
||
<el-col v-if="detail.claim_needed" :span="12">
|
||
<h4>仓库理赔</h4>
|
||
<el-descriptions :column="1" border size="small">
|
||
<el-descriptions-item label="金额">¥{{ detail.claim_amount ?? '-' }}</el-descriptions-item>
|
||
<el-descriptions-item label="状态">
|
||
<el-tag size="small" :type="claimStatusTagType(detail.claim_status!)">{{ claimStatusLabel(detail.claim_status!) }}</el-tag>
|
||
</el-descriptions-item>
|
||
</el-descriptions>
|
||
</el-col>
|
||
<el-col v-if="detail.carrier_claim_needed" :span="12">
|
||
<h4>运方理赔</h4>
|
||
<el-descriptions :column="1" border size="small">
|
||
<el-descriptions-item label="金额">¥{{ detail.carrier_claim_amount ?? '-' }}</el-descriptions-item>
|
||
<el-descriptions-item label="状态">
|
||
<el-tag size="small" :type="claimStatusTagType(detail.carrier_claim_status!)">{{ claimStatusLabel(detail.carrier_claim_status!) }}</el-tag>
|
||
</el-descriptions-item>
|
||
</el-descriptions>
|
||
</el-col>
|
||
</el-row>
|
||
</el-card>
|
||
</div>
|
||
</div>
|
||
</template>
|
||
</div>
|
||
|
||
<TransferDialog ref="transferDlgRef" :after-sale-id="detail?.id ?? 0" @success="onSubActionSuccess" />
|
||
<ClaimDialog
|
||
ref="claimDlgRef"
|
||
:after-sale-id="detail?.id ?? 0"
|
||
:claim-needed="detail?.claim_needed"
|
||
:claim-amount="detail?.claim_amount ?? undefined"
|
||
:claim-status="detail?.claim_status ?? undefined"
|
||
:carrier-claim-needed="detail?.carrier_claim_needed"
|
||
:carrier-claim-amount="detail?.carrier_claim_amount ?? undefined"
|
||
:carrier-claim-status="detail?.carrier_claim_status ?? undefined"
|
||
@success="onSubActionSuccess"
|
||
/>
|
||
</el-dialog>
|
||
</template>
|
||
|
||
<script setup lang="ts">
|
||
import { ref, watch } from 'vue'
|
||
import { ElMessage } from 'element-plus'
|
||
import { Plus, Refresh } from '@element-plus/icons-vue'
|
||
import {
|
||
afterSaleDetail,
|
||
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,
|
||
AFTER_SALE_STATUS_MAP, AFTER_SALE_STATUS_TAG_MAP,
|
||
AFTER_SALE_ROLE_GROUP_MAP, AFTER_SALE_ROLE_GROUP_TAG_MAP,
|
||
CLAIM_STATUS_MAP, CLAIM_STATUS_TAG_MAP,
|
||
STEP_STATUS_MAP, STEP_STATUS_TAG_MAP,
|
||
} from '@/views/afterSale/list/afterSale-config'
|
||
import TransferDialog from './TransferDialog.vue'
|
||
import ClaimDialog from './ClaimDialog.vue'
|
||
|
||
const props = defineProps<{ visible: boolean; afterSaleId: number | null }>()
|
||
const emit = defineEmits<{ 'update:visible': [v: boolean]; success: [] }>()
|
||
|
||
// 工具
|
||
const typeLabel = (t: string) => AFTER_SALE_TYPE_MAP[t] ?? t ?? '-'
|
||
const typeTagType = (t: string) => AFTER_SALE_TYPE_TAG_MAP[t] ?? 'info'
|
||
const subTypeLabel = (s: string) => AFTER_SALE_SUB_TYPE_MAP[s] ?? s ?? '-'
|
||
const statusLabel = (s: any) => AFTER_SALE_STATUS_MAP[s] ?? s ?? '-'
|
||
const statusTagType = (s: any) => AFTER_SALE_STATUS_TAG_MAP[s] ?? 'info'
|
||
const roleGroupLabel = (r: string) => AFTER_SALE_ROLE_GROUP_MAP[r] ?? r ?? '-'
|
||
const roleGroupTagType = (r: string) => AFTER_SALE_ROLE_GROUP_TAG_MAP[r] ?? 'info'
|
||
const claimStatusLabel = (c: string) => CLAIM_STATUS_MAP[c] ?? c ?? '-'
|
||
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 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
|
||
loading.value = true
|
||
try {
|
||
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
|
||
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 }
|
||
}
|
||
|
||
watch(() => props.afterSaleId, (id) => { if (id) fetchDetail() }, { immediate: true })
|
||
|
||
// 明细加载后同步状态默认值(处理下拉框无 pending 选项,统一默认为 processing)
|
||
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'
|
||
}
|
||
})
|
||
|
||
function resetState() {
|
||
detail.value = null; steps.value = []
|
||
orderLogVisible.value = false; orderLogs.value = []
|
||
}
|
||
|
||
// 子操作弹窗 refs
|
||
const transferDlgRef = ref<InstanceType<typeof TransferDialog>>()
|
||
const claimDlgRef = ref<InstanceType<typeof ClaimDialog>>()
|
||
|
||
function onSubActionSuccess() {
|
||
fetchDetail()
|
||
emit('success')
|
||
}
|
||
|
||
function showTransferDialog() { transferDlgRef.value?.open() }
|
||
function showClaimDialog() { claimDlgRef.value?.open() }
|
||
|
||
// ==================== 处理工单(内联) ====================
|
||
const handleStatus = ref('processing')
|
||
const handleRemark = ref('')
|
||
const handleLoading = ref(false)
|
||
const handleFiles = ref<Array<{ raw: File; url: string; fileId?: number }>>([])
|
||
const uploadedIds = ref<number[]>([])
|
||
const fileInputRef = ref<HTMLInputElement>()
|
||
|
||
function triggerFileInput() { fileInputRef.value?.click() }
|
||
|
||
async function onFilePicked(e: Event) {
|
||
const files = (e.target as HTMLInputElement).files
|
||
if (!files) return
|
||
for (let i = 0; i < files.length; i++) {
|
||
const f = files[i]
|
||
if (!f) continue
|
||
const item = { raw: f, url: URL.createObjectURL(f), fileId: undefined as number | undefined }
|
||
handleFiles.value.push(item)
|
||
// 立即上传
|
||
try {
|
||
const configRes: any = await getCOSUploadConfig({ fileName: f.name, fileType: f.type, fileSize: f.size })
|
||
const cos = configRes?.data ?? configRes
|
||
if (cos?.isNew === false) { item.fileId = cos.fileId ?? cos.file_id; if (item.fileId != null) uploadedIds.value.push(item.fileId); continue }
|
||
if (cos?.error || !cos?.uploadUrl) { ElMessage.warning(`文件 ${f.name} 上传配置获取失败`); continue }
|
||
const fd = new FormData()
|
||
if (cos.data) Object.keys(cos.data).forEach(k => fd.append(k, cos.data[k]))
|
||
fd.append('file', f)
|
||
const uploadRes = await fetch(cos.uploadUrl, { method: 'POST', headers: cos.headers || {}, body: fd })
|
||
if (!uploadRes.ok) { ElMessage.warning(`文件 ${f.name} 上传失败`); continue }
|
||
const notifyRes: any = await uploadSuccessNotify(cos.fileInfo || cos)
|
||
const resultData = notifyRes?.data ?? notifyRes
|
||
const fid = resultData?.file_id ?? resultData?.fileId ?? notifyRes?.file_id
|
||
if (fid != null) { item.fileId = Number(fid); uploadedIds.value.push(Number(fid)) }
|
||
} catch { ElMessage.warning(`文件 ${f.name} 上传失败`) }
|
||
}
|
||
;(e.target as HTMLInputElement).value = ''
|
||
}
|
||
|
||
function removeFile(i: number) {
|
||
const f = handleFiles.value[i]
|
||
if (!f) return
|
||
if (f.url) URL.revokeObjectURL(f.url)
|
||
if (f.fileId != null) {
|
||
uploadedIds.value = uploadedIds.value.filter(id => id !== f.fileId)
|
||
}
|
||
handleFiles.value.splice(i, 1)
|
||
}
|
||
|
||
async function submitHandle() {
|
||
if (!detail.value) return
|
||
handleLoading.value = true
|
||
try {
|
||
const res: any = await afterSaleHandleWorkOrder({
|
||
id: detail.value.id, status: handleStatus.value as any,
|
||
remark: handleRemark.value || undefined,
|
||
attachment_ids: uploadedIds.value.length > 0 ? uploadedIds.value : undefined,
|
||
})
|
||
if (res && (res.flag === 'success' || res.code === 1 || res.code === 200 || res.code === 20000)) {
|
||
ElMessage.success('处理成功')
|
||
const submittedStatus = handleStatus.value
|
||
handleRemark.value = ''
|
||
handleFiles.value.forEach(f => { if (f.url) URL.revokeObjectURL(f.url) })
|
||
handleFiles.value = []
|
||
uploadedIds.value = []
|
||
handleStatus.value = HANDLE_STATUS_OPTIONS.includes(detail.value?.status) ? detail.value!.status : 'processing'
|
||
emit('success')
|
||
// 状态为已完成或已关闭时,关闭详情弹窗
|
||
if (submittedStatus === 'completed' || submittedStatus === 'closed') {
|
||
emit('update:visible', false)
|
||
return
|
||
}
|
||
fetchDetail()
|
||
} else ElMessage.error(res?.message || '失败')
|
||
} catch { ElMessage.error('失败') } finally { handleLoading.value = false }
|
||
}
|
||
</script>
|
||
|
||
<style scoped>
|
||
.detail-dialog-body { display: flex; flex-direction: column; min-height: 40vh; max-height: 70vh; }
|
||
.detail-actions-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-shrink: 0; }
|
||
|
||
.detail-split {
|
||
display: flex; gap: 12px; flex: 1; min-height: 0;
|
||
}
|
||
.detail-left {
|
||
flex: 0 0 360px; min-width: 0; display: flex; flex-direction: column;
|
||
}
|
||
.detail-left-scroll {
|
||
flex: 1; overflow-y: auto; min-height: 0;
|
||
border: 1px solid #ebeef5; border-top: none; border-radius: 0 0 4px 4px;
|
||
padding: 8px 12px; background: #fff;
|
||
}
|
||
.detail-right {
|
||
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;
|
||
}
|
||
.step-item { padding: 2px 0; }
|
||
.step-header { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
|
||
.step-action { font-weight: 500; }
|
||
.step-remark { color: #606266; font-size: 13px; margin-top: 2px; }
|
||
.step-operator { color: #909399; font-size: 12px; margin-top: 2px; }
|
||
.step-attachments { margin-top: 4px; display: flex; gap: 6px; flex-wrap: wrap; }
|
||
.att-item { display: inline-flex; align-items: center; }
|
||
|
||
/* 紧凑时间线 */
|
||
.detail-left-scroll :deep(.el-timeline) { padding-left: 4px; }
|
||
h4 { margin: 0 0 10px; font-size: 14px; }
|
||
|
||
.detail-handle-bar {
|
||
border-top: 1px solid #ebeef5; padding: 10px 0 0; margin-top: 10px; flex-shrink: 0;
|
||
}
|
||
.handle-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
|
||
.remark-input { flex: 1; min-width: 80px; }
|
||
.handle-files-row { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
|
||
.file-thumb {
|
||
position: relative; width: 48px; height: 48px; border-radius: 4px; overflow: hidden; cursor: pointer;
|
||
border: 1px solid #dcdfe6;
|
||
}
|
||
.file-thumb img { width: 100%; height: 100%; object-fit: cover; }
|
||
.file-close {
|
||
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>
|