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


    {% block js %}
        {{ block.super }}

    $('#data-content div.award_photo br').remove();
    $('#photo-clear_id,#id_photo').removeClass('form-control');



        $('.btn-save').click(function(){
            $.SubmitForm('#obj_form form','{{request.path}}');
        });
        {% if form.instance %}
            $('#co').val('{{form.instance.company.id}}');
        {% endif %}

        $('#co').change(function(){
            $('#id_company').val($('#co').val());
        });

        $("#id_awardcat").on('change',function (){
            console.log($(this).val());
            let id = $(this).val();
            catChoose(id);
        })
        var select_id = $("#id_awardcat option:selected").val();
        catChoose(select_id);
        function catChoose(id){
            if (id ==='1' || id === '7'){
                $("#hexiao_choose").show();
            }
            else{
                $("#hexiao_choose").hide();
                $("#id_is_need_hexiao").prop("checked",false)
            }
        }

        $('#obj_form .award_photo a').click(function(event){      
        event.preventDefault();
        var src=$(this).attr('href');
        var i="<div style='text-align:center;'><img src='"+src+"' style='height:400px;'></img></div>";
        $.OpenCfmDlg($('#id_name').val(),i);                   
    });
    {% endblock %}


    {% block subtitle-1 %}
        {% trans "营销活动" %}
    {% endblock %}
    {% block subtitle-2 %}
        {% trans "奖品设置" %}
    {% endblock %}

    <span style="margin-left:10px; color:green; ">
        {% block subtitle-3 %}
            {% if form.instance.id %}
                {% trans "修改" %}
            {% else %}
                {% trans "新建" %}
            {% endif %}
        {% endblock %}

    </span>



{% block form_content %}
    {{ block.super }}    
    <div class="form-group ">
        <label class="col-sm-2 control-label ">{% get_verbose_field_name form.instance 'company' %} </label>
        <div class="col-sm-10">
            <select id='co'>
                <option value=''>-----------------------------</option>
                {% for c in companys %}
                    <option value='{{c.0}}'>{{c.1}}</option>
                {% endfor %}
            </select>
        </div>
    </div>
    <div class="form-group ">
        <label class="col-sm-2 control-label ">{% get_verbose_field_name form.instance 'name' %} </label>
        <div class="col-sm-10">{{ form.name }}</div>
    </div>
    <div class="form-group ">
        <label class="col-sm-2 control-label ">{% get_verbose_field_name form.instance 'awardcat' %} </label>
        <div class="col-sm-10">{{ form.awardcat }}</div>
    </div>
    <div class="form-group award_photo">
        <label class="col-sm-2 control-label ">{% get_verbose_field_name form.instance 'photo' %} </label>
        <div class="col-sm-10">{{ form.photo }}</div>
    </div>
    <div class="form-group ">
        <label class="col-sm-2 control-label ">{% get_verbose_field_name form.instance 'points' %} </label>
        <div class="col-sm-10">{{ form.points }}</div>
    </div>
    <div class="form-group ">
        <label class="col-sm-2 control-label ">{% get_verbose_field_name  form.instance 'amount' %} </label>
        <div class="col-sm-10">{{ form.amount }}</div>
    </div>  
    <div class="form-group">
        <label class="col-sm-2 control-label ">{% get_verbose_field_name  form.instance 'is_usein_banquet' %} </label>
        <div class="col-sm-1">{{ form.is_usein_banquet }}</div>
    </div>
	<div id="hexiao_choose" style="display: none">
		<div class="form-group">
			<label class="col-sm-2 control-label ">{% get_verbose_field_name  form.instance 'is_need_hexiao' %} </label>
			<div class="col-sm-1">{{ form.is_need_hexiao }}</div>
		</div>
		<div class="form-group">
			<label class="col-sm-2 control-label ">{% get_verbose_field_name  form.instance 'hexiao_level_id' %} </label>
			<div class="col-sm-1">{{ form.hexiao_level_id }}</div>
		</div>
	</div>
    <div class="form-group ">
        <label class="col-sm-2 control-label ">{% get_verbose_field_name form.instance 'remark' %} </label>
        <div class="col-sm-10">{{ form.remark }}</div>
    </div>

    <div>
        <a class="btn btn-primary btn-save" type="button" style="float:right;">{% trans '保存' %}</a>
    </div>
{% endblock %}
