feat(protocol): 记录协议单操作前后快照便于责任追溯
为细胞存储与科研捐赠协议增加 append-only 操作日志,覆盖 Web/小程序 create/update/delete/状态类动作,并在查看弹窗与移动详情提供操作日志入口(Issue #24)。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
1fb25f4fc2
commit
4a12d92631
14 files changed
+1099
-6
No files matched your search
@@ -1174,6 +1174,41 @@
|
||||
</el-table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 操作日志(Issue #24) -->
|
||||
<div id="view-section-operation-log" class="section-card section-card--white">
|
||||
<div class="section-title section-title--banner"><h3>操作日志</h3></div>
|
||||
<div class="list-body list-wrap view-inner-table-wrap">
|
||||
<el-table
|
||||
v-loading="operationLogLoading"
|
||||
class="list-table inner-table"
|
||||
:data="operationLogRecords"
|
||||
stripe
|
||||
empty-text="暂无操作日志"
|
||||
>
|
||||
<el-table-column type="index" label="序号" min-width="68" align="center" header-align="center" />
|
||||
<el-table-column label="动作" min-width="100" align="center" header-align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="operationActionTagType(String(row.action || ''))" size="small">
|
||||
{{ operationActionLabel(String(row.action || '')) }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="来源端" min-width="90" align="center" header-align="center">
|
||||
<template #default="{ row }">{{ operationChannelLabel(String(row.clientChannel || '')) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作时间" min-width="170" align="center" header-align="center">
|
||||
<template #default="{ row }">{{ dash(row.operateTime) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作人" min-width="120" align="center" header-align="center">
|
||||
<template #default="{ row }">{{ dash(row.operatorUserName) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="变更摘要" min-width="260" align="left" header-align="center" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ operationSummary(row) }}</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
@@ -1226,6 +1261,7 @@
|
||||
fetchCollectionProtocolAuditList,
|
||||
fetchCollectionProtocolDetail,
|
||||
fetchCollectionProtocolStatusChanges,
|
||||
fetchCollectionProtocolOperationLogs,
|
||||
type CollectionProtocolRow
|
||||
} from '@/api/collection-protocol'
|
||||
import {
|
||||
@@ -1317,6 +1353,7 @@
|
||||
}
|
||||
tabs.push({ key: 'attachment', label: '附件信息' })
|
||||
tabs.push({ key: 'status-change', label: '状态变更记录' })
|
||||
tabs.push({ key: 'operation-log', label: '操作日志' })
|
||||
return tabs
|
||||
})
|
||||
|
||||
@@ -1327,6 +1364,90 @@
|
||||
const bundle = ref<Record<string, any> | null>(null)
|
||||
const auditRecords = ref<Array<Record<string, unknown>>>([])
|
||||
const statusChangeRecords = ref<Array<Record<string, unknown>>>([])
|
||||
const operationLogLoading = ref(false)
|
||||
const operationLogRecords = ref<Array<Record<string, unknown>>>([])
|
||||
|
||||
const OPERATION_ACTION_LABEL: Record<string, string> = {
|
||||
create: '创建',
|
||||
update: '修改',
|
||||
delete: '删除',
|
||||
void: '作废',
|
||||
activate: '生效',
|
||||
expire: '过期',
|
||||
to_research: '转科研',
|
||||
to_storage: '转细胞存储',
|
||||
audit: '审核'
|
||||
}
|
||||
const OPERATION_ACTION_TAG: Record<string, 'success' | 'warning' | 'danger' | 'primary' | 'info'> = {
|
||||
create: 'success',
|
||||
update: 'primary',
|
||||
delete: 'danger',
|
||||
void: 'danger',
|
||||
activate: 'success',
|
||||
expire: 'warning',
|
||||
to_research: 'primary',
|
||||
to_storage: 'primary',
|
||||
audit: 'info'
|
||||
}
|
||||
|
||||
function operationActionLabel(action: string) {
|
||||
return OPERATION_ACTION_LABEL[action] || action || '—'
|
||||
}
|
||||
function operationActionTagType(action: string) {
|
||||
return OPERATION_ACTION_TAG[action] || 'info'
|
||||
}
|
||||
function operationChannelLabel(channel: string) {
|
||||
if (channel === 'mini') return '小程序'
|
||||
if (channel === 'web') return 'Web'
|
||||
return channel || '—'
|
||||
}
|
||||
function operationSummary(row: Record<string, unknown>) {
|
||||
const before = (row.before || {}) as Record<string, any>
|
||||
const after = (row.after || {}) as Record<string, any>
|
||||
const beforeProto = (before.protocol || before.donation || {}) as Record<string, any>
|
||||
const afterProto = (after.protocol || after.donation || {}) as Record<string, any>
|
||||
const beforeParty = (before.partyCustomer || before.party || {}) as Record<string, any>
|
||||
const afterParty = (after.partyCustomer || after.party || {}) as Record<string, any>
|
||||
const parts: string[] = []
|
||||
const beforeStatus = String(beforeProto.protocolStatus || beforeProto.donationStatus || '')
|
||||
const afterStatus = String(afterProto.protocolStatus || afterProto.donationStatus || '')
|
||||
if (beforeStatus || afterStatus) {
|
||||
if (beforeStatus && afterStatus && beforeStatus !== afterStatus) {
|
||||
parts.push(`状态 ${beforeStatus}→${afterStatus}`)
|
||||
} else if (afterStatus) {
|
||||
parts.push(`状态 ${afterStatus}`)
|
||||
}
|
||||
}
|
||||
for (const key of ['motherName', 'customerName', 'donorName', 'name']) {
|
||||
const b = String(beforeParty[key] || '').trim()
|
||||
const a = String(afterParty[key] || '').trim()
|
||||
if (b || a) {
|
||||
if (b && a && b !== a) parts.push(`姓名 ${b}→${a}`)
|
||||
else if (a && !b) parts.push(`姓名 ${a}`)
|
||||
break
|
||||
}
|
||||
}
|
||||
const beforeSamples = Array.isArray(before.samples) ? before.samples : []
|
||||
const afterSamples = Array.isArray(after.samples) ? after.samples : []
|
||||
if (beforeSamples.length || afterSamples.length) {
|
||||
const pick = (list: any[]) =>
|
||||
list
|
||||
.map((s) => `${s?.sampleCode || ''}:${s?.sampleStatus || s?.status || ''}`)
|
||||
.filter((x) => x !== ':')
|
||||
.join(',')
|
||||
const bs = pick(beforeSamples)
|
||||
const as = pick(afterSamples)
|
||||
if (bs || as) {
|
||||
if (bs && as && bs !== as) parts.push(`样本 ${bs}→${as}`)
|
||||
else if (as) parts.push(`样本 ${as}`)
|
||||
}
|
||||
}
|
||||
if (!parts.length) {
|
||||
const remark = String(row.remark || '').trim()
|
||||
return remark || '见前后快照'
|
||||
}
|
||||
return parts.join(';')
|
||||
}
|
||||
|
||||
const STATUS_CHANGE_TYPE_LABEL: Record<string, string> = {
|
||||
activate: '生效',
|
||||
@@ -2075,6 +2196,7 @@
|
||||
async function loadStatusChangeRecords() {
|
||||
if (!props.protocolId) {
|
||||
statusChangeRecords.value = []
|
||||
operationLogRecords.value = []
|
||||
return
|
||||
}
|
||||
statusChangeLoading.value = true
|
||||
@@ -2083,11 +2205,28 @@
|
||||
statusChangeRecords.value = res.list || []
|
||||
} catch {
|
||||
statusChangeRecords.value = []
|
||||
operationLogRecords.value = []
|
||||
} finally {
|
||||
statusChangeLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function loadOperationLogRecords() {
|
||||
if (!props.protocolId) {
|
||||
operationLogRecords.value = []
|
||||
return
|
||||
}
|
||||
operationLogLoading.value = true
|
||||
try {
|
||||
const res = await fetchCollectionProtocolOperationLogs(props.protocolId)
|
||||
operationLogRecords.value = res.list || []
|
||||
} catch {
|
||||
operationLogRecords.value = []
|
||||
} finally {
|
||||
operationLogLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function loadAuditRecords() {
|
||||
if (!props.showAuditHistory || !props.protocolId) {
|
||||
auditRecords.value = []
|
||||
@@ -2115,10 +2254,12 @@
|
||||
bundle.value = null
|
||||
auditRecords.value = []
|
||||
statusChangeRecords.value = []
|
||||
operationLogRecords.value = []
|
||||
|
||||
const baseLookupsPromise = loadBaseLookups().catch(() => {})
|
||||
const auditPromise = props.showAuditHistory ? loadAuditRecords() : null
|
||||
const statusChangePromise = loadStatusChangeRecords()
|
||||
const operationLogPromise = loadOperationLogRecords()
|
||||
|
||||
let data: Record<string, any> | null = null
|
||||
try {
|
||||
@@ -2136,6 +2277,7 @@
|
||||
void finishLookups(data, baseLookupsPromise)
|
||||
void auditPromise
|
||||
void statusChangePromise
|
||||
void operationLogPromise
|
||||
if (props.highlightSampleCode) {
|
||||
nextTick(() => {
|
||||
document
|
||||
@@ -2159,6 +2301,7 @@
|
||||
bundle.value = null
|
||||
auditRecords.value = []
|
||||
statusChangeRecords.value = []
|
||||
operationLogRecords.value = []
|
||||
activeTab.value = 'basic'
|
||||
detailLoading.value = false
|
||||
lookupLoading.value = false
|
||||
|
||||
Reference in new issue
Block a user