Merge branch 'devlopment' of http://pms.dtyx.net:3000/wuxueyu/Industrial-image-management-system---web into devlopment
This commit is contained in:
commit
9d6086726d
|
@ -23,8 +23,8 @@ export interface EquipmentPageQuery {
|
|||
invoice?: string
|
||||
barcode?: string
|
||||
importer?: string
|
||||
page?: number
|
||||
pageSize?: number
|
||||
page?: number // 当前页码 - 与后端参数保持一致
|
||||
pageSize?: number // 每页大小
|
||||
orderBy?: string
|
||||
orderDirection?: string
|
||||
}
|
||||
|
|
|
@ -249,6 +249,19 @@ const pagination = reactive<any>({
|
|||
showPageSize: true,
|
||||
showJumper: true,
|
||||
showTotal: (total: number) => `共 ${total} 条记录`,
|
||||
pageSizeOptions: [10, 20, 50, 100], // 添加分页条数选项
|
||||
onChange: (page: number, pageSize: number) => {
|
||||
console.log('分页变化 - 页码:', page, '每页条数:', pageSize)
|
||||
pagination.current = page
|
||||
pagination.pageSize = pageSize
|
||||
loadData(currentSearchParams.value)
|
||||
},
|
||||
onPageSizeChange: (pageSize: number) => {
|
||||
console.log('每页条数变化:', pageSize)
|
||||
pagination.pageSize = pageSize
|
||||
pagination.current = 1 // 重置到第一页
|
||||
loadData(currentSearchParams.value)
|
||||
}
|
||||
})
|
||||
|
||||
// 弹窗控制
|
||||
|
@ -460,8 +473,8 @@ const loadData = async (searchParams?: EquipmentApprovalListReq) => {
|
|||
try {
|
||||
// 构建完整的请求参数 - 参考设备采购功能的实现
|
||||
const params: EquipmentApprovalListReq = {
|
||||
pageNum: pagination.current, // 修改为 pageNum,与后端期望的参数名一致
|
||||
pageSize: pagination.pageSize,
|
||||
page: pagination.current,
|
||||
...(searchParams || {}),
|
||||
}
|
||||
|
||||
|
@ -478,46 +491,52 @@ const loadData = async (searchParams?: EquipmentApprovalListReq) => {
|
|||
|
||||
console.log('API响应:', res)
|
||||
|
||||
// 处理不同的响应格式
|
||||
let dataList: any[] = []
|
||||
let total = 0
|
||||
if (res.code === 200 || res.success || res.status === 200) {
|
||||
let dataList: any[] = []
|
||||
let totalCount = 0
|
||||
|
||||
if (res && res.data) {
|
||||
if (Array.isArray(res.data)) {
|
||||
// 检查不同的数据字段 - 后端返回的是 PageResult 格式
|
||||
if ((res as any).rows && Array.isArray((res as any).rows)) {
|
||||
// 后端返回的是 PageResult 格式,数据在 rows 字段中
|
||||
dataList = (res as any).rows
|
||||
totalCount = (res as any).total || 0
|
||||
console.log('从 rows 字段获取数据,总数:', totalCount)
|
||||
} else if (Array.isArray(res.data)) {
|
||||
dataList = res.data
|
||||
total = res.data.length
|
||||
totalCount = (res as any).total || dataList.length || 0
|
||||
console.log('从 data 字段获取数据,总数:', totalCount)
|
||||
} else if (res.data && Array.isArray((res.data as any).records)) {
|
||||
dataList = (res.data as any).records
|
||||
total = (res.data as any).total || 0
|
||||
totalCount = (res.data as any).total || dataList.length || 0
|
||||
console.log('从 records 字段获取数据,总数:', totalCount)
|
||||
} else if (res.data && Array.isArray((res.data as any).list)) {
|
||||
dataList = (res.data as any).list
|
||||
total = (res.data as any).total || 0
|
||||
} else if (res.data && Array.isArray((res.data as any).rows)) {
|
||||
dataList = (res.data as any).rows
|
||||
total = (res.data as any).total || 0
|
||||
} else if (res.data && Array.isArray((res.data as any).data)) {
|
||||
dataList = (res.data as any).data
|
||||
total = (res.data as any).total || 0
|
||||
totalCount = (res.data as any).total || dataList.length || 0
|
||||
console.log('从 list 字段获取数据,总数:', totalCount)
|
||||
} else {
|
||||
console.warn('未找到有效的数据字段,响应结构:', res)
|
||||
dataList = []
|
||||
totalCount = 0
|
||||
}
|
||||
} else if (Array.isArray(res)) {
|
||||
dataList = res
|
||||
total = res.length
|
||||
}
|
||||
|
||||
console.log('处理后的数据列表:', dataList)
|
||||
console.log('总数:', total)
|
||||
if (dataList.length > 0) {
|
||||
const transformedData = transformBackendData(dataList)
|
||||
tableData.value = transformedData
|
||||
console.log('数据转换完成,设置到表格:', transformedData.length, '条')
|
||||
} else {
|
||||
tableData.value = []
|
||||
console.log('没有数据,清空表格')
|
||||
}
|
||||
|
||||
if (dataList.length > 0) {
|
||||
const transformedData = transformBackendData(dataList)
|
||||
console.log('转换后的数据:', transformedData)
|
||||
tableData.value = transformedData
|
||||
// 设置总数 - 优先使用后端返回的总数
|
||||
pagination.total = totalCount
|
||||
console.log('设置分页总数:', totalCount)
|
||||
} else {
|
||||
console.log('没有数据,设置空数组')
|
||||
console.error('请求失败,响应:', res)
|
||||
message.error(res.msg || (res as any).message || '加载数据失败')
|
||||
tableData.value = []
|
||||
pagination.total = 0
|
||||
}
|
||||
|
||||
pagination.total = total
|
||||
console.log('设置分页总数:', pagination.total)
|
||||
} catch (error: any) {
|
||||
console.error('加载数据失败:', error)
|
||||
message.error(error?.message || '加载数据失败')
|
||||
|
@ -525,7 +544,6 @@ const loadData = async (searchParams?: EquipmentApprovalListReq) => {
|
|||
pagination.total = 0
|
||||
} finally {
|
||||
loading.value = false
|
||||
console.log('📊 loadData - 加载完成')
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -119,7 +119,11 @@
|
|||
:loading="loading"
|
||||
:pagination="pagination"
|
||||
row-key="equipmentId"
|
||||
@change="handleTableChange"
|
||||
:scroll="{ x: 'max-content', y: 500 }"
|
||||
:bordered="false"
|
||||
:stripe="true"
|
||||
size="medium"
|
||||
table-layout="auto"
|
||||
>
|
||||
<template #equipmentType="{ record }">
|
||||
<a-tag :color="getEquipmentTypeColor(record.equipmentType)">
|
||||
|
@ -247,13 +251,44 @@ const tableData = ref<EquipmentResp[]>([])
|
|||
const loading = ref(false)
|
||||
|
||||
// 分页配置
|
||||
const pagination = reactive<any>({
|
||||
const pagination = reactive({
|
||||
current: 1,
|
||||
pageSize: 10,
|
||||
total: 0,
|
||||
showPageSize: true,
|
||||
showTotal: true,
|
||||
showJumper: true,
|
||||
showTotal: (total: number) => `共 ${total} 条记录`,
|
||||
showPageSize: true,
|
||||
pageSizeOptions: [10, 20, 50, 100],
|
||||
// 确保分页器完全可见
|
||||
hideOnSinglePage: false,
|
||||
// 分页器大小
|
||||
size: 'default',
|
||||
// 分页器位置
|
||||
position: 'bottom',
|
||||
// 分页事件处理
|
||||
onChange: (page: number, pageSize: number) => {
|
||||
console.log('🔄 分页变化事件触发:', { page, pageSize })
|
||||
console.log('📊 变化前分页状态:', {
|
||||
current: pagination.current,
|
||||
pageSize: pagination.pageSize,
|
||||
total: pagination.total
|
||||
})
|
||||
|
||||
pagination.current = page
|
||||
if (pageSize !== pagination.pageSize) {
|
||||
pagination.pageSize = pageSize
|
||||
pagination.current = 1 // 重置到第一页
|
||||
}
|
||||
|
||||
console.log('📊 变化后分页状态:', {
|
||||
current: pagination.current,
|
||||
pageSize: pagination.pageSize,
|
||||
total: pagination.total
|
||||
})
|
||||
|
||||
console.log('🚀 开始重新加载数据...')
|
||||
loadData(currentSearchParams.value)
|
||||
}
|
||||
})
|
||||
|
||||
// 弹窗控制
|
||||
|
@ -568,46 +603,101 @@ const transformBackendData = (data: any[]) => {
|
|||
const loadData = async (searchParams?: EquipmentPageQuery) => {
|
||||
loading.value = true
|
||||
try {
|
||||
// 构建请求参数,确保分页参数正确
|
||||
const params = {
|
||||
pageSize: pagination.pageSize,
|
||||
page: pagination.current,
|
||||
pageNum: pagination.current, // 当前页码 - 使用pageNum匹配后端期望
|
||||
pageSize: pagination.pageSize, // 每页条数
|
||||
...(searchParams || {}), // 添加搜索条件
|
||||
}
|
||||
|
||||
console.log('🚀 发送分页请求参数:', params)
|
||||
console.log('📊 当前分页状态:', {
|
||||
current: pagination.current,
|
||||
pageSize: pagination.pageSize,
|
||||
total: pagination.total
|
||||
})
|
||||
|
||||
const res = await EquipmentAPI.pageEquipment(params)
|
||||
|
||||
console.log('📡 后端响应数据:', res)
|
||||
|
||||
// 兼容不同的响应格式
|
||||
if (res.success || res.status === 200 || res.code === 200) {
|
||||
if (res.code === 200 || res.success || res.status === 200) {
|
||||
// 处理数据,确保数据格式正确
|
||||
let dataList: any[] = []
|
||||
let totalCount = 0
|
||||
|
||||
// 检查不同的数据字段
|
||||
if (Array.isArray(res.data)) {
|
||||
dataList = res.data
|
||||
} else if (res.data && Array.isArray((res.data as any).records)) {
|
||||
dataList = (res.data as any).records
|
||||
} else if (res.data && Array.isArray((res.data as any).list)) {
|
||||
dataList = (res.data as any).list
|
||||
} else if (res.data && Array.isArray((res.data as any).rows)) {
|
||||
dataList = (res.data as any).rows
|
||||
console.log('🔍 开始解析响应数据,响应结构:', res)
|
||||
|
||||
// 检查不同的数据字段 - 后端返回的是 PageResult 格式
|
||||
if ((res as any).rows && Array.isArray((res as any).rows)) {
|
||||
// 后端返回的是 PageResult 格式,数据在 rows 字段中
|
||||
dataList = (res as any).rows
|
||||
totalCount = (res as any).total || 0
|
||||
console.log('✅ 从 rows 字段获取数据,总数:', totalCount, '当前页数据:', dataList.length)
|
||||
} else if ((res as any).data && Array.isArray((res as any).data)) {
|
||||
dataList = (res as any).data
|
||||
totalCount = (res as any).total || dataList.length || 0
|
||||
console.log('✅ 从 data 字段获取数据,总数:', totalCount, '当前页数据:', dataList.length)
|
||||
} else if ((res as any).data && (res as any).data.rows && Array.isArray((res as any).data.rows)) {
|
||||
// 嵌套结构:res.data.rows 和 res.data.total
|
||||
dataList = (res as any).data.rows
|
||||
totalCount = (res as any).data.total || 0
|
||||
console.log('✅ 从嵌套 data.rows 字段获取数据,总数:', totalCount, '当前页数据:', dataList.length)
|
||||
} else if ((res as any).data && Array.isArray(((res as any).data as any).records)) {
|
||||
dataList = ((res as any).data as any).records
|
||||
totalCount = (((res as any).data as any).total) || dataList.length || 0
|
||||
console.log('✅ 从 records 字段获取数据,总数:', totalCount, '当前页数据:', dataList.length)
|
||||
} else if ((res as any).data && Array.isArray(((res as any).data as any).list)) {
|
||||
dataList = ((res as any).data as any).list
|
||||
totalCount = (((res as any).data as any).total) || dataList.length || 0
|
||||
console.log('✅ 从 list 字段获取数据,总数:', totalCount, '当前页数据:', dataList.length)
|
||||
} else {
|
||||
console.warn('⚠️ 未找到有效的数据字段,响应结构:', res)
|
||||
dataList = []
|
||||
totalCount = 0
|
||||
}
|
||||
|
||||
// 临时解决方案:如果后端没有返回total但有数据,使用当前页数据长度作为总数
|
||||
if (dataList.length > 0 && totalCount === 0) {
|
||||
totalCount = dataList.length
|
||||
console.log('⚠️ 后端未返回total,使用当前页数据长度作为总数:', totalCount)
|
||||
}
|
||||
|
||||
// 如果后端返回了数据但total为0,说明后端分页逻辑有问题
|
||||
if (dataList.length > 0 && totalCount === 0) {
|
||||
console.warn('🚨 后端分页逻辑问题:返回了数据但total为0,使用当前页数据长度作为总数')
|
||||
totalCount = dataList.length
|
||||
}
|
||||
|
||||
if (dataList.length > 0) {
|
||||
const transformedData = transformBackendData(dataList)
|
||||
|
||||
tableData.value = transformedData
|
||||
console.log('✅ 数据转换完成,设置到表格:', transformedData.length, '条')
|
||||
} else {
|
||||
tableData.value = []
|
||||
console.log('ℹ️ 没有数据,清空表格')
|
||||
}
|
||||
|
||||
// 设置总数
|
||||
pagination.total = (res.data as any)?.total || (res as any).total || dataList.length || 0
|
||||
// 设置总数 - 优先使用后端返回的总数
|
||||
pagination.total = totalCount
|
||||
console.log('📊 设置分页总数:', totalCount)
|
||||
console.log('📊 分页组件状态:', {
|
||||
current: pagination.current,
|
||||
pageSize: pagination.pageSize,
|
||||
total: pagination.total
|
||||
})
|
||||
} else {
|
||||
message.error(res.msg || '加载数据失败')
|
||||
console.error('❌ 请求失败,响应:', res)
|
||||
message.error((res as any).msg || (res as any).message || '加载数据失败')
|
||||
tableData.value = []
|
||||
pagination.total = 0
|
||||
}
|
||||
} catch (error: any) {
|
||||
console.error('加载数据失败:', error)
|
||||
console.error('❌ 加载数据失败:', error)
|
||||
message.error(error?.message || '加载数据失败')
|
||||
tableData.value = []
|
||||
pagination.total = 0
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
|
@ -631,11 +721,42 @@ const handleReset = () => {
|
|||
|
||||
// 表格变化
|
||||
const handleTableChange = (pag: any) => {
|
||||
pagination.current = pag.current || 1
|
||||
pagination.pageSize = pag.pageSize || 10
|
||||
console.log('表格变化,分页参数:', pag) // 添加调试日志
|
||||
|
||||
// 更新分页配置
|
||||
if (pag.current !== undefined) {
|
||||
pagination.current = pag.current
|
||||
}
|
||||
if (pag.pageSize !== undefined) {
|
||||
pagination.pageSize = pag.pageSize
|
||||
}
|
||||
|
||||
console.log('更新分页配置:', {
|
||||
current: pagination.current,
|
||||
pageSize: pagination.pageSize
|
||||
})
|
||||
|
||||
// 重新加载数据
|
||||
loadData(currentSearchParams.value)
|
||||
}
|
||||
|
||||
// 分页变化 - 已移至分页配置中处理
|
||||
// const handlePageChange = (page: number) => {
|
||||
// console.log('页码变化:', page)
|
||||
// pagination.current = page
|
||||
// loadData(currentSearchParams.value)
|
||||
// }
|
||||
|
||||
// 每页条数变化 - 已移至分页配置中处理
|
||||
// const handlePageSizeChange = (pageSize: number) => {
|
||||
// console.log('每页条数变化:', pageSize)
|
||||
// pagination.pageSize = pageSize
|
||||
// pagination.current = 1 // 重置到第一页
|
||||
// loadData(currentSearchParams.value)
|
||||
// }
|
||||
|
||||
|
||||
|
||||
// 新增
|
||||
const handleAdd = () => {
|
||||
modalMode.value = 'add'
|
||||
|
@ -920,7 +1041,8 @@ onMounted(() => {
|
|||
.table-card {
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
|
||||
overflow: hidden;
|
||||
overflow: visible; // 改为 visible,允许内容溢出
|
||||
min-height: 600px; // 设置最小高度,确保有足够的滚动空间
|
||||
|
||||
.card-title {
|
||||
display: flex;
|
||||
|
@ -943,6 +1065,11 @@ onMounted(() => {
|
|||
}
|
||||
|
||||
.arco-table {
|
||||
// 确保表格可以正常滚动
|
||||
.arco-table-container {
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
.arco-table-th {
|
||||
background: var(--color-fill-2);
|
||||
font-weight: 600;
|
||||
|
@ -956,6 +1083,12 @@ onMounted(() => {
|
|||
.arco-table-tr:hover {
|
||||
background: var(--color-fill-1);
|
||||
}
|
||||
|
||||
// 确保表格可以正常滚动
|
||||
.arco-table-body {
|
||||
overflow-y: auto;
|
||||
max-height: 500px; // 设置最大高度,确保可以滚动
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1003,6 +1136,7 @@ onMounted(() => {
|
|||
.arco-pagination {
|
||||
margin-top: 24px;
|
||||
justify-content: center;
|
||||
padding: 16px 0;
|
||||
|
||||
.arco-pagination-item {
|
||||
border-radius: 6px;
|
||||
|
@ -1013,6 +1147,14 @@ onMounted(() => {
|
|||
border-color: var(--color-primary);
|
||||
}
|
||||
}
|
||||
|
||||
.arco-pagination-size-changer {
|
||||
margin-left: 16px;
|
||||
}
|
||||
|
||||
.arco-pagination-jumper {
|
||||
margin-left: 16px;
|
||||
}
|
||||
}
|
||||
|
||||
// 响应式设计
|
||||
|
|
|
@ -277,6 +277,19 @@ const pagination = reactive<any>({
|
|||
showPageSize: true,
|
||||
showJumper: true,
|
||||
showTotal: (total: number) => `共 ${total} 条记录`,
|
||||
pageSizeOptions: [10, 20, 50, 100], // 添加分页条数选项
|
||||
onChange: (page: number, pageSize: number) => {
|
||||
console.log('分页变化 - 页码:', page, '每页条数:', pageSize)
|
||||
pagination.current = page
|
||||
pagination.pageSize = pageSize
|
||||
loadData(currentSearchParams.value)
|
||||
},
|
||||
onPageSizeChange: (pageSize: number) => {
|
||||
console.log('每页条数变化:', pageSize)
|
||||
pagination.pageSize = pageSize
|
||||
pagination.current = 1 // 重置到第一页
|
||||
loadData(currentSearchParams.value)
|
||||
}
|
||||
})
|
||||
|
||||
// 弹窗控制
|
||||
|
@ -592,31 +605,52 @@ const loadData = async (searchParams?: EquipmentListReq) => {
|
|||
|
||||
loading.value = true
|
||||
try {
|
||||
// 构建请求参数,确保分页参数正确
|
||||
const params: EquipmentListReq = {
|
||||
pageSize: pagination.pageSize,
|
||||
page: pagination.current,
|
||||
pageNum: pagination.current, // 当前页码
|
||||
pageSize: pagination.pageSize, // 每页条数
|
||||
minPrice: undefined,
|
||||
maxPrice: undefined,
|
||||
...(searchParams || {}),
|
||||
}
|
||||
|
||||
console.log('📊 loadData - 构建的完整请求参数:', params)
|
||||
console.log('📊 当前分页状态:', {
|
||||
current: pagination.current,
|
||||
pageSize: pagination.pageSize,
|
||||
total: pagination.total
|
||||
})
|
||||
|
||||
const res = await equipmentProcurementApi.page(params)
|
||||
|
||||
console.log('API响应:', res)
|
||||
|
||||
if (res.success || res.status === 200 || res.code === 200) {
|
||||
if (res.code === 200 || res.success || res.status === 200) {
|
||||
let dataList: any[] = []
|
||||
let totalCount = 0
|
||||
|
||||
if (Array.isArray(res.data)) {
|
||||
// 检查不同的数据字段 - 后端返回的是 PageResult 格式
|
||||
if ((res as any).rows && Array.isArray((res as any).rows)) {
|
||||
// 后端返回的是 PageResult 格式,数据在 rows 字段中
|
||||
dataList = (res as any).rows
|
||||
totalCount = (res as any).total || 0
|
||||
console.log('✅ 从 rows 字段获取数据,总数:', totalCount, '当前页数据:', dataList.length)
|
||||
} else if (Array.isArray(res.data)) {
|
||||
dataList = res.data
|
||||
totalCount = (res as any).total || dataList.length || 0
|
||||
console.log('✅ 从 data 字段获取数据,总数:', totalCount, '当前页数据:', dataList.length)
|
||||
} else if (res.data && Array.isArray((res.data as any).records)) {
|
||||
dataList = (res.data as any).records
|
||||
totalCount = (res.data as any).total || dataList.length || 0
|
||||
console.log('✅ 从 records 字段获取数据,总数:', totalCount, '当前页数据:', dataList.length)
|
||||
} else if (res.data && Array.isArray((res.data as any).list)) {
|
||||
dataList = (res.data as any).list
|
||||
} else if (res.data && Array.isArray((res.data as any).rows)) {
|
||||
dataList = (res.data as any).rows
|
||||
totalCount = (res.data as any).total || dataList.length || 0
|
||||
console.log('✅ 从 list 字段获取数据,总数:', totalCount, '当前页数据:', dataList.length)
|
||||
} else {
|
||||
console.warn('⚠️ 未找到有效的数据字段,响应结构:', res)
|
||||
dataList = []
|
||||
totalCount = 0
|
||||
}
|
||||
|
||||
console.log('处理后的数据列表:', dataList)
|
||||
|
@ -633,14 +667,25 @@ const loadData = async (searchParams?: EquipmentListReq) => {
|
|||
tableData.value = []
|
||||
}
|
||||
|
||||
pagination.total = (res.data as any)?.total || (res as any).total || dataList.length || 0
|
||||
console.log('总数:', pagination.total)
|
||||
// 设置总数 - 优先使用后端返回的总数
|
||||
pagination.total = totalCount
|
||||
console.log('📊 总数:', totalCount)
|
||||
console.log('📊 分页组件状态:', {
|
||||
current: pagination.current,
|
||||
pageSize: pagination.pageSize,
|
||||
total: pagination.total
|
||||
})
|
||||
} else {
|
||||
message.error(res.msg || '加载数据失败')
|
||||
console.error('❌ 请求失败,响应:', res)
|
||||
message.error(res.msg || (res as any).message || '加载数据失败')
|
||||
tableData.value = []
|
||||
pagination.total = 0
|
||||
}
|
||||
} catch (error: any) {
|
||||
console.error('加载数据失败:', error)
|
||||
console.error('❌ 加载数据失败:', error)
|
||||
message.error(error?.message || '加载数据失败')
|
||||
tableData.value = []
|
||||
pagination.total = 0
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue