|
@@ -6,200 +6,203 @@
|
|
|
|
|
|
<!-- Content Wrapper. Contains page content -->
|
|
|
<div class="content-wrapper">
|
|
|
- <section class="content-header">
|
|
|
- <h1>
|
|
|
- <small><button type="button" class="btn btn-primary" data-toggle="modal" onclick="add()">新增用户</button></small>
|
|
|
- </h1>
|
|
|
- <ol class="breadcrumb">
|
|
|
- <li><a href="/front/user"><i class="fa fa-dashboard"></i> 人员管理</a></li>
|
|
|
- </ol>
|
|
|
+ <section class="content-header">
|
|
|
+ <h1>
|
|
|
+ <small>
|
|
|
+ <button type="button" class="btn btn-primary" data-toggle="modal" onclick="add()">新增用户</button>
|
|
|
+ </small>
|
|
|
+ </h1>
|
|
|
+ <ol class="breadcrumb">
|
|
|
+ <li><a href="/front/user"><i class="fa fa-dashboard"></i> 人员管理</a></li>
|
|
|
+ </ol>
|
|
|
+ </section>
|
|
|
+ <!-- Main content -->
|
|
|
+ <section class="content">
|
|
|
+ <div class="row">
|
|
|
+ <div class="col-xs-12">
|
|
|
+ <div class="box">
|
|
|
+ <div class="box-body">
|
|
|
+ <table id="dataTable" class="table table-bordered table-hover">
|
|
|
+ <thead>
|
|
|
+ <tr>
|
|
|
+ <th>编号</th>
|
|
|
+ <th>账号</th>
|
|
|
+ <th>姓名</th>
|
|
|
+ <th>角色</th>
|
|
|
+ <th>操作</th>
|
|
|
+ </tr>
|
|
|
+ </thead>
|
|
|
+ </table>
|
|
|
+ </div>
|
|
|
+ <!-- /.box-body -->
|
|
|
+ </div>
|
|
|
+ <!-- /.box -->
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
</section>
|
|
|
- <!-- Main content -->
|
|
|
- <section class="content">
|
|
|
- <div class="row">
|
|
|
- <div class="col-xs-12">
|
|
|
- <div class="box">
|
|
|
- <div class="box-body">
|
|
|
- <table id="dataTable" class="table table-bordered table-hover">
|
|
|
- <thead>
|
|
|
- <tr>
|
|
|
- <th>编号</th>
|
|
|
- <th>账号</th>
|
|
|
- <th>姓名</th>
|
|
|
- <th>角色</th>
|
|
|
- <th>操作</th>
|
|
|
- </tr>
|
|
|
- </thead>
|
|
|
- </table>
|
|
|
- </div>
|
|
|
- <!-- /.box-body -->
|
|
|
- </div>
|
|
|
- <!-- /.box -->
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </section>
|
|
|
</div>
|
|
|
-
|
|
|
+
|
|
|
<div class="modal fade" id="modal-info">
|
|
|
- <div class="modal-dialog">
|
|
|
- <form id="userform" class="form-horizontal" role="form">
|
|
|
- <div class="modal-content">
|
|
|
- <div class="modal-header">
|
|
|
- <button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
|
|
- <span aria-hidden="true">×</span></button>
|
|
|
- <h4 class="modal-title">用户信息</h4>
|
|
|
- </div>
|
|
|
- <div class="modal-body">
|
|
|
- <div class="form-group">
|
|
|
- <label for="code" class="col-sm-2 control-label">账号:</label>
|
|
|
- <div class="col-sm-10">
|
|
|
- <input id="email" name="email" type="email" class="form-control" placeholder="请输入账号">
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- <div class="form-group">
|
|
|
- <label for="code" class="col-sm-2 control-label">密码:</label>
|
|
|
- <div class="col-sm-10">
|
|
|
- <input id="pwd" name="pwd" type="password" class="form-control" placeholder="请输入密码">
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- <div class="form-group">
|
|
|
- <label for="site" class="col-sm-2 control-label">姓名:</label>
|
|
|
- <div class="col-sm-10">
|
|
|
- <input id="name" name="name" type="text" class="form-control" placeholder="请输入姓名">
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- <div class="form-group">
|
|
|
- <label for="modify" class="col-sm-2 control-label">角色:</label>
|
|
|
- <div class="col-sm-10">
|
|
|
- <select id="role" name="role" class="form-control">
|
|
|
- <option value="2">开发员</option>
|
|
|
- <option value="1">管理员</option>
|
|
|
- <option value="0">系统管理员</option>
|
|
|
- </select>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- <div class="modal-footer">
|
|
|
- <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
|
|
|
- <button type="button" class="btn btn-primary" onclick="save()">保存</button>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- <!-- /.modal-content -->
|
|
|
- </form>
|
|
|
- </div>
|
|
|
- <!-- /.modal-dialog -->
|
|
|
+ <div class="modal-dialog">
|
|
|
+ <form id="userform" class="form-horizontal" role="form">
|
|
|
+ <div class="modal-content">
|
|
|
+ <div class="modal-header">
|
|
|
+ <button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
|
|
+ <span aria-hidden="true">×</span></button>
|
|
|
+ <h4 class="modal-title">用户信息</h4>
|
|
|
+ </div>
|
|
|
+ <div class="modal-body">
|
|
|
+ <div class="form-group">
|
|
|
+ <label for="code" class="col-sm-2 control-label">账号:</label>
|
|
|
+ <div class="col-sm-10">
|
|
|
+ <input id="email" name="email" type="email" class="form-control" placeholder="请输入账号">
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="form-group">
|
|
|
+ <label for="code" class="col-sm-2 control-label">密码:</label>
|
|
|
+ <div class="col-sm-10">
|
|
|
+ <input id="pwd" name="pwd" type="password" class="form-control" placeholder="请输入密码">
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="form-group">
|
|
|
+ <label for="site" class="col-sm-2 control-label">姓名:</label>
|
|
|
+ <div class="col-sm-10">
|
|
|
+ <input id="name" name="name" type="text" class="form-control" placeholder="请输入姓名">
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="form-group">
|
|
|
+ <label for="modify" class="col-sm-2 control-label">角色:</label>
|
|
|
+ <div class="col-sm-10">
|
|
|
+ <select id="role_select" class="form-control"></select>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="modal-footer">
|
|
|
+ <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
|
|
|
+ <button type="button" class="btn btn-primary" onclick="save()">保存</button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <!-- /.modal-content -->
|
|
|
+ </form>
|
|
|
+ </div>
|
|
|
+ <!-- /.modal-dialog -->
|
|
|
</div>
|
|
|
<!-- /.modal -->
|
|
|
-
|
|
|
+
|
|
|
<!-- footer -->
|
|
|
{{include "com/footer.html"}}
|
|
|
|
|
|
<script>
|
|
|
-menuActive("user");
|
|
|
-var _id="";
|
|
|
-$(function () {
|
|
|
- ttable=$('#dataTable').DataTable({
|
|
|
- "paging" : true,
|
|
|
- "lengthChange": false,
|
|
|
- "searching" : true,
|
|
|
- "ordering" : true,
|
|
|
- "info" : true,
|
|
|
- "autoWidth" : false,
|
|
|
- "ajax": {
|
|
|
- "url": "/front/user",
|
|
|
- "type": "post",
|
|
|
- "data":{}
|
|
|
- },
|
|
|
- "language": {
|
|
|
- "url": "/dist/js/dataTables.chinese.lang"
|
|
|
- },
|
|
|
- "columns": [
|
|
|
- { "data": "_id",render:function(val,a,row){
|
|
|
- return row._id
|
|
|
- }},
|
|
|
- { "data": "s_email"},
|
|
|
- { "data": "s_name"},
|
|
|
- { "data": "s_role",render:function(val,a,row){
|
|
|
- role=""
|
|
|
- if(val==2){
|
|
|
- role="开发员"
|
|
|
- }else if(val==1){
|
|
|
- role="管理员"
|
|
|
- }else if(val==0){
|
|
|
- role="系统管理员"
|
|
|
+ menuActive("user");
|
|
|
+
|
|
|
+ var role = {{.T.role}}
|
|
|
+ var _id = "";
|
|
|
+ for (const roleKey in role) {
|
|
|
+ console.log(role)
|
|
|
+ var provOpt = document.createElement('option');
|
|
|
+ provOpt.innerText = role[roleKey];
|
|
|
+ provOpt.value = roleKey;
|
|
|
+ $('#role_select')[0].appendChild(provOpt);
|
|
|
+ }
|
|
|
+ $(function () {
|
|
|
+ ttable = $('#dataTable').DataTable({
|
|
|
+ "paging": true,
|
|
|
+ "lengthChange": false,
|
|
|
+ "searching": false,
|
|
|
+ "ordering": false,
|
|
|
+ "info": true,
|
|
|
+ "autoWidth": false,
|
|
|
+ "ajax": {
|
|
|
+ "url": "/front/user",
|
|
|
+ "type": "post",
|
|
|
+ "data": {}
|
|
|
+ },
|
|
|
+ "language": {
|
|
|
+ "url": "/dist/js/dataTables.chinese.lang"
|
|
|
+ },
|
|
|
+ "columns": [
|
|
|
+ {
|
|
|
+ "data": "_id", render: function (val, a, row) {
|
|
|
+ return row._id
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {"data": "s_email"},
|
|
|
+ {"data": "s_name"},
|
|
|
+ {"data": "role_name"},
|
|
|
+ {
|
|
|
+ "data": "_id", render: function (val, a, row) {
|
|
|
+ return "<a href='#' onclick='edit(\"" + row['_id'] + "\",\"" + row['s_email'] + "\",\"" + row['s_name'] + "\",\"" + row['s_role'] + "\",\"" + row['s_pwd'] + "\")'><i class='fa fa-fw fa-edit text-yellow'></i></a> " +
|
|
|
+ "<a href='#' onclick='del(\"" + val + "\")'><i class='fa fa-fw fa-trash text-red'></i></a>"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ });
|
|
|
+ })
|
|
|
+
|
|
|
+ function save() {
|
|
|
+ role = $("select[id=role_select]").val();
|
|
|
+ email = $("#email").val();
|
|
|
+ s_name = $("#name").val();
|
|
|
+ pwd = $("#pwd").val();
|
|
|
+ if (email == "" || name == "" || role == "" || pwd == "") {
|
|
|
+ alert("表单填写不完整!")
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ $.ajax({
|
|
|
+ url: "/front/user/save",
|
|
|
+ type: "post",
|
|
|
+ data: {"role": role, "_id": _id, "email": email, "name": s_name, "pwd": pwd},
|
|
|
+ success: function (r) {
|
|
|
+ if (r.rep) {
|
|
|
+ $("#modal-info").modal("hide");
|
|
|
+ ttable.ajax.reload();
|
|
|
+ } else {
|
|
|
+ alert("保存失败");
|
|
|
}
|
|
|
- return role
|
|
|
- }},
|
|
|
- { "data":"_id",render:function(val,a,row){
|
|
|
- return "<a href='#' onclick='edit(\""+row['_id']+"\",\""+row['s_email']+"\",\""+row['s_name']+"\",\""+row['s_role']+"\",\""+row['s_pwd']+"\")'><i class='fa fa-fw fa-edit text-yellow'></i></a> "+
|
|
|
- "<a href='#' onclick='del(\""+val+"\")'><i class='fa fa-fw fa-trash text-red'></i></a>"
|
|
|
- }}
|
|
|
- ]
|
|
|
- });
|
|
|
- //ttable.on('init.dt', function () {});
|
|
|
-})
|
|
|
-function save(){
|
|
|
- role=$("select[id=role]").val();
|
|
|
- email=$("#email").val();
|
|
|
- name=$("#name").val();
|
|
|
- pwd=$("#pwd").val();
|
|
|
- if(email==""||name==""||role==""||pwd==""){
|
|
|
- alert("表单填写不完整!")
|
|
|
- return false;
|
|
|
- }
|
|
|
- $.ajax({
|
|
|
- url:"/front/user/save",
|
|
|
- type:"post",
|
|
|
- data:{"role":role,"_id":_id,"email":email,"name":name,"pwd":pwd},
|
|
|
- success:function(r){
|
|
|
- if(r.rep){
|
|
|
- $("#modal-info").modal("hide");
|
|
|
- ttable.ajax.reload();
|
|
|
- }else{
|
|
|
- alert("保存失败");
|
|
|
- }
|
|
|
- }
|
|
|
- })
|
|
|
-}
|
|
|
-function edit(id,email,name,role,pwd){
|
|
|
- _id=id;
|
|
|
- $("#modal-info #email").val(email);
|
|
|
- $("#modal-info #name").val(name);
|
|
|
- $("#modal-info #role").val(role);
|
|
|
- $("#modal-info #pwd").val(pwd);
|
|
|
- $("#modal-info #email").attr("disabled",true);
|
|
|
- $("#modal-info #name").attr("disabled",true);
|
|
|
- $("#modal-info #pwd").attr("disabled",true);
|
|
|
- $("#modal-info").modal("show");
|
|
|
-}
|
|
|
-function del(_id){
|
|
|
- showConfirm("确定删除?", function() {
|
|
|
- $.ajax({
|
|
|
- url:"/front/user/del",
|
|
|
- type:"post",
|
|
|
- data:{"_id":_id},
|
|
|
- success:function(r){
|
|
|
- if(r.rep){
|
|
|
- ttable.ajax.reload();
|
|
|
- }else{
|
|
|
- showTip("删除失败", 1000, function() {});
|
|
|
- }
|
|
|
- }
|
|
|
- })
|
|
|
- });
|
|
|
-}
|
|
|
-function add(){
|
|
|
- //com.maskShow("测试")
|
|
|
- //com.maskHide()
|
|
|
-
|
|
|
- _id="";
|
|
|
- $("#modal-info #email").val("");
|
|
|
- $("#modal-info #name").val("");
|
|
|
- $("#modal-info #pwd").val("");
|
|
|
- $("#modal-info #role").val("2");
|
|
|
- $("#modal-info #email").removeAttr("disabled",true);
|
|
|
- $("#modal-info #name").removeAttr("disabled",true);
|
|
|
- $("#modal-info #pwd").removeAttr("disabled",true);
|
|
|
- $("#modal-info").modal("show");
|
|
|
-}
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ function edit(id, email, s_name, s_role, pwd) {
|
|
|
+ _id = id;
|
|
|
+ $("#modal-info #email").val(email);
|
|
|
+ $("#modal-info #name").val(s_name);
|
|
|
+ $("#modal-info #role").val(role);
|
|
|
+ $("#modal-info #pwd").val(pwd);
|
|
|
+ $("#modal-info #email").attr("disabled", true);
|
|
|
+ $("#modal-info #name").attr("disabled", true);
|
|
|
+ $("#modal-info #pwd").attr("disabled", true);
|
|
|
+ $("#modal-info #role").val(s_role);
|
|
|
+ $("#modal-info").modal("show");
|
|
|
+ }
|
|
|
+
|
|
|
+ function del(_id) {
|
|
|
+ showConfirm("确定删除?", function () {
|
|
|
+ $.ajax({
|
|
|
+ url: "/front/user/del",
|
|
|
+ type: "post",
|
|
|
+ data: {"_id": _id},
|
|
|
+ success: function (r) {
|
|
|
+ if (r.rep) {
|
|
|
+ ttable.ajax.reload();
|
|
|
+ } else {
|
|
|
+ showTip("删除失败", 1000, function () {
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ function add() {
|
|
|
+ _id = "";
|
|
|
+ $("#modal-info #email").val("");
|
|
|
+ $("#modal-info #name").val("");
|
|
|
+ $("#modal-info #pwd").val("");
|
|
|
+ $("#modal-info #role").val("2");
|
|
|
+ $("#modal-info #email").removeAttr("disabled", true);
|
|
|
+ $("#modal-info #name").removeAttr("disabled", true);
|
|
|
+ $("#modal-info #pwd").removeAttr("disabled", true);
|
|
|
+ $("#modal-info").modal("show");
|
|
|
+ }
|
|
|
</script>
|