Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
4b554204
authored
Mar 20, 2025
by
smallNorthLee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: oa业务表单添加审批人选择
parent
772deb50
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
95 additions
and
50 deletions
+95
-50
src/views/bpm/oa/leave/create.vue
+95
-50
No files found.
src/views/bpm/oa/leave/create.vue
View file @
4b554204
<
template
>
<
template
>
<el-form
<el-row
:gutter=
"20"
>
<el-col
:span=
"16"
><el-form
ref=
"formRef"
ref=
"formRef"
v-loading=
"formLoading"
v-loading=
"formLoading"
:model=
"formData"
:model=
"formData"
...
@@ -35,49 +37,33 @@
...
@@ -35,49 +37,33 @@
/>
/>
</el-form-item>
</el-form-item>
<el-form-item
label=
"原因"
prop=
"reason"
>
<el-form-item
label=
"原因"
prop=
"reason"
>
<el-input
v-model=
"formData.reason"
placeholder=
"请输
请假原因"
type=
"textarea"
/>
<el-input
v-model=
"formData.reason"
placeholder=
"请输入
请假原因"
type=
"textarea"
/>
</el-form-item>
</el-form-item>
<el-col
v-if=
"startUserSelectTasks.length > 0"
>
<el-card
class=
"mb-10px"
>
<template
#
header
>
指定审批人
</
template
>
<el-form
:model=
"startUserSelectAssignees"
:rules=
"startUserSelectAssigneesFormRules"
ref=
"startUserSelectAssigneesFormRef"
>
<el-form-item
v-for=
"userTask in startUserSelectTasks"
:key=
"userTask.id"
:label=
"`任务【${userTask.name}】`"
:prop=
"userTask.id"
>
<el-select
v-model=
"startUserSelectAssignees[userTask.id]"
multiple
placeholder=
"请选择审批人"
>
<el-option
v-for=
"user in userList"
:key=
"user.id"
:label=
"user.nickname"
:value=
"user.id"
/>
</el-select>
</el-form-item>
</el-form>
</el-card>
</el-col>
<el-form-item>
<el-form-item>
<el-button
:disabled=
"formLoading"
type=
"primary"
@
click=
"submitForm"
>
确 定
</el-button>
<el-button
:disabled=
"formLoading"
type=
"primary"
@
click=
"submitForm"
>
确 定
</el-button>
</el-form-item>
</el-form-item>
</el-form>
</el-form></el-col
>
<el-col
:span=
"8"
>
<!-- 流程时间线 -->
<ProcessInstanceTimeline
ref=
"timelineRef"
:activity-nodes=
"activityNodes"
:show-status-icon=
"false"
@
select-user-confirm=
"selectUserConfirm"
/>
</el-col>
</el-row>
</
template
>
</
template
>
<
script
lang=
"ts"
setup
>
<
script
lang=
"ts"
setup
>
import
{
DICT_TYPE
,
getIntDictOptions
}
from
'@/utils/dict'
import
{
DICT_TYPE
,
getIntDictOptions
}
from
'@/utils/dict'
import
*
as
LeaveApi
from
'@/api/bpm/leave'
import
*
as
LeaveApi
from
'@/api/bpm/leave'
import
{
useTagsViewStore
}
from
'@/store/modules/tagsView'
import
{
useTagsViewStore
}
from
'@/store/modules/tagsView'
import
*
as
DefinitionApi
from
'@/api/bpm/definition'
import
*
as
DefinitionApi
from
'@/api/bpm/definition'
import
*
as
UserApi
from
'@/api/system/user'
import
ProcessInstanceTimeline
from
'../../processInstance/detail/ProcessInstanceTimeline.vue'
import
*
as
ProcessInstanceApi
from
'@/api/bpm/processInstance'
import
{
CandidateStrategy
,
NodeId
}
from
'@/components/SimpleProcessDesignerV2/src/consts'
import
{
ApprovalNodeInfo
}
from
'@/api/bpm/processInstance'
defineOptions
({
name
:
'BpmOALeaveCreate'
})
defineOptions
({
name
:
'BpmOALeaveCreate'
})
...
@@ -104,9 +90,9 @@ const formRef = ref() // 表单 Ref
...
@@ -104,9 +90,9 @@ const formRef = ref() // 表单 Ref
const
processDefineKey
=
'oa_leave'
// 流程定义 Key
const
processDefineKey
=
'oa_leave'
// 流程定义 Key
const
startUserSelectTasks
=
ref
([])
// 发起人需要选择审批人的用户任务列表
const
startUserSelectTasks
=
ref
([])
// 发起人需要选择审批人的用户任务列表
const
startUserSelectAssignees
=
ref
({})
// 发起人选择审批人的数据
const
startUserSelectAssignees
=
ref
({})
// 发起人选择审批人的数据
const
startUserSelectAssigneesFormRef
=
ref
()
// 发起人选择审批人的表单 Ref
const
tempStartUserSelectAssignees
=
ref
({})
// 历史发起人选择审批人的数据,用于每次表单变更时,临时保存
const
startUserSelectAssigneesFormRules
=
ref
({})
// 发起人选择审批人的表单 Rules
const
activityNodes
=
ref
<
ProcessInstanceApi
.
ApprovalNodeInfo
[]
>
([])
// 审批节点信息
const
userList
=
ref
<
any
[]
>
([])
// 用户列表
const
processDefinitionId
=
ref
(
''
)
/** 提交表单 */
/** 提交表单 */
const
submitForm
=
async
()
=>
{
const
submitForm
=
async
()
=>
{
...
@@ -116,7 +102,14 @@ const submitForm = async () => {
...
@@ -116,7 +102,14 @@ const submitForm = async () => {
if
(
!
valid
)
return
if
(
!
valid
)
return
// 校验指定审批人
// 校验指定审批人
if
(
startUserSelectTasks
.
value
?.
length
>
0
)
{
if
(
startUserSelectTasks
.
value
?.
length
>
0
)
{
await
startUserSelectAssigneesFormRef
.
value
.
validate
()
for
(
const
userTask
of
startUserSelectTasks
.
value
)
{
if
(
Array
.
isArray
(
startUserSelectAssignees
.
value
[
userTask
.
id
])
&&
startUserSelectAssignees
.
value
[
userTask
.
id
].
length
===
0
)
{
return
message
.
warning
(
`请选择
${
userTask
.
name
}
的审批人`
)
}
}
}
}
// 提交请求
// 提交请求
...
@@ -137,28 +130,80 @@ const submitForm = async () => {
...
@@ -137,28 +130,80 @@ const submitForm = async () => {
}
}
}
}
/** 预测流程节点会因为输入的参数值而产生新的预测结果值,所以需重新预测一次 */
watch
(
formData
.
value
,
(
newValue
)
=>
{
// if (newValue && Object.keys(newValue.value).length > 0) {
// // 记录之前的节点审批人
// tempStartUserSelectAssignees.value = startUserSelectAssignees.value
// startUserSelectAssignees.value = {}
// // 加载最新的审批详情
// getApprovalDetail({
// id: processDefinitionId,
// processVariablesStr: JSON.stringify(newValue.value) // 解决 GET 无法传递对象的问题,后端 String 再转 JSON
// })
// }
},
{
immediate
:
true
}
)
/** 获取审批详情 */
const
getApprovalDetail
=
async
(
row
:
any
)
=>
{
try
{
const
data
=
await
ProcessInstanceApi
.
getApprovalDetail
({
processDefinitionId
:
row
.
id
,
activityId
:
NodeId
.
START_USER_NODE_ID
})
if
(
!
data
)
{
message
.
error
(
'查询不到审批详情信息!'
)
return
}
// 获取审批节点,显示 Timeline 的数据
activityNodes
.
value
=
data
.
activityNodes
// 获取发起人自选的任务
startUserSelectTasks
.
value
=
data
.
activityNodes
?.
filter
(
(
node
:
ApprovalNodeInfo
)
=>
CandidateStrategy
.
START_USER_SELECT
===
node
.
candidateStrategy
)
// 恢复之前的选择审批人
if
(
startUserSelectTasks
.
value
?.
length
>
0
)
{
for
(
const
node
of
startUserSelectTasks
.
value
)
{
if
(
tempStartUserSelectAssignees
.
value
[
node
.
id
]
&&
tempStartUserSelectAssignees
.
value
[
node
.
id
].
length
>
0
)
{
startUserSelectAssignees
.
value
[
node
.
id
]
=
tempStartUserSelectAssignees
.
value
[
node
.
id
]
}
else
{
startUserSelectAssignees
.
value
[
node
.
id
]
=
[]
}
}
}
}
finally
{
}
}
/** 选择发起人 */
const
selectUserConfirm
=
(
id
:
string
,
userList
:
any
[])
=>
{
startUserSelectAssignees
.
value
[
id
]
=
userList
?.
map
((
item
:
any
)
=>
item
.
id
)
}
/** 初始化 */
/** 初始化 */
onMounted
(
async
()
=>
{
onMounted
(
async
()
=>
{
const
processDefinitionDetail
=
await
DefinitionApi
.
getProcessDefinition
(
const
processDefinitionDetail
=
await
DefinitionApi
.
getProcessDefinition
(
undefined
,
undefined
,
processDefineKey
processDefineKey
)
)
if
(
!
processDefinitionDetail
)
{
if
(
!
processDefinitionDetail
)
{
message
.
error
(
'OA 请假的流程模型未配置,请检查!'
)
message
.
error
(
'OA 请假的流程模型未配置,请检查!'
)
return
return
}
}
processDefinitionId
.
value
=
processDefinitionDetail
.
id
startUserSelectTasks
.
value
=
processDefinitionDetail
.
startUserSelectTasks
startUserSelectTasks
.
value
=
processDefinitionDetail
.
startUserSelectTasks
// 设置指定审批人
getApprovalDetail
({
id
:
processDefinitionId
.
value
,
processVariablesStr
:
JSON
.
stringify
(
formData
.
value
)
})
if
(
startUserSelectTasks
.
value
?.
length
>
0
)
{
// 设置校验规则
for
(
const
userTask
of
startUserSelectTasks
.
value
)
{
startUserSelectAssignees
.
value
[
userTask
.
id
]
=
[]
startUserSelectAssigneesFormRules
.
value
[
userTask
.
id
]
=
[
{
required
:
true
,
message
:
'请选择审批人'
,
trigger
:
'blur'
}
]
}
// 加载用户列表
userList
.
value
=
await
UserApi
.
getSimpleUserList
()
}
})
})
</
script
>
</
script
>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment