套餐设置套餐管理完善

This commit is contained in:
2026-01-28 14:26:41 +08:00
parent 41494ebf7c
commit 0cecf3bcad
11 changed files with 299 additions and 65 deletions

View File

@@ -182,12 +182,12 @@ const filteredAdviceBaseList = computed(() => {
if (!props.adviceQueryParams.searchKey) {
result = adviceBaseList.value.slice(0, 50); // 返回前50个常用项目
} else {
const searchKey = props.adviceQueryParams.searchKey.toLowerCase();
const searchKey = props.adviceQueryParams.searchKey.toLowerCase();
result = adviceBaseList.value.filter(item =>
item.adviceName.toLowerCase().includes(searchKey) ||
item.py_str?.toLowerCase().includes(searchKey) ||
item.wb_str?.toLowerCase().includes(searchKey)
).slice(0, 100); // 限制返回数量
item.adviceName.toLowerCase().includes(searchKey) ||
item.py_str?.toLowerCase().includes(searchKey) ||
item.wb_str?.toLowerCase().includes(searchKey)
).slice(0, 100); // 限制返回数量
}
return result;

View File

@@ -152,14 +152,25 @@
<!-- 分页组件 -->
<div class="pagination">
<button class="page-btn">&lt;</button>
<button class="page-btn active">1</button>
<button class="page-btn">2</button>
<button class="page-btn">3</button>
<button class="page-btn">...</button>
<button class="page-btn">10</button>
<button class="page-btn">&gt;</button>
<div class="total-count">总数{{ filteredData.length }}</div>
<button
class="page-btn"
:disabled="currentPage === 1"
@click="handlePrevPage"
>&lt;</button>
<button
v-for="page in pageButtons"
:key="page"
class="page-btn"
:class="{ active: page === currentPage }"
:disabled="page === '...'"
@click="handlePageChange(page)"
>{{ page }}</button>
<button
class="page-btn"
:disabled="currentPage >= totalPages || totalPages <= 1"
@click="handleNextPage"
>&gt;</button>
<div class="total-count">总数{{ total }}</div>
</div>
</main>
</div>
@@ -221,6 +232,10 @@ const tableData = ref([])
const loading = ref(false)
const total = ref(0)
// 分页参数
const currentPage = ref(1)
const pageSize = ref(10)
// 获取当前日期的函数格式为YYYY-MM-DD
function getCurrentDate() {
const today = new Date();
@@ -247,8 +262,8 @@ async function loadData() {
// 构建查询参数(匹配后端 InspectionPackage 实体字段)
const params = {
pageNum: 1,
pageSize: 1000, // 获取足够多的数据
pageNum: currentPage.value,
pageSize: pageSize.value,
packageCategory: '检验套餐' // InspectionPackage 使用 packageCategory 而不是 packageType
}
@@ -272,34 +287,55 @@ async function loadData() {
console.log('准备调用 listInspectionPackage API参数:', params)
const response = await listInspectionPackage(params)
console.log('listInspectionPackage API 返回:', response)
console.log('listInspectionPackage API 完整返回:', response)
console.log('response 类型:', typeof response)
console.log('response.data 是否存在:', !!response.data)
console.log('response.rows 是否存在:', !!response.rows)
console.log('response.total 是否存在:', !!response.total)
if (response) {
// 处理不同的响应格式优先按若依风格response.rows / response.total
let dataList = []
if (Array.isArray(response)) {
let totalCount = 0
// 优先检查 response.dataaxios 包装的响应)
if (response.data) {
const data = response.data
console.log('response.data 内容:', data)
console.log('response.data.rows:', data.rows)
console.log('response.data.total:', data.total)
if (Array.isArray(data.rows)) {
// TableDataInfo 格式:{ rows: [], total: 0 }
dataList = data.rows
totalCount = data.total || 0
console.log('使用 response.data.rows 和 response.data.total, totalCount:', totalCount)
} else if (Array.isArray(data.records)) {
// MyBatis Plus 分页格式
dataList = data.records
totalCount = data.total || 0
console.log('使用 response.data.records 和 response.data.total, totalCount:', totalCount)
} else if (Array.isArray(data)) {
// 直接是数组
dataList = data
totalCount = data.length
console.log('使用 response.data 数组, totalCount:', totalCount)
}
} else if (Array.isArray(response.rows)) {
// 直接是 TableDataInfo 格式
dataList = response.rows
totalCount = response.total || 0
console.log('使用 response.rows 和 response.total, totalCount:', totalCount)
} else if (Array.isArray(response)) {
// 直接返回数组
dataList = response
total.value = response.length
} else if (Array.isArray(response.rows)) {
// TableDataInfo 格式:{ rows: [], total: 0 }
dataList = response.rows
total.value = response.total || response.rows.length || 0
} else if (response.data) {
// 兼容 axios 原始 response.data 写法
const data = response.data
if (Array.isArray(data)) {
dataList = data
total.value = data.length
} else if (Array.isArray(data.rows)) {
dataList = data.rows
total.value = data.total || data.rows.length || 0
} else if (Array.isArray(data.records)) {
dataList = data.records
total.value = data.total || data.records.length || 0
}
totalCount = response.length
console.log('使用 response 数组, totalCount:', totalCount)
}
total.value = totalCount
console.log('设置 total.value =', total.value)
// 转换数据格式以匹配前端显示InspectionPackage 字段映射)
console.log('原始数据列表:', dataList)
console.log('数据列表长度:', dataList.length)
@@ -309,6 +345,8 @@ async function loadData() {
id: item.basicInformationId || item.id, // 优先使用 basicInformationId
packageId: item.packageId || item.basicInformationId || item.id, // 保存packageId用于跳转
basicInformationId: item.basicInformationId, // 保存原始basicInformationId
// 兼容旧逻辑:有些地方把主键当成 departmentId 使用注意真正的科室ID仍在后端字段 departmentId 上)
departmentId: item.basicInformationId || item.id || item.packageId,
hospital: item.orgName || '演示医院',
date: item.createTime ? (item.createTime.split('T')[0] || item.createTime.substring(0, 10)) : '',
name: item.packageName || '',
@@ -331,9 +369,12 @@ async function loadData() {
console.log('最终 tableData.value:', tableData.value)
console.log('tableData.value 长度:', tableData.value.length)
console.log('最终 total.value:', total.value)
console.log('计算的总页数 totalPages:', Math.ceil(total.value / pageSize.value))
} else {
tableData.value = []
total.value = 0
console.log('response 为空,重置数据')
}
} catch (error) {
console.error('加载数据失败:', error)
@@ -373,6 +414,7 @@ function toggleSidebar() {
// 处理查询
function handleSearch() {
currentPage.value = 1; // 搜索时重置到第一页
loadData()
}
@@ -385,9 +427,103 @@ function handleReset() {
packageLevel: '',
department: ''
};
currentPage.value = 1; // 重置到第一页
loadData()
}
// 计算总页数
const totalPages = computed(() => {
const pages = Math.ceil(total.value / pageSize.value)
console.log('[分页] 计算总页数: total=', total.value, 'pageSize=', pageSize.value, 'totalPages=', pages)
return pages > 0 ? pages : 1 // 至少返回1页
})
// 处理分页 - 上一页
function handlePrevPage() {
if (currentPage.value > 1) {
currentPage.value--
loadData()
}
}
// 处理分页 - 下一页
function handleNextPage() {
console.log('[分页] 点击下一页, currentPage:', currentPage.value, 'totalPages:', totalPages.value)
if (currentPage.value < totalPages.value) {
currentPage.value++
console.log('[分页] 跳转到第', currentPage.value, '页')
loadData()
} else {
console.log('[分页] 已经是最后一页,无法继续')
}
}
// 处理分页 - 跳转到指定页
function handlePageChange(page) {
console.log('[分页] 点击页码, page:', page, 'currentPage:', currentPage.value, 'totalPages:', totalPages.value)
if (page === '...') {
return // 省略号不可点击
}
if (page >= 1 && page <= totalPages.value && page !== currentPage.value) {
currentPage.value = page
console.log('[分页] 跳转到第', currentPage.value, '页')
loadData()
} else {
console.log('[分页] 无效的页码或已经是当前页')
}
}
// 生成分页按钮数组
const pageButtons = computed(() => {
const buttons = []
const total = totalPages.value
const current = currentPage.value
console.log('[分页] 计算分页按钮, totalPages:', total, 'currentPage:', current)
if (total <= 0) {
// 如果没有数据至少显示第1页
buttons.push(1)
return buttons
}
if (total <= 7) {
// 如果总页数小于等于7显示所有页码
for (let i = 1; i <= total; i++) {
buttons.push(i)
}
} else {
// 如果总页数大于7显示省略号
if (current <= 4) {
// 当前页在前4页
for (let i = 1; i <= 5; i++) {
buttons.push(i)
}
buttons.push('...')
buttons.push(total)
} else if (current >= total - 3) {
// 当前页在后4页
buttons.push(1)
buttons.push('...')
for (let i = total - 4; i <= total; i++) {
buttons.push(i)
}
} else {
// 当前页在中间
buttons.push(1)
buttons.push('...')
for (let i = current - 1; i <= current + 1; i++) {
buttons.push(i)
}
buttons.push('...')
buttons.push(total)
}
}
console.log('[分页] 生成的按钮:', buttons)
return buttons
})
// 处理新增
function handleAdd() {
router.push('/maintainSystem/Inspection?tab=2');
@@ -816,6 +952,22 @@ tr:hover {
align-items: center;
justify-content: center;
cursor: pointer;
transition: all 0.2s;
}
.page-btn:hover:not(:disabled) {
background-color: #f0f8ff;
border-color: var(--primary);
}
.page-btn:disabled {
opacity: 0.5;
cursor: not-allowed;
pointer-events: none;
}
.page-btn:not(:disabled) {
cursor: pointer;
}
.page-btn.active {