-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimg_list.php
251 lines (161 loc) · 7.27 KB
/
img_list.php
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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>img_page</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
<link rel="stylesheet" href="./css/font.css">
<link rel="stylesheet" href="./css/xadmin.css">
<script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
<script type="text/javascript" src="./lib/layui/layui.js" charset="utf-8"></script>
<script type="text/javascript" src="./js/xadmin.js"></script>
<!-- 让IE8/9支持媒体查询,从而兼容栅格 -->
<!--[if lt IE 9]>
<script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
<script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="x-nav">
<span class="layui-breadcrumb">
<a target="_parent" href="index.php">首页</a>
<a href="img_list.php">图片管理</a>
<a>
<cite>图片列表</cite></a>
</span>
<a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
<i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>
<div class="x-body">
<table class="layui-hide" id="LAY_table_user" lay-filter="useruv"></table>
</div>
<script type="text/html" id="barDemo">
<a class="layui-btn layui-btn-xs " onclick="" lay-event="detail"><i class="layui-icon"></i>编辑</a>
<a class="layui-btn layui-btn-xs layui-btn-danger" lay-event="del"><i class="layui-icon"></i>删除</a>
</script>
<script src="./lib/layui/layui.js"></script>
<script>
layui.use('table', function(){
var table = layui.table;
//方法级渲染
table.render({
elem: '#LAY_table_user'
,url: 'php/img/img_query.php'
,cols: [[
{field:'img_id', title: '图片ID', sort: true, fixed: false,width:100}
,{field:'img_name', title: '图片名', sort: false, fixed: false}
,{field:'img_show', title: '图片预览', sort: false, fixed: false,templet:'#show-img'}
,{field:'img_text', title: '配图文字', sort: false, fixed: false}
,{field:'img_url', title: '图片地址', sort: false, fixed: false}
,{field:'img_class', title: '图片用途', sort: false, fixed: false,width:100}
//,{field:'img_source', title: '图片来源', sort: false, fixed: false}
// ,{field:'img_direction', title: '跳转地址', sort: true, fixed: false}
,{field:'addtime', title: '添加时间', sort: true, fixed: false,width:180}
,{field:'right', title: '操作', width:178,align:'center',toolbar:"#barDemo", fixed: 'right'}
]]
,id: 'testReload'
,page: true
//,height: 600
});
//js实现条件搜索传值的地方
var $ = layui.$, active = {
reload: function(){
var isSearch = '1';
var search_startdate= $('#search_startdate');
var search_enddate= $('#search_enddate');
var search_gender= $('#search_gender');
var search_source= $('#search_source');
var search_option= $('#search_option');
var search_option_keyword= $('#search_option_keyword');
var 传值名 = $('#传值名');
table.reload('testReload', {
url: 'php/msg_search.php',
method: 'post',
where: {
search_startdate:search_startdate.val(),
search_enddate:search_enddate.val(),
search_gender:search_gender.val(),
search_source:search_source.val(),
search_option: search_option.val(),
search_option_keyword: search_option_keyword.val(),
chuanzhiming: 传值名.val(),
}
});
}
};
//监听表格复选框选择
table.on('checkbox(useruv)', function(obj){
console.log(obj)
});
//监听工具条
table.on('tool(useruv)', function(obj){
var data = obj.data;
if(obj.event === 'detail'){
var c='php/img/img_edit.php?img_id='+data.img_id;
x_admin_show('图片编辑',c,600,420);
} else if(obj.event === 'del'){
layer.confirm('确定删除这张图片?', function(index){
console.log(data);
obj.del();
layer.close(index);
$.ajax({
url: "php/img/img_delete.php",
type: "post",
data:{"img_id":data.img_id,"img_url":data.img_url},
dataType: "text",
});
});
} else if(obj.event === 'edit'){
layer.prompt({
formType: 2
,title: '修改 ID 为 ['+ data.id +'] 的访问量'
,value: data.uv
}, function(value, index){
EidtUv(data,value,index,obj);
});
}
});
$('.demoTable .layui-btn').on('click', function(){
var type = $(this).data('type');
active[type] ? active[type].call(this) : '';
});
function EidtUv(data,value,index,obj) {
$.ajax({
url: "UVServlet",
type: "POST",
data:{"uvid":data.id,"memthodname":"edituv","aid":data.aid,"uv":value},
dataType: "json",
success: function(data){
if(data.state==1){
layer.close(index);
//同步更新表格和缓存对应的值
obj.update({
uv: value
});
layer.msg("修改成功", {icon: 6});
}else{
layer.msg("修改失败", {icon: 5});
}
}
});
}
});
layui.use('laydate', function(){
var laydate = layui.laydate;
//执行一个laydate实例
laydate.render({
elem: '#search_startdate' //指定元素
});
//执行一个laydate实例
laydate.render({
elem: '#search_enddate' //指定元素
});
});
</script>
<script type="text/html" id="show-img"><img src="../{{d.img_url}}" /></script>
</form>
</body>
</html>