当前位置:网站首页>El table supports paging multiple selection
El table supports paging multiple selection
2022-07-21 18:58:00 【Come and play games with others】
<template>
<div>
<el-dialog
:title="` Include material type `"
:visible.sync="visible"
width="60%"
center
append-to-body
:before-close="handleClose"
>
<div
class="box"
v-loading="tableLoading"
>
<!-- Content area -->
<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=" name "
align="center"
min-width="250"
>
</el-table-column>
</el-table>
</div>
<!-- Pagination -->
<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')"
> indeed set </el-button>
<el-button
size="mini"
@click="handleClose"
> take eliminate </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: [],
// Pager
pagination: {
total: 300,
page: 1,
page_size: 10
},
// Remove in bulk
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: {
// Raw acquisition data
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
}
},
// Paging data
paginationChange (page, pageSize) {
this.getData({
page,
page_size: pageSize
})
},
// Multiple selection modification
handleSelectionChange (val) {
// this.aboutBatchDele.singlePage = val.map(item => item.id)
// Sorting the current page is deleted id
let valItem = val.map(item => {
return item.id
})
// Modifying the current page is to delete the function
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) {
// Enter and remove the part
if (!valItem.includes(id)) {
this.aboutBatchDele.deleArr.push(id)
}
} else {
// There is no need to remove some
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
}
})
// Update page
this.$nextTick(() => {
let valItem = this.aboutBatchDele.deleArr
this.tableData.forEach(item => {
if (valItem.includes(item.id)) {
this.$refs.multipleTable.toggleRowSelection(item);
}
})
})
},
// close
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>
边栏推荐
- C语言经典实例:21-30例:插入排序、希尔排序1、快速排序、希尔排序2、递归法、完数、斐波那契数列、公约数和公倍数、判断水仙花数统计单词个数
- STM32F40x 最小系统
- [04] through the power consumption wall, what aspects should we improve "performance"?
- Involution: Inverting the Inherence of Convolution for Visual Recognition(CVPR2021)
- Solution to field 'ID' doesn't have a default value error
- Redis+Caffeine两级缓存,让访问速度纵享丝滑
- Custom paging label
- 全新红包封面平台可搭建分站独立后台的源码
- ACM training July 5
- Splicing of SRC variables in wechat applet pictures
猜你喜欢
Stm32 DHT11 temperature and humidity sensor module learning summary
最新开源!基于LiDAR的位置识别网络OverlapTransformer,RAL/IROS 2022
牛客网刷题篇
ES 自定义分析器
0715今日歌单 One Last Kiss, 耗尽
Hongmeng harmonios deveco studio reported an error unistall_ FAILED_ INTERNAL_ ERROR
Apple released watchos 8.7 with bug fixes and security updates
Exchange class sorting
Visual solution of digital twin landing high-speed railway bridge
第一部分—C语言基础篇_8. 内存管理
随机推荐
bryntum gantt 5.0.6
ESB結合UMC雲平臺開發說明
Custom paging label
C语言经典实例:21-30例:插入排序、希尔排序1、快速排序、希尔排序2、递归法、完数、斐波那契数列、公约数和公倍数、判断水仙花数统计单词个数
字符串首尾空格去除问题
Introduction to C language --- operators
General paging (encapsulation of paging code)
ACM training July 4
C language practice topic + answer: 26-30
Part I - Fundamentals of C language_ 10. Document operation
生成二维码
Involution: Inverting the Inherence of Convolution for Visual Recognition(CVPR2021)
C语言练习题目+答案:21-25
有趣的 Kotlin 0x0D:IntArray vs Array<Int>
DOS命令导出文件夹内所有文件的名称和全路径
教程篇(7.0) 03. FortiClient EMS配置和管理 * FortiClient EMS * Fortinet 网络安全专家 NSE 5
在线问题反馈模块实战(九):实现图片上传功能(下)
0715今日歌单 One Last Kiss, 耗尽
Design of the multi live architecture in different places of the king glory mall
Embedded learning: introduction to Cortex-M series chips