门诊号码管理维护界面-》优化
This commit is contained in:
@@ -0,0 +1,105 @@
|
||||
/**
|
||||
* 操作日志工具
|
||||
* 所有操作必须有操作日志
|
||||
*/
|
||||
import { addOperationLog } from './outpatientNumber'
|
||||
|
||||
/**
|
||||
* 记录操作日志
|
||||
* @param {Object} params
|
||||
* @param {string} params.operation - 操作类型(新增/修改/删除/查询)
|
||||
* @param {string} params.details - 操作详情
|
||||
* @param {boolean} params.success - 操作是否成功
|
||||
* @param {string} params.errorMessage - 错误信息
|
||||
* @param {Object} params.userInfo - 用户信息
|
||||
*/
|
||||
export async function logOperation({ operation, details, success, errorMessage, userInfo }) {
|
||||
try {
|
||||
const logData = {
|
||||
operation,
|
||||
details,
|
||||
success,
|
||||
errorMessage: errorMessage || null,
|
||||
timestamp: new Date().toISOString(),
|
||||
userId: userInfo?.id || null,
|
||||
userName: userInfo?.name || null,
|
||||
}
|
||||
|
||||
// 控制台输出(便于调试)
|
||||
console.log('[门诊号码管理] 操作日志:', logData)
|
||||
|
||||
// 调用后端接口记录日志
|
||||
try {
|
||||
await addOperationLog(logData)
|
||||
} catch (apiError) {
|
||||
console.warn('[门诊号码管理] 日志接口调用失败,仅记录到控制台')
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('[门诊号码管理] 记录日志失败:', error)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 记录查询操作
|
||||
*/
|
||||
export function logQuery(recordCount, userInfo) {
|
||||
return logOperation({
|
||||
operation: '查询',
|
||||
details: `查询门诊号码段列表,共 ${recordCount} 条记录`,
|
||||
success: true,
|
||||
userInfo
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 记录新增操作
|
||||
*/
|
||||
export function logCreate(record, success, errorMessage, userInfo) {
|
||||
const details = success
|
||||
? `新增门诊号码段:${record.startNo} - ${record.endNo}(操作员:${record.operatorName})`
|
||||
: `尝试新增门诊号码段:${record.startNo} - ${record.endNo},失败原因:${errorMessage}`
|
||||
|
||||
return logOperation({
|
||||
operation: '新增',
|
||||
details,
|
||||
success,
|
||||
errorMessage,
|
||||
userInfo
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 记录修改操作
|
||||
*/
|
||||
export function logUpdate(record, success, errorMessage, userInfo) {
|
||||
const details = success
|
||||
? `修改门诊号码段:${record.startNo} - ${record.endNo}(ID:${record.id})`
|
||||
: `尝试修改门诊号码段 ID:${record.id},失败原因:${errorMessage}`
|
||||
|
||||
return logOperation({
|
||||
operation: '修改',
|
||||
details,
|
||||
success,
|
||||
errorMessage,
|
||||
userInfo
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 记录删除操作
|
||||
*/
|
||||
export function logDelete(records, success, errorMessage, userInfo) {
|
||||
const recordsInfo = records.map(r => `${r.startNo}-${r.endNo}`).join('、')
|
||||
const details = success
|
||||
? `删除门诊号码段(共 ${records.length} 条):${recordsInfo}`
|
||||
: `尝试删除门诊号码段(共 ${records.length} 条),失败原因:${errorMessage}`
|
||||
|
||||
return logOperation({
|
||||
operation: '删除',
|
||||
details,
|
||||
success,
|
||||
errorMessage,
|
||||
userInfo
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
/**
|
||||
* 门诊号码管理 API 接口
|
||||
* 严格按照要求实现
|
||||
*/
|
||||
import request from '@/utils/request'
|
||||
|
||||
/**
|
||||
* 分页查询门诊号码段列表
|
||||
* 要求:普通用户只能查看自己的,管理员可以查看所有
|
||||
*/
|
||||
export function listOutpatientNo(query) {
|
||||
return request({
|
||||
url: '/business-rule/outpatient-no/page',
|
||||
@@ -8,6 +16,10 @@ export function listOutpatientNo(query) {
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增门诊号码段
|
||||
* 要求:必须校验前缀一致性、长度一致性、重复检查
|
||||
*/
|
||||
export function addOutpatientNo(data) {
|
||||
return request({
|
||||
url: '/business-rule/outpatient-no',
|
||||
@@ -16,6 +28,9 @@ export function addOutpatientNo(data) {
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新门诊号码段
|
||||
*/
|
||||
export function updateOutpatientNo(data) {
|
||||
return request({
|
||||
url: '/business-rule/outpatient-no',
|
||||
@@ -24,6 +39,10 @@ export function updateOutpatientNo(data) {
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除门诊号码段
|
||||
*要求:双重校验(归属权+使用状态)
|
||||
*/
|
||||
export function deleteOutpatientNo(params) {
|
||||
return request({
|
||||
url: '/business-rule/outpatient-no',
|
||||
@@ -32,5 +51,14 @@ export function deleteOutpatientNo(params) {
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 记录操作日志
|
||||
* PRD要求:所有操作必须有操作日志
|
||||
*/
|
||||
export function addOperationLog(data) {
|
||||
return request({
|
||||
url: '/business-rule/outpatient-no/log',
|
||||
method: 'post',
|
||||
data,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,6 +1,15 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<!-- Windows XP风格窗口布局,600px固定宽度 -->
|
||||
<div class="outpatient-no-management-wrapper">
|
||||
<div class="outpatient-no-management">
|
||||
<!--标题栏(32px高) -->
|
||||
<div class="title-bar">
|
||||
<span class="title-text">门诊号码管理</span>
|
||||
</div>
|
||||
|
||||
<!-- 功能按钮区(40px高) -->
|
||||
<div class="button-bar">
|
||||
<el-row :gutter="10">
|
||||
<el-col :span="1.5">
|
||||
<el-button type="primary" plain icon="Plus" @click="onAdd">新设(A)</el-button>
|
||||
</el-col>
|
||||
@@ -8,7 +17,7 @@
|
||||
<el-button type="danger" plain icon="Delete" :disabled="multiple" @click="onDelete">删除(D)</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="success" plain icon="Check" :disabled="multiple" @click="() => onSave()">保存(S)</el-button>
|
||||
<el-button type="success" plain icon="Check" @click="() => onSave()">保存(S)</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="warning" plain icon="Close" @click="onClose">关闭(X)</el-button>
|
||||
@@ -22,7 +31,10 @@
|
||||
/>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
|
||||
<!-- 表格内容区(自适应剩余高度) -->
|
||||
<div class="table-content">
|
||||
<el-table
|
||||
v-loading="loading"
|
||||
:data="tableData"
|
||||
@@ -51,6 +63,7 @@
|
||||
<el-input
|
||||
v-if="row._editing"
|
||||
v-model.trim="row.startNo"
|
||||
@input="() => onStartNoChange(row)"
|
||||
@blur="() => validateNumField(row, 'startNo')"
|
||||
/>
|
||||
<span v-else>{{ row.startNo }}</span>
|
||||
@@ -90,6 +103,8 @@
|
||||
@pagination="getList"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 编辑弹窗 -->
|
||||
<el-dialog v-model="dialogVisible" :title="dialogTitle" width="600px" append-to-body>
|
||||
@@ -125,10 +140,17 @@
|
||||
<script setup name="outpatientNoManagement">
|
||||
import useUserStore from '@/store/modules/user'
|
||||
import { getConfigKey } from '@/api/system/config'
|
||||
import { logQuery, logCreate, logUpdate, logDelete } from './components/operationLog'
|
||||
|
||||
const { proxy } = getCurrentInstance()
|
||||
const userStore = useUserStore()
|
||||
|
||||
// 获取当前用户信息(用于日志记录)
|
||||
const getUserInfo = () => ({
|
||||
id: userStore.id,
|
||||
name: userStore.name || userStore.nickName
|
||||
})
|
||||
|
||||
const loading = ref(false)
|
||||
const tableData = ref([])
|
||||
const total = ref(0)
|
||||
@@ -199,6 +221,13 @@ function onAdd() {
|
||||
})
|
||||
}
|
||||
|
||||
// 新增时,起始号码变化时自动设置使用号码为起始号码
|
||||
function onStartNoChange(row) {
|
||||
if (!row.id && row._editing) {
|
||||
row.usedNo = row.startNo
|
||||
}
|
||||
}
|
||||
|
||||
function onClose() {
|
||||
proxy.$tab.closePage()
|
||||
}
|
||||
@@ -230,12 +259,13 @@ function confirmEdit() {
|
||||
dialogVisible.value = false
|
||||
}
|
||||
|
||||
// 字母前缀识别规则 - 从末位往前找到第一个字母
|
||||
function extractPrefix(value) {
|
||||
if (!value) return ''
|
||||
const chars = value.split('')
|
||||
for (let i = chars.length - 1; i >= 0; i--) {
|
||||
if (/[A-Za-z]/.test(chars[i])) {
|
||||
return value.slice(0, i)
|
||||
return value.slice(0, i + 1) // 包含找到的字母
|
||||
}
|
||||
}
|
||||
return ''
|
||||
@@ -371,7 +401,9 @@ function onSave(row) {
|
||||
const idx = tableData.value.indexOf(r)
|
||||
if (!validateRow(r, idx)) return
|
||||
}
|
||||
const ok = lcUpsertMany(rows.map((r) => ({
|
||||
|
||||
// 准备保存的数据
|
||||
const saveData = rows.map((r) => ({
|
||||
id: r.id,
|
||||
operatorId: r.operatorId,
|
||||
operatorName: r.operatorName,
|
||||
@@ -380,8 +412,30 @@ function onSave(row) {
|
||||
startNo: r.startNo,
|
||||
endNo: r.endNo,
|
||||
usedNo: r.usedNo,
|
||||
})))
|
||||
if (!ok) return
|
||||
}))
|
||||
|
||||
const ok = lcUpsertMany(saveData)
|
||||
if (!ok) {
|
||||
// 记录失败的操作日志
|
||||
for (const record of saveData) {
|
||||
if (record.id) {
|
||||
logUpdate(record, false, '门诊号码设置重复', getUserInfo())
|
||||
} else {
|
||||
logCreate(record, false, '门诊号码设置重复', getUserInfo())
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 记录成功的操作日志
|
||||
for (const record of saveData) {
|
||||
if (record.id) {
|
||||
logUpdate(record, true, null, getUserInfo())
|
||||
} else {
|
||||
logCreate(record, true, null, getUserInfo())
|
||||
}
|
||||
}
|
||||
|
||||
if (proxy.$modal?.alertSuccess) {
|
||||
proxy.$modal.alertSuccess('保存成功!')
|
||||
} else {
|
||||
@@ -393,20 +447,31 @@ function onSave(row) {
|
||||
function onDelete() {
|
||||
const rows = tableData.value.filter((r) => ids.value.includes(r.id))
|
||||
if (!rows.length) return
|
||||
|
||||
// 双重校验(归属权+使用状态)
|
||||
for (const r of rows) {
|
||||
const canDeleteSelf = String(r.operatorId) === String(userStore.id)
|
||||
const neverUsed = r.usedNo === r.startNo
|
||||
if (!canDeleteSelf) {
|
||||
// 权限不足提示
|
||||
alertWarn('只能删除自己维护的门诊号码段')
|
||||
logDelete(rows, false, '只能删除自己维护的门诊号码段', getUserInfo())
|
||||
return
|
||||
}
|
||||
if (!neverUsed) {
|
||||
// 已使用提示
|
||||
alertWarn('已有门诊号码段已有使用的门诊号码,请核对!')
|
||||
logDelete(rows, false, '已有门诊号码段已有使用的门诊号码', getUserInfo())
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
const doRealDelete = () => {
|
||||
lcDeleteByIds(rows.map((r) => r.id))
|
||||
|
||||
//记录成功的删除操作日志
|
||||
logDelete(rows, true, null, getUserInfo())
|
||||
|
||||
if (proxy.$modal?.alertSuccess) {
|
||||
proxy.$modal.alertSuccess('删除成功')
|
||||
} else {
|
||||
@@ -414,8 +479,11 @@ function onDelete() {
|
||||
}
|
||||
getList()
|
||||
}
|
||||
|
||||
if (proxy.$modal?.confirm) {
|
||||
proxy.$modal.confirm('是否确认删除选中数据项?').then(doRealDelete)
|
||||
proxy.$modal.confirm('是否确认删除选中数据项?').then(doRealDelete).catch(() => {
|
||||
// 用户取消删除,不记录日志
|
||||
})
|
||||
} else {
|
||||
doRealDelete()
|
||||
}
|
||||
@@ -433,9 +501,12 @@ function getList() {
|
||||
}))
|
||||
total.value = res.total
|
||||
loading.value = false
|
||||
|
||||
// 记录查询操作日志
|
||||
logQuery(total.value, getUserInfo())
|
||||
}
|
||||
|
||||
// (测试辅助功能已移除)
|
||||
|
||||
|
||||
// 纯前端本地持久化方法(localStorage)
|
||||
const STORAGE_KEY = 'ohis_outpatient_no_segments'
|
||||
@@ -505,8 +576,247 @@ function lcDeleteByIds(idList) {
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.error-row { --el-table-tr-bg-color: #fff7e6; }
|
||||
.mb8 { margin-bottom: 8px; }
|
||||
/*Windows XP风格布局 */
|
||||
|
||||
/* 外层容器 - 居中显示 */
|
||||
.outpatient-no-management-wrapper {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: flex-start;
|
||||
min-height: calc(100vh - 100px);
|
||||
padding: 20px;
|
||||
background-color: #f0f0f0;
|
||||
}
|
||||
|
||||
/* 主容器 - 600px固定宽度 */
|
||||
.outpatient-no-management {
|
||||
width: 600px;
|
||||
background-color: #D4D0C8;
|
||||
border: 1px solid #000000;
|
||||
box-shadow: 2px 2px 8px rgba(0, 0, 0, 0.3);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: 500px;
|
||||
}
|
||||
|
||||
/* 标题栏(32px高,背景色#D4D0C8) */
|
||||
.title-bar {
|
||||
height: 32px;
|
||||
background: linear-gradient(to bottom, #0055E5 0%, #0F3D8C 100%);
|
||||
border-bottom: 1px solid #000000;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 0 8px;
|
||||
}
|
||||
|
||||
/* 标题文本(14px/700,左对齐) */
|
||||
.title-text {
|
||||
font-size: 14px;
|
||||
font-weight: 700;
|
||||
color: #FFFFFF;
|
||||
letter-spacing: 0.5px;
|
||||
}
|
||||
|
||||
/* 功能按钮区(40px高) */
|
||||
.button-bar {
|
||||
height: 40px;
|
||||
background-color: #D4D0C8;
|
||||
border-bottom: 1px solid #808080;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 0 8px;
|
||||
}
|
||||
|
||||
.button-bar .el-row {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
/* 按钮样式(90x32px,1px边框,圆角0,背景色#EFEFEF) */
|
||||
.button-bar :deep(.el-button) {
|
||||
width: 90px;
|
||||
height: 32px;
|
||||
border-radius: 0;
|
||||
border: 1px solid #808080;
|
||||
font-size: 13px;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
/* 新设按钮 - 主要操作 */
|
||||
.button-bar :deep(.el-button--primary) {
|
||||
background: linear-gradient(to bottom, #FFFFFF 0%, #EFEFEF 50%, #DFDFDF 100%);
|
||||
color: #000000;
|
||||
border-top: 1px solid #FFFFFF;
|
||||
border-left: 1px solid #FFFFFF;
|
||||
border-right: 1px solid #808080;
|
||||
border-bottom: 1px solid #808080;
|
||||
}
|
||||
|
||||
.button-bar :deep(.el-button--primary:hover) {
|
||||
background: linear-gradient(to bottom, #FFFEF8 0%, #F5F4EF 50%, #E5E4DF 100%);
|
||||
}
|
||||
|
||||
/* 删除按钮 */
|
||||
.button-bar :deep(.el-button--danger) {
|
||||
background: linear-gradient(to bottom, #FFFFFF 0%, #EFEFEF 50%, #DFDFDF 100%);
|
||||
color: #000000;
|
||||
border-top: 1px solid #FFFFFF;
|
||||
border-left: 1px solid #FFFFFF;
|
||||
border-right: 1px solid #808080;
|
||||
border-bottom: 1px solid #808080;
|
||||
}
|
||||
|
||||
/* 保存按钮 */
|
||||
.button-bar :deep(.el-button--success) {
|
||||
background: linear-gradient(to bottom, #FFFFFF 0%, #EFEFEF 50%, #DFDFDF 100%);
|
||||
color: #000000;
|
||||
border-top: 1px solid #FFFFFF;
|
||||
border-left: 1px solid #FFFFFF;
|
||||
border-right: 1px solid #808080;
|
||||
border-bottom: 1px solid #808080;
|
||||
}
|
||||
|
||||
/* 关闭按钮(红色背景,白色文字) */
|
||||
.button-bar :deep(.el-button--warning) {
|
||||
background: linear-gradient(to bottom, #FF6B6B 0%, #EE5A5A 50%, #DD4949 100%);
|
||||
color: #FFFFFF;
|
||||
font-weight: 600;
|
||||
border-top: 1px solid #FF9999;
|
||||
border-left: 1px solid #FF9999;
|
||||
border-right: 1px solid #AA3333;
|
||||
border-bottom: 1px solid #AA3333;
|
||||
}
|
||||
|
||||
.button-bar :deep(.el-button--warning:hover) {
|
||||
background: linear-gradient(to bottom, #FF7B7B 0%, #FE6A6A 50%, #ED5959 100%);
|
||||
}
|
||||
|
||||
/* 按钮禁用状态 */
|
||||
.button-bar :deep(.el-button:disabled) {
|
||||
background: #D4D0C8;
|
||||
color: #808080;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
/*表格内容区(自适应剩余高度) */
|
||||
.table-content {
|
||||
flex: 1;
|
||||
background-color: #FFFFFF;
|
||||
padding: 8px;
|
||||
overflow: auto;
|
||||
min-height: 400px;
|
||||
}
|
||||
|
||||
/* 表格样式(1px实线边框#CCCCCC,表头背景#F0F0F0) */
|
||||
.table-content :deep(.el-table) {
|
||||
border: 1px solid #CCCCCC;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.table-content :deep(.el-table th) {
|
||||
background: linear-gradient(to bottom, #FFFFFF 0%, #F0F0F0 100%);
|
||||
border: 1px solid #CCCCCC;
|
||||
color: #000000;
|
||||
font-weight: 600;
|
||||
font-size: 13px;
|
||||
padding: 8px 4px;
|
||||
}
|
||||
|
||||
.table-content :deep(.el-table td) {
|
||||
border: 1px solid #CCCCCC;
|
||||
padding: 6px 4px;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.table-content :deep(.el-table__body tr:hover > td) {
|
||||
background-color: #E5F3FF !important;
|
||||
}
|
||||
|
||||
/* 错误行样式 */
|
||||
:deep(.error-row) {
|
||||
--el-table-tr-bg-color: #fff7e6;
|
||||
}
|
||||
|
||||
/* 分页样式 */
|
||||
.table-content :deep(.pagination-container) {
|
||||
margin-top: 10px;
|
||||
padding: 10px 0;
|
||||
border-top: 1px solid #CCCCCC;
|
||||
}
|
||||
|
||||
/* 输入框样式 */
|
||||
.table-content :deep(.el-input__inner) {
|
||||
border: 1px solid #7FB4FF;
|
||||
border-radius: 0;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.table-content :deep(.el-input__inner:focus) {
|
||||
border: 2px solid #0055E5;
|
||||
}
|
||||
|
||||
/* 日期选择器样式 */
|
||||
.table-content :deep(.el-date-editor) {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
/* 开关样式 */
|
||||
.button-bar :deep(.el-switch) {
|
||||
height: 24px;
|
||||
}
|
||||
|
||||
/* 滚动条样式(Windows XP风格) */
|
||||
.table-content::-webkit-scrollbar {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
}
|
||||
|
||||
.table-content::-webkit-scrollbar-track {
|
||||
background-color: #D4D0C8;
|
||||
border: 1px solid #808080;
|
||||
}
|
||||
|
||||
.table-content::-webkit-scrollbar-thumb {
|
||||
background: linear-gradient(to bottom, #FFFFFF 0%, #EFEFEF 50%, #DFDFDF 100%);
|
||||
border: 1px solid #808080;
|
||||
}
|
||||
|
||||
.table-content::-webkit-scrollbar-thumb:hover {
|
||||
background: linear-gradient(to bottom, #FFFEF8 0%, #F5F4EF 50%, #E5E4DF 100%);
|
||||
}
|
||||
|
||||
/* 编辑弹窗样式 */
|
||||
:deep(.el-dialog) {
|
||||
border-radius: 0;
|
||||
border: 2px solid #0055E5;
|
||||
}
|
||||
|
||||
:deep(.el-dialog__header) {
|
||||
background: linear-gradient(to bottom, #0055E5 0%, #0F3D8C 100%);
|
||||
padding: 10px 15px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
:deep(.el-dialog__title) {
|
||||
color: #FFFFFF;
|
||||
font-weight: 700;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
:deep(.el-dialog__close) {
|
||||
color: #FFFFFF;
|
||||
}
|
||||
|
||||
/* 响应式调整 */
|
||||
@media (max-width: 650px) {
|
||||
.outpatient-no-management {
|
||||
width: 100%;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
.outpatient-no-management-wrapper {
|
||||
padding: 0;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user