refactor(文书库): 状态口径收敛为启用中/停用两档并移除审核链路
This commit is contained in:
@@ -40,7 +40,6 @@ import WordEditorDialog from './components/WordEditorDialog.vue'
|
||||
import { toHistoryRows } from './history'
|
||||
import {
|
||||
canInitiateSigning,
|
||||
canToggleStatus,
|
||||
DOCUMENT_LIBRARY_STATUSES,
|
||||
readLibraryStatus,
|
||||
resolveOwnershipDepartmentId,
|
||||
@@ -164,10 +163,10 @@ const departmentTabs = computed<DepartmentTab[]>(() => [
|
||||
])
|
||||
|
||||
/**
|
||||
* 状态页签按原型 V10.2 的 libStatuses 铺开(启用中 / 草稿 / 归档 / 需复审 / 停用)。
|
||||
* 状态页签只有两档(启用中 / 停用),外加「全部」。
|
||||
*
|
||||
* 不再按后端模板状态枚举做页签:原型已经抛弃「发布 → 审核」那条工作流,
|
||||
* 7 个后端状态摆到界面上,科室会看到一堆看不懂也点不动的档位。
|
||||
* 不再有草稿 / 归档 / 需复审:审核链路已废弃,后端状态也会重写。
|
||||
* 也不按后端模板状态枚举做页签——枚举摆到界面上,科室会看到一堆看不懂也点不动的档位。
|
||||
* 计数按**全库**统计(不受科室页签影响),与原型 libCountByStatus 一致。
|
||||
*/
|
||||
const statusTabs = computed<StatusTab[]>(() => [
|
||||
@@ -514,10 +513,11 @@ function addLocalTemplate(form: DocumentPropsForm, departmentId: string | null):
|
||||
name: form.name,
|
||||
code: generateTemplateCode(form.name),
|
||||
version: form.versionNo || 'v1.0.0',
|
||||
// 新建落在「草稿」:正文还没写,此时不该出现在"可发起签署"里。
|
||||
// 原型也是这个口径——新建后先写正文,再由卡片上的「提交审核」送审。
|
||||
status: 'draft',
|
||||
backendStatus: 'DRAFT',
|
||||
// 新建即「启用中」:状态只剩两档,没有草稿这一档了。
|
||||
// 正文还没写时不该发起签署,但这道闸改由正文校验把守(见 toSigningTemplate),
|
||||
// 不再靠状态去挡——否则新建的文书会先显示成「停用」,科室以为是被人下线的。
|
||||
status: 'published',
|
||||
backendStatus: 'PUBLISHED',
|
||||
updatedBy: '本地演示',
|
||||
updatedAt: new Date().toISOString(),
|
||||
category: form.category,
|
||||
@@ -752,7 +752,13 @@ async function handleContentSubmit(form: DocumentContentForm) {
|
||||
|
||||
/* ---------------- 停用 / 启用 ---------------- */
|
||||
|
||||
/** 演示模式:就地翻转状态(停用 ↔ 启用) */
|
||||
/**
|
||||
* 演示模式:就地翻转状态(停用 ↔ 启用中)。
|
||||
*
|
||||
* 停用一侧落 backendStatus = 'DISABLED'(后端真实的停用取值)。
|
||||
* 归一的 status 只能写 'archived' —— api 层的 DocumentStatus 没有 disabled 这一项,
|
||||
* 而 readLibraryStatus 优先读 backendStatus,所以显示口径仍然是准确的。
|
||||
*/
|
||||
function toggleLocalStatus(template: DocumentTemplate) {
|
||||
const next: Pick<DocumentRecord, 'status' | 'backendStatus'> =
|
||||
readLibraryStatus(template) === '停用'
|
||||
@@ -776,17 +782,12 @@ function toggleLocalStatus(template: DocumentTemplate) {
|
||||
* 真实模式走后端版本动作(停用 → disable,启用 → publish),前端不自行改写 status:
|
||||
* 「谁在什么时候把这份文书放行到可签署 / 什么时候下线的」必须由后端留痕。
|
||||
*
|
||||
* 原型 V10.2 已经抛弃「发布 → 审核」那条工作流,所以这里只剩这一个状态动作;
|
||||
* 「提交审核」只在演示模式露出(见 DocumentTemplateCard)。
|
||||
* 这是页面上**唯一**的状态动作:状态只有两档,两档之间都能来回切,因此没有
|
||||
* 「某些档位不能停用 / 启用」这种分支了。
|
||||
*/
|
||||
async function handleToggleStatus(template: DocumentTemplate) {
|
||||
const status = readLibraryStatus(template)
|
||||
|
||||
if (!canToggleStatus(status)) {
|
||||
ElMessage.info(`「${status}」的文书没有停用 / 启用这一档,请用「提交审核」或「编辑正文」`)
|
||||
return
|
||||
}
|
||||
|
||||
if (!canToggleTemplate.value) {
|
||||
ElMessage.warning('当前账号没有停用 / 启用文书的权限')
|
||||
return
|
||||
@@ -829,34 +830,6 @@ async function handleToggleStatus(template: DocumentTemplate) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 提交审核。
|
||||
*
|
||||
* 只在演示模式露出:后端当前没有独立的「提交审核」按钮码,
|
||||
* 真实模式下这一步属于审核工作流,原型 V10.2 已经把它从科室侧拿掉了。
|
||||
* 演示库里把它落成「需复审」,让这条状态在页签上真的能看见。
|
||||
*/
|
||||
function handleSubmitReview(template: DocumentTemplate) {
|
||||
if (!canWriteDocument(DOC_TEMPLATE_PERMISSIONS.publish)) {
|
||||
ElMessage.warning('当前账号没有提交审核的权限')
|
||||
return
|
||||
}
|
||||
|
||||
library.value.forEach((department) =>
|
||||
department.categories.forEach((category) =>
|
||||
category.documents.forEach((document) => {
|
||||
if (document.id === template.id) {
|
||||
document.status = 'review'
|
||||
document.backendStatus = 'PENDING_REVIEW'
|
||||
document.updatedAt = new Date().toISOString()
|
||||
}
|
||||
}),
|
||||
),
|
||||
)
|
||||
|
||||
ElMessage.success('已提交审核,审核通过后自动发布')
|
||||
}
|
||||
|
||||
/* ---------------- 历史记录 ---------------- */
|
||||
|
||||
/**
|
||||
@@ -959,7 +932,8 @@ async function viewHistoryVersion(versionId: string) {
|
||||
* 把文书转成签署模板。
|
||||
*
|
||||
* 转之前要确保有正文:真实模式的列表接口不返回正文,缺正文时发起签署会签出一份
|
||||
* 与模板无关的空文书。因此这里在缺正文时先取回,取不到就拒绝发起。
|
||||
* 与模板无关的空文书。因此这里在缺正文时先取回,取不到就拒绝发起;
|
||||
* 演示模式没有「取回」这一步,但同样在缺正文时拒绝——新建的文书正是这种。
|
||||
*/
|
||||
async function toSigningTemplate(template: DocumentTemplate): Promise<SigningTemplate | null> {
|
||||
if (!useMockLibrary && !template.currentVersionId) {
|
||||
@@ -984,6 +958,11 @@ async function toSigningTemplate(template: DocumentTemplate): Promise<SigningTem
|
||||
ElMessage.error('未能取到该文书的正文内容,无法发起签署')
|
||||
return null
|
||||
}
|
||||
} else if (!contentHtml) {
|
||||
// 演示模式:状态只剩两档,新建的文书直接落在「启用中」,
|
||||
// 于是「有没有正文」成了唯一那道闸——空正文签出来的是一份与模板无关的白纸。
|
||||
ElMessage.error('该文书还没有正文,请先点「编辑正文」编写内容后再发起签署')
|
||||
return null
|
||||
}
|
||||
|
||||
return {
|
||||
@@ -1132,13 +1111,11 @@ onMounted(() => {
|
||||
v-for="template in filteredTemplates"
|
||||
:key="template.id"
|
||||
:template="template"
|
||||
:is-mock="useMockLibrary"
|
||||
@preview="handlePreview"
|
||||
@edit-props="openPropsDialog"
|
||||
@edit-content="openContentEditor"
|
||||
@history="openHistory"
|
||||
@toggle-status="handleToggleStatus"
|
||||
@submit-review="handleSubmitReview"
|
||||
@initiate="openSigningDialog"
|
||||
/>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user