feat: [bpm] 转办和委派操作
This commit is contained in:
@@ -61,3 +61,13 @@ export function getTaskListByProcessInstanceId(processInstanceId: string) {
|
||||
export function getTaskManagerPage(params: PageParam) {
|
||||
return http.get<PageResult<Task>>('/bpm/task/manager-page', params)
|
||||
}
|
||||
|
||||
/** 委派任务 */
|
||||
export function delegateTask(data: { id: string, delegateUserId: string, reason: string }) {
|
||||
return http.put<boolean>('/bpm/task/delegate', data)
|
||||
}
|
||||
|
||||
/** 转办任务 */
|
||||
export function transferTask(data: { id: string, assigneeUserId: string, reason: string }) {
|
||||
return http.put<boolean>('/bpm/task/transfer', data)
|
||||
}
|
||||
|
||||
@@ -144,10 +144,14 @@ function handleOperation(operationType: number) {
|
||||
uni.navigateTo({ url: `/pages-bpm/processInstance/detail/audit/index?id=${runningTask.value.id}&pass=false` })
|
||||
break
|
||||
case BpmTaskOperationButtonTypeEnum.DELEGATE:
|
||||
toast.show('委派功能待实现')
|
||||
uni.navigateTo({
|
||||
url: `/pages-bpm/processInstance/detail/reassign/index?processInstanceId=${runningTask.value.processInstanceId}&taskId=${runningTask.value.id}&type=delegate`,
|
||||
})
|
||||
break
|
||||
case BpmTaskOperationButtonTypeEnum.TRANSFER:
|
||||
toast.show('转办功能待实现')
|
||||
uni.navigateTo({
|
||||
url: `/pages-bpm/processInstance/detail/reassign/index?processInstanceId=${runningTask.value.processInstanceId}&taskId=${runningTask.value.id}&type=transfer`,
|
||||
})
|
||||
break
|
||||
case BpmTaskOperationButtonTypeEnum.ADD_SIGN:
|
||||
toast.show('加签功能待实现')
|
||||
|
||||
153
src/pages-bpm/processInstance/detail/reassign/index.vue
Normal file
153
src/pages-bpm/processInstance/detail/reassign/index.vue
Normal file
@@ -0,0 +1,153 @@
|
||||
<template>
|
||||
<view class="yd-page-container">
|
||||
<!-- 顶部导航栏 -->
|
||||
<wd-navbar
|
||||
:title="isDelegate ? '委派任务' : '转办任务'"
|
||||
left-arrow placeholder safe-area-inset-top fixed
|
||||
@click-left="handleBack"
|
||||
/>
|
||||
|
||||
<!-- 操作表单 -->
|
||||
<view class="p-24rpx">
|
||||
<wd-form ref="formRef" :model="formData" :rules="formRules">
|
||||
<wd-cell-group border>
|
||||
<!-- 用户选择 -->
|
||||
<UserPicker
|
||||
v-model="formData.userId"
|
||||
prop="userId"
|
||||
type="radio"
|
||||
:label="`${isDelegate ? '接收人' : '新审批人'}:`"
|
||||
:placeholder="`请选择${isDelegate ? '接收人' : '新审批人'}`"
|
||||
/>
|
||||
|
||||
<!-- 审批意见 -->
|
||||
<wd-textarea
|
||||
v-model="formData.reason"
|
||||
prop="reason"
|
||||
label="审批意见:"
|
||||
label-width="180rpx"
|
||||
placeholder="请输入审批意见"
|
||||
:maxlength="500"
|
||||
show-word-limit
|
||||
clearable
|
||||
/>
|
||||
</wd-cell-group>
|
||||
<!-- 提交按钮 -->
|
||||
<view class="mt-48rpx">
|
||||
<wd-button
|
||||
type="primary"
|
||||
block
|
||||
:loading="submitting"
|
||||
:disabled="submitting"
|
||||
@click="handleSubmit"
|
||||
>
|
||||
{{ isDelegate ? '委派' : '转办' }}
|
||||
</wd-button>
|
||||
</view>
|
||||
</wd-form>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { FormInstance } from 'wot-design-uni/components/wd-form/types'
|
||||
import { computed, reactive, ref } from 'vue'
|
||||
import { useToast } from 'wot-design-uni'
|
||||
import { delegateTask, transferTask } from '@/api/bpm/task'
|
||||
import UserPicker from '@/components/system-select/user-picker.vue'
|
||||
import { navigateBackPlus } from '@/utils'
|
||||
|
||||
const props = defineProps<{
|
||||
processInstanceId: string
|
||||
taskId: string
|
||||
type: string // 'delegate' 或 'transfer'
|
||||
}>()
|
||||
|
||||
definePage({
|
||||
style: {
|
||||
navigationBarTitleText: '',
|
||||
navigationStyle: 'custom',
|
||||
},
|
||||
})
|
||||
|
||||
const taskId = computed(() => props.taskId)
|
||||
const processInstanceId = computed(() => props.processInstanceId)
|
||||
const operationType = computed(() => props.type || 'transfer') // 默认转办
|
||||
const isDelegate = computed(() => operationType.value === 'delegate')
|
||||
const toast = useToast()
|
||||
const submitting = ref(false)
|
||||
const formRef = ref<FormInstance>()
|
||||
|
||||
const formData = reactive({
|
||||
userId: undefined as number | undefined,
|
||||
reason: '',
|
||||
})
|
||||
|
||||
const formRules = {
|
||||
userId: [
|
||||
{ required: true, message: `请选择${isDelegate.value ? '接收人' : '新审批人'}` },
|
||||
],
|
||||
reason: [
|
||||
{ required: true, message: '审批意见不能为空' },
|
||||
],
|
||||
}
|
||||
|
||||
/** 返回上一页 */
|
||||
function handleBack() {
|
||||
navigateBackPlus(`/pages-bpm/processInstance/detail/index?id=${processInstanceId.value}&taskId=${taskId.value}`)
|
||||
}
|
||||
|
||||
/** 初始化校验 */
|
||||
if (!props.taskId || !props.processInstanceId) {
|
||||
toast.show('参数错误')
|
||||
}
|
||||
|
||||
/** 提交操作 */
|
||||
async function handleSubmit() {
|
||||
if (submitting.value)
|
||||
return
|
||||
|
||||
// 使用 wd-form 的校验方法
|
||||
const { valid } = await formRef.value!.validate()
|
||||
if (!valid) {
|
||||
return
|
||||
}
|
||||
|
||||
submitting.value = true
|
||||
try {
|
||||
const data = {
|
||||
id: taskId.value as string,
|
||||
reason: formData.reason,
|
||||
}
|
||||
|
||||
let result
|
||||
if (isDelegate.value) {
|
||||
// 委派
|
||||
result = await delegateTask({
|
||||
...data,
|
||||
delegateUserId: String(formData.userId),
|
||||
})
|
||||
} else {
|
||||
// 转办
|
||||
result = await transferTask({
|
||||
...data,
|
||||
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}`,
|
||||
})
|
||||
}, 1500)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`[reassign] ${isDelegate.value ? '委派' : '转办'}失败:`, error)
|
||||
toast.error(`${isDelegate.value ? '委派' : '转办'}失败`)
|
||||
} finally {
|
||||
submitting.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user