staff.php
8.69 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
<?php $this->load->view('common/header'); ?>
<body>
<?php $this->load->view('perm/header'); ?>
<div class="page-container">
<form class="" onreset="resetHandler()">
<div class="row cl mb-20">
<div class="col-xs-2">
<span class="select-box">
<select class="select table_search" size="1" column="6" name="departmentId">
<option value="" selected>网点</option>
<?php foreach ($this->session->departments as $k=>$v):?>
<option value="<?=$v->id?>"><?=$v->name?></option>
<?php if($v->children && !empty($v->children)):?>
<?php foreach ($v->children as $kk=>$vv):?>
<option value="<?=$vv->id?>"> <?=$vv->name?></option>
<?php endforeach;?>
<?php endif;?>
<?php endforeach;?>
</select>
</span>
</div>
<div class="col-xs-2">
<span class="select-box">
<select class="select table_search" size="1" column="5" name="role">
<option value="" selected>角色</option>
<?php foreach ($this->session->role as $k=>$v):?>
<option value="<?=$v->id?>"><?=$v->nameZh?></option>
<?php endforeach;?>
</select>
</span>
</div>
<div class="col-xs-2">
<span class="select-box">
<select class="select table_search" size="1" column="3" name="status">
<option value="" selected>状态</option>
<option value="1">正常</option>
<option value="2">冻结</option>
<option value="3">失效</option>
<option value="4">过期</option>
</select>
</span>
</div>
<div class="col-xs-2">
<input type="text" class="form-control input-text table_search" value="" size="1" placeholder="用户名" column="1" name="userName">
</div>
<div class="col-xs-2">
<input type="text" class="form-control input-text table_search" value="" size="1" placeholder="真实姓名" column="2" name="name">
</div>
<div class="col-xs-2">
<input type="text" class="form-control input-text table_search" value="" size="1" placeholder="手机号" column="3" name="phone">
</div>
</div>
<div>
<button class="btn btn-primary radius" type="button" onclick="$('#table').DataTable().draw()">搜索</button>
<input class="btn btn-warning radius" type="reset" value="重置搜索">
<button class="btn btn-primary radius" type="button" onclick="add()">添加员工</button>
</div>
</form>
<div class="body mt-20">
<table class="table table-border table-bordered table-bg" id="table" url="system/user/find">
<!-- system/user/getAllHr-->
<thead class="text-c">
<tr>
<th width="68px">操作</th>
<th>用户名</th>
<th>真实姓名</th>
<th>手机号</th>
<th>身份证号码</th>
<th>角色</th>
<th>所属网点</th>
<th>状态</th>
<th>备注</th>
</tr>
</thead>
<tbody class="text-c">
</tbody>
</table>
</div>
</div>
<?php $this->load->view('common/footer'); ?>
<script>
var table = $('#table').dataTable({
columns: [
{
data: "id", render: function (data, type, full) {
var str = '';
if(full.status == 1){
str = '<li><a href="javascript:freeze('+data+');">冻结</a></li>';
} else {
str = '<li><a href="javascript:unfreeze('+data+');">解冻</a></li>';
}
return '<span class="dropDown dropDown_hover">\
<button class="btn radius size-M">请选择 <i class="Hui-iconfont"></i></button>\
<ul class="dropDown-menu menu radius box-shadow">\
'+str+'\
<li><a href="javascript:edit('+data+');">编辑</a></li>\
<li><a href="javascript:reset('+data+');">重置密码</a></li>\
</ul></span>';
}
},
{data: "username"},//用户名
{data: "name"},//真实姓名
{data: "phone"},//手机号码
{data: "id"},//身份证号码
{data: "roles"},//角色
{data: "departmentId"},//所属网点
{data: "status"},//状态
{data: "remark"},//备注
]
});
function add() {
layer_show('添加员工', '<?=site_url('perm/staffAdd');?>');
}
function edit(id) {
layer_show('编辑员工', '<?=site_url('perm/staffEdit');?>/'+id);
}
function reset(id) {
//layer_show('重置密码', '<?=site_url('perm/reset');?>');
layer.confirm('您确定要将密码重置为 123456 吗?', {
btn: ['确认','取消'],
title: '重置密码',
icon: 3
}, function(){
$.ajax({
type: 'put',
url: apiBaseUrl + 'system/user/resetPassword/'+id+'?newPassword=' + 123456,
cache: false,
dataType: 'json',
contentType: "application/json; charset=UTF-8",
success: function (data) {
if (data.msg) {
layer.alert(data.msg);
} else if (data.code != 0) {
layer.alert('操作失败');
} else {
layer.msg('重置成功');
}
},
error: function () {
layer.alert("操作失败")
}
})
});
}
function freeze(id) {
layer.confirm('您确定要冻结这个员工账号吗?', {
btn: ['确认','取消'],
title: '冻结',
icon: 3
}, function(){
$.ajax({
type: 'put',
url: apiBaseUrl + 'system/user/freeze/' + id,
cache: false,
dataType: 'json',
contentType: "application/json; charset=UTF-8",
success: function (data) {
if (data.msg) {
layer.alert(data.msg);
} else if (data.code != 0) {
layer.alert('操作失败');
} else {
layer.msg('冻结成功');
reload();
}
},
error: function () {
layer.alert("操作失败")
}
})
});
}
function unfreeze(id) {
layer.confirm('您确定要解冻这个员工账号吗?', {
btn: ['确认','取消'],
title: '解冻',
icon: 3
}, function(){
$.ajax({
type: 'put',
// url: apiBaseUrl + 'manage/financial/confirm/' + id + '?realRepaymentDate=' + Date.now(),
url: apiBaseUrl + '/system/user/unfreeze/' + id,
cache: false,
dataType: 'json',
contentType: "application/json; charset=UTF-8",
success: function (data) {
if (data.msg) {
layer.alert(data.msg);
} else if (data.code != 0) {
layer.alert('操作失败');
} else {
layer.msg('解冻成功');
reload();
}
},
error: function () {
layer.alert("操作失败")
}
})
});
}
function reload() {
table.fnDraw();
}
function del(id) {
layer.confirm('一旦删除员工账号将无法恢复, 请谨慎操作!', {
btn: ['确认注销','取消'],
title: '注销账号',
icon: 3
}, function(){
ajax('/system/user/delete/'+id, 'delete');
this.reload();
});
}
</script>
</body>
<html>