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、效果图


相关文章
|
7月前
|
JavaScript 前端开发 安全
Vue 3
Vue 3以组合式API、Proxy响应式系统和全面TypeScript支持,重构前端开发范式。性能优化与生态协同并进,兼顾易用性与工程化,引领Web开发迈向高效、可维护的新纪元。(238字)
1003 139
|
12月前
|
缓存 JavaScript PHP
斩获开发者口碑!SnowAdmin:基于 Vue3 的高颜值后台管理系统,3 步极速上手!
SnowAdmin 是一款基于 Vue3/TypeScript/Arco Design 的开源后台管理框架,以“清新优雅、开箱即用”为核心设计理念。提供角色权限精细化管理、多主题与暗黑模式切换、动态路由与页面缓存等功能,支持代码规范自动化校验及丰富组件库。通过模块化设计与前沿技术栈(Vite5/Pinia),显著提升开发效率,适合团队协作与长期维护。项目地址:[GitHub](https://github.com/WANG-Fan0912/SnowAdmin)。
1316 5
|
7月前
|
缓存 JavaScript 算法
Vue 3性能优化
Vue 3 通过 Proxy 和编译优化提升性能,但仍需遵循最佳实践。合理使用 v-if、key、computed,避免深度监听,利用懒加载与虚拟列表,结合打包优化,方可充分发挥其性能优势。(239字)
533 1
|
8月前
|
开发工具 iOS开发 MacOS
基于Vite7.1+Vue3+Pinia3+ArcoDesign网页版webos后台模板
最新版研发vite7+vue3.5+pinia3+arco-design仿macos/windows风格网页版OS系统Vite-Vue3-WebOS。
930 11
|
7月前
|
JavaScript 安全
vue3使用ts传参教程
Vue 3结合TypeScript实现组件传参,提升类型安全与开发效率。涵盖Props、Emits、v-model双向绑定及useAttrs透传属性,建议明确声明类型,保障代码质量。
604 0
|
9月前
|
缓存 前端开发 大数据
虚拟列表在Vue3中的具体应用场景有哪些?
虚拟列表在 Vue3 中通过仅渲染可视区域内容,显著提升大数据列表性能,适用于 ERP 表格、聊天界面、社交媒体、阅读器、日历及树形结构等场景,结合 `vue-virtual-scroller` 等工具可实现高效滚动与交互体验。
962 1
|
9月前
|
缓存 JavaScript UED
除了循环引用,Vue3还有哪些常见的性能优化技巧?
除了循环引用,Vue3还有哪些常见的性能优化技巧?
485 0
|
10月前
|
JavaScript
vue3循环引用自已实现
当渲染大量数据列表时,使用虚拟列表只渲染可视区域的内容,显著减少 DOM 节点数量。
226 0
|
11月前
|
JavaScript 前端开发 UED
Vue 表情包输入组件的实现代码:支持自定义表情库、快捷键发送和输入框联动的聊天表情解决方案
本文详细介绍了在 Vue 项目中实现一个功能完善、交互友好的表情包输入组件的方法,并提供了具体的应用实例。组件设计包含表情分类展示、响应式布局、与输入框的交互及样式定制等功能。通过核心技术实现,如将表情插入输入框光标位置和点击外部关闭选择器,确保用户体验流畅。同时探讨了性能优化策略,如懒加载和虚拟滚动,以及扩展性方案,如自定义主题和国际化支持。最终,展示了如何在聊天界面中集成该组件,为用户提供丰富的表情输入体验。
822 8
|
11月前
|
JavaScript 前端开发 UED
Vue 表情包输入组件实现代码及详细开发流程解析
这是一篇关于 Vue 表情包输入组件的使用方法与封装指南的文章。通过安装依赖、全局注册和局部使用,可以快速集成表情包功能到 Vue 项目中。文章还详细介绍了组件的封装实现、高级配置(如自定义表情列表、主题定制、动画效果和懒加载)以及完整集成示例。开发者可根据需求扩展功能,例如 GIF 搜索或自定义表情上传,提升用户体验。资源链接提供进一步学习材料。
740 1