Files
his/openhis-ui-vue3/src/components/NoticePanel.vue
zhaoyun 3e7d27ee61 fix(#591): 请修复 Bug #591:【住院医生站-临床医嘱】长期医嘱点击停嘱未弹出时间录入弹窗
根因:
- Bug #请修复 Bug #591 存在的问题

修复:
- ### 变更摘要
- 全链路数据流分析**:录取(弹窗输入)→ 保存(API传入)→ 查询(Mapper返回)→ 修改(Service记录)→ 删除/停止(状态变更)→ 关联(列表展示)
- ### 后端变更(4个文件)
- 1. `AdviceBatchOpParam.java`** — 停嘱参数添加 `stopTime` 字段
- 新增 `@JsonFormat Date stopTime`,支持前端传入停嘱时间
- 2. `RequestBaseDto.java`** — 查询DTO添加 `stopUserName`、`stopTime` 字段
- 新增 `String stopUserName`(停嘱医生姓名)
- 新增 `Date stopTime`(停嘱时间)
- 3. `AdviceManageAppServiceImpl.java`** — 停嘱Service增强
- 优先使用前端传入的 `stopTime`,兜底用当前时间
- 通过 `SecurityUtils.getNickName()` 获取当前操作用户昵称,记录到 `updateBy`
- 药品和诊疗两个更新入口均已同步修改
- 4. `AdviceManageAppMapper.xml`** — 三个UNION ALL子查询添加字段
- 药品子查询:`T1.effective_dose_end AS stop_time` + `T1.update_by AS stop_user_name`
- 耗材子查询:`NULL AS stop_time` + `'' AS stop_user_name`
- 诊疗子查询:`T1.occurrence_end_time AS stop_time` + `T1.update_by AS stop_user_name`
- ### 前端变更(1个文件)
- `order/index.vue`**:
- 1. **停嘱时间弹窗** — 点击「停嘱」后弹出 `el-dialog`,内含 `el-date-picker`(datetime类型,默认当前时间),确定后才调用API
- 2. **表格列** — 在「皮试」列后面、「诊断」列前面新增两列:
- 「停嘱医生」`prop="stopUserName"`,宽度120px
- 「停嘱时间」`prop="stopTime"`,宽度170px
- 3. **`handleStopAdvice`** — 保留原有校验(未保存/未签发/已停止检查),校验通过后弹出时间选择弹窗而非直接调API
- 4. **`confirmStopAdvice`** — 新增确认函数,将 `stopTime` 拼入请求参数后调用 `stopAdvice` API
- ### 验证结果
-  前端 Lint 检查通过(仅1个预存的 `vue/no-dupe-keys` 警告)
-  后端 Maven 编译通过(BUILD SUCCESS)
2026-05-29 00:39:28 +08:00

339 lines
7.4 KiB
Vue
Executable File
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>
<el-drawer
v-model="noticeVisible"
title="公告/通知"
direction="rtl"
size="400px"
destroy-on-close
>
<el-empty
v-if="noticeList.length === 0"
description="暂无公告/通知"
/>
<div
v-else
class="notice-list"
>
<div
v-for="item in noticeList"
:key="item.noticeId"
class="notice-item"
:class="{ 'is-read': isRead(item.noticeId), 'unread': !isRead(item.noticeId) }"
@click="viewDetail(item)"
>
<div class="notice-title">
<span
v-if="!isRead(item.noticeId)"
class="unread-dot"
/>
{{ item.noticeTitle }}
</div>
<div class="notice-info">
<span class="notice-type">
<el-tag
:type="getNoticeTypeTagType(item.noticeType)"
size="small"
>
{{ getNoticeTypeText(item.noticeType) }}
</el-tag>
</span>
<span
v-if="item.priority"
class="notice-priority"
>
<el-tag
:type="getPriorityTagType(item.priority)"
size="small"
effect="plain"
>
{{ getPriorityText(item.priority) }}
</el-tag>
</span>
<span class="notice-time">{{ parseTime(item.createTime, '{y}-{m}-{d}') }}</span>
</div>
</div>
</div>
<!-- 公告/通知详情对话框 -->
<el-dialog
v-model="detailVisible"
:title="currentNotice.noticeTitle"
width="800px"
append-to-body
>
<div class="notice-detail">
<div class="detail-header">
<div class="detail-type">
<el-tag
:type="getNoticeTypeTagType(currentNotice.noticeType)"
size="small"
>
{{ getNoticeTypeText(currentNotice.noticeType) }}
</el-tag>
<el-tag
:type="getPriorityTagType(currentNotice.priority)"
size="small"
effect="plain"
style="margin-left: 8px;"
>
{{ getPriorityText(currentNotice.priority) }}
</el-tag>
</div>
<span class="detail-time">{{ parseTime(currentNotice.createTime, '{y}-{m}-{d} {h}:{i}') }}</span>
</div>
<div
class="detail-content"
v-html="currentNotice.noticeContent"
/>
</div>
<template #footer>
<el-button @click="detailVisible = false">
关闭
</el-button>
</template>
</el-dialog>
</el-drawer>
</template>
<script setup>
import {ref} from 'vue'
import {getReadNoticeIds, getUserNotices, markAsRead} from '@/api/system/notice'
const emit = defineEmits(['updateUnreadCount'])
const noticeVisible = ref(false)
const detailVisible = ref(false)
const noticeList = ref([])
const currentNotice = ref({})
const readNoticeIds = ref(new Set())
// 打开公告/通知面板
function open() {
noticeVisible.value = true
loadNotices()
loadReadNoticeIds()
}
// 加载已读公告ID列表
function loadReadNoticeIds() {
getReadNoticeIds().then(response => {
const ids = response.data || []
readNoticeIds.value = new Set(ids)
// 同步到 localStorage
localStorage.setItem('readNoticeIds', JSON.stringify(ids))
}).catch(() => {
// 接口调用失败时从 localStorage 读取
const readIds = localStorage.getItem('readNoticeIds')
if (readIds) {
try {
const ids = JSON.parse(readIds)
readNoticeIds.value = new Set(ids)
} catch (e) {
console.error('解析已读ID失败', e)
}
}
})
}
// 排序:未读的排前面,已读的排后面,同状态按优先级和时间排序
function sortNoticeList(list) {
return list.sort((a, b) => {
const aRead = isRead(a.noticeId)
const bRead = isRead(b.noticeId)
// 未读排在前面
if (aRead !== bRead) {
return aRead ? 1 : -1
}
// 同状态按优先级排序1高 2中 3低
const priorityA = a.priority || '3'
const priorityB = b.priority || '3'
if (priorityA !== priorityB) {
return priorityA.localeCompare(priorityB)
}
// 同优先级按创建时间倒序(最新的在前)
return new Date(b.createTime) - new Date(a.createTime)
})
}
// 加载公告和通知(统一从一个接口获取)
function loadNotices() {
getUserNotices().then(response => {
let list = response.data || []
noticeList.value = sortNoticeList(list)
})
}
// 获取公告类型标签类型
// noticeType: 1=通知, 2=公告
function getNoticeTypeTagType(type) {
const typeMap = {
'1': 'primary', // 通知
'2': 'success' // 公告
}
return typeMap[type] || 'info'
}
// 获取公告类型文本
function getNoticeTypeText(type) {
const textMap = {
'1': '通知',
'2': '公告'
}
return textMap[type] || '公告'
}
// 获取优先级标签类型
// priority: 1=高, 2=中, 3=低
function getPriorityTagType(priority) {
const typeMap = {
'1': 'danger', // 高优先级 - 红色
'2': 'warning', // 中优先级 - 橙色
'3': 'info' // 低优先级 - 灰色
}
return typeMap[priority] || 'info'
}
// 获取优先级文本
function getPriorityText(priority) {
const textMap = {
'1': '高',
'2': '中',
'3': '低'
}
return textMap[priority] || '中'
}
// 查看详情
function viewDetail(item) {
currentNotice.value = item
detailVisible.value = true
// 标记为已读
if (!readNoticeIds.value.has(item.noticeId)) {
markAsRead(item.noticeId).then(() => {
readNoticeIds.value.add(item.noticeId)
// 保存到 localStorage
saveReadNoticeIds()
emit('updateUnreadCount')
})
}
}
// 保存已读公告ID列表
function saveReadNoticeIds() {
const ids = Array.from(readNoticeIds.value)
localStorage.setItem('readNoticeIds', JSON.stringify(ids))
}
// 检查是否已读
function isRead(noticeId) {
return readNoticeIds.value.has(noticeId)
}
// 暴露方法给父组件
defineExpose({
open,
isRead,
readNoticeIds
})
</script>
<style lang="scss" scoped>
.notice-list {
max-height: calc(100vh - 200px);
overflow-y: auto;
}
.notice-item {
padding: 12px 0;
border-bottom: 1px solid #EBEEF5;
cursor: pointer;
transition: background-color 0.3s;
&:hover {
background-color: #F5F7FA;
}
&:last-child {
border-bottom: none;
}
&.is-read {
.notice-title {
color: #909399;
}
}
&.unread {
background-color: #fffbe6;
}
}
.notice-title {
font-size: 14px;
color: #303133;
margin-bottom: 8px;
line-height: 1.4;
display: flex;
align-items: center;
.unread-dot {
display: inline-block;
width: 6px;
height: 6px;
background-color: #f56c6c;
border-radius: 50%;
margin-right: 8px;
flex-shrink: 0;
}
}
.notice-info {
display: flex;
justify-content: space-between;
align-items: center;
font-size: 12px;
color: #909399;
gap: 8px;
.notice-type,
.notice-priority {
flex-shrink: 0;
}
}
.detail-header {
display: flex;
justify-content: space-between;
align-items: center;
padding-bottom: 16px;
border-bottom: 1px solid #EBEEF5;
margin-bottom: 16px;
.detail-type {
display: flex;
align-items: center;
}
}
.detail-time {
font-size: 12px;
color: #909399;
}
.detail-content {
font-size: 14px;
line-height: 1.8;
color: #303133;
max-height: 500px;
overflow-y: auto;
}
:deep(.el-drawer__body) {
padding: 0 20px;
}
</style>