index.php
18.6 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
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
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
<!DOCTYPE html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html>
<head>
<meta charset="UTF-8">
<title>管理员列表</title>
<link rel="stylesheet" type="text/css" href="/assets/common/css/themes/gray/easyui.css" />
<link rel="stylesheet" type="text/css" href="/assets/common/css/themes/gray/menu.css" />
<link rel="stylesheet" type="text/css" href="/assets/common/css/themes/icon.css" />
<link rel="stylesheet" type="text/css" href="/assets/web/css/jitnry.css" />
<link rel="stylesheet" type="text/css" href="/assets/web/css/common_car.css" />
<script type="text/javascript" src="/assets/common/js/jquery.min.1.9.4.js"></script>
<script type="text/javascript" src="/assets/common/js/jquery.easyui.min.1.9.4.js"></script>
<script type="text/javascript" src="/assets/common/js/jquery.cookie.1.4.1.js"></script>
<!-- 插件调用 --->
<script type="text/javascript" src="/assets/common/js/datagrid-detailview.js"></script>
<script type="text/javascript" src="/assets/common/locale/easyui-lang-zh_CN.js"></script>
<!-- 基础 JS 调用 -->
<script type="text/javascript" src="/assets/web/js/src/easyui.base.js"></script>
<script type="text/javascript" src="/assets/web/js/src/allCity.js"></script>
<style>
#fm>div {
width: 100%;
display: flex;
justify-content: space-around;
margin: 10px 0;
}
#fm>div input{
width: 180px;
}
</style>
</head>
<body style="margin-bottom: 54px;">
<div class="easyui-layout" data-options="fit:true">
<div data-options="split:false,region:'west',collapsible:true,footer:'#win_base_org_form_footer'" title="人员列表" id="saveBox" style="width:100%;">
<div class="easyui-panel" style="width:100%;max-width:100%;padding: 5px 5px">
<div style="margin-bottom:5px;">
<a id="name_add_but" href="#" data-options="iconCls:'icon-add'" class="my_but" style="vertical-align: middle;">新增</a>
</div>
</div>
<table id="dg" style="width: 100%; height: 92%"
data-options="rownumbers:true,singleSelect:true,pagination:true,toolbar:'#tb'">
</table>
<div id="tb" style="padding:5px;height:auto">
<div>
所属机构:
<input id="xiala" name="xiala" class="easyui-combobox" data-options="
valueField: 'id',
textField: 'mechanismName',
url: '/products/role/getMechanism'">
入职时间: <input class="easyui-datebox" id='start' name='start' style="width:180px">
截止时间: <input class="easyui-datebox" id='end' name='end' style="width:180px">
姓名: <input class="easyui-textbox" type="text" id='names' name='names'>
电话: <input class="easyui-numberbox" type="text" id='tel' name='tel'>
<a href="#" class="easyui-linkbutton" id="search_buttn" iconCls="icon-search">搜索</a>
<!-- <a id="derive_btn" href="/products/fu_ji_tong/to_excel" class="easyui-linkbutton" style="height:28px" data-options="iconCls:'icon-undo'">导出</a>-->
</div>
</div>
</div>
</div>
<div id="win" class="easyui-dialog" title="提示" style="width: 500px; padding: 10px 20px; height: auto" closed="true" buttons="#dlg-buttons">
<form id="fm" name="frm" method="post" style="margin-top: 20px; margin-left: 20px;">
<table style="padding: 10px 20px;" cellspacing="10">
<tr>
<td>用户名称:</td>
<td><input class="easyui-textbox" type="text" name="name" id="name" data-options="required:true,validType:'length[2,5]'"/></td>
<input class="easyui-textbox" id="user_id" name="user_id" type="hidden">
</tr>
<tr>
<td>性别:</td>
<td><input id="statusId" name="sex" class="easyui-switchbutton" data-options="onText:'男',offText:'女'" style="height:30px"></td>
</tr>
<tr>
<td>电话:</td>
<td><input class="easyui-textbox" type="text" name="phone" id="phone" data-options="required:true" validType='phoneNum'"/></td>
</tr>
<tr>
<td>所属机构:</td>
<td>
<!-- <input id="cc1" name="mechanism" class="easyui-combobox" data-options="-->
<!-- valueField: 'id',-->
<!-- textField: 'mechanismName',-->
<!-- url: '/products/role/getMechanism',-->
<!-- onSelect: function(rec){-->
<!-- var url = '/products/role/getDepartment?id='+rec.id;-->
<!-- $('#cc2').combobox('reload', url);-->
<!-- var url1 = '/products/role/generateNumber?id='+rec.id;-->
<!-- $.ajax({-->
<!-- url:url1,-->
<!-- success:function(e){-->
<!-- var arr = JSON.parse(e);-->
<!---->
<!-- $('#personalNumber').textbox('setValue',arr.num);-->
<!-- $('#personalNumber1').textbox('setValue',arr.num);-->
<!-- }-->
<!-- })-->
<!-- }">-->
<input id="cc1" name="mechanism" class="easyui-combobox" required="true" data-options="
valueField: 'id',
textField: 'mechanismName',
url: '/products/role/getMechanism',
onSelect: function(rec){
var url = '/products/role/getDepartment?id='+rec.id;
$.ajax({
url:url,
success:function(a){
var arr1=JSON.parse(a);
console.log(JSON.parse(a))
$('#cc2').combobox({
data:JSON.parse(a),
valueField:'id',
textField: 'departmentName',
});
var url1 = '/products/role/generateNumber?id='+rec.id+'&rule_id='+rule_id;
$.ajax({
url:url1,
success:function(e){
var arr = JSON.parse(e);
$('#personalNumber').textbox('setValue',arr.num);
$('#personalNumber1').textbox('setValue',arr.num);
}
})
}
})
}">
</td>
</tr>
<tr>
<td>所属部门:</td>
<td><input id="cc2" class="easyui-combobox" name="department" data-options="valueField:'id',textField:'departmentName'" required="true"></td>
</tr>
<tr>
<td>个人编号:</td>
<td>
<input class="easyui-textbox" type="text" id="personalNumber" disabled/>
<input class="easyui-textbox" id="personalNumber1" name="personalNumber" type="hidden">
</td>
</tr>
<tr>
<td>职位名称:</td>
<td><input class="easyui-textbox" type="text" name="job" id="job" data-options="required:true"/></td>
</tr>
<tr>
<td>入职时间:</td>
<!-- <td><input class="easyui-datebox" name="entryTime" id="entryTime" disabled/></td>-->
<td><input class="easyui-datebox" name="entryTime" id="entryTime" required="true"/></td>
</tr>
<tr>
<td>离职时间:</td>
<td><input class="easyui-datebox" name="quitTime" id="quitTime" /></td>
</tr>
<tr>
<td>当前状态:</td>
<td><input class="easyui-combobox" style="width:160px" name="status" id="status"
data-options="valueField:'id',
textField:'text',
data:
[{ 'id':1,
'text':'试用期' ,
},{ 'id':2,
'text':'正式员工' ,
},{
'id':3,
'text':'已离职'
}] ,panelHeight:'auto'
" required="true"/></td>
</tr>
<div id="dlg-buttons" style="display: block">
<a id="confirm" href="javascript:void(0)" class="easyui-linkbutton c6" iconcls="icon-ok" onclick="submitForm()" style="width: 90px">提交</a>
<a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-cancel" onclick="javascript:$('#win').dialog('close')" style="width: 90px">取消</a>
</div>
</table>
</form>
</div>
</body>
<tbody id="html_table"></tbody>
<script type="text/javascript" src="/assets/web/js/src/common_fu.js"></script>
<script>
$(function(){
$.extend($.fn.validatebox.defaults.rules, {
phoneNum: { //验证手机号
validator: function(value, param){
return /^1[3-8]+\d{9}$/.test(value);
},
message: '请输入正确的手机号码。'
},
comboxValidate : {
validator : function(value, param,missingMessage) {
if($('#'+param).combobox('getValue')!='' && $('#'+param).combobox('getValue')!=null){
return true;
}
return false;
},
message : "{1}"
}
});
})
var rule_id='';
//下拉框搜索
init_datagrid('/products/role/getUsers', 0);
//下拉框搜索
$('#search_buttn').bind('click', function() {
var xiala=$('#xiala').combobox('getValue');
var start = $("#start").val();
var end = $("#end").val();
var tel = $("#tel").val();
var names = $("#names").val();
if(tel.length>0){
if(tel.length!=11){
$.messager.alert('检索手机号','手机号格式错误,请重新输入');
return false;
}
}
var result = {
xiala,
start,
end,
tel,
names
}
// console.log(result);return false;
init_datagrid('/products/role/getUsers', result);
});
function init_datagrid(data_url, res) {
//表头字段
var arr_columns = dg_columns();
$("#dg").datagrid({
rownumbers:true,
singleSelect:true,
pagination:true,
url:data_url,
queryParams: res,
method:'post',
columns: [arr_columns],
loadMsg: '正在加载数据',
emptyMsg: '列表为空',
});
}
function dg_columns() {
var arr = new Array();
arr.push({
field: 'name',
title: '用户名称',
width: 80,
align: 'center'
});
arr.push({
field: 'sex',
title: '性别',
width: 80,
align: 'center'
});
arr.push({
field: 'phone',
title: '电话',
width: 150,
align: 'center'
});
arr.push({
field: 'mechanism',
title: '所属机构',
width: 220,
align: 'center'
});
arr.push({
field: 'department',
title: '所属部门',
width: 200,
align: 'center'
});
arr.push({
field: 'personalNumber',
title: '人员编号',
width: 200,
align: 'center'
});
arr.push({
field: 'job',
title: '职位名称',
width: 150,
align: 'center'
});
arr.push({
field: 'status',
title: '当前状态',
width: 150,
align: 'center'
});
arr.push({
field: 'entryTime',
title: '入职时间',
width: 150,
align: 'center'
});
arr.push({
field: 'quitTime',
title: '离职时间',
width: 150,
align: 'center'
});
arr.push({
field: 'id',
title: '操作',
width: 90,
align: 'center',
formatter:formatOper
});
// console.log(arr)
return arr;
}
//操作框
function formatOper(val, row, index) {
return '<a href="javascript:void(0)" onclick="showUser(' + val + ')">编辑</a>';
}
//添加
$('#name_add_but').linkbutton({
onClick: function () {
addFile();
}
});
function addFile(){
rule_id='';
$('#entryTime').textbox({disabled:false})
$('#win').form('clear')
$('#win').dialog({
title: '新增',
width: 500,
height: "auto",
top:20,
closed: false,//显示对话框
cache: false,
modal: true
});
}
//修改
function showUser(row){
if(row){
// alert(row);
var id=row;
rule_id=id;
if (rule_id){
$('#entryTime').textbox({disabled:true})
}
var result = {
id
}
$("#win").dialog("open").dialog("setTitle","人员信息修改");
//ajax请求数据
$.ajax({
type: "post",
data: result,
async: false,
url: "/products/role/getUsers",
success: function(data) {
// console.log(data);
var arr = JSON.parse(data);
$('#user_id').textbox('setValue',arr.rows[0].id);
$('#username').textbox('setValue',arr.rows[0].username);
$('#password').textbox('setValue',arr.rows[0].password);
$('#name').textbox('setValue',arr.rows[0].name);
$('#job').textbox('setValue',arr.rows[0].job);
$('#personalNumber').textbox('setValue',arr.rows[0].personalNumber);
$.ajax({
url:'/products/role/getMechanism',
success:function(e){
var mechanism=JSON.parse(e).find((v)=>{
if(v.mechanismName===arr.rows[0].mechanism){
$('#cc1').combobox('select',v.id);
$.ajax({
url:"/products/role/getDepartment?id="+v.id,
success:function(ee){
// console.log(JSON.parse(ee))
var department=JSON.parse(ee).find((vv)=>{
if(vv.departmentName===arr.rows[0].department){
$('#cc2').combobox('select',vv.id);
}
})
}
})
}
})
}
})
var statusData=$('#status').combobox('getData');
var status=statusData.find((ss)=>{
if(ss.text===arr.rows[0].status){
$('#status').combobox('select',ss.id);
}
})
//
if(arr.rows[0].sex == "男") {
$('#statusId').switchbutton('check');
}else {
$('#statusId').switchbutton('uncheck');
}
$('#phone').textbox('setValue',arr.rows[0].phone);
$('#entryTime').textbox('setValue',arr.rows[0].entryTime);
$('#quitTime').textbox('setValue',arr.rows[0].quitTime);
$('#materialname').combobox('setValue', $('#materialname option')[2].value);
},
error:function(data){
console.log(data)
}
});
}
}
function submitForm(){
$('#fm').form('submit', {
url:'/products/role/user_add',
onSubmit: function(){
return $(this).form('validate');
// do some check
// return false to prevent submit;
},
success:function(data){
var arr = JSON.parse(data);
$.messager.alert("提示", arr.msg);
if(arr.code==200){
$('#win').dialog({
closed: true, // 隱藏列表
});
$('#dg').datagrid('reload');
}
// // console.log(data);
// //$.messager.alert('',msg);
// //console.log(data);
// //alert(data)
}
});
}
</script>
</html>