2026-08-29 18:16:18 +08:00

316 lines
8.2 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<div class="order-management-wrapper" :style="{ height: containerHeight }">
<!-- 多标签模式 -->
<template v-if="!singlePage">
<!-- 顶部多标签页区域(对齐 order/orderManagement 的 tab-section) -->
<div class="tab-section">
<div class="tabs-header-action">
<!-- <el-button size="small">操作按钮</el-button> -->
</div>
<el-tabs
v-model="activeTab"
@tab-change="handleTabChange"
tab-position="top"
type="border-card"
class="tab-container"
>
<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>
<!-- 主内容区容器(对齐 order/orderManagement 的 main-container) -->
<div class="main-container">
<transition name="tab-fade" mode="out-in">
<keep-alive>
<component
:is="activeComponent"
:key="activeTab"
v-bind="activeTabProps"
/>
</keep-alive>
</transition>
</div>
</template>
<!-- 单页模式:直接渲染默认页签组件,复用 .tab-container 样式结构 -->
<div v-else class="tab-container single-page-container">
<keep-alive>
<component
:is="defaultTab.component"
:key="defaultTab.name"
v-bind="defaultTab.props || {}"
/>
</keep-alive>
</div>
</div>
</template>
<script setup lang="ts">
import { ref, watch, computed, markRaw } from 'vue'
import { useRoute } from 'vue-router'
import { useSettingsStore } from '@/stores/modules/settings'
import GroupWaveBatchListPanel from './GroupWaveBatchListPanel.vue'
import SandanWaveBatchListPanel from './SandanWaveBatchListPanel.vue'
import FallbackOrderListPanel from './FallbackOrderListPanel.vue'
import WaveStrategyListPanel from './WaveStrategyListPanel.vue'
import WavePickTaskListPanel from './WavePickTaskListPanel.vue'
import { safeInvoke } from '@/utils/safe-invoke'
import { WAVE_PAGE_CONFIG } from './config/wave-config'
const route = useRoute()
const settingsStore = useSettingsStore()
const shortcutExpanded = computed(() => settingsStore.shortcutExpanded)
const singlePage = WAVE_PAGE_CONFIG.singlePage
const containerHeight = computed(() => {
const baseH = shortcutExpanded.value ? 'calc(100vh - 150px)' : 'calc(100vh - 100px)'
return baseH
})
/** 单页模式下使用的默认标签(始终为 tabs 第一项) */
const defaultTab = computed(() => tabs.value[0]!)
const activeTab = ref('groupWave')
/** 当前激活页签对应的组件(渲染在主内容区 main-container 中,对齐 order/orderManagement) */
const activeComponent = computed(() => {
const tab = tabs.value.find((t) => t.name === activeTab.value)
return tab?.component
})
/** 当前激活页签对应的 props(对齐 order/orderManagement) */
const activeTabProps = computed(() => {
const tab = tabs.value.find((t) => t.name === activeTab.value)
return tab?.props || {}
})
type WaveTabItem = {
name: string
label: string
component: any
props?: Record<string, unknown>
}
const tabs = ref<WaveTabItem[]>([
{
name: 'groupWave',
label: '团购波次',
component: markRaw(GroupWaveBatchListPanel),
props: { scanBoxCacheKey: 'wave-order-group-wave' }
},
{
name: 'sandanWave',
label: '散单波次',
component: markRaw(SandanWaveBatchListPanel),
props: { scanBoxCacheKey: 'wave-order-sandan-wave' }
},
{
name: 'sandanFallbackOrders',
label: '不符合波次策略订单列表',
component: markRaw(FallbackOrderListPanel),
props: { scanBoxCacheKey: 'wave-order-sandan-fallback-orders' }
},
{
name: 'sandanWaveStrategy',
label: '波次策略',
component: markRaw(WaveStrategyListPanel),
props: { scanBoxCacheKey: 'wave-order-sandan-wave-strategy' }
},
{
name: 'pickTaskWave',
label: '拣货中任务',
component: markRaw(WavePickTaskListPanel),
props: { scanBoxCacheKey: 'wave-order-pick-task' }
}
])
/**
* 首屏 / 外部导航时从地址栏恢复 tab。
* 方案B:页签切换改为纯本地状态(handleTabChange 不写回路由),
* 因为布局层 AppMain 使用 route.fullPath 作为 router-view 的 key,
* 任何 URL 变化(含 ?tab=)都会触发整页销毁重建,导致切换卡顿、重复请求与显示闪烁。
* 此处仅:① 首屏按 URL 初始化;② 浏览器前进/后退等外部导航时同步本地 tab。
* 非法 / 缺失 tab 时纯本地归位到团购波次,绝不写回路由。
*/
watch(
() => route.query.tab,
(newTab) => {
const validTabs = tabs.value.map((t) => t.name)
const raw = newTab === undefined || newTab === null ? '' : String(newTab).trim()
if (raw && validTabs.includes(raw)) {
activeTab.value = raw
return
}
activeTab.value = 'groupWave'
},
{ immediate: true }
)
const handleTabChange = (tabName: string | number) => {
safeInvoke(() => {
const name = String(tabName)
// 方案B:纯本地切换,不写回路由(避免改变 fullPath 触发 AppMain 整页销毁重建)
if (activeTab.value === name) {
return
}
activeTab.value = name
})
}
</script>
<style lang="scss" scoped>
.order-management-wrapper {
position: relative;
width: 100%;
display: flex;
flex-direction: column;
overflow: hidden;
}
/* ===== 顶部多标签页区域(对齐 order/orderManagement 的 tab-section) ===== */
.tab-section {
flex-shrink: 0;
position: relative;
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;
}
.tabs-header-action {
position: absolute;
top: 4px;
right: 16px;
height: 38px;
display: flex;
align-items: center;
z-index: 2;
}
.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;
}
/* 隐藏内容区,仅展示标签头(对齐 order/orderManagement) */
:deep(.el-tabs__content) {
display: none;
}
}
.custom-tab-label {
display: inline-flex;
align-items: center;
gap: 6px;
}
/* ===== 主内容区容器(对齐 order/orderManagement 的 main-container) ===== */
.main-container {
flex: 1;
display: flex;
flex-direction: column;
min-height: 0;
background: #fff;
border: 1px solid #e8eef7;
border-top: none;
border-radius: 0 0 6px 6px;
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
overflow: hidden;
}
/* ========== 单页模式 ========== */
.single-page-container {
flex: 1;
min-height: 0;
background: #fff;
border: 1px solid #e8eef7;
border-radius: 6px;
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
overflow: hidden;
:deep(> *) {
flex: 1;
overflow: auto;
min-height: 0;
}
}
/* ===== 页签切换淡入淡出(对齐 storage/generalreport 的 tab-fade) ===== */
.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;
}
</style>