学习笔记--基于h-ui的下拉框,单选框,日期控件
乐正嘉瑞
2023-12-01
1.下拉框
<div class="row cl">
<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>商品分类:</label>
<div class="formControls col-xs-8 col-sm-9">
<span class="select-box">
<select class="select" name="categoryId">
<option value="">请选择</option>
<c:forEach items="${categories}" var="category">
<option value="${category.id }" <c:if test="${goods.categoryId eq category.id }">selected="selected"</c:if> >${category.name}</option>
</c:forEach>
</select>
</span>
</div>
</div>
后端代码:
@RequestMapping("edit")
public ModelAndView edit(TSGoods goods) {
ModelAndView view = new ModelAndView(PRE_BACK + "goods-edit");
if (goods.getId() != null) {
goods = goodsService.getGoods(goods.getId());
view.addObject("goods", goods);
}
List<TSSpec> goodsSpecs = specService.getSpecList();
view.addObject("goodsSpecs", goodsSpecs);
List<TSGoodsCategory> categories = categoryService.getCategoryList();
view.addObject("categories", categories);
return view;
}
2.单选框
<!-- 会员类型 -->
<div class="row cl">
<label class="form-label col-xs-4 col-sm-2">会员类型:</label>
<div class="formControls col-xs-8 col-sm-9 skin-minimal">
<#if (strTypeName == "company")>
<div class="radio-box">
<input name="strTypeName" type="radio" id="strTypeName-1" value="personal" >
<label for="strTypeName-1">个人</label>
</div>
<div class="radio-box">
<input name="strTypeName" type="radio" id="strTypeName-2" value="company" checked>
<label for="strTypeName-2">公司</label>
</div>
<#else >
<div class="radio-box">
<input name="strTypeName" type="radio" id="strTypeName-1" value="personal" checked>
<label for="strTypeName-1">个人</label>
</div>
<div class="radio-box">
<input name="strTypeName" type="radio" id="strTypeName-2" value="company">
<label for="strTypeName-2">公司</label>
</div>
</#if>
</div>
</div>
3.日期:
<div class="row cl">
<label class="form-label col-xs-4 col-sm-2">销售开始时间:</label>
<div class="formControls col-xs-8 col-sm-9">
<input type="text" name="beginTime" οnfοcus="WdatePicker({ dateFmt:'yyyy-MM-dd HH:mm:ss',maxDate:'#F{$dp.$D(\'datemax\')||\'%y-%M-%d\'}' })" value="<fmt:formatDate value='${goods.beginTime }' pattern='yyyy-MM-dd HH:mm:ss'/>" id="datemin" class="input-text Wdate" style="width:180px;">
</div>
</div>
<div class="row cl">
<label class="form-label col-xs-4 col-sm-2">销售结束时间:</label>
<div class="formControls col-xs-8 col-sm-9">
<input type="text" name="endTime" οnfοcus="WdatePicker({ dateFmt:'yyyy-MM-dd HH:mm:ss',minDate:'#F{$dp.$D(\'datemin\')}' })" value="<fmt:formatDate value='${goods.endTime }' pattern='yyyy-MM-dd HH:mm:ss'/>" id="datemax" class="input-text Wdate" style="width:180px;">
</div>
</div>