<%@ page contentType="text/html; charset=GBK"  errorPage="../../../error.jsp" %>
<%@ page import = "zr.zrpower.collectionengine.service.ConfigService"%>

<%@ page import = "zr.zrpower.common.web.SelectBox" %>
<%@ page import = "zr.zrpower.entity.sys.SessionUser" %>
<%@ page import = "zr.zrpower.collectionengine.CollectionInfo" %>
<%@ page import = "zr.zrpower.ejb.sys.UIService" %>
<%@ page import = "java.util.*" %>
<%@ page import = "java.text.*" %>

<%
ConfigService configManage = new ConfigService();
UIService userUI =new UIService();
SessionUser user = (SessionUser)session.getAttribute("userinfo");
SelectBox sb = new SelectBox(configManage.getTableList());
%>
<HTML>
<HEAD>
<TITLE>配置文件添加</TITLE>
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META http-equiv="Content-Type" content="text/html; charset=gb2312">
<LINK type="text/css" rel="stylesheet" href="../../../zrsysmanage/css/<%=user.getUserCSS()%>">
<SCRIPT type='text/javascript' src="../../../zrsysmanage/script/Public.js" ></SCRIPT>
<script type='text/javascript' src='../../../dwr/engine.js'></script>
<script type='text/javascript' src='../../../dwr/util.js'></script>
<script type='text/javascript' src='../../../dwr/interface/CollConfigBean.js'></script>
<%if("6".equals(user.getUserWINDOWTYPE())){ %>
<SCRIPT LANGUAGE="JavaScript" src="../../../zrsysmanage/html5/script/jquery-2.0.3.min.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript" src="../../../zrsysmanage/html5/layer/layer.js"></SCRIPT>
<%}%>
<script type="text/javascript">
<!--
// 加载字段下拉列表。
    function loadFieldList(tableid){
        if(tableid==null||tableid==''){
        clearFieldSel();
        return;
        }

        CollConfigBean.getFieldList(tableid,
        function(items){
              clearFieldSel();
              dwr.util.addOptions("OTHERFIELD",items,0,1);
        }
        );

    }

    function clearFieldSel(){
        dwr.util.removeAllOptions("OTHERFIELD");
    }
// 加载字段下拉列表。
    function loadFieldList1(tableid){
        if(tableid==null||tableid==''){
        clearFieldSel1();
        return;
        }

        CollConfigBean.getFieldList(tableid,
        function(items){
              clearFieldSel1();
              dwr.util.addOptions("PHOTOFIELD",items,0,1);
              dwr.util.addOptions("PHOTOCFIELD",items,0,1);
              dwr.util.addOptions("PHOTOMFIELD",items,0,1);
        }
        );


    }

    function clearFieldSel1(){
        dwr.util.removeAllOptions("PHOTOFIELD");
        dwr.util.removeAllOptions("PHOTOCFIELD");
        dwr.util.removeAllOptions("PHOTOMFIELD");
    }
//有效性检查
function Check(theForm){
  if (theForm.DOCNAME.value == ""){

    <%if("6".equals(user.getUserWINDOWTYPE())){%>
    parent.layer.alert('文档名称不能为空!', {icon: 7});
    <%}else{%>
    alert("文档名称不能为空！");
    <%}%>
    theForm.DOCNAME.focus();
    document.RegForm.reset();
    return;
  }


if(theForm.OTHERFIELD.value=="")
{

   <%if("6".equals(user.getUserWINDOWTYPE())){%>
    parent.layer.alert('请选择关联主键!', {icon: 7});
    <%}else{%>
    alert("请选择关联主键");
    <%}%>
   theForm.OTHERFIELD.focus();
       return false;
}
 document.RegForm.submit();
}
function bak()
{
  window.location.href='List.jsp';
}
function ShowModalTableTree()
{
  var url="SelectTableTree.jsp";
  var status="dialogHeight:450px;dialogWidth:250px;status:0;help:no;center:yes";
  <%if("6".equals(user.getUserWINDOWTYPE())){%>
  layer.open({
  type: 2,
  area: ['250px', '450px'],
  fix: false, //不固定
  maxmin: false,//是否可以最大化
  content: url+'?zdid=MAINTABLE'
});
  <%}else{%>
  var rtnResult=window.showModalDialog(url,window,status);
  if (rtnResult!=null)
  {
     document.RegForm.MAINTABLE.value = rtnResult;
     loadFieldList(rtnResult);
  }
  <%}%>
}



setTimeout("loadFieldList(document.RegForm.MAINTABLE.value);",600);
-->
</script>
</HEAD>
<BODY class="BodyMain">
<form action="../../../actionconfigmsg.do" method="post" name="RegForm" enctype="multipart/form-data" onsubmit="return Check(this);">
<input type="hidden" name="DOCTYPE" value="1">

<DIV id="divMessage" style='padding-left:0;padding-top:0;width:100%;height:100%;overflow:auto'>
<br>&nbsp;
           <fieldset style="width: 98%">
           <legend>新建配置文件</legend>
            <TABLE  width="100%" align="center" border="0">
             <TR>
             <TD colspan=2 height=5>
             <input type="hidden" name="Act" value="add" />
             </TD>
             </TR>
             <TR>
               <TD class="PutdSet" width="15%">文档名称：</TD>
               <TD><input class="text" type="text" name="DOCNAME"  id="DOCNAME" size="80" maxlength="200"><Font class="WriteSign">&nbsp;*</Font></TD>
             </TR>


             <TR>
               <TD class="PutdSet" width="15%">绑定数据表：</TD>
               <TD>


                 <table cellspacing="0" cellpadding="0" border='0'><tr>
                 <td>
                 <select style="width:280px" name="MAINTABLE"  id="MAINTABLE" onchange="loadFieldList(this.value)">
                  <%=sb.show()%>
                   </select>
                 </td>
                 <%=userUI.ClickButton("选择","JavaScript:ShowModalTableTree();","buttonSelect.gif",user.getUserImage())%>
                 </tr></table>


               </TD>
             </TR>
              <TR>
               <TD class="PutdSet" width="15%">关联主键：</TD>
               <TD><select style="width:280px" name="OTHERFIELD" id="OTHERFIELD"></select></TD>
             </TR>


          <TR>
               <TD colspan=2 height=23></TD>
             </TR>
           </TABLE>
            <br>
          </fieldset>
            <center><br>
                 <table cellspacing="0" cellpadding="0" border='0'><tr>
                 <%=userUI.ClickButton("保存","JavaScript:if(Check(document.RegForm)){document.RegForm.submit();}","buttonSave.gif",user.getUserImage())%>
                 <%=userUI.ClickButton("返回","JavaScript:bak();","buttonReturn.gif",user.getUserImage())%>
                 </tr></table>
                 </center>
          </DIV>


</FORM>
</BODY>
</HTML>
<%
//清空相关对象
user = null;
userUI = null;
configManage = null;
sb = null;
%>
