491 lines
15 KiB
Vue
491 lines
15 KiB
Vue
<template>
|
||
<div class="order-management-wrapper" :style="{ height: containerHeight }">
|
||
<!-- ===== 多标签模式:显示顶部多标签页 ===== -->
|
||
<template v-if="WAVEORDER2_PAGE_CONFIG.showTabArea && !WAVEORDER2_PAGE_CONFIG.singlePage">
|
||
<div class="tab-section">
|
||
<TabArea
|
||
:tabs="tabList"
|
||
:default-active="activeTabName"
|
||
@tab-change="handleTabChange"
|
||
/>
|
||
</div>
|
||
</template>
|
||
|
||
<!-- ===== 标签页隐藏时的提示条 ===== -->
|
||
<!-- <div
|
||
v-if="!WAVEORDER2_PAGE_CONFIG.showTabArea && !WAVEORDER2_PAGE_CONFIG.singlePage"
|
||
class="tab-hidden-bar"
|
||
>
|
||
<span class="tab-hidden-hint">多标签页区域已隐藏</span>
|
||
</div> -->
|
||
|
||
<!-- ===== 主内容区(结构与 waveOrder 子面板完全一致) ===== -->
|
||
<div class="tab-container main-container">
|
||
<div class="order-sub-container">
|
||
<scan-box
|
||
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">
|
||
<div class="toolbar">
|
||
<div class="toolbar-left">
|
||
<!-- 默认刷新按钮 -->
|
||
<el-button
|
||
v-if="currentTabConfig?.toolbar?.showRefresh !== false"
|
||
type="primary" size="small" @click="handleRefresh"
|
||
>
|
||
<el-icon><Refresh /></el-icon>
|
||
刷新
|
||
</el-button>
|
||
<!-- 自定义工具栏按钮 -->
|
||
<el-button
|
||
v-for="btn in currentToolbarButtons"
|
||
:key="btn.key"
|
||
:type="btn.type || ''"
|
||
size="small"
|
||
:disabled="btn.disabled"
|
||
@click="handleToolbarAction(btn.key)"
|
||
>
|
||
{{ btn.label }}
|
||
</el-button>
|
||
<!-- 默认导出按钮 -->
|
||
<el-button
|
||
v-if="currentTabConfig?.toolbar?.showExport !== false"
|
||
size="small" @click="handleExport"
|
||
>
|
||
导出
|
||
</el-button>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="split-stack" ref="splitStackRef">
|
||
<div class="upper-wrapper" :style="detailVisible ? upperPaneStyle : upperPaneFullStyle">
|
||
<upper-table
|
||
ref="upperTableRef"
|
||
:title="currentTabConfig?.upperTable.title ?? '列表'"
|
||
default-align="center"
|
||
:enable-column-config="currentTabConfig?.upperTable.enableColumnConfig ?? true"
|
||
:column-config-schema-version="1"
|
||
:table-id="`wave-order2-table-${activeTabName}`"
|
||
:data="mockList"
|
||
: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="loadMockData"
|
||
@selection-change="handleSelectionChange"
|
||
>
|
||
<!-- 动态列插槽:根据列配置的 columnSlots 自动渲染 -->
|
||
<template
|
||
v-for="(slotConfig, colProp) in currentColumnSlots"
|
||
:key="`${columnSlotsKey}-${colProp}`"
|
||
#[`column-${colProp}`]="{ row }"
|
||
>
|
||
<ColumnCellRenderer
|
||
:config="slotConfig"
|
||
:value="row[colProp]"
|
||
/>
|
||
</template>
|
||
|
||
<template #empty>
|
||
<div class="empty-tip">{{ currentTabConfig?.upperTable.emptyText ?? '暂无数据' }}</div>
|
||
</template>
|
||
</upper-table>
|
||
</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 label="波次明细" name="detail" />
|
||
</el-tabs>
|
||
</div>
|
||
<div class="detail-container">
|
||
<component :is="currentDetailComponent" :row="selectedDetail" />
|
||
</div>
|
||
</div>
|
||
|
||
<div v-else class="no-selection" :style="lowerPaneStyle">
|
||
<div class="empty-tip">
|
||
<p>请从上方列表中选择一项查看详情</p>
|
||
</div>
|
||
</div>
|
||
</template>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</template>
|
||
|
||
<script setup lang="ts">
|
||
import { ref, computed, onMounted, reactive } from 'vue'
|
||
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 {
|
||
WAVEORDER2_PAGE_CONFIG,
|
||
waveOrder2Tabs,
|
||
waveOrder2TabPages,
|
||
resolveTabConfig
|
||
} from './config/waveorder-config'
|
||
import type { TabPageConfig } from './config/waveorder-config'
|
||
|
||
defineOptions({ name: 'WaveOrder2' })
|
||
|
||
const settingsStore = useSettingsStore()
|
||
|
||
// ===== 容器高度(与 waveOrder 一致) =====
|
||
const shortcutExpanded = computed(() => settingsStore.shortcutExpanded)
|
||
const containerHeight = computed(() => {
|
||
return shortcutExpanded.value
|
||
? 'calc(100vh - 150px)'
|
||
: 'calc(100vh - 100px)'
|
||
})
|
||
|
||
// ===== 标签页 =====
|
||
const tabList = ref(waveOrder2Tabs.map((t) => ({ name: t.name, label: t.label })))
|
||
const activeTabName = ref(waveOrder2Tabs[0]?.name ?? 'tab1')
|
||
|
||
/** 当前激活标签页的完整配置(运行时由 resolveTabConfig 展开 key 引用) */
|
||
const currentTabConfig = computed<TabPageConfig | undefined>(() => {
|
||
const raw = waveOrder2TabPages.find((t) => t.name === activeTabName.value)
|
||
if (!raw) return undefined
|
||
return resolveTabConfig(raw)
|
||
})
|
||
|
||
/** 当前标签页的 ScanBox 缓存 key */
|
||
const currentScanBoxCacheKey = computed(() => {
|
||
return currentTabConfig.value?.scanBoxCacheKey ?? 'wave-order2-default'
|
||
})
|
||
|
||
/** 当前标签页的 ScanBox 筛选字段 */
|
||
const currentScanBoxFields = computed(() => {
|
||
return currentTabConfig.value?.scanBoxFields ?? []
|
||
})
|
||
|
||
/** 当前标签页的表格列 */
|
||
const currentColumns = computed(() => {
|
||
return currentTabConfig.value?.upperTable.columns ?? []
|
||
})
|
||
|
||
/** 当前标签页的列插槽配置 */
|
||
const currentColumnSlots = computed(() => {
|
||
return currentTabConfig.value?.columnSlots ?? {}
|
||
})
|
||
|
||
/** 当前标签页的明细组件 */
|
||
const currentDetailComponent = computed(() => {
|
||
return currentTabConfig.value?.detailComponent ?? null
|
||
})
|
||
|
||
/** 当前标签页的自定义工具栏按钮 */
|
||
const currentToolbarButtons = computed(() => {
|
||
return currentTabConfig.value?.toolbar?.left ?? []
|
||
})
|
||
|
||
/** 切换标签页时重置状态并加载新数据 */
|
||
const handleTabChange = (tabName: string) => {
|
||
if (activeTabName.value === tabName) return
|
||
activeTabName.value = tabName
|
||
// 重置分页和选中状态
|
||
pagination.currentPage = 1
|
||
selectedRow.value = null
|
||
selectedDetail.value = null
|
||
selectedRows.value = []
|
||
loadMockData()
|
||
}
|
||
|
||
// ===== ScanBox =====
|
||
const scanBoxRef = ref<any>(null)
|
||
const presetTree = ref<any[]>([])
|
||
|
||
const handleConditionChange = () => {
|
||
pagination.currentPage = 1
|
||
loadMockData()
|
||
}
|
||
|
||
const handleConditionReset = () => {
|
||
pagination.currentPage = 1
|
||
loadMockData()
|
||
}
|
||
|
||
const handleConditionClear = () => {
|
||
pagination.currentPage = 1
|
||
loadMockData()
|
||
}
|
||
|
||
// ===== 模拟数据 =====
|
||
const mockList = ref<Record<string, any>[]>([])
|
||
const loading = ref(false)
|
||
const queryTime = ref(0)
|
||
|
||
const pagination = reactive({
|
||
currentPage: 1,
|
||
pageSize: 20,
|
||
total: 0
|
||
})
|
||
|
||
const loadMockData = () => {
|
||
const cfg = currentTabConfig.value
|
||
if (!cfg) return
|
||
loading.value = true
|
||
const startTime = performance.now()
|
||
|
||
setTimeout(() => {
|
||
const full = cfg.mock.generateList(50)
|
||
const { currentPage, pageSize } = pagination
|
||
const start = (currentPage - 1) * pageSize
|
||
mockList.value = full.slice(start, start + pageSize)
|
||
pagination.total = full.length
|
||
loading.value = false
|
||
queryTime.value = Math.round(performance.now() - startTime)
|
||
}, 200)
|
||
}
|
||
|
||
const handlePageChange = (page: number) => {
|
||
pagination.currentPage = page
|
||
loadMockData()
|
||
}
|
||
|
||
const handlePageSizeChange = (size: number) => {
|
||
pagination.pageSize = size
|
||
pagination.currentPage = 1
|
||
loadMockData()
|
||
}
|
||
|
||
// ===== 工具栏 =====
|
||
const handleRefresh = () => {
|
||
pagination.currentPage = 1
|
||
loadMockData()
|
||
}
|
||
|
||
const handleExport = () => {
|
||
console.log('[WaveOrder2] 导出数据', activeTabName.value)
|
||
}
|
||
|
||
/** 自定义工具栏按钮点击 */
|
||
const handleToolbarAction = (key: string) => {
|
||
console.log('[WaveOrder2] 工具栏操作:', key, activeTabName.value)
|
||
// 各标签页可在此扩展处理逻辑
|
||
switch (key) {
|
||
case 'batchAssign': // 示例:批量分配
|
||
console.log('批量分配选中行:', selectedRows.value)
|
||
break
|
||
default:
|
||
break
|
||
}
|
||
}
|
||
|
||
// ===== UpperTable =====
|
||
const upperTableRef = ref<any>(null)
|
||
const selectedRows = ref<Record<string, any>[]>([])
|
||
|
||
const handleSelectionChange = (rows: Record<string, any>[]) => {
|
||
selectedRows.value = rows
|
||
}
|
||
|
||
// ===== 明细面板 =====
|
||
const detailVisible = ref(true)
|
||
const selectedRow = ref<Record<string, any> | null>(null)
|
||
const selectedDetail = ref<Record<string, any> | null>(null)
|
||
const activeDetailTab = ref('detail')
|
||
|
||
const handleRowClick = (row: Record<string, any>) => {
|
||
const cfg = currentTabConfig.value
|
||
if (!cfg) return
|
||
selectedRow.value = row
|
||
selectedDetail.value = cfg.mock.generateDetail(row)
|
||
}
|
||
|
||
// ===== 分栏拖拽(使用 useVerticalSplitPane,与 waveOrder 一致) =====
|
||
const { splitStackRef, beginSplitDrag, lowerPaneStyle, upperPaneStyle } = useVerticalSplitPane({
|
||
defaultLowerPercent: 38
|
||
})
|
||
|
||
const upperPaneFullStyle = computed(() => ({
|
||
flex: '1 1 auto',
|
||
minHeight: '0',
|
||
overflow: 'hidden' as const
|
||
}))
|
||
|
||
// ===== 初始化 & 标签页切换时重新加载 =====
|
||
onMounted(() => {
|
||
loadMockData()
|
||
})
|
||
|
||
// 当 currentTabConfig 变化(如列配置变更)时,列插槽的 key 也会变,触发重新渲染
|
||
const columnSlotsKey = computed(() => {
|
||
return `${activeTabName.value}-${Object.keys(currentColumnSlots.value).join(',')}`
|
||
})
|
||
</script>
|
||
|
||
<style lang="scss" scoped>
|
||
/* ===== 引入 waveOrder 共享样式(scan-box / toolbar / split-stack / pane-resizer / lower-level 等) ===== */
|
||
@use "../orderManagement/styles/order-sub.scss";
|
||
|
||
/* ================================================================
|
||
整体布局容器
|
||
================================================================ */
|
||
.order-management-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;
|
||
}
|
||
|
||
.tab-hidden-bar {
|
||
flex-shrink: 0;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
padding: 4px 16px;
|
||
background: #fff;
|
||
border: 1px dashed #dcdfe6;
|
||
border-bottom: none;
|
||
border-radius: 6px 6px 0 0;
|
||
|
||
.tab-hidden-hint {
|
||
font-size: 12px;
|
||
color: #909399;
|
||
}
|
||
}
|
||
|
||
/* ================================================================
|
||
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;
|
||
}
|
||
|
||
/* ================================================================
|
||
3. ScanBox"筛选/过滤"标签样式(对齐页面顶部 TabArea 风格)
|
||
================================================================ */
|
||
.main-container {
|
||
:deep(.scan-box-container .scan-tabs) {
|
||
flex-shrink: 0;
|
||
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;
|
||
}
|
||
}
|
||
|
||
/* ================================================================
|
||
补充:工具栏信息文字
|
||
================================================================ */
|
||
.toolbar-info {
|
||
font-size: 12px;
|
||
color: #909399;
|
||
white-space: nowrap;
|
||
}
|
||
|
||
/* ================================================================
|
||
补充:空提示样式
|
||
================================================================ */
|
||
.empty-tip {
|
||
text-align: center;
|
||
font-size: 13px;
|
||
color: #909399;
|
||
line-height: 1.5;
|
||
}
|
||
|
||
/* ================================================================
|
||
无选中行时的占位(与 waveOrder 保持一致)
|
||
================================================================ */
|
||
.no-selection {
|
||
flex: 0 0 38%;
|
||
height: 38%;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
border-top: 1px solid #ebeef5;
|
||
overflow: hidden;
|
||
background-color: #fff;
|
||
}
|
||
</style> |