add -- 新增流程审核可选择抄送流程功能

This commit is contained in:
konbai
2022-05-29 18:10:18 +08:00
parent ab1c50ca06
commit 64eb962366
13 changed files with 863 additions and 102 deletions

View File

@@ -5,8 +5,11 @@ import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.workflow.domain.bo.WfCopyBo;
import com.ruoyi.workflow.domain.vo.WfCopyVo;
import com.ruoyi.workflow.domain.vo.WfDefinitionVo;
import com.ruoyi.workflow.domain.vo.WfTaskVo;
import com.ruoyi.workflow.service.IWfCopyService;
import com.ruoyi.workflow.service.IWfProcessService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@@ -31,6 +34,7 @@ import java.util.Map;
public class WfProcessController extends BaseController {
private final IWfProcessService processService;
private final IWfCopyService copyService;
@GetMapping(value = "/list")
@SaCheckPermission("workflow:process:startList")
@@ -69,4 +73,12 @@ public class WfProcessController extends BaseController {
public TableDataInfo<WfTaskVo> finishedProcess(PageQuery pageQuery) {
return processService.queryPageFinishedProcessList(pageQuery);
}
@ApiOperation(value = "获取抄送列表", response = WfTaskVo.class)
@SaCheckPermission("workflow:process:copyList")
@GetMapping(value = "/copyList")
public TableDataInfo<WfCopyVo> copyProcess(WfCopyBo copyBo, PageQuery pageQuery) {
copyBo.setUserId(getUserId());
return copyService.queryPageList(copyBo, pageQuery);
}
}

View File

@@ -0,0 +1,74 @@
package com.ruoyi.workflow.domain;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.ruoyi.common.core.domain.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 流程抄送对象 wf_copy
*
* @author KonBAI
* @date 2022-05-19
*/
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("wf_copy")
public class WfCopy extends BaseEntity {
private static final long serialVersionUID=1L;
/**
* 抄送主键
*/
@TableId(value = "copy_id")
private Long copyId;
/**
* 抄送标题
*/
private String title;
/**
* 流程主键
*/
private String processId;
/**
* 流程名称
*/
private String processName;
/**
* 流程分类主键
*/
private String categoryId;
/**
* 部署主键
*/
private String deploymentId;
/**
* 流程实例主键
*/
private String instanceId;
/**
* 任务主键
*/
private String taskId;
/**
* 用户主键
*/
private Long userId;
/**
* 发起人Id
*/
private Long originatorId;
/**
* 发起人名称
*/
private String originatorName;
/**
* 删除标志0代表存在 2代表删除
*/
@TableLogic
private String delFlag;
}

View File

@@ -0,0 +1,87 @@
package com.ruoyi.workflow.domain.bo;
import com.ruoyi.common.core.domain.BaseEntity;
import com.ruoyi.common.core.validate.AddGroup;
import com.ruoyi.common.core.validate.EditGroup;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
/**
* 流程抄送业务对象 wf_copy
*
* @author ruoyi
* @date 2022-05-19
*/
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel("流程抄送业务对象")
public class WfCopyBo extends BaseEntity {
/**
* 抄送主键
*/
@ApiModelProperty(value = "抄送主键", required = true)
@NotNull(message = "抄送主键不能为空", groups = { EditGroup.class })
private Long copyId;
/**
* 抄送标题
*/
@ApiModelProperty(value = "抄送标题", required = true)
@NotNull(message = "抄送标题不能为空", groups = { AddGroup.class, EditGroup.class })
private String title;
/**
* 流程主键
*/
@ApiModelProperty(value = "流程主键", required = true)
@NotBlank(message = "流程主键不能为空", groups = { AddGroup.class, EditGroup.class })
private String processId;
/**
* 流程名称
*/
@ApiModelProperty(value = "流程名称", required = true)
@NotBlank(message = "流程名称不能为空", groups = { AddGroup.class, EditGroup.class })
private String processName;
/**
* 流程分类主键
*/
@ApiModelProperty(value = "流程分类主键", required = true)
@NotBlank(message = "流程分类主键不能为空", groups = { AddGroup.class, EditGroup.class })
private String categoryId;
/**
* 任务主键
*/
@ApiModelProperty(value = "任务主键", required = true)
@NotBlank(message = "任务主键不能为空", groups = { AddGroup.class, EditGroup.class })
private String taskId;
/**
* 用户主键
*/
@ApiModelProperty(value = "用户主键", required = true)
@NotNull(message = "用户主键不能为空", groups = { AddGroup.class, EditGroup.class })
private Long userId;
/**
* 发起人Id
*/
@ApiModelProperty(value = "发起人主键", required = true)
@NotNull(message = "发起人主键不能为空", groups = { AddGroup.class, EditGroup.class })
private Long originatorId;
/**
* 发起人名称
*/
@ApiModelProperty(value = "发起人名称", required = true)
@NotNull(message = "发起人名称不能为空", groups = { AddGroup.class, EditGroup.class })
private String originatorName;
}

View File

@@ -20,6 +20,9 @@ public class WfTaskBo {
@ApiModelProperty("任务Id")
private String taskId;
@ApiModelProperty("任务名称")
private String taskName;
@ApiModelProperty("用户Id")
private String userId;
@@ -43,4 +46,7 @@ public class WfTaskBo {
@ApiModelProperty("审批组")
private List<String> candidateGroups;
@ApiModelProperty("抄送用户Id")
private String copyUserIds;
}

View File

@@ -0,0 +1,108 @@
package com.ruoyi.workflow.domain.vo;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* 流程抄送视图对象 wf_copy
*
* @author ruoyi
* @date 2022-05-19
*/
@Data
@ApiModel("流程抄送视图对象")
@ExcelIgnoreUnannotated
public class WfCopyVo {
private static final long serialVersionUID = 1L;
/**
* 抄送主键
*/
@ExcelProperty(value = "抄送主键")
@ApiModelProperty("抄送主键")
private Long copyId;
/**
* 抄送标题
*/
@ExcelProperty(value = "抄送标题")
@ApiModelProperty("抄送标题")
private String title;
/**
* 流程主键
*/
@ExcelProperty(value = "流程主键")
@ApiModelProperty("流程主键")
private String processId;
/**
* 流程名称
*/
@ExcelProperty(value = "流程名称")
@ApiModelProperty("流程名称")
private String processName;
/**
* 流程分类主键
*/
@ExcelProperty(value = "流程分类主键")
@ApiModelProperty("流程分类主键")
private String categoryId;
/**
* 部署主键
*/
@ExcelProperty(value = "部署主键")
@ApiModelProperty("部署主键")
private String deploymentId;
/**
* 流程实例主键
*/
@ExcelProperty(value = "流程实例主键")
@ApiModelProperty("流程实例主键")
private String instanceId;
/**
* 任务主键
*/
@ExcelProperty(value = "任务主键")
@ApiModelProperty("任务主键")
private String taskId;
/**
* 用户主键
*/
@ExcelProperty(value = "用户主键")
@ApiModelProperty("用户主键")
private Long userId;
/**
* 发起人Id
*/
@ExcelProperty(value = "发起人主键")
@ApiModelProperty("发起人主键")
private Long originatorId;
/**
* 发起人名称
*/
@ExcelProperty(value = "发起人名称")
@ApiModelProperty("发起人名称")
private String originatorName;
/**
* 抄送时间(创建时间)
*/
@ExcelProperty(value = "抄送时间")
@ApiModelProperty("抄送时间")
private Date createTime;
}

View File

@@ -0,0 +1,15 @@
package com.ruoyi.workflow.mapper;
import com.ruoyi.common.core.mapper.BaseMapperPlus;
import com.ruoyi.workflow.domain.WfCopy;
import com.ruoyi.workflow.domain.vo.WfCopyVo;
/**
* 流程抄送Mapper接口
*
* @author KonBAI
* @date 2022-05-19
*/
public interface WfCopyMapper extends BaseMapperPlus<WfCopyMapper, WfCopy, WfCopyVo> {
}

View File

@@ -0,0 +1,49 @@
package com.ruoyi.workflow.service;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.workflow.domain.bo.WfCopyBo;
import com.ruoyi.workflow.domain.bo.WfTaskBo;
import com.ruoyi.workflow.domain.vo.WfCopyVo;
import java.util.List;
/**
* 流程抄送Service接口
*
* @author KonBAI
* @date 2022-05-19
*/
public interface IWfCopyService {
/**
* 查询流程抄送
*
* @param copyId 流程抄送主键
* @return 流程抄送
*/
WfCopyVo queryById(Long copyId);
/**
* 查询流程抄送列表
*
* @param wfCopy 流程抄送
* @return 流程抄送集合
*/
TableDataInfo<WfCopyVo> queryPageList(WfCopyBo wfCopy, PageQuery pageQuery);
/**
* 查询流程抄送列表
*
* @param wfCopy 流程抄送
* @return 流程抄送集合
*/
List<WfCopyVo> queryList(WfCopyBo wfCopy);
/**
* 抄送
* @param taskBo
* @return
*/
Boolean makeCopy(WfTaskBo taskBo);
}

View File

@@ -0,0 +1,113 @@
package com.ruoyi.workflow.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.helper.LoginHelper;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.workflow.domain.WfCopy;
import com.ruoyi.workflow.domain.bo.WfCopyBo;
import com.ruoyi.workflow.domain.bo.WfTaskBo;
import com.ruoyi.workflow.domain.vo.WfCopyVo;
import com.ruoyi.workflow.mapper.WfCopyMapper;
import com.ruoyi.workflow.service.IWfCopyService;
import lombok.RequiredArgsConstructor;
import org.flowable.engine.RuntimeService;
import org.flowable.engine.runtime.ProcessInstance;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* 流程抄送Service业务层处理
*
* @author KonBAI
* @date 2022-05-19
*/
@RequiredArgsConstructor
@Service
public class WfCopyServiceImpl implements IWfCopyService {
private final WfCopyMapper baseMapper;
private final RuntimeService runtimeService;
/**
* 查询流程抄送
*
* @param copyId 流程抄送主键
* @return 流程抄送
*/
@Override
public WfCopyVo queryById(Long copyId){
return baseMapper.selectVoById(copyId);
}
/**
* 查询流程抄送列表
*
* @param bo 流程抄送
* @return 流程抄送
*/
@Override
public TableDataInfo<WfCopyVo> queryPageList(WfCopyBo bo, PageQuery pageQuery) {
LambdaQueryWrapper<WfCopy> lqw = buildQueryWrapper(bo);
lqw.orderByDesc(WfCopy::getCreateTime);
Page<WfCopyVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
return TableDataInfo.build(result);
}
/**
* 查询流程抄送列表
*
* @param bo 流程抄送
* @return 流程抄送
*/
@Override
public List<WfCopyVo> queryList(WfCopyBo bo) {
LambdaQueryWrapper<WfCopy> lqw = buildQueryWrapper(bo);
return baseMapper.selectVoList(lqw);
}
private LambdaQueryWrapper<WfCopy> buildQueryWrapper(WfCopyBo bo) {
Map<String, Object> params = bo.getParams();
LambdaQueryWrapper<WfCopy> lqw = Wrappers.lambdaQuery();
lqw.like(StringUtils.isNotBlank(bo.getProcessName()), WfCopy::getProcessName, bo.getProcessName());
lqw.like(StringUtils.isNotBlank(bo.getOriginatorName()), WfCopy::getOriginatorName, bo.getOriginatorName());
return lqw;
}
@Override
public Boolean makeCopy(WfTaskBo taskBo) {
if (StringUtils.isBlank(taskBo.getCopyUserIds())) {
// 若抄送用户为空,则不需要处理,返回成功
return true;
}
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery()
.processInstanceId(taskBo.getInstanceId()).singleResult();
String[] ids = taskBo.getCopyUserIds().split(",");
List<WfCopy> copyList = new ArrayList<>(ids.length);
Long originatorId = LoginHelper.getUserId();
String originatorName = LoginHelper.getNickName();
String title = processInstance.getProcessDefinitionName() + "-" + taskBo.getTaskName();
for (String id : ids) {
Long userId = Long.valueOf(id);
WfCopy copy = new WfCopy();
copy.setTitle(title);
copy.setProcessId(processInstance.getProcessDefinitionId());
copy.setProcessName(processInstance.getProcessDefinitionName());
copy.setDeploymentId(processInstance.getDeploymentId());
copy.setInstanceId(taskBo.getInstanceId());
copy.setTaskId(taskBo.getTaskId());
copy.setUserId(userId);
copy.setOriginatorId(originatorId);
copy.setOriginatorName(originatorName);
copyList.add(copy);
}
return baseMapper.insertBatch(copyList);
}
}

View File

@@ -21,6 +21,7 @@ import com.ruoyi.system.service.ISysUserService;
import com.ruoyi.workflow.domain.bo.WfTaskBo;
import com.ruoyi.workflow.domain.dto.WfNextDto;
import com.ruoyi.workflow.domain.vo.WfViewerVo;
import com.ruoyi.workflow.service.IWfCopyService;
import com.ruoyi.workflow.service.IWfTaskService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@@ -64,6 +65,8 @@ public class WfTaskServiceImpl extends FlowServiceFactory implements IWfTaskServ
private final ISysRoleService sysRoleService;
private final IWfCopyService copyService;
/**
* 完成任务
*
@@ -89,6 +92,12 @@ public class WfTaskServiceImpl extends FlowServiceFactory implements IWfTaskServ
taskService.complete(taskBo.getTaskId());
}
}
// 设置任务节点名称
taskBo.setTaskName(task.getName());
// 处理抄送用户
if (!copyService.makeCopy(taskBo)) {
throw new RuntimeException("抄送任务失败");
}
}
/**
@@ -215,7 +224,11 @@ public class WfTaskServiceImpl extends FlowServiceFactory implements IWfTaskServ
} catch (FlowableException e) {
throw new RuntimeException("无法取消或开始活动");
}
// 设置任务节点名称
bo.setTaskName(task.getName());
if (!copyService.makeCopy(bo)) {
throw new RuntimeException("抄送任务失败");
}
}
/**
@@ -298,6 +311,12 @@ public class WfTaskServiceImpl extends FlowServiceFactory implements IWfTaskServ
} catch (FlowableException e) {
throw new RuntimeException("无法取消或开始活动");
}
// 设置任务节点名称
bo.setTaskName(task.getName());
// 处理抄送用户
if (!copyService.makeCopy(bo)) {
throw new RuntimeException("抄送任务失败");
}
}
@@ -405,6 +424,12 @@ public class WfTaskServiceImpl extends FlowServiceFactory implements IWfTaskServ
taskService.setOwner(bo.getTaskId(), LoginHelper.getUserId().toString());
// 执行委派
taskService.delegateTask(bo.getTaskId(), bo.getUserId());
// 设置任务节点名称
bo.setTaskName(task.getName());
// 处理抄送用户
if (!copyService.makeCopy(bo)) {
throw new RuntimeException("抄送任务失败");
}
}
@@ -438,6 +463,12 @@ public class WfTaskServiceImpl extends FlowServiceFactory implements IWfTaskServ
taskService.setOwner(bo.getTaskId(), LoginHelper.getUserId().toString());
// 转办任务
taskService.setAssignee(bo.getTaskId(), bo.getUserId());
// 设置任务节点名称
bo.setTaskName(task.getName());
// 处理抄送用户
if (!copyService.makeCopy(bo)) {
throw new RuntimeException("抄送任务失败");
}
}
/**

View File

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.workflow.mapper.WfCopyMapper">
<resultMap type="com.ruoyi.workflow.domain.WfCopy" id="WfCopyResult">
<result property="copyId" column="copy_id"/>
<result property="title" column="title"/>
<result property="processId" column="process_id"/>
<result property="processName" column="process_name"/>
<result property="categoryId" column="category_id"/>
<result property="taskId" column="taskId"/>
<result property="userId" column="user_id"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
<result property="delFlag" column="del_flag"/>
</resultMap>
</mapper>

View File

@@ -46,6 +46,15 @@ export function listFinishedProcess(query) {
})
}
// 查询流程抄送列表
export function listCopyProcess(query) {
return request({
url: '/workflow/process/copyList',
method: 'get',
params: query
})
}
// 完成任务
export function complete(data) {
return request({

View File

@@ -0,0 +1,208 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="流程名称" prop="processName">
<el-input
v-model="queryParams.processName"
placeholder="请输入流程名称"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="发起人" prop="originatorName">
<el-input
v-model="queryParams.originatorName"
placeholder="请输入发起人"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
v-hasPermi="['workflow:copy:export']"
>导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="copyList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="抄送编号" align="center" prop="copyId" />
<el-table-column label="标题" align="center" prop="title" :show-overflow-tooltip="true" />
<el-table-column label="流程名称" align="center" prop="processName" :show-overflow-tooltip="true" />
<el-table-column label="发起人" align="center" prop="originatorName" />
<el-table-column label="创建时间" align="center" prop="createTime">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime) }}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-tickets"
@click="handleFlowRecord(scope.row)"
>详情</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
</div>
</template>
<script>
import { listCopyProcess } from "@/api/workflow/process"
export default {
name: "Copy",
data() {
return {
// 按钮loading
buttonLoading: false,
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 流程抄送表格数据
copyList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
processId: undefined,
processName: undefined,
categoryId: undefined,
taskId: undefined,
userId: undefined,
originatorName: undefined,
},
// 表单参数
form: {},
// 表单校验
rules: {
copyId: [
{ required: true, message: "抄送主键不能为空", trigger: "blur" }
],
processId: [
{ required: true, message: "流程主键不能为空", trigger: "blur" }
],
processName: [
{ required: true, message: "流程名称不能为空", trigger: "blur" }
],
categoryId: [
{ required: true, message: "流程分类主键不能为空", trigger: "blur" }
],
taskId: [
{ required: true, message: "任务主键不能为空", trigger: "blur" }
],
userId: [
{ required: true, message: "用户主键不能为空", trigger: "blur" }
]
}
};
},
created() {
this.getList();
},
methods: {
/** 查询流程抄送列表 */
getList() {
this.loading = true;
listCopyProcess(this.queryParams).then(response => {
this.copyList = response.rows;
this.total = response.total;
this.loading = false;
});
},
// 取消按钮
cancel() {
this.open = false;
this.reset();
},
// 表单重置
reset() {
this.form = {
copyId: undefined,
processId: undefined,
processName: undefined,
categoryId: undefined,
taskId: undefined,
userId: undefined,
originatorName: undefined,
createBy: undefined,
createTime: undefined,
updateBy: undefined,
updateTime: undefined,
delFlag: undefined
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.copyId)
this.single = selection.length!==1
this.multiple = !selection.length
},
/** 查看详情 */
handleFlowRecord(row){
this.$router.push({ path: '/work/detail',
query: {
definitionId: row.processId,
procInsId: row.instanceId,
deployId: row.deploymentId,
taskId: row.taskId,
finished: false
}
})
},
/** 导出按钮操作 */
handleExport() {
this.download('workflow/copy/export', {
...this.queryParams
}, `copy_${new Date().getTime()}.xlsx`)
}
}
};
</script>

View File

@@ -1,7 +1,8 @@
<template>
<div class="app-container">
<el-tabs tab-position="top">
<el-tab-pane label="任务办理" v-if="finished === 'true'">
<el-tabs tab-position="top" :value="finished === 'true' ? 'approval' : 'form'">
<el-tab-pane label="任务办理" name="approval" v-if="finished === 'true'">
<el-card class="box-card" shadow="never">
<el-row>
<el-col :span="20" :offset="2">
@@ -9,6 +10,17 @@
<el-form-item label="审批意见" prop="comment">
<el-input type="textarea" :rows="5" v-model="taskForm.comment" placeholder="请输入 审批意见" />
</el-form-item>
<el-form-item label="抄送人" prop="copyUserIds">
<el-tag
:key="index"
v-for="(item, index) in userData.copyUser"
closable
:disable-transitions="false"
@close="handleClose(item)">
{{ item.label }}
</el-tag>
<el-button class="button-new-tag" type="primary" icon="el-icon-plus" size="mini" circle @click="onSelectUsers" />
</el-form-item>
</el-form>
</el-col>
</el-row>
@@ -34,7 +46,8 @@
</el-row>
</el-card>
</el-tab-pane>
<el-tab-pane label="表单信息">
<el-tab-pane label="表单信息" name="form">
<el-card class="box-card" shadow="never">
<!--流程处理表单模块-->
<el-col :span="20" :offset="2" v-if="variableOpen">
@@ -52,9 +65,9 @@
</el-card>
</el-tab-pane >
<el-tab-pane label="流转记录">
<el-tab-pane label="流转记录" name="record">
<el-card class="box-card" shadow="never">
<el-col :span="18" :offset="3">
<el-col :span="20" :offset="2">
<div class="block">
<el-timeline>
<el-timeline-item v-for="(item,index) in flowRecordList" :key="index" :icon="setIcon(item.finishTime)" :color="setColor(item.finishTime)">
@@ -82,7 +95,7 @@
</el-card>
</el-tab-pane>
<el-tab-pane label="流程跟踪">
<el-tab-pane label="流程跟踪" name="track">
<el-card class="box-card" shadow="never">
<process-viewer :key="`designer-${loadIndex}`" :style="'height:' + height" :xml="xmlData"
:finishedInfo="finishedInfo" :allCommentList="null"
@@ -110,7 +123,7 @@
</span>
</el-dialog>
<el-dialog :title="userDialogTitle" :visible.sync="userOpen" width="60%" append-to-body>
<el-dialog :title="userData.title" :visible.sync="userData.open" width="60%" append-to-body>
<el-row type="flex" :gutter="20">
<!--部门数据-->
<el-col :span="5">
@@ -133,8 +146,16 @@
</el-card>
</el-col>
<el-col :span="18">
<el-table ref="userTable" height="500" :data="userList" highlight-current-row @current-change="changeCurrentUser">
<el-table-column width="30">
<el-table ref="userTable"
:key="userData.type"
height="500"
v-loading="userLoading"
:data="userList"
highlight-current-row
@current-change="changeCurrentUser"
@selection-change="handleSelectionChange">
<el-table-column v-if="userData.type === 'copy'" width="55" type="selection" />
<el-table-column v-else width="30">
<template slot-scope="scope">
<el-radio :label="scope.row.userId" v-model="currentUserId">{{''}}</el-radio>
</template>
@@ -152,9 +173,8 @@
</el-col>
</el-row>
<span slot="footer" class="dialog-footer">
<el-button @click="userOpen = false"> </el-button>
<el-button type="primary" v-if="userDialogTitle === '委派任务'" @click="submitDelegate"> </el-button>
<el-button type="primary" v-if="userDialogTitle === '转办任务'" @click="submitTransfer"> </el-button>
<el-button @click="userData.open = false"> </el-button>
<el-button type="primary" @click="submitUserData"> </el-button>
</span>
</el-dialog>
</div>
@@ -220,6 +240,7 @@ export default {
deptName: undefined,
// 部门树选项
deptOptions: undefined,
userLoading: false,
// 用户表格数据
userList: null,
deptProps: {
@@ -248,6 +269,7 @@ export default {
deployId: "", // 流程定义编号
taskId: "" ,// 流程任务编号
definitionId: "", // 流程编号
copyUserIds: "", // 抄送人Id
vars: "",
targetKey:""
},
@@ -268,9 +290,16 @@ export default {
returnOpen: false,
rejectOpen: false,
rejectTitle: null,
userData: {
title: '',
type: 'copy',
open: false,
currentUserId: null,
copyUser: [],
},
userMultipleSelection: [],
userDialogTitle: '',
userOpen: false,
userData:[],
userOpen: false
};
},
activated() {
@@ -300,11 +329,13 @@ export default {
},
/** 查询用户列表 */
getList() {
this.userLoading = true;
listUser(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
this.userList = response.rows;
this.total = response.total;
}
);
this.userList = response.rows;
this.total = response.total;
this.toggleSelection(this.userMultipleSelection);
this.userLoading = false;
});
},
// 筛选节点
filterNode(value, data) {
@@ -356,21 +387,25 @@ export default {
},
// 多选框选中数据
handleSelectionChange(selection) {
this.userData = selection
const val = selection.map(item => item.userId)[0];
if (val instanceof Array) {
this.taskForm.values = {
"approval": val.join(',')
}
this.userMultipleSelection = selection
},
toggleSelection(selection) {
if (selection && selection.length > 0) {
this.$nextTick(()=> {
selection.forEach(item => {
let row = this.userList.find(k => k.userId === item.userId);
this.$refs.userTable.toggleRowSelection(row);
})
})
} else {
this.taskForm.values = {
"approval": val
}
this.$refs.userTable.clearSelection();
}
},
// 关闭标签
handleClose(tag) {
this.userData.splice(this.userData.indexOf(tag), 1);
let userObj = this.userMultipleSelection.find(item => item.userId === tag.id);
this.userMultipleSelection.splice(this.userMultipleSelection.indexOf(userObj), 1);
this.userData.copyUser.splice(this.userData.copyUser.indexOf(tag), 1);
},
/** 流程变量赋值 */
handleCheckChange(val) {
@@ -389,7 +424,6 @@ export default {
const params = {procInsId: procInsId, deployId: deployId}
getDetailInstance(params).then(res => {
this.flowRecordList = res.data.flowList;
console.log("res flowList => ", this.flowRecordList)
// 流程过程中不存在初始化表单 直接读取的流程变量中存储的表单值
if (res.data.formData) {
this.formConf = res.data.formData;
@@ -399,14 +433,6 @@ export default {
this.goBack();
})
},
fillFormData(form, data) {
form.fields.forEach(item => {
const val = data[item.__vModel__]
if (val) {
item.__config__.defaultValue = val
}
})
},
/** 获取流程变量内容 */
processVariables(taskId) {
if (taskId) {
@@ -417,50 +443,32 @@ export default {
});
}
},
/** 根据当前任务或者流程设计配置的下一步节点 */
getNextFlowNode(taskId) {
// 根据当前任务或者流程设计配置的下一步节点 todo 暂时未涉及到考虑网关、表达式和多节点情况
const params = {taskId: taskId}
getNextFlowNode(params).then(res => {
const data = res.data;
if (data) {
if (data.type === 'assignee') {
this.userDataList = res.data.userList;
} else if (data.type === 'candidateUsers') {
this.userDataList = res.data.userList;
this.taskForm.multiple = true;
} else if (data.type === 'candidateGroups') {
res.data.roleList.forEach(role => {
role.userId = role.roleId;
role.nickName = role.roleName;
})
this.userDataList = res.data.roleList;
this.taskForm.multiple = false;
} else if (data.type === 'multiInstance') {
this.userDataList = res.data.userList;
this.taskForm.multiple = true;
}
this.taskForm.sendUserShow = true;
}
})
onSelectUsers() {
this.userData.title = '添加抄送人';
this.userData.type = 'copy';
this.getTreeSelect();
this.getList()
this.userData.open = true;
this.$refs.userTable.clearSelection();
},
/** 通过任务 */
handleComplete() {
this.$refs['taskForm'].validate(valid => {
if (valid) {
complete(this.taskForm).then(response => {
this.$modal.msgSuccess(response.msg);
this.goBack();
});
}
if (valid) {
complete(this.taskForm).then(response => {
this.$modal.msgSuccess(response.msg);
this.goBack();
});
}
});
},
/** 委派任务 */
handleDelegate() {
this.$refs["taskForm"].validate(valid => {
if (valid) {
this.userDialogTitle = '委派任务'
this.userOpen = true;
this.userData.type = 'delegate';
this.userData.title = '委派任务'
this.userData.open = true;
this.getTreeSelect();
}
})
@@ -469,8 +477,9 @@ export default {
handleTransfer(){
this.$refs["taskForm"].validate(valid => {
if (valid) {
this.userDialogTitle = '转办任务'
this.userOpen = true;
this.userData.type = 'transfer';
this.userData.title = '转办任务';
this.userData.open = true;
this.getTreeSelect();
}
})
@@ -534,35 +543,48 @@ export default {
}
}
},
submitDelegate() {
if (!this.taskForm.comment) {
this.$modal.msgError("请输入审批意见");
return false;
submitUserData() {
let type = this.userData.type;
if (type === 'copy') {
if (!this.userMultipleSelection || this.userMultipleSelection.length <= 0) {
this.$modal.msgError("请选择用户");
return false;
}
this.userData.copyUser = this.userMultipleSelection.map(k => {
return { id: k.userId, label: k.nickName }
})
this.userData.open = false;
} else {
if (!this.taskForm.comment) {
this.$modal.msgError("请输入审批意见");
return false;
}
if (!this.currentUserId) {
this.$modal.msgError("请选择用户");
return false;
}
// 若有选择抄送用户获取抄送用户ID
if (this.userData.copyUser && this.userData.copyUser.length > 0) {
const val = this.userData.copyUser.map(item => item.id);
this.taskForm.copyUserIds = val instanceof Array ? val.join(',') : val;
} else {
this.taskForm.copyUserIds = '';
}
this.taskForm.userId = this.currentUserId;
if (type === 'delegate') {
delegate(this.taskForm).then(res => {
this.$modal.msgSuccess(res.msg);
this.goBack();
});
}
if (type === 'transfer') {
transfer(this.taskForm).then(res => {
this.$modal.msgSuccess(res.msg);
this.goBack();
});
}
}
if (!this.currentUserId) {
this.$modal.msgError("请选择委派用户");
return false;
}
this.taskForm.userId = this.currentUserId;
delegate(this.taskForm).then(res => {
this.$modal.msgSuccess(res.msg);
this.goBack();
});
},
submitTransfer() {
if (!this.taskForm.comment) {
this.$modal.msgError("请输入审批意见");
return false;
}
if (!this.currentUserId) {
this.$modal.msgError("请选择受理用户");
return false;
}
this.taskForm.userId = this.currentUserId;
transfer(this.taskForm).then(res => {
this.$modal.msgSuccess(res.msg);
this.goBack();
});
},
/** 可退回任务列表 */
handleReturn() {
@@ -629,4 +651,8 @@ export default {
.el-col {
border-radius: 4px;
}
.button-new-tag {
margin-left: 10px;
}
</style>