当前位置: 首页 > news >正文

elemeentui el-table封装

elemeentui el-table封装 

<template><div style="height: 100%;"><el-table ref="sneTable"  element-loading-text="加载中" element-loading-spinner="el-icon-loading"element-loading-background="rgba(45,47,79, 0.8)" :border="border" :stripe="stripe" :height="height":max-height="maxHeight" :size="size" :row-key="rowKey" :data="dataSource" style="width: 99%;font-size: 14px ":default-expand-all="isExpandAll" :tree-props="treeProps" :span-method="onSpanMethod"@current-change="currentRowChange" @selection-change="selectionChange" @row-click="rowClick"@sort-change="sortChange"><div slot="empty" class="relative"><empty /></div><el-table-column v-if="selector" reserve-selection fixed="left" type="selection" header-align="center"align="center" width="50" :selectable="checkSelectTable" /><el-table-column v-if="index" align="center" fixed="left" type="index" label="序号" width="50"></el-table-column><template v-for="(column, i) in columns"><el-table-column v-if="isShow(column)" :key="i" :prop="column.prop" :label="column.label" :width="column.width":min-width="column.minWidth" :sortable="column.sortable || false" :align="column.align || 'left'":fixed="column.fixed" :show-overflow-tooltip="showTooltip"><template #default="{ row }"><span v-if="!column.slotName">{{row[column.prop] || row[column.prop] === 0? row[column.prop]: "--"}}</span><slot v-else :name="column.slotName" :data="row" /></template></el-table-column></template></el-table></div>
</template>
<script setup>
const props = defineProps({// 加载loading: { type: Boolean, default: false },// 是否带边框border: { type: Boolean, default: false },// 是否带斑马纹stripe: { type: Boolean, default: false },// 是否有序号index: { type: Boolean, default: true },// 表格高度 不传默认是计算后的高度height: { type: [Number, String], default: null },// 表格最大高度maxHeight: { type: Number, default: null },// 表格大小size: { type: String, default: "small" },// 唯一标识rowKey: { type: String, default: null },// 表数据dataSource: { type: Array, default: () => [] },// 是否多选selector: { type: Boolean, default: false },// 表头columns: { type: [String, Object, Array], required: true },// 是否展开isExpandAll: { type: Boolean, default: false },// 渲染嵌套数据的配置选项treeProps: {type: Object,default: () => { }},small: { type: Boolean, default: false },showTooltip: {type: Boolean,default: true}
})
const emit = defineEmits()
function sortChange({ column, prop, order }) {emit("sortChange", { column, prop, order });
}
function onSpanMethod({ rowIndex, columnIndex }) {let obj = { rowspan: 1, colspan: 1 };emit("onSpanMethod", { rowIndex, columnIndex }, val => {obj = val;});return obj;
}
function isShow(c) {return c.show === undefined ? true : c.show;
}
// 当前行变化
function currentRowChange(row) {if (row) emit("currentRowChange", row);
}// 多选
function selectionChange(values) {emit("selection-change", values);
}// 设置多选框(数据增加selectionIsSelect字段,判断当前是否可勾选)
function checkSelectTable(row) {return row.selectionIsSelect !== undefined ? row.selectionIsSelect : true;
}
// 点击某一行
function rowClick(row) {if (row) emit("row-click", row);
}
</script>

父使用

  <sne-table ref="sRef" :loading="loading" :selector="true" size="mini" row-key="id" height="calc( 100% - 140px )":data-source="noticeList" :columns="columns" @selection-change="handleSelectionChange"><template #noticeType="{data}"><dict-tag :options="sys_notice_type" :value="data.noticeType" /></template><template #status="{ data }"><dict-tag :options="sys_notice_status" :value="data.status" /></template><template #createTime="{ data }"><span>{{ parseTime(data.createTime, '{y}-{m}-{d}') }}</span></template><template #operate="{ data }"><el-button  link type="primary" :icon="EditPen" @click="handleUpdate(data)">修改</el-button><el-button link type="primary" icon="Delete" @click="handleDelete(data)" v-hasPermi="['system:notice:remove']">删除</el-button></template></sne-table>

elemeentuiPlus el-table封装   vue3

<template><div style="height: 100%;"><!-- element-loading-text="加载中" element-loading-spinner="el-icon-loading"element-loading-background="rgba(45,47,79, 0.8)"  --><el-table ref="sneTable"  :data="dataSource" :row-key="rowKey"v-loading="loading":default-expand-all="isExpandAll" :tree-props="treeProps" :border="border" :stripe="stripe" :height="height":max-height="maxHeight" size="default" @row-click="rowClick"@selection-change="selectionChange" @sort-change="sortChange"@current-change="currentRowChange" :span-method="onSpanMethod"style="width: 99%;font-size: 14px "><el-table-column v-if="selector" reserve-selection fixed="left" type="selection" header-align="center"align="center" width="50" :selectable="checkSelectTable" /><el-table-column v-if="index" align="center" fixed="left" type="index" label="序号" width="50"></el-table-column><template  v-for="(column, i) in columns"><el-table-column  v-if="isShow(column)" :prop="column.prop" :label="column.label" :width="column.width":min-width="column.minWidth" :sortable="column.sortable || false" :align="column.align || 'left'":fixed="column.fixed" :show-overflow-tooltip="showTooltip"><template #default="{ row }"><span v-if="!column.slotName">{{ row[column.prop] ||  row[column.prop] === 0? row[column.prop] :'' }}</span><slot :name="column.slotName" :data="row" /></template></el-table-column></template></el-table></div>
</template>
<script setup>
const props = defineProps({// 是否带边框border: { type: Boolean, default: false },// 是否带斑马纹stripe: { type: Boolean, default: false },// 是否有序号index: { type: Boolean, default: true },// 表格高度 不传默认是计算后的高度height: { type: [Number, String], default: null },// 表格最大高度maxHeight: { type: Number, default: null },// 表格大小size: { type: String, default: "large" },// 表数据dataSource: {type: Array,default: () => []},// 加载loading: {type: Boolean, default: false},// 表头columns: { type: [String, Object, Array], required: true },// 是否显示tooltipshowTooltip: {type: Boolean,default: true},// 是否多选selector: { type: Boolean, default: false },// 唯一标识rowKey: { type: String, default: null },// 是否展开isExpandAll: { type: Boolean, default: false },// 渲染嵌套数据的配置选项treeProps: { type: Object, default: () => { }},
})
const emit = defineEmits()function onSpanMethod({ rowIndex, columnIndex }) {// let obj = { rowspan: 1, colspan: 1 };// emit("onSpanMethod", { rowIndex, columnIndex }, val => {obj = val;});// return obj;
}
function isShow(c) {return c.show === undefined ? true : c.show;
}
// 当前行变化
function currentRowChange(row) {// if (row) emit("currentRowChange", row);
}
function sortChange({ column, prop, order }) {// emit("sortChange", { column, prop, order });
}
// 多选
function selectionChange(values) {emit("selection-change", values);
}// 设置多选框(数据增加selectionIsSelect字段,判断当前是否可勾选)
function checkSelectTable(row) {return row.selectionIsSelect !== undefined ? row.selectionIsSelect : true;
}
// // 点击某一行
function rowClick(row) {// if (row) emit("row-click", row);
}
</script>

相关文章:

elemeentui el-table封装

elemeentui el-table封装 <template><div style"height: 100%;"><el-table ref"sneTable" element-loading-text"加载中" element-loading-spinner"el-icon-loading"element-loading-background"rgba(45,47,79…...

openssl3.2 - 官方demo学习 - guide - quic-client-block.c

文章目录 openssl3.2 - 官方demo学习 - guide - quic-client-block.c概述笔记END openssl3.2 - 官方demo学习 - guide - quic-client-block.c 概述 在程序运行时, 要指定环境变量 SSL_CERT_FILErootcert.pem, 同时将rootcert.pem拷贝到工程目录下, 否则不好使 吐槽啊, 为啥不…...

滑动窗口经典入门题-——长度最小子数组

文章目录 算法原理题目解析暴力枚举法的代码优化第一步初始化第二步right右移第三步left右移 滑动窗口法的代码 算法原理 滑动窗口是一种在序列&#xff08;例如数组或链表&#xff09;上解决问题的算法模式。它通常用于解决子数组或子字符串的问题&#xff0c;其中滑动窗口表示…...

AcGeMatrix2d::alignCoordSys一种实现方式

问题描述 此处为了简化问题&#xff0c;在2维空间中处理&#xff0c;按以下方式调用&#xff0c;AcGeMatrix2d::alignCoordSys是如何求出一个矩阵的呢&#xff0c;这里提供一个实现思路&#xff08;但效率不保证好&#xff09; AcGeMatrix2d matTrans AcGeMatrix2d::alignCo…...

InternLM第5次课笔记

LMDeploy 大模型量化部署实践 1 大模型部署背景 2 LMDeploy简介 3 动手实践环节 https://github.com/InternLM/tutorial/blob/main/lmdeploy/lmdeploy.md 3...

2018年认证杯SPSSPRO杯数学建模D题(第一阶段)投篮的最佳出手点全过程文档及程序

2018年认证杯SPSSPRO杯数学建模 对于投篮最佳出手点的探究 D题 投篮的最佳出手点 原题再现&#xff1a; 影响投篮命中率的因素不仅仅有出手角度、球感、出手速度&#xff0c;还有出手点的选择。规范的投篮动作包含两膝微屈、重心落在两脚掌上、下肢蹬地发力、身体随之向前上…...

使用pdfbox 为 PDF 增加水印

使用pdfbox 为 PDF增加水印https://www.jylt.cc/#/detail?activityIndex2&idbd410851b0a72dad3105f9d50787f914 引入依赖 <dependency><groupId>org.apache.pdfbox</groupId><artifactId>pdfbox</artifactId><version>3.0.1</ve…...

6.【CPP】Date类的实现

Date.h #pragma once using namespace std; #include<iostream>class Date {friend ostream& operator<<(ostream& out, const Date& d);friend istream& operator>>(istream& in, Date& d); public://构造函数会被频繁调用,放在类…...

三角形任意一外角大于不相邻的任意一内角

一.代数证明 ∵ 对与△ A C B 中 ∠ c 外接三角形是 ∠ B C D ∵对与△ACB中∠c外接三角形是∠BCD ∵对与△ACB中∠c外接三角形是∠BCD ∴ ∠ B C D π − ∠ C ∴∠BCD\pi-∠C ∴∠BCDπ−∠C ∵ ∠ A ∠ B ∠ C π ∵∠A∠B∠C\pi ∵∠A∠B∠Cπ ∴ ∠ B C D ∠ A ∠…...

【Spring Boot 3】【Redis】集成Lettuce

【Spring Boot 3】【Redis】集成Lettuce 背景介绍开发环境开发步骤及源码工程目录结构总结背景 软件开发是一门实践性科学,对大多数人来说,学习一种新技术不是一开始就去深究其原理,而是先从做出一个可工作的DEMO入手。但在我个人学习和工作经历中,每次学习新技术总是要花…...

【SQL注入】SQLMAP v1.7.11.1 汉化版

下载链接 【SQL注入】SQLMAP v1.7.11.1 汉化版 简介 SQLMAP是一款开源的自动化SQL注入工具&#xff0c;用于扫描和利用Web应用程序中的SQL注入漏洞。它在安全测试领域被广泛应用&#xff0c;可用于检测和利用SQL注入漏洞&#xff0c;以验证应用程序的安全性。 SQL注入是一种…...

时序预测 | MATLAB实现GRNN广义回归神经网络时间序列未来多步预测(程序含详细预测步骤)

时序预测 | MATLAB实现GRNN广义回归神经网络时间序列未来多步预测(程序含详细预测步骤) 目录 时序预测 | MATLAB实现GRNN广义回归神经网络时间序列未来多步预测(程序含详细预测步骤)预测效果基本介绍程序设计参考资料预测效果 基本介绍 MATLAB实现GRNN广义回归神经网络时间序列…...

长期戴耳机的危害有哪些?戴哪种耳机不伤耳朵听力?

长期佩戴耳机可能会出现听力下降、耳道感染等危害。 听力下降&#xff1a;长时间戴耳机可能会导致耳道内的声音过大&#xff0c;容易对耳膜造成一定的刺激&#xff0c;容易出现听力下降的情况。 耳道感染&#xff1a;长时间戴耳机&#xff0c;耳道长期处于封闭潮湿的情况下&a…...

C++中的预处理

一.预定义符号 1.__FILE__进行编译的源文件 2.__LINE__文件当前的行号 3.__DATE__文件被编译的日期 4.__TIME文件被编译的时间 5.__STDC__如果编译器遵循ANSIC,其值为1,否则未定义 二.#define 基本语法:#define 名字 内容 eg.define M 1 经#define定义的常量时不经过…...

flink 最后一个窗口一直没有新数据,窗口不关闭问题

flink 最后一个窗口一直没有新数据&#xff0c;窗口不关闭问题 自定义实现 WatermarkStrategy接口 自定义实现 WatermarkStrategy接口 窗口类型&#xff1a;滚动窗口 代码&#xff1a; public static class WatermarkDemoFunction implements WatermarkStrategy<JSONObject…...

mybatis----小细节

1、起别名 在MyBatis中&#xff0c;<typeAliases>元素用于定义类型别名&#xff0c;它可以将Java类名映射为一个更简短的别名&#xff0c;这样在映射文件中可以直接使用别名而不需要完整的类名。 下面是一个示例&#xff1a; 在mybatis核心配置文件中配置typeAliases标…...

解密Oracle数据库引擎:揭开数据存储的神秘面纱

目录 1、介绍Oracle数据库引擎 1.1 什么是Oracle数据库引擎 1.2 Oracle数据库引擎的作用和功能 1.3 Oracle数据库引擎的历史和发展 2、Oracle数据库引擎的体系结构 2.1 Oracle数据库实例的组成部分 2.2 Oracle数据库引擎的层次结构 2.3 Oracle数据库引擎的关键组件 3、…...

「HDLBits题解」Karnaugh Map to Circuit

本专栏的目的是分享可以通过HDLBits仿真的Verilog代码 以提供参考 各位可同时参考我的代码和官方题解代码 或许会有所收益 相关资料&#xff1a;卡诺图化简法-CSDN博客 题目链接&#xff1a;Kmap1 - HDLBits module top_module(input a,input b,input c,output out );assig…...

由于找不到d3dcompiler_43.dll缺失,无法打开软件的解决方法分享

d3dcompiler43.dll是什么文件&#xff1f;为什么会出现丢失的情况&#xff1f;又该如何解决呢&#xff1f;本文将详细介绍d3dcompiler43.dll的作用和影响&#xff0c;并提供6个有效的解决方法。 一、d3dcompiler43.dll是什么文件&#xff1f; d3dcompiler43.dll是DirectX SDK…...

现阶段Python和Java哪个更吃香?

现阶段Python和Java哪个更吃香&#xff1f; 在开始前我有一些资料&#xff0c;是我根据网友给的问题精心整理了一份「Java的资料从专业入门到高级教程」&#xff0c; 点个关注在评论区回复“888”之后私信回复“888”&#xff0c;全部无偿共享给大家&#xff01;&#xff01;&…...

Cesium1.95中高性能加载1500个点

一、基本方式&#xff1a; 图标使用.png比.svg性能要好 <template><div id"cesiumContainer"></div><div class"toolbar"><button id"resetButton">重新生成点</button><span id"countDisplay&qu…...

Cilium动手实验室: 精通之旅---20.Isovalent Enterprise for Cilium: Zero Trust Visibility

Cilium动手实验室: 精通之旅---20.Isovalent Enterprise for Cilium: Zero Trust Visibility 1. 实验室环境1.1 实验室环境1.2 小测试 2. The Endor System2.1 部署应用2.2 检查现有策略 3. Cilium 策略实体3.1 创建 allow-all 网络策略3.2 在 Hubble CLI 中验证网络策略源3.3 …...

多模态大语言模型arxiv论文略读(108)

CROME: Cross-Modal Adapters for Efficient Multimodal LLM ➡️ 论文标题&#xff1a;CROME: Cross-Modal Adapters for Efficient Multimodal LLM ➡️ 论文作者&#xff1a;Sayna Ebrahimi, Sercan O. Arik, Tejas Nama, Tomas Pfister ➡️ 研究机构: Google Cloud AI Re…...

基于PHP的连锁酒店管理系统

有需要请加文章底部Q哦 可远程调试 基于PHP的连锁酒店管理系统 一 介绍 连锁酒店管理系统基于原生PHP开发&#xff0c;数据库mysql&#xff0c;前端bootstrap。系统角色分为用户和管理员。 技术栈 phpmysqlbootstrapphpstudyvscode 二 功能 用户 1 注册/登录/注销 2 个人中…...

探索Selenium:自动化测试的神奇钥匙

目录 一、Selenium 是什么1.1 定义与概念1.2 发展历程1.3 功能概述 二、Selenium 工作原理剖析2.1 架构组成2.2 工作流程2.3 通信机制 三、Selenium 的优势3.1 跨浏览器与平台支持3.2 丰富的语言支持3.3 强大的社区支持 四、Selenium 的应用场景4.1 Web 应用自动化测试4.2 数据…...

Vue 模板语句的数据来源

&#x1f9e9; Vue 模板语句的数据来源&#xff1a;全方位解析 Vue 模板&#xff08;<template> 部分&#xff09;中的表达式、指令绑定&#xff08;如 v-bind, v-on&#xff09;和插值&#xff08;{{ }}&#xff09;都在一个特定的作用域内求值。这个作用域由当前 组件…...

WEB3全栈开发——面试专业技能点P7前端与链上集成

一、Next.js技术栈 ✅ 概念介绍 Next.js 是一个基于 React 的 服务端渲染&#xff08;SSR&#xff09;与静态网站生成&#xff08;SSG&#xff09; 框架&#xff0c;由 Vercel 开发。它简化了构建生产级 React 应用的过程&#xff0c;并内置了很多特性&#xff1a; ✅ 文件系…...

leetcode73-矩阵置零

leetcode 73 思路 记录 0 元素的位置&#xff1a;遍历整个矩阵&#xff0c;找出所有值为 0 的元素&#xff0c;并将它们的坐标记录在数组zeroPosition中置零操作&#xff1a;遍历记录的所有 0 元素位置&#xff0c;将每个位置对应的行和列的所有元素置为 0 具体步骤 初始化…...

DAY 45 超大力王爱学Python

来自超大力王的友情提示&#xff1a;在用tensordoard的时候一定一定要用绝对位置&#xff0c;例如&#xff1a;tensorboard --logdir"D:\代码\archive (1)\runs\cifar10_mlp_experiment_2" 不然读取不了数据 知识点回顾&#xff1a; tensorboard的发展历史和原理tens…...

Ray框架:分布式AI训练与调参实践

Ray框架&#xff1a;分布式AI训练与调参实践 系统化学习人工智能网站&#xff08;收藏&#xff09;&#xff1a;https://www.captainbed.cn/flu 文章目录 Ray框架&#xff1a;分布式AI训练与调参实践摘要引言框架架构解析1. 核心组件设计2. 关键技术实现2.1 动态资源调度2.2 …...