vue elementui el-table 表格里边展示四分位图

ops/2024/9/24 0:25:38/

elementui_eltable__0">vue elementui el-table 表格里边展示四分位图

直接上代码(效果图在文章末尾):

父组件:

<template>
<el-table size="small":header-cell-style="headerCellStyle()"style="width: 100%;"highlight-current-rowrow-key="index":data="tableData1" ><el-table-columnlabel="标题1"prop="name1"align="left"><template slot-scope="scope"><span>{{ scope.row.name1}}</span></template></el-table-column><el-table-columnlabel="数据1"prop="value1"align="center"><template slot-scope="scope"><div v-if="scope.row.name1 === '指标4'"><quartileChart :quartile="scope.row.value1"></quartileChart></div><span v-else>{{ scope.row.value1}}</span></template></el-table-column><el-table-columnlabel="数据2"prop="value2"align="center"><template slot-scope="scope"><div v-if="scope.row.name1 === '指标4'"><quartileChart :quartile="scope.row.value2"></quartileChart></div><span v-else>{{ scope.row.value2}}</span></template></el-table-column><el-table-columnlabel="数据3"prop="value3"align="center"><template slot-scope="scope"><div v-if="scope.row.name1 === '指标4'"><quartileChart :quartile="scope.row.value3"></quartileChart></div><span v-else>{{ scope.row.value3}}</span></template></el-table-column><el-table-columnlabel="数据4"prop="value4"align="center"><template slot-scope="scope"><div v-if="scope.row.name1 === '指标4'"><quartileChart :quartile="scope.row.value4"></quartileChart></div><span v-else>{{ scope.row.value4}}</span></template></el-table-column><el-table-columnlabel="数据5"prop="value5"align="center"><template slot-scope="scope"><div v-if="scope.row.name1 === '指标4'"><quartileChart :quartile="scope.row.value5"></quartileChart></div><span v-else>{{ scope.row.value5}}</span></template></el-table-column></el-table>
</template>
<script>javascript">
import quartileChart from '@/components/quartileChart.vue' // 引入子组件(四分位图),注意引入路径
export default {
components: { quartileChart },data() {return {tableData1: [{name1: '指标1',value1: '0.33%', value2: '0.33%', value3: '0.33%', value4: '0.33%', value5: '0.33%', },{name1: '指标2',value1: '0.33%', value2: '0.33%', value3: '0.33%', value4: '0.33%', value5: '0.33%', },{name1: '指标3',value1: '0.33%', value2: '0.33%', value3: '0.33%', value4: '0.33%', value5: '0.33%', },{name1: '指标4',value1: '1', value2: '2', value3: '3', value4: '4', value5: null, }]}methods: {headerCellStyle () {return {color: " #333 !important", backgroundColor: "#cedff3  !important",fontSize: '14px',fontWeight: 500,}}}}
}</script>

子组件:

<template><div><div v-if="5 - Number(quartile) === 1" class="ranking rank_1"><div class="r4"></div><div class="r3"></div><div class="r2"></div><div class="r1"></div></div><div v-else-if="5 - Number(quartile) === 2" class="ranking rank_2"><div class="r4"></div><div class="r3"></div><div class="r2"></div><div class="r1"></div></div><div v-else-if="5 - Number(quartile) === 3" class="ranking rank_3"><div class="r4"></div><div class="r3"></div><div class="r2"></div><div class="r1"></div></div><div v-else-if="5 - Number(quartile) === 4" class="ranking rank_4"><div class="r4"></div><div class="r3"></div><div class="r2"></div><div class="r1"></div></div><div v-else class="ranking rank_5"><div class="r4"></div><div class="r3"></div><div class="r2"></div><div class="r1"></div></div></div>
</template><script>javascript">
export default {name: 'quartileChart',components: {},props: {quartile: {type: String,}},data () {return {}},created () {},mounted () {},computed: {},watch: {},methods: {},
}
</script><style lang="scss" scoped>
.ranking{width: 47px;margin: 0 auto;height: 39px;margin-top: 1px;margin-bottom: 2px;div {height: 9px;zoom: 1;overflow: hidden;border: 1px solid #dcdcdc;margin-top: -1px;}
}
.rank_1 { .r4 {height: 11px;}.r3 {height: 11px;}.r2 {height: 11px;}.r1 {border: 0;background: #e1edfc;height: 11px;}
}
.rank_2 { .r4 {height: 11px;}.r3 {height: 11px;}.r2 {border: 0;background: #cbdff8;height: 11px;}.r1 {border: 0;background: #e1edfc;height: 11px;}
}
.rank_3 { .r4 {height: 11px;}.r3 {border: 0;background: #b3ceef;height: 11px;}.r2 {border: 0;background: #cbdff8;height: 11px;}.r1 {border: 0;background: #e1edfc;height: 11px;}
}
.rank_4 { .r4 {border: 0;background: #94b7e3;height: 11px;}.r3 {border: 0;background: #b3ceef;height: 11px;}.r2 {border: 0;background: #cbdff8;height: 11px;}.r1 {border: 0;background: #e1edfc;height: 11px;}
}
.rank_5 { .r4 {height: 11px;}.r3 {height: 11px;}.r2 {height: 11px;}.r1 {height: 11px;}
}</style>

展示效果图:

在这里插入图片描述


http://www.ppmy.cn/ops/19544.html

相关文章

解决双击PDF文件出现打印的问题【Adobe DC】

问题描述 电脑安装Adobe Acrobat DC之后&#xff0c;双击PDF文件就会出现打印&#xff0c;而无法直接打开。 右键PDF文件就会发现&#xff0c;第一栏出现的不是用Adobe打开&#xff0c;而是打印。 重装软件多次仍然无法解决。 原因 右键菜单被改写了。双击其实是执行右键菜…

C语言为什么没有应用层开发的库

C语言是一门“古老”的语言了&#xff0c;在中大型的应用层项目开发中&#xff0c;C,Java,Python,C# 等其他编程语言能够更好地胜任&#xff0c;为C语言开发应用层的库简直是费力不讨好&#xff0c;所以几乎没人这么做。在开始前我有一些资料&#xff0c;是我根据网友给的问题精…

SQL嵌套查询和集合查询

嵌套查询 先导概念 查询块&#xff1a;一个select语句为一个查询块 嵌套查询&#xff1a;将一个查询块嵌套在一个另一个查询块中where子句中的查询叫做嵌套查询。 嵌套查询的种类&#xff1a; 不相关子查询&#xff1a;子查询里的条件不依赖于父查询&#xff0c;从里到外依…

Parallels Desktop19虚拟机电脑版下载安装Windows详细图文教程2024最新

Parallels Desktop是一款Mac虚拟机软件&#xff0c;可以在Mac上运行Windows系统&#xff0c;它是Mac上最优秀的虚拟机软件之一。用户无需重启即可在Mac上同时运行Mac OS和Windows应用程序&#xff0c;且两者之间能够无缝切换&#xff0c;对此&#xff0c;用户甚至无需设置双系统…

C语言 三目运算符

C语言 逻辑分支语句中 还有一种 三目运算符 我们编写代码如下 #include <stdio.h>int main() {const char* a 1 1 ? "表达式1" : "表达式2";printf("%s", a);return 0; }这里 我们根据逻辑 先定义一个a 然后 它的值 等于一个 三目运算…

iZotope RX 10 音频修复和增强工具 mac/win

iZotope RX 10 for Mac是一款出色的音频修复和增强工具&#xff0c;凭借其卓越的音频处理技术&#xff0c;能够轻松应对各种音频问题。 无论是背景噪音、回声还是失真&#xff0c;RX 10都能精准去除&#xff0c;还原清晰纯净的音频。同时&#xff0c;它还提供了丰富的增强工具&…

如何处理PHP中的文件上传和下载?

如何处理PHP中的文件上传和下载&#xff1f; 处理PHP中的文件上传和下载是Web开发中常见的任务&#xff0c;涉及到前端表单的设计、后端脚本的编写以及服务器配置等多个方面。下面将详细阐述如何在PHP中实现文件上传和下载的功能。 文件上传 文件上传通常涉及前端表单的创建…

阿里云服务器部署wordpress站点

步骤如下&#xff1a; 安装宝塔登录宝塔&#xff0c;安装wordpress环境新建站点&#xff0c;新建的时候只输入ip地址就可以&#xff0c;再创建一个数据库dev1在站点文件夹中传入wordpress&#xff0c;更改站点的配置文件&#xff0c;将工作目录xxx改成xxx/wordpress修改wordpr…