【VUE】element Table指定字段单元格样式及数据格式化

将列表中的指定字段的数据,根据字典值回显,并修改指定状态的显示样式

html 复制代码
	<el-table
				ref="table"
				height="500px"
				:data="dataList"
			>
				<template v-for="(item, index) in columns">
					<el-table-column
						:key="index"
						:index="index"
						:label="item.label"
						align="center"
						:prop="item.code"
						:show-overflow-tooltip="true"
					>
						<template slot-scope="scope">
							<template v-if="item.render">
								<span>
									<RenderDom
										:row="scope.row"
										:index="index"
										:render="item.render"
									/>
								</span>
							</template>

							<template v-else-if="item.code === 'deviceCount'">
								<span
									v-if="
										scope.row[item.code] === null || scope.row[item.code] === ''
									"
									>-</span
								>
								<button
									v-else
									class="deviceCountBtn"
									@click="handleDeviceCountBtn(scope.row)"
								>
									{{ scope.row[item.code] }}
								</button>
							</template>

							<template v-else-if="item.code === 'status'">
								<div class="statusFlex">
									<div
										:class="[
											'statusCircle',
											{ statusCirclePurple: scope.row[item.code] === '2' },
											{
												statusCircleGray:
													scope.row[item.code] === '1' ||
													scope.row[item.code] === '3' ||
													scope.row[item.code] === '4',
											},
										]"
									></div>
									<span>{{
										selectDictLabel(
											dict.type.paas_orderStatus,
											scope.row[item.code]
										)
									}}</span>
								</div>
							</template>
							<template v-else>
								<span>{{ scope.row[item.code] }}</span>
							</template>
						</template>
					</el-table-column>
				</template>
</el-table>
html 复制代码
// 列信息
			columns: [
				{
					label: this.$t('paasOrder.status'),
					code: `status`,
					visible: true,
					width: '250px',
				},
				{
					label: this.$t('common.updatedBy'),
					code: `updatedBy`,
					visible: true,
					width: '220px',
				},
				{
					label: this.$t('common.updatedTime'),
					code: `updatedTime`,
					visible: true,
					width: '220px',
				},
			],
html 复制代码
	// 清除圆形下默认'-'
	.statusCircle::after {
		content: '';
	}
	.statusFlex {
		display: flex;
		justify-content: center;
		align-items: center;
	}
	.statusCircleGray {
		width: 13px;
		height: 13px;
		border-radius: 13px;
		background: #d8d8d8;
		margin-right: 6px;
	}
	.statusCirclePurple {
		width: 13px;
		height: 13px;
		border-radius: 13px;
		background: #4d5aa0;
		margin-right: 6px;
	}
相关推荐
工一木子22 分钟前
URL时间戳参数深度解析:缓存破坏与前端优化的前世今生
前端·缓存
半点寒12W2 小时前
微信小程序实现路由拦截的方法
前端
某公司摸鱼前端3 小时前
uniapp socket 封装 (可拿去直接用)
前端·javascript·websocket·uni-app
要加油哦~3 小时前
vue | 插件 | 移动文件的插件 —— move-file-cli 插件 的安装与使用
前端·javascript·vue.js
小林学习编程3 小时前
Springboot + vue + uni-app小程序web端全套家具商场
前端·vue.js·spring boot
柳鲲鹏3 小时前
WINDOWS最快布署WEB服务器:apache2
服务器·前端·windows
weixin-a153003083164 小时前
【playwright篇】教程(十七)[html元素知识]
java·前端·html
ai小鬼头4 小时前
AIStarter最新版怎么卸载AI项目?一键删除操作指南(附路径设置技巧)
前端·后端·github
wen's4 小时前
React Native 0.79.4 中 [RCTView setColor:] 崩溃问题完整解决方案
javascript·react native·react.js
一只叫煤球的猫5 小时前
普通程序员,从开发到管理岗,为什么我越升职越痛苦?
前端·后端·全栈