elementUI的table使用展开功能( type=“expand“ ),展开时合起上一次展开的内容,始终保持展开内容为一个,并且再次点击合起自身

本文主要是介绍elementUI的table使用展开功能( type=“expand“ ),展开时合起上一次展开的内容,始终保持展开内容为一个,并且再次点击合起自身,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

直接上代码了没什么可讲的,主要是用到

row-key="id"

:expand-row-keys="expands

@row-click="handleRowClick"

<template><div class="ele-body"><el-card shadow="never"><!-- 数据表格 --><ele-pro-tableref="table":columns="columns":datasource="datasource"height="calc(100vh - 266px)"tool-class="ele-toolbar-form":toolkit="[]"cache-key="recordTable"row-key="id":expand-row-keys="expands"@row-click="handleRowClick"highlight-current-row@current-change="handleCurrentChange"><template v-slot:toolbar><!-- 搜索表单 --><rectify-search @search="reload"> </rectify-search></template><!-- 展开内容 --><template v-slot:expand="{ row }"><el-table :data="row.riskList" :show-header="true"><el-table-column label="序号" type="index" width="50"></el-table-column><el-table-column label="不符合项描述" show-overflow-tooltip><template v-slot="{ row }"><span>{{ row.problemDescription }}</span></template></el-table-column><el-table-column label="整改截止日期" width="130"><template v-slot="{ row }"><div>{{ $util.toDateString(row.endDate, 'yyyy-MM-dd') }}</div></template></el-table-column><el-table-column label="不符合项" show-overflow-tooltip><template v-slot="{ row }"><span>{{'【' +row.checkMasterName +'】' +row.checkItemCode +' ' +row.checkItemName}}</span></template></el-table-column><el-table-column label="整改状态" width="110" show-overflow-tooltip><template v-slot="{ row }"><el-tag size="small" type="primary" :disable-transitions="true">{{ getDictName('rectify_status', row.rectifyStatus) }}</el-tag></template></el-table-column><el-table-column label="回执内容" width="230"><template v-slot="{ row }"><span>{{ row.receiptDescription }}</span></template></el-table-column><el-table-column label="操作" width="240" align="center"><template v-slot="{ row }"><el-linktype="primary":underline="false"icon="el-icon-search"@click="openEdit(row)">查看</el-link><el-linkv-if="row.rectifyStatus < 1"type="primary":underline="false"icon="el-icon-_retrieve"@click="toCorrect(row)">纠正回执</el-link><!-- <el-linkv-if="row.rectifyStatus != 0"type="primary":underline="false"icon="el-icon-_retrieve">已回执</el-link> --></template></el-table-column></el-table></template><template v-slot:superviseType="{ row }">{{ getDictName('supervise_type', row.superviseType) }}</template><!-- 操作列 --><template v-slot:action="{ row }"><el-linktype="primary":underline="false"icon="el-icon-search"@click="openSheetAll(row)">查看</el-link></template></ele-pro-table></el-card><rectify-edit :visible.sync="showEdit" :data="current"></rectify-edit><rectify-correct-edit:visible.sync="showCorrectEdit":data="currentCorrect"@done="reload"></rectify-correct-edit></div>
</template><script>import rectifyEdit from './components/rectify-edit.vue';import rectifyCorrectEdit from './components/rectify-correct-edit.vue';import rectifySearch from './components/rectify-search.vue';import { pageDisposalOrders } from '@/api/disposal/disposal-order';export default {name: 'rectify',components: {rectifySearch,rectifyCorrectEdit,rectifyEdit},data() {return {showEdit: false,showCorrectEdit: false,columns: [{width: 45,type: 'expand',columnKey: 'expand',align: 'center',slot: 'expand'},{prop: 'code',label: '处置单编号',sortable: 'custom',showOverflowTooltip: true,width: 220},{prop: 'orderType',label: '任务类型',showOverflowTooltip: true,minWidth: 110,slot: 'orderType',formatter: (_row, _column, cellValue) => {return this.$globalDictName('order_type', cellValue);}},{prop: 'superviseType',label: '监督方式',sortable: 'custom',slot: 'superviseType',minWidth: 140},{prop: 'orgName',label: '监督站',sortable: 'custom',showOverflowTooltip: true,minWidth: 140},{prop: 'unitCode',label: '生产单位',sortable: 'custom',showOverflowTooltip: true,width: 180,formatter: (_row, _column, cellValue) => {return this.$globalOrgName(cellValue);}},{prop: 'description',label: '任务描述',sortable: 'custom',showOverflowTooltip: true,minWidth: 140},{prop: 'findDate',label: '监督日期',sortable: 'custom',showOverflowTooltip: true,width: 180,formatter: (_row, _column, cellValue) => {return this.$util.toDateString(cellValue, 'yyyy-MM-dd');}}],current: {},currentCorrect: {},expands: [],currentRow: null};},created() {},methods: {handleRowClick(row) {if (this.expands.includes(row.id)) {this.expands = this.expands.filter((val) => val !== row.id);} else {this.expands = [];this.expands.push(row.id);}},handleCurrentChange(val) {this.currentRow = val;},/* 表格数据源 */datasource({ page, limit, where, order }) {let statusList = null; //'(0,-1,-2)';return pageDisposalOrders({...where,...order,page,limit,auditStatus: 0,rectifyStatus: 0,statusIds: statusList});// return data;},getDictName(type, code) {return this.$globalDictName(type, code);},/* 刷新表格 */reload(where) {this.$refs.table.reload({ where: where });},/* 打开所有记录 */openEdit(row) {this.current = row;this.showEdit = true;},toCorrect(row) {this.currentCorrect = row;this.showCorrectEdit = true;}}};
</script>

这篇关于elementUI的table使用展开功能( type=“expand“ ),展开时合起上一次展开的内容,始终保持展开内容为一个,并且再次点击合起自身的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1078339

相关文章

苹果macOS 26 Tahoe主题功能大升级:可定制图标/高亮文本/文件夹颜色

《苹果macOS26Tahoe主题功能大升级:可定制图标/高亮文本/文件夹颜色》在整体系统设计方面,macOS26采用了全新的玻璃质感视觉风格,应用于Dock栏、应用图标以及桌面小部件等多个界面... 科技媒体 MACRumors 昨日(6 月 13 日)发布博文,报道称在 macOS 26 Tahoe 中

Python并行处理实战之如何使用ProcessPoolExecutor加速计算

《Python并行处理实战之如何使用ProcessPoolExecutor加速计算》Python提供了多种并行处理的方式,其中concurrent.futures模块的ProcessPoolExecu... 目录简介完整代码示例代码解释1. 导入必要的模块2. 定义处理函数3. 主函数4. 生成数字列表5.

Python中help()和dir()函数的使用

《Python中help()和dir()函数的使用》我们经常需要查看某个对象(如模块、类、函数等)的属性和方法,Python提供了两个内置函数help()和dir(),它们可以帮助我们快速了解代... 目录1. 引言2. help() 函数2.1 作用2.2 使用方法2.3 示例(1) 查看内置函数的帮助(

Linux脚本(shell)的使用方式

《Linux脚本(shell)的使用方式》:本文主要介绍Linux脚本(shell)的使用方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录概述语法详解数学运算表达式Shell变量变量分类环境变量Shell内部变量自定义变量:定义、赋值自定义变量:引用、修改、删

Java使用HttpClient实现图片下载与本地保存功能

《Java使用HttpClient实现图片下载与本地保存功能》在当今数字化时代,网络资源的获取与处理已成为软件开发中的常见需求,其中,图片作为网络上最常见的资源之一,其下载与保存功能在许多应用场景中都... 目录引言一、Apache HttpClient简介二、技术栈与环境准备三、实现图片下载与保存功能1.

Python中使用uv创建环境及原理举例详解

《Python中使用uv创建环境及原理举例详解》uv是Astral团队开发的高性能Python工具,整合包管理、虚拟环境、Python版本控制等功能,:本文主要介绍Python中使用uv创建环境及... 目录一、uv工具简介核心特点:二、安装uv1. 通过pip安装2. 通过脚本安装验证安装:配置镜像源(可

LiteFlow轻量级工作流引擎使用示例详解

《LiteFlow轻量级工作流引擎使用示例详解》:本文主要介绍LiteFlow是一个灵活、简洁且轻量的工作流引擎,适合用于中小型项目和微服务架构中的流程编排,本文给大家介绍LiteFlow轻量级工... 目录1. LiteFlow 主要特点2. 工作流定义方式3. LiteFlow 流程示例4. LiteF

使用Python开发一个现代化屏幕取色器

《使用Python开发一个现代化屏幕取色器》在UI设计、网页开发等场景中,颜色拾取是高频需求,:本文主要介绍如何使用Python开发一个现代化屏幕取色器,有需要的小伙伴可以参考一下... 目录一、项目概述二、核心功能解析2.1 实时颜色追踪2.2 智能颜色显示三、效果展示四、实现步骤详解4.1 环境配置4.

使用jenv工具管理多个JDK版本的方法步骤

《使用jenv工具管理多个JDK版本的方法步骤》jenv是一个开源的Java环境管理工具,旨在帮助开发者在同一台机器上轻松管理和切换多个Java版本,:本文主要介绍使用jenv工具管理多个JD... 目录一、jenv到底是干啥的?二、jenv的核心功能(一)管理多个Java版本(二)支持插件扩展(三)环境隔

SQL中JOIN操作的条件使用总结与实践

《SQL中JOIN操作的条件使用总结与实践》在SQL查询中,JOIN操作是多表关联的核心工具,本文将从原理,场景和最佳实践三个方面总结JOIN条件的使用规则,希望可以帮助开发者精准控制查询逻辑... 目录一、ON与WHERE的本质区别二、场景化条件使用规则三、最佳实践建议1.优先使用ON条件2.WHERE用