1.首先在系统字典中进行注册,系统会生成父级编码,如图:
复制父级编码(例如: 1301),在Constant类中 写上如下代码:
public static final String OPINION_TYPE ="1301"; //意见类别
2.在controller类中的写上如下代码:
Map<String, String> opinionTypeMap = Codekit.getSysDictFromPDictCode(Constants.OPINION_TYPE); //意见类别
String opinionTypeMapJson = fromObject(opinionTypeMap, Constants.BEAN_MAP_JSON);
request.setAttribute("opinionTypeMap",opinionTypeMap);
request.setAttribute("opinionTypeMapJson",opinionTypeMapJson);
private void initCommonInfo(HttpServletRequest request, HttpServletResponse response) {
/*******************按钮权限*************************/
try {
String id = (String) this.getSessionAttribute(request, "moduleid");
List<NavTreeDto> authButton = this.getAuthorizeMenuButtonJson(request,
response,
(String) this.getSessionAttribute(request, Constants.SESSION_ROLE_ID),
id,
Constants.SYS_MODULE_TERMINAL_TYPE_PCWEB);
this.setRequestAttribute(request, "buttonList", JSON.toJSON(authButton));
} catch (Exception e) {
e.printStackTrace();
}
Map<String, String> opinionTypeMap = Codekit.getSysDictFromPDictCode(Constants.OPINION_TYPE); //意见类别
String opinionTypeMapJson = fromObject(opinionTypeMap, Constants.BEAN_MAP_JSON);
request.setAttribute("opinionTypeMap",opinionTypeMap);
request.setAttribute("opinionTypeMapJson",opinionTypeMapJson);
}
3.然后在jsp和js中进行配置,opinionTypeMap和opinionTypeMapJson与controller中的对应
模糊查询:
jsp:
<td class="tab_name">意见类型:</td>
<td><select id="wttype" name="wttype">
<option value="" selected>请选择</option>
<c:forEach var="map" items="${opinionTypeMap}">
<option value="${map.key}">${map.value}</option>
</c:forEach>
</select></td>
<script type="text/javascript" charset="UTF-8">
$(function(){
Temp = {};
Temp.opinionTypeMapJson =${opinionTypeMapJson};
Temp.listpagemodulename = '${listpagemodulename}';
});
</script>
js:
var opinionTypeMapJson = Temp.opinionTypeMapJson;
columns : [ [{
field : 'wttype',
title : '类型',
align: 'center',
width : 100,
formatter : function(value, row, index){
value = opinionTypeMapJson[value];
return value;
}
增加:
jsp:
<td>意见类型:</td>
<td><select id="wttype" name="wttype">
<option value="" selected>请选择</option>
<c:forEach var="map" items="${opinionTypeMap}">
<option value="${map.key}">${map.value}</option>
</c:forEach>
</select></td>
编辑:
jsp:
<td>意见类型:</td>
<td>
<select name="wttype" id="wttype">
<option value="">请选择</option>
<c:forEach var="wt" items="${opinionTypeMap}">
<option value="${wt.key}"
${wtDto.wttype==wt.key?"selected":""}>${wt.value}
</option>
</c:forEach>
</select>
</td>