{% extends "../theme/set.html" %}

{% block action %}{{data['common']['path']}}{% end %}
{% block url %}{{data['common']['path']}}{% end %}

{% block form %}
{% for index,name in enumerate(data['common']['label']) %}
  {%set value = data['common']['update'][index] %}
  {%set value = value.split('-') %}
  {%set length = len(value) %}
  <div class="layui-form-item {% if value[1] in ('text',)  %}layui-form-text{% end %}">
      <label for="{{value[0]}}" class="layui-form-label">
        {% if value[2] or (value[1] == 'password'  and not data['info']) %}<span class="x-red">*</span>{% end %}
          {{name}}
      </label>
      <div class="layui-input-block">
      {% if value[1] == 'input' %}
          <input type="text" id="update_{{value[0]}}" name="update_{{value[0]}}" lay-verify="{{value[2]}}"
          autocomplete="off" class="layui-input" value="{% if data['info'] and value[0] in data['info'] %}{{data['info'][value[0]]}}{% end %}" />
      {% elif value[1] == 'date' %}
          <input type="text" id="update_{{value[0]}}" name="update_{{value[0]}}" lay-verify="{{value[2]}}"
          autocomplete="off" class="layui-input time" value="{% if data['info'] and value[0] in data['info'] %}{{datetime.datetime.fromtimestamp(data['info'][value[0]]).strftime('%Y-%m-%d %H:%M:%S')}}{% end %}" readonly />
      {% elif value[1] == 'password' %}
          <input type="password" id="update_{{value[0]}}" name="update_{{value[0]}}" lay-verify="{% if not data['info'] %}required{% end %}"
          autocomplete="off" class="layui-input" value="" />
      {% elif value[1] == 'text' %}
          <textarea placeholder="请输入内容" class="layui-textarea" id="update_{{value[0]}}" name="update_{{value[0]}}" value="{% if data['info'] and value[0] in data['info'] %}{{data['info'][value[0]]}}{% end %}" lay-verify="{{value[2]}}">{% if data['info'] and value[0] in data['info'] %}{{data['info'][value[0]]}}{% end %}</textarea>
      {% elif value[1] == 'editor' %}
          <textarea placeholder="请输入内容" class="layui-textarea layui-editor" id="update_{{value[0]}}" name="update_{{value[0]}}" value="{% if data['info'] and value[0] in data['info'] %}{{data['info'][value[0]]}}{% end %}" lay-verify="{{value[2]}}">{% if data['info'] and value[0] in data['info'] %}{{data['info'][value[0]]}}{% end %}</textarea>
      {% elif value[1] == 'pic' %}
          <div class="site-demo-upbar">
            <img id="upload_{{value[0]}}_show" width="200" src="{% if data['info'] and value[0] in data['info'] %}{{data['info'][value[0]]}}{% end %}" style="{% if  data['info'] and value[0] in data['info'] and data['info'][value[0]] %}display:;{% else %}display:none;{% end %}margin-left:10px;"/>
            <input type="file" class="layui-upload-file" lay-type="images" name="file" id="upload_{{value[0]}}"/>{% if length > 3 %}（建议图片尺寸：{{value[3]}}）{% end %}
            <input type="hidden" id="update_{{value[0]}}" name="update_{{value[0]}}" lay-verify="{{value[2]}}" value="{% if data['info'] and value[0] in data['info'] %}{{data['info'][value[0]]}}{% end %}"/>
          </div>
      {% elif value[1] == 'select' %}
        {%set option = 'update_' + value[0] %}
        {% if option in data['common'] %}
        {%set select = data['common'][option] %}
          <select name="update_{{value[0]}}" id="update_{{value[0]}}" lay-verify="{{value[2]}}" lay-search>
            {% for v in select %}
                <option value="{{v['id']}}" {% if data['info'] and value[0] in data['info'] and data['info'][value[0]] == v['id'] %}selected{% end %}>{{v['name']}}</option>
                {% end %}
            </select>
            {% end %}
      {% end %}
      </div>
  </div>
{% end %}
{% end %}

{% block script %}
{% end %}