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

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>

相关文章:

  • 敏捷开发笔记(第7章节)--什么是敏捷设计
  • 八爪鱼现金流-027,以后别再做软件开发了,累了,要有自己的作品
  • deepin 加入甲辰计划,共建 RISC-V 繁荣生态
  • vscode+picgo+gitee实现Markdown图床
  • 摄像头画面显示于unity场景
  • 项目五 OpenStack镜像管理与制作
  • 钓鱼网站开发原理(社会工程学)
  • KEIL5软件仿真观察PIN脚电平(软件仿真逻辑分析仪的使用)
  • centos查找文件 及 操作写入的进程
  • 概率论与数理统计(期末自用总结版)
  • 力扣-2663
  • 快速生成基于vue-element的后台管理框架,实现短时间二次开发
  • 关于飞浆文字识别技术的运用
  • [手机Linux PostmarketOS]一,1加6T真正的手机Linux系统
  • MacOS安装redis
  • ----------
  • 自己简单写的 事件订阅机制
  • 「面试题」如何实现一个圣杯布局?
  • 【Linux系统编程】快速查找errno错误码信息
  • Android组件 - 收藏集 - 掘金
  • Java方法详解
  • js中forEach回调同异步问题
  • laravel with 查询列表限制条数
  • Linux CTF 逆向入门
  • MySQL用户中的%到底包不包括localhost?
  • passportjs 源码分析
  • Phpstorm怎样批量删除空行?
  • Redis的resp协议
  • Synchronized 关键字使用、底层原理、JDK1.6 之后的底层优化以及 和ReenTrantLock 的对比...
  • tensorflow学习笔记3——MNIST应用篇
  • vue-router 实现分析
  • zookeeper系列(七)实战分布式命名服务
  • 测试如何在敏捷团队中工作?
  • 关于使用markdown的方法(引自CSDN教程)
  • 基于Volley网络库实现加载多种网络图片(包括GIF动态图片、圆形图片、普通图片)...
  • 前端每日实战:70# 视频演示如何用纯 CSS 创作一只徘徊的果冻怪兽
  • 数据库写操作弃用“SELECT ... FOR UPDATE”解决方案
  • ionic入门之数据绑定显示-1
  • 东超科技获得千万级Pre-A轮融资,投资方为中科创星 ...
  • # 透过事物看本质的能力怎么培养?
  • #NOIP 2014# day.1 生活大爆炸版 石头剪刀布
  • #考研#计算机文化知识1(局域网及网络互联)
  • (2022版)一套教程搞定k8s安装到实战 | RBAC
  • (4) openssl rsa/pkey(查看私钥、从私钥中提取公钥、查看公钥)
  • (MATLAB)第五章-矩阵运算
  • (vue)el-checkbox 实现展示区分 label 和 value(展示值与选中获取值需不同)
  • (第61天)多租户架构(CDB/PDB)
  • (附源码)ssm高校运动会管理系统 毕业设计 020419
  • (强烈推荐)移动端音视频从零到上手(下)
  • (数据结构)顺序表的定义
  • (转)linux 命令大全
  • (转)Mysql的优化设置
  • (转)创业的注意事项
  • **登录+JWT+异常处理+拦截器+ThreadLocal-开发思想与代码实现**
  • .bat批处理(三):变量声明、设置、拼接、截取