buildadmin 自定义单元格渲染

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

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

官方推荐使用slot渲染

代码示例:

php 复制代码
// 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>
相关推荐
小红帽2.01 小时前
开源PHP在线客服系统源码搭建教程
开发语言·开源·php
CRMEB定制开发2 小时前
CRMEB 框架中 PHP 上传扩展开发:涵盖本地上传及阿里云 OSS、腾讯云 COS、七牛云
阿里云·php·腾讯云·微信商城·php商城源码
hao_wujing3 小时前
攻击模型的恶意行为检测
网络·数据库·php
宇宙的最后一粒尘埃5 小时前
Typeerror: cannot read properties of undefined (reading ‘XXX‘)
vue
Yungoal19 小时前
php & apache构建 Web 服务器
服务器·php·apache
浩浩测试一下19 小时前
Authpf(OpenBSD)认证防火墙到ssh连接到SSH端口转发技术栈 与渗透网络安全的关联 (RED Team Technique )
网络·网络协议·tcp/ip·安全·网络安全·php
孤寂大仙v20 小时前
【计算机网络】网络层IP协议与子网划分详解:从主机通信到网络设计的底层逻辑
tcp/ip·计算机网络·php
清幽竹客20 小时前
vue-18(使用 Vuex 插件实现高级功能)
前端·vue.js·前端框架·vue
牧码岛1 天前
Web前端之隐藏元素方式的区别、Vue循环标签的时候在同一标签上隐藏元素的解决办法、hidden、display、visibility
前端·css·vue·html·web·web前端
vortex51 天前
浅谈 Linux 防火墙:从原理到实践
linux·网络·php