build(clinical-web): 新增富文本编辑与 Word 转换依赖

This commit is contained in:
yelan
2026-09-10 12:03:21 +08:00
parent 7bea008680
commit 23d85cf8ce
11 changed files with 1398 additions and 1063 deletions
@@ -10,12 +10,10 @@ import DocumentFilterTabs from './components/DocumentFilterTabs.vue'
import DocumentLibraryHeader from './components/DocumentLibraryHeader.vue'
import DocumentPreviewDialog from './components/DocumentPreviewDialog.vue'
import DocumentTemplateCard from './components/DocumentTemplateCard.vue'
import TemplateEditorDialog from './components/TemplateEditorDialog.vue'
import WordEditorDialog from './components/WordEditorDialog.vue'
import { documentLibrary, documentStatusOptions } from './mock'
import type { TemplateVersionAction } from './types'
import type {
DepartmentTab,
DocumentStatus,
DocumentDepartment,
DocumentFilterForm,
DocumentTemplate,
@@ -29,11 +27,9 @@ import type {
const library = ref<DocumentDepartment[]>([])
const selectedTemplate = ref<DocumentTemplate | null>(null)
const signingTemplate = ref<SigningTemplate | null>(null)
const editorTemplate = ref<DocumentTemplate | null>(null)
const wordEditingTemplate = ref<DocumentTemplate | null>(null)
const wordEditorVisible = ref(false)
const signingDialogVisible = ref(false)
const editorVisible = ref(false)
const editorSaving = ref(false)
const workflowSaving = ref(false)
const campuses: CampusRecord[] = [
{ id: 'campus-main', code: 'MAIN', name: '本部院区', status: 'ENABLED', sortNo: 1 },
@@ -124,8 +120,9 @@ function closePreview() {
}
function showAddMessage() {
editorTemplate.value = null
editorVisible.value = true
// Word 自维护方案:新增文书直接进入 Word 编辑器(粘贴/导入 .docx)。
wordEditingTemplate.value = null
wordEditorVisible.value = true
}
function showExportMessage() {
@@ -133,13 +130,14 @@ function showExportMessage() {
}
function showEditMessage(template: DocumentTemplate) {
editorTemplate.value = template
editorVisible.value = true
// Word 自维护方案:所有文书统一在 Word 编辑器中维护。
wordEditingTemplate.value = template
wordEditorVisible.value = true
}
function closeEditor() {
editorVisible.value = false
editorTemplate.value = null
function closeWordEditor() {
wordEditorVisible.value = false
wordEditingTemplate.value = null
}
function addLocalTemplate(form: TemplateEditorForm) {
@@ -181,73 +179,29 @@ function addLocalTemplate(form: TemplateEditorForm) {
}
function saveTemplate(form: TemplateEditorForm) {
editorSaving.value = true
try {
if (form.id) {
library.value.forEach((department) =>
department.categories.forEach((category) =>
category.documents.forEach((document) => {
if (document.id === form.id) {
document.version = form.versionNo || document.version
document.contentHtml = form.contentHtml
document.description = form.description
}
}),
),
)
} else {
addLocalTemplate(form)
}
closeEditor()
ElMessage.success(form.id ? '模板新版本已保存' : '模板已创建')
} catch {
ElMessage.error(form.id ? '模板版本保存失败,请稍后重试' : '模板创建失败,请稍后重试')
} finally {
editorSaving.value = false
}
}
function updateLocalTemplateStatus(templateId: string, action: TemplateVersionAction) {
const nextStatus: DocumentStatus =
action === 'submit-review' || action === 'reject'
? 'review'
: action === 'disable' || action === 'archive'
? 'archived'
: 'enabled'
library.value.forEach((department) =>
department.categories.forEach((category) =>
category.documents.forEach((document) => {
if (document.id === templateId) {
document.status = nextStatus
}
}),
),
)
}
function handleWorkflow(action: TemplateVersionAction) {
const template = editorTemplate.value
const versionId = template?.versionId
if (!template || !versionId) {
ElMessage.error('当前模板没有可操作的版本')
return
if (form.id) {
library.value.forEach((department) =>
department.categories.forEach((category) =>
category.documents.forEach((document) => {
if (document.id === form.id) {
document.name = form.name || document.name
document.version = form.versionNo || document.version
document.contentHtml = form.contentHtml
document.description = form.description
}
}),
),
)
} else {
addLocalTemplate(form)
}
workflowSaving.value = true
try {
updateLocalTemplateStatus(template.id, action)
closeEditor()
ElMessage.success('模板版本状态已更新')
} finally {
workflowSaving.value = false
}
closeWordEditor()
ElMessage.success(form.id ? '文书已更新' : '文书已创建')
}
// 版本工作流(提交审核/发布等)随原模板编辑器移除,待签署端接入后按后端工作流接口恢复。
function toSigningTemplate(template: DocumentTemplate): SigningTemplate {
return {
id: template.id,
@@ -340,16 +294,13 @@ onMounted(loadLibrary)
:initial-template="signingTemplate"
@close="closeSigningDialog"
/>
<TemplateEditorDialog
:visible="editorVisible"
:template="editorTemplate"
<WordEditorDialog
:visible="wordEditorVisible"
:template="wordEditingTemplate"
:campuses="campuses"
:departments="departments"
:saving="editorSaving"
:workflow-saving="workflowSaving"
@close="closeEditor"
@close="wordEditorVisible = false"
@save="saveTemplate"
@workflow="handleWorkflow"
/>
</section>
</template>