【功能修改】 新审批页面增加减签

pull/582/head
jason 2024-10-13 20:07:42 +08:00
parent 6b06f320b9
commit 842fe09e8b
6 changed files with 203 additions and 163 deletions

View File

@ -9,10 +9,10 @@ export enum TaskStatusEnum {
*/
NOT_START = -1,
/**
/**
*
*/
WAIT = 0,
WAIT = 0,
/**
*
*/
@ -26,7 +26,7 @@ export enum TaskStatusEnum {
*
*/
REJECT = 3,
/**
*
*/
@ -42,8 +42,7 @@ export enum TaskStatusEnum {
/**
*
*/
APPROVING = 7,
APPROVING = 7
}
export type TaskVO = {
@ -111,6 +110,11 @@ export const copyTask = async (data: any) => {
return await request.put({ url: '/bpm/task/copy', data })
}
// 获取我的待办任务
export const myTodoTask = async (processInstanceId: string) => {
return await request.get({ url: '/bpm/task/my-todo?processInstanceId=' + processInstanceId })
}
// 获取减签任务列表
export const getChildrenTaskList = async (id: string) => {
return await request.get({ url: '/bpm/task/list-by-parent-task-id?parentTaskId=' + id })

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 8.7 KiB

View File

@ -292,8 +292,8 @@ const remainingRouter: AppRouteRecordRaw[] = [
},
{
path: 'process-instance/detail',
// component: () => import('@/views/bpm/processInstance/detail/index_new.vue'),
component: () => import('@/views/bpm/processInstance/detail/index.vue'),
component: () => import('@/views/bpm/processInstance/detail/index_new.vue'),
//component: () => import('@/views/bpm/processInstance/detail/index.vue'),
name: 'BpmProcessInstanceDetail',
meta: {
noCache: true,

View File

@ -1,7 +1,7 @@
<template>
<div
class="h-50px bottom-10 text-14px flex items-center color-#32373c dark:color-#fff font-bold btn-container"
v-if="runningTask.id"
v-if="runningTask && runningTask.id"
>
<!-- 通过按钮 -->
<el-popover
@ -9,7 +9,7 @@
placement="top-end"
:width="420"
trigger="click"
v-if="isShowButton(OperationButtonType.APPROVE)"
v-if=" isHandleTaskStatus() && isShowButton(OperationButtonType.APPROVE)"
>
<template #reference>
<el-button plain type="success" @click="openPopover('approve')">
@ -38,7 +38,12 @@
/>
</el-card>
<el-form-item label="审批意见" prop="reason">
<el-input v-model="genericForm.reason" placeholder="请输入审批意见" type="textarea" :rows="4" />
<el-input
v-model="genericForm.reason"
placeholder="请输入审批意见"
type="textarea"
:rows="4"
/>
</el-form-item>
<el-form-item>
<el-button :disabled="formLoading" type="success" @click="handleAudit(true)">
@ -56,7 +61,7 @@
placement="top-end"
:width="420"
trigger="click"
v-if="isShowButton(OperationButtonType.REJECT)"
v-if=" isHandleTaskStatus() && isShowButton(OperationButtonType.REJECT)"
>
<template #reference>
<el-button class="mr-20px" plain type="danger" @click="openPopover('reject')">
@ -85,7 +90,12 @@
/>
</el-card>
<el-form-item label="审批意见" prop="reason">
<el-input v-model="genericForm.reason" placeholder="请输入审批意见" type="textarea" :rows="4" />
<el-input
v-model="genericForm.reason"
placeholder="请输入审批意见"
type="textarea"
:rows="4"
/>
</el-form-item>
<el-form-item>
<el-button :disabled="formLoading" type="danger" @click="handleAudit(false)">
@ -103,10 +113,10 @@
placement="top-start"
:width="420"
trigger="click"
v-if="isShowButton(OperationButtonType.COPY)"
v-if="isHandleTaskStatus() && isShowButton(OperationButtonType.COPY)"
>
<template #reference>
<div @click="openPopover('copy')" class="hover-bg-gray-100 rounded-xl p-6px" >
<div @click="openPopover('copy')" class="hover-bg-gray-100 rounded-xl p-6px">
<Icon :size="14" icon="svg-icon:send" />&nbsp;
{{ getButtonDisplayName(OperationButtonType.COPY) }}
</div>
@ -120,9 +130,14 @@
:rules="genericRule"
label-width="100px"
>
<el-form-item label="抄送人" prop="copyUserIds">
<el-select v-model="genericForm.copyUserIds" clearable style="width: 100%" multiple placeholder="请选择抄送人">
<el-select
v-model="genericForm.copyUserIds"
clearable
style="width: 100%"
multiple
placeholder="请选择抄送人"
>
<el-option
v-for="item in userOptions"
:key="item.id"
@ -132,7 +147,13 @@
</el-select>
</el-form-item>
<el-form-item label="抄送意见" prop="copyReason">
<el-input v-model="genericForm.copyReason" clearable placeholder="请输入抄送意见" type="textarea" :rows="3" />
<el-input
v-model="genericForm.copyReason"
clearable
placeholder="请输入抄送意见"
type="textarea"
:rows="3"
/>
</el-form-item>
<el-form-item>
@ -151,10 +172,10 @@
placement="top-start"
:width="420"
trigger="click"
v-if="isShowButton(OperationButtonType.TRANSFER)"
v-if=" isHandleTaskStatus() && isShowButton(OperationButtonType.TRANSFER)"
>
<template #reference>
<div @click="openPopover('transfer')" class="hover-bg-gray-100 rounded-xl p-6px" >
<div @click="openPopover('transfer')" class="hover-bg-gray-100 rounded-xl p-6px">
<Icon :size="14" icon="fa:share-square-o" />&nbsp;
{{ getButtonDisplayName(OperationButtonType.TRANSFER) }}
</div>
@ -168,7 +189,6 @@
:rules="genericRule"
label-width="100px"
>
<el-form-item label="新审批人" prop="assigneeUserId">
<el-select v-model="genericForm.assigneeUserId" clearable style="width: 100%">
<el-option
@ -180,12 +200,17 @@
</el-select>
</el-form-item>
<el-form-item label="审批意见" prop="reason">
<el-input v-model="genericForm.reason" clearable placeholder="请输入审批意见" type="textarea" :rows="3" />
<el-input
v-model="genericForm.reason"
clearable
placeholder="请输入审批意见"
type="textarea"
:rows="3"
/>
</el-form-item>
<el-form-item>
<el-button :disabled="formLoading" type="primary" @click="handleTransfer()">
<el-button :disabled="formLoading" type="primary" @click="handleTransfer()">
{{ getButtonDisplayName(OperationButtonType.TRANSFER) }}
</el-button>
<el-button @click="popOverVisible.transfer = false"> 取消 </el-button>
@ -193,22 +218,22 @@
</el-form>
</div>
</el-popover>
<!-- 委派按钮 -->
<el-popover
:visible="popOverVisible.delegate"
placement="top-start"
:width="420"
trigger="click"
v-if="isShowButton(OperationButtonType.DELEGATE)"
v-if="isHandleTaskStatus() && isShowButton(OperationButtonType.DELEGATE)"
>
<template #reference>
<div @click="openPopover('delegate')" class="hover-bg-gray-100 rounded-xl p-6px" >
<div @click="openPopover('delegate')" class="hover-bg-gray-100 rounded-xl p-6px">
<Icon :size="14" icon="ep:position" />&nbsp;
{{ getButtonDisplayName(OperationButtonType.DELEGATE) }}
</div>
</template>
<div class="flex flex-col flex-1 pt-20px px-20px" v-loading="formLoading">
<el-form
label-position="top"
@ -228,9 +253,15 @@
/>
</el-select>
</el-form-item>
<el-form-item label="审批意见" prop="reason">
<el-input v-model="genericForm.reason" clearable placeholder="请输入审批意见" type="textarea" :rows="3" />
<el-input
v-model="genericForm.reason"
clearable
placeholder="请输入审批意见"
type="textarea"
:rows="3"
/>
</el-form-item>
<el-form-item>
@ -241,7 +272,6 @@
</el-form-item>
</el-form>
</div>
</el-popover>
<!-- 加签按钮 当前任务审批人为A向前加签选了一个C则需要C先审批然后再是A审批向后加签BA审批完需要B再审批完才算完成这个任务节点 -->
@ -250,10 +280,10 @@
placement="top-start"
:width="420"
trigger="click"
v-if="isShowButton(OperationButtonType.ADD_SIGN)"
v-if="isHandleTaskStatus() && isShowButton(OperationButtonType.ADD_SIGN)"
>
<template #reference>
<div @click="openPopover('addSign')" class="hover-bg-gray-100 rounded-xl p-6px" >
<div @click="openPopover('addSign')" class="hover-bg-gray-100 rounded-xl p-6px">
<Icon :size="14" icon="ep:plus" />&nbsp;
{{ getButtonDisplayName(OperationButtonType.ADD_SIGN) }}
</div>
@ -278,9 +308,15 @@
/>
</el-select>
</el-form-item>
<el-form-item label="审批意见" prop="reason">
<el-input v-model="genericForm.reason" clearable placeholder="请输入审批意见" type="textarea" :rows="3" />
<el-input
v-model="genericForm.reason"
clearable
placeholder="请输入审批意见"
type="textarea"
:rows="3"
/>
</el-form-item>
<el-form-item>
<el-button :disabled="formLoading" type="primary" @click="handlerAddSign('before')">
@ -295,17 +331,25 @@
</div>
</el-popover>
<!-- TODO @jason减签 -->
<!-- 减签按钮 -->
<div
@click="openChildrenTask()"
class="hover-bg-gray-100 rounded-xl p-6px"
v-if="runningTask.children"
>
<Icon :size="14" icon="ep:semi-select" />&nbsp; 减签
</div>
<!-- 退回按钮 -->
<el-popover
:visible="popOverVisible.return"
placement="top-start"
:width="420"
trigger="click"
v-if="isShowButton(OperationButtonType.RETURN)"
v-if="isHandleTaskStatus() && isShowButton(OperationButtonType.RETURN)"
>
<template #reference>
<div @click="openReturnPopover" class="hover-bg-gray-100 rounded-xl p-6px" >
<div @click="openReturnPopover" class="hover-bg-gray-100 rounded-xl p-6px">
<Icon :size="14" icon="fa:mail-reply" />&nbsp;
{{ getButtonDisplayName(OperationButtonType.RETURN) }}
</div>
@ -320,20 +364,26 @@
label-width="100px"
>
<el-form-item label="退回节点" prop="targetTaskDefinitionKey">
<el-select v-model="genericForm.targetTaskDefinitionKey" clearable style="width: 100%">
<el-option
v-for="item in returnList"
:key="item.taskDefinitionKey"
:label="item.name"
:value="item.taskDefinitionKey"
/>
</el-select>
<el-select v-model="genericForm.targetTaskDefinitionKey" clearable style="width: 100%">
<el-option
v-for="item in returnList"
:key="item.taskDefinitionKey"
:label="item.name"
:value="item.taskDefinitionKey"
/>
</el-select>
</el-form-item>
<el-form-item label="退回理由" prop="returnReason">
<el-input v-model="genericForm.returnReason" clearable placeholder="请输入退回理由" type="textarea" :rows="3" />
<el-input
v-model="genericForm.returnReason"
clearable
placeholder="请输入退回理由"
type="textarea"
:rows="3"
/>
</el-form-item>
<el-form-item>
<el-button :disabled="formLoading" type="primary" @click="handleReturn()">
<el-button :disabled="formLoading" type="primary" @click="handleReturn()">
{{ getButtonDisplayName(OperationButtonType.RETURN) }}
</el-button>
<el-button @click="popOverVisible.return = false"> 取消 </el-button>
@ -341,29 +391,29 @@
</el-form>
</div>
</el-popover>
<!-- 弹窗子任务 -->
<TaskSignList ref="taskSignListRef" @success="reload" />
<!--TODO @jason撤回 -->
<!--TODO @jason再次发起 -->
</div>
</template>
<script lang="ts" setup>
import TaskSignList from './dialog/TaskSignList.vue'
import { setConfAndFields2 } from '@/utils/formCreate'
import { useUserStore } from '@/store/modules/user'
import * as TaskApi from '@/api/bpm/task'
import { propTypes } from '@/utils/propTypes'
import { isEmpty } from '@/utils/is'
import {
OperationButtonType,
OPERATION_BUTTON_NAME
} from '@/components/SimpleProcessDesignerV2/src/consts'
defineOptions({ name: 'ProcessInstanceBtnConatiner' })
const userId = useUserStore().getUser.id //
const message = useMessage() //
const { proxy } = getCurrentInstance() as any
const emit = defineEmits(['success']) // success
defineProps({
processInstance: propTypes.any, //
const props = defineProps({
processInstanceId: propTypes.string, //
userOptions: propTypes.any
})
const formLoading = ref(false) //
@ -374,7 +424,7 @@ const popOverVisible = ref({
transfer: false,
delegate: false,
addSign: false,
return : false,
return: false,
copy: false
})
/** 退回节点 */
@ -390,7 +440,7 @@ const genericRule = reactive({
reason: [{ required: true, message: '审批意见不能为空', trigger: 'blur' }],
returnReason: [{ required: true, message: '退回理由不能为空', trigger: 'blur' }],
copyUserIds: [{ required: true, message: '抄送人不能为空', trigger: 'change' }],
assigneeUserId:[{ required: true, message: '新审批人不能为空', trigger: 'change' }],
assigneeUserId: [{ required: true, message: '新审批人不能为空', trigger: 'change' }],
delegateUserId: [{ required: true, message: '接收人不能为空', trigger: 'change' }],
addSignUserIds: [{ required: true, message: '加签处理人不能为空', trigger: 'change' }]
})
@ -407,43 +457,25 @@ watch(
}
)
// TODO @jaosn
/**
* 设置 runningTasks 中的任务
*/
const loadRunningTask = (tasks: any[]) => {
runningTask.value = {}
genericForm.value = {}
approveForm.value = {}
approveFormFApi.value = {}
tasks.forEach((task: any) => {
if (!isEmpty(task.children)) {
loadRunningTask(task.children)
}
// 2.1
if (task.status !== 1 && task.status !== 6) {
return
}
// 2.2
if (!task.assigneeUser || task.assigneeUser.id !== userId) {
return
}
// 2.3
runningTask.value = { ...task }
genericForm.value = {
reason: '',
copyUserIds: []
}
// 2.4 approve
if (task.formId && task.formConf) {
const tempApproveForm = {}
setConfAndFields2(tempApproveForm, task.formConf, task.formFields, task.formVariables)
approveForm.value = tempApproveForm
/** 弹出退回气泡卡 */
const openReturnPopover = async () => {
returnList.value = await TaskApi.getTaskListByReturn(runningTask.value.id)
if (returnList.value.length === 0) {
message.warning('当前没有可退回的节点')
return
}
openPopover('return')
}
/** 弹出气泡卡 */
const openPopover = (type: string) => {
Object.keys(popOverVisible.value).forEach((item) => {
if (item === type) {
popOverVisible.value[item] = true
} else {
approveForm.value = {} //
popOverVisible.value[item] = false
}
})
formRef.value.resetFields()
}
/** 处理审批通过和不通过的操作 */
@ -479,7 +511,7 @@ const handleAudit = async (pass: boolean) => {
message.success('审批不通过成功')
}
// 2.2
getDetail()
reload()
} finally {
formLoading.value = false
}
@ -511,7 +543,6 @@ const handleCopy = async () => {
/** 处理转交 */
const handleTransfer = async () => {
formLoading.value = true
try {
const transferFormRef = proxy.$refs['formRef']
@ -526,12 +557,12 @@ const handleTransfer = async () => {
reason: genericForm.value.reason,
assigneeUserId: genericForm.value.assigneeUserId
}
await TaskApi.transferTask(data)
popOverVisible.value.transfer = false
message.success('操作成功')
// 2.
getDetail()
reload()
} finally {
formLoading.value = false
}
@ -539,30 +570,30 @@ const handleTransfer = async () => {
/** 处理委派 */
const handleDelegate = async () => {
formLoading.value = true
try {
const deletegateFormRef = proxy.$refs['formRef']
// 1.1
const elForm = unref(deletegateFormRef)
if (!elForm) return
const valid = await elForm.validate()
if (!valid) return
// 1.2
const data = {
id: runningTask.value.id,
reason: genericForm.value.reason,
delegateUserId: genericForm.value.delegateUserId
}
await TaskApi.delegateTask(data)
popOverVisible.value.delegate = false
message.success('操作成功')
// 2.
getDetail()
} finally {
formLoading.value = false
}
}
formLoading.value = true
try {
const deletegateFormRef = proxy.$refs['formRef']
// 1.1
const elForm = unref(deletegateFormRef)
if (!elForm) return
const valid = await elForm.validate()
if (!valid) return
// 1.2
const data = {
id: runningTask.value.id,
reason: genericForm.value.reason,
delegateUserId: genericForm.value.delegateUserId
}
await TaskApi.delegateTask(data)
popOverVisible.value.delegate = false
message.success('操作成功')
// 2.
reload()
} finally {
formLoading.value = false
}
}
/** 处理加签 */
const handlerAddSign = async (type: string) => {
@ -585,7 +616,7 @@ const handlerAddSign = async (type: string) => {
message.success('操作成功')
popOverVisible.value.addSign = false
// 2
getDetail()
reload()
} finally {
formLoading.value = false
}
@ -607,43 +638,41 @@ const handleReturn = async () => {
reason: genericForm.value.returnReason,
targetTaskDefinitionKey: genericForm.value.targetTaskDefinitionKey
}
await TaskApi.returnTask(data)
popOverVisible.value.return = false
message.success('操作成功')
// 2
getDetail()
// 2
reload()
} finally {
formLoading.value = false
}
}
/** 弹出退回气泡卡 */
const openReturnPopover = async () => {
returnList.value = await TaskApi.getTaskListByReturn(runningTask.value.id)
if (returnList.value.length === 0) {
message.warning('当前没有可退回的节点')
return
}
openPopover('return')
}
/** 弹出气泡卡 */
const openPopover = (type: string ) => {
Object.keys(popOverVisible.value).forEach( item => {
if( item === type) {
popOverVisible.value[item] = true
} else {
popOverVisible.value[item] = false
}
})
formRef.value.resetFields()
/** 子任务 */
const taskSignListRef = ref()
const openChildrenTask = () => {
taskSignListRef.value.open(runningTask.value)
}
/** 获得详情 */
const getDetail = () => {
/** 重新加载数据 */
const reload = () => {
getMyTodoTask()
emit('success')
}
/** 任务是否为处理中状态 */
const isHandleTaskStatus = () => {
let canHandle = false
if (
TaskApi.TaskStatusEnum.RUNNING === runningTask.value.status ||
TaskApi.TaskStatusEnum.DELEGATE === runningTask.value.status
) {
canHandle = true
}
return canHandle
}
/** 是否显示按钮 */
const isShowButton = (btnType: OperationButtonType): boolean => {
let isShow = true
@ -662,7 +691,26 @@ const getButtonDisplayName = (btnType: OperationButtonType) => {
return displayName
}
defineExpose({ loadRunningTask })
/** 获取我的待办任务 */
const getMyTodoTask = async () => {
genericForm.value = {}
approveForm.value = {}
approveFormFApi.value = {}
const data = await TaskApi.myTodoTask(props.processInstanceId)
runningTask.value = data
// approve .
if (data && data.formId && data.formConf) {
const tempApproveForm = {}
setConfAndFields2(tempApproveForm, data.formConf, data.formFields, data.formVariables)
approveForm.value = tempApproveForm
} else {
approveForm.value = {} //
}
}
onMounted(async () => {
await getMyTodoTask()
})
</script>
<style lang="scss" scoped>

View File

@ -2,7 +2,7 @@
<el-drawer v-model="drawerVisible" title="子任务" size="880px">
<!-- 当前任务 -->
<template #header>
<h4>{{ parentTask.name }} 审批人{{ parentTask?.assigneeUser?.nickname }}</h4>
<h4>{{ parentTask.name }} 审批人{{ parentTask?.ownerUser?.nickname }}</h4>
<el-button
style="margin-left: 5px"
v-if="isSignDeleteButtonVisible(parentTask)"

View File

@ -37,7 +37,7 @@
<div class="text-#878c93"> {{ formatDate(processInstance.startTime) }} 提交 </div>
</div>
<el-tabs v-model="activeTab" @tab-change="onTabChange">
<el-tabs v-model="activeTab">
<!-- 表单信息 -->
<el-tab-pane label="审批详情" name="form">
<div class="form-scroll-area">
@ -104,8 +104,7 @@
<div class="b-t-solid border-t-1px border-[var(--el-border-color)]">
<!-- 操作栏按钮 -->
<ProcessInstanceOperationButton
ref="operationButtonRef"
:processInstance="processInstance"
:process-instance-id="id"
:userOptions="userOptions"
@success="refresh"
/>
@ -119,7 +118,6 @@ import { formatDate } from '@/utils/formatTime'
import { DICT_TYPE } from '@/utils/dict'
import { setConfAndFields2 } from '@/utils/formCreate'
import type { ApiAttrs } from '@form-create/element-ui/types/config'
import * as DefinitionApi from '@/api/bpm/definition'
import * as ProcessInstanceApi from '@/api/bpm/processInstance'
import * as TaskApi from '@/api/bpm/task'
import ProcessInstanceBpmnViewer from './ProcessInstanceBpmnViewer.vue'
@ -132,6 +130,7 @@ import { FieldPermissionType } from '@/components/SimpleProcessDesignerV2/src/co
import audit1 from '@/assets/svgs/bpm/audit1.svg'
import audit2 from '@/assets/svgs/bpm/audit2.svg'
import audit3 from '@/assets/svgs/bpm/audit3.svg'
import audit4 from '@/assets/svgs/bpm/audit4.svg'
defineOptions({ name: 'BpmProcessInstanceDetail' })
const props = defineProps<{
@ -142,16 +141,14 @@ const props = defineProps<{
const message = useMessage() //
const processInstanceLoading = ref(false) //
const processInstance = ref<any>({}) //
let processDefinitionId = undefined // Id
const operationButtonRef = ref()
const timelineRef = ref()
const bpmnXml = ref('') // BPMN XML
const tasksLoad = ref(true) //
const tasks = ref<any[]>([]) //
const auditIcons = {
1: audit1,
2: audit2,
3: audit3
3: audit3,
4: audit4
}
// ========== ==========
@ -220,9 +217,6 @@ const getProcessInstance = async () => {
// data.processDefinition.formCustomViewPath /crm/contract/detail/index.vue
BusinessFormComponent.value = registerComponent(data.processDefinition.formCustomViewPath)
}
processDefinitionId = processDefinition.id
//
// bpmnXml.value = (await DefinitionApi.getProcessDefinition(processDefinition.id))?.bpmnXml
} finally {
processInstanceLoading.value = false
}
@ -272,7 +266,7 @@ const getTaskList = async () => {
})
//
operationButtonRef.value?.loadRunningTask(tasks.value)
//operationButtonRef.value?.loadRunningTask(tasks.value)
} finally {
tasksLoad.value = false
}
@ -291,13 +285,6 @@ const refresh = () => {
/** 当前的Tab */
const activeTab = ref('form')
/** Tab 切换 加载流程图,直接加载显示不出来,不知道啥原因,所以切换以后在加载 */
const onTabChange = async (tabName: string) => {
if (tabName === 'diagram' && processDefinitionId && !bpmnXml.value) {
//
bpmnXml.value = (await DefinitionApi.getProcessDefinition(processDefinitionId))?.bpmnXml
}
}
/** 初始化 */
const userOptions = ref<UserApi.UserVO[]>([]) //
onMounted(async () => {