<%@ Page Language="C#" ValidateRequest="false"  MasterPageFile="~/helpdesk/Pc.master" EnableEventValidation="false"  AutoEventWireup="true" CodeBehind="Pc_Scan_Hardware.aspx.cs" Inherits="helpdesk.helpdesk.Pc_Scan_Hardware" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder2" runat="server">
 
  
     <div class="alert form-inline" style="border:solid 1px #ccc">
  说明：硬件扫描通过VBS域登录脚本实现，具体配置请参考<a href="scan_help.htm" target="_blank">此处</a>,点击此处下载<a href=../VBS/custom_login_scan_hardware.vbs>VBS</a>脚本.

         &nbsp;&nbsp;&nbsp;&nbsp;
         你也可以通过EXE获取 点击下载
         <a href=../VBS/pcinfo.rar>PcInfo.rar</a>

          &nbsp;&nbsp;&nbsp;&nbsp;
              关键字 <asp:TextBox placeholder=" 机器名/使用者/型号/IP/服务编号 " runat="server"  ClientIDMode="Static" ID="txt_key" CssClass="form-control" style="width:230px; display:inline-block" ></asp:TextBox>
         
   <asp:Button runat="server" ID="btn_export" Text="导出" CssClass="btn btn-success btn-flat" OnClick="btn_export_Click" />



     </div>


   
    
      <link href="../javascript/datatables/datatables.css" rel="stylesheet" />
      <script src="../javascript/datatables/datatables.min.js"></script>

      

        <style>
      .xxx  {
            background-color: #DFF0D8;  
            font-weight:bold 
            }

    table#tbl_pc { 
             border-collapse:collapse !important;
         }

        </style>
 
   <input  type="hidden" id="hf_trid" name="hf_trid" />



       
  

 <style>
     #tbl_pc td {
      word-break:break-all;
     }
 </style>



        <table   class="table  "  id="tbl_pc"  >
        <thead  >
            <tr>
                 <th width="20px">ID</th>
                  <th width="80px">机器名</th>
                 <th  width="80px">使用者</th> 
                 <th width="80px">BIOS号</th>
                 <th width="130px">BIOS制造商</th>   
                 
                 <th width="120px">主板号</th>

                 <th width="150px">操作系统</th> 
                 <th width="100px">内存</th>
                 <th width="140px">处理器</th>
                 <th width="80px">内核数</th>

                 <th width="200px">硬盘</th> 
                 <th width="60px">IP</th> 
                 <th width="100px">MAC</th>  
                 <th width="130px">扫描日期</th>
            </tr>
        </thead>
    </table>


    <br />



     


     <ul class="dropdown-menu" id="contextMenu">
        
       
           <li>
            <a  href="#" onclick="updateToPc(0); return false;">更新到资产管理（不含登录名）</a>    
        </li>


       <li>
            <a  href="#" onclick="updateToPc(1); return false;">更新到资产管理（含登录名）</a>    
        </li>

          
       
            <li role="separator" class="divider"></li>

      
             <li>
            <a href="#"  onclick="_del(); return false;"  >批量删除</a>    
        </li>
           
   </ul>



     <script>
         
    
      function InitTable() {
          
          var table = $('#tbl_pc').DataTable();
           
         
         if ($.fn.dataTable.isDataTable('#tbl_pc')) {
             table.destroy();
         }
           

         $("#txt_key").keyup(function () { 
             table.ajax.reload(); 
         });
           

 

         //提示信息
         var lang = {
             "sProcessing": "处理中...",
             "sLengthMenu": "每页 _MENU_ 项",
             "sZeroRecords": "没有匹配结果",
             "sInfo": "<b>&nbsp;&nbsp; 每页 20 条 当前显示第 _PAGE_页 共 _PAGES_ 页，共 _TOTAL_ 条</b> (鼠标右键可以同步到资产里)",
             "sInfoEmpty": "当前显示第 0 至 0 项，共 0 项",
             "sInfoFiltered": "(由 _MAX_ 项结果过滤)",
             "sInfoPostFix": "",
             "sSearch": "搜索:",
             "sUrl": "",
             "sEmptyTable": "表中数据为空",
             "sLoadingRecords": "载入中...",
             "sInfoThousands": ",",
             "oPaginate": {
                 "sFirst": "首页",
                 "sPrevious": "上页",
                 "sNext": "下页",
                 "sLast": "末页",
                 "sJump": "跳转"
             },
             "oAria": {
                 "sSortAscending": ": 以升序排列此列",
                 "sSortDescending": ": 以降序排列此列"
             }
         };




         //初始化表格
         table = $("#tbl_pc").dataTable({

             language: lang,  //提示信息
             autoWidth: false,  //禁用自动调整列宽 
             processing: true,  //隐藏加载提示,自行处理
             serverSide: true,  //启用服务器端分页
             searching: false,  //禁用原生搜索
             orderMulti: false,  //启用多列排序
             ordering: true,//禁止排序
             order: [],  //取消默认排序查询,否则复选框一列会出现小箭头
             pageLength: 25,
             lengthMenu: [[20, 50, -1], [20, 50, "All"]],

             dom: 'ifrtp',//lfrtip frtip
             pagingType: "simple_numbers",  //分页样式：simple,simple_numbers,full,full_numbers 
             columnDefs: [{  }],



               
             ajax: function (data, callback, settings) { 
                 var colname = "";
                 var dir = "";
                 if (data.order != "") {
                     colname = data.columns[data.order[0].column]["data"];
                     dir = data.order[0].dir;
                 }
                  
                  
                 $.ajax({
                     type: "GET",
                     url: "ajax_pc/Pc_Scan_Data.aspx",
                     cache: false,  //禁用缓存
                     async: false,
                     data: { 
                         key: escape($("#txt_key").val()),
                       
                         pageIndex: data.start, 
                         pageSize: data.length,
                         dir: dir,
                         colname: colname
                       },
                     
                     dataType: "json", 
                     success: function (result) { 
                         callback(result); 
                     }
                 });
             },
              


             //列表表头字段
             columns: [
                   { "data": "id" },
                  { "data": "pcname" },
                  { "data": "loginname" },
                  { "data": "bios_serialnumber" },
                  { "data": "bios_manufacturer" },
 
                  { "data": "board_serialnumber" },

                  { "data": "os_caption" },
                  { "data": "os_totalvirtualmemorysize" },


                    { "data": "processor" },
                  { "data": "processorcount" },
                   { "data": "disks" },
                  { "data": "ip" },
                  { "data": "mac" },
                   { "data": "createdate" }
             ],



             "columnDefs": [


                 {
 
                 "targets": 7,
                 "render": function (data, type, row, meta) {
                     return  Math.round(data)+"G";
                 }
                 },

                {

                    "targets": 10,
                    "render": function (data, type, row, meta) {
                        return Math.round(data) + "G";
                    }
                }


             ]



         }).api();



       
        
         

      }

         
         

     InitTable();

      
          

 
   
    </script>





      




    

 <script>

   

     $(document).ready(function () { 

         $('#tbl_pc tbody').on('click', 'tr', function () { 
             $(this).toggleClass('xxx'); 
         });

           

         $("#tbl_pc tbody").on("contextmenu", 'tr', function (event) {

             var pageX = event.pageX;//鼠标单击的x坐标
             var pageY = event.pageY;//鼠标单击的y坐标 

             //获取菜单
             var contextMenu = $("#contextMenu");

             var cssObj = {
                 top: pageY + "px",//设置菜单离页面上边距离，top等效于y坐标
                 left: pageX + "px"//设置菜单离页面左边距离，left等效于x坐标
             };

             //判断横向位置（pageX）+自定义菜单宽度之和，如果超过页面宽度及为溢出，需要特殊处理；
             var menuWidth = contextMenu.width();
             var pageWidth = $(document).width();
             if (pageX + contextMenu.width() > pageWidth) {
                 cssObj.left = pageWidth - menuWidth - 5 + "px"; //-5是预留右边一点空隙，距离右边太紧不太美观；
             }

             //设置菜单的位置
             $("#contextMenu").css(cssObj).show();//显示使用淡入效果,比如不需要动画可以使用show()替换;

             event.preventDefault();//阻止浏览器与事件相关的默认行为；此处就是弹出右键菜单

         }); 
     });

      


     //文档对象注册鼠标按下事件；
     $(document).on("mousedown", function (event) {
         //button等于0代表左键，button等于1代表中键
         if (event.button == 0 || event.button == 1) {

             if (event.target.nodeName.toLowerCase() == "a") {

             }
             else {

                 if (event.target.nodeName.toLowerCase() == "div") {
                     $('#tbl_pc tbody tr').removeClass("xxx");
                 }
                 else {
                     $("#contextMenu").hide();
                 }
             }
         }
     });


      

      
      

   </script>






    <script>



        function MakeSureSelect() {
            var checked = 0;
            var result = "";
            var _c = 0; 
            var rows = $("tr.xxx");//table.rows('.selected').data();
             
            for (var i = 0; i < rows.length; i++) {
                checked++;
                var __id = $(rows[i]).find("td:eq(0)").html().trim(); 
                result = __id + "," + result;
            } 
            result = result + "-1";
            if (checked > 0) {
                $("#hf_trid").val(result);
                return true;
            }
            else {
                $("#hf_trid").val("");
                return false;
            }
        }


          
 

 



        function _del() {
         

            MakeSureSelect();
             
            $("#contextMenu").hide();
            _theid = $("#hf_trid").val();

            if (_theid == "") {
                layer.alert('请至少选择一条记录', 12);
                return;
            }
            $("#hf_trid").val(); 
            
            $.ajax({ cache: false, url: "ajax_pc/del_pc_scan.aspx?ids=" + _theid });

            $("tr.xxx").remove();
        }


 


        function updateToPc(isName) { 

            MakeSureSelect();
            $("#contextMenu").hide();
            _theid = $("#hf_trid").val();

            if (_theid == "") {
                layer.alert('请至少选择一条记录', 12);
                return;
            }

            $("#hf_trid").val();

            $.ajax({ cache: false, url: "ajax_pc/update_pc_from_scan.aspx?ids=" + _theid+"&isname="+isName });

            layer.msg("更新成功");


        }


    </script>















    </asp:Content>