feat: 完善审批退回流程与报销申请关联

后端优化报销单访问策略和常量定义,增强退回原因和审批状态
流转,前端完善退回对话框和审批交互组件,新增报销申请关联
模型,优化文档中心行数据和审批收件箱工具函数,增强引导
流程和会话模型,补充单元测试覆盖。
This commit is contained in:
caoxiaozhu
2026-05-27 14:35:17 +08:00
parent 7d32eae74e
commit cbb98f4469
30 changed files with 1794 additions and 250 deletions

View File

@@ -1,7 +1,7 @@
<template>
<ConfirmDialog
:open="open"
badge="退回单据"
:badge="dialogBadge"
badge-tone="warning"
:title="title"
:description="description"
@@ -17,8 +17,8 @@
>
<div class="return-reason-dialog">
<div class="return-reason-section">
<span>默认风险点</span>
<div class="return-reason-options" role="group" aria-label="默认退回风险点">
<span>{{ optionsTitle }}</span>
<div class="return-reason-options" role="group" :aria-label="optionsAriaLabel">
<label
v-for="option in options"
:key="option.code"
@@ -29,11 +29,13 @@
type="checkbox"
:value="option.code"
:disabled="busy"
@change="handleOptionChange"
/>
<i :class="option.icon"></i>
<strong>{{ option.label }}</strong>
</label>
</div>
<small v-if="selectionError" class="error">{{ selectionError }}</small>
</div>
<label class="return-reason-section">
@@ -42,11 +44,11 @@
v-model="reasonText"
rows="4"
:disabled="busy"
placeholder="请写清楚需要申请人补充或修改的内容,例如:发票金额与明细金额不一致,请重新上传正确票据。"
:placeholder="reasonPlaceholder"
@input="touched = true"
></textarea>
<small :class="{ error: reasonError }">
{{ reasonError || '会同步记录到退单埋点,并展示给申请人。' }}
{{ validationMessage }}
</small>
</label>
</div>
@@ -58,7 +60,7 @@ import { computed, ref, watch } from 'vue'
import ConfirmDialog from './ConfirmDialog.vue'
const RETURN_REASON_OPTIONS = [
const CLAIM_RETURN_REASON_OPTIONS = [
{ code: 'missing_attachment', label: '附件缺失或不清晰', icon: 'mdi mdi-paperclip-alert' },
{ code: 'invoice_mismatch', label: '票据类型/金额与明细不一致', icon: 'mdi mdi-file-compare' },
{ code: 'over_policy', label: '超出制度标准或缺少超标说明', icon: 'mdi mdi-scale-unbalanced' },
@@ -67,10 +69,44 @@ const RETURN_REASON_OPTIONS = [
{ code: 'approval_question', label: '审批人需要补充说明', icon: 'mdi mdi-comment-question-outline' }
]
const APPLICATION_RETURN_REASON_OPTIONS = [
{
code: 'application_info_incomplete',
label: '申请信息不完整',
icon: 'mdi mdi-form-textbox',
defaultReason: '请补充出差时间、地点、事由、天数或出行方式等关键信息后重新提交。'
},
{
code: 'application_business_need_unclear',
label: '业务必要性说明不足',
icon: 'mdi mdi-briefcase-question-outline',
defaultReason: '请说明本次申请对应的项目、客户或任务背景,以及必须现场处理的原因。'
},
{
code: 'application_budget_basis_missing',
label: '预算测算依据不足',
icon: 'mdi mdi-calculator-variant-outline',
defaultReason: '请补充预计住宿、交通、补贴等费用构成及测算依据,便于判断预算合理性。'
},
{
code: 'application_policy_mismatch',
label: '制度口径不匹配',
icon: 'mdi mdi-scale-balance',
defaultReason: '当前申请与差旅制度口径存在不一致,请核对职级、目的地、天数或费用标准后调整。'
},
{
code: 'application_attachment_needed',
label: '前置材料需补充',
icon: 'mdi mdi-file-document-plus-outline',
defaultReason: '请补充会议通知、客户邀约、项目安排或其他能支撑申请必要性的材料。'
}
]
const props = defineProps({
open: { type: Boolean, default: false },
busy: { type: Boolean, default: false },
claimNo: { type: String, default: '' },
application: { type: Boolean, default: false },
title: { type: String, default: '确认退回该单据吗?' },
description: {
type: String,
@@ -83,15 +119,40 @@ const emit = defineEmits(['close', 'confirm'])
const selectedCodes = ref([])
const reasonText = ref('')
const touched = ref(false)
const selectionTouched = ref(false)
const lastAutoReason = ref('')
const options = computed(() => RETURN_REASON_OPTIONS)
const options = computed(() => (props.application ? APPLICATION_RETURN_REASON_OPTIONS : CLAIM_RETURN_REASON_OPTIONS))
const dialogBadge = computed(() => (props.application ? '退回申请' : '退回单据'))
const optionsTitle = computed(() => (props.application ? '退单选项' : '默认风险点'))
const optionsAriaLabel = computed(() => (props.application ? '申请退单选项' : '默认退回风险点'))
const reasonPlaceholder = computed(() => (
props.application
? '请选择退单选项,系统会自动带入默认理由。领导可按实际情况继续修改。'
: '请写清楚需要申请人补充或修改的内容,例如:发票金额与明细金额不一致,请重新上传正确票据。'
))
const trimmedReason = computed(() => reasonText.value.trim())
const selectionError = computed(() => {
if (!props.application || !selectionTouched.value || selectedCodes.value.length > 0) {
return ''
}
return '请选择至少一个退单选项,便于后续看板统计。'
})
const reasonError = computed(() => {
if (!touched.value || trimmedReason.value.length >= 6) {
return ''
}
return '请至少填写 6 个字的明确退单理由。'
})
const validationMessage = computed(() => (
selectionError.value
|| reasonError.value
|| (
props.application
? '退单选项会写入结构化埋点,理由会展示给申请人。'
: '会同步记录到退单埋点,并展示给申请人。'
)
))
watch(
() => props.open,
@@ -100,10 +161,33 @@ watch(
selectedCodes.value = []
reasonText.value = ''
touched.value = false
selectionTouched.value = false
lastAutoReason.value = ''
}
}
)
watch(selectedCodes, () => {
if (!props.application) {
return
}
const defaultReason = selectedCodes.value
.map((code) => options.value.find((option) => option.code === code)?.defaultReason || '')
.filter(Boolean)
.join('\n')
const canAutoFill = !touched.value || !reasonText.value.trim() || reasonText.value === lastAutoReason.value
if (canAutoFill) {
reasonText.value = defaultReason
}
lastAutoReason.value = defaultReason
})
function handleOptionChange() {
selectionTouched.value = true
}
function handleClose() {
if (!props.busy) {
emit('close')
@@ -112,7 +196,8 @@ function handleClose() {
function handleConfirm() {
touched.value = true
if (trimmedReason.value.length < 6 || props.busy) {
selectionTouched.value = true
if ((props.application && selectedCodes.value.length === 0) || trimmedReason.value.length < 6 || props.busy) {
return
}

View File

@@ -27,11 +27,27 @@
<span>{{ summaryLabel }}</span>
<strong>{{ nextStage }}</strong>
</div>
<div class="submit-confirm-row">
<span>{{ opinionTitle }}</span>
<strong>{{ normalizedOpinion }}</strong>
</div>
</div>
<label class="approval-opinion-field">
<span>
{{ opinionTitle }}
<em v-if="opinionRequired">必填</em>
</span>
<textarea
:value="currentOpinion"
maxlength="500"
:required="opinionRequired"
:disabled="busy"
:placeholder="opinionPlaceholder"
:aria-label="opinionTitle"
@input="handleOpinionInput"
></textarea>
<small>
<span>{{ opinionHint }}</span>
<strong>{{ currentOpinion.length }}/500</strong>
</small>
</label>
</ConfirmDialog>
</template>
@@ -53,10 +69,83 @@ const props = defineProps({
summaryLabel: { type: String, required: true },
nextStage: { type: String, required: true },
opinionTitle: { type: String, required: true },
opinion: { type: String, default: '' }
opinion: { type: String, default: '' },
opinionPlaceholder: { type: String, default: '' },
opinionHint: { type: String, default: '' },
opinionRequired: { type: Boolean, default: false }
})
const emit = defineEmits(['close', 'confirm'])
const emit = defineEmits(['close', 'confirm', 'update:opinion'])
const normalizedOpinion = computed(() => props.opinion.trim() || '未填写')
const currentOpinion = computed(() => String(props.opinion || ''))
function handleOpinionInput(event) {
emit('update:opinion', event.target.value)
}
</script>
<style scoped>
.approval-opinion-field {
display: grid;
gap: 8px;
margin-top: 14px;
}
.approval-opinion-field > span {
display: inline-flex;
align-items: center;
gap: 8px;
color: #334155;
font-size: 12px;
font-weight: 850;
}
.approval-opinion-field em {
border-radius: 999px;
padding: 2px 7px;
background: rgba(var(--theme-primary-rgb), .1);
color: var(--theme-primary-active);
font-style: normal;
font-size: 11px;
font-weight: 850;
}
.approval-opinion-field textarea {
width: 100%;
min-height: 96px;
resize: vertical;
padding: 12px;
border: 1px solid #d7e0ea;
border-radius: 8px;
background: #fff;
color: #0f172a;
font-size: 13px;
line-height: 1.6;
outline: none;
}
.approval-opinion-field textarea:focus {
border-color: rgba(var(--theme-primary-rgb), .5);
box-shadow: 0 0 0 3px var(--theme-focus-ring);
}
.approval-opinion-field small {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
color: #64748b;
font-size: 12px;
line-height: 1.5;
}
.approval-opinion-field small span {
min-width: 0;
}
.approval-opinion-field small strong {
flex: 0 0 auto;
color: var(--theme-primary-active);
font-weight: 850;
}
</style>

View File

@@ -4,6 +4,7 @@
:title="title"
:description="description"
:busy="busy"
:application="application"
@close="emit('close')"
@confirm="emit('confirm', $event)"
/>
@@ -16,7 +17,8 @@ defineProps({
open: { type: Boolean, required: true },
title: { type: String, required: true },
description: { type: String, required: true },
busy: { type: Boolean, required: true }
busy: { type: Boolean, required: true },
application: { type: Boolean, default: false }
})
const emit = defineEmits(['close', 'confirm'])