Files
shanxia2.0/web-admin/src/components/bx/base/ApprovalHistoryView.vue
T
2026-07-01 18:52:26 +08:00

203 lines
4.9 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<script setup lang="ts">
import { computed } from 'vue'
import { Check, Close, Clock } from '@element-plus/icons-vue'
interface ApprovalHistoryItem {
id: number | string
nodeName: string
nodeOrder: number
approvalStatus: string
approvalOpinion?: string | null
approverName: string
approvalTime?: string | null
}
const props = withDefaults(
defineProps<{
items: ApprovalHistoryItem[]
loading?: boolean
}>(),
{
loading: false
}
)
const statusConfig: Record<string, { color: string; text: string; icon: any; circleClass: string }> = {
approved: { color: 'var(--success)', text: '已通过', icon: Check, circleClass: 'is-approved' },
rejected: { color: 'var(--danger)', text: '已驳回', icon: Close, circleClass: 'is-rejected' },
pending: { color: 'var(--primary)', text: '待处理', icon: Clock, circleClass: 'is-pending' }
}
function getConfig(status: string) {
return (
statusConfig[status] || {
color: 'var(--text-muted)',
text: '未知',
icon: null,
circleClass: 'is-pending'
}
)
}
const sortedItems = computed(() =>
[...props.items].sort((a, b) => {
const ta = a.approvalTime ? new Date(a.approvalTime).getTime() : 0
const tb = b.approvalTime ? new Date(b.approvalTime).getTime() : 0
if (ta !== tb) return ta - tb
return a.nodeOrder - b.nodeOrder
})
)
</script>
<template>
<div class="approval-history-view">
<el-skeleton v-if="loading" :rows="2" animated />
<template v-else>
<p v-if="sortedItems.length === 0" class="approval-empty">暂无审批历史</p>
<div v-else class="approval-history-scroll">
<div class="approval-history-track">
<template v-for="(item, index) in sortedItems" :key="item.id">
<div class="approval-history-step">
<div
class="approval-history-circle"
:class="getConfig(item.approvalStatus).circleClass"
>
<el-icon v-if="getConfig(item.approvalStatus).icon" class="approval-status-icon">
<component :is="getConfig(item.approvalStatus).icon" />
</el-icon>
</div>
<div class="approval-history-label">{{ item.nodeName }}</div>
<div
class="approval-history-status"
:style="{ color: getConfig(item.approvalStatus).color }"
>
{{ getConfig(item.approvalStatus).text }}
</div>
<div class="approval-history-meta">
<span v-if="item.approverName">审批人:{{ item.approverName }}</span>
<span v-if="item.approvalTime">{{ item.approvalTime }}</span>
</div>
<div v-if="item.approvalOpinion" class="approval-history-opinion">
{{ item.approvalOpinion }}
</div>
</div>
<div v-if="index < sortedItems.length - 1" class="approval-history-connector" />
</template>
</div>
</div>
</template>
</div>
</template>
<style scoped>
.approval-history-view {
padding: 4px 0;
}
.approval-empty {
margin: 0;
text-align: center;
color: var(--text-muted);
font-size: 13px;
padding: 24px 0;
}
.approval-history-scroll {
overflow-x: auto;
padding: 8px 4px 12px;
}
.approval-history-track {
display: flex;
align-items: flex-start;
justify-content: flex-start;
gap: 0;
min-width: min-content;
padding: 4px 8px;
}
.approval-history-step {
display: flex;
flex-direction: column;
align-items: center;
gap: 6px;
width: 132px;
flex: 0 0 auto;
text-align: center;
}
.approval-history-circle {
width: 36px;
height: 36px;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
border: 2px solid #e2e8f0;
background: #f8fafc;
color: #1e293b;
}
.approval-history-circle.is-approved {
border-color: var(--success, #1ca851);
background: linear-gradient(135deg, #1ca851, #168f45);
color: #fff;
box-shadow: 0 2px 8px rgba(28, 168, 81, 0.25);
}
.approval-history-circle.is-rejected {
border-color: var(--danger, #ef4444);
background: #fef2f2;
color: var(--danger, #ef4444);
}
.approval-history-circle.is-pending {
border-color: var(--primary, #1ca851);
background: #fff;
color: var(--primary, #1ca851);
}
.approval-status-icon {
width: 16px;
height: 16px;
}
.approval-history-label {
font-size: 13px;
font-weight: 600;
color: var(--text);
line-height: 1.3;
}
.approval-history-status {
font-size: 12px;
font-weight: 600;
}
.approval-history-meta {
display: flex;
flex-direction: column;
gap: 2px;
font-size: 11px;
color: var(--text-muted);
line-height: 1.35;
word-break: break-all;
}
.approval-history-opinion {
font-size: 11px;
color: var(--text-muted);
line-height: 1.35;
max-width: 120px;
word-break: break-all;
}
.approval-history-connector {
width: 40px;
height: 2px;
background: #cbd5e1;
margin-top: 18px;
flex-shrink: 0;
}
</style>