Skip to content

Commit 913c995

Browse files
committed
feat:增加案例流程,业务表单发起时选择审批人
1 parent a5c533b commit 913c995

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

src/views/bpm/oa/leave/create.vue

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,12 @@ const submitForm = async () => {
138138
139139
// 新增 ====== begin ========
140140
/** 获取审批详情 */
141-
const getApprovalDetail = async (row: any) => {
141+
const getApprovalDetail = async () => {
142142
try {
143143
const data = await ProcessInstanceApi.getApprovalDetail({
144-
processDefinitionId: row.id,
144+
processDefinitionId: processDefinitionId.value,
145145
activityId: NodeId.START_USER_NODE_ID,
146-
processVariablesStr: row.processVariablesStr // 解决 GET 无法传递对象的问题,后端 String 再转 JSON
146+
processVariablesStr: JSON.stringify({ day: daysDifference() }) // 解决 GET 无法传递对象的问题,后端 String 再转 JSON
147147
})
148148
149149
if (!data) {
@@ -178,6 +178,13 @@ const getApprovalDetail = async (row: any) => {
178178
const selectUserConfirm = (id: string, userList: any[]) => {
179179
startUserSelectAssignees.value[id] = userList?.map((item: any) => item.id)
180180
}
181+
182+
// 计算天数差
183+
const daysDifference = () => {
184+
const oneDay = 24 * 60 * 60 * 1000 // 一天的毫秒数
185+
const diffTime = Math.abs(Number(formData.value.endTime) - Number(formData.value.startTime))
186+
return Math.floor(diffTime / oneDay)
187+
}
181188
// 新增 ====== end ========
182189
183190
/** 初始化 */
@@ -194,15 +201,12 @@ onMounted(async () => {
194201
processDefinitionId.value = processDefinitionDetail.id
195202
startUserSelectTasks.value = processDefinitionDetail.startUserSelectTasks
196203
// 新增 ====== begin ========
197-
// 查询流程预测节点
198-
getApprovalDetail({
199-
id: processDefinitionId.value,
200-
processVariablesStr: JSON.stringify(formData.value)
201-
})
204+
// 加载最新的审批详情,主要用于节点预测
205+
getApprovalDetail()
202206
// 新增 ====== end ========
203207
})
204208
// 新增 ====== begin ========
205-
/** 预测流程节点会因为输入的参数值而产生新的预测结果值,所以需重新预测一次 */
209+
/** 预测流程节点会因为输入的参数值而产生新的预测结果值,所以需重新预测一次, formData.value可改成实际业务中的特定字段 */
206210
watch(
207211
formData.value,
208212
(newValue, oldValue) => {
@@ -213,11 +217,8 @@ watch(
213217
// 记录之前的节点审批人
214218
tempStartUserSelectAssignees.value = startUserSelectAssignees.value
215219
startUserSelectAssignees.value = {}
216-
// 加载最新的审批详情
217-
getApprovalDetail({
218-
id: processDefinitionId.value,
219-
processVariablesStr: JSON.stringify(newValue) // 解决 GET 无法传递对象的问题,后端 String 再转 JSON
220-
})
220+
// 加载最新的审批详情,主要用于节点预测
221+
getApprovalDetail()
221222
}
222223
},
223224
{

0 commit comments

Comments
 (0)