220 lines
5.2 KiB
Vue
220 lines
5.2 KiB
Vue
<template>
|
||
<div class="order-management-wrapper" :style="{ height: containerHeight }">
|
||
<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>
|
||
<keep-alive>
|
||
<component
|
||
:is="tab.component"
|
||
:key="tab.name"
|
||
v-if="activeTab === tab.name"
|
||
v-bind="tab.props || {}"
|
||
/>
|
||
</keep-alive>
|
||
</el-tab-pane>
|
||
</el-tabs>
|
||
</div>
|
||
</template>
|
||
|
||
<script setup lang="ts">
|
||
import { ref, watch, computed, markRaw } from 'vue'
|
||
import { useRoute, useRouter } 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'
|
||
|
||
const route = useRoute()
|
||
const router = useRouter()
|
||
const settingsStore = useSettingsStore()
|
||
|
||
const shortcutExpanded = computed(() => settingsStore.shortcutExpanded)
|
||
const containerHeight = computed(() => shortcutExpanded.value ? 'calc(100vh - 150px)' : 'calc(100vh - 100px)')
|
||
|
||
const activeTab = ref('groupWave')
|
||
|
||
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 与当前页签。
|
||
* 注意:布局层 AppMain 使用 route.fullPath 作为 router-view 的 key,
|
||
* 若在「无 tab 参数」的首屏强制 router.replace 补上 ?tab=,会改变 fullPath 导致整页销毁重建,
|
||
* 波次页签子组件会挂载两次并重复请求。缺省团购页签时只更新本地 activeTab,不写回路由。
|
||
*/
|
||
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'
|
||
if (raw && !validTabs.includes(raw)) {
|
||
router.replace({
|
||
query: {
|
||
...route.query,
|
||
tab: 'groupWave'
|
||
}
|
||
})
|
||
}
|
||
},
|
||
{ immediate: true }
|
||
)
|
||
|
||
const handleTabChange = (tabName: string | number) => {
|
||
safeInvoke(() => {
|
||
const name = String(tabName)
|
||
if (String(route.query.tab ?? '') === name) {
|
||
return
|
||
}
|
||
router.replace({
|
||
query: {
|
||
...route.query,
|
||
tab: name
|
||
}
|
||
})
|
||
})
|
||
}
|
||
</script>
|
||
|
||
<style lang="scss" scoped>
|
||
.order-management-wrapper {
|
||
position: relative;
|
||
width: 100%;
|
||
overflow: hidden;
|
||
}
|
||
|
||
.tab-container {
|
||
display: flex;
|
||
flex-direction: column;
|
||
height: 100%;
|
||
|
||
: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) {
|
||
flex: 1;
|
||
overflow: auto;
|
||
position: relative;
|
||
|
||
.el-tab-pane {
|
||
height: 100%;
|
||
}
|
||
}
|
||
}
|
||
|
||
.custom-tab-label {
|
||
display: inline-flex;
|
||
align-items: center;
|
||
gap: 6px;
|
||
}
|
||
</style>
|