<div class="modal-header"> 
    <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
    <h4 class="modal-title">权限配置</h4>
</div>
<form id="permission_form" class="form-horizontal">
    <div class="modal-body">

        <input type="hidden" name="member_id" value="<?= $member_id ?>">
        <select name="urls[]" class="form-control" multiple="multiple" style="height:300px;">
            <?php foreach ($permissionMap as $key => $value):?>
                <option value="<?= $key ?>" <?php if (in_array($key, $urls)): ?>selected="selected"<?php endif; ?>><?= $value ?></option>
            <?php endforeach;?>
        </select>
 

    </div>
    <div class="modal-footer">
        <button type="button" class="btn btn-white" data-dismiss="modal">取消</button>
        <button id="permission_submit" type="button" class="btn btn-primary">提交</button>
    </div>
</form>
<script type="text/javascript">

$("#permission_submit").on("click",function(){
    $.ajax({
        type: "POST",
        url: "/admin/admin/update-permission",
        data: $('#permission_form').serialize(),
        dataType: "json",
        beforeSend: function() {},
        success: function(data) {
            if(data.code == 1){
                $("#modal").modal("hide");
                table.ajax.reload();
            }else{
                toastr.error(data.message, "提示");
            }
        },
        complete: function(XMLHttpRequest, textStatus) {},
        error: function() {}
    });
});

</script>
