若依框架前端页面技术总结

本文详细介绍了如何在Thymeleaf模板引擎中使用字典数据进行搜索框配置、列表显示、数据修改及表单校验等操作,通过具体代码示例展示了各种场景下的应用技巧。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.搜索框中用到字典数据时的用法:

<li>
    <p style="width: 70px;">供应性质:</p>
    <select name="supplyProp" th:with="type=${@dict.getType('supply_prop')}">
        <option value="">所有</option>
        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
    </select>
</li>

2.列表显示用到字典数据的用法:

<script>下声明变量supplyProp,绑定的数据下添加formatter如下:

var supplyProp=[[${@dict.getType('supply_prop')}]];
{
    field : 'supplyProp', 
    title : '供应性质',
    formatter: function(value, row, index) {
        return $.table.selectDictLabel(supplyProp, value);
    }
}

3.修改数据时需要反显的数据字典用法:

<label class="col-sm-3 control-label">供应性质:</label>
<select  class="form-control" name="supplyProp" th:with="type=${@dict.getType('supply_prop')}">
    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:selected="${dict.dictValue}==*{supplyProp}" th:value="${dict.dictValue}"></option>
</select>

4.隐藏某个数据字典列表用法:

<select class="form-control" name="supplyProp" th:with="type=${@dict.getType('supply_prop')}"> <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:selected="${dict.dictValue}==*{supplyProp}"  th:hidden="${dict.dictValue}=='值'"  th:value="${dict.dictValue}"></option> </select>

5.表单校验:

// 表单验证
$("#form-goodsInfo-add").validate({
    onkeyup: false,
    rules:{
        rebateRate:{
            required:true,
            number:true,
            min:0
        },
        rate:{
            required:true,
            number:true,
            min:0
        }
    },
    focusCleanup: true
});
6.列表多选获取数据方式:
var rows = $.table.selectFirstColumns(); 
var code=$.table.selectColumns("id"); 
if (rows.length == 0) 
{ $.modal.alertWarning("请至少选择一条记录"); return; }

7.自定义传参:

/* 导入表结构-选择表结构-提交 */
function submitHandler() {
   var rows = $.table.selectColumns("tableName");
   if (rows.length == 0) {
             $.modal.alertWarning("请至少选择一条记录");
             return;
          }
   var data = {"tables": rows.join()};
   $.operate.save(prefix + "/importTable", data);
}

 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值