<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Staff_Select.aspx.cs" Inherits="TotCms.Web.Office.Staff.Staff_Select" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link href="../style/global.css" rel="stylesheet" type="text/css" />
    <script src="../../js/jquery-1.5.1.min.js" type="text/javascript"></script>
    <script src="../../js/jquery-ui-1.8.10/js/jquery-ui-1.8.10.custom.min.js" type="text/javascript"></script>
    <link href="../../js/jquery-ui-1.8.10/css/ui-lightness/jquery-ui-1.8.10.custom.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript">
      $(function () {
        $("#tabs").tabs();
        $("#dialog:ui-dialog").dialog("destroy");
        //dept window
        $("#dialog-dept").dialog({
          autoOpen: false,
          height: 220,
          width: 270,
          modal: false,
          buttons: {
            "确定": function () {
              $(this).dialog("close");
            },
            "取消": function () {
              $(this).dialog("close");
            }
          },
          close: function () {

          }
        });

        $("#selclass").click(function () {
          $("#dialog-dept").dialog("open");
        });
      });

      function CloseFrame() {
        $("#dialog-dept").dialog("close");
      }

      function SearchStaff() {
        var orgid = 0;
        var deptid = $('#CategoryId')[0].value;
        var username = $('#UserName')[0].value;
        if (username != '') username = encodeURIComponent(username);
        var childs = document.getElementById('Staffs');
        childs.length = 0;
        $.ajax({
          url: 'Staff_Gets.aspx?orgid=' + orgid + '&deptid=' + deptid + '&username=' + username,      //异步方法
          type: 'get',
          dataType: 'xml',
          timeout: 5000,                            //延迟1秒执行
          error: function () {                        //返回失败后
            alert('载入出错了，再稍后再试.');
          },
          success: function (xml) {              //返回成功
            var strbox = '';
            $(xml).find("category").each(function () {         //找到根节点
              var id = $(this).children("id").text();
              var tt = $(this).children("title").text();
              var ofs = childs.length;
              childs.options[ofs] = new Option(tt, id);              
            });            
          }
        });
      }

      function GetDept(pid, cid, did) {
        var retValue, i, sele;
        var childs = document.getElementById(did);
        childs.length = 0;
        //ajax
        $.ajax({
          url: '../Dept/GetDeptByOrg.aspx?classid=' + pid,      //异步方法
          type: 'get',
          dataType: 'xml',
          timeout: 5000,                            //延迟1秒执行
          error: function () {                        //返回失败后
            alert('载入出错了，再稍后再试.');
          },
          success: function (xml) {              //返回成功
            $(xml).find("category").each(function () {         //找到根节点
              var id = $(this).children("id").text();
              var tt = $(this).children("title").text();
              var ofs = childs.length;
              childs.options[ofs] = new Option(tt, id);
              if (parseInt(id) == parseInt(cid)) {
                childs.options[ofs].selected = true;
              }
            });
          }
        });
      }
      function GetVal() {
        var opts = document.getElementById('Staffs');
        var values = '';
        var txts = '';
        for (var i = 0; i < opts.length; i++) {
          if (opts.options[i].selected) {
            values +=opts.options[i].value+',';
            txts += opts.options[i].text+',';            
          }
        }
        values = values.substring(0, values.length - 1);
        txts = txts.substring(0, txts.length - 1);
        //return value
        parent.ReturnValue(values, txts);
      }
    </script>
</head>
<body>
    <form id="form1" runat="server">  
    <div id="dialog-dept" title="选择部门" style="display:none;">
	    <iframe src="../Dept/GetTree.aspx" width="100%" height="170" frameborder="0" scrolling="auto"></iframe>	
    </div>  
    <table cellpadding="0" cellspacing="1" border="0" width="100%" class="border">            
      <tr class="suphead">
        <td colspan="2">选择员工</td>
      </tr>
      <tr class="lines">
      <td>
      部门：</td>
      <td  style="text-align:left;">
        <asp:TextBox ID="CategoryId" runat="server" CssClass="hidden"></asp:TextBox>
          <asp:TextBox ID="CategoryTitle" runat="server" ReadOnly="True"></asp:TextBox>
          <input id="selclass" name="selclass" type="button" value="请选择" class="selclass" />
        </td>
      </tr>
      <tr class="lines">
      <td>
        姓名：</td>
      <td  style="text-align:left;">
        <input id="UserName" class="input_mini" type="text" /><input 
          id="Submit2" type="button" value="查询" onclick="SearchStaff()" /></td>
      </tr>
      <tr class="lines">
      <td>
        列表：</td>
      <td style="text-align:left;">
        <div id="CbListDiv">
        <asp:Literal ID="CbList" runat="server"></asp:Literal>
          <br />
          提示：按Ctrl+鼠标左键实现多选.</div>
        </td>
      </tr>
      <tr class="lines">
      <td colspan="2">
        <input id="Button1" type="button" value="选择" onclick="GetVal()" /></td>
      </tr>
      </table>
    </form>
</body>
</html>
