{% load i18n %}


<script type="text/javascript">
    $(document).ready(function(){
        var page_length=10;

        var table=$('#tb').DataTable({
            dom: 'Bfrtip',
            autoWidth: true,
            pageLength: page_length,
            buttons: [{extend:'excelHtml5',text: '导出到Excel'}],
            language:lng,
            data:{{datas|safe}}
        });
        table.columns().every( function () {
            var that = this;
            $('input', this.footer() ).on( 'keyup change clear', function () {
                if ( that.search() !== this.value ) {
                    that.search( this.value ).draw();
                }
            });
        });

        function  sub(){ //表单提交
            let jsonData = $("#form1").serializeObject();
            $.ajax({
                type:'POST',
                dataType:'JSON',
                url:'/tracesys/set/config/attributes/{{ data.0.1 }}/',
                data:JSON.stringify(jsonData),
                contentType: "application/json; charset=utf-8",
                {#data:$('#form1').serializeArray(),#}
                {#contentType:"application/x-www-form-urlencoded",#}
                success:function(result){
                    console.log(result.errs);
                    if (result.errs == ""){alert("ok")
                    }else{alert(result.errs);}
                    },
                error : function() {
                        alert("异常！");
                    }
                });
        }

        $("#add").on('click','a',function(){ //弹出框
            event.preventDefault();
        $.ajax({
                type:'POST',
                dataType:"JSON",
                url:$(this).attr("href"),
                contentType: "application/json; charset=utf-8",
                success:function(result){
                    console.log(result.id)
                    console.log("ok",'/member/level/details/'+result.id)
                    $("#data-content").load('/member/level/save/'+result.id);//要刷新的div

                }
         })

            });

        $('#tb tbody').on('click','img',function(){
            var src=$(this).attr('src');
            var tt=$(this).closest('tr').find('img').text();
            if(tt==''){
                tt=$(this).attr('tt');
            };
            var i="<div style='text-align:center;'><img src='"+src+"' style='height:400px;'></img></div>";
            console.log(tt,i)
            $.OpenCfmDlg(tt,i);
        });

        $('.btn-qry').click(function(){
            let jsonData = $("#form").serializeArray();
            $.ajax({
                type:'POST',
                dataType:"JSON",
                url:'/sms_send/details/',
                data:JSON.stringify(jsonData),
                contentType: "application/json; charset=utf-8",
                success:function(result){
                    alert("ok")
                    console.log(result)
                }

            })
        });
    });
</script>



<ol class="breadcrumb">
        <li>{% trans '会员管理' %}</li>
        <li>{% trans '会员等级' %}</li>
</ol>


{% if add %}
    <div class="title_right">
        <div class="pull-right">
            <span class='input-group'>
                    {% if murl == '/list/edit/member/' %}
                    <a type="button" class='btn btn-obj-add l-a create-btn' href='/sms_send/details/'>
                    <span class='glyphicon glyphicon-plus' style='padding-right:15px;'></span>{% trans '发送短信' %}</a>
                    {% endif  %}
                    <a type="button" class='btn btn-obj-add l-a create-btn' href='{{murl}}'>
                    <span class='glyphicon glyphicon-plus' style='padding-right:5px;'></span>{% trans '新建' %}</a>
            </span>
        </div>
    </div>
{% endif %}



<div id="add" class="col-md-12 col-sm-12 col-xs-12" id="mem_list">
    <div class="x_panel">
        <div  class="table-responsive">
            <table id='tb'  class="table table-striped table-bordered dt-responsive nowrap" cellspacing="0" width="100%">
            <thead>
                {% for c in clmns %}
                    <th>{{c}}</th>
                {% endfor %}
            </thead>
            <tbody></tbody>
            <tfoot>
                {% for c in clmns %}
                    <th><input type="text" placeholder="{{c}}"></th>
                {% endfor %}
            </tfoot>
            </table>
        </div>
    </div>
</div>

