Files
fad_oa/ruoyi-ui/src/views/hrm/requests/_manualApproverMixin.js
2026-04-13 17:04:38 +08:00

48 lines
1.5 KiB
JavaScript
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.

// Mixin支持“模板审批”与“手动审批人”二选一
// 依赖:
// 1. 引用 user-select 组件 (已有 src/components/userSelect)
// 2. 表单中需提供 tplId (工作流模板ID) 与 assigneeUserId (手动审批人ID)
//
// 使用方式:
// import manualApproverMixin from './_manualApproverMixin'
// export default { mixins: [manualApproverMixin], ... }
// 你的表单中绑定 approverMode / tplId / assigneeUserId
// approverMode: 'template' | 'manual'
export default {
data() {
return {
approverMode: 'template', // 默认使用流程模板
tplId: null, // 选中的模板ID
assigneeUserId: null // 手动审批人
}
},
computed: {
useTemplate() {
return this.approverMode === 'template'
}
},
methods: {
/**
* 在提交之前,调用该方法获取流程相关字段
* @returns {{tplId: number|null, assigneeUserId: number|null}}
*/
buildFlowFields() {
if (this.useTemplate) {
// 模板审批:必须选择 tplId
if (!this.tplId) {
this.$message.warning('请选择审批流程模板')
throw new Error('缺少 tplId')
}
return { tplId: this.tplId, assigneeUserId: null }
}
// 手动审批:必须选择审批人
if (!this.assigneeUserId) {
this.$message.warning('请选择审批人')
throw new Error('缺少 assigneeUserId')
}
return { tplId: 0, assigneeUserId: this.assigneeUserId }
}
}
}