欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

vue實(shí)現(xiàn)彈窗翻頁多選效果

 更新時(shí)間:2022年08月30日 15:25:05   作者:朝陽39  
這篇文章主要為大家詳細(xì)介紹了vue實(shí)現(xiàn)彈窗翻頁多選效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了vue實(shí)現(xiàn)彈窗翻頁多選效果的具體代碼,供大家參考,具體內(nèi)容如下

最終效果

點(diǎn)選擇按鈕后,彈出選擇用戶彈窗,可翻頁勾多個(gè)用戶 

完整代碼

<template>
? ? <div>
? ? ? ? <el-button size="small" type="primary" @click="choose">選擇</el-button>
? ? ? ? <p>
? ? ? ? ? ? <el-tag v-for="(item,index) in allSelectedUserList" :key="index"
? ? ? ? ? ? ? ? ? ? @close="removeUser(index)"
? ? ? ? ? ? ? ? ? ? style="margin-right: 10px"
? ? ? ? ? ? ? ? ? ? closable>
? ? ? ? ? ? ? ? {{item.name}}
? ? ? ? ? ? </el-tag>
? ? ? ? </p>
? ? ? ? <el-dialog :visible.sync="dialogVisible" title="選擇用戶" v-if="dialogVisible" width="40%" append-to-body>
? ? ? ? ? ? <s-table ref="table" @selectionChange="selectionChange" @loadData="loadData" :data="tableData"
? ? ? ? ? ? ? ? ? ? ?:config="tableConfig"></s-table>
? ? ? ? ? ? <span slot="footer">
? ? <el-button @click="dialogVisible = false" size="mini">取 消</el-button>
? ? <el-button @click="chooseConfirm" size="mini" type="primary">確 定</el-button>
? ? </span>
? ? ? ? </el-dialog>
? ? </div>
</template>
<script>
? ? export default {
? ? ? ? data() {
? ? ? ? ? ? return {
? ? ? ? ? ? ? ? dialogVisible: false,
? ? ? ? ? ? ? ? // 最終選中的所有數(shù)據(jù)
? ? ? ? ? ? ? ? allSelectedUserList: [],
? ? ? ? ? ? ? ? // 最終選中的全部唯一字段列表
? ? ? ? ? ? ? ? allUniquePropList: [],
? ? ? ? ? ? ? ? // 唯一字段
? ? ? ? ? ? ? ? uniqueProp: 'id',
? ? ? ? ? ? ? ? // 每次彈窗中選中的所有數(shù)據(jù)
? ? ? ? ? ? ? ? allSelectedList: [],
?
? ? ? ? ? ? ? ? tableData: [],
? ? ? ? ? ? ? ? tableConfig: {
? ? ? ? ? ? ? ? ? ? showSelect: true,
? ? ? ? ? ? ? ? ? ? selectable: (row, rowIndex) => {
? ? ? ? ? ? ? ? ? ? ? ? if (this.allUniquePropList.indexOf(row[this.uniqueProp]) === -1) {
? ? ? ? ? ? ? ? ? ? ? ? ? ? if (rowIndex === row.index) {
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? return false
? ? ? ? ? ? ? ? ? ? ? ? ? ? } else {
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? return true
? ? ? ? ? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ? },
? ? ? ? ? ? ? ? ? ? pageConfig: {
? ? ? ? ? ? ? ? ? ? ? ? pageSizeList: [3, 5, 10],
? ? ? ? ? ? ? ? ? ? ? ? pageSize: 3,
? ? ? ? ? ? ? ? ? ? ? ? currentPage: 1,
? ? ? ? ? ? ? ? ? ? ? ? total: 0
? ? ? ? ? ? ? ? ? ? },
? ? ? ? ? ? ? ? ? ? itemList: [
? ? ? ? ? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? ? ? label: 'id',
? ? ? ? ? ? ? ? ? ? ? ? ? ? prop: 'id'
? ? ? ? ? ? ? ? ? ? ? ? },
? ? ? ? ? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? ? ? label: '姓名',
? ? ? ? ? ? ? ? ? ? ? ? ? ? prop: 'name'
? ? ? ? ? ? ? ? ? ? ? ? },
? ? ? ? ? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? ? ? label: '年齡',
? ? ? ? ? ? ? ? ? ? ? ? ? ? prop: 'age'
? ? ? ? ? ? ? ? ? ? ? ? },
? ? ? ? ? ? ? ? ? ? ],
? ? ? ? ? ? ? ? }
? ? ? ? ? ? }
? ? ? ? },
? ? ? ? mounted() {
? ? ? ? ? ? this.loadData()
? ? ? ? },
? ? ? ? methods: {
? ? ? ? ? ? // 點(diǎn)擊選擇按鈕
? ? ? ? ? ? choose() {
? ? ? ? ? ? ? ? this.allUniquePropList = []
? ? ? ? ? ? ? ? this.allSelectedUserList.forEach(
? ? ? ? ? ? ? ? ? ? item => {
? ? ? ? ? ? ? ? ? ? ? ? this.allUniquePropList.push(item[this.uniqueProp])
? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? )
? ? ? ? ? ? ? ? this.allSelectedList = []
? ? ? ? ? ? ? ? this.dialogVisible = true
? ? ? ? ? ? },
? ? ? ? ? ? // 點(diǎn)擊選擇彈窗的確定按鈕
? ? ? ? ? ? chooseConfirm() {
? ? ? ? ? ? ? ? this.allSelectedUserList = this.allSelectedUserList.concat(this.allSelectedList)
? ? ? ? ? ? ? ? this.dialogVisible = false
? ? ? ? ? ? },
? ? ? ? ? ? // 加載數(shù)據(jù)
? ? ? ? ? ? loadData(newPageConfig) {
? ? ? ? ? ? ? ? if (newPageConfig && newPageConfig.currentPage) {
? ? ? ? ? ? ? ? ? ? this.tableConfig.pageConfig.currentPage = newPageConfig.currentPage
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? if (newPageConfig && newPageConfig.pageSize) {
? ? ? ? ? ? ? ? ? ? this.tableConfig.pageConfig.pageSize = newPageConfig.pageSize
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? this.$http.get("/user/pages", {
? ? ? ? ? ? ? ? ? ? params: {
? ? ? ? ? ? ? ? ? ? ? ? currentPage: this.tableConfig.pageConfig.currentPage,
? ? ? ? ? ? ? ? ? ? ? ? pageSize: this.tableConfig.pageConfig.pageSize
? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? })
? ? ? ? ? ? ? ? ? ? .then(res => {
? ? ? ? ? ? ? ? ? ? ? ? let data = res.data
? ? ? ? ? ? ? ? ? ? ? ? this.tableData = data.records;
? ? ? ? ? ? ? ? ? ? ? ? this.tableConfig.pageConfig.total = data.total
? ? ? ? ? ? ? ? ? ? ? ? this.updateSelectedMark()
? ? ? ? ? ? ? ? ? ? })
? ? ? ? ? ? },
? ? ? ? ? ? // 改變多選列的選中狀態(tài)時(shí),更新選中列表
? ? ? ? ? ? selectionChange(pageSelectedList) {
? ? ? ? ? ? ? ? // 當(dāng)頁唯一字段組成的列表
? ? ? ? ? ? ? ? let uniquePropList = []
? ? ? ? ? ? ? ? this.tableData.forEach(row => {
? ? ? ? ? ? ? ? ? ? uniquePropList.push(row[this.uniqueProp])
? ? ? ? ? ? ? ? })
? ? ? ? ? ? ? ? // 從全部選中的數(shù)據(jù)中,過濾掉當(dāng)前頁的數(shù)據(jù),再添加當(dāng)前頁選中的數(shù)據(jù)
? ? ? ? ? ? ? ? this.allSelectedList = this.allSelectedList.filter(row =>
? ? ? ? ? ? ? ? ? ? !uniquePropList.includes(row[this.uniqueProp])
? ? ? ? ? ? ? ? ).concat(pageSelectedList)
? ? ? ? ? ? },
? ? ? ? ? ? // 更新選中標(biāo)記--選中數(shù)據(jù)與當(dāng)頁數(shù)據(jù)的交集,標(biāo)記為選中狀態(tài)
? ? ? ? ? ? updateSelectedMark() {
? ? ? ? ? ? ? ? this.$nextTick(
? ? ? ? ? ? ? ? ? ? () => {
? ? ? ? ? ? ? ? ? ? ? ? let pageSelectedList = []
? ? ? ? ? ? ? ? ? ? ? ? this.allSelectedList.forEach(row1 => {
? ? ? ? ? ? ? ? ? ? ? ? ? ? this.tableData.forEach(row2 => {
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? if (row1[this.uniqueProp] === row2[this.uniqueProp]) {
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? pageSelectedList.push(row2)
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ? ? ? ? ? })
? ? ? ? ? ? ? ? ? ? ? ? })
? ? ? ? ? ? ? ? ? ? ? ? pageSelectedList.forEach(row => {
? ? ? ? ? ? ? ? ? ? ? ? ? ? this.$refs.table.toggleRowSelection(row);
? ? ? ? ? ? ? ? ? ? ? ? })
? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? )
? ? ? ? ? ? },
? ? ? ? ? ? // 移除選擇的用戶
? ? ? ? ? ? removeUser(index) {
? ? ? ? ? ? ? ? this.allSelectedUserList.splice(index, 1);
? ? ? ? ? ? },
? ? ? ? }
? ? }
</script>
<style scoped>
</style>

s-table全局表格組件

<template>
? ? <div>
? ? ? ? <el-table
? ? ? ? ? ? ? ? ref="table"
? ? ? ? ? ? ? ? @select="rowSelectChange"
? ? ? ? ? ? ? ? @select-all="pageSelectChange"
? ? ? ? ? ? ? ? @row-click="getCurrentRow"
? ? ? ? ? ? ? ? :data="data"
? ? ? ? ? ? ? ? border
? ? ? ? ? ? ? ? :highlight-current-row="!config.closeHighlightRow"
? ? ? ? ? ? ? ? empty-text="暫無數(shù)據(jù)">
? ? ? ? ? ? <el-table-column
? ? ? ? ? ? ? ? ? ? :selectable="config.selectable"
? ? ? ? ? ? ? ? ? ? v-if="config.showSelect"
? ? ? ? ? ? ? ? ? ? type="selection"
? ? ? ? ? ? ? ? ? ? width="55">
? ? ? ? ? ? </el-table-column>
? ? ? ? ? ? <el-table-column
? ? ? ? ? ? ? ? ? ? :align="item.align?item.align:'center'"
? ? ? ? ? ? ? ? ? ? :label=item.label
? ? ? ? ? ? ? ? ? ? :prop=item.prop
? ? ? ? ? ? ? ? ? ? :min-width="item.minWidth?item.minWidth:'120'"
? ? ? ? ? ? ? ? ? ? :formatter="item.formatter"
? ? ? ? ? ? ? ? ? ? v-for="(item,index) in config.itemList"
? ? ? ? ? ? ? ? ? ? :key="index"
? ? ? ? ? ? >
? ? ? ? ? ? </el-table-column>
? ? ? ? ? ? <slot name="操作">
? ? ? ? ? ? </slot>
? ? ? ? </el-table>
? ? ? ? <!-- 分頁 -->
? ? ? ? <div style="text-align: right">
? ? ? ? ? ? <el-pagination
? ? ? ? ? ? ? ? ? ? :current-page="config.pageConfig.currentPage"
? ? ? ? ? ? ? ? ? ? :page-size="config.pageConfig.pageSize"
? ? ? ? ? ? ? ? ? ? :page-sizes="config.pageConfig.pageSizeList"
? ? ? ? ? ? ? ? ? ? :total="config.pageConfig.total"
? ? ? ? ? ? ? ? ? ? @current-change="currentPageChange"
? ? ? ? ? ? ? ? ? ? @size-change="pageSizeChange"
? ? ? ? ? ? ? ? ? ? layout="total, sizes, prev, pager, next, jumper"
? ? ? ? ? ? ? ? ? ? style="margin: 20px 0px"
? ? ? ? ? ? ></el-pagination>
? ? ? ? </div>
? ? </div>
</template>
<script>
? ? export default {
? ? ? ? props: {
? ? ? ? ? ? data: Array,
? ? ? ? ? ? config: Object,
? ? ? ? ? ? selectable: Function
? ? ? ? },
? ? ? ? data() {
? ? ? ? ? ? return {}
? ? ? ? },
? ? ? ? methods: {
? ? ? ? ? ? rowSelectChange(pageSelected, row) {
? ? ? ? ? ? ? ? this.$emit('selectionChange',
? ? ? ? ? ? ? ? ? ? pageSelected,
? ? ? ? ? ? ? ? )
? ? ? ? ? ? },
? ? ? ? ? ? pageSelectChange(pageSelected) {
? ? ? ? ? ? ? ? this.$emit('selectionChange', pageSelected)
? ? ? ? ? ? },
? ? ? ? ? ? toggleRowSelection(row) {
? ? ? ? ? ? ? ? this.$refs.table.toggleRowSelection(row);
? ? ? ? ? ? },
? ? ? ? ? ? selectionChange(pageSelected) {
? ? ? ? ? ? ? ? this.$emit('selectionChange', pageSelected)
? ? ? ? ? ? },
? ? ? ? ? ? currentPageChange(newPage) {
? ? ? ? ? ? ? ? this.$emit('loadData',
? ? ? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? currentPage: newPage
? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? )
? ? ? ? ? ? },
? ? ? ? ? ? pageSizeChange(newPageSize) {
? ? ? ? ? ? ? ? this.$emit('loadData',
? ? ? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? pageSize: newPageSize
? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? )
? ? ? ? ? ? },
? ? ? ? ? ? getCurrentRow(row) {
? ? ? ? ? ? ? ? this.$emit('getCurrentRow', row)
? ? ? ? ? ? }
? ? ? ? }
? ? }
</script>
<style scoped>
</style>

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • 如何在vue里添加好看的lottie動(dòng)畫

    如何在vue里添加好看的lottie動(dòng)畫

    這篇文章主要介紹了在vue里添加好看的lottie動(dòng)畫效果的方法,在vue中引入lottie非常簡(jiǎn)單,需要的朋友可以參考下
    2018-08-08
  • Vue學(xué)習(xí)之常用指令實(shí)例詳解

    Vue學(xué)習(xí)之常用指令實(shí)例詳解

    這篇文章主要介紹了Vue學(xué)習(xí)之常用指令,結(jié)合實(shí)例形式詳細(xì)分析了vue.js創(chuàng)建實(shí)例、常用指令及相關(guān)操作技巧,需要的朋友可以參考下
    2020-01-01
  • Vite使用Esbuild提升性能詳解

    Vite使用Esbuild提升性能詳解

    這篇文章主要為大家介紹了Vite使用Esbuild提升性能示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-08-08
  • vue使用Office?Web實(shí)現(xiàn)線上文件預(yù)覽

    vue使用Office?Web實(shí)現(xiàn)線上文件預(yù)覽

    這篇文章主要為大家介紹了vue使用微軟的開發(fā)接口Office?Web,實(shí)現(xiàn)線上文件預(yù)覽,預(yù)覽word,excel,pptx,pdf文件,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-07-07
  • Vue無法讀取HTMLCollection列表的length問題解決

    Vue無法讀取HTMLCollection列表的length問題解決

    這篇文章主要介紹了Vue無法讀取HTMLCollection列表的length問題解決方案,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2024-03-03
  • vue3.0之Router的使用你了解嗎

    vue3.0之Router的使用你了解嗎

    這篇文章主要為大家詳細(xì)介紹了vue3.0之Router的使用,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下,希望能夠給你帶來幫助
    2022-03-03
  • vue實(shí)現(xiàn)原理this.$message實(shí)例詳解

    vue實(shí)現(xiàn)原理this.$message實(shí)例詳解

    這篇文章主要介紹了vue實(shí)現(xiàn)原理this.$message實(shí)例詳解,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友參考下吧
    2024-03-03
  • 在vue中使用v-bind:class的選項(xiàng)卡方法

    在vue中使用v-bind:class的選項(xiàng)卡方法

    今天小編就為大家分享一篇在vue中使用v-bind:class的選項(xiàng)卡方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
    2018-09-09
  • Vue使用Clipboard.JS在h5頁面中復(fù)制內(nèi)容實(shí)例詳解

    Vue使用Clipboard.JS在h5頁面中復(fù)制內(nèi)容實(shí)例詳解

    在本篇文章里小編給大家整理了關(guān)于Vue使用Clipboard.JS在h5頁面中復(fù)制內(nèi)容以及相關(guān)知識(shí)點(diǎn)內(nèi)容,需要的朋友們可以學(xué)習(xí)下。
    2019-09-09
  • VUE 更好的 ajax 上傳處理 axios.js實(shí)現(xiàn)代碼

    VUE 更好的 ajax 上傳處理 axios.js實(shí)現(xiàn)代碼

    本篇文章主要介紹了VUE 更好的 ajax 上傳處理 axios.js實(shí)現(xiàn)代碼,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2017-05-05

最新評(píng)論