<%@ 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_list">

  <s:include value="../common/body.jsp" />
  
  <s:form action="salaryConfImport" enctype="multipart/form-data" onsubmit="return checkForm(this)">
    <s:hidden name="oper" value="parse"/>
    <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="table_line" style="margin-bottom:10px;">
      <tr class="form_title">
        <td colspan="3">上传薪资配置文件</td>
      </tr>
      <tr class="form_item">
        <td width="60%"><span class="required">•</span>薪资配置文件：
          <s:file name="excelFile" cssStyle="width:230px;" title="薪资配置文件 为必填项"/>
          <span class="info">支持Excel 97-2003格式的xls文件。</span></td>
        <td width="28%"><span class="required">•</span>薪资帐套：
        <s:select cssStyle="width:120px;" name="importAccount.id" title="薪资帐套 为必填项" list='salaryAccountList'   headerKey="" headerValue="" listKey="id" listValue="name"/></td>
        <td width="12%"><input name="q" value="上传解析" type="submit" /></td>
      </tr>
    </table>
  </s:form>
  
  
  
<s:if test="excelData!=null && excelData.size()>0">
<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;
	});
	if(!res) return false;
	return confirm("您确认要导入薪资配置数据吗？");
}
</script>

<s:form action="salaryConfImport" onsubmit="return checkForm(this,otherCheck)">
	<s:hidden name="oper" value="import"/>
	<div class="item" style="margin:15px 0 5px 0;">
		下表中的数据将使用薪资帐套：<strong class="red">【<s:property value="importAccount.name"/>】</strong>
		<s:hidden name="importAccount.id"/>
	</div>
	
	<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:120px;" 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:140px;"/></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="48%" valign="top">
		<div class="info" style="padding-left:20px;">
		<strong>“标题行”</strong>下拉框中<span class="red">红色</span>字体的为必选项；
		<br />
		<strong>“生效月份”</strong>列如果为空，系统将以该员工的入职月份作为生效月份；
		<br />
		<strong>“时间格式”</strong>中字母 y M d H m s 分别表示年月日时分秒。</div>		</td>
	    <td width="52%" height="30" align="center" valign="top">
		<strong>月份格式：</strong>
        <s:textfield name="dateFormat" cssStyle="width:150px;"/>
		&nbsp;&nbsp;
		<input type="submit" name="Submit" value="导入薪资配置" />
		</td>
	    </tr>
	</table>
</s:form>
</s:if>


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