<%@ page contentType="text/html;charset=UTF-8" %>
<%@ page import="java.util.Iterator" %>
<%@ page import="java.util.Collection" %>
<%@ page import="java.util.Map" %>
<%@ page import="net.sz600.tool.SzConvert" %>
<%@ page import="net.sz600.database.SzPageInfo" %>
<%@ page import="net.sz600.system.SzProperties" %>
<%@ page import="net.sz600.system.SzPageHelp" %>
<%@ page import="net.sz600.system.SzLevelNumber" %>
<%@ page import="net.sz600.organize.*" %>
<%@ include file="/sessionInfo.jsp"%>
<body>
<%
    //只列出有部门的登陆帐号2008-01-03

    //type=all没有限制，same同一部门，tree树下的子部门
    String type = SzConvert.toSpaceStr(request.getParameter("type"));
    if (type.equals("")) {
        type = "all"; //默认是全部
    }
    String objId = SzConvert.toSpaceStr(request.getParameter("objId"));
    String objName = SzConvert.toSpaceStr(request.getParameter("objName"));
    String objDesc = SzConvert.toSpaceStr(request.getParameter("objDesc"));
    String objDescName = SzConvert.toSpaceStr(request.getParameter("objDescName"));
%>
<%@ include file="/share/organize/user_js_include.jsp"%>
<table width="550" align="center">
  <form name="formSelect" method="post">
  <input type="hidden" name="objId" value="<%=objId%>">
  <input type="hidden" name="objName" value="<%=objName%>">
  <input type="hidden" name="objDesc" value="<%=objDesc%>">
  <input type="hidden" name="objDescName" value="<%=objDescName%>">
  <tr>
    <td colspan="3"><!----------这里显示部门-------->
      <select name="DepartSelecting" style="width:250;" OnChange="SelectDepart();">
        <option value="">=====请选择部门=====</option>
<%
    //读取部门
    Collection collDepart = SzUserHelp.getDepartStaticList();
    SzDepartInfo szDepartInfo = new SzDepartInfo();
    Iterator iterDepart = null;

    if (collDepart != null) {
        iterDepart = collDepart.iterator();
    }
    String sBMMC = "";
    while (iterDepart!=null && iterDepart.hasNext()) {
        szDepartInfo = (SzDepartInfo)iterDepart.next();
        sBMMC = SzLevelNumber.getLevelSpace(szDepartInfo.getBMBH()) + szDepartInfo.getBMMC();
        //sBMMC = szDepartInfo.getBMMC();
%>
        <option value="<%=szDepartInfo.getBMID()%>"><%=sBMMC%></option>
<%
    }
%>
      </select>
    </td>
  </tr>
  <tr>
    <td width="150" align="right">
      <select name="LoginSelecting" size="15" style="width:250;" OnDblClick="MoveToRight(formSelect.LoginSelecting, formSelect.LoginSelected);">
      </select>
    </td>
    <td width="50">
      <table>
        <tr><td><input type="button" name="btnToRight" value=" >"  OnClick="MoveToRight(formSelect.LoginSelecting, formSelect.LoginSelected);"></td></tr>
        <tr><td><input type="button" name="btnToLeft"  value=" <"  OnClick="MoveToLeft(formSelect.LoginSelected, formSelect.LoginSelecting);"></td></tr>
      </table>
    </td>
    <td width="150" align="left">
      <select name="LoginSelected" size="15" style="width:250;" OnDblClick="MoveToLeft(formSelect.LoginSelected, formSelect.LoginSelecting);">
      </select>
    </td>
  </tr>
  <tr>
    <td colspan="3" align="center">
      <input type="button" name="btnOk" value="确定" OnClick="javascript:FunOk();">
      <input type="button" name="btnClose" value="关闭" OnCLick="javascript:window.close();">
    </td>
  </tr>
  </form>
</table>
</body>
<script language="javascript" src="../../share/js/selectTool.js"></script>
<script language="javascript">
  function FunOk() {

    //确定，获取
    var vId = "0";
    var vName = "";
    var vDesc = "";
    var vDescName = "";
    var j = 0;
    var oSelect = formSelect.LoginSelected;
    var iLen = oSelect.options.length;

    //这里是单个的选择，
        //部门ID
    var iSelected = formSelect.DepartSelecting.selectedIndex;
    vDesc     = formSelect.DepartSelecting.options(iSelected).value;
    vDescName = formSelect.DepartSelecting.options(iSelected).text;

    for(var i =0; i<iLen; i++) {
      if (i==0) {
        vName = oSelect.options(i).text;
        vId   = oSelect.options(i).value;
        j = 1;
        break;
      }
    }
    var objId   = formSelect.objId.value;
    var objName = formSelect.objName.value;
    var objDesc = formSelect.objDesc.value;
    var objDescName = formSelect.objDescName.value;

    var oWindow = window.dialogArguments;
    if (j == 1) {
      eval("oWindow." + objId + ".value='" + vId + "';");
      eval("oWindow." + objName + ".value='" + vName + "';");
      if (objDesc != "") {
          eval("oWindow." + objDesc + ".value='" + vDesc + "';");
      }
      if (objDescName != "") {
          eval("oWindow." + objDescName + ".value='" + vDescName + "';");
      }
    } else {
      eval("oWindow." + objId + ".value='';");
      eval("oWindow." + objName + ".value='';");
      if (objDesc != "") {
          eval("oWindow." + objDesc + ".value='';");
      }
      if (objDescName != "") {
          eval("oWindow." + objDescName + ".value='';");
      }
    }
    window.close();
  }
</script>

<script language="javascript">
  //初始化的时候，默认不显示全部的员工。选择部门后才显示员工
  //ShowAllLogin();
  //formSelect.DepartSelecting.click();
  //window.status = formSelect.DepartSelecting.clientX;
  //alert(formSelect.DepartSelecting.clientX)

</script>
