From 295a46662eb35bb6a663dc4385775e4da8ac0a45 Mon Sep 17 00:00:00 2001 From: tony <846249920@qq.com> Date: Thu, 15 Dec 2022 18:24:12 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=BC=80=E5=A7=8B=E8=8A=82=E7=82=B9?= =?UTF-8?q?=E8=8E=B7=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/FlowDefinitionController.java | 2 +- .../controller/FlowTaskController.java | 6 + .../ruoyi/flowable/domain/vo/FlowTaskVo.java | 2 + .../ruoyi/flowable/flow/FindNextNodeUtil.java | 42 ++++- .../flowable/service/IFlowTaskService.java | 2 + .../impl/FlowDefinitionServiceImpl.java | 14 +- .../service/impl/FlowTaskServiceImpl.java | 39 +++++ ruoyi-ui/src/api/flowable/todo.js | 9 ++ .../src/components/Process/PropertyPanel.vue | 2 +- .../Process/components/nodePanel/task.vue | 148 ++++-------------- .../src/components/flow/Expression/index.vue | 12 +- ruoyi-ui/src/components/flow/Role/index.vue | 109 ++++++------- ruoyi-ui/src/components/flow/User/index.vue | 51 +++--- .../src/views/flowable/definition/index.vue | 14 +- .../flowable/task/myProcess/send/index.vue | 80 +++++++++- .../views/flowable/task/todo/detail/index.vue | 6 +- 16 files changed, 311 insertions(+), 227 deletions(-) diff --git a/ruoyi-flowable/src/main/java/com/ruoyi/flowable/controller/FlowDefinitionController.java b/ruoyi-flowable/src/main/java/com/ruoyi/flowable/controller/FlowDefinitionController.java index 67895020..74bf3196 100644 --- a/ruoyi-flowable/src/main/java/com/ruoyi/flowable/controller/FlowDefinitionController.java +++ b/ruoyi-flowable/src/main/java/com/ruoyi/flowable/controller/FlowDefinitionController.java @@ -155,7 +155,7 @@ public class FlowDefinitionController { } - @ApiOperation(value = "根据流程定义id启动流程实例") + @ApiOperation(value = "发起流程") @PostMapping("/start/{procDefId}") public AjaxResult start(@ApiParam(value = "流程定义id") @PathVariable(value = "procDefId") String procDefId, @ApiParam(value = "变量集合,json对象") @RequestBody Map variables) { diff --git a/ruoyi-flowable/src/main/java/com/ruoyi/flowable/controller/FlowTaskController.java b/ruoyi-flowable/src/main/java/com/ruoyi/flowable/controller/FlowTaskController.java index 0d1cccbd..85f6bb0f 100644 --- a/ruoyi-flowable/src/main/java/com/ruoyi/flowable/controller/FlowTaskController.java +++ b/ruoyi-flowable/src/main/java/com/ruoyi/flowable/controller/FlowTaskController.java @@ -153,6 +153,12 @@ public class FlowTaskController { return flowTaskService.getNextFlowNode(flowTaskVo); } + @ApiOperation(value = "流程发起时获取下一节点") + @PostMapping(value = "/nextFlowNodeByStart") + public AjaxResult getNextFlowNodeByStart(@RequestBody FlowTaskVo flowTaskVo) { + return flowTaskService.getNextFlowNodeByStart(flowTaskVo); + } + /** * 生成流程图 * diff --git a/ruoyi-flowable/src/main/java/com/ruoyi/flowable/domain/vo/FlowTaskVo.java b/ruoyi-flowable/src/main/java/com/ruoyi/flowable/domain/vo/FlowTaskVo.java index c4834300..33cc3ec7 100644 --- a/ruoyi-flowable/src/main/java/com/ruoyi/flowable/domain/vo/FlowTaskVo.java +++ b/ruoyi-flowable/src/main/java/com/ruoyi/flowable/domain/vo/FlowTaskVo.java @@ -32,6 +32,8 @@ public class FlowTaskVo { @ApiModelProperty("节点") private String targetKey; + private String deploymentId; + @ApiModelProperty("流程变量信息") private Map values; diff --git a/ruoyi-flowable/src/main/java/com/ruoyi/flowable/flow/FindNextNodeUtil.java b/ruoyi-flowable/src/main/java/com/ruoyi/flowable/flow/FindNextNodeUtil.java index bc31c4a0..1c80cdc6 100644 --- a/ruoyi-flowable/src/main/java/com/ruoyi/flowable/flow/FindNextNodeUtil.java +++ b/ruoyi-flowable/src/main/java/com/ruoyi/flowable/flow/FindNextNodeUtil.java @@ -5,16 +5,15 @@ import com.googlecode.aviator.Expression; //import com.greenpineyu.fel.FelEngine; //import com.greenpineyu.fel.FelEngineImpl; //import com.greenpineyu.fel.context.FelContext; +import org.apache.commons.lang3.StringUtils; import org.flowable.bpmn.model.Process; import org.flowable.bpmn.model.*; import org.flowable.engine.RepositoryService; import org.flowable.engine.TaskService; +import org.flowable.engine.repository.Model; import org.flowable.engine.repository.ProcessDefinition; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Map; +import java.util.*; /** * @author Xuan xuan @@ -41,6 +40,41 @@ public class FindNextNodeUtil { return data; } + /** + * 启动流程时获取下一步骤的用户任务 + * + * @param repositoryService + * @param map + * @return + */ + public static List getNextUserTasksByStart(RepositoryService repositoryService, ProcessDefinition processDefinition, Map map) { + List data = new ArrayList<>(); + BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinition.getId()); + Process mainProcess = bpmnModel.getMainProcess(); + Collection 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 flowElements, FlowElement flowElement, Map map, List nextUser) { //如果是结束节点 if (flowElement instanceof EndEvent) { diff --git a/ruoyi-flowable/src/main/java/com/ruoyi/flowable/service/IFlowTaskService.java b/ruoyi-flowable/src/main/java/com/ruoyi/flowable/service/IFlowTaskService.java index a2ee19a1..5815b23a 100644 --- a/ruoyi-flowable/src/main/java/com/ruoyi/flowable/service/IFlowTaskService.java +++ b/ruoyi-flowable/src/main/java/com/ruoyi/flowable/service/IFlowTaskService.java @@ -165,6 +165,8 @@ public interface IFlowTaskService { */ AjaxResult getNextFlowNode(FlowTaskVo flowTaskVo); + AjaxResult getNextFlowNodeByStart(FlowTaskVo flowTaskVo); + /** * 流程初始化表单 * @param deployId diff --git a/ruoyi-flowable/src/main/java/com/ruoyi/flowable/service/impl/FlowDefinitionServiceImpl.java b/ruoyi-flowable/src/main/java/com/ruoyi/flowable/service/impl/FlowDefinitionServiceImpl.java index 2f8b98ec..9e6a04c2 100644 --- a/ruoyi-flowable/src/main/java/com/ruoyi/flowable/service/impl/FlowDefinitionServiceImpl.java +++ b/ruoyi-flowable/src/main/java/com/ruoyi/flowable/service/impl/FlowDefinitionServiceImpl.java @@ -200,13 +200,13 @@ public class FlowDefinitionServiceImpl extends FlowServiceFactory implements IFl identityService.setAuthenticatedUserId(sysUser.getUserId().toString()); variables.put(ProcessConstants.PROCESS_INITIATOR, ""); ProcessInstance processInstance = runtimeService.startProcessInstanceById(procDefId, variables); - // 给第一步申请人节点设置任务执行人和意见 todo:第一个节点不设置为申请人节点有点问题? - Task task = taskService.createTaskQuery().processInstanceId(processInstance.getProcessInstanceId()).singleResult(); - if (Objects.nonNull(task)) { - taskService.addComment(task.getId(), processInstance.getProcessInstanceId(), FlowComment.NORMAL.getType(), sysUser.getNickName() + "发起流程申请"); -// taskService.setAssignee(task.getId(), sysUser.getUserId().toString()); - taskService.complete(task.getId(), variables); - } +// // 给第一步申请人节点设置任务执行人和意见 todo:第一个节点不设置为申请人节点有点问题? +// Task task = taskService.createTaskQuery().processInstanceId(processInstance.getProcessInstanceId()).singleResult(); +// if (Objects.nonNull(task)) { +// taskService.addComment(task.getId(), processInstance.getProcessInstanceId(), FlowComment.NORMAL.getType(), sysUser.getNickName() + "发起流程申请"); +//// taskService.setAssignee(task.getId(), sysUser.getUserId().toString()); +// taskService.complete(task.getId(), variables); +// } return AjaxResult.success("流程启动成功"); } catch (Exception e) { e.printStackTrace(); diff --git a/ruoyi-flowable/src/main/java/com/ruoyi/flowable/service/impl/FlowTaskServiceImpl.java b/ruoyi-flowable/src/main/java/com/ruoyi/flowable/service/impl/FlowTaskServiceImpl.java index 9f53bb98..1bc508ca 100644 --- a/ruoyi-flowable/src/main/java/com/ruoyi/flowable/service/impl/FlowTaskServiceImpl.java +++ b/ruoyi-flowable/src/main/java/com/ruoyi/flowable/service/impl/FlowTaskServiceImpl.java @@ -970,6 +970,45 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask 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 nextUserTask = FindNextNodeUtil.getNextUserTasksByStart(repositoryService, processDefinition, new HashMap<>()); + if (CollectionUtils.isNotEmpty(nextUserTask)) { + for (UserTask userTask : nextUserTask) { + MultiInstanceLoopCharacteristics multiInstance = userTask.getLoopCharacteristics(); + // 会签节点 + if (Objects.nonNull(multiInstance)) { + List 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); + } + /** * 流程初始化表单 * diff --git a/ruoyi-ui/src/api/flowable/todo.js b/ruoyi-ui/src/api/flowable/todo.js index 16e78797..6ea6c2cd 100644 --- a/ruoyi-ui/src/api/flowable/todo.js +++ b/ruoyi-ui/src/api/flowable/todo.js @@ -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) { return request({ diff --git a/ruoyi-ui/src/components/Process/PropertyPanel.vue b/ruoyi-ui/src/components/Process/PropertyPanel.vue index 334c2b15..ce58af41 100644 --- a/ruoyi-ui/src/components/Process/PropertyPanel.vue +++ b/ruoyi-ui/src/components/Process/PropertyPanel.vue @@ -125,7 +125,7 @@ export default { }) this.modeler.on('element.click', e => { const { element } = e - console.log(element) + // console.log(element) if (element.type === 'bpmn:Process') { this.element = element } diff --git a/ruoyi-ui/src/components/Process/components/nodePanel/task.vue b/ruoyi-ui/src/components/Process/components/nodePanel/task.vue index dbcd190e..d09f85d8 100644 --- a/ruoyi-ui/src/components/Process/components/nodePanel/task.vue +++ b/ruoyi-ui/src/components/Process/components/nodePanel/task.vue @@ -18,30 +18,35 @@ @@ -99,7 +104,7 @@ :close-on-press-escape="false" :show-close="false" > - + 取 消 确 定 @@ -169,6 +174,7 @@ export default { checkType: 'single', // 选中的值 checkValues: null, + // 数据回显 selectValues: null, // 用户列表 userList: this.users, @@ -219,49 +225,11 @@ export default { dic: _this.userTypeOption, 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', name: 'checkSingleUser', label: '指定人员', // rules: [{ required: true, message: '指定人员不能为空' }], - // dic: { data: _this.users, label: 'nickName', value: 'userId' }, show: !!_this.showConfig.assignee && _this.formData.userType === 'assignee' }, { @@ -385,47 +353,6 @@ export default { } 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) { if (val === '') val = null this.updateProperties({ 'flowable:async': val }) @@ -504,10 +431,10 @@ export default { this.hasMultiInstance = false } }, - // 数据回显 + // 设计器右侧表单数据回显 getCheckValues(){ 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 businessObject = that.element.businessObject; // 指定用户 @@ -526,33 +453,22 @@ export default { const val = attrs["flowable:candidateUsers"]; if (attrs["flowable:dataType"] === "dynamic") { this.checkValues = that.expList.find(item => item.expression == val).name; + this.selectValues = that.expList.filter(item => item.expression == val).id; } else { - const array = []; - const vals = val.split(','); - vals.forEach(key => { - const user = that.userList.find(item => item.userId == key) - if (user) { - array.push(user.nickName); - } - }) - this.checkValues = array.join(','); - this.selectValues = array.join(','); + const newArr = that.userList.filter(i => val.split(',').includes(i.userId)) + this.checkValues = newArr.map(item => item.nickName).join(','); + this.selectValues = newArr.map(item => item.userId).join(','); } } else if (businessObject.hasOwnProperty("candidateGroups")) { // 候选角色信息 const val = businessObject["candidateGroups"]; if (attrs["flowable:dataType"] === "dynamic") { this.checkValues = that.expList.find(item => item.expression == val).name; + this.selectValues = that.expList.filter(item => item.expression == val).id; } else { - const array = []; - const vals = val.split(','); - vals.forEach(key => { - const role = that.groupList.find(item => item.roleId == key) - if (role) { - array.push(role.roleName); - } - }) - this.checkValues = array.join(','); + const newArr = that.groupList.filter(i => val.split(',').includes(i.roleId)) + this.checkValues = newArr.map(item => item.roleName).join(','); + this.selectValues = newArr.map(item => item.roleId).join(','); } } }, diff --git a/ruoyi-ui/src/components/flow/Expression/index.vue b/ruoyi-ui/src/components/flow/Expression/index.vue index 8586596e..238a1460 100755 --- a/ruoyi-ui/src/components/flow/Expression/index.vue +++ b/ruoyi-ui/src/components/flow/Expression/index.vue @@ -57,9 +57,10 @@ export default { dicts: ['sys_common_status'], // 接受父组件的值 props: { + // 回显数据传值 selectValues: { - type: Number, - default: 0, + type: Number | String, + default: null, required: false } }, @@ -91,16 +92,15 @@ export default { expression: null, status: null, }, - radioSelected: this.selectValues + radioSelected: null // 单选框传值 }; }, watch: { selectValues: { - immediate: true, handler(newVal) { - console.log(newVal,"selectValues") this.radioSelected = newVal - } + }, + immediate: true, } }, created() { diff --git a/ruoyi-ui/src/components/flow/Role/index.vue b/ruoyi-ui/src/components/flow/Role/index.vue index 6bf8dd70..9b0221bc 100644 --- a/ruoyi-ui/src/components/flow/Role/index.vue +++ b/ruoyi-ui/src/components/flow/Role/index.vue @@ -16,7 +16,7 @@ - + @@ -66,9 +66,17 @@ export default { dicts: ['sys_normal_disable'], // 接受父组件的值 props: { - checkType: String, - default: 'multiple', - required: false + // 回显数据传值 + selectValues: { + type: Number | String | Array, + default: null, + required: false + }, + checkType: { + type: String, + default: 'multiple', + required: true + }, }, data() { return { @@ -91,41 +99,6 @@ export default { title: "", // 是否显示弹出层 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: { pageNum: 1, @@ -136,13 +109,38 @@ export default { }, // 表单参数 form: {}, - defaultProps: { - children: "children", - label: "label" - }, - radioSelected:'' + radioSelected: null, // 单选框传值 + selectRoleList: null // 回显数据传值 }; }, + 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() { this.getList(); }, @@ -150,7 +148,7 @@ export default { /** 查询角色列表 */ getList() { this.loading = true; - listRole(this.addDateRange(this.queryParams, this.dateRange)).then(response => { + listRole(this.queryParams).then(response => { this.roleList = response.rows; this.total = response.total; 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) { - this.ids = selection.map(item => item.roleId); + const idList = selection.map(item => item.roleId); const nameList = selection.map(item => item.roleName); - console.log( this.ids,"handleRoleSelect"); - this.$emit('handleRoleSelect',this.ids.join(','),nameList.join(',')); + this.$emit('handleRoleSelect', idList.join(','), nameList.join(',')); }, // 单选框选中数据 handleSingleRoleSelect(selection) { - this.radioSelected = selection.roleId;//点击当前行时,radio同样有选中效果 - const name = selection.roleName;//点击当前行时,radio同样有选中效果 - console.log(this.radioSelected.toString() ,"handleRoleSelect"); - this.$emit('handleRoleSelect',this.radioSelected.toString(),name); + this.radioSelected = selection.roleId; + const roleName = selection.roleName; + this.$emit('handleRoleSelect', this.radioSelected.toString(), roleName); }, /** 搜索按钮操作 */ handleQuery() { @@ -186,7 +174,6 @@ export default { }, /** 重置按钮操作 */ resetQuery() { - this.dateRange = []; this.handleQuery(); }, } diff --git a/ruoyi-ui/src/components/flow/User/index.vue b/ruoyi-ui/src/components/flow/User/index.vue index b10b072c..b0abad01 100644 --- a/ruoyi-ui/src/components/flow/User/index.vue +++ b/ruoyi-ui/src/components/flow/User/index.vue @@ -53,7 +53,7 @@ 重置 - + @@ -97,11 +97,13 @@ export default { components: { Treeselect }, // 接受父组件的值 props: { + // 回显数据传值 selectValues: { - type: Number | String, - default: 0, + type: Number | String | Array, + default: null, required: false }, + // 表格类型 checkType: { type: String, default: 'multiple', @@ -133,14 +135,6 @@ export default { open: false, // 部门名称 deptName: undefined, - // 默认密码 - initPassword: undefined, - // 日期范围 - dateRange: [], - // 岗位选项 - postOptions: [], - // 角色选项 - roleOptions: [], // 表单参数 form: {}, defaultProps: { @@ -166,7 +160,8 @@ export default { { key: 5, label: `状态`, visible: true }, { key: 6, label: `创建时间`, visible: true } ], - radioSelected:null + radioSelected: null, // 单选框传值 + selectUserList: null // 回显数据传值 }; }, watch: { @@ -175,25 +170,41 @@ export default { this.$refs.tree.filter(val); }, selectValues: { - immediate: true, handler(newVal) { - console.log(newVal,"user-selectValues") - this.radioSelected = newVal - } + if (newVal instanceof Number) { + 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() { this.getList(); this.getDeptTree(); - this.getConfigKey("sys.user.initPassword").then(response => { - this.initPassword = response.msg; - }); }, methods: { /** 查询用户列表 */ getList() { this.loading = true; - listUser(this.addDateRange(this.queryParams, this.dateRange)).then(response => { + listUser(this.queryParams).then(response => { this.userList = response.rows; this.total = response.total; this.loading = false; diff --git a/ruoyi-ui/src/views/flowable/definition/index.vue b/ruoyi-ui/src/views/flowable/definition/index.vue index 9bf22bc6..56354ede 100644 --- a/ruoyi-ui/src/views/flowable/definition/index.vue +++ b/ruoyi-ui/src/views/flowable/definition/index.vue @@ -102,7 +102,7 @@