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

buildadmin 自定义单元格渲染

场景一:数据单列集中展示

例如,收购人信息有很多列,容易导致横向很长,所以需要到单列集中展示。

官方推荐使用slot渲染

在这里插入图片描述
代码示例:

// template中编写需要展示的插槽内容HTML
<template><Table ref="tableRef"><template #acquirerInfo><el-table-column label="收购人信息" :width="300"><template #default="scope"><div class="data-info"><p class="data-item">收购点:{{ scope.row['acquirer']['acquisition_name'] }}</p><p class="data-item">持卡人:{{ scope.row['acquirer']['username'] }}</p><p class="data-item">手机号:{{ scope.row['acquirer']['mobile'] }}</p><p class="data-item">身份证:{{ maskNumber(scope.row['acquirerRealname']['id_number']) }}</p></div></template></el-table-column></template><template #farmerInfo><el-table-column label="收款人信息" :width="300"><template #default="scope"><div class="data-info"><p class="data-item">收款人:{{ scope.row['farmer']['username'] }}</p><p class="data-item">身份证:{{ scope.row['acquirer']['username'] }}</p><p class="data-item">手机号:{{ scope.row['acquirer']['mobile'] }}</p><p class="data-item">身份证:{{ maskNumber(scope.row['acquirerRealname']['id_number']) }}</p><p class="data-item">银行卡:{{ maskNumber(scope.row['bank_no']) }}</p></div></template></el-table-column></template></Table>
</template>// column 字段中新增
{label: t('order.acquirer_info'),prop: 'acquirer.acquirer_info',align: 'center',operatorPlaceholder: t('Fuzzy query'),operator: false,width: 170,render: 'slot',slotName: 'acquirerInfo'
},// 样式设置 
<style scoped>
.data-info {font-family: 'Arial', sans-serif; /* 设置字体 */background-color: #f9f9f9; /* 背景色 */padding: 12px; /* 内边距 */border-radius: 6px; /* 边框圆角 */box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); /* 阴影效果 */
}.data-item {margin-bottom: 8px; /* 每行之间的间距 */color: #333; /* 文本颜色 */font-size: 14px; /* 字体大小 */
}.data-label {font-weight: bold; /* 标签字体加粗 */color: #0a74da; /* 标签字体颜色 */
}.data-info p:last-child {margin-bottom: 0; /* 最后一行不加底部间距 */
}.el-table .cell {padding: 0; /* 去掉单元格的默认间距 */
}.el-table-column {padding-left: 10px;padding-right: 10px;
}/* 鼠标悬停效果 */
.el-table__row:hover {background-color: #f0f8ff; /* 悬停背景色 */
}.el-table__cell {padding: 12px; /* 单元格内间距 */
}/* 为表格头部设置样式 */
.el-table th {background-color: #e6f7ff; /* 表头背景色 */font-weight: bold; /* 表头字体加粗 */color: #555; /* 表头文字颜色 */text-align: center; /* 表头文字居中 */
}
</style>

相关文章:

  • AOSP Android14 Launcher3——点击桌面图标启动应用动画流程
  • Docker安装beef-xss
  • Python3网络爬虫开发--爬虫基础
  • 多语言商城系统开发流程
  • 【Easylive】consumes = MediaType.MULTIPART_FORM_DATA_VALUE 与 @RequestPart
  • 【英语语法】词法---连词
  • Spring是如何实现资源文件的加载
  • LX5-STM32F103C8T6引脚分布与定义
  • longchain使用通义千问
  • 如何对只能有一个`public`顶层类这句话的理解
  • 大文件分片上传进阶版(新增md5校验、上传进度展示、并行控制,智能分片、加密上传、断点续传、自动重试),实现四位一体的网络感知型大文件传输系统‌
  • Maxscript调用Newtonsoft.Json解析Json
  • 从 TinyZero 到 APR:语言模型推理能力的探索与自适应并行化
  • Linux——入门常用基础指令
  • 基于unsloth微调一个越狱大模型
  • Linux——信号(2)信号保存与捕捉
  • CompletableFuture并行处理任务
  • 《MySQL:MySQL表的基本查询操作CRUD》
  • ros2 humble moveit调试笔记
  • docker基本命令1
  • 成都市政府秘书长王忠诚调任遂宁市委副书记
  • 延安市委副书记马月逢已任榆林市委副书记、市政府党组书记
  • 黄仁勋结束年内第二次中国行:关键时刻,重申对中国市场承诺
  • 夜读丨“看看世界”本身就是一种意义
  • 中央和国家机关工委建立健全整治形式主义为基层减负长效机制
  • 释新闻|特朗普喊话鲍威尔早点走人,美国总统能否解雇美联储主席?