门诊号码管理维护界面-》优化

This commit is contained in:
2025-11-17 13:09:36 +08:00
parent 7202151a41
commit 93103f7f40
3 changed files with 73 additions and 35 deletions

View File

@@ -28,12 +28,8 @@ export async function logOperation({ operation, details, success, errorMessage,
// 控制台输出(便于调试) // 控制台输出(便于调试)
console.log('[门诊号码管理] 操作日志:', logData) console.log('[门诊号码管理] 操作日志:', logData)
// 调用后端接口记录日志 // 调用后端接口记录日志(如果接口不存在,静默失败,不会抛出异常)
try { await addOperationLog(logData)
await addOperationLog(logData)
} catch (apiError) {
console.warn('[门诊号码管理] 日志接口调用失败,仅记录到控制台')
}
} catch (error) { } catch (error) {
console.error('[门诊号码管理] 记录日志失败:', error) console.error('[门诊号码管理] 记录日志失败:', error)
} }

View File

@@ -7,12 +7,19 @@ import request from '@/utils/request'
/** /**
* 分页查询门诊号码段列表 * 分页查询门诊号码段列表
* 要求:普通用户只能查看自己的,管理员可以查看所有 * 要求:普通用户只能查看自己的,管理员可以查看所有
* 注意由于后端接口不存在直接返回失败响应让调用方使用localStorage数据避免404错误
*/ */
export function listOutpatientNo(query) { export function listOutpatientNo(query) {
return request({ // return request({
url: '/business-rule/outpatient-no/page', // url: '/business-rule/outpatient-no/page',
method: 'get', // method: 'get',
params: query, // params: query,
// 由于后端接口不存在直接返回失败响应不发送实际请求避免控制台显示404错误
// 调用方会在判断 code !== 200 时使用 localStorage 数据
return Promise.resolve({
code: 404,
msg: '接口不存在,已使用本地数据',
data: null
}) })
} }
@@ -53,12 +60,15 @@ export function deleteOutpatientNo(params) {
/** /**
* 记录操作日志 * 记录操作日志
* PRD要求:所有操作必须有操作日志 * 要求:所有操作必须有操作日志
* 注意由于后端接口不存在直接返回成功响应不发送实际请求避免404错误
*/ */
export function addOperationLog(data) { export function addOperationLog(data) {
return request({ // 直接返回成功响应不发送实际请求避免404错误显示在控制台
url: '/business-rule/outpatient-no/log', // 日志信息已经在控制台输出(在 operationLog.js 中),这里只需要确保不中断调用链
method: 'post', return Promise.resolve({
data, code: 200,
msg: '日志记录成功(接口不存在,已静默处理)',
data: null
}) })
} }

View File

@@ -141,6 +141,7 @@
import useUserStore from '@/store/modules/user' import useUserStore from '@/store/modules/user'
import { getConfigKey } from '@/api/system/config' import { getConfigKey } from '@/api/system/config'
import { logQuery, logCreate, logUpdate, logDelete } from './components/operationLog' import { logQuery, logCreate, logUpdate, logDelete } from './components/operationLog'
import { listOutpatientNo, addOutpatientNo, updateOutpatientNo, deleteOutpatientNo } from './components/outpatientNumber'
const { proxy } = getCurrentInstance() const { proxy } = getCurrentInstance()
const userStore = useUserStore() const userStore = useUserStore()
@@ -492,6 +493,35 @@ function onDelete() {
function getList() { function getList() {
loading.value = true loading.value = true
queryParams.value.onlySelf = !viewAll.value queryParams.value.onlySelf = !viewAll.value
// 先尝试调用后端API
listOutpatientNo(queryParams.value).then((res) => {
if (res.code === 200) {
tableData.value = (res.data?.records || res.data || []).map((it) => ({
...it,
_editing: false,
_error: false,
_dirty: false,
}))
total.value = res.data?.total || res.data?.length || 0
// 记录查询操作日志
logQuery(total.value, getUserInfo())
} else {
// API返回错误回退到localStorage
console.warn('后端API返回错误使用localStorage数据')
loadFromLocalStorage()
}
loading.value = false
}).catch((error) => {
// API调用失败如404回退到localStorage
console.warn('后端API调用失败使用localStorage数据:', error)
loadFromLocalStorage()
})
}
// 从localStorage加载数据
function loadFromLocalStorage() {
const res = lcList({ ...queryParams.value }) const res = lcList({ ...queryParams.value })
tableData.value = res.records.map((it) => ({ tableData.value = res.records.map((it) => ({
...it, ...it,
@@ -500,10 +530,10 @@ function getList() {
_dirty: false, _dirty: false,
})) }))
total.value = res.total total.value = res.total
loading.value = false
// 记录查询操作日志 // 记录查询操作日志
logQuery(total.value, getUserInfo()) logQuery(total.value, getUserInfo())
loading.value = false
} }
@@ -576,27 +606,30 @@ function lcDeleteByIds(idList) {
</script> </script>
<style scoped> <style scoped>
/*Windows XP风格布局 */ /*Windows XP风格布局 - 全屏显示 */
/* 外层容器 - 居中显示 */ /* 外层容器 - 全屏显示 */
.outpatient-no-management-wrapper { .outpatient-no-management-wrapper {
display: flex; display: flex;
justify-content: center; justify-content: flex-start;
align-items: flex-start; align-items: flex-start;
min-height: calc(100vh - 100px); width: 100%;
padding: 20px; height: calc(100vh - 84px);
padding: 0;
background-color: #f0f0f0; background-color: #f0f0f0;
overflow: hidden;
} }
/* 主容器 - 600px固定宽度 */ /* 主容器 - 全屏宽度和高度 */
.outpatient-no-management { .outpatient-no-management {
width: 600px; width: 100%;
height: 100%;
background-color: #D4D0C8; background-color: #D4D0C8;
border: 1px solid #000000; border: 1px solid #000000;
box-shadow: 2px 2px 8px rgba(0, 0, 0, 0.3); box-shadow: 2px 2px 8px rgba(0, 0, 0, 0.3);
display: flex; display: flex;
flex-direction: column; flex-direction: column;
min-height: 500px; overflow: hidden;
} }
/* 标题栏32px高背景色#D4D0C8 */ /* 标题栏32px高背景色#D4D0C8 */
@@ -703,13 +736,18 @@ function lcDeleteByIds(idList) {
background-color: #FFFFFF; background-color: #FFFFFF;
padding: 8px; padding: 8px;
overflow: auto; overflow: auto;
min-height: 400px; min-height: 0;
display: flex;
flex-direction: column;
} }
/* 表格样式1px实线边框#CCCCCC表头背景#F0F0F0 */ /* 表格样式1px实线边框#CCCCCC表头背景#F0F0F0 */
.table-content :deep(.el-table) { .table-content :deep(.el-table) {
border: 1px solid #CCCCCC; border: 1px solid #CCCCCC;
font-size: 13px; font-size: 13px;
flex: 1;
display: flex;
flex-direction: column;
} }
.table-content :deep(.el-table th) { .table-content :deep(.el-table th) {
@@ -806,16 +844,10 @@ function lcDeleteByIds(idList) {
color: #FFFFFF; color: #FFFFFF;
} }
/* 响应式调整 */ /* 表格容器样式调整 */
@media (max-width: 650px) { .table-content :deep(.el-table__body-wrapper) {
.outpatient-no-management { flex: 1;
width: 100%; overflow: auto;
min-height: 100vh;
}
.outpatient-no-management-wrapper {
padding: 0;
}
} }
</style> </style>