vue 实战 区域内小组件元素拖拽 示例

<template><div><el-button type="primary" @click="showDialog = true">快捷布局</el-button><el-dialog title="快捷布局配置" :visible.sync="showDialog"><el-row :gutter="20"><el-col><el-card class="box-card" header="开始面板引流区"><draggable tag="div" class="buttons-container" v-model="drainComponents" ><el-button v-for="component in drainComponents" :key="component.comId" class="button" :style="{ backgroundColor: component.color }"><div class="button-content"><div>{{ component.name }}</div><div class="component-id">{{ component.comId }}</div></div></el-button></draggable></el-card></el-col><el-col><el-card class="box-card" header="开始面板数据区"><draggable tag="div" class="buttons-container" v-model="dataComponents" ><el-button v-for="component in dataComponents" :key="component.comId" class="button" :style="{ backgroundColor: component.color }"><div class="button-content"><div>{{ component.name }}</div><div class="component-id">{{ component.comId }}</div></div></el-button></draggable></el-card></el-col><el-col><el-card class="box-card" header="生活中默认区域"><draggable tag="div" class="buttons-container" v-model="liveComponents" ><el-button v-for="component in liveComponents" :key="component.comId" class="button" :style="{ backgroundColor: component.color }"><div class="button-content"><div>{{ component.name }}</div><div class="component-id">{{ component.comId }}</div></div></el-button></draggable></el-card></el-col></el-row><span slot="footer" class="dialog-footer"><el-button @click="showDialog = false">取消</el-button><el-button type="primary" @click="saveLayout">确定</el-button></span></el-dialog></div></template><script>import draggable from 'vuedraggable';// 生成柔和颜色的函数const generateSoftColor = () => {const hue = Math.floor(Math.random() * 360);const saturation = 60 + Math.random() * 20; // 饱和度在60%-80%之间const lightness = 70 + Math.random() * 20; // 亮度在70%-90%之间return `hsl(${hue}, ${saturation}%, ${lightness}%)`;};// 通用的转换函数const convertDataList = (dataList) => {return dataList.map(item => ({comId: item.comId,name: item.name,weight: item.weight,color: generateSoftColor()}));};const sortedDataList = (dataList) => {return dataList.slice().sort((a, b) => b.weight - a.weight);}// 数据列表const dataList1 = [{ comId: '1000009', name: '对方如果', property: 0, type: 0, weight: 4 },{ comId: '1000004', name: '辅导费人', property: 0, type: 0, weight: 1 },{ comId: '1000010', name: '电电风扇', property: 0, type: 0, weight: 2 },{ comId: '1000006', name: '小组件', property: 0, type: 0, weight: 3 },{ comId: '1000007', name: '飒飒飒飒', property: 0, type: 0, weight: 5 },{ comId: '1000011', name: '你说的分手', property: 0, type: 0, weight: 6 },{ comId: '1000012', name: '大润发儿童', property: 0, type: 0, weight: 9 },{ comId: '1000013', name: '大方的发过的', property: 0, type: 0, weight: 8 }];const dataList2 = [{ comId: '1000001', name: '哈哈哈', property: 0, type: 1, weight: 2 },{ comId: '1000005', name: '测试组件名称', property: 0, type: 1, weight: 2 },{ comId: '1000002', name: '啦啦啦', property: 1, type: 0, weight: 0 }];const dataList3 = [{ comId: '1000017', name: 'GV地方大幅度', property: 0, type: 0, weight: 3 },{ comId: '1000016', name: '奋斗奋斗发的', property: 0, type: 0, weight: 2 },{ comId: '1000008', name: '大幅度发', property: 0, type: 0, weight: 1 },{ comId: '1000003', name: '似懂非懂发', property: 1, type: 1, weight: 0 },{ comId: '1000014', name: '个人发一个发帖人', property: 0, type: 0, weight: 0 },{ comId: '1000015', name: '会更好多说点', property: 0, type: 0, weight: 0 }];export default {components: { draggable },data() {return {showDialog: false,drainComponents: convertDataList(sortedDataList(dataList1)),dataComponents: convertDataList(sortedDataList(dataList2)),liveComponents: convertDataList(sortedDataList(dataList3))};},methods: {generateSoftColor,convertDataList,removeColorSet(data) {for(let i=0;i<data.length;i++){delete data[i].color;}return data},updateWeights(data) {for(let i=0;i<data.length;i++) {data[i].weight = data.length - i;}return data},saveLayout() {this.showDialog = false;this.drainComponents = this.updateWeights(this.drainComponents)this.dataComponents = this.updateWeights(this.dataComponents)this.liveComponents = this.updateWeights(this.liveComponents)this.printComponentVal();// Remove 'color' field from each dictionary// this.drainComponents = this.removeColorSet(this.drainComponents)// console.log("this.drainComponents", this.drainComponents)// this.dataComponents = this.removeColorSet(this.dataComponents)// console.log("this.dataComponents", this.dataComponents)// this.liveComponents = this.removeColorSet(this.liveComponents)// console.log("this.liveComponents", this.liveComponents)},printComponentVal() {console.log("this.drainComponents", this.drainComponents)console.log("this.dataComponents", this.dataComponents)console.log("this.liveComponents", this.liveComponents)},}};</script><style scoped>.box-card {margin-bottom: 20px;}.buttons-container {display: flex;flex-wrap: wrap;}.button {margin: 5px;flex: 0 1 auto;display: flex;flex-direction: column;align-items: center;justify-content: center;}.button-content {text-align: center;}.component-id {font-size: 0.8em;color: #666;}.buttons-container .button:first-child {margin-left: 10px;}</style>

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

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

相关文章

深度学习每周学习总结N5:调用Gensim库训练Word2Vec模型

目录 0. 总结&#xff1a;1. 关于nn.Embedding(), nn.EmbeddingBag(), 和 word2vecnn.Embedding()nn.EmbeddingBag()Word2Vec联系与区别 2. 调用Gensim库训练Word2Vec模型准备工作对原始语料分词训练模型模型应用计算词汇相似度找出不匹配的词汇计算词汇的词频 提问&#xff1a…

全方位数据管理:一站式爬虫服务解决方案

摘要 面对互联网信息爆炸的时代&#xff0c;如何高效地收集、整理并分析海量数据&#xff0c;成为企业与开发者面临的一大挑战。本文将深入探讨一站式爬虫服务解决方案&#xff0c;揭示如何通过全方位数据管理策略&#xff0c;助力企业轻松驾驭大数据海洋&#xff0c;实现数据…

专业视频拍摄与编辑SDK,定制专属视频解决方案

无论是社交媒体营销、产品展示、教育培训还是直播电商&#xff0c;高质量的视频内容都是吸引眼球、传递信息的关键。美摄科技&#xff0c;作为视频编辑处理领域的佼佼者&#xff0c;以其强大的视频拍摄与编辑SDK&#xff0c;为企业开启了视觉创意的新篇章。 【专业级功能&…

web3d值得学习并长期发展,性价比高吗?

在数字化浪潮日益汹涌的今天&#xff0c;Web3D技术以其独特的魅力和广泛的应用前景&#xff0c;逐渐成为技术领域的焦点。对于许多热衷于技术探索和创新的人来说&#xff0c;学习并长期发展Web3D技术无疑是一个值得考虑的选择。那么&#xff0c;Web3D技术的学习和发展究竟是否性…

WHAT - 不同 HTTP Methods 使用场景、使用方法和可能遇到的问题

目录 前言基本介绍具体介绍前置知识&#xff1a;幂等和非幂等幂等操作非幂等操作幂等性和非幂等性的应用场景总结 1. GET2. POST3. PUT4. PATCH1. 确保操作是幂等的2. 使用版本控制或条件更新3. 全量更新部分属性4. 使用特定操作指令5. 幂等标识符示例代码总结 5. DELETE6. HEA…

07 JSP

文章目录 JSP1、JSP 概述2、JSP 脚本和缺点3、EL 表达式4、JSTL标签5、MVC模式和三层架构6、案例 JSP 1、JSP 概述 JSP&#xff08;全称&#xff1a;Java Server Pages&#xff09;&#xff1a;Java 服务端页面 &#xff08;1&#xff09;是一种动态的网页技术 &#xff08;2&…

【C++高阶】哈希之美:探索位图与布隆过滤器的应用之旅

&#x1f4dd;个人主页&#x1f339;&#xff1a;Eternity._ ⏩收录专栏⏪&#xff1a;C “ 登神长阶 ” &#x1f921;往期回顾&#x1f921;&#xff1a;模拟实现unordered 的奥秘 &#x1f339;&#x1f339;期待您的关注 &#x1f339;&#x1f339; ❀哈希应用 &#x1f4…

C++中的虚函数与多态机制如何工作?

在C中&#xff0c;虚函数和多态机制是实现面向对象编程的重要概念。 虚函数是在基类中声明的函数&#xff0c;可以在派生类中进行重写。当基类的指针或引用指向派生类的对象时&#xff0c;通过调用虚函数可以实现动态绑定&#xff0c;即在运行时确定要调用的函数。 多态是指通…

Cocos Creator 小游戏案例

最近在计划学习小游戏开发&#xff0c;查阅了一些资料&#xff0c;也找到了许多有趣的案例&#xff0c;特此记录与大家分享。 1. 连点成线 http://game.zaiwuchuan.com/yibihua 2. 颜色分类 http://game.zaiwuchuan.com/zhaoxiansuo 3. 星空一笔画 http://game.zaiwuchu…

大模型llama结构技术点分享;transformer模型常见知识点nlp面经

1、大模型llama3技术点 参考&#xff1a;https://www.zhihu.com/question/662354435/answer/3572364267 Llama1-3&#xff0c;数据tokens从1-2T到15T;使用了MHA&#xff08;GQA缓存&#xff09;&#xff1b;上下文长度从2-4-8K&#xff1b;应用了强化学习对其。 1、pretraini…

分布式事务(典型的分布式事务场景+CAP+解决方案)

分布式事务与分布式锁的区别&#xff1a; 分布式锁解决的是分布式资源抢占的问题&#xff1b;分布式事务和本地事务是解决流程化提交问题。 SQL中的4个事务隔离级别&#xff1a;&#xff08;1&#xff09;读未提交&#xff08;2&#xff09;读已提交&#xff08;3&#xff09…

如何远程开发完整分析一台新能源车BMS电池管理系统CAN数据矩阵

随着我国新能源汽车的崛起&#xff0c;从网络管理平台、数据中心、科研机构、高校教学、车型对标、整车DBC控制策略分析、电池管理系统研究、电池健康管理、网约车管理、电池梯度利用、车队管理等多方面的市场需求&#xff0c;完整分析一台新能源车BMS电池管理系统的CAN矩阵开发…

【深度学习】yolov8-seg分割训练,拼接图的分割复原

文章目录 项目背景造数据训练 项目背景 在日常开发中&#xff0c;经常会遇到一些图片是由多个图片拼接来的&#xff0c;如下图就是三个图片横向拼接来的。是否可以利用yolov8-seg模型来识别出这张图片的三张子图区域呢&#xff0c;这是文本要做的事情。 造数据 假设拼接方式有…

生成式AI与自然语言处理的结合-提升生成式AI的语言理解能力

引言 近年来&#xff0c;生成式AI已逐渐成为科技发展的前沿领域&#xff0c;其未来发展方向备受关注。对于人类生活和工作方式的影响&#xff0c;生成式AI在对话系统&#xff08;Chat&#xff09;和自主代理&#xff08;Agent&#xff09;中的表现引发了广泛讨论。本文将全面探…

Postman中的API Schema验证:确保响应精准无误

Postman中的API Schema验证&#xff1a;确保响应精准无误 在API开发和测试过程中&#xff0c;验证响应数据的准确性和一致性是至关重要的。Postman提供了一个强大的功能——API Schema验证&#xff0c;它允许开发者根据预定义的JSON Schema来检查API响应。本文将详细介绍如何在…

微软全球蓝屏带来的思考及未来战争走向

微软全球蓝屏事件不仅揭示了技术层面的问题和挑战&#xff0c;还引发了对未来战争走向的一些深入思考。以下是关于这些思考的内容&#xff1a; 微软全球蓝屏带来的思考&#xff1a; 系统稳定性与安全性&#xff1a;微软全球蓝屏事件凸显了操作系统稳定性和安全性的重要性。一…

Oracle配置TCPS加密协议测试

文章目录 一、环境信息二、配置过程1.创建证书2.监听配置2.1.配置sqlnet.ora2.2.配置listener.ora文件2.3.配置tnsnames.ora文件2.4.重载监听 3.数据库本地测试3.1. tcps登录测试3.2.日志监控 一、环境信息 操作系统&#xff1a;Linux 版本信息&#xff1a;Oracle 19c 参考文档…

asp.net core 集成redis详解

ASP.NET Core 集成 Redis 详解如下&#xff1a; 目录 一、Redis简介 二、在ASP.NET Core中集成Redis 三、Redis的高级用法 四、注意事项 一、Redis简介 Redis是一个开源的内存数据结构存储系统&#xff0c;它可以用作数据库、缓存和消息代理。Redis内置了复制、Lua脚本、…

在可编辑 div (contentEditable)末尾插入换行符(\n 或 \<br\>)无效的解决办法

背景: 给可编辑 div 末尾插入换行符, 发现仍然未换行; 解决方法: 提前给 div 末尾插入一个 <br> 就行了, 之后看自己情况要不要去掉 示例代码: // 如果输入框末尾没有 BR 换行符, 则自动加一个, 避免 Ctrl Enter 两次才显示 const currLastEl dom_input.lastElement…

缓存框架 Caffeine 的可视化探索与实践

作者&#xff1a;vivo 互联网服务器团队- Wang Zhi Caffeine 作为一个高性能的缓存框架而被大量使用。本文基于Caffeine已有的基础进行定制化开发实现可视化功能。 一、背景 Caffeine缓存是一个高性能、可扩展、内存优化的 Java 缓存库&#xff0c;基于 Google 的 Guava Cac…