<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/webpage/include/taglib.jsp"%>
<html>
<head>
	<title>报销单管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		var validateForm;
		var count = 0;
		$(document).ready(function() {
            if($("#submitterDate").val()==null || $("#submitterDate").val()==''){
                $("#submitterDate").val(getNowFormatDate());
            }
            $("input[name='ext']").on('ifChecked', function(event){
                var radioVal = $(this).val();
                if(radioVal == 0){
                    $(".td1").removeClass("hide");
                    $(".project_reimbursement_div").show();
                    $(".not_project_reimbursement_div").hide();
                }else{
                    $(".td1").addClass("hide");
                    $(".project_reimbursement_div").hide();
                    $(".not_project_reimbursement_div").show();
                }
            });
            if("${workReimbursement.ext}" == "1"){
                $("#ext1").iCheck('check')
            }else{
                $("#ext").iCheck('check')
            }
            $("input[name='isPublic']").on('ifChecked', function(event){
                var radioVal = $(this).val();
                if(radioVal == 1){
                    $(".isPublic").removeClass("hide");
                    $("#comname").removeClass("required");
                    $("#bank").removeClass("required");
                    $("#bankNo").removeClass("required");
                    $("#reimbursementBackList tr").each(function () {
                        $(this).remove();
                        $("#backmoney").val("0.00");
                    })
                }else{
                    $(".isPublic").addClass("hide");
                    $("#comname").addClass("required");
                    $("#bank").addClass("required");
                    $("#bankNo").addClass("required");
                    getLoan($("#achivesId").val());
                }
            });
            if("${workReimbursement.isPublic}" == "1"){
                $("#isPublic1").iCheck('check')
                $(".isPublic").removeClass("hide");
            }else{
                $("#isPublic").iCheck('check')
                $(".isPublic").addClass("hide");
            }
            validateForm = $("#inputForm").validate({
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
				},
                rules:{
                    number:{
                        required:true
                    },
                },
                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);
					}
				}
			});
            laydate.render({
                elem: '#submitterDate', //目标元素。由于laydate.js封装了一个轻量级的选择器引擎，因此elem还允许你传入class、tag但必须按照这种方式 '#id .class'
                event: 'focus', //响应事件。如果没有传入event，则按照默认的click
                type : 'date'
            });
            $("#attachment_btn").click(function () {
                $("#attachment_file").click();
            });
           // getRandom();

        });
        function doSubmit(obj){//回调函数，在编辑和保存动作时，供openDialog调用提交表单。
            var idArr = $("#workAccountList tr:visible");
            if(idArr.length<1){
                parent.layer.msg("请添加报销详情!", {icon: 5});
                return false;
            }

            var trlen = $("#workAccountList tr").length;
            var tdlen = $("#workAccountList tr td").length;
            var trArr = [];
            for(var i = 0;i < trlen;i++){
                var tableMap = {};
                tableMap["flag"] = $("#workAccountList tr").eq(i).find("td").eq(0).text();
                tableMap["typeId"] = $("#workAccountList tr").eq(i).find("td").eq(1).text();
                tableMap["money"] = $("#workAccountList tr").eq(i).find("td").eq(3).text();
                tableMap["detail"] = $("#workAccountList tr").eq(i).find("td").eq(4).text();
                tableMap["submitterId"] = $("#workAccountList tr").eq(i).find("td").eq(5).text();
                tableMap["officeId"] = $("#workAccountList tr").eq(i).find("td").eq(6).text();
                tableMap["billNumber"] = $("#workAccountList tr").eq(i).find("td").eq(7).text();
                tableMap["payMode"] = $("#workAccountList tr").eq(i).find("td").eq(8).text();
                tableMap["travelDays"] = $("#workAccountList tr").eq(i).find("td").eq(9).text();
                trArr.push(tableMap);
            }
            if(obj == 2){
               $("#flag").val("no");
            }else{
                $("#flag").val("yes");
            }
            if(validateForm.form()){
                var total=0 //价税合计总额
                var specialTotal=0;
                $("#reimbursementVATTaxes tr:visible .sumMoney").each(function () {
                    total= parseFloat($(this).val()) +total;
                });
                var falt=0;
                $("#workAccountList tr:visible").each(function () {
                    var v_id = $(this).attr("id");
                    if($("#"+v_id+"_invoiceType").val()=="专票"){
                        falt=1;
                        specialTotal=specialTotal+parseFloat($("#"+v_id+"_money").val());
                    }
                })
                if(falt==1){
                    var idArr = $("#reimbursementVATTaxes tr:visible");
                    if(idArr.length<1){
                        parent.layer.msg("请添加专用发票信息!", {icon: 5});
                        return false;
                    }
                }
                if(total!=specialTotal){
                    parent.layer.msg("专用发票报销金额应等于价税合计总额!", {icon: 5});
                    return false;
                }
                if(parseFloat($("#backmoney").val())>parseFloat($("#moneys").val())){
                    parent.layer.msg("还款金额不能大于报销金额！", {icon: 5});
                    return false;
                }
                var size = $("#reimbursementBackList tr").length;
                for (var i = 0;i<size;i++){
                    var backmoney = $("#reimbursementBackList"+i+"_6").val();
                    var notRepay = $("#reimbursementBackList"+i+"_5").val();
                    if(backmoney!=''){
                        if (backmoney!=undefined && isNumber(backmoney)){
                            if(parseFloat(backmoney)>parseFloat(notRepay)){
                                parent.layer.msg("还款金额不能大于未还款金额！", {icon: 5});
                                return false;
                            }
                        }
                    }
                }
                $("#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;
            countMoney();
        }
        function countMoney(){
            var m = 0;
           $.each(mon,function (index,item) {
                m += Number(item);
           });
           $("#mont").val(m);
        }
        function setValue(obj){
            $.ajax({
                type:'post',
                url:'${ctx}/workreimbursement/workReimbursement/getProjectInfo',
                data:{
                    "obj":obj
                },
                success:function(data){
                    var d = JSON.parse(data);
                    $("#businessType").val(d.projectType);
                    $("#projectMasterName").val(d.projectMasterName);
                    $("#officeName").val(d.officeName);
                    $("#officeId").val(d.officeId);
                }
            })
        }
        function getLoan(id){
            $.ajax({
                type:'post',
                url:'${ctx}/workreimbursementback/workReimbursementBack/getLoan',
                data:{
                    "id":id
                },
                success:function(data){
                    var idx1 = $("#reimbursementBackList tr").length;
                    for(var i=0;i<data.length;i++){
                        addRowRecord('#reimbursementBackList', reimbursementBackIdx, reimbursementBackTpl,data[i]);

                    }
                }
            });
        }
        function selectUserInfo(id) {
            if( $("#achivesId").val()!=id){
                $("#reimbursementBackList tr").each(function () {
                    $(this).remove();
                    $("#backmoney").val("0.00");
                })
                if($('#isPublic').is(':checked')) {
                    getLoan(id);
                }
                $.ajax({
                    type:'post',
                    data:{
                        "id":id
                    },
                    url:'${ctx}/workregularapply/workRegularApply/userInfo',
                    success:function(data){
                        $("#bankCard").val(data.bankCard);
                        $("#achivesId").val(id);
                        $("#officeId").val(data.office.id);
                        $("#officeName").val(data.office.name);
                        $("#projectId").val("");
                        $("#projectName").val("");
                    }
                });
            }

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

        function getRandom(){
            var GetRandomn = 1;
            //js生成时间戳
            var timestamp=new Date().getTime();
            //获取随机范围内数值的函数
            function GetRandom(n){
                //由随机数+时间戳+1组成
                GetRandomn=Math.floor(Math.random()*n+timestamp+1);
            }
            //开始调用，获得一个1-100的随机数
            GetRandom("30");
            if(!$("#numberFlag").val()){
                $("#number").val(GetRandomn)
            }
        }

        function addRow(list, idx, tpl, row){
            var idx1 = $("#workAccountList tr").length;
            if(list == '#workAccountList'){
                tpl = tpl.replace("workAccountList[0].financialSubjects","workAccountList["+idx1+"].financialSubjects");
                tpl = tpl.replace("workAccountList[0].financialSubjectss","workAccountList["+idx1+"].financialSubjectss");
                var ext = $("input[name='ext']:checked").val();
                if(ext == 0){
                    tpl = tpl.replace("not_project_reimbursement_div","not_project_reimbursement_div\" style=\"display:none;\"");
                    tpl = tpl.replace("project_reimbursement_div\" style=\"display:none;\"","project_reimbursement_div");
                }else {
                    tpl = tpl.replace("project_reimbursement_div","project_reimbursement_div\" style=\"display:none;\"");
                    tpl = tpl.replace("not_project_reimbursement_div\" style=\"display:none;\"","not_project_reimbursement_div\"");
                }
                bornTemplete(list, idx, tpl, row, idx1);
            }
            var idx2 = $("#reimbursementVATTaxes tr").length;
            if(list == '#reimbursementVATTaxes'){
                bornTemplete(list, idx, tpl, row, idx2);
            }
        }
        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");
                    }
                }
            });
        }
        function delRow(obj, prefix){
            var id = $(prefix+"_id");
            var workAccountmoney= $(prefix+"_money").val();
            var money = $("#moneys").val();
            if (isNumber(workAccountmoney)){
                if(money==""){
                    money = parseFloat(workAccountmoney).toFixed(2);
                }else {
                    money = (parseFloat(money) - parseFloat(workAccountmoney)).toFixed(2);
                }
            }
            if(money>=0){
                count++;
                $("#moneys").val(money);
                var delFlag = $(prefix+"_delFlag");
                if (id.val() == ""){
                    $(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");
                }
            }else{
                parent.layer.msg('删除失败',{icon:2});
            }

        }
        function delRowA(obj, prefix){
            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 urlRedict(file,attach){
            parent.layer.confirm('确定删除吗？', {
                btn: ['确认', '取消'] //可以无限个按钮
            }, function(index, layero){
                var index1 = parent.layer.load(0, {shade: false});
                $.post("${ctx}/workfullmanage/workFullManage/deleteFile",
                    {"file":file,"attach":attach},
                    function(result){
                        var d = JSON.parse(result);
                        if(d.str){
                            location.reload();
                            parent.layer.msg("删除成功！！！",{icon:6});
                            parent.layer.close(index1);
                            parent.layer.close(index);
                        }
                    });
            }, function(index){
                parent.layer.close(index)
            });

        }
        function insertTitle(tValue){
            var list = "${workReimbursement.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 = "6";
            console.log(file);
            var timestamp=new Date().getTime();

            var storeAs = "attachment-file/wrkReimbursement/"+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);}
        }

        function getMoney(value){
            var money = "0.00";
            //方法一使用id选择器进行计算。
            //获取输入的数字
            //自动计算出结果并填充在相应的输入框中
            var size = $("#workAccountList tr").length+count;
            for (var i = 0;i<size;i++){
                var workAccountmoney = $("#workAccountList"+i+"_money").val();
                var delFlag = $("#workAccountList"+i+"_delFlag").val();
                if (workAccountmoney!=undefined && isNumber(workAccountmoney) && delFlag==0){
                    if(money==""){
                        money = parseFloat(workAccountmoney).toFixed(2);
                    }else {
                        money = (parseFloat(money) + parseFloat(workAccountmoney)).toFixed(2);
                    }
                }
            }
            if (money!='0.00') {
                $("#moneys").val(money);
            }
        }
        function getBackMoney(value){
            var money = "0.00";
            //方法一使用id选择器进行计算。
            //获取输入的数字
            //自动计算出结果并填充在相应的输入框中
            var size = $("#reimbursementBackList tr").length;
            for (var i = 0;i<size;i++){
                var backmoney = $("#reimbursementBackList"+i+"_6").val();
                var notRepay = $("#reimbursementBackList"+i+"_5").val();

                if (backmoney!=undefined && isNumber(backmoney)){
                    if(money==""){
                        money = parseFloat(backmoney).toFixed(2);
                    }else {
                        money = (parseFloat(money) + parseFloat(backmoney)).toFixed(2);
                    }
                }
            }
            $("#backmoney").val(money);
        }
        function getMoneyVATT(index){
            var money = "0.00";
            //方法一使用id选择器进行计算。
            //获取输入的数字
            //自动计算出结果并填充在相应的输入框中
            var workmoney = $("#reimbursementVATTaxes"+index+"_money").val();
            if(parseFloat(workmoney)<0){
                workmoney=0;
                $("#reimbursementVATTaxes"+index+"_money").val(0);
            }
            if(workmoney==undefined||!isNumber(workmoney)||workmoney==''){
                workmoney=0;
            }
            var taxAmount = $("#reimbursementVATTaxes"+index+"_taxAmount").val();
            if(parseFloat(taxAmount)<0){
                taxAmount=0;
                $("#reimbursementVATTaxes"+index+"_taxAmount").val(0);
            }
            if(taxAmount==undefined||!isNumber(taxAmount)||taxAmount==''){
                taxAmount=0;
            }
            if (workmoney!=undefined && isNumber(workmoney) ){
                money = (parseFloat(taxAmount) + parseFloat(workmoney)).toFixed(2);
            }
            $("#reimbursementVATTaxes"+index+"_sumMoney").val(money);
        }
        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;
            }

        }
    </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="workReimbursement" action="${ctx}/workreimbursement/workReimbursement/saveAudit" method="post" class="form-horizontal" >
    <form:hidden path="id"/>
    <form:hidden path="home"/>
    <form:hidden path="submitter" id="submitter" />
    <form:hidden path="act.taskId"/>
    <form:hidden path="act.taskName"/>
    <form:hidden path="act.taskDefKey"/>
    <form:hidden path="act.procInsId"/>
    <form:hidden path="act.procDefId"/>
    <form:hidden id="flag" path="act.flag"/>
        <input type="hidden" id="numberFlag" value="${workReimbursement.number}" />
        <input id="wId" type="hidden" value="${workReimbursement.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 with-icon">
                    <div class="input-group">
                        <sys:gridSelectUser id="submitterId" name="submitterId" value="${workReimbursement.submitterId}" labelName="submitterName" labelValue="${workReimbursement.submitterName}"
                                            allowInput="false"   title="用户" url="${ctx}/sys/office/gridSelectUser" cssClass="form-control required layui-input" isAll="true" type="null"  isSingle="true"></sys:gridSelectUser>
                    </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">
                    <div class="input-group">
                        <form:input path="number" id="number" 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 workReimbursement.status}">${fns:getDictLabel(workReimbursement.status, 'audit_state', '')}</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">所属部门：</label>
                <div class="layui-input-block">
                    <form:input path="officeName" htmlEscape="false"  readonly="true" id="officeName"  class="form-control required layui-input" value = "${workReimbursement.officeName}"/>
                    <input type="hidden" id="officeId" name="officeId" value="${workReimbursement.officeId}">
                </div>
            </div>
            <div class="layui-item layui-col-sm6">
                <label class="layui-form-label">银行卡号：</label>
                <div class="layui-input-block">
                    <form:input path="bankCard" htmlEscape="false"  id="bankCard" minlength="16" maxlength="19" class="form-control number  layui-input" value = "${workReimbursement.bankCard}"/>
                </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 type="radio" class="i-checks" name="ext" checked id="ext" value="0">
                    <label for="ext">项目报销</label>
                    <input type="radio" class="i-checks" name="ext" id="ext1" value="1">
                    <label for="ext1">非项目报销</label>
                        <%--<input type="text" name="title" lay-verify="title" autocomplete="off" readonly="true" placeholder="" class="layui-input" value="全过程管理用户01">--%>
                </div>
            </div>

            <div class="layui-item layui-col-sm6 td1">
                <label class="layui-form-label"><span class="require-item">*</span>报销项目：</label>
                <div class="layui-input-block with-icon">
                    <sys:gridselectReproject url="${ctx}/workreimbursement/workReimbursement/selectproject" id="project" name="project.id"  value="${workReimbursement.project.id}"  title="选择报销项目" labelName="project.projectName"
                                               labelValue="${workReimbursement.project.projectName}" cssClass="form-control required layui-input" fieldLabels="工程" fieldKeys="projectName" searchLabel="工程名称" searchKey="projectName" ></sys:gridselectReproject>
                </div>
            </div>
                <%--<div class="layui-item layui-col-sm6 td1">
                    <label class="layui-form-label">项目负责人：</label>
                    <div class="layui-input-block">
                        <form:input path="projectMasterName" htmlEscape="false"  readonly="true" id="projectMasterName"  class="form-control layui-input"/>
                    </div>
                </div>--%>
            <div class="layui-item layui-col-sm6">
                <label class="layui-form-label double-line"><span class="require-item">*</span>是否对公报销：</label>
                <div class="layui-input-block">
                    <input type="radio" class="i-checks" name="isPublic" checked id="isPublic" value="0">
                    <label for="isPublic">否</label>
                    <input type="radio" class="i-checks" name="isPublic" id="isPublic1" value="1">
                    <label for="isPublic1">是</label>
                </div>
            </div>
            <div class="layui-item layui-col-sm6 isPublic">
                <label class="layui-form-label"><span class="require-item">*</span>公司名称：</label>
                <div class="layui-input-block with-icon">
                    <div class="input-group">
                        <sys:gridworkSupplier id="comnameId" name="comnameId" value="${workReimbursement.comname}" labelName="comname" labelValue="${workReimbursement.comname}"
                                              allowInput="true"   title="供应商/客户" url="${ctx}/workreimbursement/workReimbursement/gridSelectComname" cssClass="form-control required layui-input" ></sys:gridworkSupplier>
                    </div>
                </div>
            </div>
            <div class="layui-item layui-col-sm6 isPublic">
                <label class="layui-form-label"><span class="require-item">*</span>开户行：</label>
                <div class="layui-input-block">
                    <form:input path="bank" htmlEscape="false"  id="bank"  class="form-control  layui-input" value = "${workReimbursement.bank}"/>
                </div>
            </div>
            <div class="layui-item layui-col-sm6 isPublic">
                <label class="layui-form-label"><span class="require-item">*</span>银行账号：</label>
                <div class="layui-input-block">
                    <form:input path="bankNo" htmlEscape="false"  id="bankNo" minlength="16" maxlength="19" class="form-control number layui-input" value = "${workReimbursement.bankNo}"/>
                </div>
            </div>
            <div class="layui-item layui-col-sm6">
                <label class="layui-form-label">申请人：</label>
                <div class="layui-input-block">
                    <form:input path="userName" htmlEscape="false"  readonly="true" id="userName"  class="form-control required layui-input" value="${workReimbursement.submitterName}"/>
                    <input type="hidden" id="createById" name="createBy.id" value="${workReimbursement.createBy.id}">
                </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="submitterDate" name="submitterDate" type="text" readonly="true" maxlength="20" class="laydate-icondate form-control layer-date required layui-input laydate-icon"
                           value="<fmt:formatDate value="${submitterDate.submitterDate}" pattern="yyyy-MM-dd"/>"/>
                </div>
            </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="contentTable3" class="table table-bordered table-condensed can-edit no-bottom-margin">
                    <thead>
                    <tr>
                        <th width="190px">借款日期</th>
                        <th width="190px">借款类型</th>
                        <th width="190px">借款项目</th>
                        <th width="190px">借款金额</th>
                        <th width="180px">未还金额</th>
                        <th width="100px">本次还款</th>
                        <th width="120px">借款编号</th>
                    </tr>
                    </thead>
                    <tbody id="reimbursementBackList">
                    <c:if test="${not empty workReimbursement.reimbursementBackList}">
                        <c:forEach items="${workReimbursement.reimbursementBackList}" var="reimbursementBack" varStatus="index">
                            <tr id="reimbursementBackList${index.index}">
                                <td class="hide">
                                    <input id="reimbursementBackList${index.index}_id" name="reimbursementBackList[${index.index}].id" type="hidden" value="${reimbursementBack.id}"/>
                                    <input id="reimbursementBackList${index.index}_workLoanId" name="reimbursementBackList[${index.index}].workLoan.id" type="hidden" value="${reimbursementBack.workLoan.id}"/>
                                    <input id="reimbursementBackList${index.index}_delFlag" name="reimbursementBackList[${index.index}].delFlag" type="hidden" value="0"/>
                                </td>
                                <td>
                                    <input id="reimbursementBackList${index.index}_1"   type="text" maxlength="20"  readonly="true" class=" form-control layui-input"
                                           value="<fmt:formatDate value="${reimbursementBack.workLoan.loanDate}" pattern="yyyy-MM-dd"/>"/>
                                    </input>
                                </td>
                                <td>
                                    <input id="reimbursementBackList${index.index}_2"  readonly="true" type="text" value="${reimbursementBack.workLoan.type}"   class="form-control"/>
                                </td>
                                <td>
                                    <input id="reimbursementBackList${index.index}_3"  readonly="true" type="text" value="${reimbursementBack.workLoan.projectRecords.projectName}"   class="form-control"/>
                                </td>
                                <td>
                                    <input id="reimbursementBackList${index.index}_4"  readonly="true" type="text" value="${reimbursementBack.workLoan.money}"   class="form-control"/>
                                </td>
                                <td>
                                    <input id="reimbursementBackList${index.index}_5"  readonly="true" type="text" value="${reimbursementBack.workLoan.notRepay}"   class="form-control"/>
                                </td>
                                <td>
                                    <input id="reimbursementBackList${index.index}_6" onchange="getBackMoney(this.value)" name="reimbursementBackList[${index.index}].money" type="text" value="${reimbursementBack.money}"  placeholder="请输入金额" maxlength="10"  class="form-control number "/>
                                </td>
                                <td>
                                    <input id="reimbursementBackList${index.index}_7"  readonly="true" type="text" value="${reimbursementBack.workLoan.num}"   class="form-control"/>
                                </td>
                            </tr>
                        </c:forEach>
                    </c:if>
                    </tbody>
                </table>
                <table id="contentMoneys1" class="table table-bordered table-condensed can-edit summary">
                    <tr>
                        <td  style="width:190px;vertical-align:middle;text-align: center;"><label><font color="red">*</font>合计</label></td>
                        <td  width="190px" style="vertical-align:middle;text-align: center;">
                            -
                        </td >
                        <td  width="190px" style="vertical-align:middle;text-align: center;">
                            -
                        </td>
                        <td  width="190px" style="vertical-align:middle;text-align: center;">
                            -
                        </td>
                        <td width="180px" style="vertical-align:middle;text-align: center;">
                            -
                        </td>
                        <td width="100px" style="vertical-align:middle;text-align: center;">
                            <input  id="backmoney" value="${workReimbursement.backmoney}" name="backmoney" htmlEscape="false" readonly="true"   maxlength="12"  class="form-control "/>
                        </td>
                        <td  width="120px" style="vertical-align:middle;text-align: center;">
                            -
                        </td>
                    </tr>
                </table>
                <script type="text/template" id="reimbursementBackTpl">//<!--
                        <tr>
                            <td class="hide">
                                <input  id="reimbursementBackList{{idx}}_id" name="reimbursementBackList[{{idx}}].id" type="hidden" value="{{row.id}}">
                                <input id="reimbursementBackList{{idx}}_delFlag" name="reimbursementBackList[{{idx}}].delFlag" type="hidden" value="0"/>
                                <input id="reimbursementBackList{{idx}}_workLoanId" name="reimbursementBackList[{{idx}}].workLoan.id" type="hidden" value="{{row.workLoan.id}}"/>
                            </td>
                              <td>
                              <input  id="leaveDetailList{{idx}}_1" value="{{row.workLoan.loanDate}} "  readOnly="true"  type="text" maxlength="20" class=" form-control layer-date layui-input "/></input>
							</td>
                            <td >
                                <input id="reimbursementBackList{{idx}}_2"  readOnly="true"  value="{{row.workLoan.type}}" class="form-control"/>
                            </td>
                            <td >
                                <input id="reimbursementBackList{{idx}}_3"  readOnly="true"  value="{{row.workLoan.projectRecords.projectName}}" class="form-control"/>
                            </td>
                             <td >
                                <input id="reimbursementBackList{{idx}}_4"  readOnly="true"  value="{{row.workLoan.money}}" class="form-control"/>
                            </td>
                             <td >
                                <input id="reimbursementBackList{{idx}}_5"  readOnly="true"  value="{{row.workLoan.notRepay}}" class="form-control"/>
                            </td>
                             <td >
                                <input id="reimbursementBackList{{idx}}_6" onchange="getBackMoney(this.value)" name="reimbursementBackList[{{idx}}].money"  value="{{row.money}}" placeholder="请输入金额" maxlength="10"  class="form-control number "/>
                            </td>
                             <td >
                                <input id="reimbursementBackList{{idx}}_7"  readOnly="true"  value="{{row.workLoan.num}}" class="form-control"/>
                            </td>

                        </tr>//-->
                </script>
                <script type="text/javascript">
                    var reimbursementBackIdx = 0; var reimbursementBackTpl = $("#reimbursementBackTpl").html().replace(/(\/\/\<!\-\-)|(\/\/\-\->)/g,"");
                    function addRowRecord(list, idx, tpl, row){
                        if(idx==0) {
                            reimbursementBackIdx = $("#reimbursementBackList tr").length;
                            idx = reimbursementBackIdx;
                        }
                        bornTemplete(list, idx, tpl, row, idx);
                        reimbursementBackIdx +=1;
                    }
                </script>
            </div>
        </div>
    <div class="form-group layui-row">
        <div class="form-group-label"><h2>报销详情</h2></div>
        <div class="layui-item nav-btns">
            <a class="nav-btn nav-btn-add" onclick="addRow('#workAccountList', workAccountListRowIdx, workAccountListTpl);workAccountListRowIdx = workAccountListRowIdx + 1;" title="新增"><i class="fa fa-plus"></i>&nbsp;新增</a>
        </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="200px"><font color="red">*</font>财务科目</th>
                    <th><font color="red">*</font>报销费用摘要</th>
                    <th width="150px"><font color="red">*</font>发票类型</th>
                    <th width="150px"><font color="red">*</font>报销费用（元）</th>
                    <th width="200px">备注</th>
                    <th width="100px">操作</th>
                </tr>
                </thead>
                <tbody id="workAccountList">
                <c:if test="${not empty workReimbursement.workAccountList}">
                    <c:forEach items="${workReimbursement.workAccountList}" var="workAccount" varStatus="index">
                        <tr id="workAccountList${index.index}">
                            <td class="hide">
                                <input id="workAccountList${index.index}_id" name="workAccountList[${index.index}].id" type="hidden" value="${workAccount.id}"/>
                                <input id="workAccountList${index.index}_delFlag" name="workAccountList[${index.index}].delFlag" type="hidden" value="0"/>
                            </td>
                            <td>
                                <div class="project_reimbursement_div">
                                    <form:select id="workAccountList${index.index}_financialSubjects" path="workAccountList[${index.index}].financialSubjects" class="form-control required">
                                        <form:option value="" label="请选择"/>
                                        <form:options items="${fns:getMainDictList('project_reimbursement')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
                                    </form:select>
                                </div>
                                <div class="not_project_reimbursement_div" style="display:none;">
                                    <form:select id="workAccountList${index.index}financialSubjectss" path="workAccountList[${index.index}].financialSubjectss" class="form-control required">
                                        <form:option value="" label="请选择"/>
                                        <form:options items="${fns:getMainDictList('not_project_reimbursement')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
                                    </form:select>
                                </div>
                            </td>
                            <td>
                                <input id="workAccountList${index.index}_moneyAbstract"  name="workAccountList[${index.index}].moneyAbstract" maxlength="32" type="text" value="${workAccount.moneyAbstract}"  placeholder="请输入费用摘要"  class="form-control required"/>
                            </td>
                            <td>
                                <select id="workAccountList${index.index}_invoiceType" name="workAccountList[${index.index}].invoiceType" class="form-control ">
                                    <option value="专票" <c:if test="${'专票' eq workAccount.invoiceType}">selected</c:if>>专票</option>
                                    <option value="普票" <c:if test="${'普票' eq workAccount.invoiceType}">selected</c:if>>普票</option>
                                </select>
                            </td>
                            <td>
                                <input id="workAccountList${index.index}_money" onchange="getMoney(this.value)" name="workAccountList[${index.index}].money" type="text" value="${workAccount.money}"  placeholder="请输入金额"  maxlength="10" class="form-control number required"/>
                            </td>
                            <td>
                                <input id="workAccountList${index.index}_remarks" name="workAccountList[${index.index}].remarks" type="text" value="${workAccount.remarks}"  maxlength="64" placeholder="请输入备注"  class="form-control"/>
                            </td>

                            <td class="text-center op-td" >
                                <span class="op-btn op-btn-delete" onclick="delRow(this, '#workAccountList${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 width="200px" style="vertical-align:middle;text-align: center;"><label><font color="red">*</font>总报销费用(元)：</label></td>
                    <td >
                        <input htmlEscape="false" id="moneys" name="money" readonly="true" class="form-control layui-input" value="${workReimbursement.money}"/>
                    </td>
                </tr>
            </table>
            <script type="text/template" id="workAccountListTpl">//<!--
                                    <tr id="workAccountList{{idx}}">
                                        <td class="hide">
                                            <input id="workAccountList{{idx}}_id" name="workAccountList[{{idx}}].id" type="hidden" value="{{row.id}}"/>
                                            <input id="workAccountList{{idx}}_delFlag" name="workAccountList[{{idx}}].delFlag" type="hidden" value="0"/>
                                        </td>
                                        <td>
                                            <div class="project_reimbursement_div">
                                                <form:select id="workAccountList{{idx}}_financialSubjects" path="workAccountList[0].financialSubjects" class="form-control required">
                                                    <form:option value="" label="请选择"/>
                                                    <form:options items="${fns:getMainDictList('project_reimbursement')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
                                                </form:select>
                                            </div>
                                            <div class="not_project_reimbursement_div" style="display:none;">
                                                <form:select id="workAccountList{{idx}}_financialSubjectss" path="workAccountList[0].financialSubjectss" class="form-control required">
                                                    <form:option value="" label="请选择"/>
                                                    <form:options items="${fns:getMainDictList('not_project_reimbursement')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
                                                </form:select>
                                            </div>
                                        </td>
                                        <td>
                                            <input id="workAccountList{{idx}}_moneyAbstract"  name="workAccountList[{{idx}}].moneyAbstract" type="text" maxlength="32" value="{{row.moneyAbstract}}"  placeholder="请输入费用摘要"  class="form-control required"/>
                                        </td>
                                         <td style="text-align:center;">
                                             <select id="workAccountList{{idx}}_invoiceType" name="workAccountList[{{idx}}].invoiceType" class="form-control required">
                                              <option value="专票">专票</option>
                                              <option value="普票">普票</option>
                                          </select>
                                        </td>
                                        <td>
                                            <input id="workAccountList{{idx}}_money" onchange="getMoney(this.value)" name="workAccountList[{{idx}}].money" type="text" value="{{row.money}}"  placeholder="请输入金额" maxlength="10" class="form-control number required"/>
                                        </td>
                                        <td>
                                            <input id="workAccountList{{idx}}_remarks" name="workAccountList[{{idx}}].remarks" type="text" value="{{row.remarks}}" maxlength="64" placeholder="请输入备注"  class="form-control "/>
                                        </td>

                                        <td class="text-center op-td" >
                                            {{#delBtn}}<span class="op-btn op-btn-delete" onclick="delRow(this, '#workAccountList{{idx}}')" title="删除"><i class="glyphicon glyphicon-remove"></i>&nbsp;删除</span>{{/delBtn}}
                                        </td>
                                    </tr>//-->
            </script>
        </div>
    </div>
        <div class="form-group layui-row">
            <div class="form-group-label"><h2>专用发票信息</h2></div>
            <div class="layui-item nav-btns">
                <a class="nav-btn nav-btn-add" onclick="addRow('#reimbursementVATTaxes', reimbursementVATTaxesRowIdx, reimbursementVATTaxesTpl);reimbursementVATTaxesRowIdx = reimbursementVATTaxesRowIdx + 1;" title="新增"><i class="fa fa-plus"></i>&nbsp;新增</a>
            </div>
            <div class="layui-item layui-col-xs12 form-table-container">
                <table id="contentTable2" class="table table-bordered table-condensed can-edit">
                    <thead>
                    <tr>
                        <th width="300px"><font color="red">*</font>发票代码</th>
                        <th width="200px"><font color="red">*</font>发票号</th>
                        <th width="200px"><font color="red">*</font>金额</th>
                        <th width="200px"><font color="red">*</font>税额</th>
                        <th width="200px"><font color="red">*</font>价税合计</th>
                        <th width="150px">操作</th>
                    </tr>
                    </thead>
                    <tbody id="reimbursementVATTaxes">
                    <c:if test="${not empty workReimbursement.reimbursementVATTaxes}">
                        <c:forEach items="${workReimbursement.reimbursementVATTaxes}" var="reimbursementVATTaxes" varStatus="index">
                            <tr id="reimbursementVATTaxes${index.index}">
                                <td class="hide">
                                    <input id="reimbursementVATTaxes${index.index}_id" name="reimbursementVATTaxes[${index.index}].id" type="hidden" value="${reimbursementVATTaxes.id}"/>
                                    <input id="reimbursementVATTaxes${index.index}_delFlag" name="reimbursementVATTaxes[${index.index}].delFlag" type="hidden" value="0"/>
                                </td>
                                <td>
                                    <input id="reimbursementVATTaxes${index.index}_invoiceCode"  maxlength="10" minlength="10" name="reimbursementVATTaxes[${index.index}].invoiceCode" maxlength="32" type="text" value="${reimbursementVATTaxes.invoiceCode}"  placeholder="请输入发票代码"  class="form-control number required"/>
                                </td>

                                <td>
                                    <input id="reimbursementVATTaxes${index.index}_invoiceNumber"  maxlength="8" minlength="8" name="reimbursementVATTaxes[${index.index}].invoiceNumber" maxlength="32" type="text" value="${reimbursementVATTaxes.invoiceNumber}"  placeholder="请输入发票号"  class="form-control number required"/>
                                </td>
                                <td>
                                    <input id="reimbursementVATTaxes${index.index}_money" onchange="getMoneyVATT(${index.index})" name="reimbursementVATTaxes[${index.index}].money" type="text" maxlength="32" value="${reimbursementVATTaxes.money}"  placeholder="请输入金额"  class="form-control number required"/>
                                </td>
                                <td>
                                    <input id="reimbursementVATTaxes${index.index}_taxAmount" onchange="getMoneyVATT(${index.index})" name="reimbursementVATTaxes[${index.index}].taxAmount" type="text" maxlength="32" value="${reimbursementVATTaxes.taxAmount}"  placeholder="请输入税额"  class="form-control number required"/>
                                </td>
                                <td>
                                    <input id="reimbursementVATTaxes${index.index}_sumMoney" readOnly="true"  name="reimbursementVATTaxes[${index.index}].sumMoney" type="text" maxlength="32" value="${reimbursementVATTaxes.sumMoney}"    class="form-control number required sumMoney"/>
                                </td>
                                <td class="text-center op-td">
                                    <span class="op-btn op-btn-delete" onclick="delRowA(this, '#reimbursementVATTaxes${index.index}')" title="删除"><i class="glyphicon glyphicon-remove"></i>&nbsp;删除</span>
                                </td>
                            </tr>
                        </c:forEach>
                    </c:if>
                    </tbody>
                </table>
                <script type="text/template" id="reimbursementVATTaxesTpl">//<!--
                                    <tr id="reimbursementVATTaxes{{idx}}">
                                        <td class="hide">
                                            <input id="reimbursementVATTaxes{{idx}}_id" name="reimbursementVATTaxes[{{idx}}].id" type="hidden" value="{{row.id}}"/>
                                            <input id="reimbursementVATTaxes{{idx}}_delFlag" name="reimbursementVATTaxes[{{idx}}].delFlag" type="hidden" value="0"/>
                                        </td>
                                        <td>
                                            <input id="reimbursementVATTaxes{{idx}}_invoiceCode" maxlength="10" minlength="10" name="reimbursementVATTaxes[{{idx}}].invoiceCode" type="text" maxlength="32" value="{{row.invoiceCode}}"  placeholder="请输入发票代码"  class="form-control number required"/>
                                        </td>

                                        <td>
                                            <input id="reimbursementVATTaxes{{idx}}_invoiceNumber"  maxlength="8" minlength="8" name="reimbursementVATTaxes[{{idx}}].invoiceNumber" type="text" maxlength="32" value="{{row.invoiceNumber}}"  placeholder="请输入发票号"  class="form-control number required"/>
                                        </td>
                                         <td>
                                            <input id="reimbursementVATTaxes{{idx}}_money" onchange="getMoneyVATT({{idx}})" name="reimbursementVATTaxes[{{idx}}].money" type="text" value="{{row.money}}" maxlength="32" placeholder="请输入金额"  class="form-control number required"/>
                                        </td>
                                        <td>
                                            <input id="reimbursementVATTaxes{{idx}}_taxAmount"  onchange="getMoneyVATT({{idx}})"name="reimbursementVATTaxes[{{idx}}].taxAmount" type="text" value="{{row.taxAmount}}" maxlength="32" placeholder="请输入税额"  class="form-control number required"/>
                                        </td>
                                         <td>
                                            <input id="reimbursementVATTaxes{{idx}}_sumMoney" readOnly="true"  name="reimbursementVATTaxes[{{idx}}].sumMoney" type="text" value="{{row.sumMoney}}" maxlength="32"  class="form-control number required sumMoney"/>
                                        </td>

                                        <td class="text-center op-td">
                                            {{#delBtn}}<span class="op-btn op-btn-delete" onclick="delRowA(this, '#reimbursementVATTaxes{{idx}}')" title="删除"><i class="glyphicon glyphicon-remove"></i>&nbsp;删除</span>{{/delBtn}}
                                        </td>
                                    </tr>//-->
                </script>
                <script type="text/javascript">
                    var workAccountListRowIdx = 0, workAccountListTpl = $("#workAccountListTpl").html().replace(/(\/\/\<!\-\-)|(\/\/\-\->)/g,"");
                    var reimbursementVATTaxesRowIdx = 0, reimbursementVATTaxesTpl = $("#reimbursementVATTaxesTpl").html().replace(/(\/\/\<!\-\-)|(\/\/\-\->)/g,"");
                    if($("#id").val()){
                        workAccountListRowIdx = ${fn:length(workReimbursement.workAccountList)};
                        reimbursementVATTaxesRowIdx = ${fn:length(workReimbursement.reimbursementVATTaxes)};
                    }
                    $(document).ready(function() {
                        /*var data = ${fns:toJson(workReimbursement.reimbursementVATTaxes)};
                    for (var i=0; i<data.length; i++){
                        addRow('#reimbursementVATTaxes', reimbursementVATTaxesRowIdx, reimbursementVATTaxesTpl, data[i]);
                        reimbursementVATTaxesRowIdx = reimbursementVATTaxesRowIdx + 1;
                    }*/
                    });
                </script>
            </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="${workReimbursement.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>