This commit is contained in:
liufumingren 2026-08-23 09:37:09 +08:00
parent e46feaaa01
commit 5b9a529c84
7 changed files with 894 additions and 149 deletions

View File

@ -44,6 +44,17 @@ export type ReturnUnpackDetailItem = {
[key: string]: any
}
/** 拆包录像视频 */
export type ReturnUnpackVideo = {
id?: number
video_url?: string
/** recording 录制中 / completed 录制完成 / failed 录制失败 */
status?: 'recording' | 'completed' | 'failed' | string
camera_id?: number
camera_name?: string
[key: string]: any
}
/** 拆包单主表记录 */
export type ReturnUnpackRecord = {
id?: number
@ -65,9 +76,13 @@ export type ReturnUnpackRecord = {
is_original_return?: boolean
total_items?: number
total_quantity?: number
/** 是否产生视频:1 有 / 2 无 */
has_video?: 1 | 2
/** 视频是否可查看:1 可查看 / 2 不可用 */
video_enable?: 1 | 2
/** 幂等复用时携带 */
details?: ReturnUnpackDetailItem[]
videos?: any[]
videos?: ReturnUnpackVideo[]
returnReceived?: any
[key: string]: any
}
@ -93,6 +108,30 @@ export type ReturnUnpackOrderItem = {
/** 原订单详情(原单退回时返回,含 items 明细) */
export type ReturnUnpackOriginalOrder = {
id?: number
/** 订单号(发货单号) */
delivery_order_code?: string
warehouse_id?: number
store_id?: number
wave_id?: number
wave_no?: string
platform_name?: string
create_channel?: string
create_channel_label?: string
items_count?: number
items_total?: number
total_amount?: string
recipient?: {
name?: string
tel?: string
mobile?: string
province?: string
city?: string
district?: string
town?: string
address?: string
[key: string]: any
}
items?: ReturnUnpackOrderItem[]
[key: string]: any
}
@ -434,6 +473,46 @@ export function returnUnpackDetailList(data: ReturnUnpackDetailListParams = {}):
} as any)
}
// ============ returnUnpack.videoList ============
/** returnUnpack.videoList 的 where 筛选条件 */
export type ReturnUnpackVideoListWhere = {
/** 拆包单ID(必填,等值) */
unpack_id?: number
/** 摄像头设备ID(等值) */
camera_id?: number
/** 录像状态(等值):created / recording / completed / failed */
status?: string
}
/** returnUnpack.videoList 排序参数 */
export type ReturnUnpackVideoListSort = {
sortField?: 'id' | 'created_at' | 'updated_at' | 'camera_id'
sortOrder?: 'asc' | 'desc'
}
/** returnUnpack.videoList 请求参数 */
export type ReturnUnpackVideoListParams = {
pagination?: { page?: number; pageSize?: number }
where?: ReturnUnpackVideoListWhere
sort?: ReturnUnpackVideoListSort
}
/** returnUnpack.videoList:拆包录像分页列表 */
export function returnUnpackVideoList(data: ReturnUnpackVideoListParams = {}): Promise<any> {
return request({
url: '/system',
method: 'post',
params: {
method: 'returnUnpack.videoList',
v,
timestamp: new Date().getTime()
},
data,
isSystemApi: true
} as any)
}
// ============ returnUnpack.detail ============
/** returnUnpack.detail 请求参数 */

View File

@ -0,0 +1,58 @@
<template>
<el-table :data="list" size="small" border class="detail-table" empty-text="暂无商品明细">
<el-table-column label="商品图片" width="90">
<template #default="{ row }">
<el-image
v-if="firstImage(row)"
:src="firstImage(row)"
:preview-src-list="row.image_url ?? []"
preview-teleported
fit="cover"
class="stock-thumb"
/>
<span v-else>-</span>
</template>
</el-table-column>
<el-table-column prop="item_code" label="商品编码" min-width="120" show-overflow-tooltip />
<el-table-column prop="item_name" label="商品名称" min-width="140" show-overflow-tooltip />
<el-table-column prop="sku_property" label="SKU" min-width="130" show-overflow-tooltip />
<el-table-column label="条码" min-width="130" show-overflow-tooltip>
<template #default="{ row }">
{{ barcodesLabel(row) }}
</template>
</el-table-column>
<el-table-column prop="plan_qty" label="计划数量" width="90" />
<el-table-column prop="quantity" label="数量" width="90" />
<el-table-column prop="stock_unit" label="单位" width="80" />
<el-table-column prop="stock_id" label="商品ID" width="90">
<template #default="{ row }">{{ row.stock_id ?? '-' }}</template>
</el-table-column>
<el-table-column prop="packing_requirements" label="包装要求" min-width="110" show-overflow-tooltip />
</el-table>
</template>
<script setup lang="ts">
defineProps<{ list: any[] }>()
function firstImage(row: any): string {
return row?.image_url?.[0] ?? ''
}
function barcodesLabel(row: any): string {
const list = Array.isArray(row?.barcodes) ? row.barcodes : []
const text = list.map((b: any) => b?.barcode ?? '').filter(Boolean).join(', ')
return text || '-'
}
</script>
<style scoped lang="scss">
.detail-table {
width: 100%;
}
.stock-thumb {
width: 48px;
height: 48px;
border-radius: 4px;
}
</style>

View File

@ -0,0 +1,35 @@
<template>
<el-button
v-if="videoCount > 0"
link
type="primary"
size="small"
@click.stop="$emit('click')"
>
<el-icon style="margin-right:2px"><VideoCameraFilled /></el-icon>
有视频 ({{ videoCount }})
</el-button>
</template>
<script setup lang="ts">
import { computed } from 'vue'
import { VideoCameraFilled } from '@element-plus/icons-vue'
export interface VideoItem {
id: number
video_url: string
status?: string
camera_id?: number
camera_name?: string
}
const props = defineProps<{
videos: VideoItem[]
}>()
defineEmits<{
click: []
}>()
const videoCount = computed(() => props.videos?.length ?? 0)
</script>

View File

@ -0,0 +1,173 @@
<template>
<el-dialog
:model-value="visible"
title="拆包录像列表"
width="700px"
align-center
:close-on-click-modal="false"
@update:model-value="$emit('update:visible', $event)"
>
<div v-if="videos.length === 0" class="empty-hint">
<el-empty description="暂无录像" :image-size="80" />
</div>
<div v-else class="video-list">
<div
v-for="(video, index) in videos"
:key="video.id ?? index"
class="video-item"
:class="{ 'video-item--disabled': !video.video_url }"
@click="video.video_url && $emit('play', video)"
>
<div class="video-item__thumb">
<el-icon size="28"><VideoPlay /></el-icon>
</div>
<div class="video-item__info">
<div class="video-item__name">
{{ video.camera_name || '录像 ' + (index + 1) }}
</div>
<div class="video-item__meta">
<span>摄像头ID: {{ video.camera_id ?? '—' }}</span>
<span class="meta-divider">|</span>
<span>录像ID: {{ video.id }}</span>
<template v-if="video.status">
<span class="meta-divider">|</span>
<el-tag size="small" :type="video.status === 'completed' ? 'success' : 'danger'">
{{ video.status === 'completed' ? '已完成' : video.status === 'failed' ? '失败' : video.status }}
</el-tag>
</template>
</div>
</div>
<div class="video-item__action">
<el-button v-if="video.video_url" type="primary" size="small" round>播放</el-button>
<span v-else-if="video.status === 'failed'" class="video-item__status video-item__status--unavailable">录像不可用</span>
<span v-else class="video-item__status video-item__status--unplayable">不可播放</span>
</div>
</div>
</div>
<template #footer>
<el-button size="small" @click="$emit('update:visible', false)">关闭</el-button>
</template>
</el-dialog>
</template>
<script setup lang="ts">
import { VideoPlay } from '@element-plus/icons-vue'
import type { VideoItem } from './VideoButton.vue'
defineProps<{
visible: boolean
videos: VideoItem[]
}>()
defineEmits<{
'update:visible': [value: boolean]
play: [video: VideoItem]
}>()
</script>
<style scoped>
.video-list {
display: flex;
flex-direction: column;
gap: 12px;
padding: 4px 0;
}
.video-item {
display: flex;
align-items: center;
gap: 16px;
padding: 16px 20px;
border: 1px solid #ebeef5;
border-radius: 10px;
cursor: pointer;
transition: all 0.2s;
background: #fff;
}
.video-item:hover {
border-color: #409eff;
background: #ecf5ff;
box-shadow: 0 2px 8px rgba(64, 158, 255, 0.15);
transform: translateY(-1px);
}
.video-item--disabled {
cursor: default;
opacity: 0.7;
}
.video-item--disabled:hover {
border-color: #ebeef5;
background: #fff;
box-shadow: none;
transform: none;
}
.video-item--disabled .video-item__thumb {
background: linear-gradient(135deg, #f5f7fa 0%, #e4e7ed 100%);
color: #c0c4cc;
}
.video-item__thumb {
width: 56px;
height: 56px;
display: flex;
align-items: center;
justify-content: center;
background: linear-gradient(135deg, #ecf5ff 0%, #d9ecff 100%);
border-radius: 12px;
color: #409eff;
flex-shrink: 0;
}
.video-item:hover .video-item__thumb {
background: linear-gradient(135deg, #409eff 0%, #66b1ff 100%);
color: #fff;
}
.video-item__info {
flex: 1;
min-width: 0;
}
.video-item__name {
font-size: 15px;
font-weight: 600;
color: #303133;
margin-bottom: 6px;
}
.video-item__meta {
font-size: 13px;
color: #909399;
display: flex;
align-items: center;
gap: 6px;
}
.meta-divider {
color: #dcdfe6;
}
.video-item__action {
flex-shrink: 0;
}
.empty-hint {
padding: 40px 0;
}
.video-item__status {
font-size: 13px;
white-space: nowrap;
}
.video-item__status--unavailable {
color: #f56c6c;
}
.video-item__status--unplayable {
color: #c0c4cc;
}
</style>

View File

@ -0,0 +1,173 @@
<template>
<el-dialog
:model-value="visible"
:title="video?.camera_name || '录像回放'"
width="800px"
align-center
:close-on-click-modal="false"
destroy-on-close
@update:model-value="$emit('update:visible', $event)"
@closed="handleClosed"
>
<div class="player-wrapper">
<!-- 加载中 -->
<div v-if="loading" class="player-overlay">
<el-icon class="is-loading" size="32"><Loading /></el-icon>
<span>加载中…</span>
</div>
<!-- 播放错误 -->
<div v-else-if="errorMsg" class="player-overlay">
<el-icon size="32"><WarningFilled /></el-icon>
<span class="error-text">{{ errorMsg }}</span>
<el-button size="small" type="primary" @click="retry">重试</el-button>
</div>
<!-- 视频播放器 -->
<video
v-show="!loading && !errorMsg"
ref="videoRef"
class="video-element"
:src="video?.video_url"
controls
autoplay
@loadeddata="loading = false"
@error="handleVideoError"
@ended="handleEnded"
/>
</div>
<!-- 视频信息 -->
<div v-if="video" class="video-info-bar">
<span v-if="video.camera_id">摄像头ID: {{ video.camera_id }}</span>
<span v-if="video.camera_name && video.camera_id" class="info-divider">|</span>
<span v-if="video.camera_name">{{ video.camera_name }}</span>
<span class="info-divider">|</span>
<span>录像ID: {{ video.id }}</span>
</div>
<template #footer>
<el-button size="small" @click="$emit('update:visible', false)">关闭</el-button>
</template>
</el-dialog>
</template>
<script setup lang="ts">
import { ref, watch, nextTick } from 'vue'
import { Loading, WarningFilled } from '@element-plus/icons-vue'
import type { VideoItem } from './VideoButton.vue'
const props = defineProps<{
visible: boolean
video: VideoItem | null
}>()
const emit = defineEmits<{
'update:visible': [value: boolean]
}>()
const videoRef = ref<HTMLVideoElement | null>(null)
const loading = ref(true)
const errorMsg = ref('')
// 打开时重置状态
watch(() => props.visible, (val) => {
if (val) {
loading.value = true
errorMsg.value = ''
nextTick(() => {
if (videoRef.value) {
videoRef.value.load()
}
})
}
})
function handleVideoError(e: Event) {
loading.value = false
const el = e.target as HTMLVideoElement
const code = el?.error?.code
const msgMap: Record<number, string> = {
1: '视频加载被中止',
2: '网络错误,无法加载视频',
3: '视频解码失败',
4: '视频格式不支持或文件不存在'
}
errorMsg.value = msgMap[code ?? 4] || '视频播放失败'
}
function handleEnded() {
// 播放结束
}
function retry() {
loading.value = true
errorMsg.value = ''
nextTick(() => {
if (videoRef.value) {
videoRef.value.load()
}
})
}
function handleClosed() {
if (videoRef.value) {
videoRef.value.pause()
videoRef.value.removeAttribute('src')
videoRef.value.load()
}
loading.value = true
errorMsg.value = ''
}
</script>
<style scoped>
.player-wrapper {
position: relative;
width: 100%;
min-height: 360px;
background: #000;
border-radius: 6px;
overflow: hidden;
}
.video-element {
width: 100%;
height: 100%;
min-height: 360px;
display: block;
}
.player-overlay {
position: absolute;
inset: 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 8px;
color: #909399;
font-size: 13px;
}
.error-text {
color: #f56c6c;
max-width: 300px;
text-align: center;
}
.video-info-bar {
margin-top: 10px;
padding: 6px 0;
font-size: 12px;
color: #909399;
display: flex;
align-items: center;
gap: 6px;
flex-wrap: wrap;
}
.info-divider {
color: #dcdfe6;
}
</style>

View File

@ -27,8 +27,8 @@
</div>
</div>
<div class="split-stack">
<div class="upper-wrapper">
<div class="split-stack" ref="splitStackRef">
<div class="upper-wrapper" :style="detailVisible ? upperPaneStyle : upperPaneFullStyle">
<upper-table
ref="upperTable"
title="退回拆包单列表"
@ -39,7 +39,6 @@
:table-size="tableSize"
:pagination="upperPagination"
:show-index="true"
:show-actions="true"
:enable-column-config="true"
:loading="loading"
:query-time="queryTime"
@ -72,10 +71,21 @@
<span v-else>-</span>
</template>
<template #column-actions="{ row }">
<div class="operation-actions">
<el-button size="small" type="primary" link @click.stop="handleViewDetail(row)">详情</el-button>
</div>
<template #column-has_video="{ row }">
<el-tag :type="hasVideoTagType(row)" size="small">{{ hasVideoLabel(row) }}</el-tag>
</template>
<template #column-video_enable="{ row }">
<el-tag :type="videoEnableTagType(row)" size="small">{{ videoEnableLabel(row) }}</el-tag>
</template>
<template #column-videos="{ row }">
<VideoButton
v-if="Array.isArray(row.videos) && row.videos.length"
:videos="row.videos"
@click="openVideoList(row)"
/>
<span v-else>-</span>
</template>
<template #empty>
@ -83,116 +93,187 @@
</template>
</upper-table>
</div>
<template v-if="detailVisible">
<!-- 分隔条 -->
<div class="pane-resizer" title="拖动调整列表与详情区域高度" @mousedown="beginSplitDrag" />
<!-- 详情面板 -->
<div v-if="selectedRecord" class="lower-level" :class="tableSize" :style="lowerPaneStyle">
<div class="detail-header">
<el-tabs v-model="detailActiveTab" class="detail-tab" @tab-change="handleDetailTabChange">
<el-tab-pane label="拆包详情" name="detail" />
<el-tab-pane label="明细分页" name="detailList" />
<el-tab-pane label="拆包录像" name="videoList" />
</el-tabs>
</div>
<div class="detail-container" v-loading="detailLoading">
<div v-if="detailActiveTab === 'detail'" class="detail-page detail-scroll">
<template v-if="detailRecord">
<!-- 主表信息 -->
<el-descriptions title="拆包单信息" :column="3" border size="small" class="detail-section">
<el-descriptions-item label="拆包单ID">{{ detailRecord.id ?? '-' }}</el-descriptions-item>
<el-descriptions-item label="拆包单号">
<span
v-if="detailRecord.unpack_no"
class="copyable"
role="button"
title="点击复制"
@click="copyText(detailRecord.unpack_no)"
>{{ detailRecord.unpack_no }}</span>
<span v-else>-</span>
</el-descriptions-item>
<el-descriptions-item label="退回运单号">
<span
v-if="detailRecord.waybill_code"
class="copyable"
role="button"
title="点击复制"
@click="copyText(detailRecord.waybill_code)"
>{{ detailRecord.waybill_code }}</span>
<span v-else>-</span>
</el-descriptions-item>
<el-descriptions-item label="拆包状态">
<el-tag :type="statusTagType(detailRecord.status)" size="small">{{ statusLabel(detailRecord.status) }}</el-tag>
</el-descriptions-item>
<el-descriptions-item label="明细识别状态">
<el-tag :type="detailStatusTagType(detailRecord.detail_status)" size="small">{{ detailStatusLabel(detailRecord.detail_status) }}</el-tag>
</el-descriptions-item>
<el-descriptions-item label="是否原单退回">
<el-tag :type="detailRecord.is_original_return ? 'success' : 'info'" size="small">
{{ detailRecord.is_original_return ? '是' : '否' }}
</el-tag>
</el-descriptions-item>
<el-descriptions-item label="物品种类">{{ detailRecord.total_items ?? '-' }}</el-descriptions-item>
<el-descriptions-item label="总数量">{{ detailRecord.total_quantity ?? '-' }}</el-descriptions-item>
<el-descriptions-item label="拆包人员">{{ detailRecord.unpacker_name ?? '-' }}</el-descriptions-item>
<el-descriptions-item label="拆包日期">{{ formatTime(detailRecord.unpack_date) }}</el-descriptions-item>
<el-descriptions-item label="拆包开始时间">{{ formatTime(detailRecord.start_time) }}</el-descriptions-item>
<el-descriptions-item label="拆包结束时间">{{ formatTime(detailRecord.end_time) }}</el-descriptions-item>
<el-descriptions-item label="货主ID">{{ detailRecord.store_id ?? '-' }}</el-descriptions-item>
<el-descriptions-item label="货主名称">{{ detailRecord.shop_name || '-' }}</el-descriptions-item>
<el-descriptions-item label="平台交易单号">{{ detailRecord.source_order_codes || '-' }}</el-descriptions-item>
<el-descriptions-item label="原运单ID">{{ detailRecord.order_express_id ?? '-' }}</el-descriptions-item>
<el-descriptions-item label="原订单ID">{{ detailRecord.order_id ?? '-' }}</el-descriptions-item>
<el-descriptions-item label="关联退回收到单">{{ detailRecord.return_received_id ?? '-' }}</el-descriptions-item>
<el-descriptions-item label="摄像头" :span="3">{{ cameraIdsLabel(detailRecord.camera_ids) }}</el-descriptions-item>
<el-descriptions-item label="备注" :span="3">{{ detailRecord.remark || '-' }}</el-descriptions-item>
</el-descriptions>
<!-- 原订单信息 -->
<el-descriptions v-if="detailOrder" title="原订单信息" :column="3" border size="small" class="detail-section">
<el-descriptions-item label="订单ID">{{ detailOrder.id ?? '-' }}</el-descriptions-item>
<el-descriptions-item label="订单号">{{ detailOrder.delivery_order_code ?? detailOrder.order_no ?? '-' }}</el-descriptions-item>
<el-descriptions-item label="货主ID">{{ detailOrder.store_id ?? '-' }}</el-descriptions-item>
<el-descriptions-item label="平台">{{ detailOrder.platform_name ?? '-' }}</el-descriptions-item>
<el-descriptions-item label="波次号">{{ detailOrder.wave_no ?? '-' }}</el-descriptions-item>
<el-descriptions-item label="收件人">{{ detailOrder.recipient?.name ?? '-' }}</el-descriptions-item>
<el-descriptions-item label="联系电话">{{ detailOrder.recipient?.tel || detailOrder.recipient?.mobile || '-' }}</el-descriptions-item>
<el-descriptions-item label="收货地址" :span="2">{{ detailOrder.recipient?.address ?? '-' }}</el-descriptions-item>
<el-descriptions-item label="商品件数">{{ detailOrder.items_count ?? detailOrder.items?.length ?? '-' }}</el-descriptions-item>
<el-descriptions-item label="商品总数">{{ detailOrder.items_total ?? '-' }}</el-descriptions-item>
<el-descriptions-item label="订单金额">{{ detailOrder.total_amount ?? '-' }}</el-descriptions-item>
</el-descriptions>
<!-- 原单商品明细 -->
<template v-if="detailOrder?.items?.length">
<div class="detail-list-header">
<span class="detail-list-title">原单商品明细({{ detailOrder.items.length }})</span>
</div>
<div class="order-items-table-wrap">
<unpack-order-items-table :list="detailOrder.items" />
</div>
</template>
</template>
<el-empty v-else description="暂无详情数据" :image-size="60" />
</div>
<!-- 明细分页 -->
<div v-else-if="detailActiveTab === 'detailList'" class="detail-page detail-scroll">
<div v-loading="detailListLoading" class="detail-list-pane">
<unpack-detail-table :list="detailList" />
<el-pagination
v-if="detailPagination.total > detailPagination.pageSize"
class="detail-pagination"
layout="prev, pager, next, total"
:current-page="detailPagination.currentPage"
:page-size="detailPagination.pageSize"
:total="detailPagination.total"
@current-change="handleDetailListPageChange"
/>
</div>
</div>
<!-- 拆包录像分页列表 -->
<div v-else class="detail-page detail-scroll">
<div v-loading="videoListLoading" class="detail-list-pane">
<el-table :data="videoListRows" size="small" border empty-text="暂无录像">
<el-table-column prop="id" label="录像ID" width="90" />
<el-table-column label="摄像头" min-width="130" show-overflow-tooltip>
<template #default="{ row }">{{ row.camera_name || '-' }}</template>
</el-table-column>
<el-table-column label="状态" width="110">
<template #default="{ row }">
<el-tag :type="videoStatusTagType(row.status)" size="small">{{ videoStatusLabel(row.status) }}</el-tag>
</template>
</el-table-column>
<el-table-column prop="created_at" label="创建时间" width="170" />
<el-table-column label="操作" width="110" fixed="right">
<template #default="{ row }">
<el-button v-if="row.video_url" link type="primary" size="small" @click="handlePlayVideo(row)">播放</el-button>
<span v-else-if="row.status === 'failed'" class="detail-video-unavailable">录像不可用</span>
<span v-else class="detail-video-unplayable">不可播放</span>
</template>
</el-table-column>
</el-table>
<el-pagination
v-if="videoPagination.total > videoPagination.pageSize"
class="detail-pagination"
layout="prev, pager, next, total"
:current-page="videoPagination.currentPage"
:page-size="videoPagination.pageSize"
:total="videoPagination.total"
@current-change="loadVideoListPage"
/>
</div>
</div>
</div>
</div>
<div v-else class="no-selection" :style="lowerPaneStyle">
<div class="empty-tip">
<p>请从上方列表中选择一项查看详情</p>
</div>
</div>
</template>
</div>
</div>
<!-- ========== 拆包详情弹窗 ========== -->
<el-dialog v-model="detailVisible" title="退回拆包详情" width="1080px" destroy-on-close align-center>
<div v-loading="detailLoading" class="detail-content">
<el-tabs v-model="detailActiveTab" @tab-change="handleDetailTabChange">
<el-tab-pane label="拆包详情" name="detail">
<template v-if="detailRecord">
<!-- 主表信息 -->
<el-descriptions title="拆包单信息" :column="3" border size="small" class="detail-section">
<el-descriptions-item label="拆包单ID">{{ detailRecord.id ?? '-' }}</el-descriptions-item>
<el-descriptions-item label="拆包单号">
<span
v-if="detailRecord.unpack_no"
class="copyable"
role="button"
title="点击复制"
@click="copyText(detailRecord.unpack_no)"
>{{ detailRecord.unpack_no }}</span>
<span v-else>-</span>
</el-descriptions-item>
<el-descriptions-item label="退回运单号">
<span
v-if="detailRecord.waybill_code"
class="copyable"
role="button"
title="点击复制"
@click="copyText(detailRecord.waybill_code)"
>{{ detailRecord.waybill_code }}</span>
<span v-else>-</span>
</el-descriptions-item>
<el-descriptions-item label="拆包状态">
<el-tag :type="statusTagType(detailRecord.status)" size="small">{{ statusLabel(detailRecord.status) }}</el-tag>
</el-descriptions-item>
<el-descriptions-item label="明细识别状态">
<el-tag :type="detailStatusTagType(detailRecord.detail_status)" size="small">{{ detailStatusLabel(detailRecord.detail_status) }}</el-tag>
</el-descriptions-item>
<el-descriptions-item label="是否原单退回">
<el-tag :type="detailRecord.is_original_return ? 'success' : 'info'" size="small">
{{ detailRecord.is_original_return ? '是' : '否' }}
</el-tag>
</el-descriptions-item>
<el-descriptions-item label="物品种类">{{ detailRecord.total_items ?? '-' }}</el-descriptions-item>
<el-descriptions-item label="总数量">{{ detailRecord.total_quantity ?? '-' }}</el-descriptions-item>
<el-descriptions-item label="拆包人员">{{ detailRecord.unpacker_name ?? '-' }}</el-descriptions-item>
<el-descriptions-item label="拆包日期">{{ formatTime(detailRecord.unpack_date) }}</el-descriptions-item>
<el-descriptions-item label="拆包开始时间">{{ formatTime(detailRecord.start_time) }}</el-descriptions-item>
<el-descriptions-item label="拆包结束时间">{{ formatTime(detailRecord.end_time) }}</el-descriptions-item>
<el-descriptions-item label="货主ID">{{ detailRecord.store_id ?? '-' }}</el-descriptions-item>
<el-descriptions-item label="货主名称">{{ detailRecord.shop_name || '-' }}</el-descriptions-item>
<el-descriptions-item label="平台交易单号">{{ detailRecord.source_order_codes || '-' }}</el-descriptions-item>
<el-descriptions-item label="原运单ID">{{ detailRecord.order_express_id ?? '-' }}</el-descriptions-item>
<el-descriptions-item label="原订单ID">{{ detailRecord.order_id ?? '-' }}</el-descriptions-item>
<el-descriptions-item label="关联退回收到单">{{ detailRecord.return_received_id ?? '-' }}</el-descriptions-item>
<el-descriptions-item label="摄像头" :span="3">{{ cameraIdsLabel(detailRecord.camera_ids) }}</el-descriptions-item>
<el-descriptions-item label="备注" :span="3">{{ detailRecord.remark || '-' }}</el-descriptions-item>
</el-descriptions>
<!-- 拆包录像列表弹窗 -->
<VideoListDialog
v-model:visible="videoListVisible"
:videos="currentVideos"
@play="handlePlayVideo"
/>
<!-- 原订单信息 -->
<el-descriptions v-if="detailOrder" title="原订单信息" :column="3" border size="small" class="detail-section">
<el-descriptions-item label="订单ID">{{ detailOrder.id ?? '-' }}</el-descriptions-item>
<el-descriptions-item label="订单号">{{ detailOrder.order_no ?? '-' }}</el-descriptions-item>
<el-descriptions-item label="货主ID">{{ detailOrder.store_id ?? '-' }}</el-descriptions-item>
<el-descriptions-item label="收件人">{{ detailOrder.receiver_name ?? '-' }}</el-descriptions-item>
<el-descriptions-item label="联系电话">{{ detailOrder.receiver_tel ?? detailOrder.receiver_mobile ?? '-' }}</el-descriptions-item>
<el-descriptions-item label="商品件数">{{ detailOrder.items?.length ?? '-' }}</el-descriptions-item>
</el-descriptions>
<!-- 明细表格(returnUnpack.detail 内嵌 record.details) -->
<div class="detail-list-header">
<span class="detail-list-title">拆包明细({{ detailRecord.details?.length ?? 0 }})</span>
</div>
<unpack-detail-table :list="detailRecord.details ?? []" />
</template>
</el-tab-pane>
<!-- Tab2: returnUnpack.detailList -->
<el-tab-pane label="明细分页" name="detailList">
<div v-loading="detailListLoading" class="detail-list-pane">
<unpack-detail-table :list="detailList" />
<el-pagination
v-if="detailPagination.total > detailPagination.pageSize"
class="detail-pagination"
layout="prev, pager, next, total"
:current-page="detailPagination.currentPage"
:page-size="detailPagination.pageSize"
:total="detailPagination.total"
@current-change="handleDetailListPageChange"
/>
</div>
</el-tab-pane>
</el-tabs>
</div>
<template #footer>
<el-button @click="detailVisible = false">关闭</el-button>
</template>
</el-dialog>
<!-- 录像播放弹窗 -->
<VideoPlayerDialog
v-model:visible="playerVisible"
:video="playingVideo"
/>
</div>
</template>
<script setup lang="ts">
import { onMounted, reactive, ref } from 'vue'
import { computed, onMounted, reactive, ref } from 'vue'
import { ElMessage } from 'element-plus'
import {
returnUnpackList,
returnUnpackDetail,
returnUnpackDetailList,
returnUnpackVideoList,
} from '@/api/returnunpack'
import { loadStores } from '@/api/index/index'
import { extractStoreListFromResponse, fillStoreScanFieldOptions } from '@/views/order/orderManagement/config/order-common-config'
@ -201,7 +282,12 @@ import { returnUnpackAvailableFields, returnUnpackColumns, returnUnpackToolbarBu
import ScanBox from '@/components/ScanBox/index.vue'
import UpperTable from '@/components/UpperTable/index.vue'
import OrderToolbarButtonGroup from '@/views/order/orderManagement/component/OrderToolbarButtonGroup.vue'
import { useVerticalSplitPane } from '@/composables/useVerticalSplitPane'
import UnpackDetailTable from './components/UnpackDetailTable.vue'
import UnpackOrderItemsTable from './components/UnpackOrderItemsTable.vue'
import VideoButton, { type VideoItem } from './components/VideoButton.vue'
import VideoListDialog from './components/VideoListDialog.vue'
import VideoPlayerDialog from './components/VideoPlayerDialog.vue'
// ==================== 常量 / 工具 ====================
@ -256,6 +342,54 @@ function cameraIdsLabel(ids: any): string {
return ids.join(', ')
}
function videoStatusLabel(val: any): string {
const map: Record<string, string> = {
recording: '录制中',
completed: '录制完成',
failed: '录制失败',
}
return map[String(val)] ?? String(val ?? '-')
}
function videoStatusTagType(val: any): 'success' | 'warning' | 'info' | 'danger' {
const map: Record<string, 'success' | 'warning' | 'info' | 'danger'> = {
recording: 'warning',
completed: 'success',
failed: 'danger',
}
return map[String(val)] ?? 'info'
}
/** 是否产生视频:优先按 has_video(1 有 / 2 无),缺失时按 videos 数组兜底 */
function resolveHasVideo(row: any): 1 | 2 | null {
if (row?.has_video === 1 || row?.has_video === 2) return row.has_video
if (Array.isArray(row?.videos)) return row.videos.length > 0 ? 1 : 2
return null
}
function hasVideoLabel(row: any): string {
const v = resolveHasVideo(row)
if (v === 1) return '有视频'
if (v === 2) return '无视频'
return '-'
}
function hasVideoTagType(row: any): 'success' | 'info' {
return resolveHasVideo(row) === 1 ? 'success' : 'info'
}
function videoEnableLabel(row: any): string {
if (row?.video_enable === 1) return '可查看'
if (row?.video_enable === 2) return '不可用'
return '-'
}
function videoEnableTagType(row: any): 'success' | 'danger' | 'info' {
if (row?.video_enable === 1) return 'success'
if (row?.video_enable === 2) return 'danger'
return 'info'
}
function isOk(res: any): boolean {
return Boolean(res && (res.code === 1 || res.code === 200 || res.code === 20000))
}
@ -365,8 +499,11 @@ function handleConditionClear() {
fetchData()
}
function handleRowClick() {
/* 点击行无默认行为,详情通过操作列触发 */
function handleRowClick(row: any) {
selectedRecord.value = row ?? null
if (row) {
handleViewDetail(row)
}
}
// ==================== 条件转换 ====================
@ -468,9 +605,23 @@ function handleSortChange({ prop, order }: any) {
fetchData()
}
// ==================== 详情 ====================
// ==================== 详情(下方分栏) ====================
const detailVisible = ref(false)
const {
splitStackRef,
beginSplitDrag,
lowerPaneStyle,
upperPaneStyle,
} = useVerticalSplitPane({ defaultLowerPercent: 38 })
const upperPaneFullStyle = computed(() => ({
flex: '1 1 auto',
minHeight: '0',
overflow: 'hidden',
}))
const detailVisible = ref(true)
const selectedRecord = ref<any>(null)
const detailLoading = ref(false)
const detailActiveTab = ref('detail')
const detailRecord = ref<any>(null)
@ -481,7 +632,13 @@ const detailListLoading = ref(false)
const detailList = ref<any[]>([])
const detailPagination = reactive({ currentPage: 1, pageSize: 20, total: 0 })
// Tab3(returnUnpack.videoList)分页录像状态
const videoListLoading = ref(false)
const videoListRows = ref<any[]>([])
const videoPagination = reactive({ currentPage: 1, pageSize: 10, total: 0 })
async function handleViewDetail(row: any) {
selectedRecord.value = row
detailVisible.value = true
detailLoading.value = true
detailActiveTab.value = 'detail'
@ -490,6 +647,9 @@ async function handleViewDetail(row: any) {
detailList.value = []
detailPagination.currentPage = 1
detailPagination.total = 0
videoListRows.value = []
videoPagination.currentPage = 1
videoPagination.total = 0
try {
const res: any = await returnUnpackDetail({ id: row.id })
if (isOk(res)) {
@ -507,10 +667,12 @@ async function handleViewDetail(row: any) {
}
}
// Tab 切换:切到「明细分页」时按分页加载 detailList
// Tab 切换:切到「明细分页」时按分页加载明细,切到「拆包录像」时按分页加载录像
async function handleDetailTabChange(name: string | number) {
if (name === 'detailList' && detailRecord.value) {
await loadDetailListPage(detailPagination.currentPage || 1)
} else if (name === 'videoList' && detailRecord.value) {
await loadVideoListPage(videoPagination.currentPage || 1)
}
}
@ -545,6 +707,52 @@ function handleDetailListPageChange(page: number) {
loadDetailListPage(page)
}
async function loadVideoListPage(page: number) {
if (!detailRecord.value) return
videoListLoading.value = true
try {
const res: any = await returnUnpackVideoList({
pagination: { page, pageSize: videoPagination.pageSize },
where: { unpack_id: detailRecord.value.id },
})
if (isOk(res)) {
const data = res.data ?? res
videoListRows.value = data.list ?? []
const total = data.pagination?.total ?? 0
videoPagination.currentPage = page
videoPagination.total = total
} else {
videoListRows.value = []
videoPagination.total = 0
ElMessage.error(res?.message || '获取拆包录像列表失败')
}
} catch {
videoListRows.value = []
videoPagination.total = 0
} finally {
videoListLoading.value = false
}
}
// ==================== 录像播放 ====================
const videoListVisible = ref(false)
const playerVisible = ref(false)
const currentVideos = ref<VideoItem[]>([])
const playingVideo = ref<VideoItem | null>(null)
function openVideoList(row: any) {
currentVideos.value = Array.isArray(row.videos) ? row.videos : []
if (currentVideos.value.length === 0) return
videoListVisible.value = true
}
function handlePlayVideo(video: VideoItem) {
videoListVisible.value = false
playingVideo.value = video
playerVisible.value = true
}
// ==================== 货主选项加载 ====================
async function loadStoreOptions() {
@ -588,48 +796,65 @@ onMounted(() => {
flex-wrap: wrap;
}
.detail-content {
.detail-video-unavailable {
font-size: 12px;
color: #f56c6c;
}
.detail-video-unplayable {
font-size: 12px;
color: #c0c4cc;
}
.detail-scroll {
height: 100%;
padding: 16px;
box-sizing: border-box;
overflow: auto;
}
.detail-section {
margin-bottom: 16px;
&:last-child {
margin-bottom: 0;
}
}
.copyable {
cursor: pointer;
color: #409eff;
&:hover {
text-decoration: underline;
}
}
.detail-list-header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 8px;
.detail-list-title {
font-size: 14px;
font-weight: 600;
color: #303133;
}
}
.detail-list-pane {
min-height: 160px;
}
.detail-section {
margin-bottom: 16px;
.detail-pagination {
margin-top: 10px;
display: flex;
justify-content: flex-end;
}
&:last-child {
margin-bottom: 0;
}
}
.copyable {
cursor: pointer;
color: #409eff;
&:hover {
text-decoration: underline;
}
}
.detail-list-header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 8px;
.detail-list-title {
font-size: 14px;
font-weight: 600;
color: #303133;
}
}
.detail-list-pane {
min-height: 160px;
}
.detail-pagination {
margin-top: 10px;
display: flex;
justify-content: flex-end;
}
.order-items-table-wrap {
margin-bottom: 16px;
}
.stock-picker-trigger {

View File

@ -73,8 +73,10 @@ export const returnUnpackColumns = [
{ prop: 'unpack_date', label: '拆包日期', width: '130' },
{ prop: 'shop_name', label: '货主/店铺', minWidth: '120', showOverflowTooltip: true },
{ prop: 'is_original_return', label: '原单退回', width: '100' },
{ prop: 'has_video', label: '视频', width: '90' },
{ prop: 'video_enable', label: '视频可用', width: '100' },
{ prop: 'videos', label: '视频状态', minWidth: '150' },
{ prop: 'created_at', label: '创建时间', width: '170', sortable: 'custom' },
{ prop: 'actions', label: '操作', width: '240', fixed: 'right' },
]
// ============================================================