Files
xh-medical-sign-web/clinical-web/src/views/management/documents/components/DocumentTemplateCard.vue
T
yelan 81922d774f feat(文档库): 打通模板正文真实模式并新增渲染验证
模板列表接口不返回正文,展示、编辑与发起签署前需再取版本详情获取 contentHtml,
为此新增 getTemplateContent、createTemplateWithContent、updateTemplateContent 与
deleteTemplate(归档),并在签署端按 contentSha256 缓存正文快照。

同时新增 scripts/login.cjs 与 scripts/verify-pages.cjs,通过真实登录与 CDP
渲染截图、断言关键内容并收集运行时错误,并补充 .gitignore、eslint 忽略与文档说明。
2026-09-17 14:10:45 +08:00

261 lines
5.1 KiB
Vue

<script setup lang="ts">
import { computed } from 'vue'
import type { DocumentTemplate } from '../types'
import { documentStatusLabels } from '../mock'
const props = defineProps<{
template: DocumentTemplate
}>()
const emit = defineEmits<{
preview: [template: DocumentTemplate]
edit: [template: DocumentTemplate]
initiate: [template: DocumentTemplate]
remove: [template: DocumentTemplate]
}>()
const statusLabel = computed(() => documentStatusLabels[props.template.status])
/** 只有已发布 / 待复审的模板可以发起签署;草稿与已归档不可用 */
const canInitiate = computed(
() => props.template.status === 'published' || props.template.status === 'review',
)
const initiateTitle = computed(() =>
canInitiate.value ? '用此模板发起签署' : '仅已发布或待复审的模板可发起签署',
)
</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"
:disabled="!canInitiate"
:title="initiateTitle"
@click="emit('initiate', template)"
>
发起
</button>
<button
type="button"
class="card-button danger"
title="删除此文书"
@click="emit('remove', 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-published {
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);
}
.card-button:disabled {
color: #aebbc0;
background: #f1f5f6;
border-color: #dce5e8;
cursor: not-allowed;
}
.card-button.primary:disabled:hover {
background: #f1f5f6;
}
.card-button.danger {
color: #b3442f;
border-color: #cf7c68;
}
.card-button.danger:hover {
background: #fbeee9;
}
@media (max-width: 680px) {
.template-footer {
align-items: flex-start;
flex-direction: column;
}
}
</style>