<%@ page contentType="text/html;charset=gbk" %>
<%@ page import="java.util.Iterator" %>
<%@ page import="java.util.TreeMap" %>
<%@ page import="net.sz600.tool.SzConvert" %>
<%@ page import="net.sz600.database.SzPageInfo" %>
<%@ page import="net.sz600.system.SzLevelNumber" %>
<%@ page import="net.sz600.system.SzProperties" %>
<%@ page import="net.sz600.system.SzPageHelp" %>
<%@ page import="net.sz600.organize.*" %>
<%@ include file="/sessionInfo.jsp"%>
<%

    String objId = SzConvert.toSpaceStr(request.getParameter("objId"));
    String objName = SzConvert.toSpaceStr(request.getParameter("objName"));
%>
<%
    //读取部门
    SzUserHelp szUserHelp = new SzUserHelp();
    TreeMap map = szUserHelp.getDepartStaticMap();
    Iterator iter = map.values().iterator();
    SzDepartInfo szDepartInfo = new SzDepartInfo();

%>

<table width="350" align="center">
  <form name="formSelect" method="post">
  <input type="hidden" name="objName" value="<%=objName%>">
  <input type="hidden" name="objId" value="<%=objId%>">
  <tr>
    <td colspan="3">请选择系统部门
    </td>
  </tr>
  <tr>
    <td width="150" align="right">
      <select name="DepartSelecting" size="15" style="width:250;" OnDblClick="MoveToRight(formSelect.DepartSelecting, formSelect.DepartSelected);">
<%
    String sBMMC = "";
    while (iter!=null && iter.hasNext()) {
        szDepartInfo = (SzDepartInfo)iter.next();
        sBMMC = SzLevelNumber.getLevelSpace(szDepartInfo.getBMBH()) + szDepartInfo.getBMMC();
%>
        <option value="<%=szDepartInfo.getBMID()%>"><%=sBMMC%></option>
<%
    }
%>
      </select>
    </td>
    <td width="50">
      <table>
        <tr><td><input type="button" name="btnToRight" value=" >"  OnClick="MoveToRight(formSelect.DepartSelecting, formSelect.DepartSelected);"></td></tr>
        <tr><td><input type="button" name="btnToLeft"  value=" <"  OnClick="MoveToLeft(formSelect.DepartSelected, formSelect.DepartSelecting);"></td></tr>
      </table>
    </td>
    <td width="150" align="left">
      <select name="DepartSelected" size="15" style="width:250;" OnDblClick="MoveToLeft(formSelect.DepartSelected, formSelect.DepartSelecting);">
      </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>
<script language="javascript">
  function FunOk() {
    //确定，获取
    var vId = "";
    var vName = "";
    var j = 0;
    var oSelect = formSelect.DepartSelected;
    var iLen = oSelect.options.length;
    //2008-01-06 KEN 注释：最好能把空格去掉
    for(var i =0; i<iLen; i++) {
      if (i==0) {
        vId = oSelect.options(i).value;
        vName = oSelect.options(i).text;
      } else {
        vId += "," + oSelect.options(i).value;
        vName += " " + oSelect.options(i).text;
      }
      j = 1;
    }
    var objId = formSelect.objId.value;
    var objName = formSelect.objName.value;
    //top.dialogArguments.formSelect.GZDLXM.value = "tttttttt";
    var oWindow = window.dialogArguments;
    if (j == 1) {
      if (objId != "") {
          eval("oWindow." + objId + ".value='" + vId + "';");
      }
      if (objName != "") {
          eval("oWindow." + objName + ".value='" + vName + "';");
      }
    } else {
      if (objId != "") {
          eval("oWindow." + objId + ".value='';");
      }
      if (objName != "") {
          eval("oWindow." + objName + ".value='';");
      }
    }
    window.close();
  }
</script>
<script language="javascript" src="../../share/js/selectTool.js"></script>