<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Dept_Select.aspx.cs" Inherits="TotCms.Web.Office.Dept.Dept_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 id="Head1" 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 type="text/javascript">
      function SearchStaff() {
        var orgid = $('#OrgId')[0].value;
        var deptid = $('#DeptId')[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('DeptId');
        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">    
    <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;">
        <div id="CbListDiv">
        <asp:Literal ID="Literal2" 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>

