You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
338 lines
13 KiB
338 lines
13 KiB
3 years ago
|
{% extends 'baseBZP.html' %}
|
||
|
|
||
|
{% block content %}
|
||
|
|
||
|
{% load static %}
|
||
|
|
||
|
<div class="layui-fluid">
|
||
|
<div class="layui-card">
|
||
|
<div class="layui-form layui-card-header layuiadmin-card-header-auto">
|
||
|
<div class="layui-form-item">
|
||
|
<div class="layui-inline">
|
||
|
<label class="layui-form-label">工号</label>
|
||
|
<div class="layui-input-block">
|
||
|
<input type="text" name="id" placeholder="请输入" autocomplete="off" class="layui-input" id="number">
|
||
|
</div>
|
||
|
</div>
|
||
|
<div class="layui-inline">
|
||
|
<label class="layui-form-label">姓名</label>
|
||
|
<div class="layui-input-block">
|
||
|
<input type="text" name="username" placeholder="请输入" autocomplete="off" class="layui-input" id="name">
|
||
|
</div>
|
||
|
</div>
|
||
|
<div class="layui-inline">
|
||
|
<label class="layui-form-label">角色</label>
|
||
|
<div class="layui-input-block">
|
||
|
<select name="sex" id="role">
|
||
|
<option value="">不限</option>
|
||
|
{% for role in all_role_json_list%}
|
||
|
<option value="{{role.RoleName}}">{{role.RoleName}}</option>
|
||
|
{% endfor %}
|
||
|
</select>
|
||
|
</div>
|
||
|
</div>
|
||
|
<div class="layui-inline">
|
||
|
<label class="layui-form-label">账号状态</label>
|
||
|
<div class="layui-input-block">
|
||
|
<select name="sex" id="user_type">
|
||
|
<option value="">不限</option>
|
||
|
<option value="1">启用</option>
|
||
|
<option value="0">禁用</option>
|
||
|
</select>
|
||
|
</div>
|
||
|
</div>
|
||
|
<div class="layui-inline">
|
||
|
<button class="layui-btn layuiadmin-btn-useradmin" lay-submit lay-filter="LAY-user-front-search">
|
||
|
<i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
|
||
|
</button>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
|
||
|
<div class="layui-card-body">
|
||
|
<div style="padding-bottom: 10px;">
|
||
|
<button class="layui-btn layuiadmin-btn-useradmin" data-type="batchdel">删除</button>
|
||
|
<button class="layui-btn layuiadmin-btn-useradmin" data-type="add">添加</button>
|
||
|
<button class="layui-btn layuiadmin-btn-useradmin" data-type="btnTableAddFace">录入人脸</button>
|
||
|
<button class="layui-btn layuiadmin-btn-useradmin" data-type="btnTableResetPwd">重置用户密码</button>
|
||
|
<button class="layui-btn layuiadmin-btn-useradmin" data-type="btnTableQx">分配功能权限</button>
|
||
|
<button class="layui-btn layuiadmin-btn-useradmin" data-type="printer_code">打印用户条码</button>
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
</div>
|
||
|
|
||
|
<table id="LAY-datatable" lay-filter="LAY-datatable"></table>
|
||
|
<script type="text/html" id="sexTpl">
|
||
|
{% verbatim %}
|
||
|
{{# if(d.Sex==1){ }}
|
||
|
<span>男</span>
|
||
|
{{# } else { }}
|
||
|
<span>女</span>
|
||
|
{{# } }}
|
||
|
{% endverbatim %}
|
||
|
</script>
|
||
|
<script type="text/html" id="statusTpl">
|
||
|
{% verbatim %}
|
||
|
{{# if(d.IsEnabled){ }}
|
||
|
<button class="layui-btn layui-btn-xs">已启用</button>
|
||
|
{{# } else { }}
|
||
|
<button class="layui-btn layui-btn-primary layui-btn-xs">禁用</button>
|
||
|
{{# } }}
|
||
|
{% endverbatim %}
|
||
|
</script>
|
||
|
<script type="text/html" id="datatable-toolbar">
|
||
|
<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit"><i class="layui-icon layui-icon-edit"></i>编辑</a>
|
||
|
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"><i class="layui-icon layui-icon-delete"></i>删除</a>
|
||
|
</script>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
<script>
|
||
|
layui.use(['index', 'table'], function(){
|
||
|
var table = layui.table
|
||
|
,form = layui.form;
|
||
|
layui.use('form', function () {
|
||
|
var form = layui.form;
|
||
|
form.render(); //刷新select选择框渲染
|
||
|
});
|
||
|
//列表数据
|
||
|
table.render({
|
||
|
elem: '#LAY-datatable'
|
||
|
,url: "{% url 'user:getUserListJson' %}"
|
||
|
,size:'lg'
|
||
|
,cols: [[
|
||
|
{type: 'checkbox', fixed: 'left'}
|
||
|
,{field: 'UserCode', width: 130, title: '工号', sort: true}
|
||
|
,{field: 'RoleName', title: '角色', minWidth: 100}
|
||
|
,{field: 'RealName', title: '姓名'}
|
||
|
,{field: 'Sex', title: '性别', templet: '#sexTpl', width: 100,}
|
||
|
,{field: 'Mobile', title: '电话'}
|
||
|
,{field: 'Email', title: '邮箱'}
|
||
|
,{field: 'CreateDate', title: '创建时间', sort: true}
|
||
|
,{field: 'IsEnabled', title: '账号状态', templet: '#statusTpl', minWidth: 80, align: 'center'}
|
||
|
,{title: '操作', width: 200, minWidth: 150, align: 'center', fixed: 'right', toolbar: '#datatable-toolbar'}
|
||
|
]]
|
||
|
,page: {
|
||
|
layout: [ 'count', 'prev', 'page', 'next',] //自定义分页布局
|
||
|
,prev:'上一页'
|
||
|
,next:'下一页'
|
||
|
}
|
||
|
,limit: 15
|
||
|
,limits: [10, 15, 20, 25, 30]
|
||
|
,height: 'full-160'
|
||
|
});
|
||
|
|
||
|
//监听工具条
|
||
|
table.on('tool(LAY-datatable)', function(obj){
|
||
|
var data = obj.data;
|
||
|
if(obj.event === 'del'){
|
||
|
top.layer.confirm('确定删除吗?', function(index) {
|
||
|
top.layer.close(index);
|
||
|
//提交
|
||
|
$.post("{% url 'user:deleteUser' %}", {deleteIds:data.UserId}, function (obj) {
|
||
|
if (obj.status == 1) {
|
||
|
top.layer.msg("删除成功", function () {
|
||
|
});
|
||
|
}
|
||
|
else {
|
||
|
top.layer.msg("删除失败 " + obj.message);
|
||
|
}
|
||
|
});
|
||
|
obj.del();
|
||
|
// table.reload('LAY-datatable');
|
||
|
});
|
||
|
} else if(obj.event === 'edit'){
|
||
|
var tr = $(obj.tr);
|
||
|
|
||
|
top.layer.open({
|
||
|
type: 2
|
||
|
,title: '编辑用户'
|
||
|
,content: "{% url 'user:form' %}?user_id="+data.UserId
|
||
|
,area: ['800px', '680px']
|
||
|
,btn: ['确定', '取消']
|
||
|
,yes: function(index, layero){
|
||
|
var submitID = 'LAY-user-front-submit'
|
||
|
,submit = layero.find('iframe').contents().find('#'+ submitID);
|
||
|
submit.trigger('click');
|
||
|
}
|
||
|
,end:function(){
|
||
|
table.reload('LAY-datatable'); //数据刷新
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
});
|
||
|
|
||
|
//监听搜索
|
||
|
form.on('submit(LAY-user-front-search)', function(data){
|
||
|
var field = data.field;
|
||
|
//执行重载
|
||
|
table.reload('LAY-datatable', {
|
||
|
where: { //设定异步数据接口的额外参数,任意设
|
||
|
user_type: $("#user_type option:selected").val(),
|
||
|
number: $("#number").val(),
|
||
|
name: $("#name").val(),
|
||
|
role: $("#role option:selected").val(),
|
||
|
//…
|
||
|
},page: {
|
||
|
curr: 1 //重新从第 1 页开始
|
||
|
}
|
||
|
});
|
||
|
});
|
||
|
|
||
|
//事件
|
||
|
var active = {
|
||
|
batchdel: function(){
|
||
|
var checkStatus = table.checkStatus('LAY-datatable')
|
||
|
,checkData = checkStatus.data; //得到选中的数据
|
||
|
|
||
|
if(checkData.length === 0){
|
||
|
return layer.msg('请选择数据');
|
||
|
}
|
||
|
|
||
|
top.layer.confirm('确定删除吗?', function(index) {
|
||
|
var deleteIds='';
|
||
|
checkData.forEach(function(element,index){
|
||
|
if(deleteIds!=''){deleteIds+=','}
|
||
|
deleteIds+=element.UserId;
|
||
|
});
|
||
|
top.layer.close(index);
|
||
|
//提交
|
||
|
$.post("{% url 'user:deleteUser' %}", {deleteIds:deleteIds}, function (obj) {
|
||
|
if (obj.status == 1) {
|
||
|
top.layer.msg("删除成功", function () {
|
||
|
});
|
||
|
}
|
||
|
else {
|
||
|
top.layer.msg("删除失败 " + obj.message);
|
||
|
}
|
||
|
});
|
||
|
|
||
|
table.reload('LAY-datatable');
|
||
|
});
|
||
|
},
|
||
|
btnTableResetPwd:function () {
|
||
|
|
||
|
var checkStatus = table.checkStatus('LAY-datatable'), selectRow = checkStatus.data; //得到选中的数据
|
||
|
if (selectRow.length === 0) {
|
||
|
return layer.msg('请选择要重置密码的用户!');
|
||
|
}
|
||
|
selectRow = selectRow[0]
|
||
|
|
||
|
if(selectRow.RoleName == '管理员' || selectRow.RoleName == '维护人员'){
|
||
|
layer.msg('抱歉,您暂时没有权限修改管理员密码!');
|
||
|
return;
|
||
|
}
|
||
|
quiteTime = Infinity;
|
||
|
parent.layer.open({
|
||
|
title: "修改用户密码",
|
||
|
shift: 2,
|
||
|
type: 2,
|
||
|
area: ['660px', '450px'],
|
||
|
skin: 'layui-layer-rim', //加上边框
|
||
|
content: ["/home/" + selectRow.UserId + "/saveUser/", 'no'],
|
||
|
end: function () {
|
||
|
currentTime = 0;
|
||
|
quiteTime = 600;
|
||
|
tableModel.ajax.reload();
|
||
|
}
|
||
|
});
|
||
|
},
|
||
|
btnTableAddFace: function(){
|
||
|
var checkStatus = table.checkStatus('LAY-datatable'), selectRow = checkStatus.data; //得到选中的数据
|
||
|
if (selectRow.length === 0) {
|
||
|
return layer.msg('请选择要查看的用户!');
|
||
|
}
|
||
|
selectRow = selectRow[0]
|
||
|
top.P_Face.startAddFace(selectRow.UserId);
|
||
|
},
|
||
|
printer_code: function(){
|
||
|
var checkStatus = table.checkStatus('LAY-datatable'), selectRow = checkStatus.data; //得到选中的数据
|
||
|
if (selectRow.length === 0) {
|
||
|
return layer.msg('请选择要打印的用户条码!');
|
||
|
}
|
||
|
selectRow = selectRow[0]
|
||
|
console.log(selectRow,"zzzzzzzzzzzzzzzz")
|
||
|
layer.open({
|
||
|
content: '确定要打印用户条码 <h1 style="color:red">' + selectRow.BarCode + '</h1>吗?',
|
||
|
btn: ["确认", "取消"],
|
||
|
btn1:function(index, layero){
|
||
|
$.ajax({
|
||
|
url: '{% url 'user:printer_user_code' %}',
|
||
|
type: 'GET',
|
||
|
data: {
|
||
|
BarCode: selectRow.BarCode
|
||
|
},
|
||
|
success: function (e) {
|
||
|
// parent.layer.close(layer_index)
|
||
|
console.log(e.status)
|
||
|
if(e.status == 0){
|
||
|
|
||
|
layer.alert('打印成功', {time:1500,btn:[],title:""});
|
||
|
}else{
|
||
|
layer.alert("打印失败", {time:1500,btn:[],title:""});
|
||
|
}
|
||
|
},
|
||
|
error: function () {
|
||
|
layer.alert("请求失败!", {time:1500,btn:[],title:""});
|
||
|
}
|
||
|
});
|
||
|
},
|
||
|
btn2:function(index, layero){
|
||
|
console.log(index,"2222")
|
||
|
},
|
||
|
})
|
||
|
},
|
||
|
btnTableQx: function(){
|
||
|
var checkStatus = table.checkStatus('LAY-datatable'), selectRow = checkStatus.data; //得到选中的数据
|
||
|
if (selectRow.length === 0) {
|
||
|
return layer.msg('请选择要分配权限的用户!');
|
||
|
}
|
||
|
selectRow = selectRow[0]
|
||
|
|
||
|
quiteTime = Infinity;
|
||
|
parent.layer.open({
|
||
|
title: "分配用户权限-" + selectRow.RealName,
|
||
|
shift: 2,
|
||
|
type: 2,
|
||
|
area: ['860px', '520px'],
|
||
|
skin: 'layui-layer-rim', //加上边框
|
||
|
content: ["/user/" + selectRow.UserId + "/powerForm/" , 'no'],
|
||
|
end: function () {
|
||
|
currentTime = 0;
|
||
|
quiteTime = 600;
|
||
|
tableModel.ajax.reload();
|
||
|
}
|
||
|
});
|
||
|
},
|
||
|
add: function(){
|
||
|
top.layer.open({
|
||
|
type: 2
|
||
|
,title: '添加用户'
|
||
|
,content: "{% url 'user:form' %}"
|
||
|
,area: ['800px', '680px']
|
||
|
,btn: ['确定', '取消']
|
||
|
,yes: function(index, layero){
|
||
|
var submitID = 'LAY-user-front-submit'
|
||
|
,submit = layero.find('iframe').contents().find('#'+ submitID);
|
||
|
submit.trigger('click');
|
||
|
}
|
||
|
,end:function(){
|
||
|
table.reload('LAY-datatable'); //数据刷新
|
||
|
}
|
||
|
});
|
||
|
},
|
||
|
|
||
|
};
|
||
|
|
||
|
$('.layui-btn.layuiadmin-btn-useradmin').on('click', function(){
|
||
|
var type = $(this).data('type');
|
||
|
active[type] ? active[type].call(this) : '';
|
||
|
});
|
||
|
|
||
|
});
|
||
|
</script>
|
||
|
<iframe width=0 height=0 frameborder=0 id="export" />
|
||
|
{% endblock %}
|