feat: 完善报销单审批流程及退回原因追踪

新增直属领导审批通过接口和审批待办列表查询,报销单退回
支持原因码分类和审批环节标记,优化票据附件去重和路径
回退查找,前端新增退回原因对话框、审批收件箱和工作台
图标组件,补充工具函数和单元测试覆盖。
This commit is contained in:
caoxiaozhu
2026-05-20 21:00:47 +08:00
parent f8b25a7ccc
commit 002bf4f756
62 changed files with 5331 additions and 2101 deletions

View File

@@ -7,17 +7,17 @@
</div>
<div class="top-actions">
<template v-if="isChat">
<div class="kpi-chips">
<div v-for="kpi in chatKpis" :key="kpi.label" class="kpi-chip" :style="{ '--chip-color': kpi.color }">
<span class="chip-value">{{ kpi.value }}<small>{{ kpi.unit }}</small></span>
<span class="chip-label">{{ kpi.label }}</span>
<span class="chip-delta" :class="kpi.trend">{{ kpi.meta }}</span>
</div>
</div>
</template>
<template v-else-if="isOverview">
<template v-if="isChat">
<div class="kpi-chips">
<div v-for="kpi in chatKpis" :key="kpi.label" class="kpi-chip" :style="{ '--chip-color': kpi.color }">
<span class="chip-value">{{ kpi.value }}<small>{{ kpi.unit }}</small></span>
<span class="chip-label">{{ kpi.label }}</span>
<span class="chip-delta" :class="kpi.trend">{{ kpi.meta }}</span>
</div>
</div>
</template>
<template v-else-if="isOverview">
<div class="range-combo" aria-label="首页时间范围">
<div class="range-shell">
<span class="range-meta">
@@ -81,41 +81,53 @@
</div>
</div>
</div>
</template>
<template v-else-if="isRequestDetail">
<div class="detail-alert-strip">
<span
v-for="alert in detailAlerts"
:key="alert.label"
class="detail-alert-pill"
:class="alert.tone"
>
<i class="mdi mdi-alert-circle-outline"></i>
<span>{{ alert.label }}</span>
</span>
</div>
</template>
<template v-else-if="isRequests">
<div class="kpi-chips">
<div v-for="kpi in requestKpis" :key="kpi.label" class="kpi-chip" :style="{ '--chip-color': kpi.color }">
<span class="chip-value">{{ kpi.value }}<small></small></span>
<span class="chip-label">{{ kpi.label }}</span>
<span class="chip-delta" :class="kpi.trend">{{ kpi.delta }} <i :class="kpi.arrow"></i></span>
</div>
</div>
</template>
<template v-else-if="isLogs">
<div class="kpi-chips">
<div v-for="kpi in logsKpis" :key="kpi.label" class="kpi-chip" :style="{ '--chip-color': kpi.color }">
<span class="chip-value">{{ kpi.value }}<small>{{ kpi.unit }}</small></span>
<span class="chip-label">{{ kpi.label }}</span>
<span class="chip-delta" :class="kpi.trend">{{ kpi.meta }}</span>
</div>
</div>
</template>
</template>
<template v-else-if="isRequestDetail">
<div class="detail-alert-strip">
<span
v-for="alert in detailAlerts"
:key="alert.label"
class="detail-alert-pill"
:class="alert.tone"
>
<i class="mdi mdi-alert-circle-outline"></i>
<span>{{ alert.label }}</span>
</span>
</div>
</template>
<template v-else-if="isWorkbench">
<div class="kpi-chips">
<div v-for="kpi in workbenchKpis" :key="kpi.label" class="kpi-chip" :style="{ '--chip-color': kpi.color }">
<span class="chip-value">
{{ kpi.value }}<small v-if="kpi.unit">{{ kpi.unit }}</small>
</span>
<span class="chip-label">{{ kpi.label }}</span>
<span class="chip-delta" :class="kpi.trend">{{ kpi.meta }}</span>
</div>
</div>
</template>
<template v-else-if="isRequests">
<div class="kpi-chips">
<div v-for="kpi in requestKpis" :key="kpi.label" class="kpi-chip" :style="{ '--chip-color': kpi.color }">
<span class="chip-value">{{ kpi.value }}<small></small></span>
<span class="chip-label">{{ kpi.label }}</span>
<span class="chip-delta" :class="kpi.trend">{{ kpi.delta }} <i :class="kpi.arrow"></i></span>
</div>
</div>
</template>
<template v-else-if="isLogs">
<div class="kpi-chips">
<div v-for="kpi in logsKpis" :key="kpi.label" class="kpi-chip" :style="{ '--chip-color': kpi.color }">
<span class="chip-value">{{ kpi.value }}<small>{{ kpi.unit }}</small></span>
<span class="chip-label">{{ kpi.label }}</span>
<span class="chip-delta" :class="kpi.trend">{{ kpi.meta }}</span>
</div>
</div>
</template>
<template v-else-if="isApproval">
<div class="kpi-chips">
@@ -132,28 +144,28 @@
</button>
</template>
<template v-else-if="isPolicies">
<div class="kpi-chips">
<div v-for="kpi in knowledgeKpis" :key="kpi.label" class="kpi-chip" :style="{ '--chip-color': kpi.color }">
<span class="chip-value">{{ kpi.value }}</span>
<span class="chip-label">{{ kpi.label }}</span>
<span v-if="kpi.meta" class="chip-delta" :class="kpi.trend">{{ kpi.meta }}</span>
</div>
</div>
</template>
<template v-else-if="isEmployees">
<div class="kpi-chips">
<div v-for="kpi in employeeKpis" :key="kpi.label" class="kpi-chip" :style="{ '--chip-color': kpi.color }">
<span class="chip-value">{{ kpi.value }}<small>{{ kpi.unit }}</small></span>
<span class="chip-label">{{ kpi.label }}</span>
<span class="chip-delta" :class="kpi.trend">{{ kpi.meta }}</span>
</div>
</div>
</template>
</div>
</header>
</template>
<template v-else-if="isPolicies">
<div class="kpi-chips">
<div v-for="kpi in knowledgeKpis" :key="kpi.label" class="kpi-chip" :style="{ '--chip-color': kpi.color }">
<span class="chip-value">{{ kpi.value }}</span>
<span class="chip-label">{{ kpi.label }}</span>
<span v-if="kpi.meta" class="chip-delta" :class="kpi.trend">{{ kpi.meta }}</span>
</div>
</div>
</template>
<template v-else-if="isEmployees">
<div class="kpi-chips">
<div v-for="kpi in employeeKpis" :key="kpi.label" class="kpi-chip" :style="{ '--chip-color': kpi.color }">
<span class="chip-value">{{ kpi.value }}<small>{{ kpi.unit }}</small></span>
<span class="chip-label">{{ kpi.label }}</span>
<span class="chip-delta" :class="kpi.trend">{{ kpi.meta }}</span>
</div>
</div>
</template>
</div>
</header>
</template>
<script setup>
import { computed, ref, watch } from 'vue'
@@ -161,90 +173,138 @@ import { computed, ref, watch } from 'vue'
const props = defineProps({
currentView: { type: Object, required: true },
search: { type: String, default: '' },
activeView: { type: String, default: '' },
ranges: { type: Array, default: () => [] },
activeRange: { type: String, default: '' },
employeeSummary: {
type: Object,
default: () => null
},
knowledgeSummary: {
type: Object,
default: () => null
},
logsSummary: {
type: Object,
default: () => null
},
requestSummary: {
type: Object,
default: () => null
},
detailMode: {
type: Boolean,
default: false
},
logDetailMode: {
type: Boolean,
default: false
},
detailAlerts: {
type: Array,
default: () => []
},
customRange: {
type: Object,
default: () => ({ start: '2024-07-06', end: '2024-07-12' })
}
activeView: { type: String, default: '' },
ranges: { type: Array, default: () => [] },
activeRange: { type: String, default: '' },
employeeSummary: {
type: Object,
default: () => null
},
knowledgeSummary: {
type: Object,
default: () => null
},
logsSummary: {
type: Object,
default: () => null
},
requestSummary: {
type: Object,
default: () => null
},
workbenchSummary: {
type: Object,
default: () => null
},
detailMode: {
type: Boolean,
default: false
},
logDetailMode: {
type: Boolean,
default: false
},
detailAlerts: {
type: Array,
default: () => []
},
customRange: {
type: Object,
default: () => ({ start: '2024-07-06', end: '2024-07-12' })
}
})
const emit = defineEmits([
'update:search',
'update:activeRange',
'update:customRange',
'batchApprove',
'openChat',
'newApplication'
])
const isChat = computed(() => props.activeView === 'chat')
const isOverview = computed(() => props.activeView === 'overview')
const isRequestDetail = computed(() => props.activeView === 'requests' && props.detailMode)
const isRequests = computed(() => props.activeView === 'requests')
const isLogs = computed(() => props.activeView === 'logs' && !props.logDetailMode)
const isApproval = computed(() => props.activeView === 'approval')
const isPolicies = computed(() => props.activeView === 'policies')
const isEmployees = computed(() => props.activeView === 'employees')
const emit = defineEmits([
'update:search',
'update:activeRange',
'update:customRange',
'batchApprove',
'openChat',
'newApplication'
])
const requestKpis = computed(() => {
const summary = props.requestSummary ?? {}
const total = Number(summary.total ?? 0)
const draft = Number(summary.draft ?? 0)
const inProgress = Number(summary.inProgress ?? 0)
const completed = Number(summary.completed ?? 0)
return [
{ label: '全部单据', value: total, delta: '当前', trend: 'up', arrow: 'mdi mdi-minus', color: '#10b981' },
{ label: '草稿', value: draft, delta: '待提交', trend: draft > 0 ? 'down' : 'up', arrow: draft > 0 ? 'mdi mdi-arrow-down' : 'mdi mdi-minus', color: '#f59e0b' },
{ label: '审批中', value: inProgress, delta: '处理中', trend: inProgress > 0 ? 'up' : 'down', arrow: inProgress > 0 ? 'mdi mdi-arrow-up' : 'mdi mdi-minus', color: '#3b82f6' },
{ label: '已完成', value: completed, delta: '已归档', trend: 'up', arrow: 'mdi mdi-arrow-up' , color: '#10b981' }
]
})
const logsKpis = computed(() => {
const summary = props.logsSummary ?? {}
const total = Number(summary.total ?? 0)
const running = Number(summary.running ?? 0)
const completed = Number(summary.completed ?? 0)
const failed = Number(summary.failed ?? 0)
return [
{ label: 'Hermes 总任务', value: total, unit: '条', meta: '当前', trend: 'up', color: '#10b981' },
{ label: '运行中', value: running, unit: '条', meta: running > 0 ? '实时执行' : '暂无执行', trend: running > 0 ? 'up' : 'down', color: '#3b82f6' },
{ label: '已完成', value: completed, unit: '条', meta: total ? `占比 ${Math.round((completed / total) * 100)}%` : '等待数据', trend: 'up', color: '#10b981' },
{ label: '失败数', value: failed, unit: '条', meta: failed > 0 ? '需要关注' : '运行正常', trend: failed > 0 ? 'down' : 'up', color: '#ef4444' }
]
})
const isChat = computed(() => props.activeView === 'chat')
const isOverview = computed(() => props.activeView === 'overview')
const isWorkbench = computed(() => props.activeView === 'workbench')
const isRequestDetail = computed(() => props.activeView === 'requests' && props.detailMode)
const isRequests = computed(() => props.activeView === 'requests')
const isLogs = computed(() => props.activeView === 'logs' && !props.logDetailMode)
const isApproval = computed(() => props.activeView === 'approval')
const isPolicies = computed(() => props.activeView === 'policies')
const isEmployees = computed(() => props.activeView === 'employees')
const workbenchKpis = computed(() => {
const summary = props.workbenchSummary ?? {}
const monthlyCount = Number(summary.monthlyCount ?? 0)
const returnCount = Number(summary.returnCount ?? 0)
const highRiskCount = Number(summary.highRiskCount ?? 0)
const monthlyAmountLabel = String(summary.monthlyAmountLabel || '¥0')
return [
{
label: '本月报销笔数',
value: monthlyCount,
unit: '笔',
meta: '本月累计',
trend: monthlyCount > 0 ? 'up' : 'down',
color: '#10b981'
},
{
label: '本月报销总金额',
value: monthlyAmountLabel,
unit: '',
meta: '本月累计',
trend: monthlyCount > 0 ? 'up' : 'down',
color: '#3b82f6'
},
{
label: '退单次数',
value: returnCount,
unit: '次',
meta: '累计退回',
trend: returnCount > 0 ? 'down' : 'up',
color: '#f59e0b'
},
{
label: '高危风险次数',
value: highRiskCount,
unit: '次',
meta: highRiskCount > 0 ? '本月需关注' : '本月无高危',
trend: highRiskCount > 0 ? 'down' : 'up',
color: '#ef4444'
}
]
})
const requestKpis = computed(() => {
const summary = props.requestSummary ?? {}
const total = Number(summary.total ?? 0)
const draft = Number(summary.draft ?? 0)
const inProgress = Number(summary.inProgress ?? 0)
const completed = Number(summary.completed ?? 0)
return [
{ label: '全部单据', value: total, delta: '当前', trend: 'up', arrow: 'mdi mdi-minus', color: '#10b981' },
{ label: '草稿', value: draft, delta: '待提交', trend: draft > 0 ? 'down' : 'up', arrow: draft > 0 ? 'mdi mdi-arrow-down' : 'mdi mdi-minus', color: '#f59e0b' },
{ label: '审批中', value: inProgress, delta: '处理中', trend: inProgress > 0 ? 'up' : 'down', arrow: inProgress > 0 ? 'mdi mdi-arrow-up' : 'mdi mdi-minus', color: '#3b82f6' },
{ label: '已完成', value: completed, delta: '已归档', trend: 'up', arrow: 'mdi mdi-arrow-up' , color: '#10b981' }
]
})
const logsKpis = computed(() => {
const summary = props.logsSummary ?? {}
const total = Number(summary.total ?? 0)
const running = Number(summary.running ?? 0)
const completed = Number(summary.completed ?? 0)
const failed = Number(summary.failed ?? 0)
return [
{ label: 'Hermes 总任务', value: total, unit: '条', meta: '当前', trend: 'up', color: '#10b981' },
{ label: '运行中', value: running, unit: '条', meta: running > 0 ? '实时执行' : '暂无执行', trend: running > 0 ? 'up' : 'down', color: '#3b82f6' },
{ label: '已完成', value: completed, unit: '条', meta: total ? `占比 ${Math.round((completed / total) * 100)}%` : '等待数据', trend: 'up', color: '#10b981' },
{ label: '失败数', value: failed, unit: '条', meta: failed > 0 ? '需要关注' : '运行正常', trend: failed > 0 ? 'down' : 'up', color: '#ef4444' }
]
})
const chatKpis = [
{ label: '今日已问数', value: 86, unit: '次', meta: '较昨日 +18', trend: 'up', color: '#10b981' },
@@ -260,85 +320,85 @@ const approvalKpis = [
{ label: '今日已处理', value: 28, unit: '单', meta: '通过率 86%', trend: 'up', color: '#10b981' }
]
const knowledgeKpis = computed(() => {
const summary = props.knowledgeSummary ?? {}
const totalDocuments = Number(summary.totalDocuments ?? 0)
return [
{
label: '文档总数',
value: String(totalDocuments),
meta: '',
trend: 'up',
color: '#10b981'
}
]
})
const employeeKpis = computed(() => {
const summary = props.employeeSummary ?? {}
const total = Number(summary.total ?? 0)
const active = Number(summary.active ?? 0)
const onboarding = Number(summary.onboarding ?? 0)
const disabled = Number(summary.disabled ?? 0)
const followUp = Number(summary.followUp ?? 0)
const departments = Number(summary.departments ?? 0)
return [
{
label: '员工总数',
value: total,
unit: '人',
meta: `覆盖 ${departments} 个部门`,
trend: 'up',
color: '#10b981'
},
{
label: '在职账号',
value: active,
unit: '人',
meta: total ? `占比 ${Math.round((active / total) * 100)}%` : '等待数据',
trend: 'up',
color: '#3b82f6'
},
{
label: '待处理状态',
value: onboarding + disabled,
unit: '人',
meta: `试用 ${onboarding} / 停用 ${disabled}`,
trend: onboarding + disabled > 0 ? 'down' : 'up',
color: '#f59e0b'
},
{
label: '同步待处理',
value: followUp,
unit: '人',
meta: followUp > 0 ? '存在待同步账号' : '资料已同步',
trend: followUp > 0 ? 'down' : 'up',
color: '#8b5cf6'
}
]
})
const knowledgeKpis = computed(() => {
const summary = props.knowledgeSummary ?? {}
const totalDocuments = Number(summary.totalDocuments ?? 0)
return [
{
label: '文档总数',
value: String(totalDocuments),
meta: '',
trend: 'up',
color: '#10b981'
}
]
})
const employeeKpis = computed(() => {
const summary = props.employeeSummary ?? {}
const total = Number(summary.total ?? 0)
const active = Number(summary.active ?? 0)
const onboarding = Number(summary.onboarding ?? 0)
const disabled = Number(summary.disabled ?? 0)
const followUp = Number(summary.followUp ?? 0)
const departments = Number(summary.departments ?? 0)
return [
{
label: '员工总数',
value: total,
unit: '人',
meta: `覆盖 ${departments} 个部门`,
trend: 'up',
color: '#10b981'
},
{
label: '在职账号',
value: active,
unit: '人',
meta: total ? `占比 ${Math.round((active / total) * 100)}%` : '等待数据',
trend: 'up',
color: '#3b82f6'
},
{
label: '待处理状态',
value: onboarding + disabled,
unit: '人',
meta: `试用 ${onboarding} / 停用 ${disabled}`,
trend: onboarding + disabled > 0 ? 'down' : 'up',
color: '#f59e0b'
},
{
label: '同步待处理',
value: followUp,
unit: '人',
meta: followUp > 0 ? '存在待同步账号' : '资料已同步',
trend: followUp > 0 ? 'down' : 'up',
color: '#8b5cf6'
}
]
})
const calendarOpen = ref(false)
const draftStart = ref(props.customRange.start)
const draftEnd = ref(props.customRange.end)
const rangeOptions = computed(() =>
props.ranges.map((range, index) => ({
value: range,
label: String(range)
}))
)
const rangeOptions = computed(() =>
props.ranges.map((range, index) => ({
value: range,
label: String(range)
}))
)
const activeOption = computed(() =>
rangeOptions.value.find((option) => option.value === props.activeRange) ?? rangeOptions.value[0]
)
const isCustomRange = computed(() => props.activeRange === 'custom')
const activeDateLabel = computed(() => {
if (isCustomRange.value) return formatRangeLabel(props.customRange.start, props.customRange.end)
return buildPresetRangeLabel(activeOption.value?.label)
})
const activeDateLabel = computed(() => {
if (isCustomRange.value) return formatRangeLabel(props.customRange.start, props.customRange.end)
return buildPresetRangeLabel(activeOption.value?.label)
})
const canApplyCustomRange = computed(() =>
Boolean(draftStart.value && draftEnd.value && draftStart.value <= draftEnd.value)
@@ -365,49 +425,49 @@ function applyCustomRange() {
calendarOpen.value = false
}
function formatRangeLabel(start, end) {
if (!start || !end) return '选择时间段'
if (start === end) return start
return `${start} ~ ${end}`
}
function toDateLabel(date) {
const year = date.getFullYear()
const month = String(date.getMonth() + 1).padStart(2, '0')
const day = String(date.getDate()).padStart(2, '0')
return `${year}-${month}-${day}`
}
function buildPresetRangeLabel(label) {
const now = new Date()
const today = toDateLabel(now)
if (label === '今日') {
return today
}
if (label === '近10日') {
const start = new Date(now)
start.setHours(0, 0, 0, 0)
start.setDate(start.getDate() - 9)
return `${toDateLabel(start)} ~ ${today}`
}
if (label === '本周') {
const start = new Date(now)
const day = start.getDay() || 7
start.setHours(0, 0, 0, 0)
start.setDate(start.getDate() - day + 1)
return `${toDateLabel(start)} ~ ${today}`
}
if (label === '本月') {
return `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, '0')}`
}
return today
}
</script>
function formatRangeLabel(start, end) {
if (!start || !end) return '选择时间段'
if (start === end) return start
return `${start} ~ ${end}`
}
function toDateLabel(date) {
const year = date.getFullYear()
const month = String(date.getMonth() + 1).padStart(2, '0')
const day = String(date.getDate()).padStart(2, '0')
return `${year}-${month}-${day}`
}
function buildPresetRangeLabel(label) {
const now = new Date()
const today = toDateLabel(now)
if (label === '今日') {
return today
}
if (label === '近10日') {
const start = new Date(now)
start.setHours(0, 0, 0, 0)
start.setDate(start.getDate() - 9)
return `${toDateLabel(start)} ~ ${today}`
}
if (label === '本周') {
const start = new Date(now)
const day = start.getDay() || 7
start.setHours(0, 0, 0, 0)
start.setDate(start.getDate() - day + 1)
return `${toDateLabel(start)} ~ ${today}`
}
if (label === '本月') {
return `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, '0')}`
}
return today
}
</script>
<style scoped>
.topbar {
@@ -650,53 +710,53 @@ function buildPresetRangeLabel(label) {
background: #cbd5e1;
}
.kpi-chips {
display: flex;
gap: 10px;
}
.detail-alert-strip {
display: flex;
align-items: center;
justify-content: flex-end;
gap: 10px;
flex-wrap: wrap;
}
.detail-alert-pill {
display: inline-flex;
align-items: center;
gap: 6px;
min-height: 32px;
padding: 0 12px;
border: 1px solid #fed7aa;
border-radius: 999px;
background: #fff7ed;
color: #ea580c;
font-size: 12px;
font-weight: 800;
white-space: nowrap;
}
.detail-alert-pill i {
font-size: 14px;
}
.detail-alert-pill.success {
border-color: #bbf7d0;
background: #f0fdf4;
color: #059669;
}
.detail-alert-pill.danger {
border-color: #fecaca;
background: #fff1f2;
color: #dc2626;
}
.kpi-chip {
display: grid;
grid-template-columns: auto auto;
.kpi-chips {
display: flex;
gap: 10px;
}
.detail-alert-strip {
display: flex;
align-items: center;
justify-content: flex-end;
gap: 10px;
flex-wrap: wrap;
}
.detail-alert-pill {
display: inline-flex;
align-items: center;
gap: 6px;
min-height: 32px;
padding: 0 12px;
border: 1px solid #fed7aa;
border-radius: 999px;
background: #fff7ed;
color: #ea580c;
font-size: 12px;
font-weight: 800;
white-space: nowrap;
}
.detail-alert-pill i {
font-size: 14px;
}
.detail-alert-pill.success {
border-color: #bbf7d0;
background: #f0fdf4;
color: #059669;
}
.detail-alert-pill.danger {
border-color: #fecaca;
background: #fff1f2;
color: #dc2626;
}
.kpi-chip {
display: grid;
grid-template-columns: auto auto;
grid-template-rows: auto auto;
gap: 2px 10px;
padding: 8px 16px;
@@ -740,10 +800,10 @@ function buildPresetRangeLabel(label) {
min-width: 0;
}
.create-top-btn {
height: 40px;
display: inline-flex;
align-items: center;
.create-top-btn {
height: 40px;
display: inline-flex;
align-items: center;
gap: 8px;
padding: 0 18px;
border: 0;
@@ -756,11 +816,11 @@ function buildPresetRangeLabel(label) {
white-space: nowrap;
}
.create-top-btn:hover {
background: #047857;
}
@media (max-width: 1120px) {
.create-top-btn:hover {
background: #047857;
}
@media (max-width: 1120px) {
.range-combo {
width: 100%;
justify-content: flex-end;
@@ -773,13 +833,13 @@ function buildPresetRangeLabel(label) {
align-items: stretch;
}
.top-actions,
.search-wrap,
.search-wrap.wide,
.detail-alert-strip,
.month-chip,
.qa-filter,
.new-question-btn {
.top-actions,
.search-wrap,
.search-wrap.wide,
.detail-alert-strip,
.month-chip,
.qa-filter,
.new-question-btn {
width: 100%;
}