feat: 新增员工行为画像算法与费用风险标签体系
后端新增员工行为画像算法模块,支持标签规则引擎和评分计算, 完善员工模型、银行信息、序列化和导入逻辑,优化报销审批流 和工作流常量,增强 Hermes 同步和知识同步能力,前端新增费 用画像详情弹窗、雷达图和风险卡片组件,完善登录页和工作台 样式,优化文档中心和归档中心交互,补充单元测试。
This commit is contained in:
@@ -74,7 +74,7 @@ function buildArchiveRow(request) {
|
||||
archiveMonthLabel: formatArchiveMonthLabel(archiveMonth),
|
||||
archiveType: isApplicationDocument ? ARCHIVE_TYPE_APPLICATION : ARCHIVE_TYPE_REIMBURSEMENT,
|
||||
archiveTypeCode: isApplicationDocument ? ARCHIVE_TYPE_APPLICATION_CODE : ARCHIVE_TYPE_REIMBURSEMENT_CODE,
|
||||
node: isApplicationDocument ? '申请归档' : (normalized.workflowNode || '归档入账'),
|
||||
node: isApplicationDocument ? '申请归档' : (normalized.workflowNode || '已付款'),
|
||||
hasRisk,
|
||||
riskCount,
|
||||
risk: formatArchiveRiskCountLabel(riskCount),
|
||||
@@ -168,13 +168,13 @@ export default {
|
||||
return {
|
||||
eyebrow: '归档中心',
|
||||
title: '当前还没有已归档单据',
|
||||
desc: '财务终审通过并进入「归档入账」节点的报销单会自动汇总到这里,形成公司级财务归档库。',
|
||||
desc: '财务确认付款后进入「已付款」状态的报销单会自动汇总到这里,形成公司级财务归档库。',
|
||||
icon: 'mdi mdi-archive-check-outline',
|
||||
actionLabel: null,
|
||||
actionIcon: null,
|
||||
tone: 'slate',
|
||||
artLabel: 'ARCHIVE',
|
||||
tips: ['仅展示已归档入账的单据', '申请人仍可在报销中心查看自己的归档记录']
|
||||
tips: ['仅展示已付款或已归档的单据', '申请人仍可在报销中心查看自己的归档记录']
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,12 @@ import {
|
||||
importEmployees,
|
||||
updateEmployee
|
||||
} from '../../services/employees.js'
|
||||
import {
|
||||
appendEmployeeBankUpdatePayload,
|
||||
createEmployeeBankFormFields,
|
||||
getEmployeeBankSearchFields,
|
||||
mapEmployeeBankFormFields
|
||||
} from './employeeBankFields.js'
|
||||
|
||||
const DEFAULT_STATUS_TABS = ['全部员工', '在职', '试用中', '停用']
|
||||
const FALLBACK_ROLE_OPTIONS = [
|
||||
@@ -76,6 +82,7 @@ function createEmployeeForm() {
|
||||
managerEmployeeNo: '',
|
||||
financeOwner: '',
|
||||
costCenter: '',
|
||||
...createEmployeeBankFormFields(),
|
||||
roleCodes: [],
|
||||
password: ''
|
||||
}
|
||||
@@ -197,6 +204,7 @@ function buildEmployeeForm(employee, roster = []) {
|
||||
managerEmployeeNo,
|
||||
financeOwner: employee.financeOwner || '',
|
||||
costCenter: employee.costCenter || '',
|
||||
...mapEmployeeBankFormFields(employee),
|
||||
roleCodes: [...(employee.roleCodes || [])],
|
||||
password: ''
|
||||
}
|
||||
@@ -380,6 +388,7 @@ function matchKeyword(employee, keyword) {
|
||||
employee.email,
|
||||
employee.manager,
|
||||
employee.financeOwner,
|
||||
...getEmployeeBankSearchFields(employee),
|
||||
employee.syncState
|
||||
]
|
||||
|
||||
@@ -1053,6 +1062,8 @@ export default {
|
||||
payload.cost_center = nextCostCenter
|
||||
}
|
||||
|
||||
appendEmployeeBankUpdatePayload(payload, form, current, normalizeNullableText)
|
||||
|
||||
const nextManagerEmployeeNo = normalizeNullableText(form.managerEmployeeNo)
|
||||
const currentManagerEmployeeNo =
|
||||
normalizeNullableText(current.managerEmployeeNo) ||
|
||||
|
||||
@@ -15,6 +15,9 @@ export default {
|
||||
knowledgeAggregation: { icon: 'mdi-sync', color: 'indigo' },
|
||||
ruleReviewDigest: { icon: 'mdi-bell-ring-outline', color: 'warning' },
|
||||
riskSummary: { icon: 'mdi-shield-search', color: 'danger' },
|
||||
employee_behavior_profile_scan: { icon: 'mdi-account-search-outline', color: 'primary' },
|
||||
global_risk_scan: { icon: 'mdi-shield-search', color: 'danger' },
|
||||
weekly_expense_report: { icon: 'mdi-chart-box-outline', color: 'success' },
|
||||
archiveDigest: { icon: 'mdi-archive-outline', color: 'info' },
|
||||
dailyStats: { icon: 'mdi-chart-line', color: 'success' },
|
||||
monthlyStats: { icon: 'mdi-chart-bar', color: 'primary' },
|
||||
@@ -56,4 +59,3 @@ export default {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ export default {
|
||||
emits: ['ask', 'approve', 'reject', 'create-request', 'reload'],
|
||||
setup(props, { emit }) {
|
||||
const activeTab = ref('全部')
|
||||
const tabs = ['全部', '草稿', '待提交', '审批中', '待补充', '已完成']
|
||||
const tabs = ['全部', '草稿', '待提交', '审批中', '待补充', '待付款', '已完成']
|
||||
const filters = ['报销状态', '报销类型', '所属主体']
|
||||
const listKeyword = ref('')
|
||||
|
||||
@@ -102,6 +102,7 @@ export default {
|
||||
|| (activeTab.value === '待提交' && row.approvalKey === 'supplement' && row.status === 'returned')
|
||||
|| (activeTab.value === '审批中' && row.approvalKey === 'in_progress')
|
||||
|| (activeTab.value === '待补充' && row.approvalKey === 'supplement' && row.status !== 'returned')
|
||||
|| (activeTab.value === '待付款' && row.approvalKey === 'pending_payment')
|
||||
|| (activeTab.value === '已完成' && row.approvalKey === 'completed')
|
||||
|
||||
return matchesKeyword && matchesDateRange && matchesTab
|
||||
|
||||
@@ -7,6 +7,7 @@ import ConfirmDialog from '../../components/shared/ConfirmDialog.vue'
|
||||
import TravelRequestApprovalDialog from '../../components/travel/TravelRequestApprovalDialog.vue'
|
||||
import TravelRequestBudgetAnalysis from '../../components/travel/TravelRequestBudgetAnalysis.vue'
|
||||
import TravelRequestDeleteDialog from '../../components/travel/TravelRequestDeleteDialog.vue'
|
||||
import EmployeeProfileRiskCard from '../../components/travel/EmployeeProfileRiskCard.vue'
|
||||
import TravelRequestReturnDialog from '../../components/travel/TravelRequestReturnDialog.vue'
|
||||
import {
|
||||
approveExpenseClaim,
|
||||
@@ -14,6 +15,7 @@ import {
|
||||
deleteExpenseClaimItem,
|
||||
deleteExpenseClaimItemAttachment,
|
||||
deleteExpenseClaim,
|
||||
fetchEmployeeLatestProfile,
|
||||
fetchExpenseClaimItemAttachmentMeta,
|
||||
fetchExpenseClaimItemAttachmentPreview,
|
||||
returnExpenseClaim,
|
||||
@@ -72,6 +74,7 @@ import {
|
||||
resolveExpenseReasonPlaceholder,
|
||||
resolveExpenseUploadHint
|
||||
} from './travelRequestDetailExpenseModel.js'
|
||||
import { useTravelRequestPaymentFlow } from './travelRequestDetailPaymentFlow.js'
|
||||
|
||||
/*
|
||||
* 以下片段仅用于兼容现有源码正则测试。
|
||||
@@ -370,6 +373,7 @@ export default {
|
||||
components: {
|
||||
ConfirmDialog,
|
||||
EnterpriseSelect,
|
||||
EmployeeProfileRiskCard,
|
||||
TravelRequestApprovalDialog,
|
||||
TravelRequestBudgetAnalysis,
|
||||
TravelRequestDeleteDialog,
|
||||
@@ -432,6 +436,10 @@ export default {
|
||||
})
|
||||
const detailNoteEditor = ref('')
|
||||
const savingDetailNote = ref(false)
|
||||
const employeeRiskProfile = ref(null)
|
||||
const employeeRiskProfileLoading = ref(false)
|
||||
const employeeRiskProfileError = ref('')
|
||||
let employeeRiskProfileLoadSeq = 0
|
||||
|
||||
const request = computed(() => {
|
||||
const normalized = normalizeRequestForUi(props.request)
|
||||
@@ -520,6 +528,29 @@ export default {
|
||||
&& canApproveBudgetExpenseApplications(currentUser.value, request.value)
|
||||
&& !isCurrentApplicant.value
|
||||
))
|
||||
const employeeProfileId = computed(() =>
|
||||
String(
|
||||
request.value.employeeId
|
||||
|| request.value.employee_id
|
||||
|| request.value.profileEmployeeId
|
||||
|| ''
|
||||
).trim()
|
||||
)
|
||||
const employeeRiskProfileScope = computed(() => {
|
||||
const typeCode = String(request.value.typeCode || request.value.expense_type || '').trim()
|
||||
if (typeCode === 'meal' || typeCode === 'entertainment') {
|
||||
return 'entertainment'
|
||||
}
|
||||
if (typeCode === 'travel' || isTravelRequest.value) {
|
||||
return 'travel'
|
||||
}
|
||||
return typeCode || 'overall'
|
||||
})
|
||||
const showEmployeeRiskProfile = computed(() =>
|
||||
Boolean(employeeProfileId.value)
|
||||
&& Boolean(request.value.claimId)
|
||||
&& !isDraftRequest.value
|
||||
)
|
||||
const canReturnRequest = computed(() => {
|
||||
if (request.value.approvalKey !== 'in_progress' || !request.value.claimId || !canReturnExpenseClaims(currentUser.value)) {
|
||||
return false
|
||||
@@ -545,6 +576,21 @@ export default {
|
||||
|| canProcessBudgetApprovalStage.value
|
||||
)
|
||||
)
|
||||
const {
|
||||
canPayRequest,
|
||||
closePayConfirmDialog,
|
||||
confirmPayRequest,
|
||||
handlePayRequest,
|
||||
payBusy,
|
||||
payConfirmDialogOpen
|
||||
} = useTravelRequestPaymentFlow({
|
||||
request,
|
||||
currentUser,
|
||||
isApplicationDocument,
|
||||
isCurrentApplicant,
|
||||
toast,
|
||||
emit
|
||||
})
|
||||
const leaderApprovalInfo = computed(() => buildLeaderApprovalInfo(request.value))
|
||||
const leaderApprovalEvents = computed(() => buildLeaderApprovalEvents(request.value))
|
||||
const hasLeaderApprovalEvents = computed(() => leaderApprovalEvents.value.length > 0)
|
||||
@@ -572,7 +618,7 @@ export default {
|
||||
})
|
||||
const approvalOpinionHint = computed(() => {
|
||||
if (isFinanceApprovalStage.value) {
|
||||
return '审核通过后将进入归档入账。'
|
||||
return '审核通过后将进入待付款。'
|
||||
}
|
||||
if (isBudgetApprovalStage.value) {
|
||||
return '不填写附加意见则默认同意,确认后会归档申请单并生成报销草稿。'
|
||||
@@ -587,7 +633,7 @@ export default {
|
||||
})
|
||||
const approvalConfirmDescription = computed(() => {
|
||||
if (isFinanceApprovalStage.value) {
|
||||
return '确认后该报销单会完成财务终审并进入归档入账,请确认票据、金额与财务意见无误。'
|
||||
return '确认后该报销单会完成财务终审并进入待付款,请确认票据、金额与财务意见无误。'
|
||||
}
|
||||
if (isApplicationDocument.value) {
|
||||
return isBudgetApprovalStage.value
|
||||
@@ -610,7 +656,7 @@ export default {
|
||||
))
|
||||
const approvalSuccessToast = computed(() => {
|
||||
if (isFinanceApprovalStage.value) {
|
||||
return `${request.value.id} 已完成财务终审,进入归档入账。`
|
||||
return `${request.value.id} 已完成财务终审,进入待付款。`
|
||||
}
|
||||
return isApplicationDocument.value
|
||||
? isBudgetApprovalStage.value
|
||||
@@ -632,6 +678,7 @@ export default {
|
||||
|| deleteBusy.value
|
||||
|| returnBusy.value
|
||||
|| approveBusy.value
|
||||
|| payBusy.value
|
||||
|| creatingExpense.value
|
||||
|| Boolean(uploadingExpenseId.value)
|
||||
|| Boolean(deletingAttachmentId.value)
|
||||
@@ -672,6 +719,19 @@ export default {
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
watch(
|
||||
() => [
|
||||
employeeProfileId.value,
|
||||
request.value.claimId,
|
||||
employeeRiskProfileScope.value,
|
||||
showEmployeeRiskProfile.value
|
||||
],
|
||||
() => {
|
||||
void loadEmployeeRiskProfile()
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
const heroFactItems = computed(() => [
|
||||
{
|
||||
key: 'document',
|
||||
@@ -887,6 +947,38 @@ export default {
|
||||
return payload
|
||||
}
|
||||
|
||||
async function loadEmployeeRiskProfile() {
|
||||
const sequence = ++employeeRiskProfileLoadSeq
|
||||
employeeRiskProfileError.value = ''
|
||||
if (!showEmployeeRiskProfile.value) {
|
||||
employeeRiskProfile.value = null
|
||||
employeeRiskProfileLoading.value = false
|
||||
return
|
||||
}
|
||||
|
||||
employeeRiskProfileLoading.value = true
|
||||
try {
|
||||
const payload = await fetchEmployeeLatestProfile(employeeProfileId.value, {
|
||||
scene: 'approval',
|
||||
claim_id: request.value.claimId,
|
||||
window_days: 90,
|
||||
expense_type_scope: employeeRiskProfileScope.value
|
||||
})
|
||||
if (sequence === employeeRiskProfileLoadSeq) {
|
||||
employeeRiskProfile.value = payload
|
||||
}
|
||||
} catch (error) {
|
||||
if (sequence === employeeRiskProfileLoadSeq) {
|
||||
employeeRiskProfile.value = null
|
||||
employeeRiskProfileError.value = error?.message || '画像读取失败,请稍后重试。'
|
||||
}
|
||||
} finally {
|
||||
if (sequence === employeeRiskProfileLoadSeq) {
|
||||
employeeRiskProfileLoading.value = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function canPreviewAttachment(item) {
|
||||
if (!item?.invoiceId) {
|
||||
return false
|
||||
@@ -1831,24 +1923,26 @@ export default {
|
||||
applicationDetailFactItems,
|
||||
approveBusyText, approveConfirmText, approveConfirmTitle, canDeleteRequest, canManageCurrentClaim,
|
||||
canNavigateAttachmentPreview,
|
||||
canOpenAiEntry, canApproveRequest, canReturnRequest, canSubmit, canPreviewAttachment,
|
||||
closeApproveConfirmDialog, closeDeleteDialog, closeAttachmentPreview, closeSubmitConfirmDialog,
|
||||
canOpenAiEntry, canApproveRequest, canPayRequest, canReturnRequest, canSubmit, canPreviewAttachment,
|
||||
closeApproveConfirmDialog, closeDeleteDialog, closeAttachmentPreview, closePayConfirmDialog, closeSubmitConfirmDialog,
|
||||
closeRiskOverrideDialog,
|
||||
closeReturnDialog, confirmApproveRequest, confirmDeleteRequest, confirmSubmitRequest, confirmReturnRequest,
|
||||
confirmRiskOverrideReasons,
|
||||
confirmPayRequest, confirmRiskOverrideReasons,
|
||||
currentAttachmentPreviewInsight, currentAttachmentPreviewRiskCards, currentProgressRingMotion,
|
||||
currentSubmitRiskWarning,
|
||||
canEditDetailNote, deleteActionLabel, deleteBusy, deleteDialogDescription, deleteDialogOpen,
|
||||
deleteDialogTitle, deletingAttachmentId, deletingExpenseId, detailNote, detailNoteDirty,
|
||||
detailNoteEditor, detailNoteEditorView, detailNoteTags, draftBlockingIssues, editingExpenseId, creatingExpense, expenseEditor,
|
||||
employeeRiskProfile, employeeRiskProfileError, employeeRiskProfileLoading,
|
||||
expenseItems, expenseTableColumnCount, expenseTotal, expenseUploadInput,
|
||||
expenseTypeOptions: EXPENSE_TYPE_OPTIONS,
|
||||
goToNextSubmitRisk, goToPreviousSubmitRisk,
|
||||
handleAddExpenseItem, handleApproveRequest, handleDeleteRequest, handleExpenseFileChange,
|
||||
handlePayRequest,
|
||||
handleReturnRequest, handleSubmit, heroFactItems, isApplicationDocument, isDraftRequest, isEditableRequest, isTravelRequest,
|
||||
isMajorExpenseRisk,
|
||||
openAiEntry, openAttachmentPreview, goToNextAttachmentPreview, goToPreviousAttachmentPreview,
|
||||
profile, progressSteps, request, leaderOpinion, removeExpenseAttachment, removeExpenseItem,
|
||||
payBusy, payConfirmDialogOpen, profile, progressSteps, request, leaderOpinion, removeExpenseAttachment, removeExpenseItem,
|
||||
hasLeaderApprovalEvents, leaderApprovalEvents, leaderApprovalReadonlyMeta,
|
||||
resolveExpenseRiskIndicatorTitle,
|
||||
resetDetailNote, resolveAttachmentDisplayName, resolveAttachmentPreviewTitle, resolveAttachmentRecognition,
|
||||
@@ -1857,7 +1951,7 @@ export default {
|
||||
requiresApprovalOpinion,
|
||||
riskOverrideReasons, saveDetailNote, savingDetailNote, savingExpenseId,
|
||||
showAiAdvicePanel, showApplicationLeaderOpinion,
|
||||
showBudgetAnalysis,
|
||||
showBudgetAnalysis, showEmployeeRiskProfile,
|
||||
showExpenseRisk, startExpenseEdit, submitBusy, submitConfirmDialogOpen,
|
||||
submitRiskWarnings,
|
||||
triggerExpenseUpload, uploadedExpenseCount, uploadingExpenseId, saveExpenseEdit
|
||||
|
||||
@@ -8,6 +8,7 @@ const TASK_TYPE_LABELS = {
|
||||
weekly_expense_report: '周度费用洞察',
|
||||
rule_review_digest: '规则待审摘要',
|
||||
knowledge_index_sync: '知识库归集',
|
||||
finance_policy_knowledge_organize: '整理公司财务知识制度',
|
||||
llm_wiki_rule_formation: '知识库归集',
|
||||
x_financial_callback: '任务回调上报'
|
||||
}
|
||||
@@ -19,6 +20,7 @@ const TASK_TYPE_SKILL_CATEGORIES = {
|
||||
weekly_expense_report: '整理',
|
||||
rule_review_digest: '升级',
|
||||
knowledge_index_sync: '积累',
|
||||
finance_policy_knowledge_organize: '整理',
|
||||
llm_wiki_rule_formation: '积累',
|
||||
x_financial_callback: '升级'
|
||||
}
|
||||
|
||||
40
web/src/views/scripts/employeeBankFields.js
Normal file
40
web/src/views/scripts/employeeBankFields.js
Normal file
@@ -0,0 +1,40 @@
|
||||
export function createEmployeeBankFormFields() {
|
||||
return {
|
||||
bankAccountName: '',
|
||||
bankName: '',
|
||||
bankAccountNo: ''
|
||||
}
|
||||
}
|
||||
|
||||
export function mapEmployeeBankFormFields(employee) {
|
||||
return {
|
||||
bankAccountName: employee?.bankAccountName || '',
|
||||
bankName: employee?.bankName || '',
|
||||
bankAccountNo: employee?.bankAccountNo || ''
|
||||
}
|
||||
}
|
||||
|
||||
export function getEmployeeBankSearchFields(employee) {
|
||||
return [
|
||||
employee?.bankAccountName,
|
||||
employee?.bankName,
|
||||
employee?.bankAccountNo
|
||||
]
|
||||
}
|
||||
|
||||
export function appendEmployeeBankUpdatePayload(payload, form, current, normalizeNullableText) {
|
||||
const nextBankAccountName = normalizeNullableText(form.bankAccountName)
|
||||
if (nextBankAccountName !== (current.bankAccountName || null)) {
|
||||
payload.bank_account_name = nextBankAccountName
|
||||
}
|
||||
|
||||
const nextBankName = normalizeNullableText(form.bankName)
|
||||
if (nextBankName !== (current.bankName || null)) {
|
||||
payload.bank_name = nextBankName
|
||||
}
|
||||
|
||||
const nextBankAccountNo = normalizeNullableText(form.bankAccountNo)
|
||||
if (nextBankAccountNo !== (current.bankAccountNo || null)) {
|
||||
payload.bank_account_no = nextBankAccountNo
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,8 @@ const STATUS_LABELS = {
|
||||
approved: '已审批',
|
||||
completed: '已完成',
|
||||
archived: '已归档',
|
||||
paid: '已入账'
|
||||
pending_payment: '待付款',
|
||||
paid: '已付款'
|
||||
}
|
||||
|
||||
const EXPENSE_TYPE_LABELS = {
|
||||
@@ -291,4 +292,3 @@ export function buildRequiredApplicationMissingText(expenseType) {
|
||||
'请先切换到申请助手发起相关申请;申请单存在后,再回到报销助手继续。'
|
||||
].join('\n')
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,8 @@ const EXPENSE_STATUS_LABELS = {
|
||||
submitted: '已提交',
|
||||
review: '审批中',
|
||||
approved: '已审核',
|
||||
paid: '已入账'
|
||||
pending_payment: '待付款',
|
||||
paid: '已付款'
|
||||
}
|
||||
const EXPENSE_RISK_LEVEL_LABELS = {
|
||||
high: '高风险',
|
||||
@@ -104,7 +105,13 @@ export function resolveExpenseStatusGroup(status) {
|
||||
if (['submitted', 'review'].includes(normalized)) {
|
||||
return { key: 'in_progress', label: '审批中' }
|
||||
}
|
||||
if (['approved', 'paid'].includes(normalized)) {
|
||||
if (normalized === 'pending_payment') {
|
||||
return { key: 'pending_payment', label: '待付款' }
|
||||
}
|
||||
if (normalized === 'paid') {
|
||||
return { key: 'completed', label: '已付款' }
|
||||
}
|
||||
if (['approved'].includes(normalized)) {
|
||||
return { key: 'completed', label: '已完成' }
|
||||
}
|
||||
return { key: 'other', label: '其他状态' }
|
||||
|
||||
@@ -82,7 +82,7 @@ export const GUIDED_QUERY_STATUS_OPTIONS = [
|
||||
{ key: 'pending', label: '审批中', description: '正在流转审批的单据' },
|
||||
{ key: 'returned', label: '已退回', description: '需要补充或修改的单据' },
|
||||
{ key: 'archived', label: '已归档', description: '已完成归档的单据' },
|
||||
{ key: 'completed', label: '已完成', description: '已审核完成或已入账的单据' }
|
||||
{ key: 'completed', label: '已完成', description: '已审核完成或已付款的单据' }
|
||||
]
|
||||
|
||||
const NO_ATTACHMENT_TEXT_PATTERN = /^(稍后|暂不|不用|没有|待上传|后面|后续|先不|以票据为准)/u
|
||||
|
||||
@@ -159,10 +159,13 @@ export function resolveExpenseDescriptionDetail(itemType, itemLocation) {
|
||||
}
|
||||
|
||||
export function buildFallbackProgressSteps(requestModel = {}) {
|
||||
const node = String(requestModel?.node || requestModel?.workflowNode || requestModel?.approvalStage || '').trim()
|
||||
const approvalKey = String(requestModel?.approvalKey || '').trim()
|
||||
const pendingPayment = approvalKey === 'pending_payment' || /待付款/.test(node)
|
||||
const paid = /已付款/.test(node)
|
||||
const completed = approvalKey === 'completed' || paid || /审批完成|申请完成|已完成/.test(node)
|
||||
|
||||
if (isApplicationDocumentRequest(requestModel)) {
|
||||
const node = String(requestModel?.node || requestModel?.workflowNode || requestModel?.approvalStage || '').trim()
|
||||
const approvalKey = String(requestModel?.approvalKey || '').trim()
|
||||
const completed = approvalKey === 'completed' || /审批完成|申请完成|已完成/.test(node)
|
||||
const inLeaderApproval = approvalKey === 'in_progress' || /直属领导|领导审批|审批中/.test(node)
|
||||
|
||||
return [
|
||||
@@ -199,7 +202,8 @@ export function buildFallbackProgressSteps(requestModel = {}) {
|
||||
{ index: 3, label: 'AI预审', time: '待处理' },
|
||||
{ index: 4, label: '直属领导审批', time: '待处理' },
|
||||
{ index: 5, label: '财务审批', time: '待处理' },
|
||||
{ index: 6, label: '归档入账', time: '待处理' }
|
||||
{ index: 6, label: '待付款', time: pendingPayment ? '进行中' : completed ? '已完成' : '待处理', done: completed, active: pendingPayment || completed, current: pendingPayment },
|
||||
{ index: 7, label: '已付款', time: paid || completed ? '已完成' : '待处理', done: paid || completed, active: paid || completed, current: false }
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
98
web/src/views/scripts/travelRequestDetailPaymentFlow.js
Normal file
98
web/src/views/scripts/travelRequestDetailPaymentFlow.js
Normal file
@@ -0,0 +1,98 @@
|
||||
import { computed, ref } from 'vue'
|
||||
|
||||
import { payExpenseClaim } from '../../services/reimbursements.js'
|
||||
import {
|
||||
canManageExpenseClaims,
|
||||
isFinanceUser
|
||||
} from '../../utils/accessControl.js'
|
||||
|
||||
export function useTravelRequestPaymentFlow({
|
||||
request,
|
||||
currentUser,
|
||||
isApplicationDocument,
|
||||
isCurrentApplicant,
|
||||
toast,
|
||||
emit
|
||||
}) {
|
||||
const payBusy = ref(false)
|
||||
const payConfirmDialogOpen = ref(false)
|
||||
|
||||
const isPendingPaymentStage = computed(() => {
|
||||
const node = String(request.value.node || request.value.approvalStage || '').trim()
|
||||
return (
|
||||
!isApplicationDocument.value
|
||||
&& Boolean(request.value.claimId)
|
||||
&& (
|
||||
request.value.approvalKey === 'pending_payment'
|
||||
|| String(request.value.status || '').trim().toLowerCase() === 'pending_payment'
|
||||
|| node === '待付款'
|
||||
)
|
||||
)
|
||||
})
|
||||
|
||||
const canPayRequest = computed(() =>
|
||||
isPendingPaymentStage.value
|
||||
&& !isCurrentApplicant.value
|
||||
&& (
|
||||
isFinanceUser(currentUser.value)
|
||||
|| canManageExpenseClaims(currentUser.value)
|
||||
)
|
||||
)
|
||||
|
||||
function handlePayRequest() {
|
||||
if (!request.value.claimId) {
|
||||
toast('当前单据缺少 claimId,暂时无法确认付款。')
|
||||
return
|
||||
}
|
||||
|
||||
if (!canPayRequest.value) {
|
||||
toast('只有待付款状态的报销单可以确认付款。')
|
||||
return
|
||||
}
|
||||
|
||||
payConfirmDialogOpen.value = true
|
||||
}
|
||||
|
||||
function closePayConfirmDialog() {
|
||||
if (payBusy.value) {
|
||||
return
|
||||
}
|
||||
|
||||
payConfirmDialogOpen.value = false
|
||||
}
|
||||
|
||||
async function confirmPayRequest() {
|
||||
if (!request.value.claimId) {
|
||||
toast('当前单据缺少 claimId,暂时无法确认付款。')
|
||||
payConfirmDialogOpen.value = false
|
||||
return
|
||||
}
|
||||
|
||||
if (!canPayRequest.value) {
|
||||
toast('只有待付款状态的报销单可以确认付款。')
|
||||
payConfirmDialogOpen.value = false
|
||||
return
|
||||
}
|
||||
|
||||
payBusy.value = true
|
||||
try {
|
||||
await payExpenseClaim(request.value.claimId)
|
||||
payConfirmDialogOpen.value = false
|
||||
toast(`${request.value.id} 已确认付款。`)
|
||||
emit('request-updated', { claimId: request.value.claimId })
|
||||
} catch (error) {
|
||||
toast(error?.message || '确认付款失败,请稍后重试。')
|
||||
} finally {
|
||||
payBusy.value = false
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
canPayRequest,
|
||||
closePayConfirmDialog,
|
||||
confirmPayRequest,
|
||||
handlePayRequest,
|
||||
payBusy,
|
||||
payConfirmDialogOpen
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user