mul.html 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <input type="hidden" name="id" id="id" value="{% if 'info' in data and data['info'] and 'id' in data['info'] and data['info']['id'] > 0 %}{{data['info']['id']}}{% end %}" />
  2. <div class="form">
  3. <label><span>控制名称:</span><input type="text" name="update_name" id="update_name" value="{% if 'info' in data and data['info'] and 'name' in data['info'] and data['info']['name'] %}{{data['info']['name']}}{% end %}" placeholder="批量控制名称"></label>
  4. <label><span>设备类型:</span>
  5. <select id="update_type" name="update_type" onchange="selectDevice($(this))">
  6. {% for v in data['type'] %}
  7. <option value="{{v['id']}}" {% if 'info' in data and data['info'] and 'device_type' in data['info'] and data['info']['device_type'] == v['id'] %}selected{% end %}>{{v['name']}}</option>
  8. {% end %}
  9. </select>
  10. </label>
  11. {% if Demeter.isset('span') == 0 %}<label><span>选择设备:</span></label>{% end %}
  12. <div class="flex-cont">
  13. <div class="scroller">
  14. <ul>
  15. {% for v in data['gateway'] %}
  16. <li tab-id="{{v['id']}}" id="gateway_{{v['id']}}"><a href="javascript:;">{{v['name']}}</a></li>
  17. {% end %}
  18. </ul>
  19. </div>
  20. <div class="scroller tab-cont">
  21. {% for k,v in enumerate(data['gateway']) %}
  22. <ul tab-cont-id="{{v['id']}}" {% if k == 0 %}style="display: block;"{% else %}style="display: none;"{% end %}>
  23. {% if data['device'] and v['id'] in data['device'] %}
  24. {% for d in data['device'][v['id']] %}
  25. {%set type = Demeter.service('common').one('setting_device_type', id=d['type_id'])%}
  26. <li {% if type['unit'] == 'button' %}class="device_type device_type_2"{% else %}class="device_type device_type_1"{% end %}><label><input type="checkbox" name="update_devices" ids="update_devices" value="{{d['id']}}" data-parent="{{v['id']}}" {% if 'devices' in data['info'] and d['id'] in data['info']['devices'] %}checked{% end %}><span>{{d['name']}}</span></label></li>
  27. {% end %}
  28. {% end %}
  29. </ul>
  30. {% end %}
  31. </div>
  32. </div>
  33. <script type="text/javascript">
  34. $('.scroller').on('click','[tab-id]',function(){
  35. var tabid = $(this).attr('tab-id');
  36. $('.tab-cont [tab-cont-id="'+tabid+'"]').show().siblings().hide();
  37. })
  38. function selectDevice(e) {
  39. var v = e.val();
  40. var id = '.device_type_' + v;
  41. $(".device_type").hide();
  42. $(id).show();
  43. }
  44. $(function()
  45. {
  46. $("#update_type").change();
  47. });
  48. </script>
  49. </div>