yin 6838d69788 perf(app): 详情面板统一迁移 UpperTable,路由按需加载并优化跨浏览器性能
- 新增 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 校验与数量提示
- 新增《跨浏览器性能-分析与优化清单》文档
2026-11-11 18:00:42 +08:00

272 lines
6.5 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="log-container">
<div class="header-actions">
<div class="left-actions">
<el-button
size="small"
type="primary"
:loading="loading"
:disabled="!props.id"
@click="fetchReceivingLogs"
>
刷新
</el-button>
</div>
<div class="right-actions">
<span v-if="selectedRows.length" class="selection-text">
已选 {{ selectedRows.length }} 项
</span>
</div>
</div>
<div class="table-host">
<upper-table
table-id="storage-receiving-operation-logs"
:data="tableData"
:columns="columns"
default-align="center"
table-size="small"
:show-selection="true"
:pagination="pagination"
:page-sizes="[10, 20, 50, 100]"
:loading="loading"
:query-time="queryTime"
empty-text="暂无操作日志"
@page-change="handlePageChange"
@page-size-change="handlePageSizeChange"
@selection-change="handleSelectionChange"
>
<template #column-actions="{ row }">
<el-button
v-if="row.external_log_id"
type="primary"
link
size="small"
@click.stop="viewData(row)"
>
查看报文
</el-button>
<el-button
v-if="row.operation_code === 'UPDATE'"
type="primary"
link
size="small"
@click.stop="backData(row)"
>
修改前快照
</el-button>
</template>
</upper-table>
</div>
<el-drawer
v-model="showRequestData"
direction="rtl"
:with-header="false"
size="800px"
class="el-drawers"
>
<RequestData
v-if="showRequestData"
:id="requestId"
:type="requestType"
/>
</el-drawer>
</div>
</template>
<script setup lang="ts">
import { ref, reactive, watch } from 'vue'
import { ElMessage } from 'element-plus'
import * as receivingApi from '@/api/storage_receiving/receiving'
import UpperTable from '@/components/UpperTable/index.vue'
import RequestData from '@/components/RequestData/index.vue'
const props = defineProps<{
id?: number | string
}>()
const loading = ref(false)
const tableData = ref<any[]>([])
const showRequestData = ref(false)
const requestId = ref(0)
const requestType = ref('')
const queryTime = ref(0)
/** 表格勾选行(UpperTable selection-change) */
const selectedRows = ref<Record<string, any>[]>([])
function handleSelectionChange(rows: Record<string, any>[]) {
selectedRows.value = rows
}
/** 列配置与「商品明细」一致:default-align="center"、small 尺寸、操作列固定右侧 */
const columns = [
{ prop: 'created_at', label: '时间', width: 250 },
{ prop: 'operator_name', label: '操作人', width: 120 },
{ prop: 'operation_name', label: '操作名称' },
{ prop: 'platform_name', label: '操作平台' },
{ prop: 'actions', label: '操作', width: 150, fixed: 'right' }
]
const pagination = reactive({
currentPage: 1,
pageSize: 20,
total: 0
})
watch(() => props.id, (newVal) => {
if (newVal) {
pagination.currentPage = 1
fetchReceivingLogs()
} else {
tableData.value = []
pagination.total = 0
}
}, { immediate: true })
async function handlePageChange(page: number) {
pagination.currentPage = page
await fetchReceivingLogs()
}
async function handlePageSizeChange(pageSize: number) {
pagination.pageSize = pageSize
pagination.currentPage = 1
await fetchReceivingLogs()
}
async function fetchReceivingLogs() {
if (!props.id) return
loading.value = true
const start = Date.now()
try {
const res: any = await receivingApi.queryReceivingLogs({
receiving_id: props.id,
pagination: {
page: pagination.currentPage,
pageSize: pagination.pageSize
}
})
if (res && (res.code === 200 || res.code === 0 || res.code === 1)) {
const data = res.data || {}
tableData.value = Array.isArray(data.list) ? data.list : []
pagination.currentPage = data.pagination?.page ?? pagination.currentPage
pagination.pageSize = data.pagination?.pageSize ?? pagination.pageSize
pagination.total = data.pagination?.total ?? 0
} else {
tableData.value = []
pagination.total = 0
ElMessage.error(res?.message || '获取收货单操作日志失败')
}
} catch (error: any) {
console.error('获取收货单操作日志失败', error)
tableData.value = []
pagination.total = 0
ElMessage.error(error?.message || '获取收货单操作日志失败')
} finally {
loading.value = false
queryTime.value = Date.now() - start
}
}
function viewData(row: any) {
requestId.value = Number(row.external_log_id) || 0
requestType.value = row.external_log_type
showRequestData.value = true
}
function backData(row: any) {
}
</script>
<style scoped lang="scss">
/* 样式对齐 stock/external_stock「外部绑定」新样式:
header-actions(按钮行,间距 6px 对齐 toolbar) + table-host(自适应剩余高度) + 右对齐分页 */
.log-container {
width: 100%;
height: 100%;
padding: 6px 10px 8px;
overflow: hidden;
display: flex;
flex-direction: column;
background: #fff;
box-sizing: border-box;
}
.header-actions {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 6px;
flex-shrink: 0;
gap: 4px;
flex-wrap: wrap;
}
.left-actions {
display: flex;
align-items: center;
gap: 6px;
/* 清除 Element Plus 默认按钮左边距,统一由 gap 控制等间距 */
:deep(.el-button) {
margin-left: 0;
margin-right: 0;
}
}
.right-actions {
display: flex;
align-items: center;
gap: 8px;
.selection-text {
font-size: 12px;
color: #409eff;
}
}
.table-host {
flex: 1;
min-height: 120px;
min-width: 0;
overflow: hidden;
display: flex;
flex-direction: column;
}
/* 与「商品明细」Product.vue 的 UpperTable 完全一致的容器/分页处理 */
.table-host :deep(.upper-table-container) {
height: 100%;
display: flex;
flex-direction: column;
overflow: hidden;
}
.table-host :deep(.table-container) {
flex: 1;
min-height: 0;
height: auto !important;
}
.table-host :deep(.pagination-container) {
flex-shrink: 0;
padding: 0;
border-top: none;
margin-top: 6px;
justify-content: flex-end;
}
.table-host :deep(.pagination-info) {
display: none;
}
:deep(.el-drawer__body) {
height: 100%;
padding: 0;
}
</style>