当前位置:网站首页>vxe-table 从页面批量删除数据 (不动数据库里的数据)
vxe-table 从页面批量删除数据 (不动数据库里的数据)
2022-08-04 00:36:00 【paradoxaaa_】
<vxe-table v-if="options"
ref="vxeTable"
border
:column-config="{resizable: true}"
:row-config="{isCurrent: true, isHover: true,keyField:'id'}"
:checkbox-config="{range: true,reserve: true,trigger: 'row'}"
@checkbox-all="selectAllEvent"
@checkbox-change="selectChangeEvent"
v-loading="options.loading"
>
<vxe-table-column type="checkbox" width="38"></vxe-table-column>
</vxe-table>
<div class="btn-del">
<vxe-button status="primary" @click="markedDelHandle"
:disabled="disableHandle">Marked Del</vxe-button>
<vxe-button @click="UnMarkedDelHandle" :disabled="disableHandle">UnMarkedDelHandle</vxe-button>
</div>思路:先将选中数据保存在新数组arr中 然后定义一个空数组datas,遍历表格所有数据(这里是options.data) 如果不存在选定的数组arr 就把表格其他数据添加到空数组datas中 然后页面只显示新的datas。
// 全选
selectAllEvent ({ checked, records}) {
this.filterData = records;
this.checkedList= records;
// 无选中数据时禁用按钮
if (records && records.length) {
this.disableHandle = false;
} else{
this.disableHandle = true;
}
console.log(checked ? '所有勾选事件' : '所有取消事件', records)
this.$emit("checkChanged", records);
},
// 复选
selectChangeEvent ({ checked, records }) {
this.filterData = records;
this.checkedList= records;
if (records && records.length) {
this.disableHandle = false;
} else{
this.disableHandle = true;
}
console.log(checked ? '勾选事件' : '取消事件', records)
this.$emit("checkChanged", records);
},
// 删除选中行数据
markedDelHandle (){
let arr=this.checkedList; //选中的数据
let datas = [];
this.options.data.forEach((item)=>{
if(arr.indexOf(item) === -1 ){
datas.push(item)
}
})
this.options.data = datas
},
// 保留选中行数据
UnMarkedDelHandle (){
this.options.data = this.checkedList
},
边栏推荐
猜你喜欢
随机推荐
Apple told Qualcomm: I bought a new campus for $445 million and may plan to speed up self-development of baseband chips
【杂项】如何将指定字体装入电脑然后能在Office软件里使用该字体?
Web3 security risks daunting?How should we respond?
研究生新生培训第四周:MobileNetV1, V2, V3
typescript48 - type compatibility between functions
苹果对高通说:我4.45亿美元买下一个新园区,可能计划加快基带芯片自研
免费的公共WiFi不要乱连,遭中间人攻击了吧?
越来越火的图数据库到底能做什么?
jmeter跨平台运行csv等文件
关于mnn模型输出的数据杂乱无章问题
扩展卡尔曼滤波EKF
Justin Sun was invited to attend the 36氪 Yuan Universe Summit and delivered a keynote speech
MPLS综合实验
After building the pytorch environment, the pip and conda commands cannot be used
MATLAB三维绘图命令plot3入门
WMS仓储管理系统能解决电子行业哪些仓库管理问题
【详细教程】一文参透MongoDB聚合查询
Shell编程之循环语句(for、while)
Getting started with MATLAB 3D drawing command plot3
.NET静态代码织入——肉夹馍(Rougamo) 发布1.1.0








