| | |
| | | var inputDomVal = document.querySelector("input[data-key="+val+"]").value; |
| | | var selectDom = document.querySelector("select[data-key="+val+"Select]"); |
| | | selectDom.length = 0; |
| | | var defaultOption = new Option("取消选择", ""); |
| | | var defaultOption = new Option(typeof I18n !== 'undefined' ? I18n.t('cancel_selection') : "取消选择", ""); |
| | | defaultOption.title = ""; |
| | | selectDom.appendChild(defaultOption); |
| | | selectDom.style.display='none'; |
| | |
| | | if (res.code === 200){ |
| | | var list = res.data; |
| | | for (var i=0;i<list.length;i++){ |
| | | var option = new Option(list[i].value, i); |
| | | var text = list[i].value; |
| | | var id = list[i].id; |
| | | |
| | | // 尝试翻译 |
| | | if (typeof I18n !== 'undefined' && typeof window.i18nEnumMap !== 'undefined') { |
| | | var mapper = window.i18nEnumMap[val]; |
| | | if (mapper) { |
| | | var transKey = null; |
| | | if (typeof mapper === 'function') { |
| | | transKey = mapper(id); |
| | | } else { |
| | | transKey = mapper[id]; |
| | | } |
| | | |
| | | if (transKey) { |
| | | var trans = I18n.t(transKey); |
| | | if (trans !== transKey) { |
| | | text = trans; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | var option = new Option(text, i); |
| | | option.title = list[i].id; |
| | | selectDom.options[i+1] = option; |
| | | } |