<%@ 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"><%=GetString("D0006") %></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"><%=GetString("D0016") %></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"><%=GetString("D0017") %></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"><%=GetString("D0018") %></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"><%=GetString("D0010") %></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"><%=GetString("B0030") %></button>
                            <button type="button" id="btn_query" class="btn btn-primary"><%=GetString("B0031") %></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"><%=GetString("D0062") %></h4>
                </div>
                <div class="modal-body">
                        <div class="row" style="padding:2px;">
                        <label class="control-label  col-md-2"><%=GetString("D0016") %></label>
                        <div class="col-md-4">
                            <input type="text" id="edtComputerid" name="edtComputerid" readonly="true"  />
                        </div>
                            <label class="control-label col-md-2"><%=GetString("D0063") %></label>
                          <div class=" col-md-4">
                            <input type="radio" id="edtAccessmodepc" name="edtAccessmode"  value="0"  onclick="updateCheckedCard()"/>
                             <label for="edtAccessmodepc"><%=GetString("D0064") %></label>
                             <input type="radio" id="edtAccessmodecard" name="edtAccessmode"  value="1"   onclick="updateCheckedCard()"/>
                             <label for="edtAccessmodecard"><%=GetString("D0065") %></label> 
                        </div>
                    </div>
                    </div>
             <div class="panel panel-default">
            <div class="panel-heading"><%=GetString("D0006") %></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"><%=GetString("D0066") %></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"><%=GetString("B0030") %></button>
                            <button type="button" id="btncard_query" class="btn btn-primary"><%=GetString("B0031") %></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><%=GetString("B0025") %></button>
                    <button type="button" id="sava-pc-btn" class="btn btn-primary"><span class="glyphicon glyphicon-floppy-disk" aria-hidden="true"></span><%=GetString("B0026") %></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"><%=GetString("D0067") %></h4>
                </div>
                <div class="modal-body">
                          <div class="row" style="padding:2px;">
                        <label class="control-label  col-md-2"><%=GetString("D0016") %></label>
                        <div class="col-md-4">
                            <input type="text" id="edtComputercode" name="edtComputercode" readonly="true"  />
                        </div>
                            <label class="control-label col-md-2"><%=GetString("D0063") %></label>
                          <div class="radio-list col-md-4">
                            <input type="radio" id="edtAccessmodegpc" name="edtgAccessmode"  value="0"   onclick="updateCheckedG()"/>
                             <label for="edtAccessmodepc"><%=GetString("D0064") %></label>
                             <input type="radio" id="edtAccessmodegcard" name="edtgAccessmode"  value="1"   onclick="updateCheckedG()"/>
                             <label for="edtAccessmodegcard"><%=GetString("D0065") %></label> 
                        </div>
                    </div>
                    </div>
             <div class="panel panel-default">
            <div class="panel-heading"><%=GetString("D0006") %></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"><%=GetString("D0066") %></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"><%=GetString("B0030") %></button>
                            <button type="button" id="btngroup_query" class="btn btn-primary"><%=GetString("B0031") %></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><%=GetString("B0025") %></button>
                    <button type="button" id="sava-selectgroup-btn" class="btn btn-primary"><span class="glyphicon glyphicon-floppy-disk" aria-hidden="true"></span><%=GetString("B0026") %></button>
                </div>
                
            </div>
        </div>
    </div>

    <!--卡复制到-->
      <div class="modal fade" id="myModalselectcopypc" 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="myModalbandpcLabel"><%=GetString("D0068") %></h4>
                </div>
                <div class="modal-body">
                        <div class="row" style="padding:2px;">
                        <label class="control-label  col-md-2"><%=GetString("D0016") %></label>
                        <div class="col-md-4">
                            <input type="text" id="edtSrcComputerid" name="edtSrcComputerid" readonly="true"  />
                        </div>

                    </div>
                    
             <div class="panel panel-default">
            <div class="panel-heading"><%=GetString("D0006") %></div>
            <div class="panel-body"> 
                <form id="formSearchcopypc" class="form-horizontal">
                    <div class="form-group">
                        <div class ="row">
                        <label class="control-label col-xs-3" for="txt_search_text"><%=GetString("D0066") %></label>
                        <div class="col-xs-4">
                            <input type="text" class="form-control" name="txt_searchpc_text" id="txt_searchpc_text"/>
                        </div>
                        
   
                        <div class="col-xs-4" style="text-align:right;">
                            <button type="button" id="btncopy_clear"  class="btn"><%=GetString("B0030") %></button>
                            <button type="button" id="btncopy_query" class="btn btn-primary"><%=GetString("B0031") %></button>
                        </div>
                            </div>
                    </div>
                </form>
            </div> 
                 </div> 
        </div>
                    <table id="tb_selectpctocopy" ></table>
                
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span><%=GetString("B0025") %></button>
                    <button type="button" id="sava-copypc-btn" class="btn btn-primary"><span class="glyphicon glyphicon-floppy-disk" aria-hidden="true"></span><%=GetString("B0026") %></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"><%=GetString("D0069") %></h4>
                </div>
                <div class="modal-body">
                        <div class="row" style="padding:10px;">
                        <label class="control-label col-xs-2"><%=GetString("D0007") %></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"><%=GetString("D0016") %></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"><%=GetString("D0070") %></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"><%=GetString("D0071") %></th>
            <th scope="col" colspan="2" ><%=GetString("D0072") %></th>
            <th scope="col"colspan="2"><%=GetString("D0073") %></th>

          </tr>
           <tr>
            <th scope="col">-</th>
            <th scope="col"><%=GetString("D0074") %></th>
            <th scope="col"><%=GetString("D0075") %></th>
            <th scope="col"><%=GetString("D0074") %></th>
            <th scope="col"><%=GetString("D0075") %></th>
          </tr>
          </thead>
          <tbody>
          <tr>
            <th scope="row">1(Mon)</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">2(Tue)</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">3(Wed)</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">4(Thu)</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">5(Fri)</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">6(Sat)</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">7(Sun)</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><%=GetString("B0025") %></button>
                    <button type="button" id="sava-config-btn" class="btn btn-primary"><span class="glyphicon glyphicon-floppy-disk" aria-hidden="true"></span><%=GetString("B0026") %></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";
               
                //表格的初始化
                $('#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: <%=GetQuoteString("D0016") %>,
                        width: 100

                    }, {
                        field: 'PCGroupName',
                        title: <%=GetQuoteString("D0010") %>,
                        width: 200

                    }, {
                        field: 'ComputerName',
                        title: <%=GetQuoteString("D0017") %>,
                        width: 200

                    }, {
                        field: 'ComputerUserName',
                        title: <%=GetQuoteString("D0019") %>,
                        width: 300
                    }, {
                        field: 'CardCount',
                        title: <%=GetQuoteString("D0076") %>,
                        width: 200
                    },
                    {
                        field: 'ComputerMemo',
                        title: <%=GetQuoteString("D0018") %>,
                        width: 100
                    },
                    {
                        field: 'ComputerAddTime',
                        title: <%=GetQuoteString("D0015") %>,
                        width: 100
                    }, {
                        title: <%=GetQuoteString("B0027") %>,
                        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 >' +<%=GetQuoteString("B0040") %>+ '</button >'
                                    + '<button type="button" onclick="addgroup(\'' + row.ComputerID + '\')" class="btn btn-primary"><span class="glyphicon glyphicon-plus" aria- hidden="true" ></span >' +<%=GetQuoteString("B0041") %>+ '</button >'
                             + '<button type="button" onclick="copycardto(\'' + row.ComputerID + '\')" class="btn btn-danger"><span class="glyphicon glyphicon-copy" aria- hidden="true" ></span >' +<%=GetQuoteString("B0042") %>+ '</button >';
                            return html;
                        }
                    }],
                    onEditableSave: function (field, row, oldValue, $el) {
                        
                    }
                });



                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: <%=GetQuoteString("D0007") %>,
                        }, {
                            field: 'CardHolderName',
                            title: <%=GetQuoteString("D0008") %>
                        }, {
                            field: 'Status',
                            title: <%=GetQuoteString("D0077") %>,
                            formatter: function (value, row, index) {
                                if (row['Status'] == '0') {
                                    return <%=GetQuoteString("D0078") %>;
                                }
                                if (row['Status'] == '1') {
                                    return <%=GetQuoteString("D0079") %>;
                                }
                                if (row['Status'] == '2') {
                                    return <%=GetQuoteString("D0080") %>;
                                }
                                return value;
                            },
                            width: 80

                        }, {
                            field: 'CardValid',
                            title: <%=GetQuoteString("D0070") %>
                        },  {
                            field: 'AccessMode',
                            title: <%=GetQuoteString("D0081") %>,
                            editable: {
                                type: 'select',
                                title:  <%=GetQuoteString("D0082") %>,
                                source:[{value:"0",text:<%=GetQuoteString("D0064") %>},{value:"1",text:<%=GetQuoteString("D0065") %>}]
            
                                
                            }
                            
                        },{
                            title: <%=GetQuoteString("B0027") %>,
                            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 >'+<%=GetQuoteString("B0043") %>+'</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 >'+<%=GetQuoteString("B0044") %>+'</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 //静态刷新
                                        });
                                        toastr.success(<%=GetQuoteString("C0005") %>);
                                    }
                                },
                                error: function () {
                                    toastr.error(<%=GetQuoteString("C0006") %>);
                                },
                                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: <%=GetQuoteString("D0007") %>,
                            width: 100

                        }, {
                            field: 'CardHolderName',
                            title: <%=GetQuoteString("D0008") %>,
                            width: 200

                        },
                            {
                            field: 'CardGroupName',
                            title: <%=GetQuoteString("D0010") %>,
                            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: <%=GetQuoteString("B0024") %>,
                        width: 100

                    }, {
                        field: 'CardGroupName',
                        title: <%=GetQuoteString("D0010") %>,
                        width: 200

                    },
                        {
                            field: 'GroupMemo',
                            title: <%=GetQuoteString("D0005") %>,
                            width: 100
                        }]


                });


            }

            var copycardto = function (id) {
                //$('#myModalselectmainpc').bootstrapTable("resetView");
                //弹出模态框
               
                $("#myModalselectcopypc").modal();
                //给弹出框里面的各个文本框赋值
                $("#myModalselectcopypc input").val("");
                $("#myModalselectcopypc input[name='edtSrcComputerid']").val(id);

                $('#tb_selectpctocopy').bootstrapTable({
                    url: "computerselect.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语句起始索引
                            srcid:  id,
                            keystr: $("#myModalselectcopypc input[name='txt_searchpc_text']").val()
                        }

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

                    }, {
                        field: 'ComputerName',
                        title: <%=GetQuoteString("D0017") %>,
                        width: 200

                    }]
        
                    
                });
            };
            //配置事件
            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: <%=GetQuoteString("D0083") %>,
                    text: <%=GetQuoteString("D0084") %> + cardno,
                    icon: "warning",
                    // buttons: true,
                    dangerMode: true,
                    buttons:{
                        cancel: <%=GetQuoteString("B0029") %>,
                        confirm: {
                            text: <%=GetQuoteString("B0028") %>,
                            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(<%=GetQuoteString("C0005") %>);
                                }
                                else {
                                    toastr.error(<%=GetQuoteString("C0006") %>);
                                }
                            }
                        },
                        error: function () {
                            toastr.error(<%=GetQuoteString("C0006") %>);
                        },
                        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(<%=GetQuoteString("C0005") %>);
                            }
                            else {
                                toastr.error(<%=GetQuoteString("C0006") %>);
                            }
                        }
                    },
                    error: function () {
                        toastr.error(<%=GetQuoteString("C0006") %>);
                    },
                    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(<%=GetQuoteString("C0005") %>);
                            }
                            else {
                                toastr.error(<%=GetQuoteString("C0006") %>);
                            }
                        }
                    },
                    error: function () {
                        toastr.error(<%=GetQuoteString("C0006") %>);
                    },
                    complete: function () {

                    }

                });
            });

            //sava-copypc-btn
            $("#sava-copypc-btn").click(function () {
                $('#myModalselectcopypc').modal('hide');
                var sels = $("#tb_selectpctocopy").bootstrapTable('getSelections');



                var groups = "";
                sels.forEach(function (row) {
                    groups = groups + row.ComputerID + ",";
                });

                if(groups=="")
                {
                    toastr.info(<%=GetQuoteString("D0085") %>);
                    return;
                }

                var computerid = $("#myModalselectcopypc input[name='edtSrcComputerid']").val();

                $.ajax({
                    type: "post",
                    url: "ComputerCopyToEdit.ashx",
                    data: {
                        "computerid": computerid,
                        "others": groups
                    },
                    dataType: 'JSON',
                    success: function (data, status) {
                        if (status == "success") {
                            if (data.result == true) {

                                toastr.success(<%=GetQuoteString("D0086") %>);
                            }
                            else {
                                toastr.error(<%=GetQuoteString("C0006") %>);
                            }
                        }
                    },
                    error: function () {
                        toastr.error(<%=GetQuoteString("C0006") %>);
                    },
                    complete: function () {

                    }

                });
            });

           

            $('#myModalselectcard').on('hidden.bs.modal', function () {
                $("#tb_selectcard").bootstrapTable('destroy');
            });
            $('#myModalselectcopypc').on('hidden.bs.modal', function () {
                $("#tb_selectpctocopy").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(<%=GetQuoteString("C0005") %>);
                            }
                            else {
                                toastr.error(<%=GetQuoteString("C0006") %>);
                            }
                        }
                    },
                    error: function () {
                        toastr.error(<%=GetQuoteString("C0006") %>);
                    },
                    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(<%=GetQuoteString("C0006") %>);
                            }
                        }
                    },
                    error: function () {
                        toastr.error(<%=GetQuoteString("C0006") %>);
                    },
                    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 });
            })
            
            $("#btncopy_clear").click(function () {
                $("#txt_searchpc_text").val("");
            })

            $("#btncopy_query").click(function () {
                $('#tb_selectpctocopy').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>
