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

<!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/bootstrap-table/extensions/fixed-column/bootstrap-table-fixed-columns.css"  rel="stylesheet" />
    <link href="Content/toastr/toastr.min.css"  rel="stylesheet" />
</head>
<body>
    <div class="panel-body" style="padding-bottom:0px;">
      
          <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>

        <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>
        <table id="tb_computer"></table>
    </div>

    <!--新增或者编辑的弹出框
    <div class="modal fade" id="myModal" 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:10px;">
                        <label class="control-label col-xs-2">卡号</label>
                        <div class="col-xs-10">
                            <input type="text" name="edtAddCardNo" class="form-control" placeholder="0000000000"/>
                        </div>
                    </div>
                    <div class="row" style="padding:10px;">
                        <label class="control-label col-xs-2">持卡人</label>
                        <div class="col-xs-10">
                            <input type="text" name="edtCardName" class="form-control" placeholder="姓名"/>
                        </div>
                    </div>
                    <div class="row" style="padding:10px;">
                        <label class="control-label col-xs-2">电话</label>
                        <div class="col-xs-10">
                            <input type="text" name="edtCardPhone" class="form-control" placeholder="电话"/>
                        </div>
                    </div>
                    <div class="row" style="padding:10px;">
                        <label class="control-label col-xs-2">证件</label>
                        <div class="col-xs-10">
                            <input type="text" name="edtCardID" class="form-control" placeholder="证件"/>
                        </div>
                    </div>
                    <div class="row" style="padding:10px;">
                        <label class="control-label col-xs-2">地址</label>
                        <div class="col-xs-10">
                           <input type="text" name="edtCardAddr" class="form-control" placeholder="地址"/>
                        </div>
                    </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-edit-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="ModuleComputer" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="staticBackdropLiveLabel" aria-hidden="true">
  <div class="modal-dialog">
    <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>
          <h5 class="modal-title" id="staticBackdropLiveLabel">编辑计算机</h5>
      </div>
      <div class="modal-body">
       
                 <div class="row mt-3">          
                
          <div class="col-sm-2"><label for="edtComputerID" >编码</label> </div>
          <div class="col-sm-10"><input type="text"  id="edtComputerID" name="edtComputerID" class="form-control" placeholder="0000000000"/></div>
           
                   </div>

            <div class="row mt-3">         
                                
          <div class="col-sm-2"><label for="edtComputerGroup" >组号</label> </div>
          <div class="col-sm-4"><input type="text"  id="edtComputerGroup"  name="edtComputerGroup" readonly="true" class="form-control" placeholder="组号" /></div>
   
          <div class="col-sm-2"><label for="edtComputerName" >名称</label> </div>
          <div class="col-sm-4"><input type="text"  id="edtComputerName" name="edtComputerName"  class="form-control" placeholder="名称"  /></div>
              </div>
               
          <div class="row mt-3">    
          <div class="col-sm-2"><label for="edtComputerUserName" >计算机用户名</label> </div>
          <div class="col-sm-4"><input type="text" id="edtComputerUserName"  name="edtComputerUserName" class="form-control" placeholder="计算机用户名"/></div>

          <div class="col-sm-2"><label for="edtComputerUserPwd" >计算机密码</label></div> 
          <div class="col-sm-4"><input type="password"  id="edtComputerUserPwd" name="edtComputerUserPwd"  class="form-control" placeholder="不修改密码不用填写" /></div> 
              
         </div>
          <div class="row mt-3"> 
          <div class="col-sm-2"><label for="edtComputerDomain" >计算机AD域</label></div> 
          <div class="col-sm-10"><input type="text" id="edtComputerDomain"  name="edtComputerDomain" class="form-control" placeholder="计算机AD域" /></div> 
         </div>
          <div class="row mt-3"> 
          <div class="col-sm-2"><label for="edtComputerDomain" >本地域</label></div> 
          <div class="col-sm-10"><input type="text" id="edtPCDomain"  name="edtPCDomain" class="form-control" placeholder="本地域" /></div> 
         </div>
                    <div class="row mt-3"> 
          <div class="col-sm-2"><label for="edtComputerMemo" >备注</label></div> 
          <div class="col-sm-10"><input type="text" id="edtComputerMemo"  name="edtComputerMemo"   class="form-control"/></div> 
         </div>
           <div class="row mt-3"> 
                               
                        <label class="control-label col-xs-2">所属组</label>
                        <div class="col-xs-10">
     
                        <select name="selectgroup" id="selectgroup" class="form-control">
    
                            </select>

                        
          
         </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="pc-sava-edit-btn" class="btn btn-primary"><span class="glyphicon glyphicon-floppy-disk" aria-hidden="true"></span>保存</button>
        
      </div>
    </div>
  </div>
</div>
</div>

<div class="modal fade" id="ModuleLogonUI" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="staticModuleLogonUI" aria-hidden="true">
  <div class="modal-dialog">
    <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>
          <h5 class="modal-title" id="staticModuleLogonUI">编辑登录界面</h5>
      </div>
      <div class="modal-body">
       
                 <div class="row mt-3">          
                
          <div class="col-sm-2"><label for="edtComputerID2" >编码</label> </div>
          <div class="col-sm-10"><input type="text"  id="edtComputerID2" name="edtComputerID2" class="form-control" placeholder="0000000000"/></div>
           
                   </div>

            
            <div class="text-center"> 
                <div class="col-sm-3"></div>
                <div class="col-sm-9">
            <img id="imgshow" width="128" height="128"  src=""/>
            <input type="file" class="form-control" accept="image/*"  id="customFile" style="display: none;" />
            
            <button type="button" class="btn btn-primary btn-lg" onclick="$('#customFile').click()" >选择图片</button>
                <label>请选择jpg或者png图片，标准尺寸128*128</label>
                    </div>
            </div>   
         
          <div class="row mt-3"> 
          <div class="col-sm-2"><label for="edtComputerDomain" >第一行</label></div> 
          <div class="col-sm-10"><input type="text" id="edtLogonUIText1"  name="edtLogonUIText1" class="form-control" placeholder="刷卡登录" /></div> 
         </div>
                    <div class="row mt-3"> 
          <div class="col-sm-2"><label for="edtComputerMemo" >第二行</label></div> 
          <div class="col-sm-10"><input type="text" id="edtLogonUIText2"  name="edtLogonUIText2"   class="form-control" placeholder="友我科技"/></div> 
         </div>
           <div class="row mt-3 "> 
             <div class="col-sm-2"><label for="edtComputerDomain" >密码输入框</label></div> 
          <div class="col-sm-3 form-check">
              <input type="radio" id="showeditauto"  name="showeditauto" value="0"  />
             <label class="form-check-label" for="showeditauto">自动</label>
                </div> 
               <div class="col-sm-3 form-check">
              <input type="radio" id="showedityes"  name="showeditauto"   value="1"  />
             <label class="form-check-label" for="showedityes">一直显示</label>
          </div> 
             <div class="col-sm-3 form-check">
              <input type="radio" id="showeditno"  name="showeditauto"   value="2"  />
             <label class="form-check-label" for="showeditno">不显示</label>
          </div> 
             <div class="col-sm-3 form-check">
              <input type="radio" id="cardkey"  name="showeditauto"   value="3"  />
             <label class="form-check-label" for="cardkey">卡密双验证</label>
          </div> 
         </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="Logonui-sava-edit-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="ModuleComputerConfig" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="staticBackdropLiveLabel" aria-hidden="true">
  <div class="modal-dialog">
    <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>
          <h5 class="modal-title" id="staticLiveLabel">锁屏方式</h5>
      </div>
      <div class="modal-body">
       
                 <div class="row mt-3">          
                
          <div class="col-sm-2"><label for="edtComputerID" >编码</label> </div>
          <div class="col-sm-10"><input type="text"  id="edtConfigComputerID" name="edtConfigComputerID" class="form-control" readonly="true"/></div>
           
                   </div>

         <div class="row mt-3">         
                                
          <div class="col-sm-2"><label >时间超过设定时段计算机的处理方式：</label> </div>
          <div class="col-sm-4">
              <div class="form-check">
              <input type="radio" name="outoftime" class="form-check-input" id="outtime0" value="0" />
              <label class="form-check-label" for="outtime0">不处理</label>
            </div>
                            <div class="form-check">
              <input type="radio" name="outoftime" class="form-check-input" id="outtime1" value="1" />
              <label class="form-check-label" for="outtime1">锁屏</label>
            </div>
                            <div class="form-check">
              <input type="radio" name="outoftime" class="form-check-input" id="outtime2" value="2" />
              <label class="form-check-label" for="outtime2">注销</label>
            </div>
                            <div class="form-check">
              <input type="radio" name="outoftime" class="form-check-input" id="outtime3" value="3" />
              <label class="form-check-label" for="outtime3">关机</label>
            </div>
              <div class="form-check">
              <input type="radio" name="outoftime" class="form-check-input" id="outtime4" value="4" />
              <label class="form-check-label" for="outtime4">关机提示后关机</label>
            </div>

          </div>
         </div>
               
          <div class="row mt-3">         
                                
          <div class="col-sm-2"><label>卡离开时计算机的处理方式：</label> </div>
          <div class="col-sm-4">
              <div class="form-check">
              <input type="radio" name="outofcard" class="form-check-input" id="outcard0" value="0" />
              <label class="form-check-label" for="outcard0">不处理</label>
            </div>
                            <div class="form-check">
              <input type="radio" name="outofcard" class="form-check-input" id="outcard1" value="1" />
              <label class="form-check-label" for="outcard1">锁屏</label>
            </div>
                            <div class="form-check">
              <input type="radio" name="outofcard" class="form-check-input" id="outcard2" value="2" />
              <label class="form-check-label" for="outcard2">注销</label>
            </div>
                            <div class="form-check">
              <input type="radio" name="outofcard" class="form-check-input" id="outcard3" value="3" />
              <label class="form-check-label" for="outcard3">关机</label>
            </div>
              <div   class="form-check" >
              <input type="radio" name="outofcard" class="form-check-input" id="outcard4" value="4" />
              <label class="form-check-label" for="outcard4">关机提示后关机</label>
            </div>

          </div>
         </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="pc-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/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/fixed-column/bootstrap-table-fixed-columns.js"></script>
            <script src="Content/toastr/toastr.min.js"></script>
        <script src="Content/sweetalert/sweetalert.min.js"></script>
        <script type="text/javascript">
            //页面加载完成之后


            $(function () {


                //表格的初始化
                $('#tb_computer').bootstrapTable({
                    url: "Computer.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: false,          //是否显示详细视图和列表视图的切换按钮
                    cardView: false,          //是否显示详细视图
                    showExport: true, //是否显示导出按钮
                    exportDataType: "all",
                    exportTypes: ['excel'], //导出文件类型
                    //注册加载子表的事件。注意下这里的三个参数！
                    onExpandRow: function (index, row, $detail) {
                        InitSubTable(index, row, $detail);
                    },
                    columns: [{
                        checkbox: false,
                        width: 20
                    }, {
                        field: 'ComputerID',
                        title: '编码',
                        width: 100

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

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

                    }, {
                        field: 'ComputerUserName',
                        title: '计算机用户名',
                        width: 200
                    }, {
                    
                        title: '域',
                        width: 300,
                        formatter: function (value, row, index) {//这里的三个参数：value表示当前行当前列的值；row表示当前行的数据；index表示当前行的索引（从0开始）。
                            var html = 'AD域:' + row.ComputerDomain + '<br/>本地域:' + row.ComputerDeviceID;
                                return html;
                            }
                        
                    },
                    {
                        field: 'ComputerMemo',
                        title: '备注',
                        width: 100
                    },
                    {
                        field: 'ComputerAddTime',
                        title: '日期',
                         width: 100
                    },
                    {
                        title: '登录界面',
                        width: 200,
                        formatter: function (value, row, index) {//这里的三个参数：value表示当前行当前列的值；row表示当前行的数据；index表示当前行的索引（从0开始）。
                            var html = '<div align="center"><img width="100" height="100" src="' + row.LogonUIImage + '"><br/>' + row.LogonUIText1 + '<br/>' + row.LogonUIText2 + '</div>';
                    return html;
                }
                    }, {
                        title: '操作',
                        width: 200,
                        formatter: function (value, row, index) {//这里的三个参数：value表示当前行当前列的值；row表示当前行的数据；index表示当前行的索引（从0开始）。

                            var html = '<button type="button" onclick="editModelpc(\'' + row.ComputerID + '\')" class="btn btn-primary"><span class="glyphicon glyphicon-pencil" aria- hidden="true" ></span >编辑信息</button >&nbsp;&nbsp;';
                                     
                            html = html + '<button type="button" onclick="configModelpc(\'' + row.ComputerID + '\')" class="btn btn-warning"><span class="glyphicon glyphicon-lock" aria- hidden="true" ></span >锁屏方式</button >&nbsp;&nbsp;' +
                                       '<button type="button" onclick="configLogonUI(\'' + row.ComputerID + '\')" class="btn btn-success"><span class="glyphicon glyphicon-user" aria- hidden="true" ></span >登录界面</button >&nbsp;&nbsp;';
                            html = html + '<button type="button" onclick="deleteModelpc(\'' + row.ComputerID + '\')" class="btn btn-danger"><span class="glyphicon glyphicon-remove" 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 () {

                        //    }

                        //});
                    }
                });

                
                
                $("#customFile").change(function (e) {
                    //获取目标文件
                    var file = e.target.files || e.dataTransfer.files;
                    //如果目标文件存在
                    if (file) {
                        //定义一个文件阅读器
                        var reader = new FileReader();
                        //文件装载后将其显示在图片预览里
                        reader.onload = function () {
                            $("#imgshow").attr("src", this.result);
                        }
                        //装载文件
                        reader.readAsDataURL(file[0]);
                    }
                });

                //新增事件
                $("#btn_add").on('click', function () {
                    $('#tb_computer').bootstrapTable("resetView");
                    //弹出模态框
                    loadGroupdata();
                    $("#ModuleComputer").modal();
                    //给弹出框里面的各个文本框赋值
                    $("#ModuleComputer input").val("");
                    $("#ModuleComputer input[name='edtComputerID']").prop("readonly", false);
                    $("#ModuleComputer input[name='edtComputerGroup']").prop("readonly", true);
                    $("#ModuleComputer input[name='edtComputerGroup']").val('<%=Session["GroupName"]%>');

                });

            });


            //编辑事件
            var editModelpc = function (id) {
                //根据当前行的id获取当前的行数据
                
                var row = $("#tb_computer").bootstrapTable('getRowByUniqueId', id);
                //弹出模态框
                loadGroupdata(row.PCGroupID);
                $("#ModuleComputer").modal();
                //给弹出框里面的各个文本框赋值
                $("#ModuleComputer input").val("");
                 $("#ModuleComputer input[name='edtComputerID']").prop("readonly", true);
                 $("#ModuleComputer input[name='edtComputerID']").val(row.ComputerID);
                 $("#ModuleComputer input[name='edtComputerGroup']").val(row.ComputerGroup);
                 $("#ModuleComputer input[name='edtComputerName']").val(row.ComputerName);
                 $("#ModuleComputer input[name='edtComputerUserName']").val(row.ComputerUserName);

                 $("#ModuleComputer input[name='edtComputerDomain']").val(row.ComputerDomain);
                 $("#ModuleComputer input[name='edtPCDomain']").val(row.ComputerDeviceID);
                 $("#ModuleComputer input[name='edtComputerMemo']").val(row.ComputerMemo); 


            }




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

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

                

                $("#ModuleLogonUI").modal();
                //给弹出框里面的各个文本框赋值
                //$("#ModuleLogonUI input").val("");
                $("#ModuleLogonUI input[name='edtComputerID2']").prop("readonly", true);
                $("#ModuleLogonUI input[name='edtComputerID2']").val(row.ComputerID);
                console.log("ModuleLogonUI ComputerID=", row.ComputerID);
                $("#imgshow").attr("src",row.LogonUIImage);
                $("#ModuleLogonUI input[name='edtLogonUIText1']").val(row.LogonUIText1);
                $("#ModuleLogonUI input[name='edtLogonUIText2']").val(row.LogonUIText2);

                if (row.LogonUIShowEdit == "1") {
                  
                    $("#ModuleLogonUI input[id='showedityes']").prop('checked', 'true');
                }
                else if (row.LogonUIShowEdit == "2") {
                    
                    $("#ModuleLogonUI input[id='showeditno']").prop('checked', 'true');
                }
                else if (row.LogonUIShowEdit == "3") {
                   
                    $("#ModuleLogonUI input[id='cardkey']").prop('checked', 'true');
                }
                else {
                   
                    $("#ModuleLogonUI input[id='showeditauto']").prop('checked', 'true');
                }

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

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

                $("#ModuleComputerConfig").modal();
                //给弹出框里面的各个文本框赋值

               // $("#ModuleComputerConfig input[name='edtComputerID']").prop("readonly", true);
                $("#ModuleComputerConfig input[name='edtConfigComputerID']").val(row.ComputerID);
                switch (row.outoftime) {
                    case 0: $("#ModuleComputerConfig input[name='outoftime'][value=0]").prop("checked", true); break;
                    case 1: $("#ModuleComputerConfig input[name='outoftime'][value=1]").prop("checked", true); break;
                    case 2: $("#ModuleComputerConfig input[name='outoftime'][value=2]").prop("checked", true); break;
                    case 3: $("#ModuleComputerConfig input[name='outoftime'][value=3]").prop("checked", true); break;
                    case 4: $("#ModuleComputerConfig input[name='outoftime'][value=4]").prop("checked", true); break;
                }
                switch (row.outofcard) {
                    case 0: $("#ModuleComputerConfig input[name='outofcard'][value=0]").prop("checked", true); break;
                    case 1: $("#ModuleComputerConfig input[name='outofcard'][value=1]").prop("checked", true); break;
                    case 2: $("#ModuleComputerConfig input[name='outofcard'][value=2]").prop("checked", true); break;
                    case 3: $("#ModuleComputerConfig input[name='outofcard'][value=3]").prop("checked", true); break;
                    case 4: $("#ModuleComputerConfig input[name='outofcard'][value=4]").prop("checked", true); break;
                }
                
              
                


            }
            //删除事件
            var deleteModelpc = function (id) {
               
                    swal({
                        title: "删除计算机",
                        text: "是否删除编号为" + id + "的计算机?",
                        icon: "warning",
                        // buttons: true,
                        dangerMode: true,
                        buttons:{
                            cancel: '取消',
                            confirm: {
                                text: '删除',
                                value: 'confirm'
                            }
                        }
                    })
    .then((value) => {
        if (value==='confirm') {
                    $.ajax({
                        type: "post",
                        url: "ComputerEdit.ashx",
                        data: {
                            'Edit': "delete",
                            'ComputerID': id

                        },
                        dataType: 'JSON',
                        success: function (data, status) {
                            if (status == "success") {
                                if (data.result == true) {
                                    $("#tb_computer").bootstrapTable("refresh", {
                                        silent: true //静态刷新
                                    });
                                    toastr.success('操作成功');
                                }
                                else {
                                    toastr.error('操作失败');
                                }
                            }
                        },
                        error: function () {
                            toastr.error('操作失败');
                        },
                        complete: function () {

                        }

                    });
            }
            });//then
            }


            $("#pc-sava-edit-btn").click(function () {
                $('#ModuleComputer').modal('hide');

                $.ajax({
                    type: "post",
                    url: "ComputerEdit.ashx",
                    data: {
                        'Edit': $("#ModuleComputer input[name='edtComputerID']").prop("readonly"),
                        'ComputerID': $("#ModuleComputer input[name='edtComputerID']").val(),
                        'ComputerGroup': $("#ModuleComputer input[name='edtComputerGroup']").val(),
                        'ComputerName': $("#ModuleComputer input[name='edtComputerName']").val(),
                        'ComputerUserName': $("#ModuleComputer input[name='edtComputerUserName']").val(),
                        'ComputerUserPwd': $("#ModuleComputer input[name='edtComputerUserPwd']").val(),
                        'ComputerDomain': $("#ModuleComputer input[name='edtComputerDomain']").val(),
                        'PCDomain': $("#ModuleComputer input[name='edtPCDomain']").val(),
                        'ComputerMemo': $("#ModuleComputer input[name='edtComputerMemo']").val(),
                        'PCGroupID': $("#ModuleComputer select[name='selectgroup']").val()
                    },
                    dataType: 'JSON',
                    success: function (data, status) {
                        if (status == "success") {
                            if (data.result == true) {
                                $("#tb_computer").bootstrapTable("refresh", {
                                    silent: true //静态刷新
                                });
                                toastr.success('操作成功');
                            }
                            else {
                                toastr.error('操作失败');
                            }
                        }
                    },
                    error: function () {
                        toastr.error('操作失败');
                    },
                    complete: function () {

                    }

                });
            })


            $("#pc-sava-config-btn").click(function () {
                $('#ModuleComputerConfig').modal('hide');

                $.ajax({
                    type: "post",
                    url: "ComputerLockEdit.ashx",
                    data: {
                        'ComputerID': $("#ModuleComputerConfig input[name='edtConfigComputerID']").val(),
                        'outoftime': $("#ModuleComputerConfig input[name='outoftime']:checked").val(),
                        'outofcard': $("#ModuleComputerConfig input[name='outofcard']:checked").val()

                    },
                    dataType: 'JSON',
                    success: function (data, status) {
                        if (status == "success") {
                            if (data.result == true) {
                                $("#tb_computer").bootstrapTable("refresh", {
                                    silent: true //静态刷新
                                });
                                toastr.success('操作成功');
                            }
                            else {
                                toastr.error('操作失败');
                            }
                        }
                    },
                    error: function () {
                        toastr.error('操作失败');
                    },
                    complete: function () {

                    }

                });
            })

            
           
            $("#Logonui-sava-edit-btn").click(function () {
                $('#ModuleLogonUI').modal('hide');
                

                console.log("showeditauto=", $("#ModuleLogonUI input[name='showeditauto']:checked").val());
                $.ajax({
                    type: "post",
                    url: "ComputerUIEdit.ashx",
                    data: {
                        'ComputerID': $("#ModuleLogonUI input[name='edtComputerID2']").val(),
                        'LogonUIImage': $("#imgshow").attr("src"),
                        'LogonUIText1': $("#ModuleLogonUI input[name='edtLogonUIText1']").val(),
                        'LogonUIText2': $("#ModuleLogonUI input[name='edtLogonUIText2']").val(),
                        'LogonUIShowEdit': $("#ModuleLogonUI input[name='showeditauto']:checked").val()
                    },
                    dataType: 'JSON',
                    success: function (data, status) {
                        if (status == "success") {
                            if (data.result == true) {
                                $("#tb_computer").bootstrapTable("refresh", {
                                    silent: true //静态刷新
                                });
                                toastr.success('操作成功');
                            }
                            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 });
            })

            function loadGroupdata(selectval) {
                $.ajax({
                    url: "PCGroup.ashx",
                    type: 'GET',
                    data: {
                        'edit': 'loadgroup'
                    },
                    async: true,
                    datatype: 'JSON',
                    success: function (data) {
                        if (data) {

                            var groupnames = [];
                            for (var i = 0, len = data.length; i < len; i++) {
                                var groupdata = data[i];
                                //拼接成多个<option><option/>
                                if (selectval == groupdata.ID)
                                    groupnames.push('<option value="' + groupdata.ID + '" selected>' + groupdata.PCGroupName + '</option>');
                                else
                                groupnames.push('<option value="' + groupdata.ID + '">' + groupdata.PCGroupName + '</option>')
                            }
                            $("#selectgroup").html(groupnames.join(' '));
                        }
                    },
                    error: function () {
                        toastr.error("error");
                    }
                });
            }
            toastr.options.positionClass = 'toast-top-center';
        </script>
</body>
</html>
