Jelajahi Sumber

!40 feat: [bpm] review 修改
Merge pull request !40 from Jason/master

芋道源码 3 bulan lalu
induk
melakukan
7a5d8d9881

+ 23 - 31
src/pages-bpm/processInstance/detail/add-sign/index.vue

@@ -40,8 +40,8 @@
             type="primary"
             type="primary"
             class="flex-1"
             class="flex-1"
             plain
             plain
-            :loading="submitting"
-            :disabled="submitting"
+            :loading="formLoading"
+            :disabled="formLoading"
             @click="handleSubmit('before')"
             @click="handleSubmit('before')"
           >
           >
             向前加签
             向前加签
@@ -49,8 +49,8 @@
           <wd-button
           <wd-button
             type="primary"
             type="primary"
             class="flex-1"
             class="flex-1"
-            :loading="submitting"
-            :disabled="submitting"
+            :loading="formLoading"
+            :disabled="formLoading"
             @click="handleSubmit('after')"
             @click="handleSubmit('after')"
           >
           >
             向后加签
             向后加签
@@ -84,7 +84,7 @@ definePage({
 const taskId = computed(() => props.taskId)
 const taskId = computed(() => props.taskId)
 const processInstanceId = computed(() => props.processInstanceId)
 const processInstanceId = computed(() => props.processInstanceId)
 const toast = useToast()
 const toast = useToast()
-const submitting = ref(false)
+const formLoading = ref(false)
 const formData = reactive({
 const formData = reactive({
   userIds: [] as number[],
   userIds: [] as number[],
   reason: '',
   reason: '',
@@ -104,48 +104,40 @@ function handleBack() {
   navigateBackPlus(`/pages-bpm/processInstance/detail/index?id=${processInstanceId.value}&taskId=${taskId.value}`)
   navigateBackPlus(`/pages-bpm/processInstance/detail/index?id=${processInstanceId.value}&taskId=${taskId.value}`)
 }
 }
 
 
-// TODO @jason:最好放在 onMounted 里?或者其他地方,有个入口方法。
-/** 初始化校验 */
-if (!props.taskId || !props.processInstanceId) {
-  toast.show('参数错误')
-}
-
 /** 提交操作 */
 /** 提交操作 */
 async function handleSubmit(type: 'before' | 'after') {
 async function handleSubmit(type: 'before' | 'after') {
-  if (submitting.value) {
+  if (formLoading.value) {
     return
     return
   }
   }
   const { valid } = await formRef.value!.validate()
   const { valid } = await formRef.value!.validate()
   if (!valid) {
   if (!valid) {
     return
     return
   }
   }
-
-  // TODO @jason:submitting 改成 formLoading 哇?统一代码风格哈;
-  submitting.value = true
+  formLoading.value = true
   try {
   try {
-    // TODO @jason:这里是不是不用判断 result 哈?
-    const result = await signCreateTask({
+    await signCreateTask({
       id: taskId.value as string,
       id: taskId.value as string,
       type,
       type,
       userIds: formData.userIds,
       userIds: formData.userIds,
       reason: formData.reason,
       reason: formData.reason,
     })
     })
-    if (result) {
-      const actionText = type === 'before' ? '向前加签' : '向后加签'
-      toast.success(`${actionText}成功`)
-      setTimeout(() => {
-        uni.redirectTo({
-          url: `/pages-bpm/processInstance/detail/index?id=${processInstanceId.value}&taskId=${taskId.value}`,
-        })
-      }, 500)
-    }
-  } catch (error) {
-    // TODO @jason:可以不用这里的 catch 哈?
     const actionText = type === 'before' ? '向前加签' : '向后加签'
     const actionText = type === 'before' ? '向前加签' : '向后加签'
-    console.error(`[add-sign] ${actionText}失败:`, error)
-    toast.error(`${actionText}失败`)
+    toast.success(`${actionText}成功`)
+    setTimeout(() => {
+      uni.redirectTo({
+        url: `/pages-bpm/processInstance/detail/index?id=${processInstanceId.value}&taskId=${taskId.value}`,
+      })
+    }, 500)
   } finally {
   } finally {
-    submitting.value = false
+    formLoading.value = false
   }
   }
 }
 }
+
+/** 页面加载时 */
+onMounted(() => {
+  /** 初始化校验 */
+  if (!props.taskId || !props.processInstanceId) {
+    toast.show('参数错误')
+  }
+})
 </script>
 </script>

+ 49 - 44
src/pages-bpm/processInstance/detail/audit/index.vue

@@ -10,29 +10,29 @@
 
 
     <!-- 审批表单 -->
     <!-- 审批表单 -->
     <view class="p-24rpx">
     <view class="p-24rpx">
-      <view class="overflow-hidden rounded-12rpx bg-white shadow-sm">
-        <view class="p-24rpx">
-          <view class="mb-16rpx text-32rpx text-[#333] font-semibold">
-            审批意见
-          </view>
+      <wd-form ref="formRef" :model="formData" :rules="formRules">
+        <wd-cell-group border>
+          <!-- 审批意见 -->
           <wd-textarea
           <wd-textarea
             v-model="formData.reason"
             v-model="formData.reason"
+            prop="reason"
+            label="审批意见:"
+            label-width="180rpx"
             placeholder="请输入审批意见"
             placeholder="请输入审批意见"
             :maxlength="500"
             :maxlength="500"
             show-word-limit
             show-word-limit
             clearable
             clearable
-            custom-class="border border-solid border-[#e5e5e5] rounded-8rpx"
           />
           />
-        </view>
-      </view>
+        </wd-cell-group>
+      </wd-form>
 
 
       <!-- 提交按钮 -->
       <!-- 提交按钮 -->
       <view class="mt-48rpx">
       <view class="mt-48rpx">
         <wd-button
         <wd-button
           :type="isApprove ? 'primary' : 'error'"
           :type="isApprove ? 'primary' : 'error'"
           block
           block
-          :loading="submitting"
-          :disabled="submitting"
+          :loading="formLoading"
+          :disabled="formLoading"
           @click="handleSubmit"
           @click="handleSubmit"
         >
         >
           {{ isApprove ? '同意' : '拒绝' }}
           {{ isApprove ? '同意' : '拒绝' }}
@@ -43,14 +43,16 @@
 </template>
 </template>
 
 
 <script lang="ts" setup>
 <script lang="ts" setup>
-import { computed, reactive, ref } from 'vue'
+import type { FormInstance } from 'wot-design-uni/components/wd-form/types'
+import { computed, onMounted, reactive, ref } from 'vue'
 import { useToast } from 'wot-design-uni'
 import { useToast } from 'wot-design-uni'
 import { approveTask, rejectTask } from '@/api/bpm/task'
 import { approveTask, rejectTask } from '@/api/bpm/task'
 import { navigateBackPlus } from '@/utils'
 import { navigateBackPlus } from '@/utils'
 
 
 const props = defineProps<{
 const props = defineProps<{
-  id?: string | any
-  pass?: string | any
+  processInstanceId?: string
+  taskId?: string
+  pass?: string
 }>()
 }>()
 
 
 definePage({
 definePage({
@@ -60,63 +62,66 @@ definePage({
   },
   },
 })
 })
 
 
-const taskId = computed(() => props.id || '')
+const taskId = computed(() => props.taskId || '')
+const processInstanceId = computed(() => props.processInstanceId)
 const isPass = computed(() => props.pass !== 'false') // true: 同意, false: 拒绝
 const isPass = computed(() => props.pass !== 'false') // true: 同意, false: 拒绝
 const toast = useToast()
 const toast = useToast()
-const submitting = ref(false)
+const formLoading = ref(false)
 const formData = reactive({
 const formData = reactive({
   reason: '',
   reason: '',
 })
 })
 
 
+const formRules = {
+  reason: [
+    { required: true, message: '审批意见不能为空' },
+  ],
+}
+
+const formRef = ref<FormInstance>()
+
 /** 是否为同意操作 */
 /** 是否为同意操作 */
 const isApprove = computed(() => isPass.value)
 const isApprove = computed(() => isPass.value)
 
 
 /** 返回上一页 */
 /** 返回上一页 */
 function handleBack() {
 function handleBack() {
-  navigateBackPlus(`/pages-bpm/processInstance/detail/index?id=${taskId.value}`)
-}
-
-/** 初始化校验 */
-if (!props.id) {
-  toast.show('参数错误')
-}
-
-/** 校验表单 */
-function validateForm() {
-  if (!formData.reason.trim()) {
-    toast.show('请输入审批意见')
-    return false
-  }
-  return true
+  navigateBackPlus(`/pages-bpm/processInstance/detail/index?id=${processInstanceId.value}&taskId=${taskId.value}`)
 }
 }
 
 
 /** 提交审批 */
 /** 提交审批 */
 async function handleSubmit() {
 async function handleSubmit() {
-  // TODO @jason:看看是不是要用原生的校验
-  if (submitting.value) {
+  if (formLoading.value) {
     return
     return
   }
   }
-  if (!validateForm()) {
+
+  // 使用 wd-form 的校验方法
+  const { valid } = await formRef.value!.validate()
+  if (!valid) {
     return
     return
   }
   }
 
 
-  // TODO @jason:要不换成 formLoading?保持项目统一;
-  submitting.value = true
+  formLoading.value = true
   try {
   try {
     const api = isApprove.value ? approveTask : rejectTask
     const api = isApprove.value ? approveTask : rejectTask
-    // TODO @jason:这里看看不用 result
-    const result = await api({
+    await api({
       id: taskId.value as string,
       id: taskId.value as string,
       reason: formData.reason,
       reason: formData.reason,
     })
     })
-    if (result) {
-      toast.success('审批成功')
-      setTimeout(() => {
-        handleBack()
-      }, 1500)
-    }
+    toast.success('审批成功')
+    setTimeout(() => {
+      uni.redirectTo({
+        url: `/pages-bpm/processInstance/detail/index?id=${processInstanceId.value}&taskId=${taskId.value}`,
+      })
+    }, 1000)
   } finally {
   } finally {
-    submitting.value = false
+    formLoading.value = false
   }
   }
 }
 }
+
+/** 页面加载时 */
+onMounted(() => {
+  /** 初始化校验 */
+  if (!props.taskId || !props.processInstanceId) {
+    toast.show('参数错误')
+  }
+})
 </script>
 </script>

+ 2 - 3
src/pages-bpm/processInstance/detail/components/operation-button.vue

@@ -52,7 +52,6 @@ import type { Action } from 'wot-design-uni/components/wd-action-sheet/types'
 import type { ButtonType } from 'wot-design-uni/components/wd-button/types'
 import type { ButtonType } from 'wot-design-uni/components/wd-button/types'
 import type { ProcessInstance } from '@/api/bpm/processInstance'
 import type { ProcessInstance } from '@/api/bpm/processInstance'
 import type { Task } from '@/api/bpm/task'
 import type { Task } from '@/api/bpm/task'
-import { useToast } from 'wot-design-uni'
 import { useUserStore } from '@/store'
 import { useUserStore } from '@/store'
 import {
 import {
   BpmProcessInstanceStatus,
   BpmProcessInstanceStatus,
@@ -198,10 +197,10 @@ function init(theProcessInstance: ProcessInstance, task: Task) {
 function handleOperation(operationType: number) {
 function handleOperation(operationType: number) {
   switch (operationType) {
   switch (operationType) {
     case BpmTaskOperationButtonTypeEnum.APPROVE:
     case BpmTaskOperationButtonTypeEnum.APPROVE:
-      uni.navigateTo({ url: `/pages-bpm/processInstance/detail/audit/index?id=${runningTask.value.id}&pass=true` })
+      uni.navigateTo({ url: `/pages-bpm/processInstance/detail/audit/index?processInstanceId=${processInstance.value.id}&taskId=${runningTask.value?.id}&pass=true` })
       break
       break
     case BpmTaskOperationButtonTypeEnum.REJECT:
     case BpmTaskOperationButtonTypeEnum.REJECT:
-      uni.navigateTo({ url: `/pages-bpm/processInstance/detail/audit/index?id=${runningTask.value.id}&pass=false` })
+      uni.navigateTo({ url: `/pages-bpm/processInstance/detail/audit/index?processInstanceId=${processInstance.value.id}&taskId=${runningTask.value?.id}&pass=false` })
       break
       break
     case BpmTaskOperationButtonTypeEnum.DELEGATE:
     case BpmTaskOperationButtonTypeEnum.DELEGATE:
       uni.navigateTo({
       uni.navigateTo({

+ 35 - 51
src/pages-bpm/processInstance/detail/delete-sign/index.vue

@@ -40,8 +40,8 @@
           <wd-button
           <wd-button
             type="primary"
             type="primary"
             block
             block
-            :loading="submitting"
-            :disabled="submitting"
+            :loading="formLoading"
+            :disabled="formLoading"
             @click="handleSubmit"
             @click="handleSubmit"
           >
           >
             减签
             减签
@@ -75,7 +75,7 @@ definePage({
 const taskId = computed(() => props.taskId)
 const taskId = computed(() => props.taskId)
 const processInstanceId = computed(() => props.processInstanceId)
 const processInstanceId = computed(() => props.processInstanceId)
 const toast = useToast()
 const toast = useToast()
-const submitting = ref(false)
+const formLoading = ref(false)
 const taskOptions = ref<any[]>([])
 const taskOptions = ref<any[]>([])
 const formData = reactive({
 const formData = reactive({
   deleteSignTaskId: '',
   deleteSignTaskId: '',
@@ -96,12 +96,6 @@ function handleBack() {
   navigateBackPlus(`/pages-bpm/processInstance/detail/index?id=${processInstanceId.value}&taskId=${taskId.value}`)
   navigateBackPlus(`/pages-bpm/processInstance/detail/index?id=${processInstanceId.value}&taskId=${taskId.value}`)
 }
 }
 
 
-/** 初始化校验 */
-// TODO @jason:最好放在 onMounted 里?或者其他地方,有个入口方法。
-if (!props.taskId || !props.processInstanceId) {
-  toast.show('参数错误')
-}
-
 /** 获取减签人员标签 */
 /** 获取减签人员标签 */
 function getDeleteSignUserLabel(task: any): string {
 function getDeleteSignUserLabel(task: any): string {
   const deptName = task?.assigneeUser?.deptName || task?.ownerUser?.deptName
   const deptName = task?.assigneeUser?.deptName || task?.ownerUser?.deptName
@@ -111,37 +105,30 @@ function getDeleteSignUserLabel(task: any): string {
 
 
 /** 获取可减签的任务列表 */
 /** 获取可减签的任务列表 */
 async function loadDeleteSignTaskList() {
 async function loadDeleteSignTaskList() {
-  try {
-    let childTasks = []
-    // TODO @jason:这里应该是从 props 里获取?
-    // 从 URL 参数中获取子任务数据
-    if (props.children) {
-      try {
-        childTasks = JSON.parse(decodeURIComponent(props.children))
-      } catch (parseError) {
-        console.error('[delete-sign] 解析子任务数据失败:', parseError)
-      }
+  let childTasks = []
+  // 从 props 中获取子任务数据
+  if (props.children) {
+    try {
+      childTasks = JSON.parse(decodeURIComponent(props.children))
+    } catch (parseError) {
+      console.error('[delete-sign] 解析子任务数据失败:', parseError)
     }
     }
-    // 提示没有子任务数据
-    if (childTasks.length === 0) {
-      toast.show('没有可减签的任务')
-      return
-    }
-
-    taskOptions.value = childTasks.map(task => ({
-      id: task.id,
-      label: getDeleteSignUserLabel(task),
-    }))
-  } catch (error) {
-    // TODO @jason:这里不用 try catch 哈
-    console.error('[delete-sign] 获取可减签任务失败:', error)
-    toast.error('获取可减签任务失败')
   }
   }
+  // 提示没有子任务数据
+  if (childTasks.length === 0) {
+    toast.show('没有可减签的任务')
+    return
+  }
+
+  taskOptions.value = childTasks.map(task => ({
+    id: task.id,
+    label: getDeleteSignUserLabel(task),
+  }))
 }
 }
 
 
 /** 提交操作 */
 /** 提交操作 */
 async function handleSubmit() {
 async function handleSubmit() {
-  if (submitting.value) {
+  if (formLoading.value) {
     return
     return
   }
   }
   const { valid } = await formRef.value!.validate()
   const { valid } = await formRef.value!.validate()
@@ -149,33 +136,30 @@ async function handleSubmit() {
     return
     return
   }
   }
 
 
-  // TODO @jason:submitting 改成 formLoading 哇?统一代码风格哈;
-  submitting.value = true
+  formLoading.value = true
   try {
   try {
-    // TODO @jason:这里是不是不用判断 result 哈?
-    const result = await signDeleteTask({
+    await signDeleteTask({
       id: formData.deleteSignTaskId,
       id: formData.deleteSignTaskId,
       reason: formData.reason,
       reason: formData.reason,
     })
     })
-    if (result) {
-      toast.success('减签成功')
-      setTimeout(() => {
-        uni.redirectTo({
-          url: `/pages-bpm/processInstance/detail/index?id=${processInstanceId.value}&taskId=${taskId.value}`,
-        })
-      }, 500)
-    }
-  } catch (error) {
-    // TODO @jason:可以不用这里的 catch 哈?
-    console.error('[delete-sign] 减签失败:', error)
-    toast.error('减签失败')
+    toast.success('减签成功')
+    setTimeout(() => {
+      uni.redirectTo({
+        url: `/pages-bpm/processInstance/detail/index?id=${processInstanceId.value}&taskId=${taskId.value}`,
+      })
+    }, 500)
   } finally {
   } finally {
-    submitting.value = false
+    formLoading.value = false
   }
   }
 }
 }
 
 
 /** 页面加载时,获取可减签任务列表 */
 /** 页面加载时,获取可减签任务列表 */
 onMounted(() => {
 onMounted(() => {
+  /** 初始化校验 */
+  if (!props.taskId || !props.processInstanceId) {
+    toast.show('参数错误')
+    return
+  }
   loadDeleteSignTaskList()
   loadDeleteSignTaskList()
 })
 })
 </script>
 </script>

+ 21 - 27
src/pages-bpm/processInstance/detail/process-cancel/index.vue

@@ -37,8 +37,8 @@
           <wd-button
           <wd-button
             type="primary"
             type="primary"
             block
             block
-            :loading="submitting"
-            :disabled="submitting"
+            :loading="formLoading"
+            :disabled="formLoading"
             @click="handleSubmit"
             @click="handleSubmit"
           >
           >
             确认取消
             确认取消
@@ -71,7 +71,7 @@ definePage({
 const processInstanceId = computed(() => props.processInstanceId)
 const processInstanceId = computed(() => props.processInstanceId)
 const taskId = computed(() => props.taskId)
 const taskId = computed(() => props.taskId)
 const toast = useToast()
 const toast = useToast()
-const submitting = ref(false)
+const formLoading = ref(false)
 const formData = reactive({
 const formData = reactive({
   cancelReason: '',
   cancelReason: '',
 })
 })
@@ -90,43 +90,37 @@ function handleBack() {
   navigateBackPlus(backUrl)
   navigateBackPlus(backUrl)
 }
 }
 
 
-/** 初始化校验 */
-if (!props.processInstanceId) {
-  toast.show('参数错误')
-}
-
 /** 提交操作 */
 /** 提交操作 */
 async function handleSubmit() {
 async function handleSubmit() {
-  if (submitting.value) {
+  if (formLoading.value) {
     return
     return
   }
   }
   const { valid } = await formRef.value!.validate()
   const { valid } = await formRef.value!.validate()
   if (!valid) {
   if (!valid) {
     return
     return
   }
   }
-
-  // TODO @jason:最好放在 onMounted 里?或者其他地方,有个入口方法。
-  submitting.value = true
+  formLoading.value = true
   try {
   try {
-    // TODO @jason:不判断 result 可以哇?
-    const result = await cancelProcessInstanceByStartUser(
+    await cancelProcessInstanceByStartUser(
       processInstanceId.value,
       processInstanceId.value,
       formData.cancelReason,
       formData.cancelReason,
     )
     )
-    if (result) {
-      toast.success('流程取消成功')
-      setTimeout(() => {
-        uni.redirectTo({
-          url: `/pages-bpm/processInstance/detail/index?id=${processInstanceId.value}`,
-        })
-      }, 500)
-    }
-  } catch (error) {
-    // TODO @jason:错误处理,这里可以去掉哈。
-    console.error('[process-cancel] 取消流程失败:', error)
-    toast.error('取消流程失败')
+    toast.success('流程取消成功')
+    setTimeout(() => {
+      uni.redirectTo({
+        url: `/pages-bpm/processInstance/detail/index?id=${processInstanceId.value}`,
+      })
+    }, 500)
   } finally {
   } finally {
-    submitting.value = false
+    formLoading.value = false
   }
   }
 }
 }
+
+/** 页面加载时 */
+onMounted(() => {
+  /** 初始化校验 */
+  if (!props.processInstanceId) {
+    toast.show('参数错误')
+  }
+})
 </script>
 </script>

+ 16 - 22
src/pages-bpm/processInstance/detail/reassign/index.vue

@@ -95,12 +95,6 @@ function handleBack() {
   navigateBackPlus(`/pages-bpm/processInstance/detail/index?id=${processInstanceId.value}&taskId=${taskId.value}`)
   navigateBackPlus(`/pages-bpm/processInstance/detail/index?id=${processInstanceId.value}&taskId=${taskId.value}`)
 }
 }
 
 
-/** 初始化校验 */
-// TODO @jason:最好放在 onMounted 里?或者其他地方,有个入口方法。
-if (!props.taskId || !props.processInstanceId) {
-  toast.show('参数错误')
-}
-
 /** 提交操作 */
 /** 提交操作 */
 async function handleSubmit() {
 async function handleSubmit() {
   if (submitting.value) {
   if (submitting.value) {
@@ -118,33 +112,33 @@ async function handleSubmit() {
       id: taskId.value as string,
       id: taskId.value as string,
       reason: formData.reason,
       reason: formData.reason,
     }
     }
-    // todo @jason:这里是不是不用判断 result 哈?
-    let result: boolean
     if (isDelegate.value) {
     if (isDelegate.value) {
-      result = await delegateTask({
+      await delegateTask({
         ...data,
         ...data,
         delegateUserId: String(formData.userId),
         delegateUserId: String(formData.userId),
       })
       })
     } else {
     } else {
-      result = await transferTask({
+      await transferTask({
         ...data,
         ...data,
         assigneeUserId: String(formData.userId),
         assigneeUserId: String(formData.userId),
       })
       })
     }
     }
-    if (result) {
-      toast.success(`${isDelegate.value ? '委派' : '转办'}成功`)
-      setTimeout(() => {
-        uni.redirectTo({
-          url: `/pages-bpm/processInstance/detail/index?id=${processInstanceId.value}&taskId=${taskId.value}`,
-        })
-      }, 500)
-    }
-  } catch (error) {
-    // TODO @jason:可以不用这里的 catch 哈?
-    console.error(`[reassign] ${isDelegate.value ? '委派' : '转办'}失败:`, error)
-    toast.error(`${isDelegate.value ? '委派' : '转办'}失败`)
+    toast.success(`${isDelegate.value ? '委派' : '转办'}成功`)
+    setTimeout(() => {
+      uni.redirectTo({
+        url: `/pages-bpm/processInstance/detail/index?id=${processInstanceId.value}&taskId=${taskId.value}`,
+      })
+    }, 500)
   } finally {
   } finally {
     submitting.value = false
     submitting.value = false
   }
   }
 }
 }
+
+/** 页面加载时 */
+onMounted(() => {
+  /** 初始化校验 */
+  if (!props.taskId || !props.processInstanceId) {
+    toast.show('参数错误')
+  }
+})
 </script>
 </script>

+ 15 - 32
src/pages-bpm/processInstance/detail/return/index.vue

@@ -94,25 +94,10 @@ function handleBack() {
   navigateBackPlus(`/pages-bpm/processInstance/detail/index?id=${processInstanceId.value}&taskId=${taskId.value}`)
   navigateBackPlus(`/pages-bpm/processInstance/detail/index?id=${processInstanceId.value}&taskId=${taskId.value}`)
 }
 }
 
 
-/** 初始化校验 */
-// TODO @jason:最好放在 onMounted 里?或者其他地方,有个入口方法。
-if (!props.taskId || !props.processInstanceId) {
-  toast.show('参数错误')
-}
-
 /** 获取可退回的节点列表 */
 /** 获取可退回的节点列表 */
 async function loadReturnTaskList() {
 async function loadReturnTaskList() {
-  try {
-    const result = await getTaskListByReturn(taskId.value)
-    // TODO @jason:这个判断可以考虑去掉哈。
-    if (result && Array.isArray(result)) {
-      activityOptions.value = result
-    }
-  } catch (error) {
-    // TODO @jason:错误处理,这里可以去掉哈。
-    console.error('[return] 获取可退回节点失败:', error)
-    toast.error('获取可退回节点失败')
-  }
+  const result = await getTaskListByReturn(taskId.value)
+  activityOptions.value = result
 }
 }
 
 
 /** 提交操作 */
 /** 提交操作 */
@@ -124,28 +109,21 @@ async function handleSubmit() {
   if (!valid) {
   if (!valid) {
     return
     return
   }
   }
-
   // TODO @jason:submitting 改成 formLoading 哇?统一代码风格哈;
   // TODO @jason:submitting 改成 formLoading 哇?统一代码风格哈;
   submitting.value = true
   submitting.value = true
   try {
   try {
-    // TODO @jason:这里是不是不用判断 result 哈?
-    const result = await returnTask({
+    await returnTask({
       id: taskId.value as string,
       id: taskId.value as string,
       targetTaskDefinitionKey: formData.targetActivityId,
       targetTaskDefinitionKey: formData.targetActivityId,
       reason: formData.reason,
       reason: formData.reason,
     })
     })
-    if (result) {
-      toast.success('退回成功')
-      setTimeout(() => {
-        uni.redirectTo({
-          url: `/pages-bpm/processInstance/detail/index?id=${processInstanceId.value}&taskId=${taskId.value}`,
-        })
-      }, 500)
-    }
-  } catch (error) {
-    // TODO @jason:可以不用这里的 catch 哈?
-    console.error('[return] 退回失败:', error)
-    toast.error('退回失败')
+
+    toast.success('退回成功')
+    setTimeout(() => {
+      uni.redirectTo({
+        url: `/pages-bpm/processInstance/detail/index?id=${processInstanceId.value}&taskId=${taskId.value}`,
+      })
+    }, 500)
   } finally {
   } finally {
     submitting.value = false
     submitting.value = false
   }
   }
@@ -153,6 +131,11 @@ async function handleSubmit() {
 
 
 /** 页面加载时获取可退回节点列表 */
 /** 页面加载时获取可退回节点列表 */
 onMounted(() => {
 onMounted(() => {
+  /** 初始化校验 */
+  if (!props.taskId || !props.processInstanceId) {
+    toast.show('参数错误')
+    return
+  }
   loadReturnTaskList()
   loadReturnTaskList()
 })
 })
 </script>
 </script>

+ 2 - 2
src/pages/bpm/components/todo-list.vue

@@ -123,12 +123,12 @@ function handleDetail(item: Task) {
 
 
 /** 同意 */
 /** 同意 */
 function handleApprove(item: Task) {
 function handleApprove(item: Task) {
-  uni.navigateTo({ url: `/pages-bpm/processInstance/detail/audit/index?id=${item.id}&pass=true` })
+  uni.navigateTo({ url: `/pages-bpm/processInstance/detail/audit/index?processInstanceId=${item.processInstance.id}&taskId=${item.id}&pass=true` })
 }
 }
 
 
 /** 拒绝 */
 /** 拒绝 */
 function handleReject(item: Task) {
 function handleReject(item: Task) {
-  uni.navigateTo({ url: `/pages-bpm/processInstance/detail/audit/index?id=${item.id}&pass=false` })
+  uni.navigateTo({ url: `/pages-bpm/processInstance/detail/audit/index?processInstanceId=${item.processInstance.id}&taskId=${item.id}&pass=false` })
 }
 }
 
 
 /** 触底加载更多 */
 /** 触底加载更多 */