safesite/safesite/templates/userhtml.html

278 lines
12 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<div class="easyui-layout" style="width:100%;height:100%;fit:true">
<div data-options="region:'west',title:'组织机构',split:true,border:false" style="width:300px;height:100%;">
<ul id="parttree" data-options="animate:true,"></ul>
</div>
<div data-options="region:'center',title:'用户列表',split:true,border:false" style="height:100%;">
<div id="userbar" style="padding:5px;height:auto">
<div>
{% load myfilter %}
{% if request|has_permission:'b_user_add' %}
<a id="adduser" onclick="adduser()" class="easyui-linkbutton" data-options="iconCls:'fa-plus',plain:true">新增</a>
{% endif %}
{% if request|has_permission:'b_user_upd' %}
<a id="edituser" onclick="edituser()" class="easyui-linkbutton" data-options="iconCls:'fa-pencil',plain:true">编辑</a>
{% endif %}
{% if request|has_permission:'b_user_del' %}
<a id="deluser" onclick="deluser()" class="easyui-linkbutton" data-options="iconCls:'fa-trash',plain:true">删除</a>
{% endif %}
{% if request|has_permission:'b_user_updpwd' %}
<a id="resetpass" onclick="resetpass()" class="easyui-linkbutton" data-options="iconCls:'fa-window-restore',plain:true">重置密码</a>
{% endif %}
{% if request|has_permission:'b_user_up' %}
<a id="drusers" onclick="drusers()" class="easyui-linkbutton" data-options="iconCls:'fa-upload',plain:true">导入用户</a>
{% endif %}
<script></script>
<input id='sname' class='easyui-textbox' data-options="prompt:'姓名/账户'"/>
<a onclick="usersearch()" class='easyui-linkbutton' iconCls='fa-search' plain=true>查询</a>
</div>
</div>
<table name="" id="usertable" style="height:70%;width:100%" data-options="
rownumbers:true,
singleSelect:true,
striped: true,
method:'get',
toolbar:'#userbar'">
<thead>
<tr>
<th data-options="field:'userid',hidden:true">用户ID</th>
<th data-options="field:'empid',align:'right'" width="10%">工号</th>
<th data-options="field:'name',align:'right'" width="10%">姓名</th>
<th data-options="field:'username',align:'right'" width="10%">账户</th>
<th data-options="field:'ubelongpart__partname',align:'right'" width="25%">所属部门</th>
<th data-options="field:'userprofile__gender',align:'right'" width="5%">性别</th>
<th data-options="field:'userprofile__cardnum',align:'right'" width="25%">身份证号</th>
<th data-options="field:'openid',align:'center',formatter: function (value, row, index) {
if(value!=0 && value != null){return '<img src='+'/static/safesite/easyui/themes/icons/ok.png'+'/>';}
}"
width="15%">是否可接受通知</th>
<!-- <th data-options="field:'operation',width:50,formatter:operb" >操作</th> -->
</tr>
</thead>
</table>
<table name="" id="rusertable" title='用户回收站' style="height:30%;width:100%" class='easyui-datagrid' data-options="
rownumbers:true,
singleSelect:true,
striped: true,
method:'get',
">
<thead>
<tr>
<th data-options="field:'operate',align:'center'" width="15%">操作</th>
<th data-options="field:'userid',hidden:true">用户ID</th>
<th data-options="field:'empid',align:'right'" width="15%">工号</th>
<th data-options="field:'name',align:'right'" width="20%">姓名</th>
<th data-options="field:'username',align:'right'" width="20%">账户</th>
<th data-options="field:'ubelongpart__partname',align:'right'" width="30%">所属部门</th>
<!-- <th data-options="field:'operation',width:50,formatter:operb" >操作</th> -->
</tr>
</thead>
</table>
</div>
</div>
</div>
<div id="drusersdialog" class="easyui-dialog" title="导入用户" style="width:400px;height:200px;" data-options="iconCls:'fa-upload',resizable:true,modal:true,closed:true,border:false">
<p style="color:red;margin-left: 10px">请按模板录入后导入</p>
<p style="margin-left: 10px"><a href="/static/safesite/muban/userst.xlsx">点击下载模板</a></p>
<p style="margin-left: 10px">录入完成后点击下方按钮上传文件</p>
<input type="file" id="drfile" name="" accept=".xls,.xlsx" style="margin-left: 10px" />
</div>
<script>
$("#rusertable").datagrid({
url:'api/user?a=uuserdatagrid', //这里是通过url后台传输数据
collapsible: true,
singleSelect: false,
columns:[[
{field:'operate',title:'操作',width:100,
formatter:function(value,row,index){
var del = '<a href="#" onclick="recoveryuser('+row.userid+')">恢复</a>';
return del;
}},
{field:'userid',hidden:true},
{field:'name',title:'姓名',width:200},
{field:'username',title:'账户',width:200},
{field:'ubelongpart__partname',title:'所属部门',width:250},
]]
});
document.getElementById('drfile').onchange = function () {
var fileObj = this.files[0];
var url = 'drapi?a=user'
var form = new FormData();
form.append("upfile", fileObj); // 文件对象
xhr = new XMLHttpRequest(); // XMLHttpRequest 对象
xhr.open("post", url, true); //post方式url为服务器请求地址true 该参数规定请求是否异步处理。
xhr.send(form)
$('#drusersdialog').dialog('close')
loading('导入中。。');
xhr.onload = function (evt) { //服务断接收完文件返回的结果
var data = JSON.parse(evt.target.responseText);
removeLoading();
if (data.code == 1) {
$.messager.alert('提示', data.msg, 'info', function () {
$("#main").panel({ href: 'userhtml', title: '用户' });
});
}
else if(data.code == 2){
$.messager.alert('提示', data.msg + data.info, 'info', function () {
$("#main").panel({ href: 'userhtml', title: '用户' });
});
}
else {
$.messager.alert('提示', data.msg);
}
document.getElementById('drfile').value = '';
}; //请求完成
xhr.onerror = function (evt) { $.messager.alert('提示', '失败!文件内容有误');document.getElementById('drfile').value = ''; }; //请求失败
}
$('#usertable').datagrid({ url: 'getuser?a=datagrid' ,pagination: 'true',
pageSize: 20,});
$('#parttree').tree({
url: 'parthandle?a=tree',
animate: true,
toolbar: '#partbar',
loadFilter: function (rows) {
return convert(rows);
},
formatter: function (node) {
var s = node.text;
if (node.children) {
s += '&nbsp;<span style=\'color:blue\'>(' + node.children.length + ')</span>';
}
return s;
},
onSelect: function (row) {
$("#usertable").datagrid({
url: 'getuser?partid=' + row.id + '&a=datagrid',
});
$("#usertable").attr('name', row.id);
}
});
function adduser() {
var url = 'userhandle?a=adduserh'
$("#dd").dialog({
maximizable: true,
title: '新增用户',
width: 600,
height: 500,
closed: false,
cache: false,
href: url,
modal: true,
border: false,
});
$('#dd').window('center');
}
function drusers() {
$('#drusersdialog').dialog('open').window('center');
}
function deluser() {
var row = $('#usertable').datagrid('getSelected');
if (row) {
$.messager.confirm('提示', '删除用户会删除其所有录入数据!确定删除吗', function (r) {
if (r) {
$.ajax({
//提交数据的类型 POST GET
type: "GET",
//提交的网址
url: 'userhandle?a=del',
data: { 'userid': row.userid },
//提交的数据
//data: {
//action: "deletecar",
//id: row.ID
// },
//返回数据的格式
datatype: "json",//"xml", "html", "script", "json", "jsonp", "text".
//在请求之前调用的函数
beforeSend: function () { },
//成功返回之后调用的函数
success: function (data) {
if (data.code == 1) {
//$("#div_Add").dialog('close', false);//关闭窗口
//$.messager.alert("提示", '删除成功!');
$("#usertable").datagrid('reload');//刷新页面
$("#rusertable").datagrid('reload');
} else {
$.messager.alert("提示", '您无权删除本用户!');
}
//$.messager.alert("提示", data.msgbox);
},
//调用执行后调用的函数
complete: function (XMLHttpRequest, textStatus) {
},
//调用出错执行的函数
error: function () {
//请求出错处理
}
});
}
}
);
}
else {
$.messager.alert('提示', '未选择数据!');
}
}
function recoveryuser(userid){
$.get('api/user?a=recovery&userid='+userid,function(res){
if(res.code==1){
$("#usertable").datagrid('reload');//刷新页面
$("#rusertable").datagrid('reload');
}
})
}
function edituser() {
var row = $('#usertable').datagrid('getSelected');
if (row) {
var url = 'userhandle?a=edituserh&userid=' + row.userid;
$("#dd").dialog({
maximizable: true,
title: '编辑用户',
width: 600,
height: 500,
closed: false,
cache: false,
href: url,
modal: true,
border: false,
});
$('#dd').window('center');
}
else {
$.messager.alert('提示', '未选择数据!');
}
}
function usersearch() {
$('#usertable').datagrid({ url: 'getuser?a=datagrid&name=' + $('#sname').val() });
}
function resetpass() {
var row = $('#usertable').datagrid('getSelected');
if (row) {
$.messager.confirm('提示', '确定将该账户密码重置为0000吗?', function (r) {
if (r) {
$.get('api/user?a=resetpass&userid='+row.userid,function(res){
if(res.code==1){
$("#usertable").datagrid('reload');
//location.href = 'loginout';
}else{
$.messager.alert('提示', '权限不足!');
}
})
}
}
);
}
else {
$.messager.alert('提示', '未选择数据!');
}
}
</script>