{% extends 'obj_form.html' %}
{% load i18n %}


{% block subtitle %}
<ol class="breadcrumb">
        <li>{% trans '公司管理' %}</li>
        <li>{% trans '渠道列表' %}</li>
</ol>
{% endblock %}

{% block js %}
    {{ block.super }}
    $('#ySelectSeries').ySelect(
      {
        placeholder: '选择终端级别',
        searchText: '搜索',
        showSearch: true,
        numDisplayed: 10,
        overflowText: '已选中 {n}项',
        isCheck:false
      }
    );
    if($("#ySelectSeries")){
		var channel_level_ids= $("#ySelectSeries").ySelectedValues(",");
		$("#id_channel_level_ids").val(channel_level_ids);
	};
{% endblock %}

{% block form_content %}
<script>

    $(document).ready(function () {

        $('.btn-save').click(function () {
		    if($("#ySelectSeries")){
				var channel_level_ids= $("#ySelectSeries").ySelectedValues(",");
				channel_level_ids=channel_level_ids.split(',');
				$("#id_channel_level_ids").val(channel_level_ids);
			};
	  
            $.SubmitForm('#obj_form form', '{{request.path}}',function (){
                $('.alert').fadeIn();
            });
        }); 
		
    })

</script>
<style>
    input[type=checkbox]{
        display: inline-block;
        width: auto;
        height: auto;
        margin-top: 10px;
    }
	.fs-wrap{
		width: 80% !important;
	}
</style>
<div class="alert alert-success" role="alert" style="display: none">提示：保存成功！</div>
<div class="form-group product_photo">
    <label class="col-sm-2 control-label ">渠道名称</label>
    <div class="col-sm-8">{{ form.name }}
    </div>
</div>

{% ifequal request.user.company_id 19318%}
  <div class="form-group">
    <label class="col-md-2 control-label">终端等级关联(非必选)</label>
    <input type="hidden" id="id_channel_level_ids" name="channel_level_ids" value="">
    <div class='col-sm-10'>
      <select id="ySelectSeries" multiple="multiple">
        {% for s in channel_level_ids %}
        {% ifequal s.2 1 %}
        <option value='{{s.0}}' selected="selected">{{s.1}}</option>
        {% else %}
        <option value='{{s.0}}'>{{s.1}}</option>
        {% endifequal %}
        {% endfor %}
      </select>

    </div>
  </div>
{% endifequal %}

<div class="form-group product_photo">
    <label class="col-sm-2 control-label ">备注</label>
    <div class="col-sm-8">{{ form.remark }}</div>
</div>
<div>
    <a class="btn btn-primary btn-save" type="button" style="float:right;">保存</a>
</div>
{% endblock %}