feat: 提交

This commit is contained in:
cnxianyi
2026-09-29 18:49:45 +08:00
parent 8d8fa2af47
commit 09bcf20def
17 changed files with 357 additions and 62 deletions
@@ -9,6 +9,8 @@ import {
isGeneralOwnership,
readLibraryStatus,
readStatusTone,
templateWorkflowAction,
templateWorkflowLabel,
} from '../library'
import { DOC_TEMPLATE_PERMISSIONS, workflowPermission } from '../permissions'
import type { DocumentTemplate } from '../types'
@@ -27,7 +29,22 @@ const emit = defineEmits<{
}>()
const status = computed(() => readLibraryStatus(props.template))
const tone = computed(() => readStatusTone(status.value))
const rawStatus = computed(() => props.template.backendStatus?.toUpperCase())
const statusLabel = computed(() => {
if (rawStatus.value === 'DRAFT') {
return props.template.currentVersionId ? '有新版本待发布' : '待发布'
}
if (rawStatus.value === 'APPROVED') return '待发布'
if (rawStatus.value === 'PENDING_REVIEW') return '待审核'
if (rawStatus.value === 'REJECTED') return '已驳回'
if (rawStatus.value === 'ARCHIVED') return '已归档'
return status.value
})
const tone = computed(() =>
['DRAFT', 'APPROVED', 'PENDING_REVIEW', 'REJECTED', 'ARCHIVED'].includes(rawStatus.value ?? '')
? 'stopped'
: readStatusTone(status.value),
)
const dotColor = computed(() => DOCUMENT_STATUS_DOT[tone.value])
const isGeneral = computed(() => isGeneralOwnership(props.template))
@@ -45,18 +62,19 @@ const ownershipLabel = computed(() =>
const sharedCount = computed(() => props.template.sharedDepartments?.length ?? 0)
/**
* 只有「启用中」能发起签署;「停用」已下线。
*
* 这里只看状态,不看正文——真实模式的列表接口不返回正文,按正文判断会让所有
* 真实模板的「发起」按钮都消失。缺正文由发起那一步拦下(见 index.vue 的 toSigningTemplate)。
* 真实模式必须存在 currentVersionId 才能发起签署;演示模式按「启用中 / 停用」判断。
* 列表接口不返回正文,正文完整性由发起那一步检查(见 index.vue 的 toSigningTemplate)。
*/
const canInitiate = computed(() => canInitiateSigning(status.value))
const canInitiate = computed(() =>
props.template.backendStatus
? Boolean(props.template.currentVersionId)
: canInitiateSigning(status.value),
)
const initiateTitle = computed(() =>
canInitiate.value ? '用此文书发起签署' : '仅「启用中」的文书可发起签署',
canInitiate.value ? '用此文书发起签署' : '该文书还没有已发布版本,无法发起签署',
)
/** 两档之间都能来回切,所以这个按钮没有「不适用」的状态 */
const toggleLabel = computed(() => (status.value === '停用' ? '启用' : '停用'))
const toggleLabel = computed(() => templateWorkflowLabel(props.template))
/**
* 检查类型 / 关联项目编码(原型 V10.2 卡片上的两条信息)。
@@ -67,14 +85,15 @@ const toggleLabel = computed(() => (status.value === '停用' ? '启用' : '停
const examType = computed(() => props.template.examType?.trim() ?? '')
const projectCodes = computed(() => (props.template.projectCodes ?? []).filter(Boolean))
/** 停用/启用走的是后端版本动作:停用 → disable,启用 → publish */
const toggleAction = computed<TemplateVersionAction>(() =>
status.value === '停用' ? 'publish' : 'disable',
const toggleAction = computed<TemplateVersionAction | null>(() =>
templateWorkflowAction(props.template),
)
// 按钮文案与权限码的对应关系集中在模板里,避免多处各写一份
const permissions = DOC_TEMPLATE_PERMISSIONS
const togglePermission = computed(() => workflowPermission(toggleAction.value))
const togglePermission = computed(() =>
workflowPermission(toggleAction.value ?? 'disable'),
)
</script>
<template>
@@ -83,7 +102,7 @@ const togglePermission = computed(() => workflowPermission(toggleAction.value))
<h3 class="tpl-title" :title="template.name">{{ template.name }}</h3>
<span class="tpl-status" :class="'tone-' + tone">
<i :style="{ background: dotColor }" aria-hidden="true" />
{{ status }}
{{ statusLabel }}
</span>
</div>
@@ -133,13 +152,16 @@ const togglePermission = computed(() => workflowPermission(toggleAction.value))
<span class="ft-spacer" />
<button
v-if="toggleAction"
v-permission="togglePermission"
type="button"
class="card-button"
:title="
toggleLabel === '停用'
? '停用后各科室不可见、不可发起签署'
: '启用后各科室可见并可发起签署'
? '停用后不可发起新的签署'
: toggleLabel === '发布'
? '发布当前版本后即可发起签署'
: '启用后各科室可见并可发起签署'
"
@click="emit('toggle-status', template)"
>