基于若依的ruoyi-nbcio流程管理系统增加流程节点配置(三)

更多ruoyi-nbcio功能请看演示系统

gitee源代码地址

前后端代码: https://gitee.com/nbacheng/ruoyi-nbcio

演示地址:RuoYi-Nbcio后台管理系统

     这一节主要是对每个流程节点的字段规则设置与操作规则设置,目前也是只针对自定义业务表单。

    1、前端部分

    流程规则的修改界面


    
        
          
            
              
                
              
              
                
                
              
              
                
                
              
              
                
                
              
            
          

          
            
              
                
              
              
                
                
              
            
          

        
        
    

获取流程规则数据

/** 修改规则操作 */
    handleRule(row) {
      this.loading = true;
      console.log("handleRule row=",row);
      getConfigRule(row).then(response => {
        this.loading = false;
        console.log("getConfigRule response=",response);
        this.customRuleList = response.data.customRuleVoList;
        this.operateRuleList = response.data.operateRuleVoList;
        this.activeName = "form";
        this.ruleOpen = true;
        this.title = "修改节点规则";
      });
    },

流程规则数据修改

/** 提交按钮 */
    submitRuleForm() {
      this.buttonLoading = true;
      let ruleVo = {
        customRuleVoList: this.customRuleList,
        operateRuleVoList: this.operateRuleList
      }
      updateConfigRule(ruleVo).then(response => {
        this.$modal.msgSuccess("修改成功");
        this.ruleOpen = false;
        this.getList();
      }).finally(() => {
        this.buttonLoading = false;
      });
    },

2、后端部分

     先查询,没有就增加,queryConfigRule部分

@Override
	@Transactional(rollbackFor = Exception.class)
	public WfRuleVo queryConfigRule(WfFlowConfigBo bo) {
		
		WfRuleVo ruleVo = new WfRuleVo();
		//获取自定义表单规则列表
		if(bo.getAppType().equalsIgnoreCase("ZDYYW")) { //自定义业务
			List customRuleList = customRuleMapper.selectRuleByConfigId(bo.getId());
			if(ObjectUtils.isNotEmpty(customRuleList) && customRuleList.size()>0) {
				ruleVo.setCustomRuleVoList(customRuleList);	
			}
			else {//为空添加默认表单规则设置
				if(StringUtils.isNotEmpty(bo.getFormKey())) {//获取自定义表信息
					Long formId = Convert.toLong(StringUtils.substringAfter(bo.getFormKey(), "key_"));
					WfCustomFormVo customFormVo = customFormService.queryById(formId);
					if(ObjectUtils.isNotEmpty(customFormVo)) {
						Long tableId = customFormVo.getTableId();
						List tableColumnList = genTableService.selectGenTableColumnListByTableId(tableId);
						if(ObjectUtils.isNotEmpty(tableColumnList)) {
							long i = 0L;
							List customAddRuleList = new ArrayList();
							for(GenTableColumn tableColumn : tableColumnList) {
								WfCustomRuleBo customRuleBo = new WfCustomRuleBo();
								WfCustomRuleVo customRuleVo = new WfCustomRuleVo();
								customRuleBo.setColCode(tableColumn.getColumnName());
								customRuleBo.setColName(tableColumn.getColumnComment());
								customRuleBo.setConfigId(bo.getId());
								customRuleBo.setJavaField(tableColumn.getJavaField());
								customRuleBo.setJavaType(tableColumn.getJavaType());
								customRuleBo.setAttribute("1"); //默认只读
								i = i + 1;
								customRuleBo.setSort(i);
								customRuleService.insertByBo(customRuleBo);
								BeanUtils.copyProperties(customRuleBo, customRuleVo);
								customAddRuleList.add(customRuleVo);
								
							}
							ruleVo.setCustomRuleVoList(customAddRuleList);
						}
					}
				}
			}
		} else if(bo.getAppType().equalsIgnoreCase("OA")) {
			
		}
		
		//获取操作规则列表
		List operateRuleList = operateRuleMapper.selectRuleByConfigId(bo.getId());
		if(ObjectUtils.isNotEmpty(operateRuleList) && operateRuleList.size()>0) {
			ruleVo.setOperateRuleVoList(operateRuleList);
		}
		else {//为空添加默认操作表单规则设置
			//从字典里获取操作类型
			List sysDictDataList = sysDictDataMapper.selectDictDataListByDictType("wf_oper_type");
			if(ObjectUtils.isNotEmpty(sysDictDataList)) {
				long i = 0L;
				List operateAddRuleList = new ArrayList();
				for(SysDictData sysDictData : sysDictDataList) {
					WfOperateRuleBo operateRuleBo = new WfOperateRuleBo();
					WfOperateRuleVo operateRuleVo = new WfOperateRuleVo();
					operateRuleBo.setConfigId(bo.getId());
					operateRuleBo.setOpeType(sysDictData.getDictValue());
					operateRuleBo.setOpeName(sysDictData.getDictLabel());
					if(StringUtils.equalsAnyIgnoreCase(sysDictData.getDictValue(), "agree")    ||
					   StringUtils.equalsAnyIgnoreCase(sysDictData.getDictValue(), "delegate") ||
					   StringUtils.equalsAnyIgnoreCase(sysDictData.getDictValue(), "transfer") ||
					   StringUtils.equalsAnyIgnoreCase(sysDictData.getDictValue(), "reback")   ||
					   StringUtils.equalsAnyIgnoreCase(sysDictData.getDictValue(), "reject")) {
						operateRuleBo.setIsEnable("1"); //默认上面的操作开启
					}
					else {
						operateRuleBo.setIsEnable("0"); //其它默认关闭
					}
					i = i + 1;
					operateRuleBo.setSort(i);
					operateRuleService.insertByBo(operateRuleBo);
					BeanUtils.copyProperties(operateRuleBo, operateRuleVo);
					operateAddRuleList.add(operateRuleVo);
					
				}
				ruleVo.setOperateRuleVoList(operateAddRuleList);
			}
		}
		return ruleVo;
	}

更新部分

@Override
	@Transactional(rollbackFor = Exception.class)
	public Boolean updateConfigRule(WfRuleVo vo) {
		List customRuleList = vo.getCustomRuleVoList();
		List operateRuleList = vo.getOperateRuleVoList();
		if(ObjectUtils.isNotEmpty(customRuleList) && ObjectUtils.isNotEmpty(operateRuleList) ) {
			for(WfCustomRuleVo customRuleVo : customRuleList) {
				WfCustomRuleBo customRuleBo = new WfCustomRuleBo();
				BeanUtils.copyProperties(customRuleVo,customRuleBo);
				customRuleService.updateByBo(customRuleBo);
			}
            for(WfOperateRuleVo operateRuleVo : operateRuleList) {
            	WfOperateRuleBo operateRuleBo = new WfOperateRuleBo();
            	BeanUtils.copyProperties(operateRuleVo,operateRuleBo);
            	operateRuleService.updateByBo(operateRuleBo);
			}
			return true;
		}
		
		return false;
	}

3、效果图如下:

基于若依的ruoyi-nbcio流程管理系统增加流程节点配置(三)_第1张图片

基于若依的ruoyi-nbcio流程管理系统增加流程节点配置(三)_第2张图片

你可能感兴趣的:(ruoyi-nbcio,若依,flowable,ruoyi-nbcio,若依,flowable)