#子传父父传子props和emits #封装的table #vue3
#子传父&父传子props和emits #封装的table #vue3
父组件:emits defineEmits props
子组件:
子组件
<template><el-table v-bind="$attrs" ref="innerTableRef" v-loading="loading" border :data="tableData"@sort-change="handleSortChange">
<el-table-column v-for="{label,prop,type,align,width,tooltip,meta,fixed,reserveSelection,sortable,} in visibleColumns" :key="prop" :align="align ?? 'center'" :width="width" :label="label" :prop="prop":show-overflow-tooltip="tooltip ?? true" :type="type" :fixed="fixed" :reserve-selection="reserveSelection":sortable="sortable"><template #default="{ row, column: { rawColumnKey } }"><template v-if="type === 'operate'"><div class="flex justify-evenly"><slot :row="row" name="operate" /></div></template><template v-else-if="prop"><template v-if="type === 'radio'"><el-radio v-model="radioVal" class="none-label" :label="row[prop]" @input="onRadioInput(row)" /></template><template v-else-if="type === 'link'"><template v-if="!meta"><el-link class="cell-link" type="primary"@click="$emit(`click${getFirstCharUpperCaseProperty(rawColumnKey)}`, row)">{{ row[prop] }}</el-link></template></template><template v-else-if="type === 'tag' && meta"><el-tag v-if="row[prop] != null" effect="dark" :type="getMetaType(row[prop], meta, 'tag')">{{ getMetaLabel(row[prop], meta, 'tag') }}</el-tag></template><template v-else-if="type === 'custom'"><slot :name="rawColumnKey" :row="row" /></template><span v-else>{{ row[prop] }}</span></template></template></el-table-column></el-table>
</template><script setup lang="ts">const emits = defineEmits<{sortChange: [data: { column: any, prop: string, order: any }]
}>()
// 表格排序改变事件
function handleSortChange(data: { column: any, prop: string, order: any }) {emits('sortChange', data)
}
父组件
<template>
<div class="bg-white rounded-md p-2.5 shadow"><table-component v-model:page-index="queryParams.pageIndex" v-model:page-size="queryParams.pageSize":table-config="tableData.tableConfig" :table-data="tableData.data" :loading="tableData.loading":total="tableData.totalRows" @fetch="fetchData" @click-sys-uni-code="onClickCode" @sortChange="handleSortChange"><template #btn><el-button v-permission="['production_processing:add']" :icon="Plus" type="primary" @click="onHeadEvent('add')">添加</el-button></template><template #operate="{ row }"><el-link v-permission="['production_processing:input']" :icon="View" type="primary"@click="onRow('input', row)">{{ row.set == true ? '编辑' : '录入' }}</el-link><el-link v-permission="['production_processing:delete']" :icon="Delete" type="danger"@click="onRow('delete', row)">删除</el-link></template><template #status="{ row }"><template v-if="row.status == ASSEMBLY_ATATUS.PROGRRESS"><el-progress :text-inside="true" :stroke-width="15" :percentage="row.progressNumber" /></template><template v-if="row.status == ASSEMBLY_ATATUS.NO"><el-tag effect="dark" type="danger">未开始</el-tag></template><template v-if="row.status == ASSEMBLY_ATATUS.COMPLETED"><el-tag effect="dark" type="success">已完成</el-tag></template><template v-if="row.status == ASSEMBLY_ATATUS.CLOSED"><el-tag effect="dark" type="info">已关闭</el-tag></template></template><template #doneTimePreset="{ row }">{{ row.doneTimePreset }}<triangle border-color="red" title="超"v-if="dateVal(nowDate) <= dateVal(row.doneTimePreset) || dateVal(row.doneTimePreset) <= dateVal(row.doneTimeFact)" /></template><template #doneTimeFact="{ row }">{{ row.doneTimeFact == '' ? '' : row.doneTimeFact.substring(0, 10) }}<triangle border-color="red" title="超" v-if="dateVal(nowDate) <= dateVal(row.doneTimeFact)" /></template></table-component></div>
<script setup lang="ts">
const queryParams = ref({fBillNo: '', //订单编号sysUniCode: '', //系统序列码fMaterialNumber: '', //物料编号fMaterialName: '', //物料名称fMaterialSpecification: '', //规格型号status: [] as number[], //状态 0未开始 1进行中 2已完成srcProjectType: null, //源项目类型 1合同 2研发 3维修srcSysUniCode: '', //源项目系统序列码pageIndex: 1,pageSize: 10,outsource: false, //是否筛选加工外协OrderBy: null,Desc: true
})
const tableData = ref({tableConfig: [{label: '序号',type: 'index',width: 60},{label: '系统序列号',prop: 'sysUniCode',type: 'link'},{label: '订单编号',prop: 'fBillNo'},{label: '物料编码',prop: 'fMaterialNumber'},{label: '物料名称',prop: 'fMaterialName'},{label: '规格型号',prop: 'fMaterialSpecification'},{label: '单位',prop: 'fUnit',width: '90'},{label: '数量',prop: 'fAmount',width: '90'},{label: '合格品入库数量',prop: 'okInStock',width: '130'},{label: '进度',prop: 'status',type: 'custom',width: '200'},{label: '当前工序',prop: 'currProcedure'},{label: '预计完成时间',prop: 'doneTimePreset',type: 'custom',sortable: 'custom',},{label: '实际完成时间',prop: 'doneTimeFact',type: 'custom',sortable: 'custom',},{label: '来源项目',prop: 'srcProjectType',type: 'tag',meta: {tagConfig: [{label: '合同项目',value: SOURCE_PROJECT.CONTRACT,type: 'primary'},{label: '研发项目',value: SOURCE_PROJECT.RESEARCH,type: 'warning'},{label: '维修项目',value: SOURCE_PROJECT.SERVICE,type: 'danger'}]}},{label: '来源序列号',prop: 'srcSysUniCode'},{label: '操作',type: 'operate',width: 150}],data: [],loading: false,totalRows: 0
})
// 排序
function handleSortChange(data: { prop: string, order: string }) {console.log(data, 222)// 有排序if (data.order) {console.log(data.prop, (data.prop === 'doneTimePreset' ? 1 : 2));queryParams.value.OrderBy = (data.prop === 'doneTimePreset' ? 1 : 2)queryParams.value.Desc = (data.order === 'descending')} else {// 没排序-使用默认排序queryParams.value.OrderBy = null}// 还原成第一页并重新发起请求queryParams.value.pageIndex = 1fetchData()
}
怎么说呢还是得多看多写
相关文章:

#子传父父传子props和emits #封装的table #vue3
#子传父&父传子props和emits #封装的table #vue3 父组件:emits defineEmits props 子组件: 子组件 <template><el-table v-bind"$attrs" ref"innerTableRef" v-loading"loading" border :data"tabl…...

尚硅谷谷粒商城项目笔记——四、使用docker安装redis【电脑CPU:AMD】
四、使用docker安装redis 注意: 因为电脑是AMD芯片,自己知识储备不够,无法保证和课程中用到的环境一样,所以环境都是自己根据适应硬件软件环境重新配置的,这里的虚拟机使用的是VMware。 在解决了 Docker 安装的问题之…...
Java在无人驾驶方向的就业方向
在无人驾驶领域,Java作为一种主流编程语言,尽管不是最常见的选择(例如,C和Python通常更受欢迎),但它仍然有很多应用场景和就业机会。以下是一些Java在无人驾驶方向的就业方向: 1. 后台服务开发 …...

机器学习中的关键距离度量及其应用
引言 在当今的数据驱动世界中,机器学习算法扮演着至关重要的角色,它们在图像分类、面部识别、在线内容审核、零售目录优化和推荐系统等多个领域发挥着重要作用。这些算法的核心在于它们能够识别和利用数据之间的相似性。而实现这一点的关键,…...
Redis中缓存雪崩、缓存穿透、缓存预热、缓存更新、缓存降级等问题
目录 1.什么是缓存雪崩1.1 导致雪崩的原因1.2 如何解决 2.什么是缓存穿透2.1 导致穿透的原因2.2 如何解决 3.什么是缓存预热3.1 如何解决 4.什么是缓存降级4.1 缓存降级的目的4.2 解决方案4.3 服务降级的目的 5.缓存更新 1.什么是缓存雪崩 就是存储在缓存里面的大量数据&#…...

【C++】vector 的模拟实现
📢博客主页:https://blog.csdn.net/2301_779549673 📢欢迎点赞 👍 收藏 ⭐留言 📝 如有错误敬请指正! 📢本文由 JohnKi 原创,首发于 CSDN🙉 📢未来很长&#…...

【C++】模版详解
1、概念 C模版分两类:函数模版和类模版 1)函数模板的格式 template <class 形参名,class 形参名,......> 返回类型 函数名(参数列表) {函数体 }例如: template <class T> void swap(T& a, T& b…...

应用商店故障(UOS系统)
应用商店故障(UOS系统) 1. 安装应用商店内的应用无法下载,更新系统时提示依赖关系被破坏,怎么办? 问题描述 安装应用商店内的应用无法下载,更新系统时均提示依赖关系被破坏 解决方案 1、可先建议用户尝试修…...
8月8号前端日报:web在线进行eps32固件升级
最近几天在开发固件更新的功能,学习了不少相关的知识。 在arduino中对esp32进行固件更新,本质是使用esp官方的esptool,使用一个python exe程序,执行一段脚本,该脚本会将固件文件按照对应的位置来写入到esp芯片中。一共…...
win7安装python3.10
到这下载 PythonWin7/3.10.1 at master adang1345/PythonWin7 GitHub...

【Liunx】线程与进程的经典面试题总结
在这个浮躁的时代 只有自律的人才能脱颖而出 -- 《觉醒年代》 线程与进程的面试题总结 1 简述什么是LWP2 简述LWP与pthread_create创建的线程之间的关系3 简述轻量级进程ID与进程ID之间的区别4 请简述什么是线程互斥,为什么需要互斥5 简述你了解的进程间通信方式…...

Python中的 `break` 语句:掌握循环控制的艺术
Python中的 break 语句:掌握循环控制的艺术 下滑即可查看博客内容 🌈 欢迎莅临我的个人主页 👈这里是我静心耕耘深度学习领域、真诚分享知识与智慧的小天地!🎇 🎓 博主简介:985高校的普通本硕…...
ES2023(ES14)新特性有什么?
1. Array.prototype.with with 方法返回一个新数组,替换指定索引处的元素 const arr [a, b, c, d]; const res arr.with(2, f); console.log(res);//[a, b, f, d] console.log(arr);//[a, b, c, d] Array.prototype.toSorted 2. Array.prototype.toSorted toS…...

Linux 中的特殊文件权限:SUID、GUID 和 Sticky
注: 机翻,未校。 Special File Permissions in Linux: SUID, GUID and Sticky Bit You see an s instead of x in the file permissions? Linux has some special file permissions called SUID, GUID and Sticky Bit. Know more about them. 在文件权…...
2024 某公司python 面试真题
Q: Can the type of options or labels of switch-case be floating? 在C语言中,switch-case语句的标签必须是整数类型,不能是浮点型。而在Python中,没有switch-case语句,但是可以使用字典来实现类似的功能,而字典的键…...

jwt伪造身份组组组合拳艰难通关
前言 现在的攻防演练不再像以往那样一个漏洞直捣黄龙,而是需要各种组合拳才能信手沾来,但是有时候使尽浑身解数也不能诚心如意。 前期信息收集 首先是拿到靶标的清单 访问系统的界面,没有什么能利用的功能点 首先进行目录扫描,…...

leetcode日记(64)最小覆盖子串
很复杂的题目,无论是思路还是实践都很难… 思路还是看了答案(?)设定两个指针“框”出一串字符串,初始两个指针都指在s的零位,先移动下指针,直到使框出的字符串中包含t中所有字符串,…...

C语言——编译与链接
目录 引言 翻译环境与运行环境 翻译环境 1.翻译环境的简述 2.编译过程 2.1 预处理(预编译) 2.2 编译 2.2.1 词法分析 2.2.2 语法分析 2.2.3 语义分析 2.3 汇编 3.链接 运行环境 结束语 引言 C语言编译与链接过程是理解程序如何从代码转化…...

你一定想看的LVS详细介绍及常见模式(NAT,DR,防火墙标记)实验详解
目录 一、什么是LVS 二、LVS的核心思想 三、 LVS的优势 四、LVS的调度算法 4.1. LVS的调度算法类型 4.2. LVS静态调度算法 4.3. LVS动态调度算法 4.4.在4.15版本内核以后新增调度算法 五、LVS软件相关信息 六、ipvsadm命令 七、 LVS的NAT模式实验详解 7.1实验环境 7.…...

嵌入式初学-C语言-十七
#接嵌入式初学-C语言-十六# 函数的递归调用 含义: 在一个函数中直接或者间接调用了函数本身,称之为函数的递归调用 // 直接调用a()->a(); // 间接调用a()->b()->a();a()->b()->..->a();递归调用的本质: 本是是一种循环…...

云启出海,智联未来|阿里云网络「企业出海」系列客户沙龙上海站圆满落地
借阿里云中企出海大会的东风,以**「云启出海,智联未来|打造安全可靠的出海云网络引擎」为主题的阿里云企业出海客户沙龙云网络&安全专场于5.28日下午在上海顺利举办,现场吸引了来自携程、小红书、米哈游、哔哩哔哩、波克城市、…...
pam_env.so模块配置解析
在PAM(Pluggable Authentication Modules)配置中, /etc/pam.d/su 文件相关配置含义如下: 配置解析 auth required pam_env.so1. 字段分解 字段值说明模块类型auth认证类模块,负责验证用户身份&am…...
【解密LSTM、GRU如何解决传统RNN梯度消失问题】
解密LSTM与GRU:如何让RNN变得更聪明? 在深度学习的世界里,循环神经网络(RNN)以其卓越的序列数据处理能力广泛应用于自然语言处理、时间序列预测等领域。然而,传统RNN存在的一个严重问题——梯度消失&#…...
数据链路层的主要功能是什么
数据链路层(OSI模型第2层)的核心功能是在相邻网络节点(如交换机、主机)间提供可靠的数据帧传输服务,主要职责包括: 🔑 核心功能详解: 帧封装与解封装 封装: 将网络层下发…...

ServerTrust 并非唯一
NSURLAuthenticationMethodServerTrust 只是 authenticationMethod 的冰山一角 要理解 NSURLAuthenticationMethodServerTrust, 首先要明白它只是 authenticationMethod 的选项之一, 并非唯一 1 先厘清概念 点说明authenticationMethodURLAuthenticationChallenge.protectionS…...
LLM基础1_语言模型如何处理文本
基于GitHub项目:https://github.com/datawhalechina/llms-from-scratch-cn 工具介绍 tiktoken:OpenAI开发的专业"分词器" torch:Facebook开发的强力计算引擎,相当于超级计算器 理解词嵌入:给词语画"…...
uniapp中使用aixos 报错
问题: 在uniapp中使用aixos,运行后报如下错误: AxiosError: There is no suitable adapter to dispatch the request since : - adapter xhr is not supported by the environment - adapter http is not available in the build 解决方案&…...

Redis数据倾斜问题解决
Redis 数据倾斜问题解析与解决方案 什么是 Redis 数据倾斜 Redis 数据倾斜指的是在 Redis 集群中,部分节点存储的数据量或访问量远高于其他节点,导致这些节点负载过高,影响整体性能。 数据倾斜的主要表现 部分节点内存使用率远高于其他节…...

html css js网页制作成品——HTML+CSS榴莲商城网页设计(4页)附源码
目录 一、👨🎓网站题目 二、✍️网站描述 三、📚网站介绍 四、🌐网站效果 五、🪓 代码实现 🧱HTML 六、🥇 如何让学习不再盲目 七、🎁更多干货 一、👨…...

Netty从入门到进阶(二)
二、Netty入门 1. 概述 1.1 Netty是什么 Netty is an asynchronous event-driven network application framework for rapid development of maintainable high performance protocol servers & clients. Netty是一个异步的、基于事件驱动的网络应用框架,用于…...