ruoyi-nbcio-plus基于vue3的flowable定时边界事件代码升级修改(三)

简介: ruoyi-nbcio-plus基于vue3的flowable定时边界事件代码升级修改(三)

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

gitee源代码地址

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

演示地址:RuoYi-Nbcio后台管理系统http://218.75.87.38:9666/

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

gitee源代码地址

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

前端代码:https://gitee.com/nbacheng/nbcio-vue.git

在线演示(包括H5) : http://218.75.87.38:9888

上一节虽然显示正常了,但还是有点问题,就是不能正确地进行数据保存与更新

6、数据变化后的更新操作

   因为原先的代码基于vue2,所以有些逻辑判断与更新还是需要重新写的,否则有问题

   一个是逻辑判断修改成响应式变量的值获取type.value

  另外就是更新的时候bpmnElement.value还是要转成toRaw

//时间事件定义类型修改
  const updateTime = (type,value) => {
    //获取节点的子节点 timerEventDefinition
    //console.log("updatetime type.value=",type.value)
    let timerEventDef = bpmnInstances().bpmnElement.businessObject.eventDefinitions[0]
    console.log("updatetime timerEventDef=",timerEventDef)
    const timeCycle = bpmnInstances().moddle.create("bpmn:FormalExpression", { body:value });
    const timeDate = bpmnInstances().moddle.create("bpmn:FormalExpression", { body:value });
    const timeDuration = bpmnInstances().moddle.create("bpmn:FormalExpression", { body:value });
    if (type.value == 'timeCycle') {
      bpmnInstances().modeling.updateModdleProperties(toRaw(bpmnElement.value),timerEventDef,{timeDate:null})
      bpmnInstances().modeling.updateModdleProperties(toRaw(bpmnElement.value),timerEventDef,{timeDuration:null})
      bpmnInstances().modeling.updateModdleProperties(toRaw(bpmnElement.value),timerEventDef,{timeCycle })
    }
    else if (type.value == 'timeDate') {
      console.log("updatetime timeDate")
      bpmnInstances().modeling.updateModdleProperties(toRaw(bpmnElement.value),timerEventDef,{timeCycle:null})
      bpmnInstances().modeling.updateModdleProperties(toRaw(bpmnElement.value),timerEventDef,{timeDuration:null})
      bpmnInstances().modeling.updateModdleProperties(toRaw(bpmnElement.value),timerEventDef,{ timeDate })
    }
    else if (type.value == 'timeDuration') {
      bpmnInstances().modeling.updateModdleProperties(toRaw(bpmnElement.value),timerEventDef,{timeDate:null})
      bpmnInstances().modeling.updateModdleProperties(toRaw(bpmnElement.value),timerEventDef,{timeCycle:null})
      bpmnInstances().modeling.updateModdleProperties(toRaw(bpmnElement.value),timerEventDef,{ timeDuration })
    }
  }

7、更新后的再次点击获取数据

这个部分主要是逻辑判断要更新一下,如下,原先的判断会有逻辑问题

const getElementLoop = (businessObject) => { //获取定时边界事件原有值
    console.log("getElementLoop businessObject=",businessObject)
    //console.log("bpmnInstances().bpmnElement.businessObject=",bpmnInstances().bpmnElement.businessObject);
    if(businessObject.eventDefinitions && businessObject.eventDefinitions.length>0){
      if(businessObject.eventDefinitions[0].$type == 'bpmn:TimerEventDefinition') {
        if(businessObject.eventDefinitions[0].timeDuration) {
          timeDefinitionType.value = "timeDuration"
          FormalExpression.value = businessObject.eventDefinitions[0].timeDuration.body
        }
        else if(businessObject.eventDefinitions[0].timeDate) {
          timeDefinitionType.value = "timeDate"
          FormalExpression.value = businessObject.eventDefinitions[0].timeDate.body
        }
        else if(businessObject.eventDefinitions[0].timeCycle) {
          timeDefinitionType.value = "timeCycle"
          FormalExpression.value = businessObject.eventDefinitions[0].timeCycle.body
        }
      }
    }
  }

8、通过上面修改好后,整个保存,再次显示都正常了

<template>
  <div class="panel-tab__content">
    <!--目前只处理定时边界事件 -->
    <el-form size="mini" label-width="90px" @submit.native.prevent >
      <el-form-item label="事件类型">
        <el-select v-model="timeDefinitionType" @change="changeTimerType"  v-if= "businessObject.eventDefinitions && businessObject.eventDefinitions[0].$type.indexOf('TimerEventDefinition') !== -1"  >
          <!--bpmn:TimerEventDefinition-->
          <el-option label="指定时间" value="timeDate" />
          <el-option label="持续时间" value="timeDuration" />
          <el-option label="周期执行" value="timeCycle" />
        </el-select>
      </el-form-item>
      <template v-if="timeDefinitionType != ''">
        <el-form-item label="时间设置" required>
            <el-tooltip>
              <el-input size="mini" type="string" v-model="FormalExpression" @change="updateTimeValue"></el-input>
              <template #content>
                事件类型配置说明<br>
                1.指定时间(timeDate):触发事件的时间,如:2022-12-16T11:12:16 <br>
                2.持续时间(timeDuration):指定时器之前需等待多长时间,使用ISO 8601规定的格式<br>
                 (由BPMN 2.0规定),如PT5M(等待5分钟),也支持表达式${duration},<br>
                 这样你就可以通过流程变量来影响定时器定义<br>
                3.周期执行(timeCycle):指定重复执行的间隔,可以用来定期启动流程实例,<br>
                或为超时时间发送多个提醒。timeCycle元素可以使用两种格式。<br>
                第一种是 ISO 8601 标准的格式。示例值(R3/PT5M)(重复3次,<br>
                每次间隔5分钟),或也可以用cron表达式指定timeCycle,如从整点开始,<br>
                每10分钟执行一次(0 0/10 * * * ?)<br>
              </template>
            </el-tooltip>
        </el-form-item>
      </template>
    </el-form>
  </div>
</template>
<script lang="ts" setup>
  defineOptions({ name: 'BoundaryEvent' })
  const props = defineProps({
    businessObject: Object,
    type: String
  })
  //const prefix = inject('prefix')
  const bpmnElement = ref(null)
  const bpmnInstances = () => (window as any)?.bpmnInstances
  const timeDefinitionType = ref('')
  const FormalExpression = ref('')
  const getElementLoop = (businessObject) => { //获取定时边界事件原有值
    console.log("getElementLoop businessObject=",businessObject)
    //console.log("bpmnInstances().bpmnElement.businessObject=",bpmnInstances().bpmnElement.businessObject);
    if(businessObject.eventDefinitions && businessObject.eventDefinitions.length>0){
      if(businessObject.eventDefinitions[0].$type == 'bpmn:TimerEventDefinition') {
        if(businessObject.eventDefinitions[0].timeDuration) {
          timeDefinitionType.value = "timeDuration"
          FormalExpression.value = businessObject.eventDefinitions[0].timeDuration.body
        }
        else if(businessObject.eventDefinitions[0].timeDate) {
          timeDefinitionType.value = "timeDate"
          FormalExpression.value = businessObject.eventDefinitions[0].timeDate.body
        }
        else if(businessObject.eventDefinitions[0].timeCycle) {
          timeDefinitionType.value = "timeCycle"
          FormalExpression.value = businessObject.eventDefinitions[0].timeCycle.body
        }
      }
    }
  }
  const changeTimerType = (type) => {
    timeDefinitionType.value = type
  }
  const updateTimeValue = (value) => {
    updateTime(timeDefinitionType,value);
  }
  //时间事件定义类型修改
  const updateTime = (type,value) => {
    //获取节点的子节点 timerEventDefinition
    //console.log("updatetime type.value=",type.value)
    let timerEventDef = bpmnInstances().bpmnElement.businessObject.eventDefinitions[0]
    console.log("updatetime timerEventDef=",timerEventDef)
    const timeCycle = bpmnInstances().moddle.create("bpmn:FormalExpression", { body:value });
    const timeDate = bpmnInstances().moddle.create("bpmn:FormalExpression", { body:value });
    const timeDuration = bpmnInstances().moddle.create("bpmn:FormalExpression", { body:value });
    if (type.value == 'timeCycle') {
      bpmnInstances().modeling.updateModdleProperties(toRaw(bpmnElement.value),timerEventDef,{timeDate:null})
      bpmnInstances().modeling.updateModdleProperties(toRaw(bpmnElement.value),timerEventDef,{timeDuration:null})
      bpmnInstances().modeling.updateModdleProperties(toRaw(bpmnElement.value),timerEventDef,{timeCycle })
    }
    else if (type.value == 'timeDate') {
      console.log("updatetime timeDate")
      bpmnInstances().modeling.updateModdleProperties(toRaw(bpmnElement.value),timerEventDef,{timeCycle:null})
      bpmnInstances().modeling.updateModdleProperties(toRaw(bpmnElement.value),timerEventDef,{timeDuration:null})
      bpmnInstances().modeling.updateModdleProperties(toRaw(bpmnElement.value),timerEventDef,{ timeDate })
    }
    else if (type.value == 'timeDuration') {
      bpmnInstances().modeling.updateModdleProperties(toRaw(bpmnElement.value),timerEventDef,{timeDate:null})
      bpmnInstances().modeling.updateModdleProperties(toRaw(bpmnElement.value),timerEventDef,{timeCycle:null})
      bpmnInstances().modeling.updateModdleProperties(toRaw(bpmnElement.value),timerEventDef,{ timeDuration })
    }
  }
  watch(
    () => props.businessObject,
    (val) => {
      bpmnElement.value = bpmnInstances().bpmnElement
      getElementLoop(val)
    },
    { immediate: true }
  )
  onBeforeUnmount(() => {
    bpmnElement.value = null;
  })
</script>

9、效果图


相关文章
|
1月前
|
缓存 JavaScript PHP
斩获开发者口碑!SnowAdmin:基于 Vue3 的高颜值后台管理系统,3 步极速上手!
SnowAdmin 是一款基于 Vue3/TypeScript/Arco Design 的开源后台管理框架,以“清新优雅、开箱即用”为核心设计理念。提供角色权限精细化管理、多主题与暗黑模式切换、动态路由与页面缓存等功能,支持代码规范自动化校验及丰富组件库。通过模块化设计与前沿技术栈(Vite5/Pinia),显著提升开发效率,适合团队协作与长期维护。项目地址:[GitHub](https://github.com/WANG-Fan0912/SnowAdmin)。
260 5
|
10天前
|
JavaScript 前端开发 UED
Vue 表情包输入组件实现代码及详细开发流程解析
这是一篇关于 Vue 表情包输入组件的使用方法与封装指南的文章。通过安装依赖、全局注册和局部使用,可以快速集成表情包功能到 Vue 项目中。文章还详细介绍了组件的封装实现、高级配置(如自定义表情列表、主题定制、动画效果和懒加载)以及完整集成示例。开发者可根据需求扩展功能,例如 GIF 搜索或自定义表情上传,提升用户体验。资源链接提供进一步学习材料。
43 1
|
16天前
|
JavaScript 前端开发 UED
Vue 表情包输入组件的实现代码:支持自定义表情库、快捷键发送和输入框联动的聊天表情解决方案
本文详细介绍了在 Vue 项目中实现一个功能完善、交互友好的表情包输入组件的方法,并提供了具体的应用实例。组件设计包含表情分类展示、响应式布局、与输入框的交互及样式定制等功能。通过核心技术实现,如将表情插入输入框光标位置和点击外部关闭选择器,确保用户体验流畅。同时探讨了性能优化策略,如懒加载和虚拟滚动,以及扩展性方案,如自定义主题和国际化支持。最终,展示了如何在聊天界面中集成该组件,为用户提供丰富的表情输入体验。
60 8
|
1月前
|
JavaScript API 容器
Vue 3 中的 nextTick 使用详解与实战案例
Vue 3 中的 nextTick 使用详解与实战案例 在 Vue 3 的日常开发中,我们经常需要在数据变化后等待 DOM 更新完成再执行某些操作。此时,nextTick 就成了一个不可或缺的工具。本文将介绍 nextTick 的基本用法,并通过三个实战案例,展示它在表单验证、弹窗动画、自动聚焦等场景中的实际应用。
110 17
|
2月前
|
JavaScript 前端开发 算法
Vue 3 和 Vue 2 的区别及优点
Vue 3 和 Vue 2 的区别及优点
|
30天前
|
JavaScript 前端开发 API
Vue 2 与 Vue 3 的区别:深度对比与迁移指南
Vue.js 是一个用于构建用户界面的渐进式 JavaScript 框架,在过去的几年里,Vue 2 一直是前端开发中的重要工具。而 Vue 3 作为其升级版本,带来了许多显著的改进和新特性。在本文中,我们将深入比较 Vue 2 和 Vue 3 的主要区别,帮助开发者更好地理解这两个版本之间的变化,并提供迁移建议。 1. Vue 3 的新特性概述 Vue 3 引入了许多新特性,使得开发体验更加流畅、灵活。以下是 Vue 3 的一些关键改进: 1.1 Composition API Composition API 是 Vue 3 的核心新特性之一。它改变了 Vue 组件的代码结构,使得逻辑组
113 0
|
2月前
|
JavaScript
vue实现任务周期cron表达式选择组件
vue实现任务周期cron表达式选择组件
253 4
|
12天前
|
JavaScript 前端开发 开发者
Vue 自定义进度条组件封装及使用方法详解
这是一篇关于自定义进度条组件的使用指南和开发文档。文章详细介绍了如何在Vue项目中引入、注册并使用该组件,包括基础与高级示例。组件支持分段配置(如颜色、文本)、动画效果及超出进度提示等功能。同时提供了完整的代码实现,支持全局注册,并提出了优化建议,如主题支持、响应式设计等,帮助开发者更灵活地集成和定制进度条组件。资源链接已提供,适合前端开发者参考学习。
102 17
|
17天前
|
JavaScript 数据可视化 前端开发
基于 Vue 与 D3 的可拖拽拓扑图技术方案及应用案例解析
本文介绍了基于Vue和D3实现可拖拽拓扑图的技术方案与应用实例。通过Vue构建用户界面和交互逻辑,结合D3强大的数据可视化能力,实现了力导向布局、节点拖拽、交互事件等功能。文章详细讲解了数据模型设计、拖拽功能实现、组件封装及高级扩展(如节点类型定制、连接样式优化等),并提供了性能优化方案以应对大数据量场景。最终,展示了基础网络拓扑、实时更新拓扑等应用实例,为开发者提供了一套完整的实现思路和实践经验。
102 21
|
15天前
|
监控 JavaScript 前端开发
Vue 文件批量下载组件封装完整使用方法及优化方案解析
本文详细介绍了批量下载功能的技术实现与组件封装方案。主要包括两种实现方式:**前端打包方案(基于file-saver和jszip)** 和 **后端打包方案**。前者通过前端直接将文件打包为ZIP下载,适合小文件场景;后者由后端生成ZIP文件流返回,适用于大文件或大量文件下载。同时,提供了可复用的Vue组件`BatchDownload`,支持进度条、失败提示等功能。此外,还扩展了下载进度监控和断点续传等高级功能,并针对跨域、性能优化及用户体验改进提出了建议。可根据实际需求选择合适方案并快速集成到项目中。
104 17