自定义穿梭框封装

news/2024/9/20 2:43:57/文章来源:https://www.cnblogs.com/tlfe/p/18413509

 

 后面有时间再来慢慢搞吧,暂且先这样, 有需要的可以把代码考过去继续弄

<template><div id="app"><div class="f-transfer flex"><!-- left --><div class="f-left"><div class="f-top flex flex-justify-between"><el-checkbox:indeterminate="isIndeterminate"v-model="checkAll"@change="handleCheckAllChange">全选</el-checkbox><span style="color: #606266">{{ SelectNumLeft }}/{{ cities.length }}</span></div><div class="f-search"><el-inputplaceholder="请输入内容"prefix-icon="el-icon-search"@input="search"v-model="input2"></el-input></div><div class="f-container"><el-checkbox-groupv-model="checkedCities"@change="handleCheckedCitiesChange"><el-checkboxv-for="city in cities":label="city.key":key="city.key"class="flex"><el-row :gutter="20"><el-col :span="8"><el-tooltipclass="item"effect="dark":content="city.label"placement="top"><p class="emtys">{{ city.label }}</p></el-tooltip></el-col><el-col :span="12">{{ city.phone }}</el-col><el-col :span="2"><span style="color: #76b9ed" @click="operate(city.key)">操作</span></el-col></el-row></el-checkbox></el-checkbox-group></div><div style="padding: 8px 0"><el-pagination@size-change="handleSizeChange"@current-change="handleCurrentChange":current-page.sync="currentPage":pager-count="5":page-sizes="[10, 20, 30]":page-size="pageSize"smalllayout="prev, pager, next,sizes":total="total"></el-pagination></div></div><!-- middle --><div class="f-middle flex-column"><el-button style="margin: 10px" @click="leftDataFunc"><i class="el-icon-arrow-left"></i></el-button><el-button style="margin: 10px" @click="rightDataFunc"><i class="el-icon-arrow-right"></i></el-button></div><!-- right --><div class="f-right f-left"><div class="f-top flex flex-justify-between"><el-checkbox:indeterminate="isIndeterminateCheck"v-model="checkAllCheck"@change="handleCheckAllChangeCheck">全选</el-checkbox><span style="color: #606266">{{ SelectNumRight }}/{{ citiesCheck.length }}</span></div><div class="f-search"><el-inputplaceholder="请输入内容"prefix-icon="el-icon-search"@input="searchCheck"v-model="input2Check"></el-input></div><div class="f-container"><el-checkbox-groupv-model="checkedCitiesCheck"@change="handleCheckedCitiesChangeCheck"><el-checkboxv-for="city in citiesCheck":label="city.key":key="city.key"class="flex"><el-row :gutter="20"><el-col :span="8"><p class="emtys">{{ city.label }}</p></el-col><el-col :span="12">{{ city.phone }}</el-col><el-col :span="2"><span style="color: #76b9ed" @click="operateCheck(city.key)">操作</span></el-col></el-row></el-checkbox></el-checkbox-group></div></div></div></div>
</template><script>
export default {name: "App",data() {return {checkAll: false, //左侧全选状态checkedCities: [], //左侧勾选中的key数组cities: [], //左侧列表数据列表isIndeterminate: false, //左侧顶部选择状态input2: "", //左侧搜索valuenewCities: [], //左侧搜索时,数据暂存citiesStatus: true, //左侧是否进行暂存数据的状态currentPage: 1, //左侧当前第几页pageSize: 30, //左侧每页显示多少条数据total: 90, //左侧总条数//----------------------------checkAllCheck: false, //右侧全选状态checkedCitiesCheck: [], //右侧勾选中的key数组citiesCheck: [], //右侧列表数据列表isIndeterminateCheck: false, //右侧顶部选择状态input2Check: "", //右侧搜索valuenewCitiesCheck: [], //右侧搜索时,数据暂存citiesStatusCheck: true, //右侧是否进行暂存数据的状态//----------------------------------------
    };},mounted() {this.dataAdd();},watch: {checkedCities: {handler(newval) {if (newval.length == 0) {this.checkAll = false;this.isIndeterminate = false;}},deep: true,immediate: true,},checkedCitiesCheck: {handler(newval) {if (newval.length == 0) {this.checkAllCheck = false;this.isIndeterminateCheck = false;}},deep: true,immediate: true,},},computed: {SelectNumLeft() {return [...new Set(this.checkedCities)].length;},SelectNumRight() {return [...new Set(this.checkedCitiesCheck)].length;},},methods: {operate(key) {let result = this.cities.filter((item) => {return item.key == key;});let arry = this.citiesCheck;arry.push(result[0]);this.checkedCities = this.checkedCities.filter((key) => {return key != result[0].key;});this.cities = this.deleteObjectById(this.cities, result[0].key);this.citiesCheck = this.Deduplication(arry, "key");},//根据id删除对象
    deleteObjectById(arr, key) {return arr.filter((obj) => obj.key != key);},Deduplication(data, key) {var arr1 = data.filter(function (element, index, self) {return self.findIndex((el) => el[key] == element[key]) === index; 
      });// 在重新赋值给datareturn arr1;},search(val) {if (this.citiesStatus) {this.citiesStatus = false;this.newCities = this.cities;}let result = this.newCities.filter((item) => {return item.label.includes(val);});console.log(result, "======result");this.cities = result;if (!val) {this.cities = this.newCities;}},handleCheckAllChange(val) {if (val) {this.cities.forEach((item) => {this.checkedCities.push(item.key);});} else {this.checkedCities = [];}this.isIndeterminate = false;},handleCheckedCitiesChange(value) {let checkedCount = value.length;this.checkAll = checkedCount === this.cities.length;this.isIndeterminate =checkedCount > 0 && checkedCount < this.cities.length;},rightDataFunc() {this.checkedCities = [...new Set(this.checkedCities)];this.checkedCities.forEach((key) => {let result = this.cities.filter((item) => {return key == item.key;})[0];this.citiesCheck.push(result);this.cities = this.deleteObjectById(this.cities, result.key);this.checkedCities = this.checkedCities.filter((key) => {return key != result.key;});});},handleSizeChange(val) {console.log(`每页 ${val} 条`);this.pageSize = val;this.dataAdd();},handleCurrentChange(val) {console.log(`当前页: ${val}`);this.currentPage = val;this.dataAdd();},// ------------------------------------------------------
    leftDataFunc() {this.checkedCitiesCheck = [...new Set(this.checkedCitiesCheck)];this.checkedCitiesCheck.forEach((key) => {let result = this.citiesCheck.filter((item) => {return key == item.key;})[0];this.cities.push(result);this.citiesCheck = this.deleteObjectById(this.citiesCheck, result.key);this.checkedCitiesCheck = this.checkedCitiesCheck.filter((key) => {return key != result.key;});});},operateCheck(key) {let result = this.citiesCheck.filter((item) => {return item.key == key;});let arry = this.cities;arry.push(result[0]);this.checkedCitiesCheck = this.checkedCitiesCheck.filter((key) => {return key != result[0].key;});this.citiesCheck = this.deleteObjectById(this.citiesCheck, result[0].key);this.cities = this.Deduplication(arry, "key");},searchCheck(val) {if (this.citiesStatusCheck) {this.citiesStatusCheck = false;this.newCitiesCheck = this.citiesCheck;}let result = this.newCitiesCheck.filter((item) => {return item.label.includes(val);});console.log(result, "======result");this.citiesCheck = result;if (!val) {this.citiesCheck = this.newCitiesCheck;}},handleCheckAllChangeCheck(val) {if (val) {this.citiesCheck.forEach((item) => {this.checkedCitiesCheck.push(item.key);});} else {this.checkedCitiesCheck = [];}this.isIndeterminateCheck = false;},handleCheckedCitiesChangeCheck(value) {let checkedCountCheck = value.length;this.checkAllCheck = checkedCountCheck === this.citiesCheck.length;this.isIndeterminateCheck =checkedCountCheck > 0 && checkedCountCheck < this.citiesCheck.length;},//------------------------------------------
    dataAdd() {let array = [];for (let i = 0; i < this.pageSize; i++) {let s = (this.currentPage - 1) * this.pageSize + i;let obj = {key: s + 1,label: "王麻子" + (s + 1),phone: "15666667" + (s + 1),status: true,};array.push(obj);}this.cities = array;},},
};
</script><style>
.f-transfer .f-left {width: 320px;border-radius: 10px;overflow: hidden;border: 1px solid #ccc;
}
.flex {display: flex !important;align-items: center;
}
.f-container::-webkit-scrollbar {width: 2px;
}
.f-container::-webkit-scrollbar-thumb {border-radius: 8px;background-color: #c6d1e2;
}
.f-container::-webkit-scrollbar-track {border-radius: 8px;background-color: #f2f7ff;border: 1px solid #f2f7ff;
}
.flex-column {display: flex;flex-direction: column;
}
.flex-justify-between {justify-content: space-between;
}
.f-transfer .f-left .f-top {background: #ccc;height: 30px;padding: 10px;line-height: 30px;
}
.emtys {padding: 0;margin: 0;width: 60px;text-overflow: ellipsis;overflow: hidden;white-space: nowrap;
}
.f-search {padding: 10px;
}
.f-transfer .f-left .f-container {height: 270px;overflow-y: auto;padding: 10px;
}
.el-checkbox-group {display: flex;flex-direction: column;
}
.el-checkbox {margin: 6px 0;
}
</style>

 

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

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

相关文章

pbootcms模板时间格式调用方法详解

在PBootCMS中,时间调用主要通过date标签来实现。以下是一些常用的调用方法及其效果示例: 列表页时间调用默认格式:[list:date] 效果:2021-12-06 09:12:30年月日格式:[list:date style=Y-m-d] 效果:2021-12-06年格式:[list:date style=Y] 效果:2021月日格式:[list:date…

PbootCMS程序利用计划任务执行网站自动推送到百度

<?php header(Content-Type:text/html;charset=utf-8); /** 只需修改这里面的两个链接 **/ $xml_url = "域名/sitemap.xml"; // 这里修改你站点的xml地图链接 $baidu_api = http://data.zz.baidu.com/urls?site=域名&token=123456789;// 这里修改为你在百度…

pbootcms域名授权码怎么获取,获取后怎么授权

在PBootCMS中,域名授权码通常用于验证和授权特定域名的使用。获取并授权域名的过程相对简单。以下是详细的步骤: 获取域名授权码登录PBootCMS官网:访问PBootCMS官方网站(例如:www.pbootcms.com)。 注册并登录你的账户。进入授权管理页面:在官网的用户中心找到“授权管理…

springboot-实现excle文件导出功能

后端直接生成一个excle文件,提供给前端进行下载 1、依赖<!-- excle操作--><dependency><groupId>cn.hutool</groupId><artifactId>hutool-all</artifactId><version>5.3.8</version></dependency><dependency>&l…

【新品上市】正点原子ZYNQ7015开发板发布!ZYNQ 7000系列、双核ARM、PCIe2.0、SFPX2,性能强悍,资料丰富!

【新品发布】正点原子ZYNQ7015开发板发布!ZYNQ 7000系列、双核ARM、PCIe2.0、SFPX2,性能强悍,资料丰富! 正点原子Z15 ZYNQ开发板,搭载Xilinx Zynq7000系列芯片,核心板主控芯片的型号是XC7Z015CLG485-2。开发板由核心板+底板组成,外设资源丰富,板载1路PS端千兆以太网接…

Nginx 4层代理获取客户端真实IP

架构4层代理配置 stream {upstream backend {server 10.4.7.30:80;}server {listen 80;proxy_pass backend;proxy_connect_timeout 1s;proxy_protocol on ; # 主要是把这个参数开上} }后端nginx配置 注意这种方式客户端不能够直接访问后端服务器。 conf.d]# cat mywebsite.con…

springboot jar包瘦身

现在的项目结构是业务包引用comomn包,common包里又引用了很多其他的jar包,导致业务包打包出来动则就是一百甚至两百兆,现在要做到把公共的包放出来,放到一个单独的文件夹,业务包里只放业务代码。 现在只需要修改maven build节点如下:<build><finalName>pager…

记一次 .NET某上位机视觉程序 卡死分析

一:背景 1. 讲故事 前段时间有位朋友找到我,说他的窗体程序在客户这边出现了卡死,让我帮忙看下怎么回事?dump也生成了,既然有dump了那就上 windbg 分析吧。 二:WinDbg 分析 1. 为什么会卡死 窗体程序的卡死,入口门槛很低,后续往下分析就不一定了,不管怎么说先用 !clrs…

QT6 QML编程

QT6 QML编程使用AI技术辅助生成 [QT界面美化视频课程](https://edu.csdn.net/lecturer/7637)[QT性能优化视频课程](https://edu.csdn.net/lecturer/7637)[QT原理与源码分析视频课程](https://edu.csdn.net/lecturer/7637)[QT QML C++扩展开发视频课程](https://edu.csdn.net/le…

php短视频系统,提升系统健壮性离不开重试机制

php短视频系统,提升系统健壮性离不开重试机制随着互联网的发展php短视频系统中的业务功能越来越复杂,有一些基础服务我们不可避免的会去调用一些第三方的接口或者公司内其他项目中提供的服务,但是远程服务的健壮性和网络稳定性都是不可控因素。在测试阶段可能没有什么异常情…

前端基本功——面试必问系列(1):都2024了,还没吃透Promise?一文搞懂

该系列文章是为了帮助大家不管面试还是开发对前端的一些基本但是很重要的知识点认识更加深入和全面。想写这个系列文章的初衷是:我发现前端的很多基本知识。为什么用?怎么用会更好?原理是什么?很多人并不清楚写在前面: 大家好,我是山里看瓜,该系列文章是为了帮助大家不管…