<script type="text/javascript">    
    $(document).ready(function(){   
        var dlgId='#custom-url-modal';
        $(dlgId+' .btn-approve,'+dlgId+' .btn-reject,'+dlgId+' .btn-scrap')
                .unbind('click').bind('click',function(){  
            var btn_ids=$(this).attr('class').split(' ');
            var action='';
            var msg='';
            if(btn_ids.indexOf("btn-scrap")>-1){
                action='scrap';
                msg='申请已作废';
            }else{
                if(btn_ids.indexOf("btn-reject")>-1){
                    action='reject';
                    msg="申请已驳回";
                }else{
                    action='approve';
                    msg="申请已通过申核";
                }
            };
            var app_id=$(dlgId+' .app_id').val();
            $(dlgId).modal('hide');
            $.ajax({
                type:'POST',
                url:'{{request.path}}',
                dataType:'json',
                data:{"id":app_id,"action":action},
                success: function(data) {  
                    if(data.e!=''){
                        toastr.error(data.e); 
                    }else{                        
                        toastr.success(msg);
                        $('#tb_application tbody a[app_id="'+app_id+'"]').closest('tr').find('td:nth-child(10)').text(data.status);                        
                    };
                },
                beforeSend: function (xhr, settings) {                    
                        xhr.setRequestHeader("X-CSRFToken", '{{csrf_token}}');                    
                },
                error: function(XMLHttpRequest, textStatus, errorThrown) {
                    alert('连接服务器失败');
                    return;
                }  
            });
        });
    });
</script>

<div class="row">
    <input class='app_id' type='hidden' value='{{id}}' />
    {% for img in images %}
        <div class="col-xs-6">  
            <p class="lead" style='font-size:16px;margin-top:10px;margin-bottom:0px;'>
                <span>上传:{{img.user_name}}</span>
                <span style='margin-left:50px;'>上传时间:{{img.time}}</span>
            </p>
            <img src="{{img.image}}"  style="width:100%;">
        </div>
    {% endfor %}
</div>
