当前位置: 首页 > news >正文

table 拖拽移动

表格拖拽 

 Sortable.js中文网|配置

<!-- 教务处  --><template><div class="but"><el-button @click="mergeAndPrintArrays()" type="primary">保存数据</el-button><el-button @click="restoration()" type="primary">数据还原</el-button></div><div class="container"><div class="left"><el-table :data="myArray" row-key="id" ref="table1" id="table1"><el-table-column prop="name" label="姓名"></el-table-column><el-table-column prop="state" label="前台是否展示" width="90"><template v-slot="scope"><el-switch v-model="scope.row.states" @change="stateChanged(scope.row)" /></template></el-table-column><el-table-column prop="state" label="是否作为搜索条件" width="120"><template v-slot="scope"><el-switch v-model="scope.row.state" @change="stateChanged(scope.row)" /></template></el-table-column></el-table></div><div class="left"><el-table :data="myArray2" row-key="id" ref="table2" id="table2"><el-table-column prop="name" label="姓名"></el-table-column><el-table-column prop="state" label="前台是否展示" width="90"><template v-slot="scope"><el-switch v-model="scope.row.states" @change="stateChanged(scope.row)" /></template></el-table-column><el-table-column prop="state" label="是否作为搜索条件" width="120"><template v-slot="scope"><el-switch v-model="scope.row.state" @change="stateChanged(scope.row)" /></template></el-table-column></el-table></div><div class="left"><el-table :data="myArray3" row-key="id" ref="table3" id="table3"><el-table-column prop="name" label="姓名"></el-table-column><el-table-column prop="state" label="前台是否展示" width="90"><template v-slot="scope"><el-switch v-model="scope.row.states" @change="stateChanged(scope.row)" /></template></el-table-column><el-table-column prop="state" label="是否作为搜索条件" width="120"><template v-slot="scope"><el-switch v-model="scope.row.state" @change="stateChanged(scope.row)" /></template></el-table-column></el-table></div><div class="left"><el-table :data="myArray4" row-key="id" ref="table4" id="table4"><el-table-column prop="name" label="姓名"></el-table-column><el-table-column prop="state" label="前台是否展示" width="90"><template v-slot="scope"><el-switch v-model="scope.row.states" @change="stateChanged(scope.row)" /></template></el-table-column><el-table-column prop="state" label="是否作为搜索条件" width="120"><template v-slot="scope"><el-switch v-model="scope.row.state" @change="stateChanged(scope.row)" /></template></el-table-column></el-table></div><div class="left"><el-table :data="myArray5" row-key="id" ref="table5" id="table5"><el-table-column prop="name" label="姓名"></el-table-column><el-table-column prop="state" label="前台是否展示" width="90"><template v-slot="scope"><el-switch v-model="scope.row.states" @change="stateChanged(scope.row)" /></template></el-table-column><el-table-column prop="state" label="是否作为搜索条件" width="120"><template v-slot="scope"><el-switch v-model="scope.row.state" @change="stateChanged(scope.row)" /></template></el-table-column></el-table></div></div></template><script>
import Sortable from "sortablejs";
import webfield from "@/api/sys/webfield";
import notifyService from "@/api/notify/notifyService";
export default {data() {return {dataList: [],earchVisible: true,loading: false,myArray: [],myArray2: [],myArray3: [],myArray4: [],myArray5: [],userName: "",userNameF: "",companyDTO: '',ids: '',newtype: ''};},props: ["value1"],mounted() {this.refreshList();},async created() {var userInfo = this.$TOOL.data.get("USER_INFO");this.userName = userInfo.id;this.companyDTO = userInfo.companyDTO.id;},methods: {// 获取数据 初始化refreshList() {// this.newtype = JSON.parse(this.value1)// console.log(this.newtype, 'new11')this.loading = true;const params = {officeId: this.companyDTO,type: 1,};webfield.webfieldinit(params).then((data) => {this.dataList = JSON.parse(data.data.content)this.ids = data.data.idconsole.log(data, "disa")this.assignDataToArrays();this.loading = false;}).catch((error) => {console.error('Error fetching data:', error);this.loading = false;});},// 获取数据 平均分配assignDataToArrays() {this.myArray = [];this.myArray2 = [];this.myArray3 = [];this.myArray4 = [];this.myArray5 = [];// 计算每个数组应该分配的数据量const chunkSize = Math.ceil(this.dataList.length / 5);// 将 dataList 的数据平均分配到五个数组中for (let i = 0; i < this.dataList.length; i++) {if (i < chunkSize) {this.myArray.push(this.dataList[i]);} else if (i < chunkSize * 2) {this.myArray2.push(this.dataList[i]);} else if (i < chunkSize * 3) {this.myArray3.push(this.dataList[i]);} else if (i < chunkSize * 4) {this.myArray4.push(this.dataList[i]);} else {this.myArray5.push(this.dataList[i]);}}this.initSortable();},initSortable() {const initSortableForTable = (tableRef, dataArray, num) => {const tbody = this.$refs[tableRef].$el.querySelector(".el-table__body-wrapper tbody");Sortable.create(tbody, {onEnd: ({ newIndex, oldIndex, to, from, clone, pullMode, item }) => {const totableid = to.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.idconst fromtableid = from.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.id//id映射const tablemap = {table1: this.myArray,table2: this.myArray2,table3: this.myArray3,table4: this.myArray4,table5: this.myArray5,}if (totableid == fromtableid) {const currRow = dataArray.splice(oldIndex, 1)[0];dataArray.splice(newIndex, 0, currRow);} else {//不一致 跨列拖动const currRow = tablemap[fromtableid].splice(oldIndex, 1)[0];// //向to添加一个元素tablemap[totableid].splice(newIndex, 0, currRow);//from table会少一列if (tablemap[totableid][newIndex + 1]) {//如果 to table 的下一行有数据 补充回fromtable的oldindxtablemap[fromtableid].splice(oldIndex, 0, tablemap[totableid][newIndex + 1])//得删除to table的数据tablemap[totableid].splice(newIndex + 1, 1)} else if (tablemap[totableid][newIndex - 1]) {tablemap[fromtableid].splice(oldIndex, 0, tablemap[totableid][newIndex - 1])//得删除to table的数据tablemap[totableid].splice(newIndex - 1, 1)} else {console.error("前后都没有数据 无法补充")}// console.log(this.myArray, this.myArray2)}},group: 'zhaoxin'});};initSortableForTable('table1', this.myArray);initSortableForTable('table2', this.myArray2);initSortableForTable('table3', this.myArray3);initSortableForTable('table4', this.myArray4);initSortableForTable('table5', this.myArray5);},//合并数组  保存数据mergeAndPrintArrays() {// console.log(JSON.parse(this.value1), 'oooooooooooo')// this.newtype = JSON.parse(JSON.stringify(this.options))[0].valuethis.newtype = JSON.parse(this.value1)// 合并三个数组const mergedArray = [...this.myArray, ...this.myArray2, ...this.myArray3, ...this.myArray4, ...this.myArray5];const news = JSON.stringify(mergedArray);this.loading = true;// 构建请求参数对象const params = {officeId: this.companyDTO,type: this.newtype,content: news,operatorId: this.userName,};const newparams = {officeId: this.companyDTO,type: this.newtype,content: news,operatorId: this.userName,id: this.ids};if (this.ids === '') {console.log('空啦')webfield.webfieldadd(params).then((response) => {location.reload(true);this.loading = false;}).catch((error) => {console.error('Error fetching data:', error);this.loading = false;});} else {console.log("不空")console.log(this.myArray, 'cuirow')webfield.webfieldadd(newparams).then((response) => {location.reload(true);this.loading = false;}).catch((error) => {console.error('Error fetching data:', error);this.loading = false;});}},// 控制显隐stateChanged(row) {const index = this.myArray.findIndex(item => item.id === row.id);console.log('Row index:', index);console.log('Row data:', row);},// 还原数据restoration() {this.loading = true;console.log(this.loading, 'loading'); // 修正了拼写错误,从 'loda' 改为 'loading'if (this.ids === '' || this.ids === undefined || this.ids === null) {console.log('kong ')alert('已经还原成最初的原始数据了!');this.loading = false; // 如果不需要刷新页面,可以在这里直接设置 loading 为 false} else {console.log(this.ids, 'konglllll ')webfield.webfielddel(this.ids).then((data) => {console.log(data)this.assignDataToArrays();location.reload(true); // 仅在数据删除成功后刷新页面}).catch((error) => {console.error('Error fetching data:', error);this.loading = false; // 请求失败时设置 loading 为 false});}}},
};
</script><style lang="less" scoped>
.but {margin-bottom: 3rem;
}.container {display: flex;margin-bottom: 50rem;.left,.right {background-color: #fff;width: 282px;height: 1000px;margin: 0 4px;padding: 0 -8px;.item {height: 40px;border: 1px solid #e9e9e9;text-align: center;line-height: 40px;margin: 20px 0;background-color: rgb(242, 242, 242);}}
}
</style>

相关文章:

table 拖拽移动

表格拖拽 Sortable.js中文网|配置 <!-- 教务处 --><template><div class"but"><el-button click"mergeAndPrintArrays()" type"primary">保存数据</el-button><el-button click"restoration()" t…...

Linux使用笔记:Find Tree 命令

Tree 命令的使用 使用-I 参数&#xff0c;过滤掉不想展未的目录或文件使用-L参数&#xff0c;指定展示的目录层级个数 arsenaltxzq1899:~/Workspace/vue-application$ tree -I node_modules/ -I public/ -L 2 . ├── components.json ├── Dockerfile ├── ecosystem.c…...

数据结构入门篇——什么是数据结构。

一、引入 工具是一种什么东西呢&#xff1f;是一种转化媒介&#xff0c;我们需要熟食&#xff0c;我们要通过用火来将生肉烤熟。在这个过程中。我们要输入一个东西——生肉&#xff0c;通过工具——火的加工&#xff0c;从而得到我们的目的产物——熟肉。 将上面的例子和红字部…...

MySQL-简介与基本命令

数据库 主流数据库 关系型数据库 MySQL&#xff1a;开源免费的关系型数据库&#xff0c;易于使用和学习&#xff0c;支持大型企业级应用。其特点包括高性能、可靠性和可扩展性&#xff0c;支持多种编程语言和操作系统&#xff0c;拥有大量的社区支持和插件SQLite&#xff1a…...

汽车材料耐候性测试仪器-太阳光模拟器介绍

**太阳光模拟器**是一种用于模拟太阳光谱的设备&#xff0c;广泛应用于汽车材料的耐候性测试。通过模拟太阳光中的紫外线、可见光和红外线&#xff0c;评估材料在长期光照下的性能变化。 主要组成部分 1. **光源系统**&#xff1a; - **氙灯**&#xff1a;最常用的光源&…...

音频3A测试--AEC(回声消除)测试

一、测试前期准备 一台录制电脑:用于作为近段音源和收集远端处理后的数据; 一台测试设备B:用于测试AEC的设备; 一个高保真音响:用于播放设备B的讲话; 一台播放电脑:用于模拟设备A讲话,和模拟设备B讲话; 一台音频处理器(调音台):用于录制和播放数据; 测试使用转接线若…...

DeepSeek 助力 Vue3 开发:打造丝滑的弹性布局(Flexbox)

前言&#xff1a;哈喽&#xff0c;大家好&#xff0c;今天给大家分享一篇文章&#xff01;并提供具体代码帮助大家深入理解&#xff0c;彻底掌握&#xff01;创作不易&#xff0c;如果能帮助到大家或者给大家一些灵感和启发&#xff0c;欢迎收藏关注哦 &#x1f495; 目录 Deep…...

六、Redis 高级功能详解:BitMap、HyperLogLog、Geo、Stream

Redis 高级功能详解:BitMap、HyperLogLog、Geo、Stream Redis 不仅提供了基础的数据结构(String、List、Set、Hash、Sorted Set),还提供了一些高级数据结构,专门用于特定的应用场景,如位运算统计、去重计数、地理位置存储、流数据处理等。本文将详细介绍这些高级功能的使…...

WSL下使用git克隆失败解决

WSL默认nat模式&#xff0c;别动了防火墙放行&#xff0c;见图1git导入[bash1]&#xff0c;ip为你wsl上linxu通过ifconfig获取的本机ip&#xff0c;端口对好某alcsh软件开启tun模式【经过测试&#xff0c;不开也行】应该成了&#xff0c;如果不行&#xff0c;修改.wslconfig为下…...

【Elasticsearch】索引生命周期管理相关的操作(Index Lifecycle Actions)

Elasticsearch 的Index Lifecycle Management(ILM)是一种用于管理索引生命周期的工具&#xff0c;它允许用户根据索引的使用阶段&#xff08;如热、温、冷、冻结&#xff09;自动执行一系列操作。以下是详细解释 Elasticsearch 中的索引生命周期操作&#xff08;Index Lifecycl…...

TS的接口 泛型 自定义类型 在接口中定义一个非必须的属性

TS的接口 泛型 自定义类型 接口 新建一个ts文件&#xff0c;在里面定义一个接口 export interface PersonInter{id:string,name:string,age:number }在vue文件中引入这个ts文件 <script lang"ts" setup name"Person">import {type PersonInter} …...

Collab-Overcooked:专注于多智能体协作的语言模型基准测试平台

2025-02-27&#xff0c;由北京邮电大学和理想汽车公司联合创建。该平台基于《Overcooked-AI》游戏环境&#xff0c;设计了更具挑战性和实用性的交互任务&#xff0c;目的通过自然语言沟通促进多智能体协作。 一、研究背景 近年来&#xff0c;基于大型语言模型的智能体系统在复…...

未来经济范式争夺战:AR眼镜为何成为下一代交互终端的制高点?

未来经济范式争夺战&#xff1a;AR眼镜为何成为下一代交互终端的制高点&#xff1f; 在蒸汽机轰鸣的工业革命时代&#xff0c;煤炭、铁路、电报构建了第一个现代经济范式&#xff1b;互联网时代&#xff0c;电力、光纤、物流网络重构了全球经济版图。当前&#xff0c;我们正站…...

Mybatis实现批量添加

1.设计一张商品表 CREATE TABLE IF NOT EXISTS goods (id BIGINT AUTO_INCREMENT PRIMARY KEY,name VARCHAR(255) NOT NULL );2.编写实体类映射数据库表格 Data public class Goods {private Long id;private String name;// Getters and Setters }3.编写持久层接口以及其对应…...

golang 内存对齐和填充规则

内存对齐和填充规则 对齐要求&#xff1a;每个数据类型的起始地址必须是其大小的倍数。 int8&#xff08;1字节&#xff09;&#xff1a;不需要对齐。int16&#xff08;2字节&#xff09;&#xff1a;起始地址必须是2的倍数。int32&#xff08;4字节&#xff09;&#xff1a;起…...

【YashanDB认证】yashandb23.3.1 个人版单机部署安装实践

YCA报名链接如下: YashanDB|崖山数据库系统YashanDB学习中心-YCA认证详情 目前免费 主要参考文档&#xff1a; 单机&#xff08;主备&#xff09;部署 | YashanDB Doc 另外还参考摩天轮文章&#xff1a; YashanDB 23.2.9.101 企业版安装步骤抢先看&#xff01; - 墨天轮 …...

安全渗透测试的全面解析与实践

引言 随着网络安全威胁的日益增加&#xff0c;企业和组织对自身系统的安全性提出了更高的要求。安全渗透测试&#xff08;Penetration Testing&#xff0c;简称渗透测试&#xff09;作为主动发现和修复系统安全漏洞的重要手段&#xff0c;已成为安全防护体系中的关键环节。本文…...

通俗易懂的分类算法之决策树详解

通俗易懂的分类算法之决策树详解 1. 什么是决策树&#xff1f; 决策树是一种像树一样的结构&#xff0c;用来帮助我们对数据进行分类或预测。它的每个节点代表一个问题或判断条件&#xff0c;每个分支代表一个可能的答案&#xff0c;最后的叶子节点就是最终的分类结果。 举个…...

【OpenCV C++】以时间命名存图,自动检查存储目录,若不存在自动创建, 按下空格、回车、Q、S自动存图

文章目录 // 保存图像的函数 void saveImage(const cv::Mat& frame) {// 生成唯一文件名auto now = std::chrono::system_clock::...

post get 给后端传参数

post 方式一 &#xff1a; data: params 作为请求体&#xff08;Request Body&#xff09;传递&#xff1a; 你已经展示了这种方式&#xff0c;通过data字段直接传递一个对象或数组。这种方式通常用于传递复杂的数据结构。dowmfrom: function (params) { return request({ u…...

基于STM32F103C8与CAN总线的步科步进电机PDO映射实战解析

1. STM32F103C8与步科步进电机的基础连接 第一次接触CAN总线控制步进电机时&#xff0c;最让我头疼的就是硬件连接部分。STM32F103C8的CAN接口引脚是固定的PA11(CAN_RX)和PA12(CAN_TX)&#xff0c;而步科驱动器的CAN接口通常标注为CANH和CANL。这里有个容易踩坑的地方&#xff…...

Catia学习教程

写在前面 自学Catia的时候发现大部分教程在隔壁B站&#xff0c;CSDN上教程比较少&#xff0c;记录一下自己的学习过程&#xff0c;要有一定的AutoCAD和Solidworks基础&#xff0c;很多指令是相似的。 一、软件简介 CATIA&#xff08;Computer Aided Three-dimensional Intera…...

25619+ASMR资源一键获取:让音频收藏效率提升10倍的智能下载工具

25619ASMR资源一键获取&#xff1a;让音频收藏效率提升10倍的智能下载工具 【免费下载链接】asmr-downloader A tool for download asmr media from asmr.one(Thanks for the asmr.one) 项目地址: https://gitcode.com/gh_mirrors/as/asmr-downloader 在数字音频时代&am…...

FastAPI项目PyInstaller打包实战:避坑指南与最佳实践

1. 为什么需要打包FastAPI项目&#xff1f; 当你用FastAPI开发完一个Web应用后&#xff0c;最终需要部署到生产环境。传统方式要求服务器安装Python环境、配置依赖库&#xff0c;这个过程既繁琐又容易出错。PyInstaller的价值就在于能把整个项目打包成独立可执行文件&#xff0…...

Flow Matching 流匹配策略:从理论到机器人实时控制

目录 1.1.1.1 流匹配的基本定义 1.1.1.2 连续性方程与概率路径演化 1.1.1.3 流匹配损失函数的标准形式 1.2.1.1 条件概率路径的构造原理 1.2.1.2 条件向量场的确定性映射 1.2.1.3 条件流匹配损失的等价性证明 1.2.1.4 线性插值路径的实例化 2.1.1.1 Kantorovich最优传输…...

PROJECT MOGFACE开源社区贡献指南:从代码阅读到提交PR的全流程

PROJECT MOGFACE开源社区贡献指南&#xff1a;从代码阅读到提交PR的全流程 你是不是也遇到过这样的情况&#xff1a;在GitHub上看到一个很酷的开源项目&#xff0c;比如最近挺火的PROJECT MOGFACE&#xff0c;心里痒痒的&#xff0c;也想贡献点代码&#xff0c;但一打开那庞大…...

别再手动发卡了!2025新版ZFAKA搭配宝塔面板,30分钟搞定你的专属自动售卡站

2025年ZFAKA自动售卡系统&#xff1a;零基础30分钟搭建全攻略 在数字商品交易日益火爆的今天&#xff0c;手动处理订单不仅效率低下&#xff0c;还容易出错。想象一下凌晨三点被订单提醒吵醒&#xff0c;手忙脚乱地复制卡密发给买家——这种场景对于个体创业者来说再熟悉不过了…...

汇编开发与系统构建:FloppyBird操作系统游戏的技术解构

汇编开发与系统构建&#xff1a;FloppyBird操作系统游戏的技术解构 【免费下载链接】floppybird Floppy Bird (OS) 项目地址: https://gitcode.com/gh_mirrors/fl/floppybird 一、价值&#xff1a;当游戏成为操作系统的技术突破 在计算机科学领域&#xff0c;"操作…...

Zap vs Go:终极后端性能对比测试与实战分析

Zap vs Go&#xff1a;终极后端性能对比测试与实战分析 【免费下载链接】zap blazingly fast backends in zig 项目地址: https://gitcode.com/gh_mirrors/zap/zap Zap 作为一款基于 Zig 语言开发的后端框架&#xff0c;以其 "blazingly fast backends" 为核心…...

手把手教你为本地LLM(Llama/Qwen)实现打字机式流式输出,Gradio+Transformers保姆级教程

手把手教你为本地LLM实现打字机式流式输出&#xff1a;Gradio与Transformers深度整合指南 当我们在本地部署大语言模型时&#xff0c;最令人沮丧的体验莫过于盯着进度条等待完整响应。想象一下这样的场景&#xff1a;你向模型提出一个复杂问题&#xff0c;屏幕陷入长达十几秒的…...