若依 ruoyi-vue 隐藏字典样式

news/2025/2/14 4:47:58/

平时我们会使用若依字典样式,有时候需要隐藏。

      <el-table-column label="统计指标" align="center" prop="type" width="200px"><template slot-scope="scope"><dict-tag :options="dict.type.statistical_index" :value="scope.row.type" :hideStyle="true"/></template></el-table-column>
<template><div><template v-for="(item, index) in options"><template v-if="values.includes(item.value)"><spanv-if="getHideStyle(item)":key="item.value":index="index":class="item.raw.cssClass">{{ item.label + ' ' }}</span><el-tagv-else:disable-transitions="true":key="item.value":index="index":type="item.raw.listClass == 'primary' ? '' : item.raw.listClass":class="item.raw.cssClass">{{ item.label + ' ' }}</el-tag></template></template><template v-if="unmatch && showValue">{{ unmatchArray | handleArray }}</template></div>
</template><script>javascript">
export default {name: "DictTag",props: {options: {type: Array,default: null,},value: [Number, String, Array],// 当未找到匹配的数据时,显示valueshowValue: {type: Boolean,default: true,},separator: {type: String,default: ","},hideStyle:{type: Boolean,default: false,}},data() {return {unmatchArray: [], // 记录未匹配的项}},computed: {values() {if (this.value === null || typeof this.value === 'undefined' || this.value === '') return []return Array.isArray(this.value) ? this.value.map(item => '' + item) : String(this.value).split(this.separator)},unmatch() {this.unmatchArray = []// 没有value不显示if (this.value === null || typeof this.value === 'undefined' || this.value === '' || this.options.length === 0) return false// 传入值为数组let unmatch = false // 添加一个标志来判断是否有未匹配项this.values.forEach(item => {if (!this.options.some(v => v.value === item)) {this.unmatchArray.push(item)unmatch = true // 如果有未匹配项,将标志设置为true}})return unmatch // 返回标志的值},},filters: {handleArray(array) {if (array.length === 0) return '';return array.reduce((pre, cur) => {return pre + ' ' + cur;})},},methods: {// 封装判断逻辑的方法getHideStyle(item) {if (this.hideStyle) {return this.hideStyle} else {return ((item.raw.listClass === 'default' || item.raw.listClass === '') &&(item.raw.cssClass === '' || item.raw.cssClass === null));}}}
};
</script>
<style scoped>
.el-tag + .el-tag {margin-left: 10px;
}
</style>

http://www.ppmy.cn/news/1571879.html

相关文章

k8s ingress-nginx-controller 0.46.0 升级到 1.6.4

官网文档提到&#xff0c;只需替换镜像版本即可升级 ingress-nginx-controller 官方文档升级 寻找对应的ingress-nginx-controller版本 因为是 k8s 版本升级到1.24后导致的不兼容&#xff0c;所以我们要找到对应的版本的ingress 寻找对应版本地址 我们找到了比较合适的1.6.4…

【设计模式】【行为型模式】策略模式(Strategy)

&#x1f44b;hi&#xff0c;我不是一名外包公司的员工&#xff0c;也不会偷吃茶水间的零食&#xff0c;我的梦想是能写高端CRUD &#x1f525; 2025本人正在沉淀中… 博客更新速度 &#x1f44d; 欢迎点赞、收藏、关注&#xff0c;跟上我的更新节奏 &#x1f3b5; 当你的天空突…

2025年3月一区SCI-真菌生长优化算法Fungal growth optimizer-附Matlab免费代码

引言 本期介绍了一种新的自然启发的元启发式算法-真菌生长优化算法Fungal growth optimizer&#xff0c;FGO&#xff0c;这是受到自然界真菌生长行为的启发。该算法于2025年3月最新发表在中科院1区SCI期刊 Computer Methods in Applied Mechanics and Engineering。 模拟了以菌…

动态规划LeetCode-416.分割等和子集

给你一个 只包含正整数 的 非空 数组 nums 。请你判断是否可以将这个数组分割成两个子集&#xff0c;使得两个子集的元素和相等。 示例 1&#xff1a; 输入&#xff1a;nums [1,5,11,5] 输出&#xff1a;true 解释&#xff1a;数组可以分割成 [1, 5, 5] 和 [11] 。 示例 2&…

如何在 Java 应用中实现数据库的主从复制(读写分离)?请简要描述架构和关键代码实现?

在Java应用中实现数据库主从复制&#xff08;读写分离&#xff09; 一、架构描述 &#xff08;一&#xff09;整体架构 主库&#xff08;Master&#xff09; 负责处理所有的写操作&#xff08;INSERT、UPDATE、DELETE等&#xff09;。它是数据的源头&#xff0c;所有的数据变…

Visual Studio 进行单元测试【入门】

摘要&#xff1a;在软件开发中&#xff0c;单元测试是一种重要的实践&#xff0c;通过验证代码的正确性&#xff0c;帮助开发者提高代码质量。本文将介绍如何在VisualStudio中进行单元测试&#xff0c;包括创建测试项目、编写测试代码、运行测试以及查看结果。 1. 什么是单元测…

Maven 多模块项目管理

1. 什么是 Maven 多模块项目&#xff1f; 在 Maven 中&#xff0c;多模块项目是指一个父项目管理多个子模块的项目结构。每个子模块都可以是一个独立的模块或应用&#xff0c;但都在同一个父 POM 文件的管理下。通过这种结构&#xff0c;团队可以更好地组织大型项目&#xff0…

机器学习数学公式推导笔记

正定方程是凸函数证明 范数 向量的范数与内积 范数例子