<%@ Page Title="" Language="C#" MasterPageFile="~/helpdesk/Pc.master" AutoEventWireup="true" CodeBehind="PC_List.aspx.cs" Inherits="helpdesk.helpdesk.PC_List" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder2" runat="server">

   <script>
       function rf()
       {
           window.location = "../pc_list.aspx";
       }


   </script>
 




    
      










    <div class="panel panel-default">
  <div class="panel-heading"><b>服务器机器搜索</b> 系统采用浏览器Javascript进行分页，只显示最新的500条。请使用服务器搜索进行过滤。</div>
  <div class="panel-body">

       所属组织：<asp:DropDownList runat="server" AutoPostBack="true"  AppendDataBoundItems="true" CssClass="form-control inline" Width="150" ID="ddl_belongto">

             <asp:ListItem Text="--不限--" Value=""></asp:ListItem>
            </asp:DropDownList>


       所属部门：<asp:DropDownList runat="server"  AutoPostBack="true" CssClass="form-control inline" Width="150" AppendDataBoundItems="true" ID="ddl_dept">

             <asp:ListItem Text="--不限--" Value=""></asp:ListItem>
            </asp:DropDownList>
               
          &nbsp;&nbsp;     
  


        状态 <asp:DropDownList CssClass="form-control inline"   runat="server" ID="ddl_usestatus1" AppendDataBoundItems="true" Width="150px" AutoPostBack="true">
                   <asp:ListItem Text="--不限--" Value=""></asp:ListItem>
                    </asp:DropDownList>
        &nbsp;&nbsp;     
        用途 <asp:DropDownList   CssClass="form-control inline"   Width="150px" runat="server" ID="ddl_usetype1" AppendDataBoundItems="true" AutoPostBack="true">
                   <asp:ListItem Text="--不限--" Value=""></asp:ListItem>
                    </asp:DropDownList>
            &nbsp;&nbsp;             
                   
     

        默认数：<asp:DropDownList runat="server"  AutoPostBack="true"  CssClass="form-control inline" Width="100" AppendDataBoundItems="true" ID="ddl_count">
                    <asp:ListItem Text="500" Value="500"></asp:ListItem>
            <asp:ListItem Text="1000" Value="1000"></asp:ListItem>
            <asp:ListItem Text="1500" Value="1500"></asp:ListItem>
            <asp:ListItem Text="2000" Value="2000"></asp:ListItem>
             <asp:ListItem Text="--不限--" Value=""></asp:ListItem>
            </asp:DropDownList>           
               
                <asp:Button ID="Button1" runat="server" Text="搜索"  
            class="btn btn-primary btn-sm " onclick="Button1_Click"    />




      
      </div>
        </div>  
                  
           
            
         
           
          
    
   
              <div class="well">
          

               
                 <a href="PC_addeditpc.aspx" class="btn  bg-green   btn-flat "    >添加电脑</a>
            
                          

  <a href="javascript:void(0)"; onclick="ept('Export_Data.aspx?types=pc')" class="btn   btn-primary   btn-flat"> 导出</a>
   <a href="javascript:void(0)"; onclick="ept('Import_Data.aspx?types=pc')" class="btn    bg-teal  btn-flat"> 导入</a>
            | 

 <input type="button" id="del"  value="删除" class="btn  btn-flat btn-danger"/>
                
   |
                
<a href="javascript:void(0)";  class="btn bg-aqua   btn-flat" onclick=" if(!getIds(0)) return false; op('change','ajax/pclist_op.aspx?t=usestatus','更改机器在库状态','pc_list.aspx',true); ">更改在库状态...</a>



<a  href="javascript:void(0)"; class="btn bg-teal   btn-flat"   onclick="if(!getIds(0)) return false; op('change','ajax/pclist_op.aspx?t=dept','更改机器使用部门','pc_list.aspx',true);return false;">更改使用部门...</a>



<a  href="javascript:void(0)";  class="btn  bg-purple   btn-flat"   onclick="if(!getIds(0)) return false; op('change','ajax/pclist_op.aspx?t=usetype','更改机器使用用途','pc_list.aspx',true);return false;">更改使用用途...</a>



       <a href="javascript:void(0)";  class="btn  bg-blue   btn-flat"    onclick="if(!getIds(0)) return false; op('change','ajax/pclist_op.aspx?t=os','更改机器操作系统','pc_list.aspx',true);return false;">更改操作系统...</a>





 
 
            
           </div> 
        
         

     


   <div style="margin-top:20px;" >
       
    <asp:GridView ID="gv_list" 
        ClientIDMode="Static" 
        AllowPaging="false"   
        AutoGenerateColumns="false" 
        runat="server"   
        EnableViewState="false"
        GridLines="None"
        AllowSorting="True" 
        CssClass="table table-hover display"
        onrowdatabound="gv_list_RowDataBound" OnPreRender="gv_list_PreRender"> 
    <Columns>
    


    <asp:BoundField  HeaderText="使用部门" DataField="dept"    HeaderStyle-Width="100px"   />
        <asp:BoundField  HeaderText="所属机构" DataField="belongto"    HeaderStyle-Width="80px"   />
  
    
         <asp:TemplateField>
             <HeaderStyle Width="80px" />
             <HeaderTemplate>机器名</HeaderTemplate>
             <ItemTemplate>
 <a  href="javascript:void(0);" class="pcid"   pcid="<%# Eval("id") %>" ><%# Eval("pcname") %></a>

             </ItemTemplate>

         </asp:TemplateField>

    

    <asp:BoundField  HeaderText="使用者" DataField="enduser"    HeaderStyle-Width="100px"   />

    <asp:BoundField  HeaderText="制造商" DataField="mainboardmanufacture"    HeaderStyle-Width="100px"   />

        
    <asp:BoundField  HeaderText="使用状态" DataField="usestatus"    HeaderStyle-Width="100px"   />
    <asp:BoundField  HeaderText="机器用途" DataField="usetype"    HeaderStyle-Width="80px"   />
    <asp:BoundField  HeaderText="操作系统" DataField="os"    HeaderStyle-Width="100px"   />
    
    <asp:BoundField  HeaderText="保修日期" DataField="expiredate"   DataFormatString="{0:yyyy-MM-dd}"   HeaderStyle-Width="100px"   />
  


           <asp:TemplateField>
             <HeaderStyle Width="40px" />
             <HeaderTemplate>查看</HeaderTemplate>
             <ItemTemplate>
 <a  href="PC_addeditpc.aspx?id=<%# Eval("id") %>" target="_blank" >查看</a>

             </ItemTemplate>

         </asp:TemplateField>

    </Columns>
    
    </asp:GridView>
   
   
   </div>   



  
  
   
  
   











     










  




        <input type="hidden" name="hf_ids" id="hf_ids" />

 










    <script>


  

        

        $(".pcid").click(

           function () {
               var pcid = $(this).attr("pcid");
               var _detail = GetAjaxCall(pcid);
              

               layer.open({
                   type: 1,
                   skin: 'layui-layer-rim', //加上边框
                   area: ['600px', '350px'], //宽高 
                  
                   content: formatStr(_detail)
               });
                
           });

         

        function formatStr(_detail) {
            var result = "<table class=table>";
         
            result += "<tr>"
            result += "<th>机器名:</th><td>" + _detail.pcname + "</td>";
            result += "<th>使用者:</th><td>" + _detail.enduser + "</td>";
            result += "</tr>";


            result += "<tr>"                
            result += "<th>IP:</th><td>" + _detail.ip + "</td>";
            result += "<th>MAC地址:</th><td>" + _detail.mac + "</td>";
            result += "</tr>";


            result += "<tr>"
            result += "<th>CPU:</th><td>" + _detail.cpu + "</td>";
            result += "<th>内存:</th><td>" + _detail.mem + "</td>";
            result += "</tr>";



            result += "<tr>"
            result += "<th>型号:</th><td>" + _detail.spec + "</td>";
            result += "<th>硬盘:</th><td>" + _detail.harddisk + "</td>";
            result += "</tr>";


            result += "<tr>"
            result += "<th>鼠标:</th><td>" + _detail.mouse + "</td>";
            result += "<th>键盘:</th><td>" + _detail.keywoard + "</td>";
            result += "</tr>";


            result += "<tr>"
            result += "<th>显示器:</th><td>" + _detail.display + "</td>";
            result += "<th>网卡:</th><td>" + _detail.netcard + "</td>";
            result += "</tr>";

            result += "<tr>"
            result += "<th>声卡:</th><td>" + _detail.sound + "</td>";
            result += "<th>光驱:</th><td>" + _detail.cd + "</td>";
          
            result += "</tr>";
         
            result += "</table>";
            return result;
        }




         
        function GetAjaxCall(pcid)
        {

            for (var i = 0; i < details.length; i++) {
               
                if (details[i].id == pcid) { 
                    return details[i];
                }
            }

        }
      








        $(document).ready(function () {
           $('#gv_list').dataTable(
               {
                   stateSave: false, 
                   "lengthMenu": [[20, 40, 50], [20,40,50]] 
               }
               );
             

        

            $('#gv_list tbody').on('click', 'tr', function () {

                $(this).toggleClass('selected');

            });


           


            $('#del').click(_del);
            $('#del2').click(_del);
        });



        function _del()
        {
            getIds(1);
            if ($("#hf_ids").val() == "")
            {
                              return;
            }

         
            $.ajax("ajax/del_pc.aspx?ids=" + escape($("#hf_ids").val()));


        }



        function getIds(isdel) {

           var table = $('#gv_list').DataTable();
            _rows = table.rows('.selected').data();
               
            var ids = "";

                 
            if (_rows.length==0)
            {
                alert("请先选择需要操作的行");
                $("#hf_ids").val("");
                 return false;
            }
            else {
                    

                for (var i = 0; i < _rows.length; i++) {
                    var pattern = /(\w+)=(\w+)/ig;//定义正则表达式 
                    var _row = _rows[i][9];                        
                    _row.replace(pattern, function (a, b, _id) {
                        ids+=_id+";"
                    });

                }
            }
            $("#hf_ids").val(ids);

            if (isdel == "1")
            {
                table.row('.selected').remove().draw();

            }

            return true;


        }
    </script>














      
    <ul class="dropdown-menu" id="contextMenu">
        <li>
            <a href="PC_addeditpc.aspx"  >添加新电脑</a>    
        </li>
        <li>
            <a href="javascript:void(0);" id="del2">删除</a>    
        </li>
        <li>
            <a  href="javascript:alert('暂不可用');"  style="color:gray" id="changedept">更改使用部门...</a>    
        </li>
          <li>
            <a  href="javascript:alert('暂不可用');" style="color:gray"   id="changestatus">更改使用状态...</a>    
        </li>
</ul>





    <script>


        function showpara(_contId, _txtId) {

            layer.open({
                type: 1,
                skin: 'layui-layer-rim', //加上边框
                area: ['420px', '240px'], //宽高
                content: formatStr($("#" + _contId).html(), _txtId)
            });

        }
      


        //文档对象注册鼠标按下事件；
        $(document).on("mousedown", function (event) {
            //button等于0代表左键，button等于1代表中键
            if (event.button == 0 || event.button == 1) {
               
                if (event.target.nodeName.toLowerCase() == "a") {
                }
                else { 
                    $("#contextMenu").hide();//获取菜单停止动画，进行隐藏使用淡出效果
                }
            }
        });
 



        //文档对象注册上下文（右键）菜单事件
        $("#gv_list tbody tr").on("contextmenu", 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();//阻止浏览器与事件相关的默认行为；此处就是弹出右键菜单
        });
    </script>








</asp:Content>
