var dictionaryGroupMap = {}; var dictionaryDetailMap = {}; $(function() { var viewH = document.documentElement.clientHeight; var fkRight = document.getElementById("fkRight"); fkRight.style.height = (viewH - 98) + "px"; $.ajax({ url: '/riskManageWeb/dictionary/getAllOptions', type: 'POST', dataType: 'json', data: {}, success: function(result) { //alert(result.length); dict = result; for (var i = 0; i < result.length; i++) { var item = result[i]; var lxbm = item.lxbm, code = item.code, name = item.name; var array = dictionaryGroupMap[lxbm]; if (array == null) dictionaryGroupMap[lxbm] = array = []; array.push({ value: code, text: name }); var obj = dictionaryDetailMap[lxbm]; if (obj == null) dictionaryDetailMap[lxbm] = obj = {}; obj[code] = name; } } }) }); //获取某类型包括的全部字典数据,格式为[{text:"text1",value:"value1"},{text:"text1",value:"value1"}],适合表单元素下拉选项。周小建 function getDicts(lxbm){ return top.dictionaryGroupMap[lxbm] || []; } //获取某类型包括的全部字典数据,格式为[{text:"text1",value:"value1"},{text:"text1",value:"value1"}],适合查询框下拉选项,由于有“请选择”。周小建 function getDictsExt(lxbm){ var dicts = getDicts(lxbm); var array = [{text : "请选择", value : ""}]; $.merge(array,dicts); return array; } //获取某类型某代码对应的字典名称,经过类型和编码获取名称,适合表格中的code转name等状况。周小建 function getDict(lxbm,code){ return (top.dictionaryDetailMap[lxbm]||{})[code]; }