后端新增员工行为画像算法模块,支持标签规则引擎和评分计算, 完善员工模型、银行信息、序列化和导入逻辑,优化报销审批流 和工作流常量,增强 Hermes 同步和知识同步能力,前端新增费 用画像详情弹窗、雷达图和风险卡片组件,完善登录页和工作台 样式,优化文档中心和归档中心交互,补充单元测试。
99 lines
2.4 KiB
JavaScript
99 lines
2.4 KiB
JavaScript
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
|
||
}
|
||
}
|