<%@ page contentType="text/html;charset=UTF-8" %>
<%@ page import="net.sz600.tool.SzConvert" %>
<%@ page import="net.sz600.system.*" %>
<%@ page import="net.sz600.formEngine2.*" %>
<%@ page import="net.sz600.formEngine.*" %>
<%@ page import="net.sz600.formCreate.*" %>
<%@ include file="/xml/formEngine2/sessionInfo2.jsp"%>
<html>
<body>
<link href="<%=strSkin_SESSION%>/css2007.css" rel="stylesheet" type="text/css">
<%
    String sOPERATOR = SzConvert.toSpaceStr(request.getParameter("OPERATOR"));
    String sRelate = SzConvert.toSpaceStr(request.getParameter("relate"));
    String sObjectType = SzConvert.toSpaceStr(request.getParameter("ObjectType"));
    
    BdListSelect bdListSelect = new BdListSelect();
		BdListSelectInfo info = null;
		info = bdListSelect.getInfo(sRelate);

		if (sOPERATOR.equals("add")) {
			info.setGLTJ("1=1");
		} else if (sOPERATOR.equals("update")) {
		}
    if (sOPERATOR.equals("")) {
    	sOPERATOR = "set";
    }
    String sFormType = (String)session.getAttribute("SzFormType");
%>

<form name="formUpdate" method="post" action="formSave.jsp">
<input type="hidden" name="OPERATOR" value="<%=sOPERATOR%>">
<input type="hidden" name="ObjectType" value="<%=sObjectType%>">

<input type="hidden" name="moduleName1" value="">
<input type="hidden" name="formName1" value="">
<input type="hidden" name="moduleName2" value="">
<input type="hidden" name="formName2" value="">
<%@ include file="/xml/formEngine2/title.jsp"%>
<table width="100%">
  <tr>
    <td>
      <%=SzPageHelp.saveButton()%>
      <%=SzPageHelp.backButton()%>
    </td>
  </tr>
</table>
<table width="600" border="1" bordercolorlight="#C0C0C0" bordercolordark="#FFFFFF" class="tableClass" cellpadding="3" cellspacing="0">
  <tr>
    <td colspan="4" class="trClassTitle2">==列表选择的基本信息设置==</td>
  </tr>         
  <tr>
    <td>关联名称</td>
    <td colspan="3">     
      <input type="text" name="relateName" value="<%=info.getGLSM() %>" <%if (sOPERATOR.equals("update")){%> readonly class="txtClass1R"<%}else {%>class="txtClass1"<%} %>>（字母、下划线、数字）
      <font color="red">*</font>
    </td>
  </tr>
  <tr>

    <td>控件类型</td>
    <td colspan="3">     
      <%
      	String s_id2[] = {"0","1"};
        String s_name2[] = {"下拉列表","radio选择"};
        out.println(SzPageHelp.radio("relateType", s_id2, s_name2, info.getGLLX()));
      %> 
    </td>
  </tr>  
  <tr>
    <td>关联说明</td>
    <td colspan="3"> 
       <input type="text" name="relateDesc" value="<%=info.getGLBZ()%>"  class="txtClass2">
    </td>
  </tr> 
  <tr>
    <td>显示的名称</td>
    <td colspan="3"> 
       <input type="text" name="display" value="<%=info.getDisplay()%>"  class="txtClass1">
       (默认显示"请选择")
    </td>
  </tr>    
  <tr>
    <td colspan="4" class="trClassTitle2">==列表选择的主表信息设置==</td>
  </tr>    
  <tr>
    <td>关联主表</td>
    <td colspan="3">     
       <input type="text" name="tableName" value="<%=info.getGLBM()%>"  class="txtClass2">
       <font color="red">*</font>
    </td>
  </tr>
  
  <tr>
    <td><a href="#" onClick="javascript:SelectWin('field', 'formUpdate.fieldName', 'formUpdate.tableName');" onfocus="javascript:blur();">显示的字段<img src="<%=strLevel_SESSION%>images/share2/select.gif" border="0" ></a></td>
    <td><input type="text" name="fieldName" value="<%=info.getFieldName()%>"  class="txtClass1"> <font color="red">*</font>
    </td>  
    <td nowrap><a href="#" onClick="javascript:SelectWin('field', 'formUpdate.RelateField', 'formUpdate.tableName');" onfocus="javascript:blur();">关联的字段<img src="<%=strLevel_SESSION%>images/share2/select.gif" border="0" ></a></td>
    <td><input type="text" name="RelateField" value="<%=info.getRelateField() %>"  class="txtClass1"> <font color="red">*</font>
    </td>
  </tr>
  <tr>        
    <td>关联条件</td>
    <td colspan="3"> 
       <input type="text" name="tableCond" value="<%=info.getGLTJ()%>"  class="txtClass2">
    </td>        
  </tr>  
  <tr>
    <td colspan="4" class="trClassTitle2">==列表中被关联的字段==</td>
  </tr>  
  <tr>
    <td nowrap><a href="#" onClick="javascript:SelectWin('field','formUpdate.RelateObject', '','formUpdate.moduleName');" onfocus="javascript:blur();">被关联的字段<img src="<%=strLevel_SESSION%>images/share2/select.gif" border="0" ></a></td>
    <td ><input type="text" name="RelateObject" value="<%=info.getRelateObject()%>"  class="txtClass1R" readonly> <font color="red">*</font>
    </td>    
    <td>所属模块</td>
    <td>   
    	<input type="text" name="moduleName" value="<%=info.getModuleName()%>" class="txtClass1R" readonly>  
    </td>      
  </tr>         
<tbody style="display:none;">
  <tr>
    <td colspan="4" class="trClassTitle2">==列表选择的分类信息设置==</td>
  </tr>  
  <tr>
    <td>分类表名</td>
    <td>
     <input type="text" name="cateTable" value="<%=info.getGLGLBM()%>"  class="txtClass1">
    </td>
    <td>      
      <a href="#" onClick="javascript:SelectWin('field', 'formUpdate.cateUser', 'formUpdate.cateTable');">员工ID字段</a>
    </td>
    <td>       
      <input type="text" name="cateUser" value="<%=info.getGLDLID()%>"  class="txtClass1"> 
    </td>    
  </tr> 
  <tr>      
    <td>
      <a href="#" onClick="javascript:SelectWin('field', 'formUpdate.cateID', 'formUpdate.cateTable');">ID字段</a>
    </td>
    <td>      
      <input type="text" name="cateID" value="<%=info.getGLGLID()%>"  class="txtClass1"> 
    </td>
  
    <td>     
      <a href="#" onClick="javascript:SelectWin('field', 'formUpdate.cateName', 'formUpdate.cateTable');">名称字段</a>
    </td>
    <td>       
      <input type="text" name="cateName" value="<%=info.getGLGLMC()%>"  class="txtClass1"> 
    </td>
  </tr> 
  <tr>      
    <td>       
      <a href="#" onClick="javascript:SelectWin('field', 'formUpdate.cateRelate', 'formUpdate.tableName');">关联字段</a>
    </td>
    <td>       
      <input type="text" name="cateRelate" value="<%=info.getFieldType()%>"  class="txtClass1"> 
    </td>   
    <td>     
      查询条件
    </td>
    <td>       
      <input type="text" name="cateCond" value="<%=info.getGLGLTJ()%>"  class="txtClass1"> 
    </td>
  </tr>   
</tbody>

  <tr>
    <td colspan="4" align="center"  class="trClassTitle">          
<!--      <input type="button" value="测试" class="btnClass" OnClick="Test();"> -->  

    </td>  
  </tr>    
</table>

</form>
<script language="javascript" src="../../../share/js/commonTool.js"></script>
<script language="javascript" src="../../../share/js/selectTool.js"></script>
<script language="javascript">

  function FormSave(formName, url) {
    //关联名称不能为空
    if (!notSpace(formUpdate.relateName, "关联名称")) {
      return false;
    }  
    //名称只能为字母数字下划线
    if (!isLetterOrNumOrLine(formUpdate.relateName.value)) {
      alert("关联名称只能是字母数字下划线");
      formUpdate.relateName.focus();
      return false;
    }    
    
    if (!notSpace(formUpdate.tableName, "关联主表")) {
      return false;
    } 
    
    if (!notSpace(formUpdate.fieldName, "显示的字段")) {
      return false;
    } 
    if (!notSpace(formUpdate.RelateField, "关联的字段")) {
      return false;
    } 
    if (!notSpace(formUpdate.RelateObject, "被关联的字段")) {
      return false;
    } 
                
    //tableCond

    if (isSpace(formUpdate.cateTable.value) == false) {
    	if (!notSpace(formUpdate.cateID, "分类ID字段")) {
      		return false;
    	}    
    	if (!notSpace(formUpdate.cateName, "分类名称字段")) {
      		return false;
    	}   
    	if (!notSpace(formUpdate.cateRelate, "分类关联字段")) {
      		return false;
    	}    			
    }   
    
    formUpdate.action = "control.jsp";
    formUpdate.submit();
  }
  
 
</script>
<script language="javascript">
    
  function SelectWin(vType,  vObject, vTableObject, vModuleNameObject) {
		var moduleName = formUpdate.moduleName.value;
    var moduleName1 = formUpdate.moduleName1.value;
    var formName1 = formUpdate.formName1.value;
    var moduleName2 = formUpdate.moduleName2.value;
    var formName2 = formUpdate.formName2.value;    
    var url = "../field_select.jsp?type=" + vType + "&object=" + vObject + "&tableobject=" + vTableObject
            + "&moduleName1=" + moduleName1 + "&formName1=" + formName1
            + "&moduleName2=" + moduleName2 + "&formName2=" + formName2
            + "&moduleNameObject=" + vModuleNameObject; 
    window.showModalDialog(url,window,"status=no;dialogWidth=300px;dialogHeight=370px");  
  }
   
</script>

</body>
</html>
<!-- 
<iframe name="submitName" style='display:none;'></iframe>
 -->
