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

1、SignalAndMessage.vue原先vue2代码如下:

<template>
  <div class="panel-tab__content">
    <div class="panel-tab__content--title">
      <span><el-icon style="margin-right: 8px; color: #555555"><Menu /></el-icon>消息列表</span>
      <el-button size="small" type="primary" :icon="Plus" @click="openModel('message')">创建新消息</el-button>
    </div>
    <el-table :data="messageList" size="small" border>
      <el-table-column type="index" label="序号" width="60px" />
      <el-table-column label="消息ID" prop="id" max-width="300px" show-overflow-tooltip />
      <el-table-column label="消息名称" prop="name" max-width="300px" show-overflow-tooltip />
    </el-table>
    <div class="panel-tab__content--title" style="padding-top: 8px; margin-top: 8px; border-top: 1px solid #eeeeee">
      <span><el-icon style="margin-right: 8px; color: #555555"><Menu /></el-icon>信号列表</span>
      <el-button size="small" type="primary" :icon="Plus" @click="openModel('signal')">创建新信号</el-button>
    </div>
    <el-table :data="signalList" size="small" border>
      <el-table-column type="index" label="序号" width="60px" />
      <el-table-column label="信号ID" prop="id" max-width="300px" show-overflow-tooltip />
      <el-table-column label="信号名称" prop="name" max-width="300px" show-overflow-tooltip />
    </el-table>
    <el-dialog v-model="modelVisible" :title="modelConfig.title" :close-on-click-modal="false" width="400px" append-to-body destroy-on-close>
      <el-form :model="modelObjectForm" size="small" label-width="90px" >
        <el-form-item :label="modelConfig.idLabel">
          <el-input v-model="modelObjectForm.id" clearable />
        </el-form-item>
        <el-form-item :label="modelConfig.nameLabel">
          <el-input v-model="modelObjectForm.name" clearable />
        </el-form-item>
      </el-form>
      <template #footer>
        <el-button size="small" @click="modelVisible = false">取 消</el-button>
        <el-button size="small" type="primary" @click="addNewObject">保 存</el-button>
      </template>
    </el-dialog>
  </div>
</template>
<script>
import { Plus } from '@element-plus/icons-vue'
export default {
  name: 'SignalAndMassage',
  setup() {
    return {
      Plus
    }
  },
  data() {
    return {
      signalList: [],
      messageList: [],
      modelVisible: false,
      modelType: '',
      modelObjectForm: {}
    };
  },
  computed: {
    modelConfig() {
      if (this.modelType === 'message') {
        return { title: '创建消息', idLabel: '消息ID', nameLabel: '消息名称' };
      } else {
        return { title: '创建信号', idLabel: '信号ID', nameLabel: '信号名称' };
      }
    }
  },
  mounted() {
    this.initDataList();
  },
  methods: {
    initDataList() {
      this.rootElements = window.bpmnInstances.modeler.getDefinitions().rootElements;
      this.messageIdMap = {};
      this.signalIdMap = {};
      this.messageList = [];
      this.signalList = [];
      this.rootElements.forEach(el => {
        if (el.$type === 'bpmn:Message') {
          this.messageIdMap[el.id] = true;
          this.messageList.push({ ...el });
        }
        if (el.$type === 'bpmn:Signal') {
          this.signalIdMap[el.id] = true;
          this.signalList.push({ ...el });
        }
      });
    },
    openModel(type) {
      this.modelType = type;
      this.modelObjectForm = {};
      this.modelVisible = true;
    },
    addNewObject() {
      if (this.modelType === 'message') {
        if (this.messageIdMap[this.modelObjectForm.id]) {
          return this.$message.error('该消息已存在,请修改id后重新保存');
        }
        const messageRef = window.bpmnInstances.moddle.create('bpmn:Message', this.modelObjectForm);
        this.rootElements.push(messageRef);
      } else {
        if (this.signalIdMap[this.modelObjectForm.id]) {
          return this.$message.error('该信号已存在,请修改id后重新保存');
        }
        const signalRef = window.bpmnInstances.moddle.create('bpmn:Signal', this.modelObjectForm);
        this.rootElements.push(signalRef);
      }
      this.modelVisible = false;
      this.initDataList();
    }
  }
};
</script>

2、修改后的vue3代码如下:

<template>
  <div class="panel-tab__content">
    <div class="panel-tab__content--title">
      <span><el-icon style="margin-right: 8px; color: #555555"><Menu /></el-icon>消息列表</span>
      <el-button size="small" type="primary" :icon="Plus" @click="openModel('message')">创建新消息</el-button>
    </div>
    <el-table :data="messageList" size="small" border>
      <el-table-column type="index" label="序号" width="60px" />
      <el-table-column label="消息ID" prop="id" max-width="300px" show-overflow-tooltip />
      <el-table-column label="消息名称" prop="name" max-width="300px" show-overflow-tooltip />
    </el-table>
    <div class="panel-tab__content--title" style="padding-top: 8px; margin-top: 8px; border-top: 1px solid #eeeeee">
      <span><el-icon style="margin-right: 8px; color: #555555"><Menu /></el-icon>信号列表</span>
      <el-button size="small" type="primary" :icon="Plus" @click="openModel('signal')">创建新信号</el-button>
    </div>
    <el-table :data="signalList" size="small" border>
      <el-table-column type="index" label="序号" width="60px" />
      <el-table-column label="信号ID" prop="id" max-width="300px" show-overflow-tooltip />
      <el-table-column label="信号名称" prop="name" max-width="300px" show-overflow-tooltip />
    </el-table>
    <el-dialog v-model="dialogVisible" :title="modelConfig.title" :close-on-click-modal="false" width="400px" append-to-body destroy-on-close>
      <el-form :model="modelObjectForm" size="small" label-width="90px" >
        <el-form-item :label="modelConfig.idLabel">
          <el-input v-model="modelObjectForm.id" clearable />
        </el-form-item>
        <el-form-item :label="modelConfig.nameLabel">
          <el-input v-model="modelObjectForm.name" clearable />
        </el-form-item>
      </el-form>
      <template #footer>
        <el-button size="small" @click="dialogVisible = false">取 消</el-button>
        <el-button size="small" type="primary" @click="addNewObject">保 存</el-button>
      </template>
    </el-dialog>
  </div>
</template>
<script lang="ts" setup>
  import { Plus } from '@element-plus/icons-vue'
  defineOptions({ name: 'SignalAndMassage' })
  const signalList = ref<any[]>([])
  const messageList = ref<any[]>([])
  const dialogVisible = ref(false)
  const modelType = ref('')
  const modelObjectForm = ref<any>({})
  const rootElements = ref()
  const messageIdMap = ref()
  const signalIdMap = ref()
  const modelConfig = computed(() => {
    if (modelType.value === 'message') {
      return { title: '创建消息', idLabel: '消息ID', nameLabel: '消息名称' }
    } else {
      return { title: '创建信号', idLabel: '信号ID', nameLabel: '信号名称' }
    }
  })
  const bpmnInstances = () => (window as any)?.bpmnInstances
  const initDataList = () => {
    console.log(window, 'window')
    rootElements.value = bpmnInstances().modeler.getDefinitions().rootElements
    messageIdMap.value = {}
    signalIdMap.value = {}
    messageList.value = []
    signalList.value = []
    rootElements.value.forEach((el) => {
      if (el.$type === 'bpmn:Message') {
        messageIdMap.value[el.id] = true
        messageList.value.push({ ...el })
      }
      if (el.$type === 'bpmn:Signal') {
        signalIdMap.value[el.id] = true
        signalList.value.push({ ...el })
      }
    })
  }
  const openModel = (type) => {
    modelType.value = type
    modelObjectForm.value = {}
    dialogVisible.value = true
  }
  const addNewObject = () => {
    if (modelType.value === 'message') {
      if (messageIdMap.value[modelObjectForm.value.id]) {
        message.error('该消息已存在,请修改id后重新保存')
      }
      const messageRef = bpmnInstances().moddle.create('bpmn:Message', modelObjectForm.value)
      rootElements.value.push(messageRef)
    } else {
      if (signalIdMap.value[modelObjectForm.value.id]) {
        message.error('该信号已存在,请修改id后重新保存')
      }
      const signalRef = bpmnInstances().moddle.create('bpmn:Signal', modelObjectForm.value)
      rootElements.value.push(signalRef)
    }
    dialogVisible.value = false
    initDataList()
  }
  onMounted(() => {
    initDataList()
  })
</script>

3、效果图如下:

相关文章
|
4天前
|
缓存 JavaScript 前端开发
Vue 3的响应式系统
【5月更文挑战第31天】Vue 3的响应式系统
8 1
|
4天前
|
JavaScript 前端开发 API
vue2 /vue3【nextTick】的使用方法及实现原理,一文全搞懂!
vue2 /vue3【nextTick】的使用方法及实现原理,一文全搞懂!
|
4天前
|
JavaScript 开发者
[vue2/vue3] -- 深入剖析v-model的原理、父子组件双向绑定的多种写法
[vue2/vue3] -- 深入剖析v-model的原理、父子组件双向绑定的多种写法
[vue2/vue3] -- 深入剖析v-model的原理、父子组件双向绑定的多种写法
|
4天前
|
JavaScript API
vue3父子组件相互调用方法详解
vue3父子组件相互调用方法详解
|
11天前
|
JavaScript API
Vue3 基础语法
该内容介绍了Vue项目的创建和Vue3的语法、响应式API、生命周期、组件通信及跨组件通信方法。包括使用`npm init vue@latest`创建项目,`npm install`初始化,Vue3的`setup`语法,`reactive`、`ref`、`computed`和`watch`的用法,生命周期图解,以及父子组件间的数据传递。此外,还提到了Vue3中使用`provide`和`inject`进行跨层数据传递,以及通过Pinia库进行状态管理。
37 0
Vue3 基础语法
|
14天前
|
JavaScript 定位技术 API
在 vue3 中使用高德地图
在 vue3 中使用高德地图
23 0
|
15天前
vue3 键盘事件 回车发送消息,ctrl+回车 内容换行
const textarea = textInput.value.textarea; //获取输入框元素
29 3
|
17天前
|
JavaScript 前端开发 CDN
vue3速览
vue3速览
29 0
|
17天前
|
设计模式 JavaScript 前端开发
Vue3报错Property “xxx“ was accessed during render but is not defined on instance
Vue3报错Property “xxx“ was accessed during render but is not defined on instance
|
17天前
|
JavaScript 前端开发 安全
Vue3官方文档速通(下)
Vue3官方文档速通(下)
29 0