@{
    ViewBag.Title = "信息授权";
    Layout = "~/Views/Shared/_LayoutTable.cshtml";
}
<body>
    <div class="container-fluid">
        <div class="row-fluid">
            <div class="col-md-12"style="margin-top:5px">
                <ul class="nav nav-tabs" role="tablist" style="margin-bottom:10px;margin-left:15px">
                    <li role="presentation" class="active"><a href="#CommoditiesRights" onclick="CommoditiesLoad()" role="tab" data-toggle="tab"><h5>商品授权<i class="glyphicon glyphicon-chevron-right"></i></h5></a></li>
                    <li role="presentation"><a href="#CompaniesRights" onclick="CompaniesLoad()" role="tab" data-toggle="tab"><h5>单位授权<i class="glyphicon glyphicon-chevron-right"></i></h5></a></li>
                    <li role="presentation"><a href="#WarehousesRights" onclick="WarehousesLoad()" role="tab" data-toggle="tab"><h5>仓库授权<i class="glyphicon glyphicon-chevron-right"></i></h5></a></li>
                    <li role="presentation"><a href="#BankRights" role="tab" onclick="BankLoad()" data-toggle="tab"><h5>现金银行授权<i class="glyphicon glyphicon-chevron-right"></i></h5></a></li>
                    @{
                        if (ViewBag.isClothing == 1 && !ViewBag.IsFzLimit)
                        {
                            <li role="presentation"><a href="#StaffMembersRights" onclick="StaffMembersLoad()" role="tab" data-toggle="tab"><h5>职员授权<i class="glyphicon glyphicon-chevron-right"></i></h5></a></li>
                        }
                    }
                    @{
                        if (ViewBag.isdistribution == 1)
                        {
                            <li role="presentation"><a href="#BranchRights" onclick="BranchLoad()" role="tab" data-toggle="tab"><h5>分支机构授权</h5></a></li>
                        }
                    }
                </ul>
                <div class="tab-content">
                    <div role="tabpanel" class="tab-pane active" id="CommoditiesRights">
                        <div class="col-md-12">
                            <table  id="COMM" class="table table-bordered table-striped table-hover">
                                <tr>
                                    <td style="text-align:left;width:180px">
                                        快速设置商品组：
                                    </td>
                                    <td>
                                        @{
                                            if (ViewBag.Fast != null && ViewBag.Fast.Rows.Count > 0)
                                            {
                                                for (int i = 0; i < ViewBag.Fast.Rows.Count; i++)
                                                {
                                                    <button id="btnFast" style="margin:2px 3px" class="btn btn-default btn-sm" onclick="FastSet('@ViewBag.Fast.Rows[i]["Id"]')"><i class="glyphicon glyphicon-flash"></i> @ViewBag.Fast.Rows[i]["PtypeName"]</button>
                                                }
                                            }
                                        }
                                    </td>
                                </tr>
                            </table>
                        </div>
                        <div class="col-md-12">
                            <button id="btnCReturn" class="btn btn-default btn-sm" onclick="Creturn()"><i class="glyphicon glyphicon-backward"></i> &nbsp;返回上一层</button>
                            <table id="CommoditiesRightsTable"></table>
                        </div>
                    </div>

                    <div role="tabpanel" class="tab-pane" id="CompaniesRights">
                        <div class="col-md-12">
                            <button id="btnCpReturn" class="btn btn-default btn-sm" onclick="Cpreturn()"><i class="glyphicon glyphicon-backward"></i> &nbsp;返回上一层</button>
                            <table id="CompaniesRightsTable"></table>
                        </div>
                    </div>

                    <div role="tabpanel" class="tab-pane" id="WarehousesRights">
                        <div class="col-md-12">
                            <button id="btnWhReturn" class="btn btn-default btn-sm" onclick="Whreturn()"><i class="glyphicon glyphicon-backward"></i> &nbsp;返回上一层</button>
                            <table id="WarehousesRightsTable"></table>
                        </div>
                    </div>

                    <div role="tabpanel" class="tab-pane" id="BankRights">
                        <div class="col-md-12">
                            <button id="btnBkReturn" class="btn btn-default btn-sm" onclick="Breturn()"><i class="glyphicon glyphicon-backward"></i> &nbsp;返回上一层</button>
                            <table id="BankRightsTable"></table>
                        </div>
                    </div>
                    @{
                        if (ViewBag.isClothing == 1)
                        {
                            <div role="tabpanel" class="tab-pane" id="StaffMembersRights">
                                <div class="col-md-12">
                                    <button id="btnSmReturn" class="btn btn-default btn-sm" onclick="Smreturn()"><i class="glyphicon glyphicon-backward"></i> &nbsp;返回上一层</button>
                                    <table id="StaffMembersRightsTable"></table>
                                </div>
                            </div>
                        }
                    }

                    @{
                        if (ViewBag.isdistribution == 1)
                        {
                            <div role="tabpanel" class="tab-pane" id="BranchRights">
                                <div class="col-md-12">
                                    <button id="btnBhReturn" class="btn btn-default btn-sm" onclick="Brreturn()"><i class="glyphicon glyphicon-backward"></i> &nbsp;返回上一层</button>
                                    <table id="BranchRightsTable"></table>
                                </div>
                            </div>
                        }
                    }

                </div>
            </div>
        </div>
    </div>

    <script type="text/javascript">
    $(document).ready(function () {
        CommoditiesLoad();
    })
    function CGiveRights(pcode, zt, userid) {//保存商品授权
        $.ajax({
            url: "../WLTManage/UpdateWLTMassageRights",
            dataType: "text",
            data: { operation: "commodity", pcode: pcode, zt: zt, userid: userid },
            type: "post",
            success: function (data) {//删除成功后刷新table
                if (data == "操作成功！") {
                    layer.msg(data, { time: 2000 });
                    $('#CommoditiesRightsTable').bootstrapTable("refresh");
                } else {
                    layer.msg(data, { time: 2000 });
                }
            },
            error: function (data) {
                layer.msg(data, { time: 2000 });
            },
        })
    }
    function CpGiveRights(pcode, zt, userid) {//保存单位授权
        $.ajax({
            url: "../WLTManage/UpdateWLTMassageRights",
            dataType: "text",
            data: { operation: "Companies", pcode: pcode, zt: zt, userid: userid },
            type: "post",
            success: function (data) {//删除成功后刷新table
                if (data == "操作成功！") {
                    layer.msg(data, { time: 2000 });
                    $('#CompaniesRightsTable').bootstrapTable("refresh");
                } else {
                    layer.msg(data, { time: 2000 });
                }
            },
            error: function (data) {
                layer.msg(data, { time: 2000 });
            },
        })
    }
    function WhGiveRights(pcode, zt, userid) {//保存仓库授权
        $.ajax({
            url: "../WLTManage/UpdateWLTMassageRights",
            dataType: "text",
            data: { operation: "Warehouses", pcode: pcode, zt: zt, userid: userid },
            type: "post",
            success: function (data) {//删除成功后刷新table
                if (data == "操作成功！") {
                    layer.msg(data, { time: 2000 });
                    $('#WarehousesRightsTable').bootstrapTable("refresh");
                } else {
                    layer.msg(data, { time: 2000 });
                }
            },
            error: function (data) {
                layer.msg(data, {  time: 2000 });
            },
        })
    }
    function BGiveRights(pcode, zt, userid) {//保存银行授权
        $.ajax({
            url: "../WLTManage/UpdateWLTMassageRights",
            dataType: "text",
            data: { operation: "bank", pcode: pcode, zt: zt, userid: userid },
            type: "post",
            success: function (data) {//删除成功后刷新table
                if (data == "操作成功！") {
                    layer.msg(data, { time: 2000 });
                    $('#BankRightsTable').bootstrapTable("refresh");
                } else {
                    layer.msg(data, { time: 2000 });
                }
            },
            error: function (data) {
                layer.msg(data, { time: 2000 });
            },
        })
    }
    function SmGiveRights(pcode, zt, userid) {//保存职员授权
        $.ajax({
            url: "../WLTManage/UpdateWLTMassageRights",
            dataType: "text",
            data: { operation: "StaffMembers", pcode: pcode, zt: zt, userid: userid },
            type: "post",
            success: function (data) {//删除成功后刷新table
                if (data == "操作成功！") {
                    layer.msg(data, { time: 2000 });
                    $('#StaffMembersRightsTable').bootstrapTable("refresh");
                } else {
                    layer.msg(data, { time: 2000 });
                }
            },
            error: function (data) {
                layer.msg(data, {  time: 2000 });
            },
        })
    }
    function BrGiveRights(pcode, zt, userid) {//保存分支机构授权
        $.ajax({
            url: "../WLTManage/UpdateWLTMassageRights",
            dataType: "text",
            data: { operation: "branch", pcode: pcode, zt: zt, userid: userid },
            type: "post",
            success: function (data) {//删除成功后刷新table
                if (data == "操作成功！") {
                    layer.msg(data, { time: 2000 });
                    $('#BranchRightsTable').bootstrapTable("refresh");
                } else {
                    layer.msg(data, { time: 2000 });
                }
            },
            error: function (data) {
                layer.msg(data, { time: 2000 });
            },
        })
    }
    function Creturn() {//商品返回上层
        var data = $("#CommoditiesRightsTable").bootstrapTable("getData");
        var parid = "";
        if (data.length>0) {
            parid = data[0].parid;
        }
        if (parid != "root" &&  parid != "0") {
            if (parid=="") {
                parid = "root";
            }
            $('#CommoditiesRightsTable').bootstrapTable('refresh', {
                url: "../WLTManage/WLTMessageReturn?operation=commodity&loginid=" + '@ViewBag.LoginID' + "&parid=" + parid
            })
        } else {
            layer.msg("已到最顶层！");
        }
    }
    function Cpreturn() {//单位返回上层
        var data = $("#CompaniesRightsTable").bootstrapTable("getData");
        var parid = "";
        if (data.length>0) {
            parid = data[0].parid;
        }
        if (parid != "0" && parid != "root") {
            if (parid == "") {
                parid = "root";
            }
            $('#CompaniesRightsTable').bootstrapTable('refresh', {
                url: "../WLTManage/WLTMessageReturn?operation=Companies&loginid=" + '@ViewBag.LoginID' + "&parid=" + parid
            })
        } else {
            layer.msg("已到最顶层！");
        }
    }
    function Whreturn() {//仓库返回上层
        var data = $("#WarehousesRightsTable").bootstrapTable("getData");
        var parid = "";
        if (data.length > 0) {
            parid = data[0].parid;
        }
        if (parid != "00000" && parid != "root") {
            if (parid == "") {
                parid = "root";
            }
            $('#WarehousesRightsTable').bootstrapTable('refresh', {
                url: "../WLTManage/WLTMessageReturn?operation=Warehouses&loginid=" + '@ViewBag.LoginID' + "&parid=" + parid
            })
        } else {
            layer.msg("已到最顶层！");
        }
    }
    function Breturn() {//银行返回上层
        var data = $("#BankRightsTable").bootstrapTable("getData")
        var parid = "";
        if (data.length > 0) {
            parid = data[0].parid;
        }
        if (parid != "0" && parid != "root") {
            if (parid == "") {
                parid = "root";
            }
            $('#BankRightsTable').bootstrapTable('refresh', {
                url: "../WLTManage/WLTMessageReturn?operation=bank&loginid=" + '@ViewBag.LoginID' + "&parid=" + parid
            })
        } else {
            layer.msg("已到最顶层！");
        }
    }
    function Smreturn() {//职员返回上层
        var data = $("#StaffMembersRightsTable").bootstrapTable("getData");
        var parid = "";
        if (data.length > 0) {
            parid = data[0].parid;
        }
        if (parid != "00000" && parid != "root") {
            if (parid == "") {
                parid = "00000";
            }
            $('#StaffMembersRightsTable').bootstrapTable('refresh', {
                url: "../WLTManage/WLTMessageReturn?operation=StaffMembers&loginid=" + '@ViewBag.LoginID' + "&parid=" + parid
            })
        } else {
            layer.msg("已到最顶层！");
        }
    }
    function Brreturn() {//分支机构返回上层
        var data = $("#BranchRightsTable").bootstrapTable("getData")
        var parid = "";
        if (data.length > 0) {
            parid = data[0].parid;
        }
        if (parid != "00000" && parid != "root") {
            if (parid == "") {
                parid = "root";
            }
            $('#BranchRightsTable').bootstrapTable('refresh', {
                url: "../WLTManage/WLTMessageReturn?operation=branch&loginid=" + '@ViewBag.LoginID' + "&parid=" + parid
            })
        } else {
            layer.msg("已到最顶层！");
        }
    }

    function CommoditiesLoad() {
        $('#CommoditiesRightsTable').bootstrapTable({//商品列表绑定
            url: '../WLTManage/GetWLTCommoditiesSelector?LoginID=' + '@ViewBag.LoginID',         //请求后台的URL（*）
            method: 'post',                      //请求方式（*）
            toolbar: '#btnCReturn',                //工具按钮用哪个容器
            striped: true,                      //是否显示行间隔色
            pagination: true,                   //是否显示分页（*）
            sortOrder: "asc",
            sidePagination: "server",           //分页方式：client客户端分页，server服务端分页（*）
            pageNumber: 1,                       //初始化加载第一页，默认第一页
            pageSize: 15,                       //每页的记录行数（*）
            pageList: [15, 30, 50],        //可供选择的每页的行数（*）
            minimumCountColumns: 2,  //最少允许的列数
            //height: "100%",               //行高，如果没有设置height属性，表格自动根据记录条数觉得表格高度
            uniqueId: "nub",            //每一行的唯一标识，一般为主键列
            clickToSelect: true,              //是否启用点击选中行
            sortable: true,                     //是否启用排序
            silentSort: true,
            cache: false,                       //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
            search: false,                       //是否显示表格搜索，此搜索是客户端搜索，不会进服务端，所以，个人感觉意义不大
            strictSearch: false,
            paginationFirstText: '首页',
            paginationLastText: '末页',
            paginationPreText: '上一页',
            paginationNextText: '下一页',
            showColumns: false,            //是否显示所有的列
            showRefresh: false,              //是否显示刷新按钮
            showToggle: false,                     //是否显示详细视图和列表视图的切换按钮
             cardView: false,                    //是否显示详细视图
            detailView: false,                   //是否显示父子表
            queryParams: function (params) {
                return {
                    pagesize: params.limit,//页面大小
                    page: params.offset, //页码
                };
            },//传递参数（*）
            columns: [
                { field: 'Pusercode', title: '编号' },
                {
                    field: 'Pfullname', title: '名称', formatter: function (value, row, index) {
                        return "<span style='color:blue;cursor:Pointer;'>" + row.Pfullname + "</span>";
                    }
                },
                {
                    field: 'State', title: '状态', width: '15%', align: 'center', formatter: function (value, row, index) {
                        if (row.PZT == "2") {
                            strHtml = '<a  style="cursor:pointer" onclick="CGiveRights(\'' + row.Ptypeid + '\',\'' + row.PZT + '\',\'' + '@ViewBag.LoginID' + '\')">★</a>';
                            return strHtml;
                        } else if (row.PZT == "1") {
                            strHtml = '<a style="cursor:pointer" onclick="CGiveRights(\'' + row.Ptypeid + '\',\'' + row.PZT + '\',\'' + '@ViewBag.LoginID' + '\')">☆</a>';
                            return strHtml;
                        } else {
                            strHtml = '<a  style="cursor:pointer" onclick="CGiveRights(\'' + row.Ptypeid + '\',\'' + row.PZT + '\',\'' + '@ViewBag.LoginID' + '\')">未授权</a>';
                            return strHtml;
                        }
                    }
                },
                    { field: "typeId", titie: "typeId" },
                    { field: "Ptypeid", titie: "Ptypeid" },
                    { field: "parid", titie: "parid" },
                    { field: "Psonnum", titie: "Psonnum" },
                    { field: "PZT", titie: "PZT" }
            ],
            onClickCell: function (field, value, row) {
                if (field == 'Pfullname') {
                    if (row["Psonnum"] == "0") {
                        layer.msg("已到最底层", { time: 2000 });
                        return;
                    }
                    var parid = row.Ptypeid;
                    $('#CommoditiesRightsTable').bootstrapTable('refresh', {
                        url: '../WLTManage/GetWLTCommoditiesSelector?LoginID=' + '@ViewBag.LoginID' + '&parid=' + parid
                    })
                }
            }
        });
        $('#CommoditiesRightsTable').bootstrapTable('hideColumn', 'typeId');
        $('#CommoditiesRightsTable').bootstrapTable('hideColumn', 'parid');
        $('#CommoditiesRightsTable').bootstrapTable('hideColumn', 'Psonnum');
        $('#CommoditiesRightsTable').bootstrapTable('hideColumn', 'PZT');
        $('#CommoditiesRightsTable').bootstrapTable('hideColumn', 'Ptypeid')
    }

    function CompaniesLoad() {
        $('#CompaniesRightsTable').bootstrapTable({//单位列表绑定
            url: '../WLTManage/GetWLTCompaniesSelector?LoginID=' + '@ViewBag.LoginID',         //请求后台的URL（*）
            method: 'post',                      //请求方式（*）
            toolbar: '#btnCpReturn',                //工具按钮用哪个容器
            striped: true,                      //是否显示行间隔色
            pagination: true,                   //是否显示分页（*）
            sortOrder: "asc",
            sidePagination: "server",           //分页方式：client客户端分页，server服务端分页（*）
            pageNumber: 1,                       //初始化加载第一页，默认第一页
            pageSize: 15,                       //每页的记录行数（*）
            pageList: [15, 30, 50],        //可供选择的每页的行数（*）
            minimumCountColumns: 2,  //最少允许的列数
            //height: "100%",               //行高，如果没有设置height属性，表格自动根据记录条数觉得表格高度
            uniqueId: "nub",            //每一行的唯一标识，一般为主键列
            clickToSelect: true,              //是否启用点击选中行
            sortable: true,                     //是否启用排序
            silentSort: true,
            cache: false,                       //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
            search: false,                       //是否显示表格搜索，此搜索是客户端搜索，不会进服务端，所以，个人感觉意义不大
            strictSearch: false,
            paginationFirstText: '首页',
            paginationLastText: '末页',
            paginationPreText: '上一页',
            paginationNextText: '下一页',
            showColumns: false,            //是否显示所有的列
            showRefresh: false,              //是否显示刷新按钮
            showToggle: false,                     //是否显示详细视图和列表视图的切换按钮
             cardView: false,                    //是否显示详细视图
            detailView: false,                   //是否显示父子表
            queryParams: function (params) {
                return {
                    pagesize: params.limit,//页面大小
                    page: params.offset, //页码
                };
            },//传递参数（*）
            columns: [
                { field: 'Pusercode', title: '编号' },
                {
                    field: 'Pfullname', title: '名称', formatter: function (value, row, index) {
                        return "<span style='color:blue;cursor:Pointer;'>" + row.Pfullname + "</span>";
                    }
                },
                {
                    field: 'State', title: '状态', width: '15%', align: 'center', formatter: function (value, row, index) {
                        if (row.PZT == "2") {
                            strHtml = '<a  style="cursor:pointer" onclick="CpGiveRights(\'' + row.Ptypeid + '\',\'' + row.PZT + '\',\'' + '@ViewBag.LoginID' + '\')">★</a>';
                            return strHtml;
                        } else if (row.PZT == "1") {
                            strHtml = '<a style="cursor:pointer" onclick="CpGiveRights(\'' + row.Ptypeid + '\',\'' + row.PZT + '\',\'' + '@ViewBag.LoginID' + '\')">☆</a>';
                            return strHtml;
                        } else {
                            strHtml = '<a  style="cursor:pointer" onclick="CpGiveRights(\'' + row.Ptypeid + '\',\'' + row.PZT + '\',\'' + '@ViewBag.LoginID' + '\')">未授权</a>';
                            return strHtml;
                        }
                    }
                },
                    { field: "typeId", titie: "typeId" },
                    { field: "Ptypeid", titie: "Ptypeid" },
                    { field: "parid", titie: "parid" },
                    { field: "Psonnum", titie: "Psonnum" },
                    { field: "PZT", titie: "PZT" }
            ],
            onClickCell: function (field, value, row) {
                if (field == 'Pfullname') {
                    if (row["Psonnum"] == "0") {
                        layer.msg("已到最底层", { time: 2000 });
                        return;
                    }
                    var parid = row.Ptypeid;
                    $('#CompaniesRightsTable').bootstrapTable('refresh', {
                        url: '../WLTManage/GetWLTCompaniesSelector?LoginID=' + '@ViewBag.LoginID' + '&parid=' + parid
                    })
                }
            }
        });
        $('#CompaniesRightsTable').bootstrapTable('hideColumn', 'typeId');
        $('#CompaniesRightsTable').bootstrapTable('hideColumn', 'parid');
        $('#CompaniesRightsTable').bootstrapTable('hideColumn', 'Psonnum');
        $('#CompaniesRightsTable').bootstrapTable('hideColumn', 'PZT');
        $('#CompaniesRightsTable').bootstrapTable('hideColumn', 'Ptypeid');
    }

    function WarehousesLoad() {
        $('#WarehousesRightsTable').bootstrapTable({//仓库列表绑定
            url: '../WLTManage/GetWLTWarehousesSelector?LoginID=' + '@ViewBag.LoginID',         //请求后台的URL（*）
            method: 'post',                      //请求方式（*）
            toolbar: '#btnWhReturn',                //工具按钮用哪个容器
            striped: true,                      //是否显示行间隔色
            pagination: true,                   //是否显示分页（*）
            sortOrder: "asc",
            sidePagination: "server",           //分页方式：client客户端分页，server服务端分页（*）
            pageNumber: 1,                       //初始化加载第一页，默认第一页
            pageSize: 15,                       //每页的记录行数（*）
            pageList: [15, 30, 50],        //可供选择的每页的行数（*）
            minimumCountColumns: 2,  //最少允许的列数
            //height: "100%",               //行高，如果没有设置height属性，表格自动根据记录条数觉得表格高度
            uniqueId: "nub",            //每一行的唯一标识，一般为主键列
            clickToSelect: true,              //是否启用点击选中行
            sortable: true,                     //是否启用排序
            silentSort: true,
            cache: false,                       //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
            search: false,                       //是否显示表格搜索，此搜索是客户端搜索，不会进服务端，所以，个人感觉意义不大
            strictSearch: false,
            paginationFirstText: '首页',
            paginationLastText: '末页',
            paginationPreText: '上一页',
            paginationNextText: '下一页',
            showColumns: false,            //是否显示所有的列
            showRefresh: false,              //是否显示刷新按钮
            showToggle: false,                     //是否显示详细视图和列表视图的切换按钮
             cardView: false,                    //是否显示详细视图
            detailView: false,                   //是否显示父子表
            queryParams: function (params) {
                return {
                    pagesize: params.limit,//页面大小
                    page: params.offset, //页码
                };
            },//传递参数（*）
            columns: [
                { field: 'Pusercode', title: '编号' },
                {
                    field: 'Pfullname', title: '名称', formatter: function (value, row, index) {
                        return "<span style='color:blue;cursor:Pointer;'>" + row.Pfullname + "</span>";
                    }
                },
                {
                    field: 'State', title: '状态', width: '15%', align: 'center', formatter: function (value, row, index) {
                        if (row.PZT == "2") {
                            strHtml = '<a  style="cursor:pointer" onclick="WhGiveRights(\'' + row.Ptypeid + '\',\'' + row.PZT + '\',\'' + '@ViewBag.LoginID' + '\')">★</a>';
                            return strHtml;
                        } else if (row.PZT == "1") {
                            strHtml = '<a style="cursor:pointer" onclick="WhGiveRights(\'' + row.Ptypeid + '\',\'' + row.PZT + '\',\'' + '@ViewBag.LoginID' + '\')">☆</a>';
                            return strHtml;
                        } else {
                            strHtml = '<a  style="cursor:pointer" onclick="WhGiveRights(\'' + row.Ptypeid + '\',\'' + row.PZT + '\',\'' + '@ViewBag.LoginID' + '\')">未授权</a>';
                            return strHtml;
                        }
                    }
                },
                    { field: "typeId", titie: "typeId" },
                    { field: "Ptypeid", titie: "Ptypeid" },
                    { field: "parid", titie: "parid" },
                    { field: "PSonnum", titie: "PSonnum" },
                    { field: "PZT", titie: "PZT" }
            ],
            onClickCell: function (field, value, row) {
                if (field == 'Pfullname') {
                    if (row["PSonnum"] == "0") {
                        layer.msg("已到最底层", {  time: 2000 });
                        return;
                    }
                    var parid = row.Ptypeid;
                    $('#WarehousesRightsTable').bootstrapTable('refresh', {
                        url: '../WLTManage/GetWLTWarehousesSelector?LoginID=' + '@ViewBag.LoginID' + '&parid=' + parid
                    })
                }
            }
        });
        $('#WarehousesRightsTable').bootstrapTable('hideColumn', 'typeId');
        $('#WarehousesRightsTable').bootstrapTable('hideColumn', 'parid');
        $('#WarehousesRightsTable').bootstrapTable('hideColumn', 'PSonnum');
        $('#WarehousesRightsTable').bootstrapTable('hideColumn', 'PZT');
        $('#WarehousesRightsTable').bootstrapTable('hideColumn', 'Ptypeid')
    }

    function BankLoad() {
        $('#BankRightsTable').bootstrapTable({//现金银行列表
            url: '../WLTManage/GetWLTBankSelector?LoginID=' + '@ViewBag.LoginID',         //请求后台的URL（*）
            method: 'post',                      //请求方式（*）
            toolbar: '#btnBkReturn',                //工具按钮用哪个容器
            striped: true,                      //是否显示行间隔色
            pagination: true,                   //是否显示分页（*）
            sortOrder: "asc",
            sidePagination: "server",           //分页方式：client客户端分页，server服务端分页（*）
            pageNumber: 1,                       //初始化加载第一页，默认第一页
            pageSize: 15,                       //每页的记录行数（*）
            pageList: [15, 30, 50],        //可供选择的每页的行数（*）
            minimumCountColumns: 2,  //最少允许的列数
            //height: "100%",               //行高，如果没有设置height属性，表格自动根据记录条数觉得表格高度
            uniqueId: "nub",            //每一行的唯一标识，一般为主键列
            clickToSelect: true,              //是否启用点击选中行
            sortable: true,                     //是否启用排序
            silentSort: true,
            cache: false,                       //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
            search: false,                       //是否显示表格搜索，此搜索是客户端搜索，不会进服务端，所以，个人感觉意义不大
            strictSearch: false,
            paginationFirstText: '首页',
            paginationLastText: '末页',
            paginationPreText: '上一页',
            paginationNextText: '下一页',
            showColumns: false,            //是否显示所有的列
            showRefresh: false,              //是否显示刷新按钮
            showToggle: false,                     //是否显示详细视图和列表视图的切换按钮
             cardView: false,                    //是否显示详细视图
            detailView: false,                   //是否显示父子表
            queryParams: function (params) {
                return {
                    pagesize: params.limit,//页面大小
                    page: params.offset, //页码
                };
            },//传递参数（*）
            columns: [
                { field: 'Ausercode', title: '编号' },
                {
                    field: 'AfullName', title: '名称', formatter: function (value, row, index) {
                        return "<span style='color:blue;cursor:Pointer;'>" + row.AfullName + "</span>";
                    }
                },
                {
                    field: 'State', title: '状态', width: '15%', align: 'center', formatter: function (value, row, index) {
                        if (row.SZT == "2") {
                            strHtml = '<a  style="cursor:pointer" onclick="BGiveRights(\'' + row.AtypeId + '\',\'' + row.SZT + '\',\'' + '@ViewBag.LoginID' + '\')">★</a>';
                            return strHtml;
                        } else if (row.SZT == "1") {
                            strHtml = '<a style="cursor:pointer" onclick="BGiveRights(\'' + row.AtypeId + '\',\'' + row.SZT + '\',\'' + '@ViewBag.LoginID' + '\')">☆</a>';
                            return strHtml;
                        } else {
                            strHtml = '<a  style="cursor:pointer" onclick="BGiveRights(\'' + row.AtypeId + '\',\'' + row.SZT + '\',\'' + '@ViewBag.LoginID' + '\')">未授权</a>';
                            return strHtml;
                        }
                    }
                },
                    { field: "AtypeId", titie: "AtypeId" },
                    { field: "parid", titie: "parid" },
                    { field: "ASonnum", titie: "PSonnum" },
                    { field: "SZT", titie: "SZT" }
            ],
            onClickCell: function (field, value, row) {
                if (field == 'AfullName') {
                    if (row["ASonnum"] == "0") {
                        layer.msg("已到最底层", { time: 2000 });
                        return;
                    }
                    var typeid = row.AtypeId;
                    var parid = row.parid;

                    $('#BankRightsTable').bootstrapTable('refresh', {
                        url: '../WLTManage/GetWLTBankSelector?LoginID=' + '@ViewBag.LoginID' + '&parid=' + parid + '&typeid=' + typeid
                    })
                }
            }
        });
        $('#BankRightsTable').bootstrapTable('hideColumn', 'parid');
        $('#BankRightsTable').bootstrapTable('hideColumn', 'ASonnum');
        $('#BankRightsTable').bootstrapTable('hideColumn', 'SZT');
        $('#BankRightsTable').bootstrapTable('hideColumn', 'AtypeId')
    }

    function StaffMembersLoad() {
        $('#StaffMembersRightsTable').bootstrapTable({//职员列表绑定
            url: '../WLTManage/GetWLTStaffMembersSelector?LoginID=' + '@ViewBag.LoginID',         //请求后台的URL（*）
            method: 'post',                      //请求方式（*）
            toolbar: '#btnSmReturn',                //工具按钮用哪个容器
            striped: true,                      //是否显示行间隔色
            pagination: true,                   //是否显示分页（*）
            sortOrder: "asc",
            sidePagination: "server",           //分页方式：client客户端分页，server服务端分页（*）
            pageNumber: 1,                       //初始化加载第一页，默认第一页
            pageSize: 15,                       //每页的记录行数（*）
            pageList: [15, 30, 50],        //可供选择的每页的行数（*）
            minimumCountColumns: 2,  //最少允许的列数
            //height: "100%",               //行高，如果没有设置height属性，表格自动根据记录条数觉得表格高度
            uniqueId: "nub",            //每一行的唯一标识，一般为主键列
            clickToSelect: true,              //是否启用点击选中行
            sortable: true,                     //是否启用排序
            silentSort: true,
            cache: false,                       //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
            search: false,                       //是否显示表格搜索，此搜索是客户端搜索，不会进服务端，所以，个人感觉意义不大
            strictSearch: false,
            paginationFirstText: '首页',
            paginationLastText: '末页',
            paginationPreText: '上一页',
            paginationNextText: '下一页',
            showColumns: false,            //是否显示所有的列
            showRefresh: false,              //是否显示刷新按钮
            showToggle: false,                     //是否显示详细视图和列表视图的切换按钮
             cardView: false,                    //是否显示详细视图
            detailView: false,                   //是否显示父子表
            queryParams: function (params) {
                return {
                    pagesize: params.limit,//页面大小
                    page: params.offset //页码
                };
            },//传递参数（*）
            columns: [
                { field: 'Pusercode', title: '编号' },
                {
                    field: 'Pfullname', title: '名称', formatter: function (value, row, index) {
                        return "<span style='color:blue;cursor:Pointer;'>" + row.Pfullname + "</span>";
                    }
                },
                {
                    field: 'State', title: '状态', width: '15%', align: 'center', formatter: function (value, row, index) {
                        if (row.PZT == "2") {
                            strHtml = '<a  style="cursor:pointer" onclick="SmGiveRights(\'' + row.Ptypeid + '\',\'' + row.PZT + '\',\'' + '@ViewBag.LoginID' + '\')">★</a>';
                            return strHtml;
                        } else if (row.PZT == "1") {
                            strHtml = '<a style="cursor:pointer" onclick="SmGiveRights(\'' + row.Ptypeid + '\',\'' + row.PZT + '\',\'' + '@ViewBag.LoginID' + '\')">☆</a>';
                            return strHtml;
                        } else {
                            strHtml = '<a  style="cursor:pointer" onclick="SmGiveRights(\'' + row.Ptypeid + '\',\'' + row.PZT + '\',\'' + '@ViewBag.LoginID' + '\')">未授权</a>';
                            return strHtml;
                        }
                    }
                },
                    { field: "typeId", titie: "typeId" },
                    { field: "Ptypeid", titie: "Ptypeid" },
                    { field: "parid", titie: "parid" },
                    { field: "Psonnum", titie: "Psonnum" },
                    { field: "PZT", titie: "PZT" }
            ],
            onClickCell: function (field, value, row) {
                if (field == 'Pfullname') {
                    if (row["Psonnum"] == "0") {
                        layer.msg("已到最底层", {time: 2000 });
                        return;
                    }
                    var parid = row.Ptypeid;
                    $('#StaffMembersRightsTable').bootstrapTable('refresh', {
                        url: '../WLTManage/GetWLTStaffMembersSelector?LoginID=' + '@ViewBag.LoginID' + '&parid=' + parid
                    })
                }
            }
        });
        $('#StaffMembersRightsTable').bootstrapTable('hideColumn', 'typeId');
        $('#StaffMembersRightsTable').bootstrapTable('hideColumn', 'parid');
        $('#StaffMembersRightsTable').bootstrapTable('hideColumn', 'Psonnum');
        $('#StaffMembersRightsTable').bootstrapTable('hideColumn', 'PZT');
        $('#StaffMembersRightsTable').bootstrapTable('hideColumn', 'Ptypeid')

    }

    function BranchLoad() {
        $('#BranchRightsTable').bootstrapTable({//分支机构列表
            url: '../WLTManage/GetWLTBranchSelector?LoginID=' + '@ViewBag.LoginID',         //请求后台的URL（*）
            method: 'post',                      //请求方式（*）
            toolbar: '#btnBhReturn',                //工具按钮用哪个容器
            striped: true,                      //是否显示行间隔色
            pagination: true,                   //是否显示分页（*）
            sortOrder: "asc",
            sidePagination: "server",           //分页方式：client客户端分页，server服务端分页（*）
            pageNumber: 1,                       //初始化加载第一页，默认第一页
            pageSize: 15,                       //每页的记录行数（*）
            pageList: [15, 30, 50],        //可供选择的每页的行数（*）
            minimumCountColumns: 2,  //最少允许的列数
            //height: "100%",               //行高，如果没有设置height属性，表格自动根据记录条数觉得表格高度
            uniqueId: "nub",            //每一行的唯一标识，一般为主键列
            clickToSelect: true,              //是否启用点击选中行
            sortable: true,                     //是否启用排序
            silentSort: true,
            cache: false,                       //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
            search: false,                       //是否显示表格搜索，此搜索是客户端搜索，不会进服务端，所以，个人感觉意义不大
            strictSearch: false,
            paginationFirstText: '首页',
            paginationLastText: '末页',
            paginationPreText: '上一页',
            paginationNextText: '下一页',
            showColumns: false,            //是否显示所有的列
            showRefresh: false,              //是否显示刷新按钮
            showToggle: false,                     //是否显示详细视图和列表视图的切换按钮
             cardView: false,                    //是否显示详细视图
            detailView: false,                   //是否显示父子表
            queryParams: function (params) {
                return {
                    pagesize: params.limit,//页面大小
                    page: params.offset, //页码
                };
            },//传递参数（*）
            columns: [
                { field: 'Pusercode', title: '编号' },
                {
                    field: 'Pfullname', title: '名称', formatter: function (value, row, index) {
                        return "<span style='color:blue;cursor:Pointer;'>" + row.Pfullname + "</span>";
                    }
                },
                {
                    field: 'State', title: '状态', width: '15%', align: 'center', formatter: function (value, row, index) {
                        if (row.PZT == "2") {
                            strHtml = '<a  style="cursor:pointer" onclick="BrGiveRights(\'' + row.Ptypeid + '\',\'' + row.PZT + '\',\'' + '@ViewBag.LoginID' + '\')">★</a>';
                            return strHtml;
                        } else if (row.PZT == "1") {
                            strHtml = '<a style="cursor:pointer" onclick="BrGiveRights(\'' + row.Ptypeid + '\',\'' + row.PZT + '\',\'' + '@ViewBag.LoginID' + '\')">☆</a>';
                            return strHtml;
                        } else {
                            strHtml = '<a  style="cursor:pointer" onclick="BrGiveRights(\'' + row.Ptypeid + '\',\'' + row.PZT + '\',\'' + '@ViewBag.LoginID' + '\')">未授权</a>';
                            return strHtml;
                        }
                    }
                },
                        { field: "typeid", titie: "typeid" },
                        { field: "Ptypeid", titie: "Ptypeid" },
                        { field: "parid", titie: "parid" },
                        { field: "Psonnum", titie: "Psonnum" },
                        { field: "PZT", titie: "PZT" }
            ],
            onClickCell: function (field, value, row) {
                if (field == 'Pfullname') {
                    if (row["Psonnum"] == "0") {
                        layer.msg("已到最底层", { time: 2000 });
                        return;
                    }
                    var parid = row.Ptypeid;
                    $('#BranchRightsTable').bootstrapTable('refresh', {
                        url: '../WLTManage/GetWLTBranchSelector?LoginID=' + '@ViewBag.LoginID' + '&parid=' + parid
                    })
                }
            }
        });
        $('#BranchRightsTable').bootstrapTable('hideColumn', 'typeid');
        $('#BranchRightsTable').bootstrapTable('hideColumn', 'parid');
        $('#BranchRightsTable').bootstrapTable('hideColumn', 'Psonnum');
        $('#BranchRightsTable').bootstrapTable('hideColumn', 'PZT');
        $('#BranchRightsTable').bootstrapTable('hideColumn', 'Ptypeid');
    }

    function FastSet(id) {//快速设置权限组
        $.ajax({
            url: "../WLTManage/FastCommoditiesGroupSetting",
            dataType: "text",
            data: { id: id, LoginID: '@ViewBag.LoginID' },
            type: "post",
            success: function (data) {//删除成功后刷新table
                if (data == "商品组设置成功！") {
                    layer.msg(data, { time: 2000 });
                    $('#CommoditiesRightsTable').bootstrapTable("refresh");
                } else {
                    layer.msg(data, { time: 2000 });
                }
            },
            error: function (data) {
                layer.msg(data, {time: 2000 });
            }
        })
    }
    </script>
</body>