<!--# 
var name = name!"attachement";
var filesListId = name+"DataList";
//加载已经在数据库列表
var files = (isNew=="true")?[]:core.file(batchFileUUID);

-->
<div class="layui-upload">
	<input type="hidden" name="${name}" value="${batchFileUUID}"  id="${name}" ${isNotEmpty(layVerify)?('lay-verify="'+layVerify+'"'):''} />

	<div class="layui-upload-list">
		<table class="layui-table">
			<thead>
				<tr>
					<th>编号</th>
					<th>文件名</th>
					<th>状态</th>
					<th>操作</th>
				</tr>
			</thead>
			<tbody id="${filesListId}">
				<!--# for(file in files){  -->
		      	<tr>
		      	<td>${file.id}</td>
		      	<td>${file.name}</td>
		        <td>成功</td>
		        <td>
			        <button class="layui-btn layui-btn-mini  demo-download">下载</button>
		        </td>
		      </tr>
      			<!--# }  -->
			</tbody>
		</table>
	</div>

</div>

<script>
var downloadStr ='<button class="layui-btn layui-btn-mini demo-download">下载</button>';
layui.use('upload',function() {
    var $ = layui.jquery;
    upload = layui.upload;
    var demoListView = $('#${filesListId}');
    var trs = demoListView.children();
    for (var i = 0; i < trs.length; i++) {
        initTr($(trs[i]));
    }

    function initTr(tr) {
    		var tds = tr.children();
    		var fileId = tds.eq(0).html();
    		var fileName= tds.eq(1).html();

        //下载服务器文件
        tr.find('.demo-download').on('click', function() {
            //文件下载地址
            var address = "/core/file/download/"+fileId+"/${batchFileUUID}/"+fileName;
            //var address = "${ctxPath}/core/file/download/"+fileId+"/${batchFileUUID}/"+fileName;
            console.log(address);
           	window.location.href=address;
           	return false;
        });
    }

});
 </script>

