329 lines
14 KiB
HTML
329 lines
14 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>用户管理</title>
|
|
<link rel="shortcut icon" href="favicon.ico">
|
|
<link href="css/bootstrap.min.css?v=3.3.7" rel="stylesheet">
|
|
<link href="css/font-awesome.css?v=4.4.0" rel="stylesheet">
|
|
<link rel="shortcut icon" href="favicon.ico">
|
|
<link href="css/bootstrap.min.css?v=3.3.7" rel="stylesheet">
|
|
<!-- jqgrid-->
|
|
<link href="css/plugins/blueimp/css/blueimp-gallery.min.css" rel="stylesheet">
|
|
<link href="css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
|
|
<link href="css/plugins/jqgrid/ui.jqgrid.css?0820" rel="stylesheet">
|
|
<link href="css/plugins/iCheck/custom.css" rel="stylesheet">
|
|
<link href="css/animate.css" rel="stylesheet">
|
|
<link href="css/style.css?v=4.1.0" rel="stylesheet">
|
|
<style>
|
|
/* Additional style to fix warning dialog position */
|
|
|
|
#alertmod_table_list_2 {
|
|
top: 900px !important;
|
|
}
|
|
.lightBoxGallery{
|
|
height: 348px;
|
|
overflow: auto;
|
|
padding: 10px;
|
|
border: 1px solid #f5f5f5;
|
|
border-radius: 10px;
|
|
}
|
|
.lightBoxGallery img {
|
|
margin: 5px;
|
|
width: 160px;
|
|
}
|
|
.modal-content{
|
|
position: relative;
|
|
}
|
|
#show-user-list .checkbox-inline{
|
|
margin: 0 38px 10px 0;
|
|
width: 76px;
|
|
}
|
|
#show-user-list .checkbox-inline input{
|
|
margin-top: 0;
|
|
}
|
|
</style>
|
|
|
|
</head>
|
|
|
|
<body class="gray-bg">
|
|
<div class="wrapper wrapper-content animated fadeInRight">
|
|
<div class="row">
|
|
<div class="col-sm-12">
|
|
<div class="ibox ">
|
|
<div class="ibox-title" style="display: flex;justify-content: space-between;align-items: center;">
|
|
<h5>用户管理</h5>
|
|
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#insertUserModal">
|
|
添加人员
|
|
</button>
|
|
</div>
|
|
<div class="ibox-content">
|
|
<div class="jqGrid_wrapper">
|
|
<table id="table_list_1"></table>
|
|
<div id="pager_list_1"></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="modal inmodal" id="myModal" role="dialog" aria-hidden="true">
|
|
<div class="modal-dialog">
|
|
<div class="modal-content animated bounceInRight">
|
|
<div class="ibox-content">
|
|
<div class="row">
|
|
<div class="col-sm-12">
|
|
<div class="m-b-md" style="display: flex;align-items: center;">
|
|
<h2>人员分配</h2>
|
|
<label style="margin-bottom: 0px; margin-left: 30px;">
|
|
<input type="checkbox" id="checkAllBox"> 全选</label>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="form-group">
|
|
<div class="col-sm-12" id="show-user-list"></div>
|
|
</div>
|
|
<div class="modal-footer" style="border-top: 0px;position: absolute;bottom: 10px; right:10px;">
|
|
<button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
|
|
<button type="button" onClick="saveValue()" class="btn btn-primary">保存</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
<div class="modal inmodal" id="insertUserModal" role="dialog" aria-hidden="true">
|
|
<div class="modal-dialog">
|
|
<div class="modal-content animated bounceInRight" style="height: 400px;">
|
|
<div class="ibox-content">
|
|
<div class="row">
|
|
<div class="col-sm-12">
|
|
<div class="m-b-md">
|
|
<h2>添加用户</h2>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<form class="form-horizontal">
|
|
<div class="form-group">
|
|
<label class="col-sm-2 control-label">用户名:</label>
|
|
<div class="col-sm-10">
|
|
<input type="text" class="form-control" id="username">
|
|
</div>
|
|
</div>
|
|
<div class="form-group">
|
|
<label class="col-sm-2 control-label">账号:</label>
|
|
<div class="col-sm-10">
|
|
<input type="text" class="form-control" id="account">
|
|
</div>
|
|
</div>
|
|
<div class="form-group">
|
|
<label class="col-sm-2 control-label">密码:</label>
|
|
<div class="col-sm-10">
|
|
<input type="password" class="form-control" id="password">
|
|
</div>
|
|
</div>
|
|
</form>
|
|
<div class="modal-footer" style="border-top: 0px;position: absolute;bottom: 10px; right:10px;">
|
|
<button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
|
|
<button type="button" onClick="saveUser()" class="btn btn-primary">保存</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<!-- 全局js -->
|
|
<script src="js/jquery.min.js?v=2.1.4"></script>
|
|
<script src="js/bootstrap.min.js?v=3.3.7"></script>
|
|
<link href="css/plugins/toastr/toastr.min.css" rel="stylesheet">
|
|
|
|
|
|
<!-- Peity -->
|
|
<script src="js/plugins/peity/jquery.peity.min.js"></script>
|
|
|
|
<!-- jqGrid -->
|
|
<script src="js/plugins/jqgrid/i18n/grid.locale-cn.js?0820"></script>
|
|
<script src="js/plugins/jqgrid/jquery.jqGrid.min.js?0820"></script>
|
|
<script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
|
|
<script src="js/plugins/toastr/toastr.min.js"></script>
|
|
<!-- 自定义js -->
|
|
<script src="js/plugins/iCheck/icheck.min.js"></script>
|
|
<script src="js/content.js?v=1.0.0"></script>
|
|
<script src="js/request.js"></script>
|
|
<!-- Page-Level Scripts -->
|
|
<script>
|
|
let selectUserId = '';
|
|
let selectUserList = [];
|
|
function showModal(id) {
|
|
selectUserList = [];
|
|
selectUserId = id;
|
|
getAjaxRequst(
|
|
"/api/Users/Loads?page=1&limit=99999", {},
|
|
function (res){
|
|
if (res.code == 200) {
|
|
getAjaxRequst("/api/AccessObjs/GetIntactUsers?audituserid="+selectUserId, {},function(response){
|
|
if (response.code == 200) {
|
|
let data = res.root
|
|
let result_text = ''
|
|
$('#show-user-list').empty()
|
|
data.forEach(item => {
|
|
result_text += `<label class="checkbox-inline i-checks"><input type="checkbox" value="${item.id}">${item.name}</label>`
|
|
})
|
|
$('#show-user-list').append(result_text)
|
|
$('.i-checks').iCheck({
|
|
checkboxClass: 'icheckbox_square-green',
|
|
radioClass: 'iradio_square-green',
|
|
})
|
|
// 回显
|
|
let showList = response.result
|
|
let resultMap = $('#show-user-list').find('input').map(function(){
|
|
if(showList.includes($(this).val())){
|
|
$(this).iCheck('check')
|
|
}
|
|
})
|
|
}
|
|
});
|
|
}
|
|
}
|
|
);
|
|
}
|
|
function saveValue(){
|
|
selectUserList = $('#show-user-list').find('input:checked').map(function(){
|
|
return $(this).val()
|
|
}).get()
|
|
postAjaxRequst(
|
|
"/api/AccessObjs/AssignAuditUsers", {auditUserId: selectUserId, userIds: selectUserList},
|
|
function (res){
|
|
console.log(res)
|
|
if (res.code == 200) {
|
|
swal('保存成功');
|
|
$('#myModal').modal('hide')
|
|
selectUserId = ''
|
|
selectUserList = []
|
|
}
|
|
}
|
|
);
|
|
}
|
|
function saveUser(){
|
|
let name = $('#username').val().trim()
|
|
let account = $('#account').val().trim()
|
|
let password = $('#password').val().trim()
|
|
if(name && account && password){
|
|
postAjaxRequst(
|
|
"/api/Users/Register", {account,password,name,streetid:'b980e10a-4562-461f-bfb8-c2f65ebbfcbb'},
|
|
function (res) {
|
|
if (res.code == 200) {
|
|
swal('添加成功');
|
|
$('#insertUserModal').modal('hide')
|
|
$("#table_list_1").jqGrid("clearGridData").jqGrid("setGridParam", { url: baseURL + '/api/Users/Loads' })
|
|
.trigger("reloadGrid");
|
|
}
|
|
})
|
|
}
|
|
}
|
|
function delUser(id){
|
|
swal({
|
|
title: "确定要删除该用户吗?",
|
|
buttons: ['取消','确定'],
|
|
}).then(res => {
|
|
if(res){
|
|
postAjaxRequst(
|
|
"/api/Users/Delete", [id],
|
|
function (res) {
|
|
if (res.code == 200) {
|
|
swal('删除成功');
|
|
$("#table_list_1").jqGrid("clearGridData").jqGrid("setGridParam", { url: baseURL + '/api/Users/Loads' })
|
|
.trigger("reloadGrid");
|
|
}
|
|
}
|
|
)
|
|
}
|
|
})
|
|
}
|
|
$(document).ready(function () {
|
|
$.jgrid.defaults.styleUI = 'Bootstrap';
|
|
$("#table_list_1").jqGrid({
|
|
url: baseURL + '/api/Users/Loads',
|
|
loadBeforeSend: function (jqXHR) {
|
|
jqXHR.setRequestHeader("X-Token",localStorage.getItem('token'));
|
|
},
|
|
datatype: "json",
|
|
height: "100%",
|
|
jsonReader: {
|
|
root: "root",
|
|
page: "page",
|
|
total: "total",
|
|
records: "totalCount"
|
|
},
|
|
autowidth: true,
|
|
shrinkToFit: true,
|
|
rowNum: 10,
|
|
// rowList: [10, 20, 30],
|
|
colNames: ['账号', '名称', '创建时间', '操作'],
|
|
colModel: [
|
|
{
|
|
name: 'account',
|
|
index: 'account',
|
|
align:'center',
|
|
},
|
|
{
|
|
name: 'name',
|
|
index: 'name',
|
|
align:'center',
|
|
},
|
|
{
|
|
name: 'createTime',
|
|
index: 'createTime',
|
|
align:'center',
|
|
},
|
|
{
|
|
name: '操作',
|
|
align: "center",
|
|
width: 80, formatter: function (value, grid, rows) {
|
|
var id = rows.id;
|
|
var button1 = "agree('" + id + "')";
|
|
var button2 = "disagree('" + id + "')";
|
|
return `<div style="display:flex;justify-content: space-evenly;">
|
|
<button type="button" onClick="showModal('${id}')" class="btn btn-primary" data-toggle="modal" data-target="#myModal">
|
|
分配人员
|
|
</button>
|
|
<button type="button" onClick="delUser('${id}')" class="btn btn-danger">
|
|
删除
|
|
</button>
|
|
</div>`;
|
|
}
|
|
}
|
|
],
|
|
pager: "#pager_list_1",
|
|
viewrecords: true,
|
|
caption: "",
|
|
hidegrid: false
|
|
});
|
|
$("#checkAllBox").change(function () {
|
|
let isChecked = $(this).is(":checked");
|
|
if(isChecked){
|
|
$('#show-user-list').find('input').iCheck('check')
|
|
}else{
|
|
$('#show-user-list').find('input').iCheck('uncheck')
|
|
}
|
|
})
|
|
// Add responsive to jqGrid
|
|
$(window).bind('resize', function () {
|
|
var width = $('.jqGrid_wrapper').width();
|
|
$('#table_list_1').setGridWidth(width);
|
|
});
|
|
$('.i-checks').iCheck({
|
|
checkboxClass: 'icheckbox_square-green',
|
|
radioClass: 'iradio_square-green',
|
|
});
|
|
});
|
|
|
|
</script>
|
|
<!-- blueimp gallery -->
|
|
<script src="js/plugins/blueimp/jquery.blueimp-gallery.min.js"></script>
|
|
|
|
</body>
|
|
|
|
</html> |