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


{% block subtitle %}
<ol class="breadcrumb">
        <li>{% trans '营销活动' %}</li>
        <li>{% trans '奖品激活审核' %}</li>
</ol>
{% endblock %}

{% block form_content %}
<script>

    $(document).ready(function () {

        $('.btn-permit').click(function () { 
            var status = $(this).data('status');
            var remark = $(this).data('remark');
            var text = '您确定要执行此操作吗？'
            if(status == 2){
                text = '您确定要审核通过吗？'
            }
            else if(status == 3){
                text = '您确定要驳回审核吗？'
            }
            var r = confirm(text)
            if(!r){
                return
            }
            
            $.ajax({
                url: '/sales/consumer/winner_active/',
                data:{
                    status,
                    remark,
                    id:"{{id}}",
                    uid:"{{uid}}"
                },
                method: 'POST',
                success:function(res){
                    if(res.e === ''){
                        $(".alert-success").fadeIn();
                        changeTableData(status)
                        $("#bg-modal").modal('hide');
                    }
                    else{
                        alert(res.e);
                    }
                },
                error:function(){
                    alert('网络超时！请稍后再试！')
                }
            })
        }); 

        function changeTableData(status){
            var firstLink = $(window.click_row).find('td:first a');
            $(firstLink).text(status_dict[status][0])
            $(firstLink).removeAttr('style')
            $(firstLink).attr('style', status_dict[status][1])
            if(status_dict[status][2]){
                $(firstLink).attr(status_dict[status][2])
            }
        }
    })

</script>
<style>
    .btn-permit{
        display: inline-block;
        width: auto;
    }
</style>
<div class="alert alert-success" role="alert" style="display: none">提示：保存成功！</div>
<div class="form-group">
    <label class="col-sm-2 control-label ">审核图片</label>
    <div class="col-sm-8">
        <img src="{{photo}}" alt="" style="width: 300px;"/>
	</div>
</div>
<div class="form-group">
    <label class="col-sm-2 control-label">审核状态</label>
    <div class="col-sm-8">
        <input type="button" class="btn btn-sm btn-primary btn-permit" data-status="2" data-remark="" value="通过审核"/> <br/><br/>
        <input type="button" class="btn btn-sm btn-danger btn-permit" data-status="3" data-remark="未开瓶" value="驳回（未开瓶）"/>
        <!-- <input type="button" class="btn btn-sm btn-danger btn-permit" data-status="3" data-remark="照片不清晰" value="驳回（照片不清晰）"/> -->
	</div>
</div>
{% endblock %}