feat(documents): implement document library management

This commit is contained in:
yelan
2026-08-27 16:47:31 +08:00
parent 24d8a9ece1
commit e7aa4843b7
7 changed files with 1378 additions and 17 deletions
@@ -0,0 +1,122 @@
<script setup lang="ts">
import type { DepartmentTab, DocumentStatus, StatusTab } from '../types'
defineProps<{
department: string | null
status: DocumentStatus
departments: DepartmentTab[]
statuses: StatusTab[]
}>()
const emit = defineEmits<{
'update:department': [value: string | null]
'update:status': [value: DocumentStatus]
}>()
</script>
<template>
<div class="filter-card">
<div class="department-tabs" role="tablist" aria-label="按科室筛选">
<button
v-for="tab in departments"
:key="tab.key ?? 'all'"
type="button"
class="department-tab"
:class="{ active: department === tab.key }"
:aria-selected="department === tab.key"
role="tab"
@click="emit('update:department', tab.key)"
>
{{ tab.label }}({{ tab.count }})
</button>
</div>
<div class="status-tabs" role="tablist" aria-label="按状态筛选">
<button
v-for="tab in statuses"
:key="tab.key"
type="button"
class="status-tab"
:class="{ active: status === tab.key }"
:aria-selected="status === tab.key"
role="tab"
@click="emit('update:status', tab.key)"
>
{{ tab.label }}<span v-if="tab.count"> · {{ tab.count }}</span>
</button>
</div>
</div>
</template>
<style scoped>
.filter-card {
padding: 12px 16px;
margin-bottom: 12px;
background: var(--card);
border-radius: var(--r);
box-shadow: var(--sh);
}
.department-tabs {
display: flex;
flex-wrap: wrap;
gap: 8px;
margin-bottom: 10px;
}
.department-tab {
padding: 5px 12px;
color: var(--mut);
font-size: 12.5px;
background: #f4f8fa;
border: 1px solid transparent;
border-radius: 16px;
transition:
background-color 0.15s ease,
color 0.15s ease;
}
.department-tab:hover {
color: var(--brand);
background: #eaf2f5;
}
.department-tab.active {
color: #fff;
font-weight: 700;
background: var(--brand);
}
.status-tabs {
display: flex;
flex-wrap: wrap;
gap: 8px;
padding-top: 10px;
border-top: 1px dashed var(--line);
}
.status-tab {
padding: 4px 10px;
color: var(--mut);
font-size: 12px;
background: #fff;
border: 1px solid var(--line);
border-radius: 14px;
transition:
background-color 0.15s ease,
border-color 0.15s ease,
color 0.15s ease;
}
.status-tab:hover {
color: var(--brand);
border-color: var(--brand);
}
.status-tab.active {
color: var(--brand-d);
font-weight: 700;
background: var(--brand-l);
border-color: var(--brand);
}
</style>
@@ -0,0 +1,148 @@
<script setup lang="ts">
const props = defineProps<{
modelValue: string
total: number
}>()
const emit = defineEmits<{
'update:modelValue': [value: string]
add: []
export: []
}>()
function handleInput(event: Event) {
emit('update:modelValue', (event.target as HTMLInputElement).value)
}
</script>
<template>
<div class="library-header">
<div class="library-title">
<h2>文档库管理</h2>
<p>
按科室分类的知情同意书模板库,支持预览、编辑与版本管理。
<span>共 {{ total }} 份模板</span>
</p>
</div>
<div class="library-tools">
<input
:value="props.modelValue"
class="library-search"
type="search"
placeholder="搜索模板名称 / 编号 / 科室"
aria-label="搜索模板名称、编号或科室"
@input="handleInput"
/>
<button type="button" class="tool-button primary" @click="emit('add')">
<span aria-hidden="true">+</span>
新增文档
</button>
<button type="button" class="tool-button secondary" @click="emit('export')">
导出模板包
</button>
</div>
</div>
</template>
<style scoped>
.library-header {
display: flex;
flex-wrap: wrap;
gap: 16px;
align-items: center;
justify-content: space-between;
margin-bottom: 14px;
}
.library-title {
display: flex;
flex-direction: column;
gap: 4px;
}
.library-title h2 {
margin: 0;
color: var(--ink);
font-size: 17px;
line-height: 1.4;
}
.library-title p {
margin: 0;
color: var(--mut);
font-size: 12.5px;
}
.library-title p span {
margin-left: 8px;
color: var(--brand);
font-weight: 700;
}
.library-tools {
display: flex;
flex-wrap: wrap;
gap: 10px;
align-items: center;
}
.library-search {
width: 240px;
padding: 6px 12px;
color: var(--ink);
font-size: 12.5px;
background: #fff;
border: 1px solid var(--line);
border-radius: 8px;
}
.library-search:focus {
outline: none;
border-color: var(--brand);
box-shadow: 0 0 0 3px rgb(14 110 140 / 10%);
}
.tool-button {
padding: 7px 13px;
font-size: 12px;
font-weight: 700;
border-radius: 7px;
transition:
background-color 0.15s ease,
color 0.15s ease,
border-color 0.15s ease;
}
.tool-button.primary {
color: #fff;
background: var(--brand);
border: 1px solid var(--brand);
}
.tool-button.primary:hover {
background: var(--brand-d);
border-color: var(--brand-d);
}
.tool-button.secondary {
color: var(--brand);
background: #fff;
border: 1px solid var(--brand);
}
.tool-button.secondary:hover {
background: var(--brand-l);
}
@media (max-width: 760px) {
.library-tools {
width: 100%;
}
.library-search {
flex: 1;
min-width: 180px;
}
}
</style>
@@ -0,0 +1,320 @@
<script setup lang="ts">
import { computed } from 'vue'
import { documentStatusLabels } from '../mock'
import type { DocumentTemplate } from '../types'
const props = defineProps<{
visible: boolean
template: DocumentTemplate | null
}>()
const emit = defineEmits<{
close: []
use: [template: DocumentTemplate]
}>()
const statusLabel = computed(() => {
if (!props.template) {
return ''
}
return documentStatusLabels[props.template.status]
})
</script>
<template>
<Teleport to="body">
<div
v-if="visible && template"
class="dialog-mask"
role="presentation"
@click.self="emit('close')"
>
<section
class="preview-dialog"
role="dialog"
aria-modal="true"
aria-labelledby="document-preview-title"
>
<header class="dialog-header">
<div class="dialog-title">
<h2 id="document-preview-title">{{ template.name }}</h2>
<span class="word-badge">类 Word 版式</span>
<span class="status-badge">{{ statusLabel }}</span>
</div>
<button type="button" class="close-button" aria-label="关闭预览" @click="emit('close')">
×
</button>
</header>
<div class="dialog-body">
<article class="preview-paper">
<h3>{{ template.name }}</h3>
<p class="paper-number">模板编号:{{ template.code }} · 版本 {{ template.version }}</p>
<p>
患者:<strong>{患者姓名}</strong> · 性别:<strong>{性别}</strong> · 年龄:<strong
>{年龄}</strong
>
</p>
<p>
门诊/住院号:<strong>{就诊号}</strong> · 科室:<strong>{{
template.department
}}</strong>
· 日期:<strong>{签署日期}</strong>
</p>
<p>
医务人员已就本项检查、治疗的适应证、禁忌证、医疗风险、替代方案及可能出现的不良后果向本人(或授权委托人)充分说明,本人已完全理解上述内容,自愿接受并签署确认。
</p>
<p>
本文档采用电子方式签署,患者手写签名图片将合成至下方签名域,文档原件与签名原图双留存。
</p>
<div class="signature-area">
<div>
<span>患者 / 授权委托人签名:</span>
<div class="signature-line">签名域(自动合成)</div>
</div>
<div>
<span>日期:</span>
<div class="signature-line date-line">自动填充</div>
</div>
</div>
</article>
</div>
<footer class="dialog-footer">
<p>占位符由系统在签署时自动填充,当前仅用于原型演示。</p>
<button type="button" class="footer-button secondary" @click="emit('close')">关闭</button>
<button type="button" class="footer-button primary" @click="emit('use', template)">
用此模板发起签署
</button>
</footer>
</section>
</div>
</Teleport>
</template>
<style scoped>
.dialog-mask {
position: fixed;
z-index: 20;
inset: 0;
display: flex;
padding: 16px;
overflow-y: auto;
background: rgb(9 40 52 / 45%);
}
.preview-dialog {
display: flex;
flex-direction: column;
width: 720px;
max-width: 96vw;
max-height: calc(100vh - 32px);
margin: auto;
overflow: hidden;
background: #fff;
border-radius: 14px;
box-shadow: var(--sh-modal);
animation: dialog-pop 0.18s ease;
}
@keyframes dialog-pop {
from {
opacity: 0;
transform: scale(0.96) translateY(8px);
}
to {
opacity: 1;
transform: none;
}
}
.dialog-header {
display: flex;
gap: 12px;
align-items: center;
padding: 12px 18px;
border-bottom: 1px solid var(--line);
}
.dialog-title {
display: flex;
flex-wrap: wrap;
gap: 8px;
align-items: center;
min-width: 0;
}
.dialog-title h2 {
margin: 0;
overflow: hidden;
color: var(--ink);
font-size: 15px;
text-overflow: ellipsis;
white-space: nowrap;
}
.word-badge,
.status-badge {
padding: 3px 9px;
font-size: 11px;
font-weight: 700;
border-radius: 12px;
}
.word-badge {
color: var(--brand);
background: var(--brand-l);
}
.status-badge {
color: var(--ok);
background: var(--ok-l);
}
.close-button {
flex-shrink: 0;
margin-left: auto;
color: var(--mut);
font-size: 20px;
line-height: 1;
background: transparent;
}
.close-button:hover {
color: var(--ink);
}
.dialog-body {
min-height: 0;
padding: 12px 18px;
overflow-y: auto;
}
.preview-paper {
min-height: 420px;
padding: 26px 34px;
color: var(--ink);
font-size: 13px;
line-height: 1.9;
background: #fff;
border: 1px solid #eef4f6;
box-shadow: 0 1px 5px rgb(13 62 81 / 5%);
}
.preview-paper h3 {
margin: 0 0 6px;
color: var(--ink);
font-size: 17px;
text-align: center;
letter-spacing: 2px;
}
.preview-paper p {
margin: 0 0 7px;
text-indent: 2em;
text-align: justify;
}
.preview-paper .paper-number {
margin-bottom: 18px;
color: var(--mut);
font-size: 12px;
text-align: center;
text-indent: 0;
}
.signature-area {
display: flex;
flex-wrap: wrap;
gap: 40px;
align-items: flex-end;
margin-top: 22px;
}
.signature-area > div > span {
display: block;
margin-bottom: 6px;
color: var(--mut);
font-size: 12.5px;
}
.signature-line {
display: flex;
align-items: center;
justify-content: center;
min-width: 200px;
min-height: 64px;
color: var(--mut);
border-bottom: 2px dashed var(--line);
}
.signature-line.date-line {
min-width: 130px;
}
.dialog-footer {
display: flex;
gap: 10px;
align-items: center;
padding: 10px 18px;
background: #f8fbfc;
border-top: 1px solid var(--line);
}
.dialog-footer p {
max-width: 46%;
margin: 0;
overflow: hidden;
color: var(--mut);
font-size: 12px;
text-overflow: ellipsis;
white-space: nowrap;
}
.footer-button {
padding: 7px 13px;
font-size: 12px;
font-weight: 700;
border-radius: 7px;
}
.footer-button.secondary {
margin-left: auto;
color: var(--brand);
background: #fff;
border: 1px solid var(--brand);
}
.footer-button.primary {
color: #fff;
background: var(--brand);
border: 1px solid var(--brand);
}
.footer-button:hover {
filter: brightness(0.96);
}
@media (max-width: 680px) {
.preview-paper {
padding: 22px 18px;
}
.dialog-footer {
flex-wrap: wrap;
}
.dialog-footer p {
width: 100%;
max-width: none;
}
.footer-button.secondary {
margin-left: 0;
}
}
</style>
@@ -0,0 +1,216 @@
<script setup lang="ts">
import { computed } from 'vue'
import { documentStatusLabels } from '../mock'
import type { DocumentTemplate } from '../types'
const props = defineProps<{
template: DocumentTemplate
}>()
const emit = defineEmits<{
preview: [template: DocumentTemplate]
edit: [template: DocumentTemplate]
initiate: [template: DocumentTemplate]
}>()
const statusLabel = computed(() => documentStatusLabels[props.template.status])
</script>
<template>
<article class="template-card">
<div class="template-head">
<h3 :title="template.name">{{ template.name }}</h3>
<span class="template-status" :class="'status-' + template.status">
<i aria-hidden="true" />
{{ statusLabel }}
</span>
</div>
<p class="template-meta">
{{ template.code }} · {{ template.version }} · {{ template.department }}
</p>
<p class="template-description">{{ template.description }}</p>
<div class="template-footer">
<span class="department-tag">
<i aria-hidden="true" />
{{ template.department }}
</span>
<div class="template-actions">
<button type="button" class="card-button" @click="emit('preview', template)">预览</button>
<button type="button" class="card-button" @click="emit('edit', template)">编辑</button>
<button type="button" class="card-button primary" @click="emit('initiate', template)">
发起
</button>
</div>
</div>
</article>
</template>
<style scoped>
.template-card {
display: flex;
flex-direction: column;
gap: 10px;
min-width: 0;
padding: 16px;
background: var(--card);
border: 1px solid transparent;
border-radius: var(--r);
box-shadow: var(--sh);
transition:
border-color 0.15s ease,
box-shadow 0.15s ease,
transform 0.15s ease;
}
.template-card:hover {
border-color: var(--brand);
box-shadow: var(--sh-hover);
transform: translateY(-1px);
}
.template-head {
display: flex;
gap: 10px;
align-items: flex-start;
justify-content: space-between;
}
.template-head h3 {
display: -webkit-box;
flex: 1;
margin: 0;
overflow: hidden;
color: var(--ink);
font-size: 14px;
line-height: 1.4;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
}
.template-status {
display: inline-flex;
flex-shrink: 0;
gap: 5px;
align-items: center;
padding: 3px 9px;
font-size: 11px;
font-weight: 700;
white-space: nowrap;
border-radius: 12px;
}
.template-status i {
width: 6px;
height: 6px;
background: currentColor;
border-radius: 50%;
}
.status-enabled {
color: var(--ok);
background: var(--ok-l);
}
.status-draft {
color: #8a9aa3;
background: #eceef0;
}
.status-archived {
color: #8a9aa3;
background: #eceef0;
}
.status-review {
color: var(--warn);
background: var(--warn-l);
}
.template-meta {
margin: 0;
overflow: hidden;
color: var(--mut);
font-size: 11.5px;
text-overflow: ellipsis;
white-space: nowrap;
}
.template-description {
flex: 1;
display: -webkit-box;
min-height: 58px;
margin: 0;
overflow: hidden;
color: var(--mut);
font-size: 12px;
line-height: 1.6;
-webkit-box-orient: vertical;
-webkit-line-clamp: 3;
}
.template-footer {
display: flex;
gap: 10px;
align-items: center;
justify-content: space-between;
margin-top: 4px;
}
.department-tag {
display: inline-flex;
flex-shrink: 0;
gap: 5px;
align-items: center;
padding: 3px 9px;
color: var(--brand);
font-size: 11px;
font-weight: 700;
background: var(--brand-l);
border-radius: 12px;
}
.department-tag i {
width: 5px;
height: 5px;
background: currentColor;
border-radius: 50%;
}
.template-actions {
display: flex;
flex-shrink: 0;
gap: 6px;
}
.card-button {
padding: 4px 9px;
color: var(--brand);
font-size: 12px;
background: #fff;
border: 1px solid var(--brand);
border-radius: 5px;
}
.card-button:hover {
background: var(--brand-l);
}
.card-button.primary {
color: #fff;
background: var(--brand);
}
.card-button.primary:hover {
background: var(--brand-d);
}
@media (max-width: 680px) {
.template-footer {
align-items: flex-start;
flex-direction: column;
}
}
</style>