<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Compbindcard.aspx.cs" Inherits="SmartLogonServer.Compbindcard" %>

<!DOCTYPE html>

<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <title></title>
    <!--必须的css引用-->
    <link href="Content/bootstrap/css/bootstrap.min.css" rel="stylesheet" />
    <link href="Content/bootstrap-table/bootstrap-table.min.css"  rel="stylesheet" />
       <link href="Content/bootstrap3-editable/css/bootstrap-editable.css" rel="stylesheet" />
<link href="Content/bootstrap-table/extensions/fixed-column/bootstrap-table-fixed-columns.css"  rel="stylesheet" />
    <link href="Content/toastr/toastr.min.css"  rel="stylesheet" />
    <link href="Content/daterangepicker.css"  rel="stylesheet" />
</head>
<body>
    <div class="panel-body" style="padding-bottom:0px;">
            <!--    <div id="toolbar" class="btn-group">
            <button id="btn_add" type="button" class="btn btn-success">
                <span class="glyphicon glyphicon-plus" aria-hidden="true"></span>新增
            </button>

        </div>  -->
     <div class="panel panel-default">
            <div class="panel-heading">查询条件</div>
            <div class="panel-body">
                <form id="formSearch" class="form-horizontal">
                    <div class="form-group">
                        <div class ="row">
                        <label class="control-label col-xs-1" for="txt_search_pcode">编码</label>
                        <div class="col-xs-3">
                            <input type="text" class="form-control" id="txt_search_pccode"/>
                        </div>
                        <label class="control-label col-xs-1" for="txt_search_name">名称</label>
                        <div class="col-xs-3">
                            <input type="text" class="form-control" id="txt_search_name" />
                        </div>
                            </div>
                        <div class ="row">
                        <label class="control-label col-xs-1" for="txt_search_memo">备注</label>
                        <div class="col-xs-3">
                            <input type="text" class="form-control" id="txt_search_memo"/>
                        </div>
                        <label class="control-label col-xs-1" for="txt_search_group">所属组</label>
                        <div class="col-xs-3">
                            <input type="text" class="form-control" id="txt_search_group" />
                        </div>
   
                        <div class="col-xs-4" style="text-align:right;">
                            <button type="button" id="btn_clear"  class="btn">清空</button>
                            <button type="button" id="btn_query" class="btn btn-primary">查询</button>
                        </div>
                            </div>
                        </div>
                    
                </form>
            </div>
        </div>
         <table id="tb_computer"></table>
    </div>

    <!--新增或者编辑的弹出框-->
    <div class="modal fade" id="myModalselectcard" tabindex="-1"  role="dialog" aria-labelledby="myModalLabel">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="myModalLabel">选择智能卡</h4>
                </div>
                <div class="modal-body">
                        <div class="row" style="padding:2px;">
                        <label class="control-label  col-md-2">编码</label>
                        <div class="col-md-4">
                            <input type="text" id="edtComputerid" name="edtComputerid" readonly="true"  />
                        </div>
                            <label class="control-label col-md-2">默认使用</label>
                          <div class=" col-md-4">
                            <input type="radio" id="edtAccessmodepc" name="edtAccessmode"  value="0"  onclick="updateCheckedCard()"/>
                             <label for="edtAccessmodepc">计算机密码</label>
                             <input type="radio" id="edtAccessmodecard" name="edtAccessmode"  value="1"   onclick="updateCheckedCard()"/>
                             <label for="edtAccessmodecard">卡域密码</label> 
                        </div>
                    </div>
                    </div>
             <div class="panel panel-default">
            <div class="panel-heading">查询条件</div>
            <div class="panel-body"> 
                <form id="formSearchcard" class="form-horizontal">
                    <div class="form-group">
                        <div class ="row">
                        <label class="control-label col-xs-3" for="txt_search_text">关键字</label>
                        <div class="col-xs-4">
                            <input type="text" class="form-control" id="txt_search_text"/>
                        </div>
                        
   
                        <div class="col-xs-4" style="text-align:right;">
                            <button type="button" id="btncard_clear"  class="btn">清空</button>
                            <button type="button" id="btncard_query" class="btn btn-primary">查询</button>
                        </div>
                            </div>
                    </div>
                </form>
            </div>  
        </div>
                    
                    
                    <table id="tb_selectcard" ></table>
                
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span>关闭</button>
                    <button type="button" id="sava-pc-btn" class="btn btn-primary"><span class="glyphicon glyphicon-floppy-disk" aria-hidden="true"></span>保存</button>
                </div>
                
            </div>
        </div>
    </div>


    <!--新增或者编辑的弹出框-->
    <div class="modal fade" id="myGroupselectcard" tabindex="-1"  role="dialog" aria-labelledby="myModalLabel">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="myGroupLabel">选择智能卡组</h4>
                </div>
                <div class="modal-body">
                          <div class="row" style="padding:2px;">
                        <label class="control-label  col-md-2">编码</label>
                        <div class="col-md-4">
                            <input type="text" id="edtComputercode" name="edtComputercode" readonly="true"  />
                        </div>
                            <label class="control-label col-md-2">默认使用</label>
                          <div class="radio-list col-md-4">
                            <input type="radio" id="edtAccessmodegpc" name="edtgAccessmode"  value="0"   onclick="updateCheckedG()"/>
                             <label for="edtAccessmodepc">计算机密码</label>
                             <input type="radio" id="edtAccessmodegcard" name="edtgAccessmode"  value="1"   onclick="updateCheckedG()"/>
                             <label for="edtAccessmodegcard">卡域密码</label> 
                        </div>
                    </div>
                    </div>
             <div class="panel panel-default">
            <div class="panel-heading">查询条件</div>
            <div class="panel-body"> 
                <form id="formSearchgroup" class="form-horizontal">
                    <div class="form-group">
                        <div class ="row">
                        <label class="control-label col-xs-3" for="txt_search_text">关键字</label>
                        <div class="col-xs-4">
                            <input type="text" class="form-control" id="txt_searchgroup_text"/>
                        </div>
                        
   
                        <div class="col-xs-4" style="text-align:right;">
                            <button type="button" id="btngroup_clear"  class="btn">清空</button>
                            <button type="button" id="btngroup_query" class="btn btn-primary">查询</button>
                        </div>
                            </div>
                    </div>
                </form>
            </div>  
        </div>
                    
                    
                    <table id="tb_selectgroup" ></table>
                
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span>关闭</button>
                    <button type="button" id="sava-selectgroup-btn" class="btn btn-primary"><span class="glyphicon glyphicon-floppy-disk" aria-hidden="true"></span>保存</button>
                </div>
                
            </div>
        </div>
    </div>

     <!--新增或者编辑的弹出框-->
    <div class="modal fade" id="myModalCardConfig" tabindex="-1"  role="dialog" aria-labelledby="myModalLabel">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="myModalCardConfiglLabel">配置智能卡</h4>
                </div>
                <div class="modal-body">
                        <div class="row" style="padding:10px;">
                        <label class="control-label col-xs-2">卡号</label>
                        <div class="col-xs-4">
                            <input type="text" name="edtCardNo" readonly="true"  class="form-control" />
                        </div>
                         <input type="hidden" name="accessmode"/>
                        <label class="control-label col-xs-2">计算机ID</label>
                        <div class="col-xs-4">
                            <input type="text" name="edtComputerid" readonly="true"  class="form-control" />
                        </div>
                        </div>

                        <div class="row" style="padding:10px;">
                        <label class="control-label col-xs-2">有效期</label>
                        <div class="col-xs-4">
                           
                                <input type="date" class="form-control" name="edtValidDate" value="2023-06-07" required="required" />
                            
   
                        </div>
                        </div>

                        <div class="row" style="padding:10px;">

         <table class="table table-dark table-bordered" >
          <thead>
          <tr >
            <th scope="col">星期</th>
            <th scope="col" colspan="2" >有效时段一</th>
            <th scope="col"colspan="2">有效时段二</th>

          </tr>
           <tr>
            <th scope="col">-</th>
            <th scope="col">开始时间</th>
            <th scope="col">结束时间</th>
            <th scope="col">开始时间</th>
            <th scope="col">结束时间</th>
          </tr>
          </thead>
          <tbody>
          <tr>
            <th scope="row">一</th>
            <td><input type="time" class="form-control" name="edtTime11a" value="00:00" required="required" /></td>
            <td><input type="time" class="form-control" name="edtTime11b" value="23:59" required="required" /></td>
            <td><input type="time" class="form-control" name="edtTime12a" value="00:00" required="required" /></td>
            <td><input type="time" class="form-control" name="edtTime12b" value="00:00" required="required" /></td>

          </tr>
          <tr>
            <th scope="row">二</th>
            <td><input type="time" class="form-control" name="edtTime21a" value="00:00" required="required" /></td>
            <td><input type="time" class="form-control" name="edtTime21b" value="23:59" required="required" /></td>
            <td><input type="time" class="form-control" name="edtTime22a" value="00:00" required="required" /></td>
            <td><input type="time" class="form-control" name="edtTime22b" value="00:00" required="required" /></td>
         
          </tr>
          <tr>
            <th scope="row">三</th>
            <td><input type="time" class="form-control" name="edtTime31a" value="00:00" required="required" /></td>
            <td><input type="time" class="form-control" name="edtTime31b" value="23:59" required="required" /></td>
            <td><input type="time" class="form-control" name="edtTime32a" value="00:00" required="required" /></td>
            <td><input type="time" class="form-control" name="edtTime32b" value="00:00" required="required" /></td>
       
          </tr>
          <tr>
            <th scope="row">四</th>
              <td><input type="time" class="form-control" name="edtTime41a" value="00:00" required="required" /></td>
            <td><input type="time" class="form-control" name="edtTime41b" value="23:59" required="required" /></td>
            <td><input type="time" class="form-control" name="edtTime42a" value="00:00" required="required" /></td>
            <td><input type="time" class="form-control" name="edtTime42b" value="00:00" required="required" /></td>
    
          </tr>
          <tr>
            <th scope="row">五</th>
            <td><input type="time" class="form-control" name="edtTime51a" value="00:00" required="required" /></td>
            <td><input type="time" class="form-control" name="edtTime51b" value="23:59" required="required" /></td>
            <td><input type="time" class="form-control" name="edtTime52a" value="00:00" required="required" /></td>
            <td><input type="time" class="form-control" name="edtTime52b" value="00:00" required="required" /></td>
    
          </tr>
          <tr>
            <th scope="row">六</th>
            <td><input type="time" class="form-control" name="edtTime61a" value="00:00" required="required" /></td>
            <td><input type="time" class="form-control" name="edtTime61b" value="23:59" required="required" /></td>
            <td><input type="time" class="form-control" name="edtTime62a" value="00:00" required="required" /></td>
            <td><input type="time" class="form-control" name="edtTime62b" value="00:00" required="required" /></td>
            
          </tr>
          <tr>
            <th scope="row">日</th>
            <td><input type="time" class="form-control" name="edtTime71a" value="00:00" required="required" /></td>
            <td><input type="time" class="form-control" name="edtTime71b" value="23:59" required="required" /></td>
            <td><input type="time" class="form-control" name="edtTime72a" value="00:00" required="required" /></td>
            <td><input type="time" class="form-control" name="edtTime72b" value="00:00" required="required" /></td>
           
          </tr>
          </tbody>
        </table>
                        </div>
                    
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span>关闭</button>
                    <button type="button" id="sava-config-btn" class="btn btn-primary"><span class="glyphicon glyphicon-floppy-disk" aria-hidden="true"></span>保存</button>
                </div>
                
            </div>
        </div>
    </div>
   
        <!--必须的js文件-->
        <script src="Content/jquery-1.9.1.min.js"></script>
        <script src="Content/bootstrap/js/bootstrap.min.js"></script>
        <script src="Content/bootstrap3-editable/js/bootstrap-editable.js"></script>
        <script src="Content/bootstrap-table/bootstrap-table.min.js"></script>
        <script src="Content/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
        <script src="Content/bootstrap-table/extensions/editable/bootstrap-table-editable.min.js"></script>
            <script src="Content/toastr/toastr.min.js"></script>
        <script src="Content/sweetalert/sweetalert.min.js"></script>
            <script src="Content/moment.min.js"></script>
         <script src="Content/daterangepicker.js"></script>

        <script type="text/javascript">
            //页面加载完成之后


            $(function () {
                var radiov = "0";
               /* $('#daterange').daterangepicker({
                    autoApply: true,
                    singleDatePicker: true,
                    startDate: moment().subtract(-1, 'years'),
                 
                    locale: {
                        "format": "YYYY-MM-DD",// 显示格式
                        "separator": " / ",// 两个日期之间的分割线
                        // 中文化
                        "applyLabel": "确定",
                        "cancelLabel": "取消",
                        "fromLabel": "开始",
                        "toLabel": "结束",
                        "daysOfWeek": ["日", "一", "二", "三", "四", "五", "六"],
                        "monthNames": ["一月", "二月", "三月", "四月", "五月", "六", "七月", "八月", "九月", "十月", "十一月", "十二月"],
                        "firstDay": 1
                    },


                }, function (start, end, label) {
                    // 点击确定后的事件，下面是为了bootstrap validate得校验，
                    // 若未使用，可忽视
                    if ($this.parents("form.required-validate").length > 0) {
                        var $form = $this.parents("form.required-validate");

                        var name = $this.attr("name");
                        if ($form.length > 0) {
                            var data = $form.data('bootstrapValidator');
                            data.updateStatus(name, 'NOT_VALIDATED', null)
                            // Validate the field
                            .validateField(name);
                        }
                    }
                    // 设置最小宽度，否则显示不全
                }).css("min-width", "210px").next("i").click(function () {
                    // 对日期的i标签增加click事件，使其在鼠标点击时可以拉出日期选择
                    $(this).parent().find('input').click();
                });
            */
                //表格的初始化
                $('#tb_computer').bootstrapTable({
                    url: "ComputerCardpc.ashx",                         //直接从本地数据初始化表格
                    method: 'get',                      //请求方式（*）
                    //datatype: "json",
                    //contentType: "application/x-www-form-urlencoded",
                    toolbar: '#toolbar',                //工具按钮用哪个容器
                    idField: 'ComputerID',
                    uniqueId: 'ComputerID',
                    striped: true,                      //是否显示行间隔色
                    cache: false,                       //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
                    pagination: true,                   //是否显示分页（*）
                    sortable: false,                     //是否启用排序
                    sortOrder: "asc",                   //排序方式
                    queryParams: function (params) {
                        var pages = {
                            limit: params.pageSize, // 每页显示数量
                            offset: params.pageNumber, // SQL语句起始索引
                            pccode: $("#txt_search_pccode").val(),
                            name: $("#txt_search_name").val(),
                            memo: $("#txt_search_memo").val(),
                            pcgroup: $("#txt_search_group").val()
                        }

                        return JSON.stringify(pages);
                    },                                  //传递参数（*）
                    queryParamsType: "",
                    sidePagination: "server",           //分页方式：client客户端分页，server服务端分页（*）
                    pageNumber: 1,                      //初始化加载第一页，默认第一页
                    pageSize: 25,                       //每页的记录行数（*）
                    pageList: [10, 25, 50, 100],        //可供选择的每页的行数（*）
                    search: false,                       //是否显示表格搜索，此搜索是客户端搜索，不会进服务端，所以，个人感觉意义不大
                    strictSearch: true,
                    showColumns: true,                  //是否显示所有的列

                    showRefresh: true,                  //是否显示刷新按钮
                    minimumCountColumns: 2,             //最少允许的列数
                    height: 800,
                    selectItemName: 'parentItem',
                    fixedColumns: true,
                    fixedNumber: 6,
                    showToggle: true,          //是否显示详细视图和列表视图的切换按钮
                    cardView: false,          //是否显示详细视图
                    showExport: false, //是否显示导出按钮
                    exportDataType: "all",
                    exportTypes: ['excel'], //导出文件类型
                    detailView: true,
                    //注册加载子表的事件。注意下这里的三个参数！
                    onExpandRow: function (index, row, $detail) {
                        InitSubTable(index, row, $detail);
                    },
                    checkboxHeader: false,
                    columns: [{
                        checkbox: false,
                        width: 10
                    }, {
                        field: 'ComputerID',
                        title: '编码',
                        width: 100

                    }, {
                        field: 'PCGroupName',
                        title: '所属组',
                        width: 200

                    }, {
                        field: 'ComputerName',
                        title: '名称',
                        width: 200

                    }, {
                        field: 'ComputerUserName',
                        title: '计算机用户名',
                        width: 300
                    }, {
                        field: 'CardCount',
                        title: '卡数量',
                        width: 200
                    },
                    {
                        field: 'ComputerMemo',
                        title: '备注',
                        width: 100
                    },
                    {
                        field: 'ComputerAddTime',
                        title: '日期',
                        width: 100
                    }, {
                        title: '操作',
                        width: 200,
                        formatter: function (value, row, index) {//这里的三个参数：value表示当前行当前列的值；row表示当前行的数据；index表示当前行的索引（从0开始）。
                            var html = '<button type="button" onclick="addcard(\'' + row.ComputerID + '\')" class="btn btn-primary"><span class="glyphicon glyphicon-plus" aria- hidden="true" ></span >加卡</button >'
                                    + '<button type="button" onclick="addgroup(\'' + row.ComputerID + '\')" class="btn btn-primary"><span class="glyphicon glyphicon-plus" aria- hidden="true" ></span >加组</button >'
                            return html;
                        }
                    }],
                    onEditableSave: function (field, row, oldValue, $el) {
                        alert("更新保存事件，原始值为" + oldValue);
                        //$.ajax({
                        //    type: "post",
                        //    url: "/Editable/Edit",
                        //    data: row,
                        //    dataType: 'JSON',
                        //    success: function (data, status) {
                        //        if (status == "success") {
                        //            alert('提交数据成功');
                        //        }
                        //    },
                        //    error: function () {
                        //        alert('编辑失败');
                        //    },
                        //    complete: function () {

                        //    }

                        //});
                    }
                });



                var InitSubTable = function (index, row, $detail) {
                    var parentid = row.ComputerID;
                    var cur_table = $detail.html('<table id="cardtable' + row.ComputerID + '"></table>').find('table');
                    //子表的初始化和父表完全相同
                    $(cur_table).bootstrapTable({
                        url: 'ComputerCard.ashx',
                        //data: childData,
                        method: 'get',
                        queryParams: { computerid: parentid },
                        ajaxOptions: { computerid: parentid },
                        clickToSelect: true,
                        uniqueId: "CardNo",
                        pageSize: 10,
                        pageList: [10, 25],
                        selectItemName: 'childItem' + index,
                        checkboxHeader: false,
                        columns: [{
                            checkbox: false,
                            width: 10
                        },{
                            field: 'CardNo',
                            title: '卡号'
                        }, {
                            field: 'CardHolderName',
                            title: '持卡人'
                        }, {
                            field: 'Status',
                            title: '状态',
                            formatter: function (value, row, index) {
                                if (row['Status'] == '0') {
                                    return '已同步';
                                }
                                if (row['Status'] == '1') {
                                    return '未同步';
                                }
                                if (row['Status'] == '2') {
                                    return '待删除';
                                }
                                return value;
                            },
                            width: 80

                        }, {
                            field: 'CardValid',
                            title: '有效期'
                        },  {
                            field: 'AccessMode',
                            title: '密码方式',
                            editable: {
                                type: 'select',
                                title: '计算机登录密码验证方式',
                                source:[{value:"0",text:"计算机密码"},{value:"1",text:"卡域密码"}]
            
                                
                            }
                            
                        },{
                            title: '操作',
                            width: 200,
                            formatter: function (value, row, index) {//这里的三个参数：value表示当前行当前列的值；row表示当前行的数据；index表示当前行的索引（从0开始）。
                                var html = '<button type="button" onclick="ConfigModelpc(\'' + row.ComputerID + '\',\'' + row.CardNo + '\',\'' + row.AccessMode + '\')" class="btn btn-primary"><span class="glyphicon glyphicon-pencil" aria- hidden="true" ></span >配置</button >&nbsp;&nbsp;' +
                                           '<button type="button" onclick="deletecard(\'' + row.ComputerID + '\',\'' + row.CardNo + '\')"' + 'class="btn btn-outline-secondary"><span class="glyphicon glyphicon-minus" aria- hidden="true" ></span >移除</button >';

                                return html;
                            }
          
                        }],
                        onEditableSave: function (field, row, oldValue, $el) {
             
                            

                            $.ajax({
                                type: "post",
                                url: "ComputerCardEditAccessMode.ashx",
                                data: row,
                                dataType: 'JSON',
                                success: function (data, status) {
                                    if (data.result == true) {
                                        $('#cardtable' + row['ComputerID']).bootstrapTable("refresh", {
                                            silent: true //静态刷新
                                        });
                                    }
                                },
                                error: function () {
                                    toastr.error('编辑失败');
                                },
                                complete: function () {

                                }

                            });
                        },
                        //无线循环取子表，直到子表里面没有记录
                        onExpandRow: function (index, row, $Subdetail) {
                            //oInit.InitSubTable(index, row, $Subdetail);
                        }
                    });
                };
                

            });


            //编辑事件
            var addcard = function (id) {
                //根据当前行的id获取当前的行数据

               // var row = $("#tb_computer").bootstrapTable('getRowByUniqueId', id);
                //弹出模态框   edtAccessmode

                $("#myModalselectcard").modal();
                //给弹出框里面的各个文本框赋值
                $("#myModalselectcard input[name='edtComputerid']").val(id);
                $("#myModalselectcard input:radio[id='edtAccessmodepc']").prop('checked', 'checked');
                radiov = "0";
                //表格的初始化
                $('#tb_selectcard').bootstrapTable({
                        url: "CardSelect.ashx",                         //直接从本地数据初始化表格
                        method: 'get',                      //请求方式（*）
                            //datatype: "json",
                            //contentType: "application/x-www-form-urlencoded",
                        //toolbar: '#toolbar',                //工具按钮用哪个容器
                        idField: 'CardNo',
                        uniqueId: 'CardNo',
                        striped: true,                      //是否显示行间隔色
                        cache: false,                       //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
                        pagination: true,                   //是否显示分页（*）
                        sortable: false,                     //是否启用排序
                        sortOrder: "asc",                   //排序方式
                        queryParams: function (params) {
                            var pages = {
                                limit: params.pageSize, // 每页显示数量
                                offset: params.pageNumber, // SQL语句起始索引
                                computerid: $("#edtComputerid").val(),
                                keystr: $("#txt_search_text").val()
                            }

                            return JSON.stringify(pages);
                        },
                        queryParamsType: "",                                 //传递参数（*）
                        sidePagination: "server",           //分页方式：client客户端分页，server服务端分页（*）
                        pageNumber: 1,                      //初始化加载第一页，默认第一页
                        pageSize: 10,                       //每页的记录行数（*）
                        pageList: [10, 25],        //可供选择的每页的行数（*）
                        search: false,                       //是否显示表格搜索，此搜索是客户端搜索，不会进服务端，所以，个人感觉意义不大
                        strictSearch: true,
                        showColumns: false,                  //是否显示所有的列

                        showRefresh: false,                  //是否显示刷新按钮
                        minimumCountColumns: 2,             //最少允许的列数
                        //height: 600,
                        selectItemName: 'parentItem',
                        fixedColumns: true,
                        fixedNumber: 6,
                        showToggle: false,          //是否显示详细视图和列表视图的切换按钮
                        cardView: false,          //是否显示详细视图
                        showExport: false, //是否显示导出按钮
  
                            //注册加载子表的事件。注意下这里的三个参数！
                        onExpandRow: function (index, row, $detail) {
                            //InitSubTable(index, row, $detail);
                        },
                        columns: [{
                            checkbox: true
                        }, {
                            field: 'CardNo',
                            title: '卡号',
                            width: 100

                        }, {
                            field: 'CardHolderName',
                            title: '持卡人',
                            width: 200

                        },
                            {
                            field: 'CardGroupName',
                            title: '所属组',
                            width: 100
                        }]
        
                    
                    });


            }


            var addgroup = function (id) {
                //根据当前行的id获取当前的行数据

                // var row = $("#tb_computer").bootstrapTable('getRowByUniqueId', id);
                //弹出模态框

                $("#myGroupselectcard").modal();
                //给弹出框里面的各个文本框赋值
                $("#myGroupselectcard input[name='edtComputercode']").val(id);
                $("#myGroupselectcard input[id='edtAccessmodegpc']").prop('checked', 'checked');
                radiov = "0";
                //表格的初始化
                $('#tb_selectgroup').bootstrapTable({
                    url: "GroupSelect.ashx",                         //直接从本地数据初始化表格
                    method: 'get',                      //请求方式（*）
                    //datatype: "json",
                    //contentType: "application/x-www-form-urlencoded",
                    //toolbar: '#toolbar',                //工具按钮用哪个容器
                    idField: 'ID',
                    uniqueId: 'ID',
                    striped: true,                      //是否显示行间隔色
                    cache: false,                       //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
                    pagination: true,                   //是否显示分页（*）
                    sortable: false,                     //是否启用排序
                    sortOrder: "asc",                   //排序方式
                    queryParams: function (params) {
                        var pages = {
                            limit: params.pageSize, // 每页显示数量
                            offset: params.pageNumber, // SQL语句起始索引
                            computerid: $("#edtComputercode").val(),
                            keystr: $("#txt_searchgroup_text").val()
                        }

                        return JSON.stringify(pages);
                    },
                    queryParamsType: "",                                 //传递参数（*）
                    sidePagination: "server",           //分页方式：client客户端分页，server服务端分页（*）
                    pageNumber: 1,                      //初始化加载第一页，默认第一页
                    pageSize: 10,                       //每页的记录行数（*）
                    pageList: [10, 25],        //可供选择的每页的行数（*）
                    search: false,                       //是否显示表格搜索，此搜索是客户端搜索，不会进服务端，所以，个人感觉意义不大
                    strictSearch: true,
                    showColumns: false,                  //是否显示所有的列

                    showRefresh: false,                  //是否显示刷新按钮
                    minimumCountColumns: 2,             //最少允许的列数
                    //height: 600,
                    selectItemName: 'parentItem',
                    fixedColumns: true,
                    fixedNumber: 6,
                    showToggle: false,          //是否显示详细视图和列表视图的切换按钮
                    cardView: false,          //是否显示详细视图
                    showExport: false, //是否显示导出按钮

                    //注册加载子表的事件。注意下这里的三个参数！
                    onExpandRow: function (index, row, $detail) {
                        //InitSubTable(index, row, $detail);
                    },
                    columns: [{
                        checkbox: true
                    }, {
                        field: 'ID',
                        title: '序号',
                        width: 100

                    }, {
                        field: 'CardGroupName',
                        title: '组名称',
                        width: 200

                    },
                        {
                            field: 'GroupMemo',
                            title: '备注',
                            width: 100
                        }]


                });


            }
            //配置事件
            var ConfigModelpc = function (computerid, cardno,am) {
                

                $("#myModalCardConfig input[name='edtComputerid']").val(computerid);
                $("#myModalCardConfig input[name='edtCardNo']").val(cardno);
                $("#myModalCardConfig input[name='accessmode']").val(am);
                $('#myModalCardConfig').modal();

            }
            //删除事件
            var deletecard = function (computerid, cardno) {
    
                swal({
                    title: "移除智能卡",
                    text: "是否删移除卡号为" + cardno + "的智能卡?",
                    icon: "warning",
                    // buttons: true,
                    dangerMode: true,
                    buttons:{
                        cancel: '取消',
                        confirm: {
                            text: '删除',
                            value: 'confirm'
                        }
                    }
                })
    .then((value) => {
        if (value==='confirm') {

                    $.ajax({
                        type: "post",
                        url: "ComputerCardDel.ashx",
                        data: {
                            'Card': cardno,
                            'ComputerID': computerid

                        },
                        dataType: 'JSON',
                        success: function (data, status) {
                            if (status == "success") {
                                if (data.result == true) {
                                    

                                    $('#cardtable' + computerid).bootstrapTable("refresh", {
                                        silent: true //静态刷新
                                    });
                                    toastr.success('操作成功');
                                }
                                else {
                                    toastr.error('操作失败');
                                }
                            }
                        },
                        error: function () {
                            toastr.error('操作失败');
                        },
                        complete: function () {

                        }

                    });
            }
            });//then
            }


            $("#sava-pc-btn").click(function () {
                $('#myModalselectcard').modal('hide');
                var sels = $("#tb_selectcard").bootstrapTable('getSelections');



                var cards = "0";
                sels.forEach(function (row) {
                    cards = cards + "#" + row.CardNo;
                });

                var computerid = $("#myModalselectcard input[name='edtComputerid']").val();
                var accessmode = radiov;//$("#myModalselectcard input[id='edtAccessmodepc]").prop("checked");
               
                $.ajax({
                    type: "post",
                    url: "ComputerCardEdit.ashx",
                    data: {
                        "mode": 'card',
                        "computerid": computerid,
                        "accessmode": accessmode,
                        "cards": cards
                    },
                    dataType: 'JSON',
                    success: function (data, status) {
                        if (status == "success") {
                            if (data.result == true) {

                                $('#cardtable' + computerid).bootstrapTable("refresh", {
                                    silent: true //静态刷新
                                });
                                toastr.success('操作成功');
                            }
                            else {
                                toastr.error('操作失败');
                            }
                        }
                    },
                    error: function () {
                        toastr.error('操作失败');
                    },
                    complete: function () {
                        
                    }

                });
            });


            $("#sava-selectgroup-btn").click(function () {
                $('#myGroupselectcard').modal('hide');
                var sels = $("#tb_selectgroup").bootstrapTable('getSelections');



                var groups = "-1";
                sels.forEach(function (row) {
                    groups = groups + "#" + row.ID;
                });

                var computerid = $("#myGroupselectcard input[name='edtComputercode']").val();
                var accessmode = radiov;//$("#myGroupselectcard input[name='edtgAccessmode]:checked").val();
                $.ajax({
                    type: "post",
                    url: "ComputerCardEdit.ashx",
                    data: {
                        "mode": 'group',
                        "computerid": computerid,
                        "accessmode": accessmode,
                        "cards": groups
                    },
                    dataType: 'JSON',
                    success: function (data, status) {
                        if (status == "success") {
                            if (data.result == true) {

                                $('#cardtable' + computerid).bootstrapTable("refresh", {
                                    silent: true //静态刷新
                                });
                                toastr.success('操作成功');
                            }
                            else {
                                toastr.error('操作失败');
                            }
                        }
                    },
                    error: function () {
                        toastr.error('操作失败');
                    },
                    complete: function () {

                    }

                });
            });

            $('#myModalselectcard').on('hidden.bs.modal', function () {
                $("#tb_selectcard").bootstrapTable('destroy');
            });


            $("#sava-config-btn").click(function () {
                $('#myModalCardConfig').modal('hide');
                var Computerid=$("#myModalCardConfig input[name='edtComputerid']").val();
               
                $.ajax({
                    type: "post",
                    url: "ComputerCardTimeEdit.ashx",
                    data: {
                        computerid: Computerid,
                        cardno: $("#myModalCardConfig input[name='edtCardNo']").val(),
                        accessmode: $("#myModalCardConfig input[name='accessmode']").val(),
                        CardValid: $("#myModalCardConfig input[name='edtValidDate']").val(),
                        VTime11a: $("#myModalCardConfig input[name='edtTime11a']").val(),
                        VTime11b: $("#myModalCardConfig input[name='edtTime11b']").val(),
                        VTime12a: $("#myModalCardConfig input[name='edtTime12a']").val(),
                        VTime12b: $("#myModalCardConfig input[name='edtTime12b']").val(),

                        VTime21a: $("#myModalCardConfig input[name='edtTime21a']").val(),
                        VTime21b: $("#myModalCardConfig input[name='edtTime21b']").val(),
                        VTime22a: $("#myModalCardConfig input[name='edtTime22a']").val(),
                        VTime22b: $("#myModalCardConfig input[name='edtTime22b']").val(),

                        VTime31a: $("#myModalCardConfig input[name='edtTime31a']").val(),
                        VTime31b: $("#myModalCardConfig input[name='edtTime31b']").val(),
                        VTime32a: $("#myModalCardConfig input[name='edtTime32a']").val(),
                        VTime32b: $("#myModalCardConfig input[name='edtTime32b']").val(),

                        VTime41a: $("#myModalCardConfig input[name='edtTime41a']").val(),
                        VTime41b: $("#myModalCardConfig input[name='edtTime41b']").val(),
                        VTime42a: $("#myModalCardConfig input[name='edtTime42a']").val(),
                        VTime42b: $("#myModalCardConfig input[name='edtTime42b']").val(),

                        VTime51a: $("#myModalCardConfig input[name='edtTime51a']").val(),
                        VTime51b: $("#myModalCardConfig input[name='edtTime51b']").val(),
                        VTime52a: $("#myModalCardConfig input[name='edtTime52a']").val(),
                        VTime52b: $("#myModalCardConfig input[name='edtTime52b']").val(),

                        VTime61a: $("#myModalCardConfig input[name='edtTime61a']").val(),
                        VTime61b: $("#myModalCardConfig input[name='edtTime61b']").val(),
                        VTime62a: $("#myModalCardConfig input[name='edtTime62a']").val(),
                        VTime62b: $("#myModalCardConfig input[name='edtTime62b']").val(),

                        VTime71a: $("#myModalCardConfig input[name='edtTime71a']").val(),
                        VTime71b: $("#myModalCardConfig input[name='edtTime71b']").val(),
                        VTime72a: $("#myModalCardConfig input[name='edtTime72a']").val(),
                        VTime72b: $("#myModalCardConfig input[name='edtTime72b']").val()
                    },
                    dataType: 'JSON',
                    success: function (data, status) {
                        if (status == "success") {
                            if (data.result == true) {

                                $('#cardtable' + Computerid).bootstrapTable("refresh", {
                                    silent: true //静态刷新
                                });
                                toastr.success('操作成功');
                            }
                            else {
                                toastr.error('操作失败');
                            }
                        }
                    },
                    error: function () {
                        toastr.error('操作错误');
                    },
                    complete: function () {

                    }

                });
            });

            $('#myModalCardConfig').on('shown.bs.modal', function () {
                $.ajax({
                    type: "post",
                    url: "GetCardConfig.ashx",
                    data: {
                        computerid: $("#myModalCardConfig input[name='edtComputerid']").val(),
                        cardno: $("#myModalCardConfig input[name='edtCardNo']").val()
                    },
                    dataType: 'JSON',
                    success: function (data, status) {
                        //alert(JSON.stringify(data));
                        if (status == "success") {
                            if (data.result == 'True') {
                                $("#myModalCardConfig input[name='edtValidDate']").val(data.CardValid);

                                $("#myModalCardConfig input[name='edtTime11a']").val(data.Time11a);
                                $("#myModalCardConfig input[name='edtTime11b']").val(data.Time11b);
                                $("#myModalCardConfig input[name='edtTime12a']").val(data.Time12a);
                                $("#myModalCardConfig input[name='edtTime12b']").val(data.Time12b);

                                $("#myModalCardConfig input[name='edtTime21a']").val(data.Time21a);
                                $("#myModalCardConfig input[name='edtTime21b']").val(data.Time21b);
                                $("#myModalCardConfig input[name='edtTime22a']").val(data.Time22a);
                                $("#myModalCardConfig input[name='edtTime22b']").val(data.Time22b);

                                $("#myModalCardConfig input[name='edtTime31a']").val(data.Time31a);
                                $("#myModalCardConfig input[name='edtTime31b']").val(data.Time31b);
                                $("#myModalCardConfig input[name='edtTime32a']").val(data.Time32a);
                                $("#myModalCardConfig input[name='edtTime32b']").val(data.Time32b);

                                $("#myModalCardConfig input[name='edtTime41a']").val(data.Time41a);
                                $("#myModalCardConfig input[name='edtTime41b']").val(data.Time41b);
                                $("#myModalCardConfig input[name='edtTime42a']").val(data.Time42a);
                                $("#myModalCardConfig input[name='edtTime42b']").val(data.Time42b);

                                $("#myModalCardConfig input[name='edtTime51a']").val(data.Time51a);
                                $("#myModalCardConfig input[name='edtTime51b']").val(data.Time51b);
                                $("#myModalCardConfig input[name='edtTime52a']").val(data.Time52a);
                                $("#myModalCardConfig input[name='edtTime52b']").val(data.Time52b);

                                $("#myModalCardConfig input[name='edtTime61a']").val(data.Time61a);
                                $("#myModalCardConfig input[name='edtTime61b']").val(data.Time61b);
                                $("#myModalCardConfig input[name='edtTime62a']").val(data.Time62a);
                                $("#myModalCardConfig input[name='edtTime62b']").val(data.Time62b);

                                $("#myModalCardConfig input[name='edtTime71a']").val(data.Time71a);
                                $("#myModalCardConfig input[name='edtTime71b']").val(data.Time71b);
                                $("#myModalCardConfig input[name='edtTime72a']").val(data.Time72a);
                                $("#myModalCardConfig input[name='edtTime72b']").val(data.Time72b);

                            }
                            else {
                                toastr.error('获取配置失败');
                            }
                        }
                    },
                    error: function () {
                        toastr.error('获取配置失败');
                    },
                    complete: function () {

                    }

                });
            });

            $("#btn_clear").click(function () {
                $("#txt_search_pccode").val("");
                $("#txt_search_name").val("");
                $("#txt_search_memo").val("");
                $("#txt_search_group").val("");
            })

            $("#btn_query").click(function () {
                $('#tb_computer').bootstrapTable('refresh', { offset: 1 });
            })

            $("#btncard_clear").click(function () {
                $("#txt_search_text").val("");
            })

            $("#btncard_query").click(function () {
                $('#tb_selectcard').bootstrapTable('refresh', { offset: 1 });
            })
            $("#btngroup_clear").click(function () {
                $("#txt_searchgroup_text").val("");
            })

            $("#btngroup_query").click(function () {
                $('#tb_selectgroup').bootstrapTable('refresh', { offset: 1 });
            })

            function updateCheckedCard() {
                var radioButtons = document.getElementsByName("edtAccessmode");

                for (var i = 0; i < radioButtons.length; i++) {
                    if (radioButtons[i].checked) {
                        radioButtons[i].checked = false;
                    }
                }
                
                event.currentTarget.checked = true;
                radiov = event.currentTarget.value;
                
            }

            function updateCheckedG() {
                var radioButtons = document.getElementsByName("edtgAccessmode");

                for (var i = 0; i < radioButtons.length; i++) {
                    if (radioButtons[i].checked) {
                        radioButtons[i].checked = false;
                    }
                }

                event.currentTarget.checked = true;
                radiov = event.currentTarget.value;

            }

            toastr.options.positionClass = 'toast-top-center';
        </script>
</body>
</html>
