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.
485 lines
20 KiB
485 lines
20 KiB
{% extends 'base.html' %}
|
|
|
|
{% block content %}
|
|
|
|
{% load static %}
|
|
<div class="wrapper wrapper-content animated fadeInDown">
|
|
<div class="mail-box-header">
|
|
<form method="get" action="{% url 'user:index' %}" class="pull-right mail-search" accept-charset="UTF-8">
|
|
<div class="input-group">
|
|
<input type="text" class="form-control input-sm" id="searchValue" name="searchValue" value="{{ searchValue }}" placeholder="搜索工号、姓名">
|
|
<div class="input-group-btn">
|
|
<button type="submit" id="btnTableSearch" class="btn btn-sm btn-primary">
|
|
搜索
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
<h2>
|
|
用户列表
|
|
</h2>
|
|
<div class="mail-tools tooltip-demo m-t-md">
|
|
<div class="btn-group pull-right">
|
|
<button class="btn btn-white btn-sm" id="tablePre">
|
|
<i class="fa fa-arrow-left"></i>
|
|
</button>
|
|
<button class="btn btn-white btn-sm" id="tableNext">
|
|
<i class="fa fa-arrow-right"></i>
|
|
</button>
|
|
</div>
|
|
<button class="btn btn-white btn-sm" data-toggle="tooltip" id="btnTableReload" data-placement="left" title="刷新用户列表"><i class="fa fa-refresh"></i> 刷新</button>
|
|
<button class="btn btn-white btn-sm" data-toggle="tooltip" id="btnTableAdd" data-placement="top" title="添加新用户">
|
|
<i class="fa fa-plus-square"> 新增用户</i>
|
|
</button>
|
|
<button class="btn btn-white btn-sm centerVisit" data-toggle="tooltip" id="btnTableAddFace" data-placement="top" title="录入人脸">
|
|
<i class="fa fa-plus-square"> 录入人脸</i>
|
|
</button>
|
|
<button class="btn btn-white btn-sm" data-toggle="tooltip" id="btnTableEdit" data-placement="top" title="编辑选中用户">
|
|
<i class="fa fa-edit"> 编辑用户</i>
|
|
</button>
|
|
<button class="btn btn-white btn-sm" data-toggle="tooltip" id="btnTableDelete" data-placement="top" title="删除选中用户">
|
|
<i class="fa fa-trash-o"> 删除用户</i>
|
|
</button>
|
|
<!-- <button class="btn btn-white btn-sm" data-toggle="tooltip" id="btnTableImport" data-placement="top" title="从Excel模板导入用户">
|
|
<i class="fa fa-copy"> 导入用户</i>
|
|
</button> -->
|
|
<!-- <button class="btn btn-white btn-sm" data-toggle="tooltip" id="btnTableExport" data-placement="left" title="导出报表统计列表"><i class="fa fa-download"></i> 导出数据</button> -->
|
|
<button class="btn btn-white btn-sm" data-toggle="tooltip" id="btnTableLock" data-placement="top" title="锁定/解锁用户">
|
|
<i class="fa fa-unlock"> 锁定/解锁用户</i>
|
|
</button>
|
|
<button class="btn btn-white btn-sm" data-toggle="tooltip" id="btnTableResetPwd" data-placement="top" title="重置密码">
|
|
<i class="fa fa-repeat"> 重置用户密码</i>
|
|
</button>
|
|
|
|
<button class="btn btn-white btn-sm" data-toggle="tooltip" id="btnTableQx" data-placement="top" title="分配功能权限">
|
|
<i class="fa fa-gear"> 分配功能权限</i>
|
|
</button>
|
|
|
|
<button class="btn btn-white btn-sm centerVisit" data-toggle="tooltip" id="printer_code" data-placement="top" title="打印用户条码">
|
|
<i class="fa fa-print"> 打印用户条码</i>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
<div class="ibox-content">
|
|
<table id="dataTableModel" class="table table-striped table-bordered table-hover dataTables-example">
|
|
<thead>
|
|
<tr>
|
|
<th>用户Id</th>
|
|
<th>工号</th>
|
|
<th>角色</th>
|
|
<th>姓名</th>
|
|
<th>性别</th>
|
|
<th>QQ</th>
|
|
<th>电话</th>
|
|
<th>邮箱</th>
|
|
<th>编号</th>
|
|
<th>创建时间</th>
|
|
<th align="center">用户状态</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody></tbody>
|
|
<tfoot>
|
|
<tr>
|
|
<th>用户Id</th>
|
|
<th>工号</th>
|
|
<th>角色</th>
|
|
<th>姓名</th>
|
|
<th>性别</th>
|
|
<th>QQ</th>
|
|
<th>电话</th>
|
|
<th>邮箱</th>
|
|
<th>编号</th>
|
|
<th>创建时间</th>
|
|
<th align="center">用户状态</th>
|
|
</tr>
|
|
</tfoot>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<script src="{% static 'js/utils.js' %}"></script>
|
|
<script src="{% static 'js/fileDownload.js' %}"></script>
|
|
<script src="{% static 'js/warning.js' %}"></script>
|
|
|
|
|
|
<script type="text/javascript">
|
|
var visitType=window.parent.frames.getUrlParam('visitType');
|
|
if(visitType!='1')
|
|
{
|
|
$(".centerVisit").hide();
|
|
}
|
|
$(function () {
|
|
$('#navTitle', window.parent.document).text('用户管理');
|
|
var searchValue = $('#searchValue').val();
|
|
$("#searchValue").val(searchValue);
|
|
var tableModel = $('#dataTableModel').DataTable({
|
|
searching: false,
|
|
lengthChange: false,
|
|
select: true,
|
|
ajax: {
|
|
url: "{% url 'user:getUserListJson' %}",
|
|
data: { searchValue: searchValue },
|
|
dataSrc: 'data'
|
|
},
|
|
columns: [
|
|
{ data: 'UserId' },
|
|
{ data: 'UserCode' },
|
|
{ data: 'RoleId' },
|
|
{ data: 'RealName' },
|
|
{ data: 'Sex' },
|
|
{ data: 'QQ' },
|
|
{ data: 'Mobile' },
|
|
{ data: 'Email' },
|
|
{ data: 'BarCode' },
|
|
{ data: 'CreateDate' },
|
|
{ data: 'IsEnabled' }
|
|
],
|
|
createdRow: function (row, data, dataIndex) {
|
|
if(data.Account!='admin')
|
|
{
|
|
$(row).children('td').eq(1).html(get_role(data.RoleId));
|
|
$(row).children('td').eq(3).html(data.Sex == 1 ? "男" : "女");
|
|
$(row).children('td').eq(7).html((data.BarCode == null || data.BarCode == "") ? "<span class='label label-default'>未绑定</span>" : "<span class='label label-primary'>" + data.BarCode + "</span>");
|
|
$(row).children('td').eq(9).html(data.IsEnabled == 1 ? "<span class='label label-warning'>正常</span>" : "<span class='label label-default'>禁用</span>");
|
|
$(row).children('td').eq(9).attr('style', 'text-align: center;');
|
|
$(row).children('td').eq(8).html(date_format_sql(data.CreateDate));
|
|
}
|
|
else{
|
|
$(row).attr('style', 'display: none;');
|
|
}
|
|
},
|
|
"order": [[9, "desc"]],
|
|
columnDefs: [
|
|
{
|
|
"targets": [0],
|
|
"visible": false
|
|
}
|
|
]
|
|
});
|
|
|
|
// 用户点击打印条码事件执行
|
|
$('#printer_code').click(function () {
|
|
var selectRow = tableModel.row('.selected').data();
|
|
console.log(selectRow,"aaaaaaaaaaaaaaaaaaaa")
|
|
if(selectRow == null){
|
|
new $.flavr({ content : "请选择要打印的用户条码!",
|
|
autoclose : true, timeout : 1000 });
|
|
|
|
return false;
|
|
}
|
|
|
|
|
|
new $.flavr({ content : '确定要打印用户条码 <h1 style="color:red">' + selectRow.BarCode + '</h1>吗?',
|
|
dialog : 'confirm',
|
|
|
|
buttons: {
|
|
danger: {
|
|
text: '确定',
|
|
style: 'danger',
|
|
action: function() {
|
|
// 调用layer加载框
|
|
var layer_index = parent.layer.load(2, {
|
|
shade: [0.01,'#fff'] //0.1透明度的白色背景
|
|
},{time: 3*1000});
|
|
$.ajax({
|
|
url: '{% url 'user:printer_user_code' %}',
|
|
type: 'GET',
|
|
data:{
|
|
BarCode: selectRow.BarCode
|
|
},
|
|
success: function (e) {
|
|
parent.layer.close(layer_index);
|
|
console.log(e);
|
|
if(e.status == 0){
|
|
new $.flavr('打印成功!');
|
|
}else{
|
|
new $.flavr(e.message);
|
|
}
|
|
},
|
|
error: function () {
|
|
parent.layer.close(layer_index);
|
|
new $.flavr('请求失败!');
|
|
}
|
|
})
|
|
}
|
|
},
|
|
cancel: {
|
|
text: '取消',
|
|
style: 'default'
|
|
}
|
|
},
|
|
onConfirm : function(){
|
|
|
|
}
|
|
});
|
|
});
|
|
$("#btnTableReload").click(function () {
|
|
location.href = '/user/index';
|
|
});
|
|
|
|
$("#btnTableAdd").click(function () {
|
|
console.log(currentTime, quiteTime, 999999999999)
|
|
quiteTime = Infinity;
|
|
console.log(quiteTime)
|
|
parent.layer.open({
|
|
title: "新增用户",
|
|
shift: 2,
|
|
type: 2,
|
|
area: ['860px', '470px'],
|
|
skin: 'layui-layer-rim', //加上边框
|
|
content: ["{% url 'user:form' %}", 'no'],
|
|
end: function () {
|
|
currentTime = 0;
|
|
quiteTime = 600;
|
|
tableModel.ajax.reload();
|
|
}
|
|
});
|
|
});
|
|
$("#btnTableAddFace").click(function(){
|
|
var selectRow = tableModel.row('.selected').data();
|
|
if (selectRow == null) {
|
|
new $.flavr({ content : "请选择要查看的用户!",
|
|
autoclose : true, timeout : 1000 });
|
|
return;
|
|
}
|
|
top.P_Face.startAddFace(selectRow.UserId);
|
|
|
|
});
|
|
$("#btnTableDrugRecord").click(function () {
|
|
var selectRow = tableModel.row('.selected').data();
|
|
if (selectRow == null) {
|
|
new $.flavr({ content : "请选择要查看的用户!",
|
|
autoclose : true, timeout : 1000 });
|
|
return;
|
|
}
|
|
quiteTime = Infinity;
|
|
parent.layer.open({
|
|
title: "用户“" + selectRow.UserCode + "”的药剂流转记录",
|
|
shift: 2,
|
|
type: 2,
|
|
area: ['960px', '580px'],
|
|
//skin: 'layui-layer-rim', //加上边框
|
|
{#content: ["{% url 'home_homeDrugRecord' %}" + selectRow.UserId, 'no']#}
|
|
end: function () {
|
|
currentTime = 0;
|
|
quiteTime = 600;
|
|
}
|
|
});
|
|
});
|
|
$("#btnTableImport").click(function () {
|
|
|
|
parent.layer.open({
|
|
title: "导入用户",
|
|
shift: 2,
|
|
type: 2,
|
|
area: ['680px', '550px'],
|
|
skin: 'layui-layer-rim', //加上边框
|
|
content: ["{% url 'user:importForm' %}", 'no'],
|
|
end: function () {
|
|
tableModel.ajax.reload();
|
|
}
|
|
});
|
|
});
|
|
|
|
$("#btnTableEdit").click(function () {
|
|
var selectRow = tableModel.row('.selected').data();
|
|
if (selectRow == null) {
|
|
new $.flavr({ content : "请选择要编辑的数据!",
|
|
autoclose : true, timeout : 1000 });
|
|
return;
|
|
}
|
|
quiteTime = Infinity;
|
|
parent.layer.open({
|
|
title: "编辑用户",
|
|
shift: 2,
|
|
type: 2,
|
|
area: ['860px', '450px'],
|
|
skin: 'layui-layer-rim', //加上边框
|
|
content: ["/user/form/?user_id=" + selectRow.UserId, 'no'],
|
|
end: function () {
|
|
currentTime = 0;
|
|
quiteTime = 600;
|
|
tableModel.ajax.reload();
|
|
}
|
|
});
|
|
});
|
|
$("#btnTableQx").click(function () {
|
|
var selectRow = tableModel.row('.selected').data();
|
|
if (selectRow == null) {
|
|
new $.flavr({ content : '请选择要分配权限的用户!',
|
|
autoclose : true, timeout : 1000 });
|
|
return;
|
|
}
|
|
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();
|
|
}
|
|
});
|
|
});
|
|
$("#btnTableLock").click(function () {
|
|
var selectRow = tableModel.row('.selected').data();
|
|
console.log(selectRow)
|
|
if (selectRow == null) {
|
|
new $.flavr({ content : '请选择要锁定/解锁的用户!',
|
|
autoclose : true, timeout : 1000 });
|
|
return;
|
|
}
|
|
var txt = selectRow.IsEnabled == 1 ? "锁定" : "解锁";
|
|
|
|
new $.flavr({
|
|
content: '确定要' + txt + '用户<p style="line-height:30px;color:red;font-size:20px;">"' + selectRow.RealName + '"?</p>',
|
|
dialog: 'confirm',
|
|
buttons: {
|
|
danger: {
|
|
text: '确定',
|
|
style: 'danger',
|
|
action: function() {
|
|
$.post("{% url 'user:lockUser' %}", { userId: selectRow.UserId }, function (obj) {
|
|
if (obj.status == 1) {
|
|
new $.flavr({ content : '设置成功!',
|
|
autoclose : true, timeout : 800 });
|
|
tableModel.ajax.reload();
|
|
return false;
|
|
}
|
|
else {
|
|
new $.flavr({ content : '数据异常, 锁定失败!',
|
|
autoclose : true, timeout : 2000 });
|
|
return false;
|
|
|
|
}
|
|
})
|
|
}
|
|
},
|
|
cancel: {
|
|
text: '取消',
|
|
style: 'default'
|
|
}
|
|
},
|
|
});
|
|
});
|
|
$("#btnTableResetPwd").click(function () {
|
|
var selectRow = tableModel.row('.selected').data();
|
|
console.log(selectRow)
|
|
if (selectRow == null) {
|
|
new $.flavr({ content : "请选择要重置密码的用户!",
|
|
autoclose : true, timeout : 1000 });
|
|
return;
|
|
}
|
|
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();
|
|
}
|
|
});
|
|
});
|
|
$("#btnTableDelete").click(function () {
|
|
var selectRow = tableModel.row('.selected').data();
|
|
if (selectRow == null) {
|
|
new $.flavr({ content : '请选中要删除的用户!',
|
|
autoclose : true, timeout : 1000 });
|
|
return;
|
|
}
|
|
new $.flavr({
|
|
content: '确定要删除用户<p style="line-height:30px;color:red;font-size:20px;">"' + selectRow.RealName + '"?</p>',
|
|
dialog: 'confirm',
|
|
buttons: {
|
|
danger: {
|
|
text: '确定',
|
|
style: 'danger',
|
|
action: function() {
|
|
$.post("{% url 'user:deleteUser' %}", { userId: selectRow.UserId }, function (obj) {
|
|
if (obj.status == 1) {
|
|
new $.flavr({ content : '删除成功!',
|
|
autoclose : true, timeout : 800 });
|
|
tableModel.row('.selected').remove().draw(false);
|
|
return false;
|
|
}
|
|
else {
|
|
new $.flavr({ content : '数据异常,删除失败!',
|
|
autoclose : true, timeout : 2000 });
|
|
return false;
|
|
}
|
|
})
|
|
}
|
|
},
|
|
cancel: {
|
|
text: '取消',
|
|
style: 'default'
|
|
}
|
|
},
|
|
});
|
|
});
|
|
$("#btnTableExport").click(function () {
|
|
var index = '';
|
|
var url = '{% url 'dataReport:exportUserData' %}';
|
|
$.fileDownload(url, {
|
|
prepareCallback: function (url) {
|
|
index = parent.layer.load(2,{time: 3*1000});
|
|
},
|
|
successCallback: function (url) {
|
|
parent.layer.close(index)
|
|
},
|
|
failCallback: function (url) {
|
|
msg('数据异常, 下载失败');
|
|
parent.layer.close(index)
|
|
}
|
|
|
|
|
|
})
|
|
|
|
});
|
|
$("#tablePre").click(function () {
|
|
$("#dataTableModel_previous").click();
|
|
|
|
});
|
|
|
|
$("#tableNext").click(function () {
|
|
$("#dataTableModel_next").click();
|
|
|
|
})
|
|
});
|
|
|
|
function get_role(role) {
|
|
switch (role) {
|
|
case 'b0c86811-ec53-4d7e-bd81-84f146e43dce':
|
|
return '普通用户';
|
|
case '19535c92-8da4-4645-88c5-9a4ee3fdb22e':
|
|
return '管理员';
|
|
case '5093e125-5559-4c27-a7fb-1730ed2c8f32':
|
|
return '维护人员';
|
|
default:
|
|
return '普通用户'
|
|
}
|
|
}
|
|
function date_format_sql(params) {
|
|
if(params){
|
|
return params.replace('T', ' ')
|
|
}
|
|
}
|
|
|
|
|
|
|
|
</script>
|
|
<iframe width=0 height=0 frameborder=0 id="export" />
|
|
{% endblock %}
|