var Common = {
dictCache : {},
showDictText:function(dictType,value){
if(value == "" || value == undefined){
return "";
}
var dicts=Common.getDicts(dictType);
var rtnStr = "";
for(var i=0;i<dicts.length;i++){
if(dicts[i].id== value){
rtnStr += dicts[i].text;
}
}
return rtnStr;
},
getDicts:function(dictType){
if(Common.dictCache[dictType] == undefined || Common.dictCache[dictType] == null){
//不存在,获取缓存
$.ajax({
type: "GET",
url: contextPath + "web/admin/system/codetype/dict",
async:false,
data:{codeTypeId : dictType},
dataType: "json",
success:function (datas) {
Common.dictCache[dictType] = datas;
}
});
}
return Common.dictCache[dictType];
}
}
后台数据格式为[{id:’1′,text:’aaa’},{id:’2′,text:’bbb’}]
版权声明:本文为luo0001000原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。