<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/webpage/include/taglib.jsp"%>
<html>
<head>
    <title>收入登记导入列表</title>
</head>
<body class="hideScroll">
<form:form id="inputForm"  action="${ctx}/workreceiptsregister/workReceiptsRegister/saveImport" method="post" class="form-horizontal">
<div class="tabs-container">
    <ul class="nav nav-tabs">
        <li class="active"><a data-toggle="tab" href="#tab-1" aria-expanded="true" style="margin-top: 15px">收入明细</a>
        </li>
    </ul>
</div>
<table id="contentTable" class="table table-striped table-bordered table-condensed">
    <thead>
    <tr>
        <th> <input type="checkbox"></th>
        <th style="text-align: center">到账时间</th>
        <th style="text-align: center">到账金额</th>
        <th style="text-align: center">对方账号</th>
        <th style="text-align: center">对方户名</th>
    </tr>
    </thead>
    <tbody id="workRegisterList">
    </tbody>
</table>
<script type="text/template" id="workRegisterTpl">//<!--
					<tr id="registers{{idx}}">
                <td> <input type="checkbox" id="{{idx}}"></td>
                <td>
                    <input id="registers{{idx}}_arrivalDate" name="registers[{{idx}}].arrivalDate" type="text" value="{{row.arrivalDate}}"  readOnly="true"  class="form-control "/>
                </td>
                <td>
                    <input id="registers{{idx}}_arrivalAmt" name="registers[{{idx}}].arrivalAmt" type="text" value="{{row.arrivalAmt}}"  readOnly="true"  class="form-control money"/>
                </td>
                <td>
                    <input id="registers{{idx}}_clientAccno" name="registers[{{idx}}].clientAccno" type="text" value="{{row.clientAccno}}"  readOnly="true"  class="form-control "/>
                </td>
                <td>
                    <input id="registers{{idx}}_iclientAccname" name="registers[{{idx}}].clientAccname" type="text" value="{{row.clientAccname}}" readOnly="true"  class="form-control required"/>
                </td>
				</tr>//-->
</script>
<script type="text/javascript">
    var workRegisterIdx = 0;
    var workRegisterTpl = $("#workRegisterTpl").html().replace(/(\/\/\<!\-\-)|(\/\/\-\->)/g,"");
    $(document).ready(function() {
        var data = ${fns:toJson(registers)};
        for (var i=0; i<data.length; i++){
            addRow('#workRegisterList', workRegisterIdx, workRegisterTpl,data[i]);
        }
        $(":input.money").change();
    });

    function formatNum(obj) {
        var val = $(obj).val();
        if(val==null||val==''|| isNaN(val))return;
        var money = parseFloat((val + "").replace(/[^\d\.-]/g, "")).toFixed(2) + "";
        var l = money.split(".")[0].split("").reverse(),
            r = money.split(".")[1];
        t = "";
        for(i = 0; i < l.length; i ++ )
        {
            t += l[i] + ((i + 1) % 3 == 0 && (i + 1) != l.length ? "," : "");
        }
        $(obj).val(t.split("").reverse().join("") + "." + r);
    }

    function addRow(list, idx, tpl, row){
        bornTemplete(list, idx, tpl, row, idx);
        workRegisterIdx +=1;
    }

    function bornTemplete(list, idx, tpl, row, idx1){
        var idx1 = $("#workRegisterList tr").length +1;
        $(list).append(Mustache.render(tpl, {
            idx: idx, delBtn: true, row: row,
            order:idx1 + 1, idx1:idx1
        }));
        $(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");
                }
            }
        });
    }
</script>
</form:form>
</body>
</html>
