-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathindex.php
325 lines (287 loc) · 10.8 KB
/
index.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
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
<?php
require_once dirname(__FILE__).'/src/nav.php';
?>
<link rel="stylesheet" href="<?php $rootpath ?>/src/css/index.css">
<script src="<?php $rootpath ?>/src/js/clipboard.min.js"></script>
<script src="<?php $rootpath ?>/src/js/jquery.nicescroll.min.js"></script>
<div class="wrap">
<div class="layui-row layui-col-space15">
<div class="layui-col-md9">
<form class="layui-form layui-form-pane" action="">
<div class="layui-form-item search-wrap" pane>
<label class="layui-form-label search-button"><span class="iconfont"></span></label>
<div class="layui-input-block search-input">
<input type="text" name="title" placeholder="在这里搜索 / Search" autocomplete="off" class="layui-input">
</div>
<div class="filter-button"><span class="iconfont"></span><span lang="筛选"></span></div>
<div class="list-count">
<span lang="共"></span>
<span class="listCount">0</span>
<span lang="位联系人"></span>
</div>
</div>
</form>
</div>
<div class="layui-col-md3">
<div class="layui-btn-group">
<button class="layui-btn layui-btn-normal JS-add">
<i class="layui-icon"></i> <span lang="添加联系人"></span>
</button>
<button class="layui-btn layui-btn-primary JS-batch">
<i class="layui-icon"></i> <span lang="批量管理"></span>
</button>
</div>
</div>
</div>
<div class="layui-row">
<div class="area1">
<div class="layui-progress jindutiao" lay-filter="jindutiao">
<div class="layui-progress-bar layui-bg-blue" lay-percent="0%"></div>
</div>
<table class="layui-table" id="table1" lay-filter="table1"></table>
</div>
</div>
<div class="layui-row">
<div class="footer-line">© BING - MIT License</div>
</div>
</div>
<script type="text/javascript" src="<?php $rootpath ?>/src/js/custom.js"></script>
<script type="text/javascript">
//全局变量,判断表格是否刷新
var tableRef = false;
//初始化焦点页面
var idx = 'index';
$(document).ready(function(){
$("#index").addClass("layui-this");
//初始化语言
initLang('index',''+langNow+'');
langPages.push('index');
//使用layui前端框架
layui.use(['table', 'form','element'], function(){
var table = layui.table;
var form = layui.form;
var element = layui.element;
var timer = setInterval(function(){});
function progressRandom(start,stop){
if($('.layui-progress-bar').css('width') == '100%'){
element.progress('jindutiao', '0%');
}
$('.jindutiao').show();
clearInterval(timer);
timer = setInterval(function(){
start = start + Math.random()*10|0;
if(start > stop){
start = stop;
clearInterval(timer);
}
if(start == 100){
element.progress('jindutiao', '100%');
$('.jindutiao').fadeOut(1500);
}else{
element.progress('jindutiao', start+'%');
}
}, 10+Math.random()*100);
}
//页面首次打开自动加载表格
initTable('');
var table1;
var table1Data;
function initTable(name){
action = 'init';
progressRandom(0,90);
table1 = table.render({
elem:'#table1',
height: 528, //容器高度
url: rootpath+'/src/controller/list_controller.php',
where: {name:name,action:action},
even:true,
size:'sm',
method: 'post',
id:'table1',
page: false, //是否开启分页
cols: [[ //标题栏
{field: 'GUID',width:1,title:''},
{field: 'XING_MING',title:'<span lang="姓名"></span>',width:90, sort: true,align:'center',style:"text-align:center;font-size:13px;",templet: '#template2'},
{field: 'GONG_SI', title: '<span lang="公司"></span>', width:200, sort: true,align:'center',style:"text-align:center;font-size:13px;"},
{field: 'SHOU_JI', title: '<span lang="手机"></span>', width:110,align:'center',style:"text-align:center;font-size:13px;"},
{field: 'ZUO_JI', title: '<span lang="座机"></span>', width:110, sort: true,align:'center',style:"text-align:center;font-size:13px;"},
{field: 'YOU_XIANG', title: '<span lang="邮箱"></span>', width:220,align:'center',style:"text-align:left;font-size:13px;"},
{field: 'BEI_ZHU', title: '<span lang="备注"></span>',align:'center', sort: true,style:"text-align:left;font-size:13px;"},
{field: 'QUAN_XIAN', title: '<span lang="权限"></span>',width:95,fixed:'right',align:'center',style:"text-align:center;font-size:13px;",templet: '#template1'},
]],
done: function(res, curr, count){
progressRandom(90,100);
initLang('index',''+langNow+''); //初始化语言
table1Data = res.data;
//显示联系人数量
$(".listCount").text(res.data.length);
//移除滚动条
$(".nicescroll-rails").remove();
//自定义中间滚动条初始化
$(".layui-table-body").niceScroll({
cursorcolor:"#888",
cursorwidth:"3px",
autohidemode:false
});
inputSearch(); //根据搜索栏输入,筛选数据显示
}
});
}
//搜索输入监听 - 重新加载表格
var inputStat = 0;
//搜索函数
function inputSearch(){
inputStat += 1;
//延迟执行,防止快速输入时频繁刷新表格
setTimeout(function(){
inputStat -= 1;
if(inputStat==0){
//筛选表格
name = Trim($('.search-input input').val());
if(name!=''){
$('.layui-table-body .layui-table').find('tr').hide();
for (var id in table1Data){ // 按块模糊搜索算法
var searchStr = '';
index = table1Data[id]['LAY_TABLE_INDEX']; //获取此行索引值
for(var key in table1Data[id]){ // 遍历行数据
var piPeiDu = 0;
if(key!='GUID'&&key!='QUAN_XIAN'&&key!='USER_ID'&&key!='LAY_TABLE_INDEX'){
var dataCache = table1Data[id][key];
for(k in name){ // 匹配度计算
if(dataCache !=null){
var piPei = dataCache.toUpperCase().indexOf(name[k].toUpperCase()); //转大写,匹配大小写
if(piPei!=-1){
piPeiDu += 1;
dataCache = dataCache.slice(piPei+1);
}
}
}
}
if(piPeiDu == name.length){ // 如果匹配查询
$('.layui-table-body tr[data-index="'+index+'"]').show(); //此行显示
}
}
}
}else{
$('.layui-table-body tr').show();
}
}
$(".layui-table-body").getNiceScroll().resize(); //重置滚动条
},300);
}
//监听输入事件
$('.search-input input').bind('input propertychange', function() {
inputSearch(); //执行搜索函数
});
//添加联系人按钮点击事件
$('.JS-add').click(function(){
//打开添加弹出层
layer.open({
type: 2,
title: '添加联系人 - Add contacts',
shade: 0.4,
area: ['830px','510px'],
content: rootpath+'/src/view/addIframe.php',
end:function(){
if(tableRef==true){
initTable('');
tableRef = false;
}
}
});
});
$('.JS-batch').click(function(){
location.href = '/manage/piLiang';
});
//通讯录表格行双击事件 - 弹出查看详细窗口
$('body').on('dblclick', '.layui-table>tbody>tr', function (){
var self = $(this);
dataIndex = self.attr('data-index'); //获取此行id
GUID = $(this).find("div[class*='-GUID']").text(); //获取此行id
//打开添加弹出层
layer.open({
type: 2,
title: '查看联系人 - View contacts',
shade: 0.4,
area: ['830px','510px'],
content: rootpath+'/src/view/editIframe.php',
end:function(){
if(tableRef==true){
initTable('');
tableRef = false;
}
}
});
})
//通讯录姓名点击事件 - 弹出查看详细窗口
$('body').on('click', '.namehref', function (){
GUID = $(this).parents('tr').find("div[class*='-GUID']").text(); //获取此行id
//打开添加弹出层
layer.open({
type: 2,
title: '查看联系人 - View contacts',
shade: 0.4,
area: ['830px','510px'],
content: rootpath+'/src/view/editIframe.php',
end:function(){
if(tableRef==true){
initTable('');
tableRef = false;
}
}
});
})
//通讯录表格移入事件 - 显示复制按钮
$('body').on('mouseenter', '.layui-table>tbody>tr>td', function (){
var self = $(this);
var type = self.attr('data-field');
var text = self.find('.layui-table-cell').text();
if(type=='YOU_XIANG'){
self.append(
'<a class="iconfont icon-email" href="mailto:'+text+'"></a>'+
'<div class="iconfont icon-copy" data-clipboard-text="'+text+'"></div>'
);
}else if(type!='QUAN_XIAN'){
self.append('<div class="iconfont icon-copy" data-clipboard-text="'+text+'"></div>');
}
});
$('body').on('mouseleave', '.layui-table>tbody>tr>td', function (){
var self = $(this);
self.find('.iconfont').remove();
});
var clipboard = new Clipboard('.icon-copy');
clipboard.on('success', function(e) {
layer.msg('已复制到粘贴板:'+e.text);
e.clearSelection();
});
//筛选按钮点击事件
$('.filter-button').click(function(){
//打开筛选弹出层
layer.open({
type: 2,
title: '',
shade: 0.4,
area: ['540px','378px'],
content: rootpath+'/src/view/filterIframe.php',
end:function(){
initTable('');
}
});
});
});
});
</script>
<!--模板引擎1:显示权限-->
<script type="text/html" id="template1">
{{# if(d.USER_ID=='<?php echo $_SESSION['USER_ID']; ?>'){ }}
<span class="layui-icon icon-blue"></span>
{{# } else if(d.QUAN_XIAN=='2'){ }}
<span class="layui-icon icon-green"></span>
{{# } else { }}
<span class="layui-icon icon-gray"></span>
{{# } }}
</script>
<!--模板引擎2:姓名列-->
<script type="text/html" id="template2">
<div class="namehref">{{d.XING_MING}}</div>
</script>