downloadfilelist.jsp
7.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%
String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath();
String contextPath = request.getContextPath();
String listType=request.getParameter("listType");
String fid=request.getParameter("fid");
String status=request.getParameter("status");
String logginUserId=request.getParameter("logginUserId");
String retrievestate = request.getParameter("state");
String resourceid= request.getParameter("resourceid");
%>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="../../libs/layui2/css/layui.css" rel="stylesheet" />
<script type="text/javascript" src="../../libs/layui2/layui.js"></script>
<script type="text/javascript" src="../../libs/jquery/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="../../common/js/config.js"></script>
<script type="text/javascript" charset="utf-8" src="../../common/js/global/global.modelctls.js"></script>
<script type="text/javascript" charset="utf-8" src="../../common/js/global/global.js"></script>
<script src="../..//common/js/global/global.localStorage.js"></script>
<script type="text/javascript" src="../../js/common.js"></script>
<script src="<%=basePath%>/common/js/global/global.localStorage.js"></script>
<script src="../../libs/jquery/jquery.cookie.js"></script>
<style type="text/css">
.layui-form{
position: relative;
top:50px;
}
body{
padding-left:30px;
padding-right:30px;
}
</style>
<title>Insert title here</title>
</head>
<body>
<div class="all">
<div class="demoTable" style="position: absolute; left:30px; top:10px;">
<div class="layui-inline">
<input class="layui-input" placeholder="请输入搜索内容" name="id" id="demoReload" autocomplete="off">
</div>
<button class="layui-btn layui-btn-normal" data-type="reload">搜索</button>
</div>
<table id="demo" lay-filter="test" ></table>
</div>
</body>
<script type="text/javascript">
var global = global || {};
global = global || {};
global.contextPath='<%=contextPath%>';
</script>
<script type="text/javascript">
$(function(){
var urlParamObj = getUrlQueryString();
validateFtoken(urlParamObj['ftoken']);
for(var key in urlParamObj){
$('#'+key).val(urlParamObj[key]);
}
})
</script>
<script>
var curserver=null;
var iphost=null;
var token=$.cookie('ftoken');
$(function () {
curserver = CONF_BACK_SERVERURL;
iphost=CONF_DOC_SERVERURL;
var guidKey = getQueryString('guid');
var guidInfo = (new GlobalLocalCache()).GetCacheResult(guidKey,'','');
var paramInfo = decodeURI(guidInfo['paramUrl']);
var ftokenInfo = guidInfo['ftoken'];
var paramObj = {'ftoken':ftokenInfo};
//初始是一
//loadData(1);
downloadlist();
})
function downloadlist() {
layui.use(['laypage', 'layer','table'], function(){
var table = layui.table
,layer = layui.layer,
laypage=layui.laypage;
//第一个实例
table.render({
elem: '#demo'
,page: { //支持传入 laypage 组件的所有参数(某些参数除外,如:jump/elem) - 详见文档
layout: ['limit', 'count', 'prev', 'page', 'next', 'skip'] //自定义分页布局
//,curr: 5 //设定初始在第 5 页
,groups: 1 //只显示 1 个连续页码
,first: false //不显示首页
,last: false //不显示尾页
,theme: '#1E9FFF'
}
,id: 'testReload'
,url: curserver + global.modelctls.homepage.list
,limits: [10,15,20,30]
,limit: 15 //每页默认显示的数量
,where:{listtype:"下载中心",condition:""}
,method:'post' // 请求方式
,headers: {'token': token}
,skin:'line'
,height:'full-100'
,request: {
pageName: 'pageIndex' //页码的参数名称,默认:page
,limitName: 'pageSize' //每页数据量的参数名,默认:limit
}
,response: {
countName: 'total' //规定数据总数的字段名称,默认:count
,dataName: 'Data' //规定数据列表的字段名称,默认:data
}
/* ,data:data */
,cols: [[ //表头
{field: '公告标题', title: '文件名称',event:"downloadclick"},
{field: '公告内容', title: '文件内容',event:"downloadclick"},
{field: '创建时间', title: '创建时间',event:"downloadclick"
,templet: function(d){
console.log(d);
var date=formatDate(d.创建时间);
return date
}
}
]]
});
var $ = layui.$, active = {
reload: function(){
var demoReload = $('#demoReload');
//执行重载
table.reload('testReload', {
page: {
curr: 1 //重新从第 1 页开始
}
,where: {
listtype:"下载中心",
condition: demoReload.val()
}
}, 'data');
}
};
$('.demoTable .layui-btn').on('click', function(){
var type = $(this).data('type');
active[type] ? active[type].call(this) : '';
});
//监听工具条
table.on('tool(test)', function(obj){
if(obj.event=="downloadclick"){
var path=obj.data.附件路径;
findfile(path);
}
});
});
}
function findfile(path){
if(path!=""&&path!=null){
$("#images").empty();
var listUrl =iphost+ "/ftpfile/listkzx.do";
$.ajax({
type:"POST",
url: listUrl,
dataType:"json",
async:false,
data:{target:path},
success:function (data) {
download(data);
},
error: function(data, textStatus, errorThrown){
console.log(data);
}
});
}
}
function download(data){
iphost=CONF_DOC_SERVERURL;
var url = iphost+"ftpfile/downloadfile.do";
if(data!=null&&data.length!=0){
//eg2
layer.open({
content: '是否下载?'
,btn: ['下载', '取消']
,yes: function(index, layero){
//按钮【按钮一】的回调
window.open(url+"?filename="+data[0].path);
layer.closeAll();
}
,btn2: function(index, layero){
//按钮【按钮二】的回调
//return false 开启该代码可禁止点击该按钮关闭
},
cancel: function(){
//右上角关闭回调
//return false 开启该代码可禁止点击该按钮关闭
}
});
}
}
function formatDate(date) {
var date = new Date(date);
var YY = date.getFullYear() + '-';
var MM = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
var DD = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate());
var hh = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
var mm = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':';
var ss = (date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds());
return YY + MM + DD +" "+hh + mm + ss;
}
</script>
</html>