| | |
| | | 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; |
| | | } |
| | | selectDom.style.display='block'; |
| | | } else if (res.code === 403){ |
| | | top.location.href = "/"; |
| | | top.location.href = baseUrl+"/"; |
| | | } else { |
| | | layer.msg(res.msg) |
| | | layer.msg(typeof I18n !== 'undefined' ? I18n.t(res.msg) : res.msg, {icon: 2}) |
| | | } |
| | | } |
| | | }); |
| | |
| | | return str; |
| | | } |
| | | |
| | | // 表单值清空 |
| | | function clearFormVal(el) { |
| | | $(':input', el) |
| | | .val('') |
| | | .removeAttr('checked') |
| | | .removeAttr('selected'); |
| | | } |
| | | |
| | | var banMsg; |
| | | var tips; |
| | | // 主键校验 |
| | |
| | | layer.close(tips); |
| | | banMsg = null; |
| | | } else if (res.code === 403) { |
| | | top.location.href = "/"; |
| | | top.location.href = baseUrl+"/"; |
| | | } else if (res.code === 407) { |
| | | banMsg = res.data + "不可用"; |
| | | tips = layer.tips( |