前言

  • 若依(ruoyi): v4.3

字典配置

系统管理 > 字典管理

DictService

DictService 类位于 com.office.framework.web.service 包中。该类作为 spring 的 Bean (bean name : dict),在 Thymeleaf 中使用。

DictUtils

DictUtils 类位于 com.office.framework.web.service 包中。该类作为 spring 的 Bean (bean name : dictUtils),在导出 Excel 功能中(被 ExcelUtil 类)使用。

在 Thymeleaf 模板的 Select 中使用

<select name="status" th:with="type=${@dict.getType('sys_normal_disable')}"><option value="">所有</option><option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
</select>

注:在 spring boot 项目中的 Thymeleaf 模板中,Access any beans in your application context using SpringEL’s syntax: ${@myBean.doSomething()}

在 Thymeleaf 模板的 Radio 中使用

<div class="form-group">    <label class="col-sm-3 control-label">工作状态:</label><div class="col-sm-8"><div class="radio-box" th:each="dict : ${@dict.getType('sys_staff_state')}"><input type="radio" th:id="${dict.dictCode}" th:value="${dict.dictValue}"><label th:for="${dict.dictCode}" th:text="${dict.dictLabel}"></label></div></div>
</div>

在 Thymeleaf 模板中作为回显使用

<label class="col-sm-2 control-label">回显数据字典值:</label>
<div class="form-control-static" th:text="${@dict.getLabel('sys_normal_disable', status)}">
</div>

在 Thymeleaf 模板的 table 中使用

// 获取数据字典数据
var disableDictDatas = [[${@dict.getType('sys_normal_disable')}]];// 初始化表格
var options = {url: prefix + "/list",...{field: 'disable',title: '是否禁用',// 格式化数据字典formatter: function(value, row, index) {return $.table.selectDictLabel(disableDictDatas, value);}},...]
};
$.table.init(options);

在 @Excel 注解中使用

/** 资产来源 */
@Excel(name = "资产来源", dictType = "ass_assets_source")
private String source;

注:当实体类的属性关联字典时,类型必须为String类型。否则,将不能将字典 value 转换成字典 label

因为将字典 value 转换成字典 label 是使用 DictUtils 类的 getDictLabel 方法。public static String getDictLabel(String dictType, String dictValue) 方法的定义只能接受 String 类型的字典 value

如果重载(overload)该方法,也可以。比如:public static String getDictLabel(String dictType, int dictValue)

参考

https://doc.ruoyi.vip/ruoyi/document/qdsc.html#字典使用
https://www.thymeleaf.org/doc/tutorials/3.0/thymeleafspring.html#the-springstandard-dialect
https://blog.csdn.net/weixin_42517667/article/details/82526675

【若依(ruoyi)】字典管理相关推荐

  1. 实现option上下移动_Django实战2-自动化运维之配置管理-05:字典管理功能实现

    本节内容主要实现CMDB基础数据管理功能的实现,文档中会介绍到datatables后端分页实现和过滤查询功能的实现.在Django实战1中已经自定义了 添加.修改等自定义类视图,本节中可以直接使用. ...

  2. 管理表空间和数据文件——建立表空间——建立字典管理表空间和建立加密表空间...

    字典管理表空间是为了与早期版本兼容而保留的空间管理特性.当使用字典管理方式时,区数据字典进行管理. 注意:如果建立字典管理表空间,那么要求system表空间必须采用字典管理方式,并且建立时,需要指定e ...

  3. Guns二次开发(四):重构字典管理模块

    关于博客中使用的Guns版本问题请先阅读   Guns二次开发目录 Guns中的字段管理是一个很不错的功能,我其实也是第一次发现还能这么玩,因为以前一直使用的方法是:后端直接将数据库保存的状态值返回给 ...

  4. Oracle表空间的管理方式(LMT、DMT)--本地和字典管理

    Oracle表空间的管理方式(LMT.DMT)--本地和字典管理 字典管理:oracle 8i(不包括i),只存在一种表空间的管理模式,即字典管理表空间(DMT).DMT是指oracle的空间分配或回 ...

  5. 【FastAdmin专题一】使用双表格联动实现字典管理之修改表格原始样式

    多读多写多记录,多学多练多思考.---------- Banana.Banuit Gang(香柚帮) 字典管理首页截图如下: 左边的一排按钮可以直接在html页面隐藏 index.html<st ...

  6. ruoyi后台管理系统分析(三)---admin包

    三.admin包 --web包 -----controller包 -----------common包 CommonController.java------通用请求处理 package com.ru ...

  7. 上古卷轴5python_基于Python-Flask的权限管理5:字典管理

    #!/usr/bin/python3#-*- coding: utf-8 -*- """@Author : Huguodong @Version : ---------- ...

  8. 分布式医疗云平台(项目功能简介截图)【系统管理(科室管理、用户管理、角色管理、菜单管理 、字典管理、通知公告管理 、检查费用设置、挂号费用设置 )】】(四)-全面详解(学习总结---从入门到深化)

    项目功能截图 1. 系统管理 1.1.科室管理 1.2.用户管理 1.3.角色管理 1.4.菜单管理

  9. ruoyi后台管理系统分析(六)----system包

    六.system包 --domain包 SysConfig.java-----参数配置表 sys_config package com.ruoyi.system.domain;import org.a ...

最新文章

  1. IDEA IntelliJ 如何快速查看一个类里面包含哪些方法
  2. “半价买2080Ti”,英伟达发布RTX 30系列显卡,性能翻倍价格更低,网友高呼“NVIDIA YES”...
  3. 在JavaScript中创建多行字符串
  4. This tutorial code needs the xfeatures2d contrib module to be run.
  5. Jena文档《An Introduction to RDF and the Jena RDF API》的译文
  6. 【Python】洛谷 P1175_表达式的转换(逆波兰式、中缀表达式、后缀表达式、栈)
  7. 2013年1月18日调试触发器“表发生了变化,触发器或函数不能读它”的出现原因,以及解决方案...
  8. Codeforces Round #268 (Div. 1) C. Hack it! 数位dp + 构造数位
  9. redis的淘汰策略
  10. ctf练习之音频文件
  11. MongoDB可视化工具mongochef
  12. 计算机网络中netbuie,材料内部空隙体积占其总体积的百分率叫做()。A、孔隙率B、填充率C、空隙率D、密实度...
  13. js对象定义的几种方法
  14. 贷款广告投放行为观察:价格高企主要客户是小贷公司,朋友圈转化效果最好
  15. ArcGIS空间数据分析实用工具——方向分布(标准差椭圆)
  16. 51单片机实战教程(四 延时程序)
  17. 笔记本的结构深入分析
  18. 干货 | 如何搭建小型视频点播网站
  19. map、set(底层结构)——C++
  20. 全球Flickr地理标记数据,含经纬度

热门文章

  1. Collections.unmodifiableMap
  2. IQ推理:红眼睛和蓝眼睛
  3. Android Dialog 系统样式讲解及透明背景
  4. 解决linux下无线网卡被物理禁用问题
  5. centos6.4 搭建vsftpd
  6. 执行存储过程出现:不是有效的标识符。
  7. 如何编写一份SOP?
  8. C#反射调用 异常信息:Ambiguous match found.
  9. Spring使用@Required注解依赖检查
  10. C# winform 上传文件到服务器