feat: 开始节点获取

rf
tony 2022-12-15 18:24:12 +08:00
parent dd11a1ac66
commit 295a46662e
16 changed files with 311 additions and 227 deletions

View File

@ -155,7 +155,7 @@ public class FlowDefinitionController {
} }
@ApiOperation(value = "根据流程定义id启动流程实例") @ApiOperation(value = "发起流程")
@PostMapping("/start/{procDefId}") @PostMapping("/start/{procDefId}")
public AjaxResult start(@ApiParam(value = "流程定义id") @PathVariable(value = "procDefId") String procDefId, public AjaxResult start(@ApiParam(value = "流程定义id") @PathVariable(value = "procDefId") String procDefId,
@ApiParam(value = "变量集合,json对象") @RequestBody Map<String, Object> variables) { @ApiParam(value = "变量集合,json对象") @RequestBody Map<String, Object> variables) {

View File

@ -153,6 +153,12 @@ public class FlowTaskController {
return flowTaskService.getNextFlowNode(flowTaskVo); return flowTaskService.getNextFlowNode(flowTaskVo);
} }
@ApiOperation(value = "流程发起时获取下一节点")
@PostMapping(value = "/nextFlowNodeByStart")
public AjaxResult getNextFlowNodeByStart(@RequestBody FlowTaskVo flowTaskVo) {
return flowTaskService.getNextFlowNodeByStart(flowTaskVo);
}
/** /**
* *
* *

View File

@ -32,6 +32,8 @@ public class FlowTaskVo {
@ApiModelProperty("节点") @ApiModelProperty("节点")
private String targetKey; private String targetKey;
private String deploymentId;
@ApiModelProperty("流程变量信息") @ApiModelProperty("流程变量信息")
private Map<String, Object> values; private Map<String, Object> values;

View File

@ -5,16 +5,15 @@ import com.googlecode.aviator.Expression;
//import com.greenpineyu.fel.FelEngine; //import com.greenpineyu.fel.FelEngine;
//import com.greenpineyu.fel.FelEngineImpl; //import com.greenpineyu.fel.FelEngineImpl;
//import com.greenpineyu.fel.context.FelContext; //import com.greenpineyu.fel.context.FelContext;
import org.apache.commons.lang3.StringUtils;
import org.flowable.bpmn.model.Process; import org.flowable.bpmn.model.Process;
import org.flowable.bpmn.model.*; import org.flowable.bpmn.model.*;
import org.flowable.engine.RepositoryService; import org.flowable.engine.RepositoryService;
import org.flowable.engine.TaskService; import org.flowable.engine.TaskService;
import org.flowable.engine.repository.Model;
import org.flowable.engine.repository.ProcessDefinition; import org.flowable.engine.repository.ProcessDefinition;
import java.util.ArrayList; import java.util.*;
import java.util.Collection;
import java.util.List;
import java.util.Map;
/** /**
* @author Xuan xuan * @author Xuan xuan
@ -41,6 +40,41 @@ public class FindNextNodeUtil {
return data; return data;
} }
/**
*
*
* @param repositoryService
* @param map
* @return
*/
public static List<UserTask> getNextUserTasksByStart(RepositoryService repositoryService, ProcessDefinition processDefinition, Map<String, Object> map) {
List<UserTask> data = new ArrayList<>();
BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinition.getId());
Process mainProcess = bpmnModel.getMainProcess();
Collection<FlowElement> flowElements = mainProcess.getFlowElements();
String key = null;
// 找到开始节点 并获取唯一key
for (FlowElement flowElement : flowElements) {
if (flowElement instanceof StartEvent) {
key = flowElement.getId();
break;
}
}
FlowElement flowElement = bpmnModel.getFlowElement(key);
next(flowElements, flowElement, map, data);
return data;
}
/**
*
*
* @param flowElements
* @param flowElement
* @param map
* @param nextUser
*/
public static void next(Collection<FlowElement> flowElements, FlowElement flowElement, Map<String, Object> map, List<UserTask> nextUser) { public static void next(Collection<FlowElement> flowElements, FlowElement flowElement, Map<String, Object> map, List<UserTask> nextUser) {
//如果是结束节点 //如果是结束节点
if (flowElement instanceof EndEvent) { if (flowElement instanceof EndEvent) {

View File

@ -165,6 +165,8 @@ public interface IFlowTaskService {
*/ */
AjaxResult getNextFlowNode(FlowTaskVo flowTaskVo); AjaxResult getNextFlowNode(FlowTaskVo flowTaskVo);
AjaxResult getNextFlowNodeByStart(FlowTaskVo flowTaskVo);
/** /**
* *
* @param deployId * @param deployId

View File

@ -200,13 +200,13 @@ public class FlowDefinitionServiceImpl extends FlowServiceFactory implements IFl
identityService.setAuthenticatedUserId(sysUser.getUserId().toString()); identityService.setAuthenticatedUserId(sysUser.getUserId().toString());
variables.put(ProcessConstants.PROCESS_INITIATOR, ""); variables.put(ProcessConstants.PROCESS_INITIATOR, "");
ProcessInstance processInstance = runtimeService.startProcessInstanceById(procDefId, variables); ProcessInstance processInstance = runtimeService.startProcessInstanceById(procDefId, variables);
// 给第一步申请人节点设置任务执行人和意见 todo:第一个节点不设置为申请人节点有点问题? // // 给第一步申请人节点设置任务执行人和意见 todo:第一个节点不设置为申请人节点有点问题?
Task task = taskService.createTaskQuery().processInstanceId(processInstance.getProcessInstanceId()).singleResult(); // Task task = taskService.createTaskQuery().processInstanceId(processInstance.getProcessInstanceId()).singleResult();
if (Objects.nonNull(task)) { // if (Objects.nonNull(task)) {
taskService.addComment(task.getId(), processInstance.getProcessInstanceId(), FlowComment.NORMAL.getType(), sysUser.getNickName() + "发起流程申请"); // taskService.addComment(task.getId(), processInstance.getProcessInstanceId(), FlowComment.NORMAL.getType(), sysUser.getNickName() + "发起流程申请");
// taskService.setAssignee(task.getId(), sysUser.getUserId().toString()); //// taskService.setAssignee(task.getId(), sysUser.getUserId().toString());
taskService.complete(task.getId(), variables); // taskService.complete(task.getId(), variables);
} // }
return AjaxResult.success("流程启动成功"); return AjaxResult.success("流程启动成功");
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();

View File

@ -970,6 +970,45 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask
return AjaxResult.success(flowNextDto); return AjaxResult.success(flowNextDto);
} }
/**
*
*
* @param flowTaskVo
* @return
*/
@Override
public AjaxResult getNextFlowNodeByStart(FlowTaskVo flowTaskVo) {
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().deploymentId(flowTaskVo.getDeploymentId()).singleResult();
// Step 1. 获取当前节点并找到下一步节点
FlowNextDto flowNextDto = new FlowNextDto();
// Step 2. 获取当前流程所有流程变量(网关节点时需要校验表达式)
List<UserTask> nextUserTask = FindNextNodeUtil.getNextUserTasksByStart(repositoryService, processDefinition, new HashMap<>());
if (CollectionUtils.isNotEmpty(nextUserTask)) {
for (UserTask userTask : nextUserTask) {
MultiInstanceLoopCharacteristics multiInstance = userTask.getLoopCharacteristics();
// 会签节点
if (Objects.nonNull(multiInstance)) {
List<SysUser> list = sysUserService.selectUserList(new SysUser());
flowNextDto.setVars(ProcessConstants.PROCESS_MULTI_INSTANCE_USER);
flowNextDto.setType(ProcessConstants.PROCESS_MULTI_INSTANCE);
flowNextDto.setUserList(list);
} else {
// 读取自定义节点属性 判断是否是否需要动态指定任务接收人员、组
String dataType = userTask.getAttributeValue(ProcessConstants.NAMASPASE, ProcessConstants.PROCESS_CUSTOM_DATA_TYPE);
String userType = userTask.getAttributeValue(ProcessConstants.NAMASPASE, ProcessConstants.PROCESS_CUSTOM_USER_TYPE);
flowNextDto.setVars(ProcessConstants.PROCESS_APPROVAL);
flowNextDto.setType(userType);
// 处理加载动态指定下一节点接收人员信息
if (ProcessConstants.DYNAMIC.equals(dataType)) {
flowNextDto.setVars(ProcessConstants.PROCESS_APPROVAL);
flowNextDto.setType(userType);
}
}
}
}
return AjaxResult.success(flowNextDto);
}
/** /**
* *
* *

View File

@ -64,6 +64,15 @@ export function getNextFlowNode(data) {
}) })
} }
// 下一节点
export function getNextFlowNodeByStart(data) {
return request({
url: '/flowable/task/nextFlowNodeByStart',
method: 'post',
data: data
})
}
// 部署流程实例 // 部署流程实例
export function deployStart(deployId) { export function deployStart(deployId) {
return request({ return request({

View File

@ -125,7 +125,7 @@ export default {
}) })
this.modeler.on('element.click', e => { this.modeler.on('element.click', e => {
const { element } = e const { element } = e
console.log(element) // console.log(element)
if (element.type === 'bpmn:Process') { if (element.type === 'bpmn:Process') {
this.element = element this.element = element
} }

View File

@ -18,30 +18,35 @@
</template> </template>
<template #checkSingleUser> <template #checkSingleUser>
<el-input placeholder="请选择人员" class="input-with-select" v-model="checkValues"> <el-input placeholder="请选择人员" class="input-with-select" v-model="checkValues">
<!--指定用户--> <template slot="append">
<el-button slot="append" size="mini" icon="el-icon-user" @click="singleUserCheck"></el-button> <!--指定用户-->
<el-divider direction="vertical"></el-divider> <el-button style="padding-left: 7px" size="mini" icon="el-icon-user" @click="singleUserCheck"/>
<!--选择表达式--> <el-divider direction="vertical"></el-divider>
<el-button slot="append" size="mini" icon="el-icon-tickets" @click="singleExpCheck('assignee')"></el-button> <!--选择表达式-->
<el-button style="padding-right: 7px" size="mini" icon="el-icon-postcard" @click="singleExpCheck('assignee')"/>
</template>
</el-input> </el-input>
</template> </template>
<template #checkMultipleUser> <template #checkMultipleUser>
<el-input placeholder="请选择候选用户" class="input-with-select" v-model="checkValues"> <el-input placeholder="请选择候选用户" class="input-with-select" v-model="checkValues">
<!--候选用户--> <template slot="append">
<el-button slot="append" size="mini" icon="el-icon-user" @click="multipleUserCheck"></el-button> <!--候选用户-->
<el-divider direction="vertical"></el-divider> <el-button style="padding-left: 7px" size="mini" icon="el-icon-user" @click="multipleUserCheck"/>
<!--选择表达式--> <el-divider direction="vertical"></el-divider>
<el-button slot="append" size="mini" icon="el-icon-tickets" @click="singleExpCheck('candidateUsers')"></el-button> <!--选择表达式-->
<el-button style="padding-right: 7px" size="mini" icon="el-icon-postcard" @click="singleExpCheck('candidateUsers')"/>
</template>
</el-input> </el-input>
</template> </template>
<template #checkRole> <template #checkRole>
<el-input placeholder="请选择候选角色" class="input-with-select" v-model="checkValues"> <el-input placeholder="请选择候选角色" class="input-with-select" v-model="checkValues">
<template slot="append">
<!--候选角色--> <!--候选角色-->
<!-- <el-button slot="append" size="mini" icon="el-icon-user" @click="singleRoleCheck"></el-button>--> <el-button style="padding-left: 7px" size="mini" icon="el-icon-user" @click="multipleRoleCheck"/>
<!-- <el-divider direction="vertical"></el-divider>--> <el-divider direction="vertical"></el-divider>
<el-button slot="append" size="mini" icon="el-icon-user" @click="multipleRoleCheck"></el-button> <!--选择表达式-->
<!--选择表达式--> <el-button style="padding-right: 7px" size="mini" icon="el-icon-postcard" @click="singleExpCheck('candidateGroups')"/>
<el-button slot="append" size="mini" icon="el-icon-tickets" @click="singleExpCheck('candidateGroups')"></el-button> </template>
</el-input> </el-input>
</template> </template>
</x-form> </x-form>
@ -99,7 +104,7 @@
:close-on-press-escape="false" :close-on-press-escape="false"
:show-close="false" :show-close="false"
> >
<flow-role :checkType="checkType" @handleRoleSelect="handleRoleSelect"></flow-role> <flow-role :checkType="checkType" :selectValues="selectValues" @handleRoleSelect="handleRoleSelect"></flow-role>
<span slot="footer" class="dialog-footer"> <span slot="footer" class="dialog-footer">
<el-button @click="roleVisible = false"> </el-button> <el-button @click="roleVisible = false"> </el-button>
<el-button type="primary" @click="checkRoleComplete"> </el-button> <el-button type="primary" @click="checkRoleComplete"> </el-button>
@ -169,6 +174,7 @@ export default {
checkType: 'single', checkType: 'single',
// //
checkValues: null, checkValues: null,
//
selectValues: null, selectValues: null,
// //
userList: this.users, userList: this.users,
@ -219,49 +225,11 @@ export default {
dic: _this.userTypeOption, dic: _this.userTypeOption,
show: !!_this.showConfig.userType show: !!_this.showConfig.userType
}, },
// {
// xType: 'radio',
// name: 'dataType',
// label: '',
// dic: _this.dataTypeOption,
// show: !!_this.showConfig.dataType,
// rules: [{ required: true, message: '' }]
// },
// {
// xType: 'select',
// name: 'assignee',
// label: '',
// allowCreate: true,
// filterable: true,
// dic: { data: _this.users, label: 'nickName', value: 'userId' },
// show: !!_this.showConfig.assignee && _this.formData.userType === 'assignee'
// },
// {
// xType: 'select',
// name: 'candidateUsers',
// label: '',
// multiple: true,
// allowCreate: true,
// filterable: true,
// dic: { data: _this.users, label: 'nickName', value: 'userId' },
// show: !!_this.showConfig.candidateUsers && _this.formData.userType === 'candidateUsers'
// },
// {
// xType: 'select',
// name: 'candidateGroups',
// label: '',
// multiple: true,
// allowCreate: true,
// filterable: true,
// dic: { data: _this.groups, label: 'roleName', value: 'roleId' },
// show: !!_this.showConfig.candidateGroups && _this.formData.userType === 'candidateGroups'
// },
{ {
xType: 'slot', xType: 'slot',
name: 'checkSingleUser', name: 'checkSingleUser',
label: '指定人员', label: '指定人员',
// rules: [{ required: true, message: '' }], // rules: [{ required: true, message: '' }],
// dic: { data: _this.users, label: 'nickName', value: 'userId' },
show: !!_this.showConfig.assignee && _this.formData.userType === 'assignee' show: !!_this.showConfig.assignee && _this.formData.userType === 'assignee'
}, },
{ {
@ -385,47 +353,6 @@ export default {
} }
this.updateProperties({'flowable:userType': val}) this.updateProperties({'flowable:userType': val})
}, },
// //
// 'formData.dataType': function(val) {
// const that = this
// this.updateProperties({'flowable:dataType': val})
// if (val === 'dynamic') {
// this.updateProperties({'flowable:userType': that.formData.userType})
// }
// //
// const types = ['assignee', 'candidateUsers', 'candidateGroups']
// types.forEach(type => {
// delete this.element.businessObject.$attrs[`flowable:${type}`]
// delete this.formData[type]
// })
// //
// const params = {
// dataType: val,
// userType: this.formData.userType
// }
// this.$emit('dataType', params)
// },
// 'formData.assignee': function(val) {
// if (this.formData.userType !== 'assignee') {
// delete this.element.businessObject.$attrs[`flowable:assignee`]
// return
// }
// this.updateProperties({'flowable:assignee': val})
// },
// 'formData.candidateUsers': function(val) {
// if (this.formData.userType !== 'candidateUsers') {
// delete this.element.businessObject.$attrs[`flowable:candidateUsers`]
// return
// }
// this.updateProperties({'flowable:candidateUsers': val?.join(',')})
// },
// 'formData.candidateGroups': function(val) {
// if (this.formData.userType !== 'candidateGroups') {
// delete this.element.businessObject.$attrs[`flowable:candidateGroups`]
// return
// }
// this.updateProperties({'flowable:candidateGroups': val?.join(',')})
// },
'formData.async': function(val) { 'formData.async': function(val) {
if (val === '') val = null if (val === '') val = null
this.updateProperties({ 'flowable:async': val }) this.updateProperties({ 'flowable:async': val })
@ -504,10 +431,10 @@ export default {
this.hasMultiInstance = false this.hasMultiInstance = false
} }
}, },
// //
getCheckValues(){ getCheckValues(){
const that = this; const that = this;
console.log(that.element.businessObject,"this.element.businessObject") // console.log(that.element.businessObject,"this.element.businessObject")
const attrs = that.element.businessObject.$attrs; const attrs = that.element.businessObject.$attrs;
const businessObject = that.element.businessObject; const businessObject = that.element.businessObject;
// //
@ -526,33 +453,22 @@ export default {
const val = attrs["flowable:candidateUsers"]; const val = attrs["flowable:candidateUsers"];
if (attrs["flowable:dataType"] === "dynamic") { if (attrs["flowable:dataType"] === "dynamic") {
this.checkValues = that.expList.find(item => item.expression == val).name; this.checkValues = that.expList.find(item => item.expression == val).name;
this.selectValues = that.expList.filter(item => item.expression == val).id;
} else { } else {
const array = []; const newArr = that.userList.filter(i => val.split(',').includes(i.userId))
const vals = val.split(','); this.checkValues = newArr.map(item => item.nickName).join(',');
vals.forEach(key => { this.selectValues = newArr.map(item => item.userId).join(',');
const user = that.userList.find(item => item.userId == key)
if (user) {
array.push(user.nickName);
}
})
this.checkValues = array.join(',');
this.selectValues = array.join(',');
} }
} else if (businessObject.hasOwnProperty("candidateGroups")) { } else if (businessObject.hasOwnProperty("candidateGroups")) {
// //
const val = businessObject["candidateGroups"]; const val = businessObject["candidateGroups"];
if (attrs["flowable:dataType"] === "dynamic") { if (attrs["flowable:dataType"] === "dynamic") {
this.checkValues = that.expList.find(item => item.expression == val).name; this.checkValues = that.expList.find(item => item.expression == val).name;
this.selectValues = that.expList.filter(item => item.expression == val).id;
} else { } else {
const array = []; const newArr = that.groupList.filter(i => val.split(',').includes(i.roleId))
const vals = val.split(','); this.checkValues = newArr.map(item => item.roleName).join(',');
vals.forEach(key => { this.selectValues = newArr.map(item => item.roleId).join(',');
const role = that.groupList.find(item => item.roleId == key)
if (role) {
array.push(role.roleName);
}
})
this.checkValues = array.join(',');
} }
} }
}, },

View File

@ -57,9 +57,10 @@ export default {
dicts: ['sys_common_status'], dicts: ['sys_common_status'],
// //
props: { props: {
//
selectValues: { selectValues: {
type: Number, type: Number | String,
default: 0, default: null,
required: false required: false
} }
}, },
@ -91,16 +92,15 @@ export default {
expression: null, expression: null,
status: null, status: null,
}, },
radioSelected: this.selectValues radioSelected: null //
}; };
}, },
watch: { watch: {
selectValues: { selectValues: {
immediate: true,
handler(newVal) { handler(newVal) {
console.log(newVal,"selectValues")
this.radioSelected = newVal this.radioSelected = newVal
} },
immediate: true,
} }
}, },
created() { created() {

View File

@ -16,7 +16,7 @@
</el-form-item> </el-form-item>
</el-form> </el-form>
<el-table v-if="selectType === 'multiple'" v-loading="loading" :data="roleList" @selection-change="handleMultipleRoleSelect"> <el-table v-if="selectType === 'multiple'" ref="dataTable" v-loading="loading" :data="roleList" @selection-change="handleMultipleRoleSelect">
<el-table-column type="selection" width="50" align="center" /> <el-table-column type="selection" width="50" align="center" />
<el-table-column label="角色编号" prop="roleId" width="120" /> <el-table-column label="角色编号" prop="roleId" width="120" />
<el-table-column label="角色名称" prop="roleName" :show-overflow-tooltip="true" width="150" /> <el-table-column label="角色名称" prop="roleName" :show-overflow-tooltip="true" width="150" />
@ -66,9 +66,17 @@ export default {
dicts: ['sys_normal_disable'], dicts: ['sys_normal_disable'],
// //
props: { props: {
checkType: String, //
default: 'multiple', selectValues: {
required: false type: Number | String | Array,
default: null,
required: false
},
checkType: {
type: String,
default: 'multiple',
required: true
},
}, },
data() { data() {
return { return {
@ -91,41 +99,6 @@ export default {
title: "", title: "",
// //
open: false, open: false,
//
openDataScope: false,
menuExpand: false,
menuNodeAll: false,
deptExpand: true,
deptNodeAll: false,
//
dateRange: [],
//
dataScopeOptions: [
{
value: "1",
label: "全部数据权限"
},
{
value: "2",
label: "自定数据权限"
},
{
value: "3",
label: "本部门数据权限"
},
{
value: "4",
label: "本部门及以下数据权限"
},
{
value: "5",
label: "仅本人数据权限"
}
],
//
menuOptions: [],
//
deptOptions: [],
// //
queryParams: { queryParams: {
pageNum: 1, pageNum: 1,
@ -136,13 +109,38 @@ export default {
}, },
// //
form: {}, form: {},
defaultProps: { radioSelected: null, //
children: "children", selectRoleList: null //
label: "label"
},
radioSelected:''
}; };
}, },
watch: {
selectValues: {
handler(newVal) {
if (newVal instanceof Number) {
this.radioSelected = newVal
} else {
this.selectRoleList = newVal;
}
},
immediate: true
},
roleList: {
handler(newVal) {
if (newVal) {
this.$nextTick(() => {
this.$refs.dataTable.clearSelection();
this.selectRoleList?.split(',').forEach(key => {
this.$refs.dataTable.toggleRowSelection(newVal.find(
item => key == item.roleId
), true)
});
});
}
},
immediate: true, //
deep: true //
}
},
created() { created() {
this.getList(); this.getList();
}, },
@ -150,7 +148,7 @@ export default {
/** 查询角色列表 */ /** 查询角色列表 */
getList() { getList() {
this.loading = true; this.loading = true;
listRole(this.addDateRange(this.queryParams, this.dateRange)).then(response => { listRole(this.queryParams).then(response => {
this.roleList = response.rows; this.roleList = response.rows;
this.total = response.total; this.total = response.total;
this.loading = false; this.loading = false;
@ -158,26 +156,16 @@ export default {
); );
}, },
// //
handleRoleSelect(selection) {
// this.ids = selection.map(item => item.userId);
this.radioSelected = selection.roleId;//,radio
console.log(selection,"handleRoleSelect");
this.$emit('handleRoleSelect', selection);
},
//
handleMultipleRoleSelect(selection) { handleMultipleRoleSelect(selection) {
this.ids = selection.map(item => item.roleId); const idList = selection.map(item => item.roleId);
const nameList = selection.map(item => item.roleName); const nameList = selection.map(item => item.roleName);
console.log( this.ids,"handleRoleSelect"); this.$emit('handleRoleSelect', idList.join(','), nameList.join(','));
this.$emit('handleRoleSelect',this.ids.join(','),nameList.join(','));
}, },
// //
handleSingleRoleSelect(selection) { handleSingleRoleSelect(selection) {
this.radioSelected = selection.roleId;//,radio this.radioSelected = selection.roleId;
const name = selection.roleName;//,radio const roleName = selection.roleName;
console.log(this.radioSelected.toString() ,"handleRoleSelect"); this.$emit('handleRoleSelect', this.radioSelected.toString(), roleName);
this.$emit('handleRoleSelect',this.radioSelected.toString(),name);
}, },
/** 搜索按钮操作 */ /** 搜索按钮操作 */
handleQuery() { handleQuery() {
@ -186,7 +174,6 @@ export default {
}, },
/** 重置按钮操作 */ /** 重置按钮操作 */
resetQuery() { resetQuery() {
this.dateRange = [];
this.handleQuery(); this.handleQuery();
}, },
} }

View File

@ -53,7 +53,7 @@
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery"></el-button> <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"></el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
<el-table v-if="selectType === 'multiple'" v-loading="loading" :data="userList" @selection-change="handleMultipleUserSelect"> <el-table v-if="selectType === 'multiple'" ref="dataTable" v-loading="loading" :data="userList" @selection-change="handleMultipleUserSelect">
<el-table-column type="selection" width="50" align="center" /> <el-table-column type="selection" width="50" align="center" />
<el-table-column label="用户编号" align="center" key="userId" prop="userId" v-if="columns[0].visible" /> <el-table-column label="用户编号" align="center" key="userId" prop="userId" v-if="columns[0].visible" />
<el-table-column label="登录账号" align="center" key="userName" prop="userName" v-if="columns[1].visible" :show-overflow-tooltip="true" /> <el-table-column label="登录账号" align="center" key="userName" prop="userName" v-if="columns[1].visible" :show-overflow-tooltip="true" />
@ -97,11 +97,13 @@ export default {
components: { Treeselect }, components: { Treeselect },
// //
props: { props: {
//
selectValues: { selectValues: {
type: Number | String, type: Number | String | Array,
default: 0, default: null,
required: false required: false
}, },
//
checkType: { checkType: {
type: String, type: String,
default: 'multiple', default: 'multiple',
@ -133,14 +135,6 @@ export default {
open: false, open: false,
// //
deptName: undefined, deptName: undefined,
//
initPassword: undefined,
//
dateRange: [],
//
postOptions: [],
//
roleOptions: [],
// //
form: {}, form: {},
defaultProps: { defaultProps: {
@ -166,7 +160,8 @@ export default {
{ key: 5, label: `状态`, visible: true }, { key: 5, label: `状态`, visible: true },
{ key: 6, label: `创建时间`, visible: true } { key: 6, label: `创建时间`, visible: true }
], ],
radioSelected:null radioSelected: null, //
selectUserList: null //
}; };
}, },
watch: { watch: {
@ -175,25 +170,41 @@ export default {
this.$refs.tree.filter(val); this.$refs.tree.filter(val);
}, },
selectValues: { selectValues: {
immediate: true,
handler(newVal) { handler(newVal) {
console.log(newVal,"user-selectValues") if (newVal instanceof Number) {
this.radioSelected = newVal this.radioSelected = newVal
} } else {
this.selectUserList = newVal;
}
},
immediate: true
},
userList: {
handler(newVal) {
if (newVal) {
this.$nextTick(() => {
this.$refs.dataTable.clearSelection();
this.selectUserList?.split(',').forEach(key => {
this.$refs.dataTable.toggleRowSelection(newVal.find(
item => key == item.userId
), true)
});
});
}
},
immediate: true, //
deep: true //
} }
}, },
created() { created() {
this.getList(); this.getList();
this.getDeptTree(); this.getDeptTree();
this.getConfigKey("sys.user.initPassword").then(response => {
this.initPassword = response.msg;
});
}, },
methods: { methods: {
/** 查询用户列表 */ /** 查询用户列表 */
getList() { getList() {
this.loading = true; this.loading = true;
listUser(this.addDateRange(this.queryParams, this.dateRange)).then(response => { listUser(this.queryParams).then(response => {
this.userList = response.rows; this.userList = response.rows;
this.total = response.total; this.total = response.total;
this.loading = false; this.loading = false;

View File

@ -102,7 +102,7 @@
<el-table-column label="操作" width="250" fixed="right"class-name="small-padding fixed-width"> <el-table-column label="操作" width="250" fixed="right"class-name="small-padding fixed-width">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button @click="handleLoadXml(scope.row)" icon="el-icon-edit-outline" type="text" size="small">编辑</el-button> <el-button @click="handleLoadXml(scope.row)" icon="el-icon-edit-outline" type="text" size="small">编辑</el-button>
<el-button @click="handleAddForm(scope.row)" type="text" size="small" v-if="scope.row.formId == null"></el-button> <el-button @click="handleAddForm(scope.row)" icon="el-icon-edit-outline" type="text" size="small" v-if="scope.row.formId == null"></el-button>
<el-button @click="handleUpdateSuspensionState(scope.row)" icon="el-icon-video-pause" type="text" size="small" v-if="scope.row.suspensionState === 1"></el-button> <el-button @click="handleUpdateSuspensionState(scope.row)" icon="el-icon-video-pause" type="text" size="small" v-if="scope.row.suspensionState === 1"></el-button>
<el-button @click="handleUpdateSuspensionState(scope.row)" icon="el-icon-video-play" type="text" size="small" v-if="scope.row.suspensionState === 2"></el-button> <el-button @click="handleUpdateSuspensionState(scope.row)" icon="el-icon-video-play" type="text" size="small" v-if="scope.row.suspensionState === 2"></el-button>
<el-button @click="handleDelete(scope.row)" icon="el-icon-delete" type="text" size="small" v-hasPermi="['system:deployment:remove']"></el-button> <el-button @click="handleDelete(scope.row)" icon="el-icon-delete" type="text" size="small" v-hasPermi="['system:deployment:remove']"></el-button>
@ -401,7 +401,7 @@ export default {
/** 启动流程 */ /** 启动流程 */
handleDefinitionStart(row){ handleDefinitionStart(row){
definitionStart(row.id).then(res =>{ definitionStart(row.id).then(res =>{
this.msgSuccess(res.msg); this.$modal.msgSuccess(res.msg);
}) })
}, },
/** 挂载表单弹框 */ /** 挂载表单弹框 */
@ -435,7 +435,7 @@ export default {
submitFormDeploy(row){ submitFormDeploy(row){
this.formDeployParam.formId = row.formId; this.formDeployParam.formId = row.formId;
addDeployForm(this.formDeployParam).then(res =>{ addDeployForm(this.formDeployParam).then(res =>{
this.msgSuccess(res.msg); this.$modal.msgSuccess(res.msg);
this.formDeployOpen = false; this.formDeployOpen = false;
this.getList(); this.getList();
}) })
@ -456,7 +456,7 @@ export default {
state: state state: state
} }
updateState(params).then(res => { updateState(params).then(res => {
this.msgSuccess(res.msg); this.$modal.msgSuccess(res.msg);
this.getList(); this.getList();
}); });
}, },
@ -476,13 +476,13 @@ export default {
if (valid) { if (valid) {
if (this.form.id != null) { if (this.form.id != null) {
updateDeployment(this.form).then(response => { updateDeployment(this.form).then(response => {
this.msgSuccess("修改成功"); this.$modal.msgSuccess("修改成功");
this.open = false; this.open = false;
this.getList(); this.getList();
}); });
} else { } else {
addDeployment(this.form).then(response => { addDeployment(this.form).then(response => {
this.msgSuccess("新增成功"); this.$modal.msgSuccess("新增成功");
this.open = false; this.open = false;
this.getList(); this.getList();
}); });
@ -501,7 +501,7 @@ export default {
return delDeployment(deploymentIds); return delDeployment(deploymentIds);
}).then(() => { }).then(() => {
this.getList(); this.getList();
this.msgSuccess("删除成功"); this.$modal.msgSuccess("删除成功");
}) })
}, },
/** 导出按钮操作 */ /** 导出按钮操作 */

View File

@ -12,6 +12,26 @@
</div> </div>
</el-col> </el-col>
</el-card> </el-card>
<!--审批正常流程-->
<el-dialog :title="completeTitle" :visible.sync="completeOpen" width="60%" append-to-body>
<el-form ref="taskForm" :model="taskForm">
<el-form-item prop="targetKey">
<!-- <el-row :gutter="24">-->
<flow-user v-if="checkSendUser" :checkType="checkType" @handleUserSelect="handleUserSelect"></flow-user>
<flow-role v-if="checkSendRole" @handleRoleSelect="handleRoleSelect"></flow-role>
<!-- </el-row>-->
</el-form-item>
<el-form-item label="处理意见" label-width="80px" prop="comment" :rules="[{ required: true, message: '请输入处理意见', trigger: 'blur' }]">
<el-input type="textarea" v-model="taskForm.comment" placeholder="请输入处理意见"/>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="completeOpen = false"> </el-button>
<el-button type="primary" @click="taskComplete"> </el-button>
</span>
</el-dialog>
<!--流程图--> <!--流程图-->
<el-card class="box-card"> <el-card class="box-card">
<div slot="header" class="clearfix"> <div slot="header" class="clearfix">
@ -29,6 +49,7 @@ import flow from '@/views/flowable/task/record/flow'
import "@riophae/vue-treeselect/dist/vue-treeselect.css"; import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import {listUser} from "@/api/system/user"; import {listUser} from "@/api/system/user";
import {flowFormData} from "@/api/flowable/process"; import {flowFormData} from "@/api/flowable/process";
import {getNextFlowNodeByStart} from "@/api/flowable/todo";
export default { export default {
name: "Record", name: "Record",
@ -69,12 +90,18 @@ export default {
}, },
formConf: {}, // formConf: {}, //
variables: [], // variables: [], //
completeTitle: null,
completeOpen: false,
checkSendUser: false, //
checkSendRole: false,//
checkType: 'single', //
}; };
}, },
created() { created() {
this.taskForm.deployId = this.$route.query && this.$route.query.deployId; this.taskForm.deployId = this.$route.query && this.$route.query.deployId;
// //
this.taskForm.procDefId = this.$route.query && this.$route.query.procDefId; this.taskForm.procDefId = this.$route.query && this.$route.query.procDefId;
this.getNextFlowNode(this.taskForm.deployId);
this.getFlowFormData(this.taskForm.deployId); this.getFlowFormData(this.taskForm.deployId);
// //
this.loadModelXml(this.taskForm.deployId); this.loadModelXml(this.taskForm.deployId);
@ -143,7 +170,7 @@ export default {
formData.formBtns = false; formData.formBtns = false;
if (this.taskForm.procDefId) { if (this.taskForm.procDefId) {
variables.variables = formData; variables.variables = formData;
// //
definitionStart(this.taskForm.procDefId, JSON.stringify(variables)).then(res => { definitionStart(this.taskForm.procDefId, JSON.stringify(variables)).then(res => {
this.msgSuccess(res.msg); this.msgSuccess(res.msg);
this.goBack(); this.goBack();
@ -151,6 +178,57 @@ export default {
} }
} }
}, },
/** 根据当前任务获取流程设计配置的下一步节点 */
getNextFlowNode(deploymentId) {
// todo
const params = {deploymentId: deploymentId}
getNextFlowNodeByStart(params).then(res => {
const data = res.data;
if (data) {
if (data.type === 'assignee') { //
this.checkSendUser = true;
this.checkType = "single";
} else if (data.type === 'candidateUsers') { // ()
this.checkSendUser = true;
this.checkType = "multiple";
} else if (data.type === 'candidateGroups') { // ()
this.checkSendRole = true;
} else if (data.type === 'multiInstance') { // ?
this.checkSendUser = true;
}
}
})
},
//
handleUserSelect(selection) {
if (selection) {
const selectVal = selection.map(item => item.userId);
if (selectVal instanceof Array) {
this.taskForm.values = {
"approval": selectVal.join(',')
}
} else {
this.taskForm.values = {
"approval": selectVal
}
}
}
},
//
handleRoleSelect(selection) {
if (selection) {
if (selection instanceof Array) {
const selectVal = selection.map(item => item.roleId);
this.taskForm.values = {
"approval": selectVal.join(',')
}
} else {
this.taskForm.values = {
"approval": selection
}
}
}
},
} }
}; };
</script> </script>

View File

@ -272,7 +272,7 @@ export default {
}, },
// //
handleUserSelect(selection) { handleUserSelect(selection) {
console.log(selection,"handleUserSelect") // console.log(selection,"handleUserSelect")
if (selection) { if (selection) {
const selectVal = selection.map(item => item.userId); const selectVal = selection.map(item => item.userId);
if (selectVal instanceof Array) { if (selectVal instanceof Array) {
@ -288,7 +288,7 @@ export default {
}, },
// //
handleRoleSelect(selection) { handleRoleSelect(selection) {
console.log(selection,"handleRoleSelect") // console.log(selection,"handleRoleSelect")
if (selection) { if (selection) {
if (selection instanceof Array) { if (selection instanceof Array) {
const selectVal = selection.map(item => item.roleId); const selectVal = selection.map(item => item.roleId);
@ -381,7 +381,7 @@ export default {
this.$modal.msgError("请输入审批意见!"); this.$modal.msgError("请输入审批意见!");
return; return;
} }
console.log(this.taskForm,"流程审批提交表单数据") // console.log(this.taskForm,"")
complete(this.taskForm).then(response => { complete(this.taskForm).then(response => {
this.$modal.msgSuccess(response.msg); this.$modal.msgSuccess(response.msg);
this.goBack(); this.goBack();