<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/webpage/include/taglib.jsp"%>
<html>
<head>
	<title>请假管理</title>
	<meta name="decorator" content="default"/>
	<script src="${ctx}/act/rest/js/common/common.js" charset="UTF-8"></script>
	<script type="text/javascript">
        var validateForm;
        var count1 = 0;
        $(document).ready(function() {
            checkContentKeyUp('reason',128);
            if($("#applyTime").val()==null || $("#applyTime").val()==''){
                $("#applyTime").val(getNowFormatDate());
            }

            $("#attachment_btn").click(function () {
                $("#attachment_file").click();
            });
            validateForm = $("#inputForm").validate({
                submitHandler: function(form){
                    loading('正在提交，请稍等...');
                    form.submit();
                },
                rules:{
                },
                messages:{
                },
                errorContainer: "#messageBox",
                errorPlacement: function(error, element) {
                    $("#messageBox").text("输入有误，请先更正。");
                    if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
                        error.appendTo(element.parent().parent());
                    } else {
                        error.insertAfter(element);
                    }
                }
            });
           //alert(leaveDetailListRowIdx = ${fn:length(leaveApply.leaveDetailList)};)


            lay('.di').each(function(){
                laydate.render({
                    elem: this,
                    event: 'focus',
                    type : 'date',
                    done: function(value){//日期时间被切换后的回调
                        changeDate(this,1);
                    }
                });
            });

        });



        function doSubmit(obj){//回调函数，在编辑和保存动作时，供openDialog调用提交表单。
            var idArr = $("#leaveDetailList tr:visible");
            if(idArr.length<1){
                parent.layer.msg("请添加请假详情!", {icon: 5});
                return false;
			}
            $(".dis").attr("disabled",false);
            if(obj == 2){
                $("#inputForm").attr("action","${ctx}/leaveapply/leaveApply/store");
            }else{
                $("#inputForm").attr("action","${ctx}/leaveapply/leaveApply/save");
            }
            if(validateForm.form()){
                $("#inputForm").submit();
                return true;
            }else {
                parent.layer.msg("信息未填写完整!", {icon: 5});
            }

            return false;
        }

        function deleteRow(obj,index){
            $(obj).parent().parent().remove();
            str[index] = " ";
            mon[index] = 0;

        }
        function getNowFormatDate() {
            var date = new Date();
            var seperator1 = "-";
            var seperator2 = ":";
            var month = date.getMonth() + 1;
            var strDate = date.getDate();
            month = (month < 10)?"0"+month:month;
            strDate = (strDate < 10)?"0"+strDate:strDate;
            var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate;
            return currentdate;
        }

        function addRow(list, idx, tpl, row){
            var idx1 = $("#leaveDetailList tr").length;
            tpl = tpl.replace("leaveDetailList[0].startType","leaveDetailList["+leaveDetailListRowIdx+"].startType");
            tpl = tpl.replace("leaveDetailList[0].endType","leaveDetailList["+leaveDetailListRowIdx+"].endType");
            bornTemplete(list, idx, tpl, row, idx1);
        }
        function bornTemplete(list, idx, tpl, row, idx1){
            $(list).append(Mustache.render(tpl, {
                idx: idx, delBtn: true, row: row,
                order:idx1 + 1
            }));
            $(list+idx).find("select").each(function(){
                $(this).val($(this).attr("data-value"));
            });
            $(list+idx).find("input[type='checkbox'], input[type='radio']").each(function(){
                var ss = $(this).attr("data-value").split(',');
                for (var i=0; i<ss.length; i++){
                    if($(this).val() == ss[i]){
                        $(this).attr("checked","checked");
                    }
                }
            });
            lay('.di').each(function(){
                laydate.render({
                    elem: this,
                    event: 'focus',
                    type : 'date',
                    done: function(value){//日期时间被切换后的回调
                        changeDate(this,1);
                    }
                });
            });
        }

        function changeDate(index,type) {
            var i;
            if(type==1){
                i=$(index.elem[0]).attr("idx");
			}else{
                i=index;
			}
            var startTime=$("#leaveDetailList"+i+"_3").val();
            var endTime=$("#leaveDetailList"+i+"_5").val();
            var strtType = $("#leaveDetailList"+i+"_4").val();
            var endType = $("#leaveDetailList"+i+"_6").val();
            if(startTime != null && startTime != undefined && startTime != ''
                &&endTime != null && endTime != undefined && endTime != ''
                &&strtType != null && strtType != undefined && strtType != ''
                &&endType != null && endType != undefined && endType != ''){
                var startDate = new Date(startTime.replace(/-/g, "/"));
                var endDate = new Date(endTime.replace(/-/g, "/"));
                var time = endDate.getTime() - startDate.getTime();
                var days = parseInt(time / (1000 * 60 * 60 * 24));
                if(days<0){
                    parent.layer.msg("结束时间需大于开始时间!", {icon: 5});
                   $("#leaveDetailList"+i+"_5").val('');
                    return;
				}
				var model= $("#leaveDetailList"+i+"_2").val();
                if(model=='工作日'){
                    $.ajax({
                        type:'post',
                        async: false,
                        url:'${ctx}/leaveapply/leaveApply/weekDays?startDate='+startTime+'&endDate='+endTime,
                        success:function(data){
                            if(data==-1){
                                parent.layer.msg("该年度法定节假日还未出台，无法计算请假时长!", {icon: 5});
                                $("#leaveDetailList"+i+"_5").val('');
                                return;
							} else if(data == 0){
                                $("#leaveDetailList"+i+"_7").val(0);
                            }else{
                                data=data-1;
                                if("1" == strtType && "1" == endType){
                                    $("#leaveDetailList"+i+"_7").val( data+0.5);
                                }else if("1" == strtType && "2" == endType){
                                    $("#leaveDetailList"+i+"_7").val( data+1);
                                }else if("2" == strtType && "2" == endType){
                                    $("#leaveDetailList"+i+"_7").val( data+0.5);
                                }else if("2" == strtType && "1" == endType){
                                    $("#leaveDetailList"+i+"_7").val( data);
                                }
                            }
						},
						error:function(data){
                        }
                    });
				}else{
                        if("1" == strtType && "1" == endType){
                            $("#leaveDetailList"+i+"_7").val( days+0.5);
                        }else if("1" == strtType && "2" == endType){
                            $("#leaveDetailList"+i+"_7").val( days+1);
                        }else if("2" == strtType && "2" == endType){
                            $("#leaveDetailList"+i+"_7").val( days+0.5);
                        }else if("2" == strtType && "1" == endType){
                            $("#leaveDetailList"+i+"_7").val( days);
                        }
				}

                $("#"+"leaveDetailList"+i+"_7").change();
            }
        }

        function getMoney(value){
            var days = 0;
            //方法一使用id选择器进行计算。
            //获取输入的数字
            //自动计算出结果并填充在相应的输入框中
            var size = $("#leaveDetailList tr").length+count1;
            for (var i = 0;i<=size;i++){
                var countday= $("#leaveDetailList"+i+"_7").val();
                var delFlag = $("#leaveDetailList"+i+"_delFlag").val();
                if (countday!=undefined && isNumber(countday) && delFlag==0){
                    if(days==0){
                        days = parseFloat(countday);
                    }else {
                        days = (parseFloat(days) + parseFloat(countday));
                    }
                }
            }
                $("#longTime").val(days);

        }
        function delRow(obj, prefix){
            var id = $(prefix+"_id");
            var countday= $(prefix+"_7").val();
            var days = $("#longTime").val();
            if (isNumber(countday)){
                if(days==""){
                    days = parseFloat(countday);
                }else {
                    days = (parseFloat(days) - parseFloat(countday));
                }
            }
            count1++;
            $("#longTime").val(days);
            var id = $(prefix+"_id");
            var delFlag = $(prefix+"_delFlag");
            if (id.val() == ""){
                delFlag.val("1");
                $(obj).parent().parent().remove();
            }else if(delFlag.val() == "0"){
                delFlag.val("1");
                $(obj).html("&divide;").attr("title", "撤销删除");
                $(obj).parent().parent().addClass("error");
                $(obj).parent().parent().addClass("hide");
            }else if(delFlag.val() == "1"){
                delFlag.val("0");
                $(obj).html("&times;").attr("title", "删除");
                $(obj).parent().parent().removeClass("error");
            }
        }
        function setLeaveType(ids) {
            $.ajax({
                type:'post',
                url:'${ctx}/leaveapply/leaveApply/typeInfo?ids='+ids,
                success:function(data){
                    setUserInfo(data);
                }
            })
        }
        function setUserInfo(obj){
            addRow('#leaveDetailList', leaveDetailListRowIdx, leaveDetailListTpl);
            leaveDetailListRowIdx = leaveDetailListRowIdx + 1;
            var row = leaveDetailListRowIdx - 1 ;
            $("#"+"leaveDetailList"+row+"_leaveType").val(obj.id);
            $("#"+"leaveDetailList"+row+"_1").val(obj.name);
            $("#"+"leaveDetailList"+row+"_2").val(obj.model);
            $("#"+"leaveDetailList"+row+"_7").val(0);
            $("#"+"leaveDetailList"+row+"_7").change();
            $("#"+"leaveDetailList"+row+"_4").val("1").css('width','100%');
            $("#"+"leaveDetailList"+row+"_6").val("2").css('width','100%');
            if(obj.unit==2){
                $("#"+"leaveDetailList"+row+"_4").attr("disabled",true);
                $("#"+"leaveDetailList"+row+"_6").attr("disabled",true);
			}

        }
        function isNumber(val){
            if(val === "" || val ==null){
                return false;
            }
            var regPos = /^\d+(\.\d+)?$/; //非负浮点数
            var regNeg = /^(-(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*)))$/; //负浮点数
            if(regPos.test(val) || regNeg.test(val)){
                return true;
            }else{
                return false;
            }
        }
        function insertTitle(tValue){
            var list = "${leaveApply.workAttachments}";
            var size = (list.split('url')).length-1;
            var files = $("#attachment_file")[0].files;            for(var i = 0;i<files.length;i++) {                var file = files[i];
            var attachmentId = "";
            var attachmentFlag = "114";
            console.log(file);
            var timestamp=new Date().getTime();

            var storeAs = "attachment-file/leaveApply/"+timestamp+"/"+file['name'];
            var uploadPath="http://gangwan-app.oss-cn-hangzhou.aliyuncs.com/"+storeAs;/*将这段字符串存到数据库即可*/
            var divId = "_attachment";
            $("#addFile"+divId).show();
            multipartUploadWithSts(storeAs, file,attachmentId,attachmentFlag,uploadPath,divId,size);}
        }


	</script>
	<style>
		/*超过5个汉字，调整label的长度，以下是配套的*/
		.layui-item .layui-form-label{
			width:90px;
		}
		.form-group .layui-item .layui-input-block,
		.query .layui-input-block {
			margin-left: 116px;
		}
	</style>
</head>
<body>
<div class="single-form">
	<div class="container">
		<form:form id="inputForm" modelAttribute="leaveApply" action="${ctx}/leaveapply/leaveApply/save" method="post" class="form-horizontal" >
			<form:hidden path="id"/>
			<form:hidden path="basicInfo.id"/>
			<div class="form-group layui-row first">
				<div class="form-group-label"><h2>基础信息</h2></div>
				<div class="layui-item layui-col-sm6">
					<label class="layui-form-label"><span class="require-item">*</span>姓名：</label>
					<div class="layui-input-block">
						<form:input id="name" path="basicInfo.name" htmlEscape="false" readonly="true"  class="form-control layui-input" />
					</div>
				</div>
				<div class="layui-item layui-col-sm6">
					<label class="layui-form-label"><span class="require-item">*</span>请假编号：</label>
					<div class="layui-input-block">
						<div class="input-group">
							<form:input id="no" path="no" htmlEscape="false"  readonly="true"  class="form-control  layui-input"/>
							<span class="input-group-btn">
                                <label class="form-status"><c:choose><c:when test="${not empty leaveApply.status}">${fns:getDictLabel(leaveApply.status, 'leave_audit', '')}</c:when><c:otherwise>新增</c:otherwise></c:choose></label>
                             </span>
						</div>
					</div>
				</div>
				<div class="layui-item layui-col-sm6">
					<label class="layui-form-label"><span class="require-item">*</span>工号：</label>
					<div class="layui-input-block">
						<form:input readonly="true" path="basicInfo.no" htmlEscape="false" class="form-control layui-input"/>
					</div>
				</div>
				<div class="layui-item layui-col-sm6">
					<label class="layui-form-label"><span class="require-item">*</span>员工状态：</label>
					<div class="layui-input-block">
						<form:input  path="basicInfo.status" htmlEscape="false" readonly="true"  class="form-control layui-input"/>
					</div>
				</div>
				<div class="layui-item layui-col-sm6">
					<label class="layui-form-label"><span class="require-item">*</span>部门：</label>
					<div class="layui-input-block">
						<form:input readonly="true" path="basicInfo.office.name" htmlEscape="false" class="form-control layui-input"/>
					</div>
				</div>
				<div class="layui-item layui-col-sm6">
					<label class="layui-form-label"><span class="require-item">*</span>职级：</label>
					<div class="layui-input-block">
						<form:input  readonly="true" path="basicInfo.jobGrade.name" htmlEscape="false" class="form-control layui-input"/>
					</div>
				</div>
				<div class="layui-item layui-col-sm6">
					<label class="layui-form-label"><span class="require-item">*</span>申请日期：</label>
					<div class="layui-input-block">
						<input id="applyTime" name="applyTime" readonly="true" type="text"  maxlength="20" class="laydate-icondate form-control layer-date required layui-input laydate-icon"
							   value="<fmt:formatDate value="${leaveApply.applyTime}" pattern="yyyy-MM-dd"/>"/>
					</div>
				</div>
				<div class="layui-item layui-col-sm12  with-textarea">
					<label class="layui-form-label">请假原因：</label>
					<div class="layui-input-block">
						<form:textarea path="reason" htmlEscape="false" rows="3" onkeyup="checkContentKeyUp('reason',128);"   maxlength="128" class="form-control "/>
					</div>
					<span id="contentMsg" style="float: right"></span>
				</div>
			</div>
			<div class="form-group layui-row">
				<div class="form-group-label"><h2>假期详情</h2></div>
				<div class="layui-item nav-btns ">
					<sys:treeselectlea id="exampleInfo" name="" value="" labelName="" labelValue="" title="假期类型" url="/leaveapply/leaveApply/treeDataTypeInfo"  cssClass="form-control required "
									   allowClear="true" notAllowSelectParent="true"/>
				</div>
				<div class="layui-item layui-col-xs12 form-table-container" >
					<table id="contentTable" class="table table-bordered table-condensed can-edit no-bottom-margin">
						<thead>
						<tr>
							<th width="150px">假期名称</th>
							<th width="150px">计假模式</th>
							<th width="150px" colspan="2" >开始时间</th>
							<th width="150px" colspan="2">结束时间</th>
							<th width="100px">请假天数</th>
							<th width="100px">操作</th>
						</tr>
						</thead>
						<tbody id="leaveDetailList">
						<c:if test="${not empty leaveApply.leaveDetailList}">
							<c:forEach items="${leaveApply.leaveDetailList}" var="leaveDetail" varStatus="index">
								<tr id="leaveDetailList${index.index}">
									<td class="hide">
										<input id="leaveDetailList${index.index}_id" name="leaveDetailList[${index.index}].id" type="hidden" value="${leaveDetail.id}"/>
										<input id="leaveDetailList${index.index}_leaveType" name="leaveDetailList[${index.index}].leaveType.id" type="hidden" value="${leaveDetail.leaveType.id}"/>
										<input id="leaveDetailList${index.index}_delFlag" name="leaveDetailList[${index.index}].delFlag" type="hidden" value="0"/>
                                        <input id="leaveDetailList${index.index}_flag" name="leaveDetailList[${index.index}].flag" type="hidden" value="${leaveDetail.flat}"/>
									</td>
									<td>
										<input id="leaveDetailList${index.index}_1"  readonly="true"   type="text" value="${leaveDetail.leaveType.name}"   class="form-control "/>
									</td>
									<td>
										<input id="leaveDetailList${index.index}_2"  readonly="true"   type="text" value="${fns:getDictLabel(leaveDetail.leaveType.model, 'fake_model', '')}"   class="form-control "/>
									</td>
									<td>
										<input idx="${index.index}" style="width: 150px" id="leaveDetailList${index.index}_3" name="leaveDetailList[${index.index}].startTime"  type="text" maxlength="20" class="di laydate-icondate required form-control layer-date layui-input laydate-icon"
                                    value="<fmt:formatDate value="${leaveDetail.startTime}" pattern="yyyy-MM-dd"/>"/>
										</input>
									</td>
									<td>
										<c:if test="${leaveDetail.leaveType.unit eq '2'}">
											<form:select style="width: 150px" id="leaveDetailList${index.index}_4" path="leaveDetailList[${index.index}].startType" onchange="changeDate('${index.index}','2')" disabled="true"  class="form-control required simple-select dis">
											<form:options items="${fns:getDictList('date_type')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
										</form:select>
										</c:if>
										<c:if test="${leaveDetail.leaveType.unit eq '1'}">
											<form:select style="width: 150px" id="leaveDetailList${index.index}_4" path="leaveDetailList[${index.index}].startType" onchange="changeDate('${index.index}','2')"  class="form-control required simple-select dis">
											<form:options items="${fns:getDictList('date_type')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
										</form:select>
										</c:if>
									</td>
									<td>
										<input idx="${index.index}" style="width: 150px"  id="leaveDetailList${index.index}_5" name="leaveDetailList[${index.index}].endTime"type="text" maxlength="20" class="di laydate-icondate required form-control layer-date layui-input laydate-icon "
											   value="<fmt:formatDate value="${leaveDetail.endTime}" pattern="yyyy-MM-dd"/>"/>
										</input>
									</td>
									<td>
										<c:if test="${leaveDetail.leaveType.unit eq '2'}">
											<form:select style="width: 150px" id="leaveDetailList${index.index}_6" path="leaveDetailList[${index.index}].endType" onchange="changeDate('${index.index}','2')" disabled="true"  class="form-control required simple-select dis">
												<form:options items="${fns:getDictList('date_type')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
											</form:select>
										</c:if>
										<c:if test="${leaveDetail.leaveType.unit eq '1'}">
											<form:select style="width: 150px" id="leaveDetailList${index.index}_6" path="leaveDetailList[${index.index}].endType" onchange="changeDate('${index.index}','2')"  class="form-control required simple-select dis">
												<form:options items="${fns:getDictList('date_type')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
											</form:select>
										</c:if>
									</td>
									<td>
										<input id="leaveDetailList${index.index}_7" onchange="getMoney(this.value)" name="leaveDetailList[${index.index}].days" type="text" value="${leaveDetail.days}" readonly="true"  class="form-control number required"/>
									</td>
									<td class="text-center op-td" >
										<span class="op-btn op-btn-delete"  id="leaveDetailList${index.index}_span" onclick="delRow(this, '#leaveDetailList${index.index}')" title="删除"><i class="glyphicon glyphicon-remove"></i>&nbsp;删除</span>
									</td>
								</tr>
							</c:forEach>
						</c:if>
						</tbody>
					</table>
					<table id="contentMoneys" class="table table-bordered table-condensed can-edit summary">
						<tr>
							<td  style="vertical-align:middle;width:300px;text-align: center;"><label><font color="red">*</font>请假时长：</label></td>
							<td >
								<input htmlEscape="false" id="longTime" name="longTime" value="${leaveApply.longTime}" readonly="true" class="form-control layui-input" />
							</td>
						</tr>
					</table>
					<script type="text/template" id="leaveDetailListTpl">//<!--
                                    <tr id="leaveDetailList{{idx}}">
                                        <td class="hide">
                                            <input id="leaveDetailList{{idx}}_id" name="leaveDetailList[{{idx}}].id" type="hidden" value="{{row.id}}"/>
                                            <input id="leaveDetailList{{idx}}_leaveType" name="leaveDetailList[{{idx}}].leaveType.id" type="hidden" value="{{row.leaveType.id}}"/>
                                            <input id="leaveDetailList{{idx}}_delFlag" name="leaveDetailList[{{idx}}].delFlag" type="hidden" value="0"/>
                                            <input id="leaveDetailList{idx}}_flag" name="leaveDetailList[{{idx}}].flag" type="hidden" value="{{row.flag}}"/>
                                        </td>
                                        <td>
                                            <input id="leaveDetailList{{idx}}_1"   name="leaveDetailList[{{idx}}].leaveType.name" type="text" value="{{row.leaveType.name}}"  readonly="true"   class="form-control "/>
                                        </td>
                                        <td>
                                            <input id="leaveDetailList{{idx}}_2"  name="leaveDetailList[{{idx}}].leaveType.model" type="text" value="{{row.leaveType.model}}"   readonly="true"  class="form-control "/>
                                        </td>
                                        <td>
										<input idx="{{idx}}" style="width: 150px" id="leaveDetailList{{idx}}_3" name="leaveDetailList[{{idx}}].startTime" type="text" maxlength="20" class="di laydate-icondate required form-control layer-date layui-input laydate-icon "/>
										</input>
										</td>
										<td>
										<form:select style="width: 150px" id="leaveDetailList{{idx}}_4" path="leaveDetailList[0].startType" onchange="changeDate('{{idx}}','2')"  class="form-control required simple-select dis">
						                <form:options items="${fns:getDictList('date_type')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
										</form:select>
									</td>
									 <td>
										<input idx="{{idx}}" style="width: 150px"  id="leaveDetailList{{idx}}_5" name="leaveDetailList[{{idx}}].endTime" type="text" maxlength="20" class=" di laydate-icondate required form-control layer-date layui-input laydate-icon "/>
										</input>
										</td>
										<td>
										<form:select style="width: 150px" id="leaveDetailList{{idx}}_6" path="leaveDetailList[0].endType" onchange="changeDate('{{idx}}','2')" class="form-control required simple-select dis">
                                          <form:options items="${fns:getDictList('date_type')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
										</form:select>
									</td>
                                         <td>
                                            <input id="leaveDetailList{{idx}}_7" onchange="getMoney(this.value)" name="leaveDetailList[{{idx}}].days" type="text" value="{{row.days}}"   readonly="true" class="form-control number required"/>
                                        </td>
                                        <td class="text-center op-td" >
                                            {{#delBtn}}<span class="op-btn op-btn-delete" id="leaveDetailList{{idx}}_span" onclick="delRow(this, '#leaveDetailList{{idx}}')" title="删除"><i class="glyphicon glyphicon-remove"></i>&nbsp;删除</span>{{/delBtn}}
                                        </td>
                                    </tr>//-->
					</script>
					<script type="text/javascript">
                        var leaveDetailListRowIdx = 0, leaveDetailListTpl = $("#leaveDetailListTpl").html().replace(/(\/\/\<!\-\-)|(\/\/\-\->)/g,"");
                        if($("#id").val()){
                            leaveDetailListRowIdx = ${fn:length(leaveApply.leaveDetailList)};
                        }
                        $(document).ready(function() {
                        });
					</script>
				</div>
			</div>
			<div class="form-group layui-row">
				<div class="form-group-label"><h2>历史详情</h2></div>
				<div class="layui-item layui-col-xs12 form-table-container" >
					<table id="hisContentTable" class="table table-bordered table-condensed can-edit no-bottom-margin">
						<thead>
						<tr>
							<th width="200px">假期名称</th>
							<th width="200px">累计天数</th>
							<th width="200px">累计次数</th>
							<th width="200px">上限天数</th>
						</tr>
						</thead>
						<tbody id="hisLeaveDetailList">
						<c:if test="${not empty leaveApply.hisLeaveDetailList}">
							<c:forEach items="${leaveApply.hisLeaveDetailList}" var="leaveDetail" varStatus="index">
								<tr id="hisLeaveDetailList${index.index}">
									<td>
										<input id="hisLeaveDetailList${index.index}_1"  readonly="true"   type="text" value="${leaveDetail.name}"   class="form-control "/>
									</td>
									<td>
										<input id="hisLeaveDetailList${index.index}_2"  readonly="true"   type="text" value="${leaveDetail.sumDays}"   class="form-control "/>
									</td>
									<td>
									    <input id="hisLeaveDetailList${index.index}_3"   readonly="true" type="text" value="${leaveDetail.counts}"   class="form-control require"/>
								    </td>
									<td>
										<input id="hisLeaveDetailList${index.index}_4"  readonly="true"  type="text" value="${leaveDetail.days}"   class="form-control require"/>
									</td>
								</tr>
							</c:forEach>
						</c:if>
						</tbody>
					</table>
				</div>
			</div>
			<div class="form-group layui-row">
				<div class="form-group-label"><h2>附件信息</h2></div>
				<div class="layui-item nav-btns">
					<a id="attachment_btn" class="nav-btn nav-btn-add" title="添加附件"><i class="fa fa-plus"></i>&nbsp;添加附件</a>
				</div>
				<div id="addFile_attachment" style="display: none" class="upload-progress">
					<span id="fileName_attachment" ></span>
					<b><span id="baifenbi_attachment" ></span></b>
					<div class="progress">
						<div id="jindutiao_attachment" class="progress-bar" style="width: 0%" aria-valuenow="0">
						</div>
					</div>
				</div>
				<input id="attachment_file" type="file" name="attachment_file" multiple="multiple" style="display: none;" onChange="if(this.value)insertTitle(this.value);"/>
				<span id="attachment_title"></span>
				<div class="layui-item layui-col-xs12" style="padding:0 16px;">
					<table id="upTable" class="table table-bordered table-condensed details">
						<thead>
						<tr>
								<%-- <th>序号</th>--%>
							<th>文件预览</th>
							<th>上传人</th>
							<th>上传时间</th>
							<th width="150px">操作</th>
						</tr>
						</thead>
						<tbody id="file_attachment">
						<c:forEach items="${leaveApply.workAttachments}" var = "workClientAttachment" varStatus="status">
							<tr>
									<%-- <td>${status.index + 1}</td>--%>
								<c:choose>
									<c:when test="${fn:containsIgnoreCase(workClientAttachment.attachmentName,'jpg')
                                                           or fn:containsIgnoreCase(workClientAttachment.attachmentName,'png')
                                                           or fn:containsIgnoreCase(workClientAttachment.attachmentName,'gif')
                                                           or fn:containsIgnoreCase(workClientAttachment.attachmentName,'bmp')
                                                           or fn:containsIgnoreCase(workClientAttachment.attachmentName,'jpeg')}">
										<td><img src="${workClientAttachment.url}" width="50" height="50" onclick="openDialogView('预览','${ctx}/sys/picturepreview/picturePreview?url=${workClientAttachment.url}','90%','90%')" alt="${workClientAttachment.attachmentName}">
									</c:when>
									<c:otherwise>
										<c:choose>
											<c:when test="${fn:containsIgnoreCase(workClientAttachment.attachmentName,'pdf')}">
												<td><a class="attention-info" href="javascript:void(0)" onclick="preview('预览','${workClientAttachment.url}','90%','90%','1')">${workClientAttachment.attachmentName}</a></td>
											</c:when>
											<c:otherwise>
												<td><a class="attention-info" href="javascript:void(0)" onclick="preview('预览','${workClientAttachment.url}','90%','90%')">${workClientAttachment.attachmentName}</a></td>
											</c:otherwise>
										</c:choose>
									</c:otherwise>
								</c:choose>
								<td>${workClientAttachment.createBy.name}</td>
								<td><fmt:formatDate value="${workClientAttachment.createDate}" type="both"/></td>
								<td class="op-td">
									<div class="op-btn-box" >
										<a href="javascript:location.href='${ctx}/workfullmanage/workFullManage/downLoadAttach?file='+encodeURIComponent(encodeURIComponent('${workClientAttachment.url}'));" class="op-btn op-btn-download"><i class="fa fa-download"></i>&nbsp;下载</a>
										<c:if test="${workClientAttachment.createBy.id eq fns:getUser().id}">
											<a href="javascript:void(0)" onclick="deleteFileFromAliyun(this,'${ctx}/sys/workattachment/deleteFileFromAliyun?url=${workClientAttachment.url}&id=${workClientAttachment.id}&type=2','addFile')" class="op-btn op-btn-delete" ><i class="fa fa-trash"></i>&nbsp;删除</a>
										</c:if>
									</div>
								</td>
							</tr>
						</c:forEach>
						</tbody>
					</table>
				</div>
			</div>
			<div class="form-group layui-row page-end"></div>
		</form:form>
	</div>
</div>

</body>
</html>