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 参数,过滤掉不想展未的目录或文件使用-L参数,指定展示的目录层级个数 arsenaltxzq1899:~/Workspace/vue-application$ tree -I node_modules/ -I public/ -L 2 . ├── components.json ├── Dockerfile ├── ecosystem.c…...

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

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

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

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

DeepSeek 助力 Vue3 开发:打造丝滑的弹性布局(Flexbox)
前言:哈喽,大家好,今天给大家分享一篇文章!并提供具体代码帮助大家深入理解,彻底掌握!创作不易,如果能帮助到大家或者给大家一些灵感和启发,欢迎收藏关注哦 💕 目录 Deep…...
六、Redis 高级功能详解:BitMap、HyperLogLog、Geo、Stream
Redis 高级功能详解:BitMap、HyperLogLog、Geo、Stream Redis 不仅提供了基础的数据结构(String、List、Set、Hash、Sorted Set),还提供了一些高级数据结构,专门用于特定的应用场景,如位运算统计、去重计数、地理位置存储、流数据处理等。本文将详细介绍这些高级功能的使…...

WSL下使用git克隆失败解决
WSL默认nat模式,别动了防火墙放行,见图1git导入[bash1],ip为你wsl上linxu通过ifconfig获取的本机ip,端口对好某alcsh软件开启tun模式【经过测试,不开也行】应该成了,如果不行,修改.wslconfig为下…...
【Elasticsearch】索引生命周期管理相关的操作(Index Lifecycle Actions)
Elasticsearch 的Index Lifecycle Management(ILM)是一种用于管理索引生命周期的工具,它允许用户根据索引的使用阶段(如热、温、冷、冻结)自动执行一系列操作。以下是详细解释 Elasticsearch 中的索引生命周期操作(Index Lifecycl…...
TS的接口 泛型 自定义类型 在接口中定义一个非必须的属性
TS的接口 泛型 自定义类型 接口 新建一个ts文件,在里面定义一个接口 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,由北京邮电大学和理想汽车公司联合创建。该平台基于《Overcooked-AI》游戏环境,设计了更具挑战性和实用性的交互任务,目的通过自然语言沟通促进多智能体协作。 一、研究背景 近年来,基于大型语言模型的智能体系统在复…...

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

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 内存对齐和填充规则
内存对齐和填充规则 对齐要求:每个数据类型的起始地址必须是其大小的倍数。 int8(1字节):不需要对齐。int16(2字节):起始地址必须是2的倍数。int32(4字节):起…...

【YashanDB认证】yashandb23.3.1 个人版单机部署安装实践
YCA报名链接如下: YashanDB|崖山数据库系统YashanDB学习中心-YCA认证详情 目前免费 主要参考文档: 单机(主备)部署 | YashanDB Doc 另外还参考摩天轮文章: YashanDB 23.2.9.101 企业版安装步骤抢先看! - 墨天轮 …...
安全渗透测试的全面解析与实践
引言 随着网络安全威胁的日益增加,企业和组织对自身系统的安全性提出了更高的要求。安全渗透测试(Penetration Testing,简称渗透测试)作为主动发现和修复系统安全漏洞的重要手段,已成为安全防护体系中的关键环节。本文…...
通俗易懂的分类算法之决策树详解
通俗易懂的分类算法之决策树详解 1. 什么是决策树? 决策树是一种像树一样的结构,用来帮助我们对数据进行分类或预测。它的每个节点代表一个问题或判断条件,每个分支代表一个可能的答案,最后的叶子节点就是最终的分类结果。 举个…...
【OpenCV C++】以时间命名存图,自动检查存储目录,若不存在自动创建, 按下空格、回车、Q、S自动存图
文章目录 // 保存图像的函数 void saveImage(const cv::Mat& frame) {// 生成唯一文件名auto now = std::chrono::system_clock::...
post get 给后端传参数
post 方式一 : data: params 作为请求体(Request Body)传递: 你已经展示了这种方式,通过data字段直接传递一个对象或数组。这种方式通常用于传递复杂的数据结构。dowmfrom: function (params) { return request({ u…...
[特殊字符] 智能合约中的数据是如何在区块链中保持一致的?
🧠 智能合约中的数据是如何在区块链中保持一致的? 为什么所有区块链节点都能得出相同结果?合约调用这么复杂,状态真能保持一致吗?本篇带你从底层视角理解“状态一致性”的真相。 一、智能合约的数据存储在哪里…...

深度学习在微纳光子学中的应用
深度学习在微纳光子学中的主要应用方向 深度学习与微纳光子学的结合主要集中在以下几个方向: 逆向设计 通过神经网络快速预测微纳结构的光学响应,替代传统耗时的数值模拟方法。例如设计超表面、光子晶体等结构。 特征提取与优化 从复杂的光学数据中自…...
DeepSeek 赋能智慧能源:微电网优化调度的智能革新路径
目录 一、智慧能源微电网优化调度概述1.1 智慧能源微电网概念1.2 优化调度的重要性1.3 目前面临的挑战 二、DeepSeek 技术探秘2.1 DeepSeek 技术原理2.2 DeepSeek 独特优势2.3 DeepSeek 在 AI 领域地位 三、DeepSeek 在微电网优化调度中的应用剖析3.1 数据处理与分析3.2 预测与…...
反向工程与模型迁移:打造未来商品详情API的可持续创新体系
在电商行业蓬勃发展的当下,商品详情API作为连接电商平台与开发者、商家及用户的关键纽带,其重要性日益凸显。传统商品详情API主要聚焦于商品基本信息(如名称、价格、库存等)的获取与展示,已难以满足市场对个性化、智能…...

Redis相关知识总结(缓存雪崩,缓存穿透,缓存击穿,Redis实现分布式锁,如何保持数据库和缓存一致)
文章目录 1.什么是Redis?2.为什么要使用redis作为mysql的缓存?3.什么是缓存雪崩、缓存穿透、缓存击穿?3.1缓存雪崩3.1.1 大量缓存同时过期3.1.2 Redis宕机 3.2 缓存击穿3.3 缓存穿透3.4 总结 4. 数据库和缓存如何保持一致性5. Redis实现分布式…...

2025 后端自学UNIAPP【项目实战:旅游项目】6、我的收藏页面
代码框架视图 1、先添加一个获取收藏景点的列表请求 【在文件my_api.js文件中添加】 // 引入公共的请求封装 import http from ./my_http.js// 登录接口(适配服务端返回 Token) export const login async (code, avatar) > {const res await http…...
【C语言练习】080. 使用C语言实现简单的数据库操作
080. 使用C语言实现简单的数据库操作 080. 使用C语言实现简单的数据库操作使用原生APIODBC接口第三方库ORM框架文件模拟1. 安装SQLite2. 示例代码:使用SQLite创建数据库、表和插入数据3. 编译和运行4. 示例运行输出:5. 注意事项6. 总结080. 使用C语言实现简单的数据库操作 在…...

让AI看见世界:MCP协议与服务器的工作原理
让AI看见世界:MCP协议与服务器的工作原理 MCP(Model Context Protocol)是一种创新的通信协议,旨在让大型语言模型能够安全、高效地与外部资源进行交互。在AI技术快速发展的今天,MCP正成为连接AI与现实世界的重要桥梁。…...

Spring数据访问模块设计
前面我们已经完成了IoC和web模块的设计,聪明的码友立马就知道了,该到数据访问模块了,要不就这俩玩个6啊,查库势在必行,至此,它来了。 一、核心设计理念 1、痛点在哪 应用离不开数据(数据库、No…...
Java 二维码
Java 二维码 **技术:**谷歌 ZXing 实现 首先添加依赖 <!-- 二维码依赖 --><dependency><groupId>com.google.zxing</groupId><artifactId>core</artifactId><version>3.5.1</version></dependency><de…...