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


相关文章
|
2天前
|
JavaScript
Vue3搜索框(InputSearch)
这篇文章介绍了如何在Vue 3中创建一个具有搜索、清除、加载状态等多功能的搜索框组件(InputSearch),并提供了组件的配置选项、事件处理和使用示例。
Vue3搜索框(InputSearch)
|
2天前
|
JavaScript API 容器
Vue3加载条(LoadingBar)
这是一个基于 Vue 的加载条组件,提供了丰富的自定义选项和方法。通过简单的 API,可以控制加载条的开始、结束及错误状态。支持设置容器类名、样式、颜色等属性,并可通过 `start`、`finish` 和 `error` 方法来触发不同状态。
Vue3加载条(LoadingBar)
|
2天前
|
JavaScript
Vue3滚动条(Scrollbar)
这是一个基于 Vue 的自定义滚动条组件 Scrollbar.vue,提供了丰富的配置选项和方法。通过参数如 `contentClass`、`size` 和 `trigger` 等,可以灵活控制滚动条的样式和行为。
Vue3滚动条(Scrollbar)
|
2天前
|
JavaScript
Vue3分段控制器(Segmented)
这是一个基于 Vue 的分段控制器组件 `Segmented`,支持多种选项和自定义渲染。通过 `v-model` 绑定当前选中值,并提供 `block`、`disabled` 和 `size` 等属性来调整样式。
Vue3分段控制器(Segmented)
|
2天前
|
JavaScript
Vue3渐变文字(GradientText)
该文档介绍了一个基于 Vue 的渐变文字组件 `GradientText`,允许用户通过配置参数实现不同样式和尺寸的文字渐变效果。支持自定义起始和结束颜色、渐变角度及多种预设类型(如 `primary`、`info` 等)。
Vue3渐变文字(GradientText)
|
1天前
|
JavaScript 开发者 UED
Vue.js 错误处理与调试:跟上技术潮流,摆脱开发困扰,成为代码大神不是梦!
【8月更文挑战第30天】在 Vue.js 开发中,错误处理与调试至关重要。本文将对比 Vue 的全局错误捕获机制 `Vue.config.errorHandler` 和组件内 `watch` 监听数据变化的方式,并介绍 Vue 开发者工具、控制台打印 (`console.log`) 以及代码断点 (`debugger`) 等调试方法。此外,还将探讨如何通过自定义错误页面提升用户体验。通过这些技巧的对比,帮助开发者灵活选择适合的策略,确保应用稳定性和开发效率。
|
1天前
|
JavaScript 前端开发
揭秘Vue.js组件魔法:如何轻松驾驭前端代码,让维护变得轻而易举?
【8月更文挑战第30天】本文探讨了如何利用Vue.js的组件化开发提升前端代码的可维护性。组件化开发将复杂页面拆分为独立、可复用的组件,提高开发效率和代码可维护性。Vue.js支持全局及局部组件注册,并提供了多种组件间通信方式如props、事件等。通过示例展示了组件定义、数据传递及复用组合的方法,强调了组件化开发在实际项目中的重要性。
|
2天前
|
JavaScript API 开发者
关于维护vue3的响应式的那些事:unref、toRef、toRefs、toRaw、toValue
总结:Vue 3的Composition API提供的这些工具,大大增强了我们对响应式状态的操作能力,让状态管理变得更为灵活和高效。`unref`、`toRef`、`toRefs` 以及 `toRaw` 各有其用途和应用场景,灵活应用这些工具,将有助于开发出更为强大和响应式的Vue应用。在开发过程中,正确区分和使用这些API,能够有效提高开发效率以及应用的性能。
6 0
|
2天前
|
JavaScript 开发者
[译] 监听第三方 Vue 组件的生命周期钩子
[译] 监听第三方 Vue 组件的生命周期钩子
|
2天前
|
JavaScript 前端开发
[译] 复用 Vue 组件的 6 层手段
[译] 复用 Vue 组件的 6 层手段