| | |
| | | function setFormVal(el, data, showImg) { |
| | | for (var val in data) { |
| | | var find = el.find(":input[id='" + val + "']"); |
| | | var currentVal = data[val]; |
| | | if (val === 'area') { |
| | | currentVal = normalizeAreaValue(currentVal); |
| | | } |
| | | if (find[0]!=null){ |
| | | if (find[0].type === 'checkbox'){ |
| | | if (data[val]==='Y'){ |
| | | if (currentVal==='Y'){ |
| | | find.attr("checked","checked"); |
| | | find.val('Y'); |
| | | } else { |
| | |
| | | continue; |
| | | } |
| | | } |
| | | find.val(data[val]); |
| | | find.val(currentVal); |
| | | if (showImg){ |
| | | var next = find.next(); |
| | | if (next.get(0)){ |
| | | if (next.get(0).localName === "img") { |
| | | find.hide(); |
| | | next.attr("src", data[val]); |
| | | next.attr("src", currentVal); |
| | | next.show(); |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | function normalizeAreaValue(value) { |
| | | if (value === undefined || value === null) { |
| | | return value; |
| | | } |
| | | var normalized = String(value).replace(/\s+/g, '').toUpperCase(); |
| | | if (normalized === '1' || normalized === 'A' || normalized === 'A区' || normalized === 'A库' || normalized === 'A库区') { |
| | | return 'A'; |
| | | } |
| | | if (normalized === '2' || normalized === 'B' || normalized === 'B区' || normalized === 'B库' || normalized === 'B库区') { |
| | | return 'B'; |
| | | } |
| | | if (normalized === '3' || normalized === 'C' || normalized === 'C区' || normalized === 'C库' || normalized === 'C库区') { |
| | | return 'C'; |
| | | } |
| | | return value; |
| | | } |
| | | |
| | | function clearFormVal(el) { |
| | | $(':input', el) |
| | | .val('') |