手写顺序流程图组件

效果图

完整代码

<template><div><div class="container" :style="{ width: `${spacingX * (colNum - 1) + itemWidth * colNum}px` }"><divv-for="(item, i) in recordList":key="i"class="list-box":style="{marginTop: i < colNum ? '0' : `${spacingY}px`,marginRight: i % (2 * colNum) === colNum - 1 || i % (2 * colNum) === colNum ? '0' : `${spacingX}px`,order: orderList[i] && orderList[i].order,visibility: orderList[i] && orderList[i].itemHide ? 'hidden' : 'visible'}"><div class="cont-box" :style="{ width: itemWidth + 'px', height: itemHeight + 'px', backgroundColor: '#16a085' }">{{ item }}</div><div v-if="i !== listLen - 1" class="arrow-box" :style="arrowStyle[orderList[i] && orderList[i].arrow]"><div class="line-tip" /><div class="arrow-tip" /></div></div></div></div>
</template><script>
export default {name: 'FlowPath',data() {return {itemWidth: 75, // item宽度itemHeight: 75, // item高度colNum: 1, // 显示的列数spacingX: 40, // 列间距spacingY: 40, // 行间距rawList: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18], // 原始数据recordList: [], // 列表数据arrowStyle: { right: {}, down: {}, left: {}}, // 箭头样式orderList: [], // 列表排序序号listLen: '' // 列表数据长度}},mounted() {this.listLen = this.rawList.lengththis.initFun() // 初始化方法window.addEventListener('resize', this.initFun) // 页面宽度变化监听器},beforeDestroy() {window.removeEventListener('resize', this.initFun) // 组件销毁时移除 resize 事件监听器,避免内存泄漏},methods: {/* 初始化方法 */initFun() {const pageWidth = document.documentElement.clientWidth // 获取页面宽度(可视区域宽度)const minTotalWidth = this.itemWidth + this.spacingX // 每个 item(包含间距) 期望的最小总宽度为 minTotalWidth(单位:px)const newNum = Math.floor(pageWidth / minTotalWidth) // 计算 colNum,向下取整this.colNum = Math.max(newNum, 1) // 限制 colNum 的最小值,比如至少为 1 列// 更新箭头样式和列表样式,因为 colNum 变化了,相关布局依赖 colNum 列数this.setArrowStyle() // 设置箭头样式this.setOrderList() // 设置列表样式},/* 设置箭头样式 */setArrowStyle() {const left = {width: this.spacingX + 'px',top: this.itemHeight / 2 + 'px',left: -this.spacingX + 'px'}const right = {width: this.spacingX + 'px',top: this.itemHeight / 2 + 'px',right: -this.spacingX + 'px',transform: 'rotate(180deg)'}const down = {width: this.spacingY + 'px',left: this.itemWidth / 2 + 'px',bottom: -this.spacingY + 'px',transform: 'rotate(-90deg)',transformOrigin: 0}this.arrowStyle = { right, left, down }},/* 设置列表样式 */setOrderList() {this.recordList = JSON.parse(JSON.stringify(this.rawList))this.orderList = [] // 列表排序序号const n = this.colNum // 显示的列数const dbn = n * 2 // 列数 * 2// 添加占位的 item 项const arrLen = this.listLenconst remainder = (arrLen - 1) % dbnif (remainder >= n && remainder < dbn) {const diff = dbn - 1 - remainderfor (let i = 0; i < diff; i++) {this.orderList[arrLen + i] = {itemHide: true,order: arrLen + i}this.recordList[arrLen + i] = null}}// 设置 item 的箭头方向和顺序this.recordList.map((item, index) => {const i = index % dbn	// 余数if (i >= 0 && i < n) {this.orderList[index] = {order: index,arrow: i !== n - 1 ? 'right' : 'down'} // 不用改变顺序} else {this.orderList[index] = {order: index + ((n - 1) - 2 * (i - n)), // i - n 是与最近一侧的距离arrow: i !== dbn - 1 ? 'left' : 'down',itemHide: this.orderList[index]?.itemHide} // 需要改变顺序}})}}
}
</script><style scoped lang="scss">
.container {display: flex;flex-wrap: wrap;box-sizing: border-box;overflow: hidden;.list-box {position: relative;font-size: 20px;box-sizing: border-box;.cont-box {}}
}
/* 箭头区域 */
.arrow-box {$bgColor: #303133;position: absolute;// 线条样式.line-tip {position: absolute;top: 50%;transform: translateY(-50%);left: 3px;width: 90%;height: 2px;background-color: $bgColor;}// 箭头样式.arrow-tip {position: absolute;top: 50%;transform: translateY(-50%);left: 1px;width: 0;height: 0;border-top: 8px solid transparent;border-bottom: 8px solid transparent;border-right: 8px solid $bgColor;}
}
</style>

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/891682.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

多个线程处理不同的数据,等线程都完成后再进行下一步操作

现在有三个任务,三个任务之间没有关联关系,但是第四个任务要等前三个完成之后才能进行,于是使用多线程完成前三个任务节省时间 示例代码: public void saveDataByOnlineTimeNew(LocalDateTime startTime, LocalDateTime endTime) {Objects.requireNonNull(startTime, "开…

Spring Boot自定义中文Banner

Spring Boot自定义中文Banner在线生成工具 https://www.bootschool.net/https://www.bootschool.net/1.选择喜欢的复制 2.在resources文件下新建banner文件&#xff0c;粘贴即可 <_> ::::: …

SpringCloud源码-Ribbon

一、Spring定制化RestTemplate&#xff0c;预留出RestTemplate定制化扩展点 org.springframework.cloud.client.loadbalancer.LoadBalancerAutoConfiguration 二、Ribbon定义RestTemplate Ribbon扩展点功能 org.springframework.cloud.netflix.ribbon.RibbonAutoConfiguratio…

风力涡轮机缺陷检测数据集,86.6%准确识别率,11921张图片,支持yolo,PASICAL VOC XML,COCO JSON格式的标注

风力涡轮机缺陷检测数据集&#xff0c;86.6&#xff05;准确识别率&#xff0c;11921张图片&#xff0c;支持yolo&#xff0c;PASICAL VOC XML&#xff0c;COCO JSON格式的标注 数据集下载 yolov11&#xff1a; https://download.csdn.net/download/pbymw8iwm/90206849 yolov…

Vue 针对浏览器参数过长实现浏览器参数加密解密

1、首先安装crypto-js npm install crypto-js 1、在router/index.js中添加如下代码 在utils工具类添加如下 encryption.js源码 import CryptoJS from crypto-js import CryptoJSCore from crypto-js/core import AES from crypto-js/aes import ZeroPadding from crypto-js/…

antdesignvue vue3全局loading

这里封装为loading.js文件&#xff0c;代码赋值即可用 import { createApp, h } from vue import { Spin } from ant-design-vuelet instance null// 定义全屏遮罩样式 const style {position: fixed,left: 0,top: 0,width: 100%,height: 100%,display: flex,justifyContent…

WPF的一些控件的触发事件记录

<c1:C1ComboBox Width"230" ItemsSource"{Binding ReplaceWayList}" Style"{StaticResource ListSearch-C1ComboBox}" SelectedValueChanged"C1ComboBox_SelectedValueChanged"&#xff0c; 下拉框事件&#xff0c;SelectedValu…

设计模式-创建型设计模式总结

创建型设计模式&#xff08;Creational Design Patterns&#xff09;是 设计模式 中的一类&#xff0c;专注于如何实例化对象或类。它们提供了一些优雅的方式来创建对象&#xff0c;允许程序在对象创建过程中更灵活地进行管理&#xff0c;从而提高系统的扩展性和维护性。 创建…

Transformer算法实现IMDB文本分类任务和WMT14机器翻译任务

Transformer算法详解与PyTorch实现 目录 Transformer算法详解与PyTorch实现1. Transformer算法简介1.1 Transformer的优势1.2 Transformer的应用场景2. Transformer的核心组件2.1 自注意力机制(Self-Attention)2.2 多头注意力机制(Multi-Head Attention)2.3 位置编码(Posi…

Python脚本实现通过Vector VN1630A CAN盒子与ECU通信

1 安装 python-can 包 安装命令如下&#xff1a; pip install python-can安装完成后可用下面命令查看是否安装成功及版本。 pip show python-canName: python-can Version: 4.4.2 Summary: Controller Area Network interface module for Python Home-page: https://github.…

React虚拟DOM:理解和应用

写在前面 在现代前端开发中&#xff0c;React 是一个非常流行的 JavaScript 库&#xff0c;用于构建用户界面。它引入了一个名为“虚拟 DOM”&#xff08;Virtual DOM&#xff09;的概念&#xff0c;这个概念对于 React 的高效性能和易用性至关重要。本文将深入探讨 React Vir…

VSCode 插件全解析:解锁编码新维度

文章目录 前言一、插件的重要性二、插件分类三、创建自己的插件结语 前言 Visual Studio Code&#xff08;简称 VSCode&#xff09;是一款由微软开发的免费开源文本编辑器&#xff0c;支持多种编程语言和各种扩展插件。它以其轻量级、跨平台和强大的可定制性而闻名&#xff0c…

Oracle 创建本地用户,授予权限,创建表并插入数据

目录 一. 用户的种类二. 切换session为PDB三. 创建用户并授予权限四. 创建表空间五. 为用户分配默认表空间并指定表空间配额六. 通过创建的用户进行登录七. 创建脚本&#xff0c;简化登录八. 查看用户信息九. 创建表&#xff0c;并插入数据9.1 查看当前用户的schema9.2 插入数据…

普及组集训数据结构--并查集

P1551 亲戚 - 洛谷 | 计算机科学教育新生态 并查集就是把所有相关联的量串成一串珠子&#xff0c;抽象来说就是&#xff1a; 把此类相关联的量当作节点&#xff0c;两个节点之间连接一条无向边&#xff0c;所形成的图 例题算法流程&#xff1a; 在此定义“族长”就是一个树的…

pytorch张量高级索引介绍

PyTorch 中&#xff0c;张量索引操作可以使用高级索引&#xff08;advanced indexing&#xff09;&#xff0c;其中索引可以是另一个张量。使用这种索引方式时&#xff0c;返回值的维度由索引张量的形状和原始张量的形状共同决定。以下是具体的规则和解释&#xff1a; 1. 基本…

ESP32-S3遇见OpenAI:OpenAI官方发布ESP32嵌入式实时RTC SDK

目录 OpenAI RTC SDK简介应用场景详解智能家居控制系统个人健康助手教育玩具 技术亮点解析低功耗设计快速响应高精度RTC安全性保障开发者指南 最近&#xff0c;OpenAI官方发布了一款针对ESP32-S3的嵌入式实时RTC&#xff08;实时时钟&#xff09;SDK&#xff0c;这标志着ESP32-…

JS基础 -- 数组 (对象 / 数组 / 类数组 / 对象数组)的遍历

一、数组&#xff1a; 数组是复杂数据类型&#xff0c;用于存储一组有序的数据。 1、创建数组&#xff1a; ① 使用 new 关键字&#xff1a; let arr new Array() // 创建一个长度为0的空数组 let arrLength new Array(5) // 创建一个长度为5的空数组② 字面量形式&#…

【期末复习】一、操作系统概论

题型 选择题 论述题 综合分析题(计算,证明) 算法分析题(根据程序代码分析) 1.方面 操作系统在计算机系统中主要涉及硬件、软件和数据这三个重要方面。 2.操作系统发展历史 手工操作阶段(1940s) 联机批处理系统阶段(1950s) 脱机批处理系统阶段(1950s) 多道…

基于STM32F103的USART的原理及应用(一)(实现手机BLE和MCU进行通信)

一&#xff0c;查阅数据手册&#xff0c;找到对应的IO口和外设总线并配置好外设源文件 想了解USART的具体原理的小伙伴请进传送门&#xff1a;&#xff08;总结&#xff09;STM32中USART原理及应用&#xff08;PC、BLE、ESP8266通信实现&#xff09;-CSDN博客 二&#xff0c;打…

如何在Java开发中选择适合的高性能工具库?

如何在Java开发中选择适合的高性能工具库&#xff1f; 在 Java 开发中选择适合的高性能工具库需要综合考虑多个因素&#xff0c;以下是详细的步骤和要点&#xff1a; 一、明确项目需求 功能需求 首先要确定项目需要的功能。例如&#xff0c;如果主要是进行 JSON 数据处理&a…