feat: 提交
This commit is contained in:
@@ -43,9 +43,11 @@ import {
|
||||
DOCUMENT_LIBRARY_STATUSES,
|
||||
readLibraryStatus,
|
||||
resolveOwnershipDepartmentId,
|
||||
templateWorkflowAction,
|
||||
templateWorkflowLabel,
|
||||
} from './library'
|
||||
import { loadDocumentLibrary, saveDocumentLibrary } from './mock'
|
||||
import { DOC_TEMPLATE_PERMISSIONS } from './permissions'
|
||||
import { DOC_TEMPLATE_PERMISSIONS, workflowPermission } from './permissions'
|
||||
import type {
|
||||
DepartmentTab,
|
||||
DocumentContentForm,
|
||||
@@ -163,10 +165,8 @@ const departmentTabs = computed<DepartmentTab[]>(() => [
|
||||
])
|
||||
|
||||
/**
|
||||
* 状态页签只有两档(启用中 / 停用),外加「全部」。
|
||||
*
|
||||
* 不再有草稿 / 归档 / 需复审:审核链路已废弃,后端状态也会重写。
|
||||
* 也不按后端模板状态枚举做页签——枚举摆到界面上,科室会看到一堆看不懂也点不动的档位。
|
||||
* 状态页签只有两组(启用中 / 停用),外加「全部」。卡片按需显示待发布等具体版本状态;
|
||||
* 不按完整后端枚举增加筛选页签。
|
||||
* 计数按**全库**统计(不受科室页签影响),与原型 libCountByStatus 一致。
|
||||
*/
|
||||
const statusTabs = computed<StatusTab[]>(() => [
|
||||
@@ -763,10 +763,11 @@ async function handleContentSubmit(form: DocumentContentForm) {
|
||||
* 而 readLibraryStatus 优先读 backendStatus,所以显示口径仍然是准确的。
|
||||
*/
|
||||
function toggleLocalStatus(template: DocumentTemplate) {
|
||||
const action = templateWorkflowAction(template)
|
||||
const next: Pick<DocumentRecord, 'status' | 'backendStatus'> =
|
||||
readLibraryStatus(template) === '停用'
|
||||
? { status: 'published', backendStatus: 'PUBLISHED' }
|
||||
: { status: 'archived', backendStatus: 'DISABLED' }
|
||||
action === 'disable'
|
||||
? { status: 'archived', backendStatus: 'DISABLED' }
|
||||
: { status: 'published', backendStatus: 'PUBLISHED' }
|
||||
|
||||
library.value.forEach((department) =>
|
||||
department.categories.forEach((category) =>
|
||||
@@ -782,27 +783,31 @@ function toggleLocalStatus(template: DocumentTemplate) {
|
||||
/**
|
||||
* 停用 / 启用。
|
||||
*
|
||||
* 真实模式走后端版本动作(停用 → disable,启用 → publish),前端不自行改写 status:
|
||||
* 真实模式走后端版本动作(草稿/停用 → enable,审核通过 → publish,已发布 → disable):
|
||||
* 「谁在什么时候把这份文书放行到可签署 / 什么时候下线的」必须由后端留痕。
|
||||
*
|
||||
* 这是页面上**唯一**的状态动作:状态只有两档,两档之间都能来回切,因此没有
|
||||
* 「某些档位不能停用 / 启用」这种分支了。
|
||||
* 仅在后端支持的状态上显示动作;审核中、驳回和归档版本不能直接切换。
|
||||
*/
|
||||
async function handleToggleStatus(template: DocumentTemplate) {
|
||||
const status = readLibraryStatus(template)
|
||||
const action = templateWorkflowAction(template)
|
||||
const nextLabel = templateWorkflowLabel(template)
|
||||
|
||||
if (!canToggleTemplate.value) {
|
||||
ElMessage.warning('当前账号没有停用 / 启用文书的权限')
|
||||
if (!action) {
|
||||
ElMessage.info('该文书当前状态不可操作')
|
||||
return
|
||||
}
|
||||
|
||||
const nextLabel = status === '停用' ? '启用' : '停用'
|
||||
const action = status === '停用' ? 'publish' : 'disable'
|
||||
if (!canWriteDocument(workflowPermission(action))) {
|
||||
ElMessage.warning(`当前账号没有${nextLabel}文书的权限`)
|
||||
return
|
||||
}
|
||||
|
||||
const confirmed = await ElMessageBox.confirm(
|
||||
status === '停用'
|
||||
? `确定启用「${template.name}」?启用后各科室可见,并可发起签署。`
|
||||
: `确定停用「${template.name}」?停用后不能再发起新的签署,已签署的记录不受影响。`,
|
||||
nextLabel === '发布'
|
||||
? `确定发布「${template.name}」${template.version}?发布后该版本可用于发起签署。`
|
||||
: nextLabel === '启用'
|
||||
? `确定启用「${template.name}」?启用后各科室可见,并可发起签署。`
|
||||
: `确定停用「${template.name}」?停用后不能再发起新的签署,已签署的记录不受影响。`,
|
||||
`确认${nextLabel}`,
|
||||
{ type: 'warning', confirmButtonText: nextLabel, cancelButtonText: '取消' },
|
||||
)
|
||||
@@ -819,13 +824,16 @@ async function handleToggleStatus(template: DocumentTemplate) {
|
||||
return
|
||||
}
|
||||
|
||||
if (!template.versionId) {
|
||||
const versionId = action === 'disable'
|
||||
? template.currentVersionId ?? template.versionId
|
||||
: template.versionId
|
||||
if (!versionId) {
|
||||
ElMessage.error('该文书没有可操作的版本,请刷新后重试')
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
await updateTemplateVersionStatus(template.id, template.versionId, action)
|
||||
await updateTemplateVersionStatus(template.id, versionId, action)
|
||||
ElMessage.success(`已${nextLabel}`)
|
||||
await loadLibrary()
|
||||
} catch {
|
||||
@@ -997,6 +1005,11 @@ async function openSigningDialog(template: DocumentTemplate) {
|
||||
return
|
||||
}
|
||||
|
||||
if (!useMockLibrary && !template.currentVersionId) {
|
||||
ElMessage.info('该文书还没有已发布版本,无法发起签署')
|
||||
return
|
||||
}
|
||||
|
||||
closePreview()
|
||||
|
||||
try {
|
||||
@@ -1021,7 +1034,7 @@ function closeSigningDialog() {
|
||||
// 闭环:文档库发起签署后跳到工作台并选中该任务,否则任务创建成功但用户看不到后续
|
||||
function handleTaskCreated(task: SigningTaskRecord) {
|
||||
closeSigningDialog()
|
||||
void router.push({ name: 'workbench-signing', query: { taskId: task.id } })
|
||||
void router.push({ path: '/sign/workbench', query: { taskId: task.id } })
|
||||
}
|
||||
|
||||
/* ---------------- 页面级 ---------------- */
|
||||
|
||||
Reference in New Issue
Block a user