add 添加流程干预

This commit is contained in:
gssong 2024-12-08 15:02:33 +08:00
parent 3257db38a0
commit a9cd07785d
8 changed files with 299 additions and 176 deletions

View File

@ -38,53 +38,6 @@ export const getFlowImage = (businessKey: string | number) => {
});
};
/**
* id获取历史流程图运行中
*/
export const getHistoryList = (businessKey: string): AxiosPromise<Record<string, any>> => {
return request({
url: `/workflow/processInstance/getHistoryList/${businessKey}` + '?t' + Math.random(),
method: 'get'
});
};
/**
*
* @param data
* @returns
*/
export const deleteRunInstance = (data: object) => {
return request({
url: `/workflow/processInstance/deleteRunInstance`,
method: 'post',
data: data
});
};
/**
*
* @param businessKey id
* @returns
*/
export const deleteRunAndHisInstance = (businessKey: string | string[]) => {
return request({
url: `/workflow/processInstance/deleteRunAndHisInstance/${businessKey}`,
method: 'delete'
});
};
/**
*
* @param businessKey id
* @returns
*/
export const deleteFinishAndHisInstance = (businessKey: string | string[]) => {
return request({
url: `/workflow/processInstance/deleteFinishAndHisInstance/${businessKey}`,
method: 'delete'
});
};
/**
*
* @param query
@ -122,14 +75,23 @@ export const getInstanceVariable = (instanceId: string) => {
method: 'get'
});
};
/**
*
* @param instanceIds id
* @returns
*/
export const deleteByInstanceIds = (instanceIds: Array<string | number> | string | number) => {
return request({
url: `/workflow/processInstance/deleteByInstanceIds/${instanceIds}`,
method: 'delete'
});
};
export default {
getPageByRunning,
getPageByFinish,
getFlowImage,
getHistoryList,
deleteRunInstance,
deleteRunAndHisInstance,
deleteFinishAndHisInstance,
getPageByCurrent,
cancelProcessApply
};

View File

@ -1,14 +1,15 @@
import { FlowTaskVO } from '@/api/workflow/task/types';
export interface ProcessInstanceQuery extends PageQuery {
export interface FlowInstanceQuery extends PageQuery {
categoryCode?: string;
flowCode?: string;
flowName?: string;
createBy?: string;
businessId?: string;
}
export interface ProcessInstanceVO extends BaseEntity {
id: string;
export interface FlowInstanceVO extends BaseEntity {
id: string | number;
definitionId: string;
flowName: string;
flowCode: string;

View File

@ -93,30 +93,6 @@ export const completeTask = (data: object) => {
});
};
/**
*
* @param taskId
* @returns {*}
*/
export const claim = (taskId: string): any => {
return request({
url: '/workflow/task/claim/' + taskId,
method: 'post'
});
};
/**
*
* @param taskId
* @returns {*}
*/
export const returnTask = (taskId: string): any => {
return request({
url: '/workflow/task/returnTask/' + taskId,
method: 'post'
});
};
/**
*
* @param data
@ -142,32 +118,6 @@ export const getTaskById = (taskId: string) => {
});
};
/**
*
* @param data
* @returns
*/
export const addMultiInstanceExecution = (data: any) => {
return request({
url: '/workflow/task/addMultiInstanceExecution',
method: 'post',
data: data
});
};
/**
*
* @param data
* @returns
*/
export const deleteMultiInstanceExecution = (data: any) => {
return request({
url: '/workflow/task/deleteMultiInstanceExecution',
method: 'post',
data: data
});
};
/**
*
* @param taskIds
@ -182,18 +132,6 @@ export const updateAssignee = (taskIdList: Array<string>, userId: string) => {
});
};
/**
*
* @returns
*/
export const transferTask = (data: any) => {
return request({
url: `/workflow/task/transferTask`,
method: 'post',
data: data
});
};
/**
*
* @returns
@ -281,7 +219,7 @@ export const taskOperation = (data: TaskOperationBo, operation: string) => {
* @param taskId id
* @returns
*/
export const getUserListTaskId = (taskId: string) => {
export const getUserListTaskId = (taskId: string | number) => {
return request({
url: `/workflow/task/getUserListTaskId/${taskId}`,
method: 'get'

View File

@ -27,6 +27,7 @@ export interface FlowTaskVO {
flowStatus: string;
nodeType: number;
nodeRatio: string | number;
version?: string;
wfNodeConfigVo?: NodeConfigVO;
wfDefinitionConfigVo?: DefinitionConfigVO;
}
@ -42,7 +43,7 @@ export interface TaskOperationBo {
//加签/减签人的用户ID列表必填针对加签/减签操作)
userIds?: string[];
//任务ID必填
taskId: string;
taskId: string | number;
//意见或备注信息(可选)
message?: string;
}

View File

@ -23,7 +23,14 @@
<el-table-column prop="message" label="审批意见" :show-overflow-tooltip="true" sortable align="center"></el-table-column>
<el-table-column prop="createTime" label="开始时间" width="160" :show-overflow-tooltip="true" sortable align="center"></el-table-column>
<el-table-column prop="updateTime" label="结束时间" width="160" :show-overflow-tooltip="true" sortable align="center"></el-table-column>
<el-table-column prop="runDuration" label="运行时常" width="120" sortable align="center"></el-table-column>
<el-table-column
prop="runDuration"
label="运行时常"
width="140"
:show-overflow-tooltip="true"
sortable
align="center"
></el-table-column>
<el-table-column prop="attachmentList" width="100" label="附件" sortable align="center">
<template #default="scope">
<el-popover v-if="scope.row.attachmentList && scope.row.attachmentList.length > 0" placement="right" :width="310" trigger="click">

View File

@ -0,0 +1,237 @@
<template>
<el-dialog v-model="visible" draggable title="流程干预" :width="props.width" :height="props.height" :close-on-click-modal="false">
<el-descriptions v-loading="loading" class="margin-top" :title="`${task.flowName}(${task.flowCode})`" :column="2" border>
<el-descriptions-item label="任务名称">{{ task.nodeName }}</el-descriptions-item>
<el-descriptions-item label="节点编码">{{ task.nodeCode }}</el-descriptions-item>
<el-descriptions-item label="开始时间">{{ task.createTime }}</el-descriptions-item>
<el-descriptions-item label="流程实例ID">{{ task.instanceId }}</el-descriptions-item>
<el-descriptions-item label="版本号">{{ task.version }}.0</el-descriptions-item>
<el-descriptions-item label="业务ID">{{ task.businessId }}</el-descriptions-item>
</el-descriptions>
<template #footer>
<span class="dialog-footer">
<el-button v-if="task.flowStatus === 'waiting'" :disabled="buttonDisabled" type="primary" @click="openDelegateTask"> 委托 </el-button>
<el-button v-if="task.flowStatus === 'waiting'" :disabled="buttonDisabled" type="primary" @click="openTransferTask"> 转办 </el-button>
<el-button
v-if="task.flowStatus === 'waiting' && Number(task.nodeRatio) > 0"
:disabled="buttonDisabled"
type="primary"
@click="openMultiInstanceUser"
>
加签
</el-button>
<el-button
v-if="task.flowStatus === 'waiting' && Number(task.nodeRatio) > 0"
:disabled="buttonDisabled"
type="primary"
@click="handleTaskUser"
>
减签
</el-button>
<el-button v-if="task.flowStatus === 'waiting'" :disabled="buttonDisabled" type="danger" @click="handleTerminationTask"> 终止 </el-button>
</span>
</template>
<!-- 转办 -->
<UserSelect ref="transferTaskRef" :multiple="false" @confirm-call-back="handleTransferTask"></UserSelect>
<!-- 委托 -->
<UserSelect ref="delegateTaskRef" :multiple="false" @confirm-call-back="handleDelegateTask"></UserSelect>
<!-- 加签组件 -->
<UserSelect ref="multiInstanceUserRef" :multiple="true" @confirm-call-back="addMultiInstanceUser"></UserSelect>
<el-dialog v-model="deleteSignatureVisible" draggable title="减签人员" width="700px" height="400px" append-to-body :close-on-click-modal="false"
><div>
<el-table :data="deleteUserList" border>
<el-table-column prop="nodeName" label="任务名称" />
<el-table-column prop="nickName" label="办理人" />
<el-table-column label="操作" align="center" width="160">
<template #default="scope">
<el-button type="danger" size="small" icon="Delete" @click="deleteMultiInstanceUser(scope.row)">删除</el-button>
</template>
</el-table-column>
</el-table>
</div>
</el-dialog>
</el-dialog>
</template>
<script lang="ts" setup>
import { propTypes } from '@/utils/propTypes';
import { FlowTaskVO, TaskOperationBo } from '@/api/workflow/task/types';
import UserSelect from '@/components/UserSelect';
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
import { getTaskById, taskOperation, getUserListTaskId, terminationTask } from '@/api/workflow/task';
const props = defineProps({
width: propTypes.string.def('50%'),
height: propTypes.string.def('100%')
});
const emits = defineEmits(['submitCallback']);
const transferTaskRef = ref<InstanceType<typeof UserSelect>>();
const delegateTaskRef = ref<InstanceType<typeof UserSelect>>();
const multiInstanceUserRef = ref<InstanceType<typeof UserSelect>>();
//
const loading = ref(true);
//
const buttonDisabled = ref(true);
const visible = ref(false);
//
const deleteSignatureVisible = ref(false);
//
const deleteUserList = ref<any>([]);
//
const task = ref<FlowTaskVO>({
id: undefined,
createTime: undefined,
updateTime: undefined,
tenantId: undefined,
definitionId: undefined,
instanceId: undefined,
flowName: undefined,
businessId: undefined,
nodeCode: undefined,
nodeName: undefined,
flowCode: undefined,
flowStatus: undefined,
nodeType: undefined,
nodeRatio: undefined,
version: undefined
});
const open = (taskId: string) => {
visible.value = true;
getTaskById(taskId).then((response) => {
loading.value = false;
buttonDisabled.value = false;
task.value = response.data;
});
};
//
const openDelegateTask = () => {
delegateTaskRef.value.open();
};
//
const handleDelegateTask = async (data) => {
if (data && data.length > 0) {
const taskOperationBo = reactive<TaskOperationBo>({
userId: data[0].userId,
taskId: task.value.id,
message: ''
});
await proxy?.$modal.confirm('是否确认提交?');
loading.value = true;
buttonDisabled.value = true;
await taskOperation(taskOperationBo, 'delegateTask').finally(() => {
loading.value = false;
buttonDisabled.value = false;
});
visible.value = false;
emits('submitCallback');
proxy?.$modal.msgSuccess('操作成功');
} else {
proxy?.$modal.msgWarning('请选择用户!');
}
};
//
const openTransferTask = () => {
transferTaskRef.value.open();
};
//
const handleTransferTask = async (data) => {
if (data && data.length > 0) {
const taskOperationBo = reactive<TaskOperationBo>({
userId: data[0].userId,
taskId: task.value.id,
message: ''
});
await proxy?.$modal.confirm('是否确认提交?');
loading.value = true;
buttonDisabled.value = true;
await taskOperation(taskOperationBo, 'transferTask').finally(() => {
loading.value = false;
buttonDisabled.value = false;
});
visible.value = false;
emits('submitCallback');
proxy?.$modal.msgSuccess('操作成功');
} else {
proxy?.$modal.msgWarning('请选择用户!');
}
};
//
const openMultiInstanceUser = async () => {
multiInstanceUserRef.value.open();
};
//
const addMultiInstanceUser = async (data) => {
if (data && data.length > 0) {
const taskOperationBo = reactive<TaskOperationBo>({
userIds: data.map((e) => e.userId),
taskId: task.value.id,
message: ''
});
await proxy?.$modal.confirm('是否确认提交?');
loading.value = true;
buttonDisabled.value = true;
await taskOperation(taskOperationBo, 'addSignature').finally(() => {
loading.value = false;
buttonDisabled.value = false;
});
visible.value = false;
emits('submitCallback');
proxy?.$modal.msgSuccess('操作成功');
} else {
proxy?.$modal.msgWarning('请选择用户!');
}
};
//
const deleteMultiInstanceUser = async (row) => {
await proxy?.$modal.confirm('是否确认提交?');
loading.value = true;
buttonDisabled.value = true;
const taskOperationBo = reactive<TaskOperationBo>({
userIds: [row.userId],
taskId: task.value.id,
message: ''
});
await taskOperation(taskOperationBo, 'reductionSignature').finally(() => {
loading.value = false;
buttonDisabled.value = false;
});
visible.value = false;
emits('submitCallback');
proxy?.$modal.msgSuccess('操作成功');
};
//
const handleTaskUser = async () => {
let data = await getUserListTaskId(task.value.id);
deleteUserList.value = data.data;
if (deleteUserList.value && deleteUserList.value.length > 0) {
deleteUserList.value.forEach((e) => {
e.nodeName = task.value.nodeName;
});
}
deleteSignatureVisible.value = true;
};
//
const handleTerminationTask = async () => {
let params = {
taskId: task.value.id,
comment: ''
};
await proxy?.$modal.confirm('是否确认终止?');
loading.value = true;
buttonDisabled.value = true;
await terminationTask(params).finally(() => {
loading.value = false;
buttonDisabled.value = false;
});
visible.value = false;
emits('submitCallback');
proxy?.$modal.msgSuccess('操作成功');
};
/**
* 对外暴露子组件方法
*/
defineExpose({
open
});
</script>

View File

@ -33,10 +33,10 @@
<el-card shadow="hover">
<el-form v-show="showSearch" ref="queryFormRef" :model="queryParams" :inline="true" label-width="120px">
<el-form-item label="流程定义名称" prop="name">
<el-input v-model="queryParams.name" placeholder="请输入流程定义名称" @keyup.enter="handleQuery" />
<el-input v-model="queryParams.flowName" placeholder="请输入流程定义名称" @keyup.enter="handleQuery" />
</el-form-item>
<el-form-item label="流程定义KEY" prop="key">
<el-input v-model="queryParams.key" placeholder="请输入流程定义KEY" @keyup.enter="handleQuery" />
<el-input v-model="queryParams.flowCode" placeholder="请输入流程定义KEY" @keyup.enter="handleQuery" />
</el-form-item>
<el-form-item>
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
@ -158,17 +158,10 @@
</template>
<script lang="ts" setup>
import {
getPageByRunning,
getPageByFinish,
deleteRunAndHisInstance,
deleteFinishAndHisInstance,
deleteRunInstance,
getInstanceVariable
} from '@/api/workflow/processInstance';
import { getPageByRunning, getPageByFinish, deleteByInstanceIds, getInstanceVariable } from '@/api/workflow/processInstance';
import { listCategory } from '@/api/workflow/category';
import { CategoryVO } from '@/api/workflow/category/types';
import { ProcessInstanceQuery, ProcessInstanceVO } from '@/api/workflow/processInstance/types';
import { FlowInstanceQuery, FlowInstanceVO } from '@/api/workflow/processInstance/types';
import workflowCommon from '@/api/workflow/workflowCommon';
import { RouterJumpVo } from '@/api/workflow/workflowCommon/types';
import VueJsonPretty from 'vue-json-pretty';
@ -183,8 +176,8 @@ const categoryTreeRef = ref<ElTreeInstance>();
const loading = ref(true);
//
const ids = ref<Array<any>>([]);
// id
const businessKeys = ref<Array<any>>([]);
// id
const instanceIds = ref<Array<number | string>>([]);
//
const single = ref(true);
//
@ -197,11 +190,11 @@ const total = ref(0);
//
const variableVisible = ref(false);
const variableLoading = ref(true);
const variables = ref<string>('')
const variables = ref<string>('');
//
const processDefinitionName = ref();
//
const processInstanceList = ref<ProcessInstanceVO[]>([]);
const processInstanceList = ref<FlowInstanceVO[]>([]);
const processDefinitionHistoryList = ref<Array<any>>([]);
const categoryOptions = ref<CategoryOption[]>([]);
const categoryName = ref('');
@ -221,10 +214,11 @@ const tab = ref('running');
//
const deleteReason = ref('');
//
const queryParams = ref<ProcessInstanceQuery>({
const queryParams = ref<FlowInstanceQuery>({
pageNum: 1,
pageSize: 10,
flowCode: undefined,
flowName: undefined,
categoryCode: undefined
});
@ -277,9 +271,9 @@ const resetQuery = () => {
handleQuery();
};
//
const handleSelectionChange = (selection: ProcessInstanceVO[]) => {
const handleSelectionChange = (selection: FlowInstanceVO[]) => {
ids.value = selection.map((item: any) => item.id);
businessKeys.value = selection.map((item: any) => item.businessKey);
instanceIds.value = selection.map((item: FlowInstanceVO) => item.id);
single.value = selection.length !== 1;
multiple.value = !selection.length;
};
@ -303,15 +297,15 @@ const getProcessInstanceFinishList = () => {
};
/** 删除按钮操作 */
const handleDelete = async (row: any) => {
const businessKey = row.businessKey || businessKeys.value;
await proxy?.$modal.confirm('是否确认删除业务id为【' + businessKey + '】的数据项');
const handleDelete = async (row: FlowInstanceVO) => {
const instanceIdList = row.id || instanceIds.value;
await proxy?.$modal.confirm('是否确认删除');
loading.value = true;
if ('running' === tab.value) {
await deleteRunAndHisInstance(businessKey).finally(() => (loading.value = false));
await deleteByInstanceIds(instanceIdList).finally(() => (loading.value = false));
getProcessInstanceRunningList();
} else {
await deleteFinishAndHisInstance(businessKey).finally(() => (loading.value = false));
await deleteByInstanceIds(instanceIdList).finally(() => (loading.value = false));
getProcessInstanceFinishList();
}
proxy?.$modal.msgSuccess('删除成功');
@ -326,7 +320,7 @@ const changeTab = async (data: string) => {
}
};
/** 作废按钮操作 */
const handleInvalid = async (row: ProcessInstanceVO) => {
const handleInvalid = async (row: FlowInstanceVO) => {
await proxy?.$modal.confirm('是否确认作废业务id为【' + row.businessId + '】的数据项?');
loading.value = true;
if ('running' === tab.value) {
@ -334,7 +328,7 @@ const handleInvalid = async (row: ProcessInstanceVO) => {
businessKey: row.businessId,
deleteReason: deleteReason.value
};
await deleteRunInstance(param).finally(() => (loading.value = false));
//await deleteRunInstance(param).finally(() => (loading.value = false));
getProcessInstanceRunningList();
proxy?.$modal.msgSuccess('操作成功');
}
@ -355,7 +349,7 @@ const handleView = (row) => {
};
//
const handleInstanceVariable = async (row: ProcessInstanceVO) => {
const handleInstanceVariable = async (row: FlowInstanceVO) => {
variableLoading.value = true;
variableVisible.value = true;
processDefinitionName.value = row.flowName;
@ -368,7 +362,7 @@ const handleInstanceVariable = async (row: ProcessInstanceVO) => {
* json转为对象
* @param data 原始数据
*/
function formatToJsonObject(data: string) {
function formatToJsonObject(data: string) {
try {
return JSON.parse(data);
} catch (error) {

View File

@ -76,19 +76,14 @@
</template>
</el-table-column>
<el-table-column align="center" prop="createTime" label="创建时间" width="160"></el-table-column>
<el-table-column label="操作" align="center" :width="tab === 'finish' ? '80' : '151'">
<el-table-column label="操作" align="center" :width="tab === 'finish' ? '88' : '188'">
<template #default="scope">
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-col :span="1.5" v-if="tab === 'waiting' || tab === 'finish'">
<el-button type="primary" size="small" icon="View" @click="handleView(scope.row)">查看</el-button>
</el-col>
</el-row>
<el-row v-if="scope.row.multiInstance" :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" size="small" icon="Remove" @click="deleteMultiInstanceUser(scope.row)">减签</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="primary" size="small" icon="CirclePlus" @click="addMultiInstanceUser(scope.row)">加签</el-button>
<el-col :span="1.5" v-if="tab === 'waiting'">
<el-button type="primary" size="small" icon="Setting" @click="handleMeddle(scope.row)">流程干预</el-button>
</el-col>
</el-row>
</template>
@ -102,25 +97,24 @@
@pagination="handleQuery"
/>
</el-card>
<!-- 加签组件 -->
<multiInstanceUser ref="multiInstanceUserRef" :title="title" @submit-callback="handleQuery" />
<!-- 选人组件 -->
<UserSelect ref="userSelectRef" :multiple="false" @confirm-call-back="submitCallback"></UserSelect>
<!-- 选人组件 -->
<processMeddle ref="processMeddleRef" @submitCallback="getWaitingList"></processMeddle>
</div>
</template>
<script lang="ts" setup>
import { getPageByAllTaskWait, getPageByAllTaskFinish, updateAssignee } from '@/api/workflow/task';
import MultiInstanceUser from '@/components/Process/multiInstanceUser.vue';
import UserSelect from '@/components/UserSelect';
import { TaskQuery, FlowTaskVO, VariableVo } from '@/api/workflow/task/types';
import { TaskQuery } from '@/api/workflow/task/types';
import workflowCommon from '@/api/workflow/workflowCommon';
import { RouterJumpVo } from '@/api/workflow/workflowCommon/types';
//
//
const multiInstanceUserRef = ref<InstanceType<typeof MultiInstanceUser>>();
import processMeddle from '@/components/Process/processMeddle';
//
const userSelectRef = ref<InstanceType<typeof UserSelect>>();
//
const processMeddleRef = ref<InstanceType<typeof processMeddle>>();
const queryFormRef = ref<ElFormInstance>();
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
@ -151,20 +145,6 @@ const queryParams = ref<TaskQuery>({
});
const tab = ref('waiting');
//
const addMultiInstanceUser = (row: FlowTaskVO) => {
if (multiInstanceUserRef.value) {
title.value = '加签人员';
multiInstanceUserRef.value.getAddMultiInstanceList(row.id, []);
}
};
//
const deleteMultiInstanceUser = (row: FlowTaskVO) => {
if (multiInstanceUserRef.value) {
title.value = '减签人员';
multiInstanceUserRef.value.getDeleteMultiInstanceList(row.id);
}
};
/** 搜索按钮操作 */
const handleQuery = () => {
if ('waiting' === tab.value) {
@ -239,6 +219,9 @@ const handleView = (row) => {
});
workflowCommon.routerJump(routerJumpVo, proxy);
};
const handleMeddle = (row) => {
processMeddleRef.value.open(row.id);
};
onMounted(() => {
getWaitingList();
});