基于Jeecgboot3.6.3的vue3版本的流程中仿钉钉流程的鼠标拖动功能支持

因为这个项目license问题无法开源,更多技术支持与服务请加入我的知识星球。

1、因为原先仿钉钉流程里不能进行鼠标拖动来查看流程,所以根据作者提供的信息进行修改,在hooks下增加下面文件useDraggableScroll.ts

javascript 复制代码
import { ref, onMounted, onBeforeUnmount, type Ref } from 'vue'

export function useDraggableScroll(containerRef: Ref<HTMLElement | null>) {
  const isDragging = ref(false);
  let startX: number, startY: number;
  let scrollLeft: number, scrollTop: number;

  const onMouseDown = (e: MouseEvent) => {
    if (!containerRef.value) return;
    isDragging.value = true;
    startX = e.pageX;
    startY = e.pageY;
    scrollLeft = containerRef.value.scrollLeft;
    scrollTop = containerRef.value.scrollTop;
    document.addEventListener('mousemove', onMouseMove);
    document.addEventListener('mouseup', onMouseUp);
  };

  const onMouseMove = (e: MouseEvent) => {
    if (!isDragging.value || !containerRef.value) return;
    const deltaX = e.pageX - startX;
    const deltaY = e.pageY - startY;
    containerRef.value.scrollLeft = scrollLeft - deltaX;
    containerRef.value.scrollTop = scrollTop - deltaY;
  };

  const onMouseUp = () => {
    isDragging.value = false;
    document.removeEventListener('mousemove', onMouseMove);
    document.removeEventListener('mouseup', onMouseUp);
  };

  onMounted(() => {
    containerRef.value?.addEventListener('mousedown', onMouseDown);
  });

  onBeforeUnmount(() => {
    containerRef.value?.removeEventListener('mousedown', onMouseDown);
  });

  return {
    isDragging,
  };
}

2、在lowflow\flowDesign\index修改增加相应的操作

import { useDraggableScroll } from '@/views/lowflow/hooks/useDraggableScroll'

const designerContainerRef = ref<HTMLElement | null>(null)

useDraggableScroll(designerContainerRef);

<div class="designer-container cursor-default active:cursor-grabbing" ref="designerContainerRef">

designer-container {

--flow-bg-color: v-bind(bgColor);

position: relative;

display: flex;

flex-direction: row;

height: 100%;

width: 100%;

overflow: auto;

background-color: var(--flow-bg-color);

padding: 80px 0;

3、ModelDesigner.vue的样式做下面的跳转,以便满足拖动等界面要求

javascript 复制代码
.el-dialog.is-fullscreen.ddDialog {
      overflow: hidden;
    }
    .ddDialog .el-dialog__body {
      height: 95%;
      overflow: auto;
    }

4、效果图

相关推荐
Yolanda944 小时前
【项目经验】钉钉免密登录实现
前端·javascript·钉钉
Yolanda949 小时前
【教程技巧】钉钉自定义机器人新建及url获取流程
机器人·钉钉
无法长大9 小时前
Mac M1 环境下使用 Rust Tauri 将 Vue3 项目打包成 APK 完整指南
android·前端·macos·rust·vue3·tauri·打包apk
淡笑沐白1 天前
Vue3使用ElementPlus实现菜单的无限递归
javascript·vue3·elementplus
Sapphire~1 天前
Vue3-18 生命周期(vue2+vue3)
vue3
Sapphire~2 天前
Vue3-17 父子组件使用props传值
vue3
gjxDaniel3 天前
钉钉是什么?
钉钉·生活
小圣贤君3 天前
在 Electron 应用中优雅接入 DeepSeek AI:从零到一的完整实践指南
人工智能·electron·vue3·ai写作·deepseek
Sapphire~4 天前
Vue3-14 watch监视对象及对象属性,watchEffect
vue3
技术宅星云4 天前
7. vue3-element-admin 二次开发图文教程
vue3·element-admin·后端开箱即用前端框架