<%@ page contentType="text/html; charset=GBK" session="false"%>

<%@ taglib uri="/cmsTag" prefix="cms"%>



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<%
			response.setHeader("Pragma", "No-cache");
			response.setHeader("Cache-Control", "no-cache");
			response.setDateHeader("Expires", 0);
		%>
		<title>创建新字段</title>

		<link rel="stylesheet" type="text/css" href="../../style/default/main.css" />

		<!--加载 js -->
		<script type="text/javascript" src="../common/js/jquery-1.7.gzjs"></script>



		<%--<script type="text/javascript" src="../common/js/jquery-1.5.1.min.js"></script>
		--%>
		<script type="text/javascript" src="../javascript/commonUtil.js"></script>
		<script type="text/javascript">
    	$(function()
		{
			switchHtmlElementType('1');
		})
    </script>
	</head>



	<body>
		<form id="filedForm" name="filedForm" method="post">
			<table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#b5d6e6">
				<tr>

					<td height="22" class="head_title">
						<img src="../../core/style/default/images/title_y.gif" />
						<span class="STYLE1">创建新字段</span>
					</td>

				</tr>

				<tr>
					<td>
						<table width="100%" cellspacing=1 cellpadding=0 align=center border="0" bgcolor="#FFFFFF">
							<tr>
								<td>
									<table width="100%" cellspacing=10 cellpadding=1 align=center border="0">
										<tr>
											<td class="title_td" width="12%">
												页面展示形式:
											</td>
											<td width="88%">
												<select id="htmlElementId" name="htmlElementId" onchange="javascript:switchHtmlElementType(this.value)">
													<option value="1" selected>
														文本输入框
													</option>
													<option value="2">
														多行文本框
													</option>
													<option value="3">
														文本编辑器
													</option>
													<option value="4">
														下拉选择框
													</option>
													<option value="5">
														单选框
													</option>
													<option value="6">
														复选框
													</option>
													<option value="7">
														日期选择
													</option>
													<option value="7">
														时间选择
													</option>
													<option value="7">
														日期时间选择
													</option>
													<option value="8">
														文件上传
													</option>
													<option value="9">
														图片上传
													</option>
													<option value="10">
														媒体上传
													</option>
													<option value="11">
														自定义HTML
													</option>




												</select>
											</td>
										</tr>
										<tr>
											<td class="title_td" width="12%">
												字段名称:
											</td>
											<td width="88%">
												<input type="text" size="30" id="showName" name="showName" class="f_input"></input>
											</td>
										</tr>
										<tr>
											<td class="title_td" width="12%">
												字段标识:
											</td>
											<td width="88%">
												<input type="text" size="30" id="filedSign" name="filedSign" class="f_input"></input>
											</td>
										</tr>
										<tr id="defaultValueDIV">
											<td class="title_td" width="12%">
												默认值:
											</td>
											<td width="88%">
												<input type="text" size="30" id="defaultValue" name="defaultValue" class="f_input"></input>
											</td>
										</tr>
										<tr id="defaultValueMultDIV" style="display:none">
											<td class="title_td" width="12%">
												默认值:
											</td>
											<td width="88%">
												<textarea rows="3" cols="13" id="defaultValueMult" name="defaultValueMult" class="f_text"></textarea>
											</td>
										</tr>
										<tr id="mustFillDIV">
											<td class="title_td" width="12%">
												必填项:
											</td>
											<td width="88%">
												<input id="isMustFill" name="isMustFill" type="radio" value="10" />
												<span class="STYLE12">是</span> &nbsp;
												<input id="isMustFill" name="isMustFill" type="radio" value="20" checked />
												<span class="STYLE12">否</span>
											</td>
										</tr>





										<!-- 以下为独立选项 start -->
										<tr id="maxLengthDIV" style="display: none">
											<td class="title_td" width="12%">
												最大字符:
												<!-- 文本 -->
											</td>
											<td width="88%">
												<input type="text" size="15" id="maxLength" name="maxLength" class="f_input" value=60></input>
											</td>
										</tr>

										<tr id="sizeDIV" style="display: none">
											<td class="title_td" width="12%">
												框体大小:
												<!-- 多行文本 -->
											</td>
											<td width="88%">
												<span class="STYLE1"></span><span class="STYLE12">行数</span>
												<input type="text" size="3" id="height" name="height" class="f_input" value="4"></input>
												:
												<span class="STYLE12">列数</span>
												<input type="text" size="3" id="width" name="width" class="f_input" value="6"></input>
											</td>
										</tr>


										<tr id="choiceValueDIV" style="display: none">
											<td class="title_td" width="12%">
												可选值:
												<!-- 下拉框 -->
											</td>
											<td width="88%">
												<textarea id="choiceValue" name="choiceValue" rows="6" cols="35" class="f_text"></textarea>
											</td>
										</tr>

										<tr id="htmlContentDIV" style="display: none">
											<td class="title_td" width="12%">
												HTML代码:
												<!-- 自定义html -->
											</td>
											<td width="88%">
												<textarea id="htmlContent" name="htmlContent" rows="12" cols="55" class="f_text"></textarea>
											</td>
										</tr>

										<tr id="fileTypeDIV" style="display: none">
											<td class="title_td" width="12%">
												允许文件格式:
												<!-- 自定义html -->
											</td>
											<td width="88%">
												<input type="text" size="40" id="allowableFile" name="allowableFile" class="f_input"></input>
												<span class="STYLE12"><font color="red">(多个格式间用逗号隔离)</font> </span>
											</td>
										</tr>




										<!-- 以下为独立选项 end -->
										<tr id="validateDIV">
											<td class="title_td" width="12%">
												验证类型:
											</td>
											<td width="88%">
												<select id="validateType" name="validateType">
													<option value="0">
														无
													</option>
													<option value="1">
														数字
													</option>
													<option value="2">
														整数
													</option>
													<option value="3">
														小数
													</option>
													<option value="4">
														URL
													</option>
													<option value="5">
														邮箱
													</option>
													<option value="6">
														必填
													</option>
												</select>
											</td>
										</tr>

										<tr id="messageDIV">
											<td class="title_td" width="12%">
												提示信息:
											</td>
											<td width="88%">
												<input type="text" size="35" id="errorMessage" name="errorMessage" class="f_input"></input>
											</td>
										</tr>



									</table>
								</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<td class="feet" colspan="2" />
				</tr>
			</table>
			</td>

			</tr>

			</table>
			<br>
			<br>

			<input type="hidden" id="modelId" name="modelId" value="${param.modelId}" />

			<center>
				<button type="button" id="save" onclick='javascript:submitModelFiledForm();'>
					<img src="../../core/style/default/images/add-act.png" alt="" />
					确认
				</button>
				&nbsp;&nbsp;&nbsp;
				<button type="button" onClick="javascript:window.close();">
					<img src="../../core/style/default/images/reset-act.png" alt="" />
					取消
				</button>
			</center>
		</form>

	</body>

</html>

<script type="text/javascript">

function switchHtmlElementType(htmlType)
{	
	//文本框
	if('1' == htmlType)
	{
		$('#maxLengthDIV').show();
		$('#sizeDIV').hide();
		$('#choiceValueDIV').hide();
		$('#htmlContentDIV').hide();
		
		$('#mustFillDIV').show();
		
		$('#defaultValueDIV').show();
		$('#defaultValueMultDIV').hide();
		
		$('#validateDIV').show();
		$('#messageDIV').show();
		
		$('#fileTypeDIV').hide();
	}//多行文本
	else if('2' == htmlType)
	{
		$('#maxLengthDIV').show();
		$('#sizeDIV').show();
		$('#choiceValueDIV').hide();
		$('#htmlContentDIV').hide();
		
		$('#mustFillDIV').show();
		
		$('#defaultValueDIV').show();
		$('#defaultValueMultDIV').hide();
		
		$('#validateDIV').show();
		$('#messageDIV').show();
		
		$('#fileTypeDIV').hide();
	}//编辑器
	else if('3' == htmlType)
	{
		$('#maxLengthDIV').show();
		$('#sizeDIV').show();
		$('#choiceValueDIV').hide();
		$('#htmlContentDIV').hide();

		
		$('#mustFillDIV').show();
		
		$('#defaultValueDIV').show();
		$('#defaultValueMultDIV').hide();
		
		$('#validateDIV').show();
		$('#messageDIV').show();
		
		$('#fileTypeDIV').hide();
	}
	//下拉
	else if('4' == htmlType)
	{
		$('#maxLengthDIV').hide();
		$('#sizeDIV').hide();
		$('#choiceValueDIV').show();
		$('#htmlContentDIV').hide();


		
		$('#mustFillDIV').show();
		
		$('#defaultValueDIV').show();
		$('#defaultValueMultDIV').hide();
			
		$('#validateDIV').hide();
		$('#messageDIV').hide();
		
		$('#fileTypeDIV').hide();
	}
	//单选
	else if('5' == htmlType )
	{
		$('#maxLengthDIV').hide();
		$('#sizeDIV').hide();
		$('#choiceValueDIV').show();
		$('#htmlContentDIV').hide();

		
		$('#mustFillDIV').hide();
		
		$('#defaultValueDIV').show();
		$('#defaultValueMultDIV').hide();
			
		$('#validateDIV').hide();
		$('#messageDIV').hide();
		
		$('#fileTypeDIV').hide();
	}
	//复选
	else if('6' == htmlType )
	{
		$('#maxLengthDIV').hide();
		$('#sizeDIV').hide();
		$('#choiceValueDIV').show();
		$('#htmlContentDIV').hide();

		
		$('#mustFillDIV').show();
		
		$('#defaultValueDIV').hide();
		$('#defaultValueMultDIV').show();
			
		$('#validateDIV').hide();
		$('#messageDIV').hide();
		
		$('#fileTypeDIV').hide();
	}
	//日期时间
	else if('7' == htmlType )
	{
		$('#maxLengthDIV').hide();
		$('#sizeDIV').hide();
		$('#choiceValueDIV').hide();
		$('#htmlContentDIV').hide();

		$('#mustFillDIV').show();
		
		$('#defaultValueDIV').hide();
		$('#defaultValueMultDIV').hide();
			
		$('#validateDIV').hide();
		$('#messageDIV').hide();
		
		$('#fileTypeDIV').hide();
	}
	//文件上传
	else if('8' == htmlType || '9' == htmlType || '10' == htmlType )
	{
		$('#maxLengthDIV').hide();
		$('#sizeDIV').hide();
		$('#choiceValueDIV').hide();
		$('#htmlContentDIV').hide();

		
		$('#mustFillDIV').show();
		
		$('#defaultValueDIV').hide();
		$('#defaultValueMultDIV').hide();
			
		$('#validateDIV').hide();
		$('#messageDIV').hide();
		
		$('#fileTypeDIV').show();
	}
	//htmml自定义代码
	else if('11' == htmlType )
	{
		$('#maxLengthDIV').hide();
		$('#sizeDIV').hide();
		$('#choiceValueDIV').hide();
		$('#htmlContentDIV').show();

		$('#mustFillDIV').hide();
		
		$('#defaultValueDIV').hide();
		$('#defaultValueMultDIV').hide();
			
		$('#validateDIV').hide();
		$('#messageDIV').hide();
		
		$('#fileTypeDIV').hide();
	}
}




function submitModelFiledForm()
{
	var postData = 
	     'htmlElementId='+$('#htmlElementId').val()
	    +'&dataModelId='+${param.modelId}
   		+'&showName='+$('#showName').val()
		+'&filedSign='+$('#filedSign').val()
		+'&isMustFill='+$('#isMustFill').val()
		+'&defaultValue='+$('#defaultValue').val()
		+'&defaultValueMult='+$('#defaultValueMult').val()
		+'&maxLength='+$('#maxLength').val()
		+'&width='+$('#width').val()
		+'&height='+$('#height').val()
		+'&choiceValue='+$('#choiceValue').val()
		+'&htmlContent='+$('#htmlContent').val()
		+'&allowableFile='+$('#allowableFile').val()
		+'&validateType='+$('#validateType').val()
		+'&errorMessage='+$('#errorMessage').val();
		
		//alert(postData);

   var url = "../../metadata/addModelFiled.cmd?"+postData+"&random="+Math.random();
 
   $.ajax({
   type:'POST',
   async:false,
   url:url,
   success:
  	function(data, textStatus)
  	{
  	 	var msgs = data.split(':');
  	  
         if('success'!=msgs[0])
         {
            alert(msgs[1]);
         }
         else 
         {
      		//alert(window.parent.document.all[id='treeFrame'].src);
      		 alert(msgs[1]);
      		 window.returnValue ='reload';
  		     window.close();
  		    
  		     
             return;  
         }
  	}
  });
  

  		    
  		     
          
}

</script>
