This commit is contained in:
yin 2026-07-22 18:18:30 +08:00
parent 6c8d1f5014
commit daebceebd6
35 changed files with 3816 additions and 409 deletions

View File

@ -4,5 +4,8 @@ VITE_USER_NODE_ENV = development
# base api
VITE_APP_BASE_API = 'http://192.168.11.56:6060/'
# file server (export download)
VITE_FILE_SERVER_BASE = 'https://ye4s.file.gzxunren.com'
VITE_APP_IM_WS_URL=wss://your-im-server.com/ws
VITE_APP_IM_API_URL=https://your-im-server.com/api

View File

@ -4,5 +4,8 @@ VITE_USER_NODE_ENV = production
# base api
VITE_APP_BASE_API = 'https://qimen.wms.gztbyc.com/'
# file server (export download)
VITE_FILE_SERVER_BASE = 'https://ye4s.file.gzxunren.com'
VITE_APP_IM_WS_URL=wss://your-im-server.com/ws
VITE_APP_IM_API_URL=https://your-im-server.com/api

View File

@ -3,3 +3,6 @@ VITE_USER_NODE_ENV = production
# base api
VITE_APP_BASE_API = '/stage-api'
# file server (export download)
VITE_FILE_SERVER_BASE = 'https://ye4s.file.gzxunren.com'

View File

@ -55,6 +55,25 @@ export function stockWarehouseExternalList(params: {
} as any)
}
/** 提交外仓商品导出任务,返回 task_id/status/progress/message/result/error/update_time */
export function stockWarehouseExternalExport(data: {
warehouse_id?: number
where?: Record<string, any>
sort?: StockWarehouseListSort
}) {
return request({
url: '/system',
method: 'post',
params: {
method: 'stock.warehouse.externalExport',
v,
timestamp: new Date().getTime()
},
data: data || {},
isSystemApi: true
} as any)
}
export function getProhibitedType() {
return request({
url: '/system',

View File

@ -748,3 +748,50 @@ export function entryExportTaskProgress(data: EntryExportTaskProgressParams): Pr
isSystemApi: true,
} as any)
}
/** storage.entry.storeExport 查询参数(货主侧入库单导出) */
export type EntryStoreExportParams = {
where?: Record<string, any>
sort?: {
sortField?: string
sort_field?: string
sortOrder?: string
sort_order?: string
}
}
/** storage.entry.storeExport:货主侧提交入库单导出任务 */
export function entryStoreExport(data: EntryStoreExportParams): Promise<any> {
return request({
url: '/system',
method: 'post',
params: {
method: 'storage.entry.storeExport',
v,
timestamp: new Date().getTime(),
},
data,
isSystemApi: true,
} as any)
}
/** storage.entry.storeExportTaskProgress 查询参数 */
export type EntryStoreExportTaskProgressParams = {
task_id?: string
taskId?: string
}
/** storage.entry.storeExportTaskProgress:货主侧查询入库单导出任务进度 */
export function entryStoreExportTaskProgress(data: EntryStoreExportTaskProgressParams): Promise<any> {
return request({
url: '/system',
method: 'post',
params: {
method: 'storage.entry.storeExportTaskProgress',
v,
timestamp: new Date().getTime(),
},
data,
isSystemApi: true,
} as any)
}

View File

@ -51,3 +51,50 @@ export function getAvailableInboundQuantity(
isSystemApi: true
} as any)
}
/** storage.receiving.export 查询参数(货主维度收货单导出) */
export type ReceivingExportParams = {
where?: Record<string, any>
sort?: {
sortField?: string
sort_field?: string
sortOrder?: string
sort_order?: string
}
}
/** storage.receiving.export:货主侧提交收货单导出任务 */
export function exportReceiving(data: ReceivingExportParams): Promise<any> {
return request({
url: '/system',
method: 'post',
params: {
method: 'storage.receiving.export',
v,
timestamp: new Date().getTime()
},
data,
isSystemApi: true
} as any)
}
/** storage.receiving.exportTaskProgress 查询参数 */
export type ReceivingExportTaskProgressParams = {
task_id?: string
taskId?: string
}
/** storage.receiving.exportTaskProgress:货主侧查询收货单导出任务进度 */
export function exportReceivingTaskProgress(data: ReceivingExportTaskProgressParams): Promise<any> {
return request({
url: '/system',
method: 'post',
params: {
method: 'storage.receiving.exportTaskProgress',
v,
timestamp: new Date().getTime()
},
data,
isSystemApi: true
} as any)
}

View File

@ -130,18 +130,38 @@ export function rejectReceiving(data: any): Promise<any> {
})
}
// export function exportReceiving(data: any): Promise<any> {
// return request({
// url: '/system',
// method: 'post',
// params: {
// method: 'storage.receiving.exportReceiving',
// v,
// timestamp: new Date().getTime()
// },
// data: data
// })
// }
/** 提交收货单异步导出任务 */
export function exportReceiving(data: {
where?: Record<string, any>
sort?: { sortField?: string; sortOrder?: string }
}): Promise<any> {
return request({
url: '/system',
method: 'post',
params: {
method: 'storage.receiving.export',
v,
timestamp: new Date().getTime()
},
data: data || {},
isSystemApi: true
} as any)
}
/** 查询收货单导出任务进度 */
export function exportReceivingTaskProgress(data: { task_id?: string; taskId?: string }): Promise<any> {
return request({
url: '/system',
method: 'post',
params: {
method: 'storage.receiving.exportTaskProgress',
v,
timestamp: new Date().getTime()
},
data,
isSystemApi: true
} as any)
}
export function createReceiving(data: any): Promise<any> {
return request({

View File

@ -397,3 +397,59 @@ export function storeWarehouseExportPrintQuantityLogsTaskProgress(data: {
isSystemApi: true
} as any)
}
/** 按条件分页查询面单余额变更日志(货主维度,无需 store_id) */
export function storeWarehouseQueryStorePrintQuantityLogs(data: {
where?: Record<string, any>
pagination?: {
page?: number
page_size?: number
}
}) {
return request({
url: '/system',
method: 'post',
params: {
method: 'storeWarehouse.store.queryStorePrintQuantityLogs',
v,
timestamp: new Date().getTime()
},
data,
isSystemApi: true
} as any)
}
/** 提交面单余额变更日志导出任务(货主维度) */
export function storeWarehouseExportStorePrintQuantityLogs(data: {
where?: Record<string, any>
}) {
return request({
url: '/system',
method: 'post',
params: {
method: 'storeWarehouse.store.exportStorePrintQuantityLogs',
v,
timestamp: new Date().getTime()
},
data,
isSystemApi: true
} as any)
}
/** 查询面单余额变更日志导出任务进度(货主维度) */
export function storeWarehouseExportStorePrintQuantityLogsTaskProgress(data: {
task_id?: string
taskId?: string
}) {
return request({
url: '/system',
method: 'post',
params: {
method: 'storeWarehouse.store.exportStorePrintQuantityLogsTaskProgress',
v,
timestamp: new Date().getTime()
},
data,
isSystemApi: true
} as any)
}

View File

@ -27,6 +27,8 @@
<!-- 自定义筛选 -->
<div v-show="activeTab === 'custom'" class="custom-filter">
<div class="filter-scroll-area" ref="filterScroll">
<!-- 页面自定义头部(如仓库选择、关键词搜索等) -->
<slot name="filter-header" />
<!-- 所有字段配置的表单 -->
<div class="field-forms">
<template v-for="(field, fieldIndex) in availableFields" :key="field.value">
@ -1308,43 +1310,59 @@ defineExpose({ getConditions, reset, clear, getFieldDraft, setFieldCondition, su
.scan-tabs {
flex-shrink: 0;
border-bottom: 1px solid #ebeef5;
background: #fafafa;
background: #f8fbff;
}
.scan-tabs :deep(.el-tabs__header) {
margin: 0;
}
.scan-tabs :deep(.el-tabs__header.is-top) {
padding: 4px 12px 0;
background: #f8fbff;
border-bottom: 1px solid #e8eef7;
margin: 0;
}
.scan-tabs :deep(.el-tabs__nav-wrap::after) {
display: none;
}
.scan-tabs :deep(.el-tabs__active-bar) {
display: none;
height: 2px;
border-radius: 2px;
background-color: #409eff;
bottom: 0;
}
.scan-tabs :deep(.el-tabs__item) {
height: 40px;
line-height: 40px;
font-size: 13px;
padding: 0 12px;
height: 38px;
line-height: 38px;
font-size: 14px;
font-weight: 500;
padding: 0 20px;
color: #606266;
border: 1px solid transparent;
border-bottom: none;
border-radius: 4px 4px 0 0;
transition: color 0.2s;
border-radius: 6px 6px 0 0;
transition: all 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);
margin-right: 4px;
}
.scan-tabs :deep(.el-tabs__item:hover) {
color: var(--el-color-primary);
color: #409eff;
background-color: rgba(64, 158, 255, 0.05);
}
.scan-tabs :deep(.el-tabs__item.is-active) {
color: var(--el-color-primary);
color: #409eff;
font-weight: 600;
background-color: #fff;
border-color: #ebeef5;
border-bottom-color: #fff;
border-color: #e8eef7;
border-bottom: 2px solid #fff;
margin-bottom: -1px;
position: relative;
z-index: 1;
}
.tab-label {
@ -1382,6 +1400,16 @@ defineExpose({ getConditions, reset, clear, getFieldDraft, setFieldCondition, su
scrollbar-width: none; /* Firefox */
}
/* filter-header 插槽内容样式 */
.filter-header-content {
display: flex;
flex-direction: column;
gap: 8px;
margin-bottom: 16px;
padding-bottom: 12px;
border-bottom: 1px solid #ebeef5;
}
/* 自定义筛选样式 */
.field-forms {
display: flex;

View File

@ -41,7 +41,7 @@ export const componentMap: Record<string, any> = {
'storage/productflow/store': () => import('@/views/storage/productflow/store/index.vue'),
'store/index': () => import('@/views/store/stores/index.vue'),
'Externalwarehouse/shipperSigning/index': () => import('@/views/Externalwarehouse/shipperSigning/index.vue'),
'wave/index': () => import('@/views/order/waveOrder/index.vue'),
'wave/index': () => import('@/views/order/waveOrder2/index.vue'),
/** 与后端菜单 component 字段兼容 */
'order/waveOrder': () => import('@/views/order/waveOrder/index.vue'),
'orderreview/index': () => import('@/views/order/orderreview/index.vue'),
@ -65,5 +65,5 @@ export const componentMap: Record<string, any> = {
'system/setting/pickcart/index':() => import('@/views/system/setting/pickcart/index.vue'),
'video/cameraServer/index': () => import('@/views/video/newcamaraserver/index.vue'),
'video/camera/index': () => import('@/views/video/newcamara/index.vue'),
'data/packingflow': () => import('@/views/data/packingflow/index.vue'),
'data/packingflow': () => import('@/views/data/newpackingflow/index.vue'),
};

View File

@ -47,8 +47,17 @@ export function normalizeExportDownloadUrl(fileUrl: string) {
if (!fileUrl) return ''
if (/^https?:\/\//i.test(fileUrl)) return fileUrl
const normalizedPath = fileUrl.startsWith('/') ? fileUrl : `/${fileUrl}`
const baseApi = String(import.meta.env.VITE_APP_BASE_API || '')
// 优先使用文件服务器地址,否则回退到 API 基础地址
const baseApi = String(
import.meta.env.VITE_FILE_SERVER_BASE
|| import.meta.env.VITE_APP_BASE_API
|| ''
)
const normalizedBase = baseApi.endsWith('/') ? baseApi.slice(0, -1) : baseApi
if (/^https?:\/\//i.test(normalizedBase)) {
return `${normalizedBase}${normalizedPath}`
}
if (normalizedBase.startsWith('/')) {
return `${window.location.origin}${normalizedBase}${normalizedPath}`
}

View File

@ -23,8 +23,8 @@
<script setup lang="ts">
import { computed } from 'vue'
import type { ColumnSlotConfig } from '../config/template-config'
import { TAG_RESOLVERS, translate, formatTime } from '../config/template-config'
import type { ColumnSlotConfig } from '../config/packingflow-config'
import { TAG_RESOLVERS, translate, formatTime } from '../config/packingflow-config'
defineOptions({ name: 'ColumnCellRenderer' })

View File

@ -58,8 +58,8 @@
<script setup lang="ts">
import { ref, reactive, type Component } from 'vue'
import { ElMessageBox } from 'element-plus'
import { COMPONENT_REGISTRY } from '../config/template-config'
import type { OperationButtonConfig } from '../config/template-config'
import { COMPONENT_REGISTRY } from '../config/packingflow-config'
import type { OperationButtonConfig } from '../config/packingflow-config'
defineOptions({ name: 'OperationCellRenderer' })

View File

@ -0,0 +1,34 @@
<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
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,134 @@
<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"
@click="$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>
</div>
</div>
<div class="video-item__action">
<el-button type="primary" size="small" round>播放</el-button>
</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__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;
}
</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

@ -42,8 +42,8 @@
<script setup lang="ts">
import { ref, watch } from 'vue'
import { TAG_RESOLVERS, translate } from '../template-config'
import type { DetailSectionConfig, DetailFieldConfig } from '../template-config'
import { TAG_RESOLVERS, translate } from '../packingflow-config'
import type { DetailSectionConfig, DetailFieldConfig } from '../packingflow-config'
defineOptions({ name: 'DetailPanel' })
@ -60,10 +60,7 @@ const enrichedData = ref<Record<string, any> | null>(null)
watch(() => props.row, async (newRow) => {
if (newRow && props.apiMethod) {
try {
const res = await props.apiMethod({
id: newRow.id,
code: newRow.code
})
const res = await props.apiMethod(newRow.id)
if (res && (res.code === 1 || res.code === 200)) {
enrichedData.value = res.data ?? res
} else {
@ -112,14 +109,18 @@ function resolveTagType(field: DetailFieldConfig, value: any): string {
<style lang="scss" scoped>
.detail-panel {
padding: 8px 0;
height: 100%;
overflow-y: auto;
padding: 16px;
}
.empty-tip {
text-align: center;
font-size: 13px;
display: flex;
align-items: center;
justify-content: center;
height: 100%;
font-size: 14px;
color: #909399;
padding: 40px 0;
}
.section {

View File

@ -0,0 +1,750 @@
/**
* 【打包流水】页面配置 — 基于 template v2 架构
*
* 原 packingflow 页面迁移至 newpackingflow 新结构。
* 仓库选择、运单号搜索等筛选条件统一整合到左侧 ScanBox 面板。
*/
import type { Component } from 'vue'
import DetailPanel from './components/DetailPanel.vue'
import LogPanel from './components/LogPanel.vue'
import { packingList, packingGet } from '@/api/order/packing/index'
// ============================================================
// 〇、全局页面配置
// ============================================================
export const PAGE_CONFIG = {
/** 是否显示顶部多标签栏 */
showTabArea: false,
/** 单页模式:不显示标签栏,仅一个标签页内容 */
singlePage: true,
/** 是否启用详情面板(底部分栏),false 时表格占满全高 */
enableDetailPanel: true
}
// ============================================================
// 〇-A、组件注册表
// ============================================================
export const COMPONENT_REGISTRY: Record<string, Component> = {
DetailPanel,
LogPanel
}
// ============================================================
// 〇-B、SCANBOX_GROUPS — ScanBox 分组名称
// ============================================================
export const SCANBOX_GROUPS = {
basic: '基础信息',
process: '流程状态',
time: '时间范围'
} as const
// ============================================================
// 一、FIELD_DICT — 全局字段预设表(唯一真相来源)
// ============================================================
// 每个字段拥有:
// label — 唯一翻译文本
// scanBox — ScanBox 渲染配置(type/options/group)
// table — 表格列配置(minWidth/fixed/align/sortable)
// slot — 单元格渲染配置(tag/tagResolver/translateField)
// detailLabel — 明细面板中的标签文本(可选,默认用 label)
// filterParamMap — ScanBox 筛选值 → API 传参值映射
export interface FieldDefinition {
key: string
label: string
scanBox: {
type: 'text' | 'select' | 'daterange' | 'number'
group?: string
options?: { label: string; value: any }[]
} | null
table: {
minWidth?: number
width?: number
fixed?: 'left' | 'right' | boolean
align?: 'left' | 'center' | 'right'
sortable?: boolean
showOverflowTooltip?: boolean
copyAction?: 'copy' | 'copyQr'
copyValue?: (row: any) => any
} | null
slot: {
type: 'tag' | 'text' | 'default' | 'operation'
tagType?: string | Record<string, string>
tagResolver?: string
translateField?: string
format?: 'datetime'
} | null
detailLabel?: string
filterParamMap?: Record<string, string>
}
// ============================================================
// VALUE_MAPS — 值翻译映射(select options 和 tag 翻译共用)
// ============================================================
export const VALUE_MAPS: Record<string, Record<string, string>> = {
status: {
'0': '待处理', '1': '打包中', '2': '已完成', '3': '异常',
'待处理': '待处理', '打包中': '打包中', '已完成': '已完成', '异常': '异常'
},
pack_mode: {
'1': '散单', '2': '团购',
'散单': '散单', '团购': '团购'
}
}
/** 从 VALUE_MAPS 衍生 options(优先取中文值作为 option value) */
export function getOptions(field: string): { label: string; value: string }[] {
const map = VALUE_MAPS[field]
if (!map) return []
const seen = new Set<string>()
const opts: { label: string; value: string }[] = []
const chineseKeys: [string, string][] = []
const otherKeys: [string, string][] = []
for (const [v, l] of Object.entries(map)) {
if (/^[\u4e00-\u9fa5]/.test(v)) {
chineseKeys.push([v, l])
} else {
otherKeys.push([v, l])
}
}
for (const [v, l] of [...chineseKeys, ...otherKeys]) {
if (!seen.has(l)) {
seen.add(l)
opts.push({ label: l, value: v })
}
}
return opts
}
/** 翻译 value → label */
export function translate(field: string, value: any): string {
const map = VALUE_MAPS[field]
if (!map) return String(value ?? '—')
return map[String(value)] ?? String(value ?? '—')
}
/** 格式化时间戳为 YYYY-MM-DD HH:mm:ss */
export function formatTime(value: any): string {
if (!value) return '—'
try {
const d = new Date(value)
if (isNaN(d.getTime())) return String(value)
const pad = (n: number) => String(n).padStart(2, '0')
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())} ${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}`
} catch {
return String(value)
}
}
// ============================================================
// TAG_RESOLVERS — 标签颜色解析器
// ============================================================
export const TAG_RESOLVERS: Record<string, (val: any) => string> = {
resolveStatusTag(v) {
const s = Number(v)
if (s === 0) return 'info' // 待处理
if (s === 1) return 'warning' // 打包中
if (s === 2) return 'success' // 已完成
if (s === 3) return 'danger' // 异常
return 'info'
},
resolvePackModeTag(v) {
const s = Number(v)
if (s === 2) return 'warning' // 团购
return 'info' // 散单
}
}
// ============================================================
// 二、FIELD_DICT 实例 — 打包流水字段定义
// ============================================================
export const FIELD_DICT: Record<string, FieldDefinition> = {
id: {
key: 'id',
label: '任务ID',
scanBox: null,
table: { width: 90 },
slot: null,
detailLabel: '任务ID'
},
order_id: {
key: 'order_id',
label: '订单ID',
scanBox: { type: 'text', group: SCANBOX_GROUPS.basic },
table: { width: 100 },
slot: null,
detailLabel: '订单ID'
},
waybill_code: {
key: 'waybill_code',
label: '运单号',
scanBox: { type: 'text', group: SCANBOX_GROUPS.basic },
table: { minWidth: 160, showOverflowTooltip: true },
slot: null,
detailLabel: '运单号'
},
wave_no: {
key: 'wave_no',
label: '波次号',
scanBox: { type: 'text', group: SCANBOX_GROUPS.basic },
table: { minWidth: 140, showOverflowTooltip: true },
slot: null,
detailLabel: '波次号'
},
operator_text: {
key: 'operator_text',
label: '打包员',
scanBox: null,
table: { width: 100 },
slot: null,
detailLabel: '打包员'
},
workbench_name: {
key: 'workbench_name',
label: '工作台',
scanBox: null,
table: { width: 120, showOverflowTooltip: true },
slot: null,
detailLabel: '工作台'
},
pack_quantity: {
key: 'pack_quantity',
label: '打包数量',
scanBox: null,
table: { width: 100, align: 'center', sortable: true },
slot: null,
detailLabel: '打包数量'
},
pack_mode: {
key: 'pack_mode',
label: '打包模式',
scanBox: { type: 'select', group: SCANBOX_GROUPS.process, options: getOptions('pack_mode') },
table: { width: 100, align: 'center' },
slot: { type: 'tag', tagResolver: 'resolvePackModeTag', translateField: 'pack_mode' },
detailLabel: '打包模式',
filterParamMap: { '散单': '1', '团购': '2' }
},
status: {
key: 'status',
label: '任务状态',
scanBox: { type: 'select', group: SCANBOX_GROUPS.process, options: getOptions('status') },
table: { width: 100, align: 'center' },
slot: { type: 'tag', tagResolver: 'resolveStatusTag', translateField: 'status' },
detailLabel: '任务状态',
filterParamMap: { '待处理': '0', '打包中': '1', '已完成': '2', '异常': '3' }
},
start_time: {
key: 'start_time',
label: '开始时间',
scanBox: { type: 'daterange', group: SCANBOX_GROUPS.time },
table: { width: 170, sortable: true },
slot: { type: 'text', format: 'datetime' },
detailLabel: '开始时间'
},
end_time: {
key: 'end_time',
label: '结束时间',
scanBox: { type: 'daterange', group: SCANBOX_GROUPS.time },
table: { width: 170, sortable: true },
slot: { type: 'text', format: 'datetime' },
detailLabel: '结束时间'
},
create_time: {
key: 'create_time',
label: '创建时间',
scanBox: { type: 'daterange', group: SCANBOX_GROUPS.time },
table: { width: 170, sortable: true },
slot: { type: 'text', format: 'datetime' },
detailLabel: '创建时间'
},
/** 仓库 — 仅用于 ScanBox 筛选,options 由 index.vue 动态注入 */
warehouse_id: {
key: 'warehouse_id',
label: '仓库',
scanBox: { type: 'select', group: SCANBOX_GROUPS.basic, options: [] },
table: null,
slot: null
},
/** 工作台ID — 仅用于 ScanBox 筛选 */
workbench_id: {
key: 'workbench_id',
label: '工作台ID',
scanBox: { type: 'text', group: SCANBOX_GROUPS.basic },
table: null,
slot: null
},
/** 录像列 — 由 index.vue 自定义插槽渲染 VideoButton */
videos: {
key: 'videos',
label: '录像',
scanBox: null,
table: { width: 110, fixed: 'right', align: 'center' },
slot: null
}
}
// ============================================================
// 三、ColumnSlotConfig — 列单元格渲染配置
// ============================================================
export interface ColumnSlotConfig {
type: 'tag' | 'text' | 'default' | 'operation'
tagType?: string | Record<string, string>
tagResolver?: string
translateField?: string
format?: 'datetime'
}
// ============================================================
// 三-A、OperationButtonConfig — 操作列按钮配置
// ============================================================
export interface OperationButtonConfig {
key: string
label: string
type?: 'primary' | 'success' | 'warning' | 'danger' | 'info' | ''
actionType: 'form' | 'action'
formKey?: string
formTitle?: string
formWidth?: string
paramMap?: Record<string, string>
extraParams?: Record<string, any>
disabledOnField?: string
confirmMessage?: string
confirmTitle?: string
confirmType?: 'warning' | 'danger' | 'info'
confirmButtonText?: string
}
// ============================================================
// 四、DetailFieldConfig / DetailSectionConfig — 明细面板配置
// ============================================================
export interface DetailFieldConfig {
key: string
label?: string
span?: number
renderType?: 'text' | 'tag' | 'pre'
tagType?: string | Record<string, string>
tagResolver?: string
translateField?: string
}
export interface DetailSectionConfig {
title: string
columnCount: number
fields: DetailFieldConfig[]
}
export interface DetailTabConfig {
name: string
label: string
componentKey: string
component?: Component
}
// ============================================================
// 五、TabPageApiConfig — 标签页接口插槽配置
// ============================================================
export type ApiMethod = (...args: any[]) => Promise<any>
export type ApiSource = 'api' | 'list'
export type ComponentApiConfig = { source: 'list' } | ApiMethod
export interface TabPageApiConfig {
/** 列表查询接口 */
list: ApiMethod
/** 明细面板接口(可选,不配则用 row 数据) */
detail?: ComponentApiConfig
/** 操作日志接口(可选) */
log?: ComponentApiConfig
/** 导出接口(可选) */
export?: ApiMethod
/** 导出进度查询接口(可选) */
exportProgress?: ApiMethod
/** ScanBox 下拉选项数据源接口(可选) */
scanBoxOptions?: Record<string, ApiMethod>
/** 工具栏按钮 → API 方法映射(可选) */
toolbar?: Record<string, ApiMethod>
/** 列表响应解析器 */
parseListResponse?: (res: any) => { list: any[]; total: number }
/** 构建列表请求参数 */
buildListParams?: (params: {
pagination: { page: number; pageSize: number }
conditions: Record<string, any>
sort?: { prop: string; order: string }
}) => Record<string, any>
}
// ============================================================
// 六、TabPageRawConfig — 标签页声明配置(仅用 key 引用)
// ============================================================
export interface TabPageRawConfig {
name: string
label: string
scanBoxCacheKey: string
/** ScanBox 需要的字段 key 列表(从 FIELD_DICT 中查找) */
scanBoxFieldKeys: string[]
/** 表格需要的列 key 列表(从 FIELD_DICT 中查找) */
tableColumnKeys: string[]
upperTableDefaults: {
title: string
enableColumnConfig?: boolean
showIndex?: boolean
showSelection?: boolean
emptyText?: string
}
/** 明细面板标签页配置 */
detailTabs?: { name: string; label: string; componentKey: string }[]
/** 明细面板分区配置(字段 key 列表,resolveTabConfig 展开) */
detailSections: {
title: string
columnCount: number
fieldKeys: string[]
}[]
/** 接口配置(有 api 时启用真实接口) */
api?: TabPageApiConfig
/** 操作列按钮配置(需 tableColumnKeys 包含 'operation') */
operationButtons?: OperationButtonConfig[]
}
// ============================================================
// 七、TabPageConfig — 展开后的完整配置(给 index.vue 使用)
// ============================================================
export interface TabPageConfig {
name: string
label: string
scanBoxCacheKey: string
scanBoxFields: Record<string, any>[]
upperTable: {
title: string
enableColumnConfig: boolean
showIndex: boolean
showSelection: boolean
emptyText: string
columns: Record<string, any>[]
}
columnSlots: Record<string, ColumnSlotConfig>
detailConfig: DetailSectionConfig[]
detailTabs: DetailTabConfig[]
api?: TabPageApiConfig
operationButtons?: OperationButtonConfig[]
}
// ============================================================
// 八、resolveTabConfig — 加载时将 RawConfig 展开为完整配置
// ============================================================
export function resolveTabConfig(raw: TabPageRawConfig): TabPageConfig {
// 展开 ScanBox 字段
const scanBoxFields: Record<string, any>[] = []
for (const key of raw.scanBoxFieldKeys) {
const def = FIELD_DICT[key]
if (!def || !def.scanBox) continue
scanBoxFields.push({
label: def.label,
value: def.key,
type: def.scanBox.type,
options: def.scanBox.options ? [...def.scanBox.options] : undefined,
group: def.scanBox.group,
required: (def.scanBox as any).required
})
}
// 展开表格列
const columns: Record<string, any>[] = []
for (const key of raw.tableColumnKeys) {
const def = FIELD_DICT[key]
if (!def || !def.table) continue
columns.push({
prop: def.key,
label: def.label,
...def.table
})
}
// 展开列插槽
const columnSlots: Record<string, ColumnSlotConfig> = {}
for (const key of raw.tableColumnKeys) {
const def = FIELD_DICT[key]
if (!def || !def.slot) continue
columnSlots[def.key] = { ...def.slot }
}
// 展开明细面板配置
const detailConfig: DetailSectionConfig[] = raw.detailSections.map((sec) => ({
title: sec.title,
columnCount: sec.columnCount,
fields: sec.fieldKeys
.map((key): DetailFieldConfig | null => {
const def = FIELD_DICT[key]
if (!def) return null
return {
key: def.key,
label: def.detailLabel ?? def.label,
translateField: def.slot?.translateField,
tagResolver: def.slot?.tagResolver,
tagType: def.slot?.tagType,
renderType: def.slot?.type === 'tag' ? 'tag' : 'text'
}
})
.filter((f): f is DetailFieldConfig => f !== null)
}))
// 展开明细标签页(解析 componentKey → Component)
const detailTabs: DetailTabConfig[] = raw.detailTabs
? raw.detailTabs.map((tab) => ({
name: tab.name,
label: tab.label,
componentKey: tab.componentKey,
component: COMPONENT_REGISTRY[tab.componentKey]
}))
: [{ name: 'detail', label: '明细', componentKey: 'DetailPanel', component: COMPONENT_REGISTRY['DetailPanel'] }]
return {
name: raw.name,
label: raw.label,
scanBoxCacheKey: raw.scanBoxCacheKey,
scanBoxFields,
upperTable: {
title: raw.upperTableDefaults.title,
enableColumnConfig: raw.upperTableDefaults.enableColumnConfig ?? true,
showIndex: raw.upperTableDefaults.showIndex ?? true,
showSelection: raw.upperTableDefaults.showSelection ?? true,
emptyText: raw.upperTableDefaults.emptyText ?? '暂无数据',
columns
},
columnSlots,
detailConfig,
detailTabs,
api: raw.api,
operationButtons: raw.operationButtons
}
}
// ============================================================
// 九、buildWhereConditions — 将 ScanBox 条件转为 API where 参数
// ============================================================
export function buildWhereConditions(rawConditions: Record<string, any>): Record<string, any> {
const where: Record<string, any> = {}
for (const [key, cond] of Object.entries(rawConditions || {})) {
let value: any = undefined
if (cond && typeof cond === 'object' && 'operator' in cond) {
value = (cond as any).value
} else if (cond !== undefined && cond !== null && cond !== '') {
value = Array.isArray(cond) ? cond[0] ?? '' : cond
}
if (value === undefined || value === null || value === '' || (Array.isArray(value) && value.length === 0)) {
continue
}
const def = FIELD_DICT[key]
// daterange 类型:拆分为 key_start / key_end
if (def?.scanBox?.type === 'daterange' && Array.isArray(value) && value.length === 2) {
where[`${key}_start`] = value[0]
where[`${key}_end`] = value[1]
continue
}
// filterParamMap 值映射(如中文 → 数字)
if (def?.filterParamMap) {
const mapped = def.filterParamMap[String(value)]
if (mapped !== undefined) {
where[key] = mapped
continue
}
}
where[key] = value
}
return where
}
// ============================================================
// 十、工具栏按钮系统
// ============================================================
// 按钮分为三类:
// common — 公共按钮(刷新、导出)
// function — 功能按钮(打开表单/确认窗口)
// basic — 基础操作(字段设置、隐藏详情)
export interface ToolbarButtonConfig {
key: string
label: string
category: 'common' | 'function' | 'basic'
size?: '' | 'default' | 'small' | 'large'
type?: '' | 'primary' | 'success' | 'warning' | 'info' | 'danger'
plain?: boolean
loadingKey?: string
disabledKey?: string
action: string
dynamicLabelKey?: string
onlyForTabs?: string[]
buttonType?: 'default' | 'dropdown'
dropdownOptions?: Array<{ label: string; action: string; divided?: boolean }>
formKey?: string
}
export const TOOLBAR_BUTTONS: Record<string, ToolbarButtonConfig> = {
// ===== 公共按钮 =====
refresh: {
key: 'refresh',
label: '刷新',
category: 'common',
type: 'primary',
size: 'small',
loadingKey: 'loading',
action: 'loadData'
},
// ===== 基础操作 =====
columnConfig: {
key: 'columnConfig',
label: '字段设置',
category: 'basic',
size: 'small',
action: 'openColumnConfigPanel'
},
toggleDetail: {
key: 'toggleDetail',
label: '显示详情',
category: 'basic',
dynamicLabelKey: 'detailToggleLabel',
size: 'small',
action: 'toggleDetailVisible'
}
}
/** 按标签页名称获取工具栏按钮列表(自动根据 PAGE_CONFIG 过滤) */
export function getTabToolbarButtons(tabName: string): ToolbarButtonConfig[] {
return Object.values(TOOLBAR_BUTTONS).filter((btn) => {
if (btn.onlyForTabs && !btn.onlyForTabs.includes(tabName)) return false
// 详情面板禁用时,隐藏「显示/隐藏详情」按钮
if (!PAGE_CONFIG.enableDetailPanel && btn.key === 'toggleDetail') return false
return true
})
}
// ============================================================
// 十一、批量操作配置(可选,接入 BatchOperationForm 时使用)
// ============================================================
export interface BatchOperationConfig {
action: string
title: string
confirmText: string
confirmType?: 'warning' | 'error' | 'info' | 'success'
confirmButtonText: string
successText: string
failText: string
apiMethod: (...args: any[]) => Promise<any>
payloadKey?: string
idField?: string | string[]
payloadBuilder?: (rows: Record<string, any>[]) => Record<string, any>
useProgress?: boolean
progressApiMethod?: (...args: any[]) => Promise<any>
}
/** ★ 在此配置批量操作 */
export const BATCH_OPERATION_CONFIGS: Record<string, BatchOperationConfig> = {
// batchExample: {
// action: 'batchExample',
// title: '批量操作示例',
// confirmText: '确定对选中的 {count} 项执行操作吗?',
// confirmType: 'warning',
// confirmButtonText: '确认操作',
// successText: '批量操作成功',
// failText: '批量操作失败',
// apiMethod: yourBatchApi,
// payloadKey: 'ids',
// idField: 'id'
// }
}
// ============================================================
// 十二、标签页注册表 — 打包流水(单页模式)
// ============================================================
export const tabPages: TabPageRawConfig[] = [
{
name: 'packing',
label: '打包任务',
scanBoxCacheKey: 'packingflow-list',
scanBoxFieldKeys: [
'warehouse_id', 'waybill_code', 'wave_no', 'order_id', 'workbench_id',
'status', 'pack_mode',
'start_time'
],
tableColumnKeys: [
'id', 'order_id', 'waybill_code', 'wave_no', 'operator_text',
'workbench_name', 'pack_quantity', 'pack_mode', 'status',
'start_time', 'end_time', 'create_time', 'videos'
],
upperTableDefaults: {
title: '打包任务列表',
showIndex: true,
showSelection: false,
emptyText: '暂无打包任务数据'
},
detailTabs: [
{ name: 'detail', label: '任务明细', componentKey: 'DetailPanel' }
],
detailSections: [
{
title: '基础信息',
columnCount: 2,
fieldKeys: ['id', 'order_id', 'wave_no', 'waybill_code', 'operator_text', 'workbench_name', 'pack_quantity', 'pack_mode', 'status']
},
{
title: '时间信息',
columnCount: 2,
fieldKeys: ['start_time', 'end_time', 'create_time']
}
],
api: {
list: packingList as ApiMethod,
detail: packingGet as ApiMethod,
parseListResponse(res: any) {
const codeOk = [200, 20000, 1, 0].includes(res.code)
if (!codeOk) throw new Error(res.message || '查询失败')
const list = (res.data?.list ?? []).map((item: any) => ({
...item,
waybill_code: extractWaybillCode(item)
}))
return {
list,
total: res.data?.pagination?.total ?? 0
}
},
buildListParams({ pagination, conditions, sort }) {
// warehouse_id 提到顶层,其余进入 where
const { warehouse_id, ...rest } = buildWhereConditions(conditions)
return {
warehouse_id: warehouse_id || undefined,
pagination: { page: pagination.page, pageSize: pagination.pageSize },
where: rest,
sort: sort?.prop
? { sortField: sort.prop, sortOrder: sort.order === 'ascending' ? 'ASC' : 'DESC' }
: { sortField: 'create_time', sortOrder: 'DESC' }
}
}
}
}
]
// ============================================================
// 十三、工具函数
// ============================================================
/**
* 从 API 返回数据中提取运单号
* 优先取顶层 waybill_code,若为空则从 expresses 数组中拼接
*/
export function extractWaybillCode(row: any): string | null {
if (row.waybill_code) return row.waybill_code
if (row.expresses?.length) {
return row.expresses
.map((e: any) => e.waybill_code)
.filter(Boolean)
.join(',')
}
return null
}
// ============================================================
// 十四、向后兼容导出
// ============================================================
export const templateTabs = tabPages.map((t) => ({ name: t.name, label: t.label, scanBoxCacheKey: t.scanBoxCacheKey }))

View File

@ -6,7 +6,7 @@
===== 快速复制使用 =====
1. 复制整个 views/mode/ 文件夹 → 重命名为你的页面名(如 views/order/myPage/)
2. 修改 defineOptions name(如 'MyPage')
3. 编辑 config/template-config.ts:
3. 编辑 config/packingflow-config.ts:
a. 在 FIELD_DICT 中添加页面字段
b. 在 tabPages 中配置标签页(引用 FIELD_DICT 的 key)
c. 在 TabPageApiConfig 中接入真实接口
@ -125,6 +125,11 @@
/>
</template>
<!-- 录像列自定义渲染 -->
<template #column-videos="{ row }">
<VideoButton :videos="row.videos || []" @click="openVideoList(row)" />
</template>
<template #empty>
<div class="empty-tip">{{ currentTabConfig?.upperTable.emptyText ?? '暂无数据' }}</div>
</template>
@ -216,6 +221,11 @@
/>
</template>
<!-- 录像列自定义渲染 -->
<template #column-videos="{ row }">
<VideoButton :videos="row.videos || []" @click="openVideoList(row)" />
</template>
<template #empty>
<div class="empty-tip">{{ currentTabConfig?.upperTable.emptyText ?? '暂无数据' }}</div>
</template>
@ -228,13 +238,16 @@
</div>
</div>
<!-- ===== 功能按钮表单(pages/ 目录下的组件) ===== -->
<!-- ★ 在此添加表单弹窗组件,如:
<YourFormDialog
v-model:visible="yourFormVisible"
@success="handleFormSuccess"
<!-- ===== 录像弹窗 ===== -->
<VideoListDialog
v-model:visible="videoListVisible"
:videos="currentVideos"
@play="handlePlayVideo"
/>
<VideoPlayerDialog
v-model:visible="playerVisible"
:video="playingVideo"
/>
-->
</div>
</template>
@ -242,12 +255,13 @@
// ============================================================
// ★★★ 第一步:修改组件名 ★★★
// ============================================================
defineOptions({ name: 'PageTemplate' })
defineOptions({ name: 'PackingFlow' })
import { ref, computed, onMounted, reactive } from 'vue'
import { ElMessage } from 'element-plus'
import { useSettingsStore } from '@/stores/modules/settings'
import { useVerticalSplitPane } from '@/composables/useVerticalSplitPane'
import { loadWarehouses } from '@/api/index/index'
import ScanBox from '@/components/ScanBox/index.vue'
import UpperTable from '@/components/UpperTable/index.vue'
import TabArea from './components/TabArea.vue'
@ -263,7 +277,11 @@ import {
type TabPageConfig,
type DetailTabConfig,
type ToolbarButtonConfig,
} from './config/template-config'
} from './config/packingflow-config'
import { extractWaybillCode } from './config/packingflow-config'
import VideoButton, { type VideoItem } from './components/VideoButton.vue'
import VideoListDialog from './components/VideoListDialog.vue'
import VideoPlayerDialog from './components/VideoPlayerDialog.vue'
// ============================================================
// 容器高度
@ -294,10 +312,19 @@ const currentScanBoxCacheKey = computed(
() => currentTabConfig.value?.scanBoxCacheKey ?? 'template-default'
)
/** 当前 ScanBox 筛选字段 */
const currentScanBoxFields = computed(
() => currentTabConfig.value?.scanBoxFields ?? []
)
/** 当前 ScanBox 筛选字段(动态注入仓库选项) */
const warehouseOptions = ref<{ label: string; value: any }[]>([])
const currentScanBoxFields = computed(() => {
const fields = currentTabConfig.value?.scanBoxFields ?? []
if (warehouseOptions.value.length === 0) return fields
return fields.map((f: any) => {
if (f.value === 'warehouse_id') {
return { ...f, options: warehouseOptions.value }
}
return f
})
})
/** 当前表格列 */
const currentColumns = computed(
@ -334,11 +361,12 @@ const currentDetailTabApiMethod = computed(() => {
const tab = currentDetailTabs.value.find((t) => t.name === activeDetailTab.value)
if (!tab) return undefined
// DetailPanel 的数据由 handleRowClick 获取并预处理(如 extractWaybillCode),
// 此处不传 apiMethod,避免 DetailPanel 内部重复请求覆盖已处理的数据
let componentCfg: unknown
switch (tab.componentKey) {
case 'DetailPanel':
componentCfg = cfg.api.detail
break
return undefined
case 'LogPanel':
componentCfg = cfg.api.log
break
@ -416,9 +444,7 @@ function resolveButtonLabel(defaultLabel: string, dynamicLabelKey?: string) {
const toolbarActionMap: Record<string, () => void> = {
loadData: () => { void loadData() },
openColumnConfigPanel: () => { upperTableRef.value?.openColumnConfig?.() },
toggleDetailVisible: () => { detailVisible.value = !detailVisible.value },
handleExport: () => { console.log('[PageTemplate] 导出(不含明细)', activeTabName.value) },
handleExportItem: () => { console.log('[PageTemplate] 导出(含明细)', activeTabName.value) }
toggleDetailVisible: () => { detailVisible.value = !detailVisible.value }
}
function handleToolbarButtonClick(action: string) {
@ -578,9 +604,11 @@ const handleRowClick = async (row: Record<string, any>) => {
const detailCfg = cfg.api?.detail
if (typeof detailCfg === 'function') {
try {
const detailRes = await detailCfg({ id: row.id, code: row.code })
if (detailRes && (detailRes.code === 1 || detailRes.code === 200)) {
selectedDetail.value = detailRes.data ?? detailRes
const detailRes = await detailCfg(row.id)
if (detailRes && (detailRes.code === 1 || detailRes.code === 200 || detailRes.code === 20000)) {
const rawData = detailRes.data ?? detailRes
rawData.waybill_code = extractWaybillCode(rawData)
selectedDetail.value = rawData
} else {
selectedDetail.value = { ...row }
}
@ -621,17 +649,56 @@ const upperPaneFullStyle = computed(() => ({
overflow: 'hidden' as const
}))
// ============================================================
// 录像相关
// ============================================================
const videoListVisible = ref(false)
const playerVisible = ref(false)
const currentVideos = ref<VideoItem[]>([])
const playingVideo = ref<VideoItem | null>(null)
function openVideoList(row: Record<string, any>) {
currentVideos.value = (row.videos as VideoItem[]) || []
if (currentVideos.value.length === 0) return
videoListVisible.value = true
}
function handlePlayVideo(video: VideoItem) {
videoListVisible.value = false
playingVideo.value = video
playerVisible.value = true
}
// ============================================================
// 初始化
// ============================================================
onMounted(() => {
/** 加载仓库列表,注入到 ScanBox 的 warehouse_id 选项中 */
async function loadWarehouseOptions() {
try {
const res: any = await loadWarehouses()
const raw = res?.warehouses || res?.data?.list || res?.data || []
warehouseOptions.value = raw.map((item: any) => ({
label: item.label || item.warehouse_name || item.company_name || String(item.value ?? ''),
value: item.value ?? item.warehouse_id ?? item.id
}))
} catch {
// 仓库列表加载失败不影响主流程
}
}
onMounted(async () => {
await loadWarehouseOptions()
loadData()
})
</script>
<style lang="scss" scoped>
/* ===== 引入共享样式(scan-box / toolbar / split-stack / pane-resizer / lower-level 等) ===== */
@use "../../order/orderManagement/styles/order-sub.scss";
/* ================================================================
整体布局
整体布局容器
================================================================ */
.page-wrapper {
position: relative;
@ -642,7 +709,7 @@ onMounted(() => {
}
/* ================================================================
1. 顶部多标签页
1. 顶部多标签页区域
================================================================ */
.tab-section {
flex-shrink: 0;
@ -655,7 +722,7 @@ onMounted(() => {
}
/* ================================================================
2. 主内容区
2. 主内容区容器
================================================================ */
.main-container {
flex: 1;
@ -669,26 +736,62 @@ onMounted(() => {
overflow: hidden;
}
.order-sub-container {
display: flex;
height: 100%;
width: 100%;
background-color: #f0f2f5;
:deep(.scan-box-container) {
flex: 0 0 250px;
/* ================================================================
3. ScanBox "筛选/过滤" 标签样式(对齐页面顶部 TabArea 风格)
================================================================ */
.main-container {
:deep(.scan-box-container .scan-tabs) {
flex-shrink: 0;
height: 100%;
border-bottom: 1px solid #e8eef7;
background: #f8fbff;
}
:deep(.scan-box-container .scan-tabs .el-tabs__header) {
margin: 0;
padding: 4px 8px 0;
}
:deep(.scan-box-container .scan-tabs .el-tabs__nav-wrap::after) {
display: none;
}
:deep(.scan-box-container .scan-tabs .el-tabs__active-bar) {
display: none;
}
:deep(.scan-box-container .scan-tabs .el-tabs__item) {
height: 38px;
line-height: 38px;
font-size: 14px;
font-weight: 500;
padding: 0 20px;
color: #606266;
border: 1px solid transparent;
border-bottom: none;
border-radius: 6px 6px 0 0;
transition: all 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);
margin-right: 4px;
}
:deep(.scan-box-container .scan-tabs .el-tabs__item:hover) {
color: #409eff;
background-color: rgba(64, 158, 255, 0.05);
}
:deep(.scan-box-container .scan-tabs .el-tabs__item.is-active) {
color: #409eff;
font-weight: 600;
background: #ffffff;
border-color: #e8eef7;
border-bottom-color: #fff;
}
}
/* ================================================================
补充:过渡动画
================================================================ */
.main-content {
flex: 1;
display: flex;
flex-direction: column;
padding: 10px;
overflow: hidden;
min-width: 0;
position: relative;
}
.tab-content-inner {
@ -698,114 +801,43 @@ onMounted(() => {
min-height: 0;
}
/* ================================================================
3. 工具栏
================================================================ */
.toolbar {
margin-bottom: 3px;
padding: 6px 10px;
border: 1px solid #ebeef5;
display: flex;
justify-content: space-between;
align-items: center;
background-color: #fff;
min-width: 0;
overflow: hidden;
/* fade + slide 混合过渡 */
.tab-fade-enter-active,
.tab-fade-leave-active {
transition: opacity 0.2s ease, transform 0.2s ease;
}
.toolbar-left {
flex: 1;
min-width: 0;
display: flex;
align-items: center;
gap: 10px;
overflow: hidden;
}
.tab-fade-enter-from {
opacity: 0;
transform: translateY(8px);
}
.toolbar-right {
flex: 0 0 auto;
margin-left: 10px;
display: flex;
align-items: center;
justify-content: flex-end;
gap: 10px;
}
.tab-fade-leave-to {
opacity: 0;
transform: translateY(-8px);
}
.tab-fade-leave-active {
position: absolute;
width: 100%;
}
/* ================================================================
4. 分栏区域
无选中行时的占位(与 waveOrder2 保持一致)
================================================================ */
.split-stack {
flex: 1;
display: flex;
flex-direction: column;
min-height: 0;
overflow: hidden;
:deep(.el-card__header) {
padding: 2px 12px;
font-size: 13px;
}
}
.upper-wrapper {
flex: 1 1 62%;
min-height: 0;
overflow: hidden;
}
/* 详情面板禁用时,表格占满全高 */
.upper-wrapper--full {
flex: 1 1 auto;
min-height: 0;
overflow: hidden;
}
.pane-resizer {
flex-shrink: 0;
height: 5px;
cursor: row-resize;
background-color: #f0f2f5;
border-top: 1px solid #ebeef5;
border-bottom: 1px solid #ebeef5;
transition: background-color 0.2s;
user-select: none;
&:hover {
background-color: #d3d9e3;
}
}
.lower-level {
flex: 1 1 38%;
min-height: 0;
overflow: hidden;
display: flex;
flex-direction: column;
:deep(.el-card) {
height: 100%;
display: flex;
flex-direction: column;
}
}
.no-selection {
flex: 1 1 38%;
min-height: 0;
flex: 0 0 38%;
height: 38%;
display: flex;
align-items: center;
justify-content: center;
border: 1px solid #ebeef5;
border-radius: 4px;
.empty-tip p {
font-size: 14px;
color: #909399;
}
border-top: 1px solid #ebeef5;
overflow: hidden;
background-color: #fff;
}
/* ================================================================
5. 明细面板
明细面板
================================================================ */
.detail-header {
flex-shrink: 0;
@ -831,24 +863,17 @@ onMounted(() => {
}
/* ================================================================
6. 过渡动画
================================================================ */
.tab-fade-enter-active,
.tab-fade-leave-active {
transition: opacity 0.2s ease;
opacity: 1;
}
.tab-fade-enter-from,
.tab-fade-leave-to {
opacity: 0;
}
/* ================================================================
7. 空状态
空提示样式
================================================================ */
.empty-tip {
text-align: center;
font-size: 13px;
color: #909399;
line-height: 1.5;
}
.empty-tip p {
font-size: 14px;
color: #909399;
}
</style>

View File

@ -27,10 +27,7 @@
>
批量删除
</el-button>
<!-- <el-tag size="small" type="info">共 {{ pagination.total }} 条</el-tag> -->
</div>
<div class="toolbar-right">
<el-button size="small" type="primary" plain @click="searchFormVisible = true">快速搜索</el-button>
<!-- <el-button size="small" type="primary" plain @click="searchFormVisible = true">快速搜索</el-button> -->
<el-button type="success" size="small" @click="openCreate">新增包材</el-button>
<el-button type="warning" size="small" plain @click="openBatchImport">批量导入</el-button>
</div>

View File

@ -32,6 +32,7 @@ export const packageMaterialScanFields = [
value: 'quickWhere',
label: '关键词',
type: 'text',
group: '基础信息',
placeholder: '编码/名称/类型',
operators: ['eq','contains'],
defaultOperator: 'eq'
@ -40,6 +41,7 @@ export const packageMaterialScanFields = [
value: 'material_code',
label: '包材编码',
type: 'text',
group: '基础信息',
placeholder: '请输入包材编码',
operators: ['eq', 'contains', 'like'],
defaultOperator: 'eq'
@ -48,6 +50,7 @@ export const packageMaterialScanFields = [
value: 'material_name',
label: '包材名称',
type: 'text',
group: '基础信息',
placeholder: '请输入包材名称',
operators: ['eq', 'contains', 'like'],
defaultOperator: 'eq'
@ -56,6 +59,7 @@ export const packageMaterialScanFields = [
value: 'material_type',
label: '包材类型',
type: 'text',
group: '基础信息',
placeholder: '请输入包材类型',
operators: ['eq', 'contains', 'like'],
defaultOperator: 'eq'
@ -64,6 +68,7 @@ export const packageMaterialScanFields = [
value: 'status',
label: '状态',
type: 'select',
group: '其他筛选',
clearable: true,
options: [
{ label: '启用', value: '1' },
@ -74,6 +79,7 @@ export const packageMaterialScanFields = [
value: 'id',
label: 'ID',
type: 'number',
group: '其他筛选',
placeholder: '包材 ID',
operators: ['eq', 'ne'],
defaultOperator: 'eq'

View File

@ -0,0 +1,65 @@
<!--
ColumnCellRenderer — 通用表格列渲染器
根据传入的 ColumnSlotConfig 决定如何渲染单元格:
- type='tag' → el-tag(支持 tagResolver / tagType 颜色映射)
- type='text' → 纯文本(支持 datetime 格式化)
- type='default' → 默认插槽渲染
- type='operation' → 操作列(由 OperationCellRenderer 处理)
-->
<template>
<template v-if="!config || config.type === 'default'">
<slot />
</template>
<template v-else-if="config.type === 'tag'">
<el-tag size="small" :type="resolvedTagType">
{{ displayValue }}
</el-tag>
</template>
<template v-else>
<span>{{ displayValue }}</span>
</template>
</template>
<script setup lang="ts">
import { computed } from 'vue'
import type { ColumnSlotConfig } from '../config/template-config'
import { TAG_RESOLVERS, translate, formatTime } from '../config/template-config'
defineOptions({ name: 'ColumnCellRenderer' })
const props = defineProps<{
/** 列插槽渲染配置 */
config: ColumnSlotConfig | undefined
/** 单元格值 */
value: any
}>()
/** 显示文本:translateField 翻译 > format 格式化 > 原始值 */
const displayValue = computed(() => {
const v = props.value
if (props.config?.translateField) {
return translate(props.config.translateField, v)
}
if (props.config?.format === 'datetime') {
return formatTime(v)
}
return v ?? '—'
})
const resolvedTagType = computed(() => {
if (!props.config || props.config.type !== 'tag') return ''
const { tagType, tagResolver } = props.config
// 优先使用 tagResolver(函数名映射)
if (tagResolver && TAG_RESOLVERS[tagResolver]) {
return TAG_RESOLVERS[tagResolver](props.value)
}
// 其次使用 tagType 映射表(用原始值查找)
if (tagType && typeof tagType === 'object') {
return tagType[String(props.value)] ?? 'info'
}
// 最后使用固定值
return (typeof tagType === 'string' ? tagType : 'info')
})
</script>

View File

@ -0,0 +1,175 @@
<!--
OperationCellRenderer — 表格操作列渲染组件
根据 operationButtons 配置渲染按钮列表。
支持的行为类型:
- actionType='action' → 触发 @operation-action 事件(可选配置 confirmMessage 弹确认框)
- actionType='form' → 打开 COMPONENT_REGISTRY 中注册的表单组件
使用方式:在 index.vue 中通过插槽 column-operation 引入:
<OperationCellRenderer
:buttons="currentTabConfig?.operationButtons"
:row="row"
@operation-action="handleOperationAction"
/>
-->
<template>
<div class="operation-cell">
<template v-for="btn in buttons" :key="btn.key">
<!-- action 按钮:支持确认弹窗 -->
<el-button
v-if="btn.actionType === 'action'"
link
:type="btn.type || 'primary'"
size="small"
:loading="actionLoadingMap[btn.key]"
:disabled="isDisabled(btn)"
@click.stop="handleActionClick(btn)"
>
{{ btn.label }}
</el-button>
<!-- form 按钮:打开表单弹窗 -->
<template v-else-if="btn.actionType === 'form'">
<el-button
link
:type="btn.type || 'primary'"
size="small"
:disabled="isDisabled(btn)"
@click.stop="openForm(btn)"
>
{{ btn.label }}
</el-button>
<!-- 表单弹窗 -->
<component
:is="resolvedFormComponents[btn.key]"
v-if="resolvedFormComponents[btn.key] && activeFormKey === btn.key"
v-model:visible="formVisibleMap[btn.key]"
v-bind="buildFormProps(btn)"
@success="handleFormSuccess(btn.key)"
/>
</template>
</template>
</div>
</template>
<script setup lang="ts">
import { ref, reactive, type Component } from 'vue'
import { ElMessageBox } from 'element-plus'
import { COMPONENT_REGISTRY } from '../config/template-config'
import type { OperationButtonConfig } from '../config/template-config'
defineOptions({ name: 'OperationCellRenderer' })
const props = defineProps<{
/** 操作按钮配置列表(来自 TabPageConfig.operationButtons) */
buttons?: OperationButtonConfig[]
/** 当前行数据 */
row: Record<string, any>
}>()
const emit = defineEmits<{
/** action 按钮点击事件(key: 按钮标识, row: 行数据) */
(e: 'operation-action', key: string, row: Record<string, any>): void
}>()
// ===== form 弹窗管理 =====
const activeFormKey = ref('')
const formVisibleMap = reactive<Record<string, boolean>>({})
const resolvedFormComponents = ref<Record<string, Component>>({})
const actionLoadingMap = reactive<Record<string, boolean>>({})
// ============================================================
// action 按钮:支持确认弹窗
// ============================================================
async function handleActionClick(btn: OperationButtonConfig) {
if (btn.confirmMessage) {
try {
await ElMessageBox.confirm(
btn.confirmMessage,
btn.confirmTitle || '确认操作',
{
confirmButtonText: btn.confirmButtonText || '确定',
cancelButtonText: '取消',
type: (btn.confirmType || 'warning') as any
}
)
} catch {
return // 取消
}
}
actionLoadingMap[btn.key] = true
try {
emit('operation-action', btn.key, props.row)
} finally {
actionLoadingMap[btn.key] = false
}
}
// ============================================================
// form 按钮:打开表单弹窗
// ============================================================
function openForm(btn: OperationButtonConfig) {
if (!btn.formKey) return
const comp = COMPONENT_REGISTRY[btn.formKey]
if (!comp) {
console.warn(`[OperationCellRenderer] 未注册的表单组件: ${btn.formKey}`)
return
}
activeFormKey.value = btn.key
resolvedFormComponents.value[btn.key] = comp
formVisibleMap[btn.key] = true
}
function buildFormProps(btn: OperationButtonConfig): Record<string, any> {
const props: Record<string, any> = {}
// paramMap: { formProp: rowField } → 从行数据取值注入表单
if (btn.paramMap) {
for (const [formProp, rowField] of Object.entries(btn.paramMap)) {
props[formProp] = props.row[rowField]
}
}
// extraParams: 固定参数直接注入
if (btn.extraParams) {
Object.assign(props, btn.extraParams)
}
return props
}
function handleFormSuccess(key: string) {
emit('operation-action', key, props.row)
}
// ============================================================
// 按钮禁用判断
// ============================================================
function isDisabled(btn: OperationButtonConfig): boolean {
if (btn.disabledOnField) {
const val = props.row[btn.disabledOnField]
if (val === undefined || val === null || val === '' || val === false) {
return true
}
}
return false
}
</script>
<style lang="scss" scoped>
.operation-cell {
display: flex;
flex-wrap: wrap;
gap: 2px;
justify-content: center;
}
</style>

View File

@ -0,0 +1,132 @@
<template>
<div class="tab-area-wrapper">
<el-tabs
v-model="activeTab"
tab-position="top"
type="border-card"
class="tab-container"
@tab-click="handleTabClick"
>
<el-tab-pane
v-for="tab in tabs"
:key="tab.name"
:name="tab.name"
:lazy="false"
>
<template #label>
<span class="custom-tab-label">{{ tab.label }}</span>
</template>
</el-tab-pane>
</el-tabs>
</div>
</template>
<script setup lang="ts">
import { ref } from 'vue'
defineOptions({ name: 'TabArea' })
interface TabItem {
name: string
label: string
}
const props = withDefaults(
defineProps<{
tabs?: TabItem[]
defaultActive?: string
}>(),
{
tabs: () => [],
defaultActive: ''
}
)
const emit = defineEmits<{
(e: 'tab-change', tabName: string): void
}>()
const activeTab = ref(props.defaultActive || props.tabs[0]?.name || '')
const handleTabClick = (pane: any) => {
const name = pane?.name ?? pane?.props?.name ?? ''
if (name) {
activeTab.value = name
emit('tab-change', name)
}
}
</script>
<style lang="scss" scoped>
.tab-area-wrapper {
flex-shrink: 0;
}
.tab-container {
display: flex;
flex-direction: column;
:deep(.el-tabs__header) {
margin-bottom: 0;
flex-shrink: 0;
}
:deep(.el-tabs__header.is-top) {
padding: 4px 12px 0;
background: #f8fbff;
border-bottom: 1px solid #e8eef7;
margin: 0;
}
:deep(.el-tabs__nav-wrap::after) {
display: none;
}
:deep(.el-tabs__item.is-top) {
height: 38px;
line-height: 38px;
padding: 0 20px;
border-radius: 6px 6px 0 0;
color: #606266;
font-size: 14px;
font-weight: 500;
transition: all 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);
border: 1px solid transparent;
border-bottom: none;
margin-right: 4px;
}
:deep(.el-tabs__item.is-top:hover) {
color: #409eff;
background-color: rgba(64, 158, 255, 0.05);
}
:deep(.el-tabs__item.is-top.is-active) {
color: #409eff;
font-weight: 600;
background: #ffffff;
border-color: #e8eef7;
border-bottom: 2px solid #ffffff;
margin-bottom: -1px;
position: relative;
z-index: 1;
}
:deep(.el-tabs__active-bar) {
height: 2px;
border-radius: 2px;
background-color: #409eff;
bottom: 0;
}
:deep(.el-tabs__content) {
display: none;
}
}
.custom-tab-label {
display: inline-flex;
align-items: center;
gap: 6px;
}
</style>

View File

@ -0,0 +1,159 @@
<!--
DetailPanel — 明细面板(通用)
根据 detailConfig 配置的 sections 渲染 el-descriptions 分区。
支持 text、tag、pre 三种渲染类型。
支持 translateField + tagResolver 集中式翻译。
支持 apiMethod 自动获取详情数据。
-->
<template>
<div class="detail-panel">
<div v-if="!row" class="empty-tip">请从上方列表中选择一项查看明细</div>
<template v-else>
<div v-for="(section, si) in detailConfig" :key="si" class="section">
<div class="section-title">{{ section.title }}</div>
<el-descriptions :column="section.columnCount" border size="small" class="detail-descriptions">
<el-descriptions-item
v-for="(field, fi) in section.fields"
:key="fi"
:label="field.label"
:span="field.span ?? 1"
>
<!-- tag 渲染 -->
<template v-if="field.renderType === 'tag'">
<el-tag size="small" :type="resolveTagType(field, getRowData()?.[field.key])">
{{ resolveDisplayValue(field, getRowData()?.[field.key]) }}
</el-tag>
</template>
<!-- pre 渲染 -->
<template v-else-if="field.renderType === 'pre'">
<pre class="order-list-pre">{{ getRowData()?.[field.key] ?? '—' }}</pre>
</template>
<!-- 默认文本渲染 -->
<template v-else>
{{ resolveDisplayValue(field, getRowData()?.[field.key]) }}
</template>
</el-descriptions-item>
</el-descriptions>
</div>
</template>
</div>
</template>
<script setup lang="ts">
import { ref, watch } from 'vue'
import { TAG_RESOLVERS, translate } from '../template-config'
import type { DetailSectionConfig, DetailFieldConfig } from '../template-config'
defineOptions({ name: 'DetailPanel' })
const props = defineProps<{
row: Record<string, any> | null
detailConfig: DetailSectionConfig[]
/** 可选的 detail API 方法,传入后自动调用获取完整明细数据 */
apiMethod?: (...args: any[]) => Promise<any>
}>()
/** 通过 API 获取的增强数据(与 row 合并) */
const enrichedData = ref<Record<string, any> | null>(null)
watch(() => props.row, async (newRow) => {
if (newRow && props.apiMethod) {
try {
const res = await props.apiMethod({
id: newRow.id,
code: newRow.code
})
if (res && (res.code === 1 || res.code === 200)) {
enrichedData.value = res.data ?? res
} else {
enrichedData.value = null
}
} catch {
enrichedData.value = null
}
} else {
enrichedData.value = null
}
}, { immediate: true })
/** 合并 row + API 增强数据 */
function getRowData(): Record<string, any> | null {
if (!props.row) return null
if (enrichedData.value) {
return { ...props.row, ...enrichedData.value }
}
return props.row
}
/** 解析显示值:优先使用 translateField 翻译,否则显示原始值 */
function resolveDisplayValue(field: DetailFieldConfig, value: any): string {
if (field.translateField) {
return translate(field.translateField, value)
}
return value ?? '—'
}
/** 解析 tag 颜色 */
function resolveTagType(field: DetailFieldConfig, value: any): string {
if (field.tagResolver) {
const resolver = TAG_RESOLVERS[field.tagResolver]
if (resolver) return resolver(value)
}
if (field.tagType) {
if (typeof field.tagType === 'object') {
return field.tagType[String(value)] ?? 'info'
}
return field.tagType
}
return 'info'
}
</script>
<style lang="scss" scoped>
.detail-panel {
padding: 8px 0;
}
.empty-tip {
text-align: center;
font-size: 13px;
color: #909399;
padding: 40px 0;
}
.section {
margin-bottom: 12px;
&:last-child {
margin-bottom: 0;
}
.section-title {
font-size: 14px;
font-weight: 600;
color: #303133;
margin-bottom: 10px;
padding-left: 8px;
border-left: 3px solid #409eff;
line-height: 1.4;
}
}
.detail-descriptions {
:deep(.el-descriptions__label) {
width: 120px;
background: #fafbfc;
font-weight: 500;
}
}
.order-list-pre {
margin: 0;
font-family: inherit;
font-size: 13px;
line-height: 1.8;
white-space: pre-wrap;
color: #606266;
}
</style>

View File

@ -0,0 +1,227 @@
<!--
LogPanel — 操作日志面板(通用)
支持两种数据来源:
- apiMethod 传入 → 调用真实接口获取日志
- 无 apiMethod → 基于 row 生成模拟日志(开发调试用)
-->
<template>
<div class="log-panel">
<div class="section-title">操作日志</div>
<div v-if="apiLoading" v-loading="true" class="empty-tip">加载中…</div>
<div v-else-if="!logs.length" class="empty-tip">暂无操作日志</div>
<div v-else class="log-timeline">
<div v-for="(log, i) in logs" :key="i" class="log-item">
<div class="log-dot" :class="log.level" />
<div class="log-content">
<div class="log-header">
<span class="log-operator">{{ log.operator }}</span>
<span class="log-action">{{ log.action }}</span>
<el-tag v-if="log.result === '成功'" size="small" type="success">成功</el-tag>
<el-tag v-else-if="log.result === '失败'" size="small" type="danger">失败</el-tag>
<el-tag v-else size="small" type="info">{{ log.result }}</el-tag>
</div>
<div v-if="log.detail" class="log-detail">{{ log.detail }}</div>
<div class="log-time">{{ log.time }}</div>
</div>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { computed, ref, watch } from 'vue'
defineOptions({ name: 'LogPanel' })
interface LogItem {
operator: string
action: string
result: string
detail?: string
time: string
level: 'success' | 'info' | 'warning' | 'error'
}
const props = defineProps<{
/** 当前选中行数据(用于生成关联日志) */
row: Record<string, any> | null
/** 可选的日志 API 方法,传入后自动调用获取真实日志 */
apiMethod?: (...args: any[]) => Promise<any>
}>()
/** 通过 API 获取的真实日志列表 */
const apiLogs = ref<LogItem[] | null>(null)
const apiLoading = ref(false)
watch(() => props.row, async (newRow) => {
if (newRow && props.apiMethod) {
apiLoading.value = true
try {
const res = await props.apiMethod({
id: newRow.id,
code: newRow.code,
page: 1,
pageSize: 100
})
if (res && (res.code === 1 || res.code === 200)) {
const list = res.data?.list ?? res.data?.logs ?? res.list ?? res.logs ?? []
apiLogs.value = Array.isArray(list) ? list.map((item: any) => ({
operator: item.operator ?? item.creator ?? '—',
action: item.action ?? item.operation ?? '—',
result: item.result ?? item.status ?? '—',
detail: item.detail ?? item.description ?? '',
time: item.time ?? item.create_time ?? '—',
level: (item.result === '成功' || item.status === 'success') ? 'success'
: (item.result === '失败' || item.status === 'error') ? 'error'
: 'info'
})) : []
} else {
apiLogs.value = []
}
} catch {
apiLogs.value = []
} finally {
apiLoading.value = false
}
} else {
apiLogs.value = null
}
}, { immediate: true })
/** 基于 row 生成模拟日志(无 apiMethod 时使用) */
const mockLogs = computed<LogItem[]>(() => {
if (!props.row) return []
const rowName = props.row.name ?? props.row.code ?? '—'
const now = new Date()
const pad = (n: number) => String(n).padStart(2, '0')
const fmt = (d: Date) =>
`${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())} ${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}`
return [
{
operator: '系统',
action: `创建了「${rowName}」`,
result: '成功',
time: fmt(new Date(now.getTime() - 3600000 * 3)),
level: 'success'
},
{
operator: props.row.creator ?? '管理员',
action: `更新了「${rowName}」`,
result: '成功',
detail: `修改了状态和相关配置`,
time: fmt(new Date(now.getTime() - 3600000)),
level: 'success'
}
]
})
/** 最终展示的日志:优先使用 API 日志,否则使用 mock 日志 */
const logs = computed<LogItem[]>(() => {
if (apiLogs.value !== null) {
return apiLogs.value
}
return mockLogs.value
})
</script>
<style lang="scss" scoped>
.log-panel {
padding: 8px 0;
}
.empty-tip {
text-align: center;
font-size: 13px;
color: #909399;
padding: 40px 0;
}
.section-title {
font-size: 14px;
font-weight: 600;
color: #303133;
margin-bottom: 12px;
padding-left: 4px;
border-left: 3px solid #409eff;
}
.log-timeline {
padding-left: 8px;
.log-item {
display: flex;
gap: 12px;
margin-bottom: 12px;
padding-bottom: 8px;
border-bottom: 1px dashed #ebeef5;
&:last-child {
border-bottom: none;
margin-bottom: 0;
}
}
.log-dot {
flex-shrink: 0;
width: 8px;
height: 8px;
margin-top: 6px;
border-radius: 50%;
background: #c0c4cc;
&.success {
background: #67c23a;
}
&.warning {
background: #e6a23c;
}
&.error {
background: #f56c6c;
}
&.info {
background: #409eff;
}
}
.log-content {
flex: 1;
min-width: 0;
}
.log-header {
display: flex;
align-items: center;
gap: 8px;
flex-wrap: wrap;
}
.log-operator {
font-weight: 600;
font-size: 13px;
color: #303133;
}
.log-action {
font-size: 13px;
color: #606266;
}
.log-detail {
margin-top: 4px;
font-size: 12px;
color: #909399;
}
.log-time {
margin-top: 2px;
font-size: 12px;
color: #c0c4cc;
}
}
</style>

View File

@ -0,0 +1,854 @@
<!--
╔══════════════════════════════════════════════════════════════╗
║ 【页面模板 v2】— 基于 waveOrder2 架构设计 ║
╚══════════════════════════════════════════════════════════════╝
===== 快速复制使用 =====
1. 复制整个 views/mode/ 文件夹 → 重命名为你的页面名(如 views/order/myPage/)
2. 修改 defineOptions name(如 'MyPage')
3. 编辑 config/template-config.ts:
a. 在 FIELD_DICT 中添加页面字段
b. 在 tabPages 中配置标签页(引用 FIELD_DICT 的 key)
c. 在 TabPageApiConfig 中接入真实接口
4. 在 router/map.ts 中添加路由
===== 页面结构 =====
┌─────────────────────────────────────────────────────────┐
│ TabArea(多标签页切换,可关闭) │
├──────────┬──────────────────────────────────────────────┤
│ ScanBox │ OrderToolbarButtonGroup(工具栏按钮组) │
│ 筛选面板 │ ┌──────────────────────────────────────────┐│
│ │ │ UpperTable(表格) ││
│ │ │ - OperationCellRenderer(操作列) ││
│ │ ├──────────────────────────────────────────┤│
│ │ │ 分隔条(可拖拽) ││
│ │ ├──────────────────────────────────────────┤│
│ │ │ DetailPanel / LogPanel(明细/日志面板) ││
│ │ └──────────────────────────────────────────┘│
└──────────┴──────────────────────────────────────────────┘
-->
<template>
<div class="page-wrapper" :style="{ height: containerHeight }">
<!-- ===== 多标签模式:显示顶部标签栏 ===== -->
<template v-if="PAGE_CONFIG.showTabArea && !PAGE_CONFIG.singlePage">
<div class="tab-section">
<TabArea
:tabs="tabList"
:default-active="activeTabName"
@tab-change="handleTabChange"
/>
</div>
</template>
<!-- ===== 主内容区 ===== -->
<div class="main-container">
<div class="order-sub-container">
<!-- 左侧:ScanBox 筛选面板 -->
<ScanBox
ref="scanBoxRef"
:cache-key="currentScanBoxCacheKey"
width="250px"
:tree-props="{ children: 'children', label: 'label' }"
:auto-submit="false"
:preset-tree="presetTree"
:available-fields="currentScanBoxFields"
@condition-change="handleConditionChange"
@reset="handleConditionReset"
@condition-clear="handleConditionClear"
/>
<!-- 右侧:内容区 -->
<div class="main-content">
<transition name="tab-fade" mode="out-in">
<div :key="activeTabName" class="tab-content-inner">
<!-- 工具栏按钮组 -->
<div class="toolbar">
<div class="toolbar-left">
<OrderToolbarButtonGroup
:buttons="currentToolbarButtons"
:resolve-disabled="resolveButtonDisabled"
:resolve-loading="resolveButtonLoading"
:resolve-label="resolveButtonLabel"
:layout-key="toolbarLayoutKey"
@action="handleToolbarButtonClick"
/>
</div>
</div>
<!-- 上下分栏区域:详情面板启用时才显示分栏 + 详情 -->
<template v-if="PAGE_CONFIG.enableDetailPanel">
<div class="split-stack" ref="splitStackRef">
<!-- 上半:表格 -->
<div class="upper-wrapper" :style="detailVisible ? upperPaneStyle : upperPaneFullStyle">
<UpperTable
ref="upperTableRef"
:title="currentTabConfig?.upperTable.title ?? '列表'"
default-align="center"
:enable-column-config="currentTabConfig?.upperTable.enableColumnConfig ?? true"
:column-config-schema-version="1"
:table-id="`template-table-${activeTabName}`"
:data="listData"
:row-key="'id'"
:columns="currentColumns"
table-size="small"
:pagination="pagination"
:show-index="currentTabConfig?.upperTable.showIndex ?? true"
:show-selection="currentTabConfig?.upperTable.showSelection ?? true"
:loading="loading"
:query-time="queryTime"
@current-change="handleRowClick"
@row-click="handleRowClick"
@page-change="handlePageChange"
@page-size-change="handlePageSizeChange"
@refresh="loadData"
@sort-change="handleSortChange"
@selection-change="handleSelectionChange"
>
<!-- 动态列插槽:根据 columnSlots 配置自动渲染 -->
<template
v-for="(slotConfig, colProp) in currentColumnSlots"
:key="`columnSlots-${colProp}`"
#[`column-${colProp}`]="{ row }"
>
<!-- 操作列:渲染操作按钮 -->
<OperationCellRenderer
v-if="slotConfig.type === 'operation'"
:buttons="currentTabConfig?.operationButtons"
:row="row"
@operation-action="handleOperationAction"
/>
<!-- 其他列:标签/文本渲染 -->
<ColumnCellRenderer
v-else
:config="slotConfig"
:value="row[colProp]"
/>
</template>
<template #empty>
<div class="empty-tip">{{ currentTabConfig?.upperTable.emptyText ?? '暂无数据' }}</div>
</template>
</UpperTable>
</div>
<!-- 分隔条(可拖拽) -->
<template v-if="detailVisible">
<div
class="pane-resizer"
title="拖动调整列表与详情区域高度"
@mousedown="beginSplitDrag"
/>
<!-- 下半:明细面板 -->
<div v-if="selectedRow" class="lower-level" :style="lowerPaneStyle">
<div class="detail-header">
<el-tabs v-model="activeDetailTab" class="detail-tab">
<el-tab-pane
v-for="tab in currentDetailTabs"
:key="tab.name"
:label="tab.label"
:name="tab.name"
/>
</el-tabs>
</div>
<div class="detail-container">
<component
:is="activeDetailTabComponent"
:row="selectedDetail"
:detail-config="currentDetailConfig"
:api-method="currentDetailTabApiMethod"
/>
</div>
</div>
<!-- 未选中行时的占位 -->
<div v-else class="no-selection" :style="lowerPaneStyle">
<div class="empty-tip">
<p>请从上方列表中选择一项查看详情</p>
</div>
</div>
</template>
</div>
</template>
<!-- 详情面板禁用:表格占满全高 -->
<template v-else>
<div class="upper-wrapper upper-wrapper--full">
<UpperTable
ref="upperTableRef"
:title="currentTabConfig?.upperTable.title ?? '列表'"
default-align="center"
:enable-column-config="currentTabConfig?.upperTable.enableColumnConfig ?? true"
:column-config-schema-version="1"
:table-id="`template-table-${activeTabName}`"
:data="listData"
:row-key="'id'"
:columns="currentColumns"
table-size="small"
:pagination="pagination"
:show-index="currentTabConfig?.upperTable.showIndex ?? true"
:show-selection="currentTabConfig?.upperTable.showSelection ?? false"
:loading="loading"
:query-time="queryTime"
@current-change="handleRowClick"
@row-click="handleRowClick"
@page-change="handlePageChange"
@page-size-change="handlePageSizeChange"
@refresh="loadData"
@sort-change="handleSortChange"
@selection-change="handleSelectionChange"
>
<template
v-for="(slotConfig, colProp) in currentColumnSlots"
:key="`columnSlots-${colProp}`"
#[`column-${colProp}`]="{ row }"
>
<OperationCellRenderer
v-if="slotConfig.type === 'operation'"
:buttons="currentTabConfig?.operationButtons"
:row="row"
@operation-action="handleOperationAction"
/>
<ColumnCellRenderer
v-else
:config="slotConfig"
:value="row[colProp]"
/>
</template>
<template #empty>
<div class="empty-tip">{{ currentTabConfig?.upperTable.emptyText ?? '暂无数据' }}</div>
</template>
</UpperTable>
</div>
</template>
</div>
</transition>
</div>
</div>
</div>
<!-- ===== 功能按钮表单(pages/ 目录下的组件) ===== -->
<!-- ★ 在此添加表单弹窗组件,如:
<YourFormDialog
v-model:visible="yourFormVisible"
@success="handleFormSuccess"
/>
-->
</div>
</template>
<script setup lang="ts">
// ============================================================
// ★★★ 第一步:修改组件名 ★★★
// ============================================================
defineOptions({ name: 'PageTemplate' })
import { ref, computed, onMounted, reactive } from 'vue'
import { ElMessage } from 'element-plus'
import { useSettingsStore } from '@/stores/modules/settings'
import { useVerticalSplitPane } from '@/composables/useVerticalSplitPane'
import ScanBox from '@/components/ScanBox/index.vue'
import UpperTable from '@/components/UpperTable/index.vue'
import TabArea from './components/TabArea.vue'
import ColumnCellRenderer from './components/ColumnCellRenderer.vue'
import OperationCellRenderer from './components/OperationCellRenderer.vue'
import OrderToolbarButtonGroup from '@/views/order/orderManagement/component/OrderToolbarButtonGroup.vue'
import type { ToolbarButtonConfig as OrderToolbarButtonConfig } from '@/views/order/orderManagement/config/order-common-config'
import {
PAGE_CONFIG,
tabPages,
resolveTabConfig,
getTabToolbarButtons,
type TabPageConfig,
type DetailTabConfig,
type ToolbarButtonConfig,
} from './config/template-config'
// ============================================================
// 容器高度
// ============================================================
const settingsStore = useSettingsStore()
const shortcutExpanded = computed(() => settingsStore.shortcutExpanded)
const containerHeight = computed(() =>
shortcutExpanded.value ? 'calc(100vh - 150px)' : 'calc(100vh - 100px)'
)
// ============================================================
// 标签页
// ============================================================
const tabList = computed(() =>
tabPages.map((t) => ({ name: t.name, label: t.label }))
)
const activeTabName = ref(tabPages[0]?.name ?? 'tab1')
/** 当前激活标签页的完整配置 */
const currentTabConfig = computed<TabPageConfig | undefined>(() => {
const raw = tabPages.find((t) => t.name === activeTabName.value)
if (!raw) return undefined
return resolveTabConfig(raw)
})
/** 当前 ScanBox 缓存 key */
const currentScanBoxCacheKey = computed(
() => currentTabConfig.value?.scanBoxCacheKey ?? 'template-default'
)
/** 当前 ScanBox 筛选字段 */
const currentScanBoxFields = computed(
() => currentTabConfig.value?.scanBoxFields ?? []
)
/** 当前表格列 */
const currentColumns = computed(
() => currentTabConfig.value?.upperTable.columns ?? []
)
/** 当前列插槽配置 */
const currentColumnSlots = computed(
() => currentTabConfig.value?.columnSlots ?? {}
)
/** 当前明细面板配置 */
const currentDetailConfig = computed(
() => currentTabConfig.value?.detailConfig ?? []
)
/** 当前明细标签页列表 */
const currentDetailTabs = computed<DetailTabConfig[]>(
() => currentTabConfig.value?.detailTabs ?? []
)
/** 当前激活的明细标签页组件 */
const activeDetailTabComponent = computed(() => {
const tab = currentDetailTabs.value.find(
(t) => t.name === activeDetailTab.value
)
return tab?.component ?? null
})
/** 当前激活明细标签页对应的 API 方法 */
const currentDetailTabApiMethod = computed(() => {
const cfg = currentTabConfig.value
if (!cfg?.api) return undefined
const tab = currentDetailTabs.value.find((t) => t.name === activeDetailTab.value)
if (!tab) return undefined
let componentCfg: unknown
switch (tab.componentKey) {
case 'DetailPanel':
componentCfg = cfg.api.detail
break
case 'LogPanel':
componentCfg = cfg.api.log
break
default:
return undefined
}
if (typeof componentCfg === 'function') {
return componentCfg
}
return undefined
})
// ============================================================
// 工具栏按钮系统
// ============================================================
/** 当前标签页的工具栏按钮列表 */
const currentToolbarButtons = computed<OrderToolbarButtonConfig[]>(() => {
const btns = getTabToolbarButtons(activeTabName.value)
return btns.map((btn: ToolbarButtonConfig) => ({
key: btn.key,
label: btn.label,
size: btn.size,
type: btn.type,
plain: btn.plain,
loadingKey: btn.loadingKey,
disabledKey: btn.disabledKey,
action: btn.action,
dynamicLabelKey: btn.dynamicLabelKey,
buttonType: btn.buttonType,
dropdownOptions: btn.dropdownOptions
}))
})
const buttonDisabledMap = computed<Record<string, boolean>>(() => ({
noSelection: selectedRows.value.length === 0
}))
const buttonLoadingMap = computed<Record<string, boolean>>(() => ({
loading: loading.value,
exportLoading: false
}))
const buttonLabelMap = computed<Record<string, string>>(() => ({
detailToggleLabel: detailVisible.value ? '隐藏详情' : '显示详情'
}))
const toolbarLayoutKey = computed(() =>
JSON.stringify({
loading: buttonLoadingMap.value,
disabled: buttonDisabledMap.value,
labels: buttonLabelMap.value
})
)
function resolveButtonLoading(loadingKey?: string) {
if (!loadingKey) return false
return Boolean(buttonLoadingMap.value[loadingKey])
}
function resolveButtonDisabled(disabledKey?: string) {
if (!disabledKey) return false
return Boolean(buttonDisabledMap.value[disabledKey])
}
function resolveButtonLabel(defaultLabel: string, dynamicLabelKey?: string) {
if (!dynamicLabelKey) return defaultLabel
return buttonLabelMap.value[dynamicLabelKey] || defaultLabel
}
// ============================================================
// 工具栏动作分发
// ============================================================
const toolbarActionMap: Record<string, () => void> = {
loadData: () => { void loadData() },
openColumnConfigPanel: () => { upperTableRef.value?.openColumnConfig?.() },
toggleDetailVisible: () => { detailVisible.value = !detailVisible.value },
handleExport: () => { console.log('[PageTemplate] 导出(不含明细)', activeTabName.value) },
handleExportItem: () => { console.log('[PageTemplate] 导出(含明细)', activeTabName.value) }
}
function handleToolbarButtonClick(action: string) {
const handler = toolbarActionMap[action]
if (handler) {
handler()
return
}
// ★ 在此添加功能按钮分发
console.warn('[PageTemplate] 未处理的工具栏动作:', action)
}
// ============================================================
// 操作列按钮事件处理
// ============================================================
async function handleOperationAction(key: string, row: Record<string, any>) {
// ★ 在此添加操作列按钮回调
console.log('[PageTemplate] 操作列按钮:', key, row)
switch (key) {
case 'viewDetail':
// 已经通过行点击处理
break
case 'edit':
ElMessage.info(`编辑「${row.name ?? row.code ?? row.id}」`)
break
default:
console.warn('[PageTemplate] 未处理的操作按钮:', key)
}
}
// ============================================================
// ★★★ 第二步:接入真实接口 ★★★
// ============================================================
const listData = ref<Record<string, any>[]>([])
const loading = ref(false)
const queryTime = ref(0)
const pagination = reactive({
currentPage: 1,
pageSize: 20,
total: 0
})
const currentSort = reactive({ prop: '', order: '' })
const loadData = async () => {
const cfg = currentTabConfig.value
if (!cfg) return
loading.value = true
const startTime = performance.now()
try {
if (cfg.api) {
// 使用真实接口
const conditions = scanBoxRef.value?.getConditions?.() || {}
const params = cfg.api.buildListParams
? cfg.api.buildListParams({
pagination: { page: pagination.currentPage, pageSize: pagination.pageSize },
conditions,
sort: currentSort.prop ? { prop: currentSort.prop, order: currentSort.order } : undefined
})
: {
pagination: { page: pagination.currentPage, pageSize: pagination.pageSize },
where: conditions
}
const res = await cfg.api.list(params)
if (res && (res.code === 1 || res.code === 200)) {
const parsed = cfg.api.parseListResponse
? cfg.api.parseListResponse(res)
: { list: res.data?.list ?? res.list ?? [], total: res.data?.pagination?.total ?? res.total ?? 0 }
listData.value = parsed.list
pagination.total = parsed.total
} else {
throw new Error(res?.message || '接口返回异常')
}
} else {
// ★ 未配置 API 时使用模拟数据(替换为真实接口后删除)
console.log('[PageTemplate] 未配置 API,使用空数据。请在 tabPages 中配置 api 字段。')
listData.value = []
pagination.total = 0
}
} catch (e: any) {
console.error('[PageTemplate] 加载列表失败:', e)
ElMessage.error(e?.message || '获取列表数据失败')
listData.value = []
pagination.total = 0
} finally {
loading.value = false
queryTime.value = Math.round(performance.now() - startTime)
}
}
// ============================================================
// ScanBox 筛选事件
// ============================================================
const scanBoxRef = ref<any>(null)
const presetTree = ref<any[]>([])
const handleConditionChange = () => {
pagination.currentPage = 1
loadData()
}
const handleConditionReset = () => {
pagination.currentPage = 1
loadData()
}
const handleConditionClear = () => {
pagination.currentPage = 1
loadData()
}
// ============================================================
// UpperTable 事件
// ============================================================
const upperTableRef = ref<any>(null)
const selectedRows = ref<Record<string, any>[]>([])
const handleSortChange = ({ prop, order }: any) => {
currentSort.prop = prop
currentSort.order = order
pagination.currentPage = 1
loadData()
}
const handlePageChange = (page: number) => {
pagination.currentPage = page
loadData()
}
const handlePageSizeChange = (size: number) => {
pagination.pageSize = size
pagination.currentPage = 1
loadData()
}
const handleSelectionChange = (rows: Record<string, any>[]) => {
selectedRows.value = rows
}
// ============================================================
// 明细面板
// ============================================================
const detailVisible = ref(PAGE_CONFIG.enableDetailPanel)
const selectedRow = ref<Record<string, any> | null>(null)
const selectedDetail = ref<Record<string, any> | null>(null)
const activeDetailTab = ref('detail')
const handleRowClick = async (row: Record<string, any>) => {
if (!PAGE_CONFIG.enableDetailPanel) return
const cfg = currentTabConfig.value
if (!cfg) return
selectedRow.value = row
// 根据 DetailPanel 的 api 配置决定数据来源
const detailCfg = cfg.api?.detail
if (typeof detailCfg === 'function') {
try {
const detailRes = await detailCfg({ id: row.id, code: row.code })
if (detailRes && (detailRes.code === 1 || detailRes.code === 200)) {
selectedDetail.value = detailRes.data ?? detailRes
} else {
selectedDetail.value = { ...row }
}
} catch {
selectedDetail.value = { ...row }
}
} else {
// source='list' 或未配置:直接用行数据
selectedDetail.value = { ...row }
}
}
// ============================================================
// 标签页切换
// ============================================================
const handleTabChange = (tabName: string) => {
if (activeTabName.value === tabName) return
activeTabName.value = tabName
pagination.currentPage = 1
currentSort.prop = ''
currentSort.order = ''
selectedRow.value = null
selectedDetail.value = null
selectedRows.value = []
activeDetailTab.value = 'detail'
loadData()
}
// ============================================================
// 分栏拖拽
// ============================================================
const { splitStackRef, beginSplitDrag, lowerPaneStyle, upperPaneStyle } =
useVerticalSplitPane({ defaultLowerPercent: 38 })
const upperPaneFullStyle = computed(() => ({
flex: '1 1 auto',
minHeight: '0',
overflow: 'hidden' as const
}))
// ============================================================
// 初始化
// ============================================================
onMounted(() => {
loadData()
})
</script>
<style lang="scss" scoped>
/* ================================================================
整体布局
================================================================ */
.page-wrapper {
position: relative;
width: 100%;
display: flex;
flex-direction: column;
overflow: hidden;
}
/* ================================================================
1. 顶部多标签页
================================================================ */
.tab-section {
flex-shrink: 0;
background: #fff;
border: 1px solid #e8eef7;
border-bottom: none;
border-radius: 6px 6px 0 0;
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
overflow: hidden;
}
/* ================================================================
2. 主内容区
================================================================ */
.main-container {
flex: 1;
display: flex;
flex-direction: column;
min-height: 0;
background: #fff;
border: 1px solid #e8eef7;
border-radius: 0 0 6px 6px;
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
overflow: hidden;
}
.order-sub-container {
display: flex;
height: 100%;
width: 100%;
background-color: #f0f2f5;
:deep(.scan-box-container) {
flex: 0 0 250px;
flex-shrink: 0;
height: 100%;
}
}
.main-content {
flex: 1;
display: flex;
flex-direction: column;
padding: 10px;
overflow: hidden;
min-width: 0;
}
.tab-content-inner {
flex: 1;
display: flex;
flex-direction: column;
min-height: 0;
}
/* ================================================================
3. 工具栏
================================================================ */
.toolbar {
margin-bottom: 3px;
padding: 6px 10px;
border: 1px solid #ebeef5;
display: flex;
justify-content: space-between;
align-items: center;
background-color: #fff;
min-width: 0;
overflow: hidden;
.toolbar-left {
flex: 1;
min-width: 0;
display: flex;
align-items: center;
gap: 10px;
overflow: hidden;
}
.toolbar-right {
flex: 0 0 auto;
margin-left: 10px;
display: flex;
align-items: center;
justify-content: flex-end;
gap: 10px;
}
}
/* ================================================================
4. 分栏区域
================================================================ */
.split-stack {
flex: 1;
display: flex;
flex-direction: column;
min-height: 0;
overflow: hidden;
:deep(.el-card__header) {
padding: 2px 12px;
font-size: 13px;
}
}
.upper-wrapper {
flex: 1 1 62%;
min-height: 0;
overflow: hidden;
}
/* 详情面板禁用时,表格占满全高 */
.upper-wrapper--full {
flex: 1 1 auto;
min-height: 0;
overflow: hidden;
}
.pane-resizer {
flex-shrink: 0;
height: 5px;
cursor: row-resize;
background-color: #f0f2f5;
border-top: 1px solid #ebeef5;
border-bottom: 1px solid #ebeef5;
transition: background-color 0.2s;
user-select: none;
&:hover {
background-color: #d3d9e3;
}
}
.lower-level {
flex: 1 1 38%;
min-height: 0;
overflow: hidden;
display: flex;
flex-direction: column;
:deep(.el-card) {
height: 100%;
display: flex;
flex-direction: column;
}
}
.no-selection {
flex: 1 1 38%;
min-height: 0;
display: flex;
align-items: center;
justify-content: center;
border: 1px solid #ebeef5;
border-radius: 4px;
.empty-tip p {
font-size: 14px;
color: #909399;
}
}
/* ================================================================
5. 明细面板
================================================================ */
.detail-header {
flex-shrink: 0;
border-bottom: 1px solid #e8eef7;
background: #fff;
padding: 0 12px;
.detail-tab {
:deep(.el-tabs__header) {
margin-bottom: 0;
}
:deep(.el-tabs__nav-wrap::after) {
height: 1px;
}
}
}
.detail-container {
flex: 1;
overflow: auto;
padding: 12px;
background: #fff;
}
/* ================================================================
6. 过渡动画
================================================================ */
.tab-fade-enter-active,
.tab-fade-leave-active {
transition: opacity 0.2s ease;
opacity: 1;
}
.tab-fade-enter-from,
.tab-fade-leave-to {
opacity: 0;
}
/* ================================================================
7. 空状态
================================================================ */
.empty-tip {
font-size: 13px;
color: #909399;
}
</style>

View File

@ -0,0 +1,107 @@
<!--
ExampleFormDialog — 示例表单弹窗(模板)
功能按钮对应的表单组件放在 pages/ 目录下。
使用方式:
1. 在 template-config.ts 的 COMPONENT_REGISTRY 中注册
2. 在 template-config.ts 的 TOOLBAR_BUTTONS 中添加功能按钮,设置 formKey
3. index.vue 中通过工具栏按钮触发打开
-->
<template>
<el-dialog
:model-value="visible"
title="示例操作"
width="500px"
align-center
destroy-on-close
:close-on-click-modal="false"
@closed="handleClosed"
>
<div class="form-body">
<el-form ref="formRef" :model="form" label-width="100px" size="small">
<el-form-item label="名称" prop="name">
<el-input v-model="form.name" placeholder="请输入名称" />
</el-form-item>
<el-form-item label="描述" prop="description">
<el-input
v-model="form.description"
type="textarea"
:rows="3"
placeholder="请输入描述"
/>
</el-form-item>
</el-form>
</div>
<template #footer>
<el-button size="small" @click="handleClosed">取消</el-button>
<el-button size="small" type="primary" :loading="submitting" @click="handleSubmit">
确认
</el-button>
</template>
</el-dialog>
</template>
<script setup lang="ts">
import { reactive, ref, watch } from 'vue'
import { ElMessage } from 'element-plus'
defineOptions({ name: 'ExampleFormDialog' })
const props = defineProps<{
visible: boolean
/** 从行数据注入的初始值(由 OperationCellRenderer 的 paramMap 传递) */
id?: string | number
code?: string
name?: string
}>()
const emit = defineEmits<{
(e: 'update:visible', v: boolean): void
(e: 'success'): void
}>()
const formRef = ref<any>(null)
const submitting = ref(false)
const form = reactive({
name: '',
description: ''
})
// 重置表单
watch(() => props.visible, (v) => {
if (v) {
form.name = props.name ?? ''
form.description = ''
}
})
function handleClosed() {
emit('update:visible', false)
}
async function handleSubmit() {
submitting.value = true
try {
// ★ 替换为真实 API 调用
// const res = await yourApi.submit({ id: props.id, ...form })
await new Promise((r) => setTimeout(r, 500))
ElMessage.success('操作成功')
emit('update:visible', false)
emit('success')
} catch (e: any) {
ElMessage.error(e?.message || '操作失败')
} finally {
submitting.value = false
}
}
</script>
<style lang="scss" scoped>
.form-body {
padding: 12px 0;
}
</style>

View File

@ -27,9 +27,8 @@
>
批量删除
</el-button>
<!-- <el-tag size="small" type="info">共 {{ pagination.total }} 条</el-tag> -->
<el-button type="success" size="small" @click="openCreate">新增供应商</el-button>
</div>
<el-button type="success" size="small" @click="openCreate">新增供应商</el-button>
</div>
<div class="upper-wrapper">

View File

@ -24,6 +24,7 @@ export const packageSupplierScanFields = [
value: 'quickWhere',
label: '关键词',
type: 'text',
group: '基础信息',
placeholder: '编码/名称/联系人/电话',
operators: ['eq','contains'],
defaultOperator: 'eq'
@ -32,6 +33,7 @@ export const packageSupplierScanFields = [
value: 'supplier_code',
label: '供应商编码',
type: 'text',
group: '基础信息',
placeholder: '请输入供应商编码',
operators: ['eq', 'contains', 'like'],
defaultOperator: 'eq'
@ -40,6 +42,7 @@ export const packageSupplierScanFields = [
value: 'supplier_name',
label: '供应商名称',
type: 'text',
group: '基础信息',
placeholder: '请输入供应商名称',
operators: ['eq', 'contains', 'like'],
defaultOperator: 'eq'
@ -48,6 +51,7 @@ export const packageSupplierScanFields = [
value: 'contact_name',
label: '联系人',
type: 'text',
group: '基础信息',
placeholder: '请输入联系人',
operators: ['eq', 'contains', 'like'],
defaultOperator: 'eq'
@ -56,6 +60,7 @@ export const packageSupplierScanFields = [
value: 'contact_phone',
label: '联系电话',
type: 'text',
group: '基础信息',
placeholder: '请输入联系电话',
operators: ['eq', 'contains', 'like'],
defaultOperator: 'eq'
@ -64,6 +69,7 @@ export const packageSupplierScanFields = [
value: 'status',
label: '状态',
type: 'select',
group: '其他筛选',
clearable: true,
options: [
{ label: '启用', value: '1' },
@ -74,6 +80,7 @@ export const packageSupplierScanFields = [
value: 'id',
label: 'ID',
type: 'number',
group: '其他筛选',
placeholder: '供应商 ID',
operators: ['eq', 'ne'],
defaultOperator: 'eq'

View File

@ -17,26 +17,29 @@
<el-icon><Refresh /></el-icon> 刷新
</el-button>
<el-button size="small" plain @click="tableRef?.openColumnConfig?.()">字段设置</el-button>
</div>
<div class="toolbar-right">
<WarehouseSelect
v-model="queryForm.warehouse_id"
width="200px"
style="margin-right: 8px"
@change="handleWarehouseChange"
/>
<el-input
v-model="queryForm.keyword"
placeholder="搜索商品编码/名称/条码"
clearable
size="small"
style="width: 240px"
@keyup.enter="handleSearch"
<el-divider direction="vertical" />
<el-dropdown
trigger="click"
@command="handleExportCommand"
>
<template #prefix>
<el-icon><Search /></el-icon>
<el-button
size="small"
type="primary"
:loading="exportLoading"
>
导出<el-icon class="el-icon--right"><ArrowDown /></el-icon>
</el-button>
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item command="selected" :disabled="!hasSelection">
导出选中
</el-dropdown-item>
<el-dropdown-item command="all" :divided="true">
导出全部
</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-input>
</el-dropdown>
</div>
</div>
@ -61,10 +64,12 @@
:loading="loading"
:pagination="pagination"
:show-actions="true"
:show-selection="true"
@current-change="handleRowClick"
@page-change="handlePageChange"
@page-size-change="handleSizeChange"
@sort-change="handleSortChange"
@selection-change="handleSelectionChange"
>
<template #column-id="{ row }">
<span class="sku-text">{{ row.id ?? '—' }}</span>
@ -239,20 +244,36 @@
<el-button size="small" type="primary" :loading="editSaving" @click="handleEditSave">保存</el-button>
</template>
</el-dialog>
<!-- 导出进度弹窗 -->
<AsyncExportProgressDialog
v-model:visible="exportDialogVisible"
title="外仓商品导出进度"
:loading="exportLoading"
:progress-percent="exportProgressPercent"
:progress-status="exportProgressStatus"
:status-label="exportStatusLabel"
:task-id="exportTaskProgress.taskId"
:message="exportTaskProgress.message"
:error="exportTaskProgress.error"
:update-time="exportTaskProgress.updateTime"
/>
</div>
</template>
<script setup lang="ts">
import { ref, reactive, onMounted, watch } from 'vue'
import { ref, reactive, onMounted, computed } from 'vue'
import { ElMessage } from 'element-plus'
import { Search, Refresh } from '@element-plus/icons-vue'
import { stockWarehouseExternalList, saveWarehouseStock, type StockWarehouseListSort } from '@/api/stock/stock'
import { Refresh, ArrowDown } from '@element-plus/icons-vue'
import { stockWarehouseExternalList, stockWarehouseExternalExport, getExportTaskProgress, saveWarehouseStock, type StockWarehouseListSort } from '@/api/stock/stock'
import { getImages } from '@/api/index/index'
import ScanBox from '@/components/ScanBox/index.vue'
import UpperTable from '@/components/UpperTable/index.vue'
import WarehouseSelect from '@/components/WarehouseSelect.vue'
import ErpStock from '@/views/stock/stock/component/erpStock.vue'
import Log from '@/views/stock/stock/component/log.vue'
import AsyncExportProgressDialog from '@/components/AsyncExportProgressDialog.vue'
import { useAsyncExportTask } from '@/composables/useAsyncExportTask'
import { useVerticalSplitPane } from '@/composables/useVerticalSplitPane'
// ─── 列表列配置 ─────────────────────────────────────────────────────────────
@ -276,51 +297,75 @@ const columns = [
]
// ─── 筛选字段配置 ─────────────────────────────────────────────────────────
const availableFields = [
const availableFields: any[] = [
{
label: '关键词',
value: 'keyword',
type: 'text',
operators: ['like'],
placeholder: '商品编码/名称/条码',
group: '基础信息'
},
{
label: '全部仓库',
value: 'warehouse_id',
type: 'custom',
component: WarehouseSelect,
props: { width: '100%' },
group: '基础信息'
},
{
label: '商品名称',
value: 'item_name',
type: 'text'
type: 'text',
group: '基础信息'
},
{
label: '品牌',
value: 'brand_name',
type: 'text'
type: 'text',
group: '基础信息'
},
{
label: '货物编码',
value: 'goods_code',
type: 'text'
type: 'text',
group: '基础信息'
},
{
label: 'SKU',
value: 'id',
type: 'text',
group: '基础信息'
},
{
label: '条码',
value: 'barcode',
type: 'text',
group: '基础信息'
},
{
label: '库存数量',
value: 'quantity',
type: 'text',
group: '基础信息'
},
{
label: '外部商品绑定',
value: 'has_bound_item',
type: 'select',
group: '流程状态',
options: [
{ label: '全部', value: undefined },
{ label: '是', value: 'Y' },
{ label: '否', value: 'N' }
]
},
{
label: 'SKU',
value: 'id',
type: 'text'
},
{
label: '条码',
value: 'barcode',
type: 'text'
},
{
label: '库存数量',
value: 'quantity',
type: 'text'
},
{
label: 'ABC分类',
value: 'level',
type: 'select',
group: '流程状态',
options: [
{ label: '全部', value: undefined },
{ label: 'A', value: 'A' },
@ -332,6 +377,7 @@ const availableFields = [
label: '是否图片',
value: 'is_images',
type: 'select',
group: '流程状态',
options: [
{ label: '全部', value: undefined },
{ label: '是', value: 'Y' },
@ -342,6 +388,7 @@ const availableFields = [
label: 'SN管理',
value: 'is_sn_mgmt',
type: 'select',
group: '流程状态',
options: [
{ label: '全部', value: undefined },
{ label: '是', value: 'Y' },
@ -352,6 +399,7 @@ const availableFields = [
label: '保质期管理',
value: 'is_shelf_life_mgmt',
type: 'select',
group: '流程状态',
options: [
{ label: '全部', value: undefined },
{ label: '是', value: 'Y' },
@ -362,6 +410,7 @@ const availableFields = [
label: '批次管理',
value: 'is_batch_mgmt',
type: 'select',
group: '流程状态',
options: [
{ label: '全部', value: undefined },
{ label: '是', value: 'Y' },
@ -386,6 +435,83 @@ const currentCondition = ref<any>({})
const currentSort = reactive({ prop: '', order: '' })
const summary = ref<any>(null)
// ─── 多选 & 导出 ──────────────────────────────────────────────────────────
const selectionIds = ref<any[]>([])
const hasSelection = computed(() => selectionIds.value.length > 0)
function handleSelectionChange(selection: any[]) {
selectionIds.value = selection
}
const {
exportLoading,
exportDialogVisible,
exportTaskProgress,
exportProgressPercent,
exportProgressStatus,
exportStatusLabel,
submitExportTask
} = useAsyncExportTask({
storageKey: 'stock:external:exportTaskId',
submitExport: (payload) => stockWarehouseExternalExport(payload as any),
queryProgress: (params) => getExportTaskProgress(params)
})
function buildExportPayload() {
const payload: any = {
where: { ...currentCondition.value }
}
if (queryForm.keyword) {
payload.where.keyword = queryForm.keyword
}
if (queryForm.warehouse_id !== undefined && queryForm.warehouse_id !== null && queryForm.warehouse_id !== '') {
payload.warehouse_id = queryForm.warehouse_id
}
if (currentSort.prop) {
payload.sort = {
sortField: currentSort.prop,
sortOrder: currentSort.order === 'ascending' ? 'ASC' : 'DESC'
}
}
return payload
}
function buildExportSelectedPayload() {
const ids = selectionIds.value.map((item: any) => item.id)
const payload: any = {
where: {
id: {
operator: 'in',
value: ids
}
}
}
if (queryForm.warehouse_id !== undefined && queryForm.warehouse_id !== null && queryForm.warehouse_id !== '') {
payload.warehouse_id = queryForm.warehouse_id
}
return payload
}
async function handleExportAll() {
await submitExportTask(buildExportPayload())
}
async function handleExportSelected() {
if (!hasSelection.value) {
ElMessage.warning('请先勾选需要导出的商品')
return
}
await submitExportTask(buildExportSelectedPayload())
}
function handleExportCommand(command: string) {
if (command === 'selected') {
handleExportSelected()
} else if (command === 'all') {
handleExportAll()
}
}
// ─── 上下分栏拖动 ──────────────────────────────────────────────────────────
const { splitStackRef, beginSplitDrag, lowerPaneStyle, upperPaneStyle } = useVerticalSplitPane({
defaultLowerPercent: 35,
@ -393,12 +519,8 @@ const { splitStackRef, beginSplitDrag, lowerPaneStyle, upperPaneStyle } = useVer
maxLowerPercent: 70
})
// ─── 仓库列表(已由 WarehouseSelect 组件接管)───────────────────────────
function handleWarehouseChange() {
pagination.currentPage = 1
loadList()
}
// ─── 特殊字段键(不作为 where 条件,需要单独提取)──────────────────────
const SPECIAL_KEYS = ['keyword', 'warehouse_id']
// ─── 加载列表 ──────────────────────────────────────────────────────────────
async function loadList() {
@ -446,8 +568,23 @@ async function loadList() {
// ─── 事件处理 ──────────────────────────────────────────────────────────────
function handleConditionChange(condition: any) {
const where: any = {}
// 重置特殊字段
queryForm.keyword = ''
queryForm.warehouse_id = undefined
if (condition) {
Object.keys(condition).forEach(k => {
if (SPECIAL_KEYS.includes(k)) {
// 关键词、仓库 从 condition 提取到 queryForm
const c = condition[k]
const val = (c && typeof c === 'object' && c.value !== undefined) ? c.value : c
if (k === 'keyword' && val) {
queryForm.keyword = val
} else if (k === 'warehouse_id' && val !== undefined && val !== null && val !== '') {
queryForm.warehouse_id = val
}
return
}
const c = condition[k]
if (c && typeof c === 'object' && c.value !== undefined) {
if (c.value !== '' && c.value !== null) {
@ -463,11 +600,6 @@ function handleConditionChange(condition: any) {
loadList()
}
function handleSearch() {
pagination.currentPage = 1
loadList()
}
function handleReset() {
queryForm.keyword = ''
queryForm.warehouse_id = undefined
@ -615,11 +747,6 @@ onMounted(() => {
align-items: center;
gap: 6px;
}
&-right {
display: flex;
align-items: center;
}
}
.upper-wrapper {
@ -682,7 +809,6 @@ onMounted(() => {
}
.sku-text {
font-family: 'Courier New', monospace;
font-size: 12px;
}

View File

@ -18,7 +18,29 @@
<div class="toolbar">
<div class="toolbar-left">
<el-button size="small" type="primary" @click="loadData">刷新</el-button>
<ExportModeDropdown :loading="exportLoading" @action="handleExportAction" />
<el-dropdown
trigger="click"
@command="handleExportCommand"
>
<el-button
size="small"
type="primary"
plain
:loading="exportLoading"
>
导出<el-icon class="el-icon--right"><ArrowDown /></el-icon>
</el-button>
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item command="selected" :disabled="!hasSelection">
导出选中
</el-dropdown-item>
<el-dropdown-item command="all" :divided="true">
导出全部
</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
<el-button size="small" @click="openColumnConfigPanel">字段设置</el-button>
<el-button size="small" @click="toggleDetailVisible">{{ detailVisible ? '隐藏详情' : '显示详情' }}</el-button>
</div>
@ -45,13 +67,14 @@
:table-size="tableSize"
:pagination="pagination"
:show-index="true"
:show-selection="false"
:show-selection="true"
:loading="loading"
:queryTime="queryTime"
@current-change="handleRowClick"
@sort-change="handleSortChange"
@page-change="handlePageChange"
@page-size-change="handlePageSizeChange"
@selection-change="handleSelectionChange"
@refresh="loadData"
>
<template #column-order_status="{ row }">
@ -157,6 +180,20 @@
</template>
</div>
</div>
<!-- 导出进度弹窗 -->
<AsyncExportProgressDialog
v-model:visible="exportDialogVisible"
title="入库单导出进度"
:loading="exportLoading"
:progress-percent="exportProgressPercent"
:progress-status="exportProgressStatus"
:status-label="exportStatusLabel"
:task-id="exportTaskProgress.taskId"
:message="exportTaskProgress.message"
:error="exportTaskProgress.error"
:update-time="exportTaskProgress.updateTime"
/>
</div>
</template>
@ -164,12 +201,14 @@
import { ref, reactive, onMounted, computed } from 'vue'
import { useRoute } from 'vue-router'
import { ElMessage } from 'element-plus'
import { ArrowDown } from '@element-plus/icons-vue'
import ScanBox from '@/components/ScanBox/index.vue'
import UpperTable from '@/components/UpperTable/index.vue'
import AsyncExportProgressDialog from '@/components/AsyncExportProgressDialog.vue'
import { useAsyncExportTask } from '@/composables/useAsyncExportTask'
import * as indexApi from '@/api/index/index'
import * as entryApi from '@/api/storage.entry/entry'
import type { StorageEntryListParams } from '@/api/storage.entry/entry'
import * as XLSX from 'xlsx'
import {
availableFields,
@ -183,7 +222,6 @@ import entrydetail from '@/views/storage/entry/component/entrydetail.vue'
import log from '@/views/storage/entry/component/log.vue'
import DirectInboundLogs from '@/views/storage/entry/component/DirectInboundLogs.vue'
import EntryBindingRelations from '@/views/storage/entry/component/EntryBindingRelations.vue'
import ExportModeDropdown from '@/components/ExportModeDropdown.vue'
import WarehouseSelect from '@/components/WarehouseSelect.vue'
import { useVerticalSplitPane } from '@/composables/useVerticalSplitPane'
import { useSettingsStore } from '@/stores/modules/settings'
@ -238,9 +276,30 @@ const activeTab = ref('details')
const list = ref<any[]>([])
const loading = ref(false)
const exportLoading = ref(false)
const queryTime = ref(0)
// ─── 多选 & 导出 ──────────────────────────────────────────────────────────
const selectionIds = ref<any[]>([])
const hasSelection = computed(() => selectionIds.value.length > 0)
function handleSelectionChange(selection: any[]) {
selectionIds.value = selection
}
const {
exportLoading,
exportDialogVisible,
exportTaskProgress,
exportProgressPercent,
exportProgressStatus,
exportStatusLabel,
submitExportTask
} = useAsyncExportTask({
storageKey: 'storage:entry:exportTaskId',
submitExport: (payload) => entryApi.entryStoreExport(payload as any),
queryProgress: (params) => entryApi.entryStoreExportTaskProgress(params)
})
const pagination = reactive({ currentPage: 1, pageSize: 20, total: 0 })
const tableSize = ref('small')
const columns = ref(entryStoreColums)
@ -529,80 +588,52 @@ function handlePageSizeChange(size: number) {
loadData()
}
async function handleExport(mode: 'waybill' | 'item' = 'waybill') {
const sourceRows = list.value
if (!sourceRows.length) {
ElMessage.warning('当前无数据可导出')
return
function buildExportPayload() {
const where = currentCondition.value || normalizeToWhere(scanBox.value?.getConditions?.() || {})
if (selectedWarehouseId.value) {
where.warehouse_id = { operator: 'eq', value: selectedWarehouseId.value, type: 'number' }
}
exportLoading.value = true
try {
const exportColumns = columns.value.filter((col: any) => col.prop && col.label)
if (mode === 'waybill') {
const headers = exportColumns.map((col: any) => col.label)
const data = sourceRows.map((row: any) =>
exportColumns.map((col: any) => {
const val = row[col.prop]
if (['order_status', 'order_type', 'sync_status'].includes(col.prop)) {
return translateField(col.prop, val)
}
return val === null || val === undefined ? '' : val
})
)
const ws = XLSX.utils.aoa_to_sheet([headers, ...data])
const wb = XLSX.utils.book_new()
XLSX.utils.book_append_sheet(wb, ws, '入库单列表')
XLSX.writeFile(wb, `入库单列表_${new Date().getTime()}.xlsx`)
ElMessage.success('导出成功')
return
const payload: any = { where }
if (currentSort.prop) {
payload.sort = {
sortField: currentSort.prop,
sortOrder: currentSort.order === 'ascending' ? 'ASC' : 'DESC'
}
// 导出明细
const detailRows: any[] = []
for (const row of sourceRows) {
try {
const res: any = await entryApi.getEntryDetailStore({ id: row.id })
const payload = res?.data || res
const items = Array.isArray(payload?.items)
? payload.items
: payload?.entryOrder?.items || []
items.forEach((item: any) => {
detailRows.push({
'入库单号': row.entry_order_code || row.id,
'商品编码': item.warehouse_item_code || item.external_item_code || '',
'商品名称': item.warehouse_item_name || '',
'规格': item.warehouse_item_spec || '',
'计划数量': item.count ?? '',
'实收数量': item.received_quantity ?? '',
'确认数量': item.confirm_quantity ?? '',
})
})
} catch (e) {
console.warn(`获取入库单 ${row.id} 明细失败`, e)
}
}
if (!detailRows.length) {
ElMessage.warning('未获取到可导出的入库明细')
return
}
const ws = XLSX.utils.json_to_sheet(detailRows)
const wb = XLSX.utils.book_new()
XLSX.utils.book_append_sheet(wb, ws, '入库明细')
XLSX.writeFile(wb, `入库明细_${new Date().getTime()}.xlsx`)
ElMessage.success('导出成功')
} catch (e) {
console.error('导出 Excel 失败:', e)
ElMessage.error('导出失败')
} finally {
exportLoading.value = false
}
return payload
}
function handleExportAction(action: string) {
void handleExport(action === 'handleExportItem' ? 'item' : 'waybill')
function buildExportSelectedPayload() {
const ids = selectionIds.value.map((item: any) => item.id)
const payload: any = {
where: {
id: { operator: 'in', value: ids }
}
}
if (selectedWarehouseId.value) {
payload.where.warehouse_id = { operator: 'eq', value: selectedWarehouseId.value, type: 'number' }
}
return payload
}
async function handleExportAll() {
await submitExportTask(buildExportPayload())
}
async function handleExportSelected() {
if (!hasSelection.value) {
ElMessage.warning('请先勾选需要导出的入库单')
return
}
await submitExportTask(buildExportSelectedPayload())
}
function handleExportCommand(command: string) {
if (command === 'selected') {
handleExportSelected()
} else if (command === 'all') {
handleExportAll()
}
}
</script>

View File

@ -18,7 +18,29 @@
<div class="toolbar">
<div class="toolbar-left">
<el-button size="small" type="primary" @click="loadData">刷新</el-button>
<ExportModeDropdown :loading="exportLoading" @action="handleExportAction" />
<el-dropdown
trigger="click"
@command="handleExportCommand"
>
<el-button
size="small"
type="primary"
plain
:loading="exportLoading"
>
导出<el-icon class="el-icon--right"><ArrowDown /></el-icon>
</el-button>
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item command="selected" :disabled="!hasSelection">
导出选中
</el-dropdown-item>
<el-dropdown-item command="all" :divided="true">
导出全部
</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
<el-button size="small" @click="openColumnConfigPanel">字段设置</el-button>
<el-button size="small" @click="toggleDetailVisible">{{ detailVisible ? '隐藏详情' : '显示详情' }}</el-button>
</div>
@ -44,12 +66,14 @@
:table-size="tableSize"
:pagination="pagination"
:show-index="true"
:show-selection="true"
:loading="loading"
:queryTime="queryTime"
@current-change="handleRowClick"
@sort-change="handleSortChange"
@page-change="handlePageChange"
@page-size-change="handlePageSizeChange"
@selection-change="handleSelectionChange"
@refresh="loadData"
>
<template #column-status="{ row }">
@ -120,6 +144,20 @@
</template>
</div>
</div>
<!-- 导出进度弹窗 -->
<AsyncExportProgressDialog
v-model:visible="exportDialogVisible"
title="收货单导出进度"
:loading="exportLoading"
:progress-percent="exportProgressPercent"
:progress-status="exportProgressStatus"
:status-label="exportStatusLabel"
:task-id="exportTaskProgress.taskId"
:message="exportTaskProgress.message"
:error="exportTaskProgress.error"
:update-time="exportTaskProgress.updateTime"
/>
</div>
</template>
@ -127,10 +165,12 @@
import { ref, reactive, onMounted, computed } from 'vue'
import { useRoute } from 'vue-router'
import { ElMessage } from 'element-plus'
import { ArrowDown } from '@element-plus/icons-vue'
import ScanBox from '@/components/ScanBox/index.vue'
import UpperTable from '@/components/UpperTable/index.vue'
import WarehouseSelect from '@/components/WarehouseSelect.vue'
import ExportModeDropdown from '@/components/ExportModeDropdown.vue'
import AsyncExportProgressDialog from '@/components/AsyncExportProgressDialog.vue'
import { useAsyncExportTask } from '@/composables/useAsyncExportTask'
import * as indexApi from '@/api/index/index'
import * as receivingApi from '@/api/storage_receiving/receiving'
import {
@ -143,7 +183,6 @@ import {
} from '@/views/storage/receiving/receiving-config'
import Details from '@/views/storage/receiving/component/Details.vue'
import Logs from '@/views/storage/receiving/component/Logs.vue'
import * as XLSX from 'xlsx'
import { useVerticalSplitPane } from '@/composables/useVerticalSplitPane'
import { useSettingsStore } from '@/stores/modules/settings'
@ -192,9 +231,30 @@ const activeTab = ref('details')
const list = ref<any[]>([])
const loading = ref(false)
const exportLoading = ref(false)
const queryTime = ref(0)
// ─── 多选 & 导出 ──────────────────────────────────────────────────────────
const selectionIds = ref<any[]>([])
const hasSelection = computed(() => selectionIds.value.length > 0)
function handleSelectionChange(selection: any[]) {
selectionIds.value = selection
}
const {
exportLoading,
exportDialogVisible,
exportTaskProgress,
exportProgressPercent,
exportProgressStatus,
exportStatusLabel,
submitExportTask
} = useAsyncExportTask({
storageKey: 'storage:receiving:exportTaskId',
submitExport: (payload) => receivingApi.exportReceiving(payload as any),
queryProgress: (params) => receivingApi.exportReceivingTaskProgress(params)
})
const pagination = reactive({ currentPage: 1, pageSize: 20, total: 0 })
const tableSize = ref('small')
@ -392,83 +452,52 @@ function handlePageSizeChange(size: number) {
loadData()
}
async function handleExport(mode: 'waybill' | 'item' = 'waybill') {
const sourceRows = list.value
if (!sourceRows.length) {
ElMessage.warning('当前无数据可导出')
return
function buildExportPayload() {
const where = currentCondition.value || normalizeToWhere(scanBox.value?.getConditions?.() || {})
if (selectedWarehouseId.value) {
where.warehouse_id = { operator: 'eq', value: selectedWarehouseId.value, type: 'number' }
}
exportLoading.value = true
try {
const exportColumns = columns.value.filter((col: any) => col.prop && col.label)
if (mode === 'waybill') {
const headers = exportColumns.map((col: any) => col.label)
const data = sourceRows.map((row: any) =>
exportColumns.map((col: any) => {
const val = row[col.prop]
if (col.prop === 'status') return statusText(val)
if (col.prop === 'storage_status') return storageStatusText(val)
if (col.prop === 'delivery_method') return deliveryMethodText(val)
if (col.prop === 'loading_method') return loadingMethodText(val)
if (col.prop === 'created_at' || col.prop === 'updated_at' ||
col.prop === 'receiving_start_time' || col.prop === 'receiving_end_time') {
return formatTime(val)
}
return val === null || val === undefined ? '' : val
})
)
const ws = XLSX.utils.aoa_to_sheet([headers, ...data])
const wb = XLSX.utils.book_new()
XLSX.utils.book_append_sheet(wb, ws, '收货单列表')
XLSX.writeFile(wb, `收货单列表_${new Date().getTime()}.xlsx`)
ElMessage.success('导出成功')
return
const payload: any = { where }
if (currentSort.prop) {
payload.sort = {
sortField: currentSort.prop,
sortOrder: currentSort.order === 'ascending' ? 'ASC' : 'DESC'
}
// 导出明细
const detailRows: any[] = []
for (const row of sourceRows) {
try {
const res: any = await receivingApi.getReceivingDetailStore({ id: row.id })
const payload = res?.data || res
const items = Array.isArray(payload?.items)
? payload.items
: payload?.receiving?.items || []
items.forEach((item: any) => {
detailRows.push({
'收货单号': row.receiving_number || row.id,
'商品名称': item.product_name || item.item_name || '',
'商品编码': item.product_code || item.item_code || '',
'数量': item.quantity ?? '',
'箱数': item.boxes ?? '',
})
})
} catch (e) {
console.warn(`获取收货单 ${row.id} 明细失败`, e)
}
}
if (!detailRows.length) {
ElMessage.warning('未获取到可导出的收货明细')
return
}
const ws = XLSX.utils.json_to_sheet(detailRows)
const wb = XLSX.utils.book_new()
XLSX.utils.book_append_sheet(wb, ws, '收货明细')
XLSX.writeFile(wb, `收货明细_${new Date().getTime()}.xlsx`)
ElMessage.success('导出成功')
} catch (e) {
console.error('导出 Excel 失败:', e)
ElMessage.error('导出失败')
} finally {
exportLoading.value = false
}
return payload
}
function handleExportAction(action: string) {
void handleExport(action === 'handleExportItem' ? 'item' : 'waybill')
function buildExportSelectedPayload() {
const ids = selectionIds.value.map((item: any) => item.id)
const payload: any = {
where: {
id: { operator: 'in', value: ids }
}
}
if (selectedWarehouseId.value) {
payload.where.warehouse_id = { operator: 'eq', value: selectedWarehouseId.value, type: 'number' }
}
return payload
}
async function handleExportAll() {
await submitExportTask(buildExportPayload())
}
async function handleExportSelected() {
if (!hasSelection.value) {
ElMessage.warning('请先勾选需要导出的收货单')
return
}
await submitExportTask(buildExportSelectedPayload())
}
function handleExportCommand(command: string) {
if (command === 'selected') {
handleExportSelected()
} else if (command === 'all') {
handleExportAll()
}
}
</script>

View File

@ -17,6 +17,9 @@
<el-button size="small" type="primary" @click="openSignDialog">
<el-icon><Plus /></el-icon> 发起签约
</el-button>
<el-button size="small" :loading="exportLoading" @click="handleExportLogs">
<el-icon><Download /></el-icon> 导出日志
</el-button>
<el-button size="small" @click="loadList">
<el-icon><Refresh /></el-icon> 刷新
</el-button>
@ -158,7 +161,52 @@
</el-descriptions-item>
</el-descriptions>
<div v-else class="log-placeholder">
<el-empty description="操作日志开发中" :image-size="40" />
<div class="log-toolbar">
<el-pagination
v-if="logPagination.total > 0"
v-model:current-page="logPagination.currentPage"
v-model:page-size="logPagination.pageSize"
:total="logPagination.total"
:page-sizes="[10, 20, 50]"
layout="total, sizes, prev, pager, next"
size="small"
@current-change="loadLogs"
@size-change="handleLogSizeChange"
/>
</div>
<el-table :data="logList" v-loading="logLoading" size="small" border max-height="220">
<el-table-column prop="id" label="ID" width="70" />
<el-table-column prop="business_type" label="业务类型" min-width="100">
<template #default="{ row }">{{ row.business_type || '—' }}</template>
</el-table-column>
<el-table-column prop="change_quantity" label="变更数量" width="100" />
<el-table-column prop="before_quantity" label="变更前面单余额" width="130" />
<el-table-column prop="after_quantity" label="变更后面单余额" width="130" />
<el-table-column prop="reason" label="变更原因" min-width="140">
<template #default="{ row }">{{ row.reason || '—' }}</template>
</el-table-column>
<el-table-column prop="operator_name" label="操作人" width="100">
<template #default="{ row }">{{ row.operator_name || '—' }}</template>
</el-table-column>
<el-table-column prop="created_at" label="操作时间" width="170">
<template #default="{ row }">{{ row.created_at || '—' }}</template>
</el-table-column>
<template #empty>
<el-empty description="暂无操作日志" :image-size="40" />
</template>
</el-table>
<el-pagination
v-if="logPagination.total > 0"
v-model:current-page="logPagination.currentPage"
v-model:page-size="logPagination.pageSize"
:total="logPagination.total"
:page-sizes="[10, 20, 50]"
layout="total, sizes, prev, pager, next"
size="small"
style="margin-top:8px;justify-content:flex-end"
@current-change="loadLogs"
@size-change="handleLogSizeChange"
/>
</div>
</div>
</div>
@ -338,24 +386,42 @@
</template>
</el-dialog>
<AsyncExportProgressDialog
v-model:visible="exportDialogVisible"
title="面单日志导出进度"
:loading="exportLoading"
:progress-percent="exportProgressPercent"
:progress-status="exportProgressStatus"
:status-label="exportStatusLabel"
:task-id="exportTaskProgress.taskId"
:message="exportTaskProgress.message"
:error="exportTaskProgress.error"
:update-time="exportTaskProgress.updateTime"
/>
</div>
</template>
<script setup lang="ts">
import { ref, reactive, onMounted } from 'vue'
import { ref, reactive, onMounted, watch } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import { Search, Plus, Refresh } from '@element-plus/icons-vue'
import { Search, Plus, Refresh, Download } from '@element-plus/icons-vue'
import {
warehouseList,
storeWarehouseSign,
storeWarehouseConfirmSign,
storeWarehouseUnbind,
storeWarehouseRename,
listApiConfig
listApiConfig,
storeWarehouseExportStorePrintQuantityLogs,
storeWarehouseExportStorePrintQuantityLogsTaskProgress,
storeWarehouseQueryStorePrintQuantityLogs
} from '@/api/storewarehouse.store/storeWarehouse'
import { listInterfaceTypes, getQimenAppList } from '@/api/index/index'
import ScanBox from '@/components/ScanBox/index.vue'
import UpperTable from '@/components/UpperTable/index.vue'
import AsyncExportProgressDialog from '@/components/AsyncExportProgressDialog.vue'
import { useAsyncExportTask } from '@/composables/useAsyncExportTask'
// ─── 列表列配置 ─────────────────────────────────────────────────────────────
const columns = [
@ -417,6 +483,26 @@ const queryForm = reactive<{
const currentCondition = ref<any>({ store_use_status: 1 })
// ─── 操作日志状态 ──────────────────────────────────────────────────────────
const logLoading = ref(false)
const logList = ref<any[]>([])
const logPagination = reactive({ currentPage: 1, pageSize: 20, total: 0 })
// ─── 导出日志(异步任务) ──────────────────────────────────────────────────
const {
exportLoading,
exportDialogVisible,
exportTaskProgress,
exportProgressPercent,
exportProgressStatus,
exportStatusLabel,
submitExportTask
} = useAsyncExportTask({
storageKey: 'warehouses:exportLogsTaskId',
submitExport: (payload) => storeWarehouseExportStorePrintQuantityLogs(payload as any),
queryProgress: (params) => storeWarehouseExportStorePrintQuantityLogsTaskProgress(params)
})
// ─── 加载列表 ──────────────────────────────────────────────────────────────
async function loadList() {
loading.value = true
@ -782,6 +868,61 @@ async function copyText(text: string) {
}
}
// ─── 操作日志 ──────────────────────────────────────────────────────────────
async function loadLogs() {
if (!selectedRow.value?.id) return
logLoading.value = true
try {
const res = await storeWarehouseQueryStorePrintQuantityLogs({
where: { id: selectedRow.value.id },
pagination: {
page: logPagination.currentPage,
page_size: logPagination.pageSize
}
}) as any
if (res?.data) {
const payload = res.data
logList.value = payload.list || []
logPagination.total = payload.pagination?.total || payload.total || 0
}
} catch {
ElMessage.error('获取操作日志失败')
} finally {
logLoading.value = false
}
}
function handleLogSizeChange() {
logPagination.currentPage = 1
loadLogs()
}
// 监听 tab 切换,切换到操作日志时自动加载
watch(activeTab, (val) => {
if (val === 'logs' && selectedRow.value) {
logPagination.currentPage = 1
loadLogs()
}
})
watch(selectedRow, (row) => {
if (row && activeTab.value === 'logs') {
logPagination.currentPage = 1
loadLogs()
}
})
// ─── 导出操作日志 ──────────────────────────────────────────────────────────
async function handleExportLogs() {
if (!selectedRow.value?.id) {
ElMessage.warning('请先选择一条签约记录')
return
}
await submitExportTask({
where: { id: selectedRow.value.id }
})
}
// ─── 初始化 ────────────────────────────────────────────────────────────────
onMounted(() => {
loadList()