- 新增 router/view-glob.ts,动态菜单兜底的全量 glob 表改为按需动态加载, 入口 chunk 由 465KB 降至 393KB;Sidebar / TaskView 用 utils/path 的 resolveRoutePath 替换 path-browserify 静态引用 - 新增 utils/perf-probe 轻量探针(?perf=1 或 localStorage 开启),输出导航耗时、 资源分类统计、长任务与硬件信息;移除 text-rendering: optimizeLegibility, breadcrumb 过渡由 all 改为 opacity/transform,降低弱 CPU 与非 Chrome 内核开销 - Navbar 工单角标轮询在后台标签页跳过,通过 visibilitychange 回到前台补刷一次 - 库存详情、货位、条码、入库日志、出库日志与明细、收货日志、盘点记录等 详情面板由 el-table 迁移到 UpperTable,统一展开行、分页、选择与列插槽 - 11 处模板配置及内嵌表格开启行选择;转储、转退货、批量复核弹窗改用 SelectedTags 展示已选项并支持逐个移除,移除最后一个后自动关闭 - ImagesUpload 重构为「图库 + 上传区」面板,支持多选、最多 20 张、 单张 10MB 校验与数量提示 - 新增《跨浏览器性能-分析与优化清单》文档
723 lines
26 KiB
Vue
723 lines
26 KiB
Vue
<!--
|
||
╔══════════════════════════════════════════════════════════════╗
|
||
║ 【页面模板 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"
|
||
page-key="mode"
|
||
@tab-change="handleTabChange"
|
||
/>
|
||
</div>
|
||
</template>
|
||
|
||
<!-- ===== 主内容区 ===== -->
|
||
<div class="main-container">
|
||
<div class="order-sub-container">
|
||
<!-- 左侧:ScanBox 筛选面板 -->
|
||
<ScanBox
|
||
ref="scanBoxRef"
|
||
:cache-key="currentScanBoxCacheKey"
|
||
width="220px"
|
||
: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 ?? 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"
|
||
>
|
||
<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/index.vue'
|
||
import { useTabOrder } from '@/composables/useTabOrder'
|
||
import ColumnCellRenderer from './components/ColumnCellRenderer.vue'
|
||
import OperationCellRenderer from './components/OperationCellRenderer.vue'
|
||
import OrderToolbarButtonGroup from '@/components/ToolbarButtonGroup/index.vue'
|
||
import type { ToolbarButtonConfig as OrderToolbarButtonConfig } from '@/components/ToolbarButtonGroup/types'
|
||
import {
|
||
PAGE_CONFIG,
|
||
tabPages,
|
||
resolveTabConfig,
|
||
getTabToolbarButtons,
|
||
type TabPageConfig,
|
||
type DetailTabConfig,
|
||
type ToolbarButtonConfig,
|
||
} from './config/template-config'
|
||
|
||
// ============================================================
|
||
// 容器高度
|
||
// ============================================================
|
||
const settingsStore = useSettingsStore()
|
||
const containerHeight = computed(() =>
|
||
'100%' /* 高度由布局层(.app-router-page 的 flex:1)提供,不再自己算 vh */
|
||
)
|
||
|
||
// ============================================================
|
||
// 标签页
|
||
// ============================================================
|
||
const tabList = computed(() =>
|
||
tabPages.map((t) => ({ name: t.name, label: t.label }))
|
||
)
|
||
const { defaultTabName } = useTabOrder('mode', () =>
|
||
tabPages.map((tab) => ({ name: tab.name, label: tab.label }))
|
||
)
|
||
const activeTabName = ref(defaultTabName.value || 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>
|
||
/* 布局样式对齐 @/styles/list-page.scss */
|
||
@use "@/styles/list-page.scss";
|
||
|
||
/* 详情区外壳与 stock/external_stock 一致:不留上/下间距,左右 10px,
|
||
由各详情面板自身 padding 控制上下留白 */
|
||
.order-sub-container .main-content .lower-level .detail-container {
|
||
padding: 0 10px;
|
||
}
|
||
|
||
/* ================================================================
|
||
整体布局
|
||
================================================================ */
|
||
.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;
|
||
}
|
||
|
||
.tab-content-inner {
|
||
flex: 1;
|
||
display: flex;
|
||
flex-direction: column;
|
||
min-height: 0;
|
||
}
|
||
|
||
/* 分栏区域:布局样式由 @/styles/list-page.scss 提供,此处仅补充模板特有规则 */
|
||
.split-stack {
|
||
:deep(.el-card__header) {
|
||
padding: 2px 12px;
|
||
font-size: 13px;
|
||
}
|
||
}
|
||
|
||
/* ================================================================
|
||
6. 过渡动画
|
||
================================================================ */
|
||
.tab-fade-enter-active,
|
||
.tab-fade-leave-active {
|
||
/* 与 orderManagement / waveOrder 统一:0.12s */
|
||
transition: opacity 0.12s ease;
|
||
opacity: 1;
|
||
}
|
||
|
||
.tab-fade-enter-from,
|
||
.tab-fade-leave-to {
|
||
opacity: 0;
|
||
}
|
||
|
||
/* ================================================================
|
||
7. 空状态
|
||
================================================================ */
|
||
.empty-tip {
|
||
font-size: 13px;
|
||
color: #909399;
|
||
}
|
||
</style>
|