form.html 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. {% extends 'base.html' %}
  2. {% block title %}{{ '改' if editing else '新增' }}{{ meta.cn }}{% endblock %}
  3. {% block body %}
  4. <div class="page-head">
  5. <div>
  6. <h1>{{ '编辑' if editing else '新增' }}{{ meta.cn }}</h1>
  7. <div class="sub">主键 {{ meta.pk|join(' + ') }} · {{ meta.cols|length }} 个字段 · 保存后采集进程 5 秒内热重载点表</div>
  8. </div>
  9. <div class="acts">
  10. <a href="/db/{{ table }}"><button type="button" class="gray">返回列表</button></a>
  11. {% if editing and row.get('wind_id') %}
  12. <a href="/db/signal?farm_id={{ row.get('farm_id', '') }}&wind_id={{ row.get('wind_id', '') }}"><button type="button" class="gray">该机组的测点</button></a>
  13. {% endif %}
  14. </div>
  15. </div>
  16. {% if err %}<div class="err">{{ err }}</div>{% endif %}
  17. {% if ok %}<div class="flash">{{ ok }}</div>{% endif %}
  18. <form method="post" action="{{ action }}">
  19. <div class="card">
  20. <div class="grid">
  21. {% for col, cn, req in meta.cols %}
  22. {% set chosen = row.get(col) or '' %}
  23. {% set is_pk = col in meta.pk %}
  24. <div class="field">
  25. <label for="f_{{ col }}">{{ cn }}{% if req or is_pk %} *{% endif %}</label>
  26. {% if col == 'farm_id' and table != 'farm' and opts.get('farm_id') %}
  27. <select id="f_{{ col }}" name="{{ col }}"
  28. {%- if editing and is_pk %} disabled{%- endif %}>
  29. <option value="">(选风场)</option>
  30. {% for o in opts['farm_id'] %}
  31. <option value="{{ o.v }}" {{ 'selected' if chosen == o.v }} title="{{ o.v }}">{{ o.l }}</option>
  32. {% endfor %}
  33. {% if chosen and chosen not in farm_map %}
  34. <option value="{{ chosen }}" selected>{{ chosen }}(风场台账里没有这个编号)</option>
  35. {% endif %}
  36. </select>
  37. <span class="hint">{{ '主键,改风场等于换记录,请删掉重建' if editing and is_pk else '从风场台账里选' }}</span>
  38. {% elif is_pk %}
  39. <input id="f_{{ col }}" name="{{ col }}" class="mono" value="{{ chosen }}"
  40. {% if editing %}readonly{% endif %}>
  41. <span class="hint">主键{% if editing %},保存时以链接里的原值为准{% endif %}</span>
  42. {% elif col == 'enabled' %}
  43. <select id="f_{{ col }}" name="{{ col }}">
  44. <option value="true" {{ 'selected' if row.get(col) is not false }}>启用(采集进程监听这个端口)</option>
  45. <option value="false" {{ 'selected' if row.get(col) is false }}>停用(采集进程不监听,重启后生效)</option>
  46. </select>
  47. <span class="hint">停用只改台账,采集进程要重启才不监听这个端口</span>
  48. {% else %}
  49. <input id="f_{{ col }}" name="{{ col }}"
  50. class="{{ 'mono' if col in ('port', 'common_addr', 'obj_addr', 'signal_id', 'algo_signal', 'signal_name', 'wind_id', 'engine_code', 'mill_type_code') else '' }}"
  51. value="{{ chosen }}">
  52. <span class="hint">&nbsp;</span>
  53. {% endif %}
  54. </div>
  55. {% endfor %}
  56. </div>
  57. <div class="frow" style="margin-top:16px">
  58. <button type="submit">保存</button>
  59. <a href="/db/{{ table }}" class="hint">取消,返回列表</a>
  60. </div>
  61. </div>
  62. </form>
  63. {% if editing and pk_qs %}
  64. <form method="post" action="/db/{{ table }}/delete?{{ pk_qs }}"
  65. onsubmit="return confirm('确定删除这条{{ meta.cn }}?删掉后采集到的对应数据会被算作「点表未收录」。')">
  66. <button type="submit" class="red">删除这条{{ meta.cn }}</button>
  67. </form>
  68. {% endif %}
  69. {% endblock %}