【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;
	}
相关推荐
一城烟雨_1 小时前
vue3 实现将html内容导出为图片、pdf和word
前端·javascript·vue.js·pdf
树懒的梦想1 小时前
调整vscode的插件安装位置
前端·cursor
低代码布道师3 小时前
第二部分:网页的妆容 —— CSS(下)
前端·css
一纸忘忧3 小时前
成立一周年!开源的本土化中文文档知识库
前端·javascript·github
涵信3 小时前
第九节:性能优化高频题-首屏加载优化策略
前端·vue.js·性能优化
前端小巷子3 小时前
CSS单位完全指南
前端·css
SunTecTec4 小时前
Flink Docker Application Mode 命令解析 - 修改命令以启用 Web UI
大数据·前端·docker·flink
软件技术NINI4 小时前
html css js网页制作成品——HTML+CSS甜品店网页设计(4页)附源码
javascript·css·html
涵信4 小时前
第十一节:性能优化高频题-响应式数据深度监听问题
javascript·vue.js·性能优化
codingandsleeping5 小时前
Express入门
javascript·后端·node.js