<%@ page contentType="text/html; charset=utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="cm" uri="/commons-tags" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>员工数据导入</title>
<link href="../resources/style/base.css" rel="stylesheet" type="text/css"/>
<s:include value="../common/head.jsp" />
</head>

<body>
<div class="body_form" style="width:99%; padding:0;">
<s:include value="../common/body.jsp" />
  <s:form action="emplInfoImport" id="queryForm" enctype="multipart/form-data" onsubmit="return checkForm(this)">
    <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="table_line" style="margin-bottom:15px;">
      <tr class="form_title">
        <td colspan="3">上传员工数据</td>
      </tr>
      <tr class="form_item">
        <td width="75%"><span class="required">•</span>数据文件：
          <s:file name="excelFile" cssStyle="width:300px;" title="数据文件 为必填项"/>
		  </td>
        <td width="25%">
          
	      <div align="center">
	        <input name="q" value="上传解析" type="submit" />		  
        </div></td>
      </tr>
    </table>
	<s:hidden name="oper" value="parse"/>
  </s:form>




<s:if test="excelData!=null && excelData.size()>0">
<s:form action="emplInfoImport" onsubmit="return checkForm(this,otherCheck)">
	<s:hidden name="oper" value="import"/>
	<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="table_line">
      <tr class="list_title">
	    <td width="5%" class="nowrap">行号</td>
        <s:iterator value="columnSelectedArray" status="st">
		<td class="column_<s:property value='#st.index'/>">
			<s:select cssStyle="width:100px;" name="columnSelectedArray" list="columnHeaderList" value="columnSelectedArray[#st.index]" 
				headerKey="" headerValue="-- 请选择 --" listKey="code" listValue="descr" title="列名为必填项"/>
			<img src="../resources/images/del.gif" onclick="delColumn(<s:property value='#st.index'/>)" class="pointer" title="点击删除该列"/>
		</td>
		</s:iterator>
        <td width="5%" class="nowrap">操作</td>
      </tr>
      <s:iterator value="excelData" status="st">
        <s:set name="row_cls" value=""/>
        <s:if test="#st.Even">
          <s:set name="row_cls" value="%{'row_a'}"/>
        </s:if>
        <tr class="list_data <s:property value='#row_cls'/>" id="row_<s:property value='#st.index'/>">
		  <td class="center"><s:property value="(#st.index+1)"/></td>
		  <s:iterator value="top" status="sutSt">
          	<td class="center column_<s:property value='#sutSt.index'/>"><s:textfield name="excelData[%{#st.index}]" value="%{top}" cssStyle="width:120px;"/></td>
          </s:iterator>
		  	<td class="center"><img src="../resources/images/del.gif" onclick="delRow(<s:property value='#st.index'/>)" class="pointer" title="点击删除该行"/></td>
        </tr>
      </s:iterator>
    </table>
    
	
	<table width="100%" border="0" cellspacing="0" cellpadding="0" style="margin-top:10px;">
	  <tr>
	    <td width="52%" valign="top">
		<div class="info" style="padding-left:20px;">
		<strong>“标题行”</strong>下拉框中<span class="red">红色</span>字体的为必选项；
		<br />		
		<strong>“工号”</strong>列为空，系统将自动生成工号；<br />
		<strong>“状态”</strong>列为空，系统将默认设置为“在职”状态；<br />
		<strong>“日期格式”</strong>中字母 y M d 分别表示年月日。</div>		</td>
	    <td width="48%" height="30" align="center" valign="top">
		<strong>日期格式：</strong>
        <s:textfield name="dateFormat" cssStyle="width:100px;"/>
		&nbsp;&nbsp;
		<input type="submit" name="Submit" value="导入员工数据" />
		</td>
	    </tr>
	</table>
</s:form>
<script language="javascript">
function requiredOption(){
<s:iterator value="columnHeaderList" status="st">
  <s:if test="required">
	$("option[value='<s:property value='code'/>']")	.each(function(){$(this).addClass("red");});
  </s:if>
</s:iterator>
}
$(function(){ requiredOption(); });

function delColumn(ix){
	msgConfirm("您确认要删除该列数据吗？",function(){
		$(".column_"+ix).remove();
	});
}

function delRow(ix){
	msgConfirm("您确认要删除该行数据吗？",function(){
		$("#row_"+ix).remove();
	});
}
function otherCheck(){
	var tempStr="";
	var res=true;
	$("select option:selected").each(function(){
		if(!res) return;
		var text=$(this).text();
		if(tempStr.indexOf(text)!=-1){
			checkMessage($(this).parent().get(0),"重复的列名："+text);
			res=false;	
		}
		tempStr=tempStr+"#"+text;
	});
	return res;
}
</script>
</s:if>

</div>
</body>
</html>