<%@ page contentType="text/html;charset=gbk" %>
<%@ page import="java.util.Iterator" %>
<%@ page import="java.util.Collection" %>
<%@ page import="java.util.HashMap" %>
<%@ page import="net.sz600.tool.SzConvert" %>
<%@ page import="net.sz600.basicdata.*" %>
<%@ page import="net.sz600.formEngine2.*" %>
<%@ include file="/sessionInfo.jsp"%>
<%
    //获取提交的参数
    String sRelateID = SzConvert.toZeroStr(request.getParameter("type"));
	sRelateID = "50"; //指到主合同的关联
    String objId = "formUpdate.D1XXID3";
    String objName = "formUpdate.D1XXID3";
    String strForm = ""; //这个有的话要submit();

	int iPInfoId = SzConvert.toInt(request.getParameter("PKEY"));		//授信
    int iPFormID = SzConvert.toInt(request.getParameter("PFORM"));
    //String sKEY =  SzConvert.toZeroStr(request.getParameter("KEY"));    
    //int iFormID = SzConvert.toInt(request.getParameter("FormID"));
    
    BdRelateValue relateValue = new BdRelateValue();
    String field = "S1XXMC5";
    Collection coll = relateValue.getCFieldList(field, iPFormID, iPInfoId, sRelateID, "");
    Iterator iterInfo = coll.iterator();
    String value = "";

%>
<!----------将数据读进JS数组中----------->
<script language="JavaScript">
    var  infoCount;
    infoArray = new Array();
    infoCount = 0;
<%
    while (iterInfo!=null && iterInfo.hasNext()) {
    	value = (String)iterInfo.next();
%>
        //这里的ID改成名字
        infoArray[infoCount] = new Array("<%=value%>");
        infoCount++;
<%
    }
%>

  //将全体员工放进InfoSelecting
  function ShowAllInfo() {
    formSelect.InfoSelecting.length = 0;
    for (var i=0; i<infoCount; i++) {
      formSelect.InfoSelecting.options[formSelect.InfoSelecting.length]
      = new Option(infoArray[i][0], infoArray[i][0]);
    }
  }
  
  function SearchOk() {
    var vValue = "";
    var vSearch = formSelect.txtSearch.value;
    
    if (vSearch == "") {  
      ShowAllInfo();          
    } else {
      formSelect.InfoSelecting.length = 0;
      for (var i=0; i<infoCount; i++) {
        var vValue = infoArray[i][0];
        if (vValue.indexOf(vSearch) > -1) {
      	  formSelect.InfoSelecting.options[formSelect.InfoSelecting.length]
      	  = new Option(infoArray[i][0], infoArray[i][0]);      
        }	
      }      
    }	
  }  
</script>

<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="formName" value="<%=strForm%>">
  <tr>
    <td colspan="3"><!----------这里显示部门-------->
      
      查找：<input type="text" name="txtSearch" class="txtClass1">
          <input type="button" class="btnClassSearch" value="查找" OnClick="SearchOk();">
    </td>
  </tr>
  <tr>
    <td width="150" align="right">
      <select name="InfoSelecting" size="15" style="width:250;" OnDblClick="MoveToRight(formSelect.InfoSelecting, formSelect.InfoSelected);">
      </select>
    </td>
    <td width="50">
      <table>
        <tr><td><input type="button" name="btnToRight" value=" >"  OnClick="MoveToRight(formSelect.InfoSelecting, formSelect.InfoSelected);"></td></tr>
        <tr><td><input type="button" name="btnToLeft"  value=" <"  OnClick="MoveToLeft(formSelect.InfoSelected, formSelect.InfoSelecting);"></td></tr>
      </table>
    </td>
    <td width="150" align="left">
      <select name="InfoSelected" size="15" style="width:250;" OnDblClick="MoveToLeft(formSelect.InfoSelected, formSelect.InfoSelecting);">
      </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" src="../../share/js/selectTool.js"></script>
<script language="javascript">

  
  function FunOk() {
    //确定，获取
    var vName = "";
    var vId = "0";
    var j = 0;
    var oSelect = formSelect.InfoSelected;
    var iLen = oSelect.options.length;

    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;

    var oWindow = window.dialogArguments;
    if (j == 1) {
      if (objName != "") {
        eval("oWindow." + objName + ".value='" + vName + "';");
      }
      if (objId != "") {
        eval("oWindow." + objId + ".value='" + vId + "';");
      }
    } else {
      /*
      if (objName != "") {
        eval("oWindow." + objName + ".value='';");
      }
      if (objId != "") {
        eval("oWindow." + objName + ".value=0;");
      }
      */
    }
    
    //是否需要提交
    var formName = formSelect.formName.value;
    if (formName != "") {
      eval("oWindow." + formName + ".submit();");
    }
    window.close();
  }
</script>
<script language="javascript">
  //初始化的时候
  ShowAllInfo();
</script>