feat(documents): 文档归属按院区分组并改用科室 id 落库

This commit is contained in:
yelan
2026-10-06 19:56:47 +08:00
parent a520f73c49
commit eda13a42c3
4 changed files with 121 additions and 36 deletions
@@ -41,6 +41,7 @@ import { toHistoryRows } from './history'
import {
canInitiateSigning,
DOCUMENT_LIBRARY_STATUSES,
GENERAL_OWNERSHIP,
readLibraryStatus,
resolveOwnershipDepartmentId,
templateWorkflowAction,
@@ -461,6 +462,19 @@ function generateTemplateCode(name: string) {
return `TPL-ED-${suffix}-${stamp}`
}
/**
* 归属勾选结果 → 共享科室名清单(演示文库的 sharedDepartments 存的是科室名)。
*
* 勾选值现在是科室 id(同名科室跨院区会重名,名字定位不到唯一一条),
* 这里在落本地前换回名字;「通用(全院)」与主科室本身不进这份清单。
*/
function sharedDepartmentNames(ownership: string[], primaryDepartmentId: string | null): string[] {
return ownership
.filter((value) => value !== GENERAL_OWNERSHIP && value !== primaryDepartmentId)
.map((id) => departments.value.find((department) => department.id === id)?.name)
.filter((name): name is string => Boolean(name))
}
/**
* 在本地文库里定位一份文书(连同它所在的分组与类别)。
*
@@ -526,7 +540,7 @@ function addLocalTemplate(form: DocumentPropsForm, departmentId: string | null):
departmentName,
campusId: campuses.value[0]?.id ?? '',
contentHtml: '',
sharedDepartments: form.ownership.filter((name) => name !== departmentName),
sharedDepartments: sharedDepartmentNames(form.ownership, departmentId),
}
category.documents.push(record)
@@ -562,7 +576,7 @@ function updateLocalProps(form: DocumentPropsForm, departmentId: string | null)
document.departmentId = departmentId
document.departmentName = targetName
// 主科室进 departmentId,其余勾选科室留在 sharedDepartments(与新建时同一口径)
document.sharedDepartments = form.ownership.filter((name) => name !== targetName)
document.sharedDepartments = sharedDepartmentNames(form.ownership, departmentId)
if (group.key !== targetKey) {
category.documents = category.documents.filter((item) => item.id !== document.id)
@@ -593,7 +607,7 @@ function updateLocalProps(form: DocumentPropsForm, departmentId: string | null)
}
async function handlePropsSubmit(form: DocumentPropsForm) {
const departmentId = resolveOwnershipDepartmentId(form.ownership, departments.value)
const departmentId = resolveOwnershipDepartmentId(form.ownership)
if (useMockLibrary) {
if (form.id) {
@@ -1166,6 +1180,7 @@ onMounted(() => {
:visible="propsDialogVisible"
:template="propsTemplate"
:departments="departments"
:campuses="campuses"
:can-set-general="canSetGeneral"
:is-mock="useMockLibrary"
:saving="propsSaving"