Vue 实现封装combogrid表格网格(Easyui框架有类似的)(二)

在这里插入图片描述

一、i-table.vue组件的封装

table表格组件的封装很有必要,毕竟有的系统基本上每个页面都会有表格组件,封装起来不会让单页面的代码看起来很臃肿,使用起来也很方便。
template

<template>
    <div style="height: 100%;" class="table-div">
        <itoolbar :toolbar="toolbar" :toolbarId="toolbarId"></itoolbar>
        <div class="i-table">
            <div class="table-container">
                <el-table ref="table" :id="'table_'+toolbarId" :data="tableData" border :height="height" row-key="id"
                @selection-change="handleSelectionChange" 
                @row-click="rowclick" :row-class-name="tableRowClassName" :row-style="selectHignLiaght"
                :highlight-current-row="highlightCurrentRow" @current-change="handleChange">
                    <el-table-column v-if="showSelection" type="selection" width="55" align="center">
                    </el-table-column>
                    <el-table-column v-if="highlightCurrentRow" width="55" align="center">
                        <template slot-scope="scope">
                            <el-radio v-model="radiovlaue" :label="scope.$index+''">{
   {
   &nbsp;}}</el-radio>
                        </template>
                    </el-table-column>
                    <slot></slot>
                </el-table>
            </div>
            <div class="pagination-container" v-if="showPagination">
                <el-pagination @size-change="handleSizeChange"
                            @current-change="handleCurrentChange"
                            :current-page="pageInfo.pageIndex"
                            :page-sizes="[10, 20, 30, 50, 60, 70, 80, 90]"
                            :page-size="pageInfo.pageSize"
                            :pager-count="5"
                            background
                            layout="total, sizes, prev, pager, next, jumper"
                            :total="pageInfo.pageTotal">
                </el-pagination>
            </div>
        </div>
    </div>
</template>

script

<script>
import debounce from '../modules/debounce.js';
import Itoolbar from './i-toolBar.vue';
import {
    EventBus } from '../modules/event-bus';
import Sortable from 'sortablejs';
export default {
   
        name: 'i-table',
        components: {
   Itoolbar},
        props: {
   
            toolbarId: {
    // 绑定的id
                type: String,
                default: ''
            },
            showSelection: {
    // 是否多选
                type: Boolean,
                default: true
            },
            showPagination: {
    // 是否显示分页
                type: Boolean,
                default: true
            },
            highlightCurrentRow: {
    // 是否单选
                type: Boolean,
                default: false
            },
            itemList: {
    // 表头数据
                type: Array,
                default: () => {
   
                    return []
                }
            },
            toolbar: {
    // 表头按钮
                type: Array,
                default: () => {
   
                    return []
                }
            },
            searchList: {
    // 表头查询数据集
                type: Array,
                default: () => {
   
                    return []
                }
            },
            pageInfo: {
    // 表格分页
                type: Object,
                default: () => {
   
                    return {
   
                        pageIndex: 1, // 当前页
                        pageSize: 10, // 每页行数
                        pageTotal: 0 // 页总数
                    }
                }
            },
            // tableData: { // 表格数据
            //     type: Array,
            //     default: () => {
   
            //         return []
            //     }
            // },
            selectHignLiaght: {
    // style
                type: Function,
                
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值