当前位置:网站首页>el-table支持分页多选
el-table支持分页多选
2022-07-21 02:23:00 【来陪人家玩游戏嘛】
<template>
<div>
<el-dialog
:title="`包含素材类型`"
:visible.sync="visible"
width="60%"
center
append-to-body
:before-close="handleClose"
>
<div
class="box"
v-loading="tableLoading"
>
<!-- 内容区域 -->
<div class="contend">
<el-table
:data="tableData"
ref="multipleTable"
stripe
border
style="width: 100%"
@select="handleSelectionChange"
@select-all="handleSelectionChange"
>
<el-table-column
type="selection"
width="55"
>
</el-table-column>
<el-table-column
prop="id"
label="id"
align="center"
width="100"
>
</el-table-column>
<el-table-column
prop="name"
label="名称"
align="center"
min-width="250"
>
</el-table-column>
</el-table>
</div>
<!-- 分页 -->
<Pagination
v-if="tableData.length > 0"
:total.sync="pagination.total"
:page.sync="pagination.page"
:page_size.sync="pagination.page_size"
@paginationChange="paginationChange"
></Pagination>
</div>
<div class="flex mt40">
<el-button
size="mini"
type="primary"
style="marginRight: 100px"
@click="submit('ruleForm')"
>确 定</el-button>
<el-button
size="mini"
@click="handleClose"
>取 消</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import {
getPaletteTypeList } from '@/api/product.js'
import _ from 'lodash'
import Pagination from '@/components/pagination/index.vue'
export default {
data () {
return {
tableLoading: false,
tableData: [],
// 分页器
pagination: {
total: 300,
page: 1,
page_size: 10
},
// 批量移除
aboutBatchDele: {
deleArr: [],
singlePage: []
}
}
},
watch: {
visible () {
if (this.visible) {
this.pagination.page = 1
this.pagination.page_size = 10
this.getData({
page: this.pagination.page, page_size: this.pagination.page_size })
this.aboutBatchDele.deleArr = this.propData
}
}
},
props: {
visible: {
type: Boolean
},
propData: {
type: Array
},
},
methods: {
// 原始获取数据
async getData (obj) {
let results = await getPaletteTypeList({
...obj })
console.log(results)
if (results.data.code === 200 && results.data.msg === 'OK') {
this.tableData = _.cloneDeep(results.data.data)
this.managesinglePageForDele(_.cloneDeep(results.data.data))
this.pagination.total = results.data.page.total
}
},
// 分页获取数据
paginationChange (page, pageSize) {
this.getData({
page,
page_size: pageSize
})
},
// 多选修改
handleSelectionChange (val) {
// this.aboutBatchDele.singlePage = val.map(item => item.id)
// 整理当前页是删除的id
let valItem = val.map(item => {
return item.id
})
// 修改当前页是删除功能的
this.aboutBatchDele.singlePage.forEach(item => {
if (valItem.includes(item.id)) {
item.isDele = true
this.manageDeleArr(item.id, true)
} else {
item.isDele = false
this.manageDeleArr(item.id, false)
}
})
console.log(this.aboutBatchDele.deleArr);
},
manageDeleArr (id, status) {
let valItem = this.aboutBatchDele.deleArr
if (status) {
// 入移除部分
if (!valItem.includes(id)) {
this.aboutBatchDele.deleArr.push(id)
}
} else {
// 不需要移除部分
this.aboutBatchDele.deleArr = valItem.filter(item => {
if (item !== id) return true
})
}
},
managesinglePageForDele (Arr) {
this.aboutBatchDele.singlePage = Arr
console.log(this.aboutBatchDele.deleArr);
this.aboutBatchDele.singlePage.forEach(item => {
if (this.aboutBatchDele.deleArr.includes(item.id)) {
item.isDele = false
} else {
item.isDele = true
}
})
// 更新页面
this.$nextTick(() => {
let valItem = this.aboutBatchDele.deleArr
this.tableData.forEach(item => {
if (valItem.includes(item.id)) {
this.$refs.multipleTable.toggleRowSelection(item);
}
})
})
},
// 关闭
handleClose () {
this.$emit('change', false)
this.$emit('update:visible', false)
},
submit () {
console.log(this.aboutBatchDele.deleArr);
this.$emit('change', this.aboutBatchDele.deleArr)
this.$emit('update:visible', false)
},
},
components: {
Pagination
}
}
</script>
<style scoped lang="less">
.box {
padding: 15px 15px;
}
.topSearch {
background-color: #fff;
border-radius: 10px;
}
</style>
边栏推荐
- Php-cgi Remote Code Execution Vulnerability (cve-2012-1823)
- Tio2-fe3o4/mil-101 (CR) magnetic composite photocatalytic material | nano drug carriers with core-shell structure (siRNA pcnps)
- GrayLog分布式日志组件来提高查日志效率!
- 苹果公司发布watchOS 8.7 包含错误修复和安全更新
- Kwai wants to grab the shell cake. Is online selling a good business?
- 数字孪生应用案例及常用技术
- Golang collection: custom types and method sets
- Getting started with ctfshow web (included in the file)
- 工业4.0数字孪生下的应用案例
- Skiasharp's WPF self drawn bouncing ball (case version)
猜你喜欢
Explore the database, Chinese field sorting, what is it
It is not just products that keep pace with the times. Look at FAW Toyota's confidence in "Second Entrepreneurship" from Carola Ruifang
Custom paging label
Ctfhub information disclosure
Introduction to C language --- operators
KV260(一)运行AI Box
视频融合云平台EasyCVR重启服务器后,级联离线如何解决?
触发器基础知识(上)
LeetCode:06Z字形变换
Solution to field 'ID' doesn't have a default value error
随机推荐
The domestic epidemic is repeated. How can offline physical stores be transformed to break through the dilemma?
Php-cgi Remote Code Execution Vulnerability (cve-2012-1823)
读秀数据库的用法+全国图书馆参考咨询联盟
【翻译】开发人员的技术写作
洛谷P5142 区间方差 题解
Can messages in CAPL: declaration, sending and receiving
机器学习-单变量线性回归
接口幂等性
0715今日歌单 One Last Kiss, 耗尽
Face recognition attendance system based on jsp/servlet
从部队文职转行程序员,我有这些体会
The longest valid bracket of question 32 in C language. Implement with stack
C language practice topic + answer: 26-30
通用分页(分页代码的封装)
LeetCode:1260. 二维网格迁移【一维展开+拼接】
What impact will Microsoft's closure of basic authentication have on enterprises and employees?
Solution to field 'ID' doesn't have a default value error
纯干货内容:关于ivx和mendix的对比 还在犹豫选择那个低代码平台的小伙伴看过来
Graylog distributed log component to improve the efficiency of log checking!
C language -- 24 Gobang