@{
    ViewBag.Title = "复制权限";
    Layout = "~/Views/Shared/_LayoutTable.cshtml";
}
<div style="width:100%;height:100%;background-color:white; float:left">
    <table class="table table-bordered table-striped table-hover">
        <tr>
            <td style="text-align:left">
                <input type="checkbox" style="text-align:center" checked name="cbtellimit" value="1" /> <span style="text-align:center">手机端权限</span>
            </td>
            <td style="text-align:left">
                <input type="checkbox" style="text-align:center" checked name="cbpowers" value="1" /> <span style="text-align:center">基本信息授权</span>
            </td>
            <td style="text-align:left">
                当前权限用户：<a style="color:coral">@ViewBag.LoginName</a>
            </td>
            <td style="text-align:right">
                <button id="btnSave" class="btn btn-default btn-sm" onclick="Save()"><i class="glyphicon glyphicon-saved"></i> 保 存</button>
            </td>
        </tr>
    </table>
    <table id="CopyRightsTable"></table>
</div>
<script type="text/javascript">
    $(function () {
        $('#CopyRightsTable').bootstrapTable({
            url: '../DealerEdition/GetCopyRightsList?LoginID=' + '@ViewBag.LoginID',         //请求后台的URL（*）
            method: 'post',                      //请求方式（*）
            toolbar: '',                //工具按钮用哪个容器
            striped: true,                      //是否显示行间隔色
            pagination: false,                   //是否显示分页（*）
            sortOrder: "asc",                   //排序方式
            sidePagination: "server",
            minimumCountColumns: 2,  //最少允许的列数
            //height: "636",               //行高，如果没有设置height属性，表格自动根据记录条数觉得表格高度
            uniqueId: "",            //每一行的唯一标识，一般为主键列
            clickToSelect: true,              //是否启用点击选中行
            sortable: true,                     //是否启用排序
            silentSort: true,
            cache: false,                       //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
            search: false,                       //是否显示表格搜索，此搜索是客户端搜索，不会进服务端，所以，个人感觉意义不大
            strictSearch: false,
            showColumns: false,            //是否显示所有的列
            showRefresh: false,              //是否显示刷新按钮
            showToggle: false,                     //是否显示详细视图和列表视图的切换按钮
             cardView: false,                    //是否显示详细视图
            detailView: false,                   //是否显示父子表
            columns: [
                {
                    checkbox: true
                },
                {
                    field: "LoginID", title: "登录编号"
                },
                { field: 'LoginName', title: "登录人员" }
            ]
        });
    });
    function Save() {//保存
        var selectRows = $('#CopyRightsTable').bootstrapTable('getSelections');
        var check = $("input[name='cbtellimit']:checked").val();
        var check2 = $("input[name='cbpowers']:checked").val();
        var ids = "";
        for (var i = 0; i < selectRows.length; i++) {
            if (i == selectRows.length - 1)
            { ids += selectRows[i].LoginID; }
            else
            { ids += selectRows[i].LoginID + ","; }
        }
        if (selectRows.length <= 0) {
            layer.msg("请选择需要复制权限的对象", { icon: 7, time: 2000 }); return false;
        }
        if (check == undefined && check2 == undefined) {
            layer.msg("请选择需要复制权限的类型", { icon: 7, time: 2000 }); return false;
        }
        else {
            $.ajax({
                url: "../DealerEdition/SaveDealerCopyRights",
                dataType: "text",
                data: { mobile: check, basic: check2, sel: ids, LoginID: '@ViewBag.LoginID' },
                type: "post",
                success: function (data) {//删除成功后刷新table
                    if (data == "复制权限完成！") {
                        parent.$('#businessTable').bootstrapTable('refresh');
                        parent.layer.msg(data, { time: 2000 })
                        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                        parent.layer.close(index); //再执行关闭
                    } else {
                        layer.msg(data, { time: 2000 });
                    }
                },
                error: function (data) {
                    layer.msg(data, { icon: 5, time: 2000 });
                }
            })
        }
    }
</script>