123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357 |
- <!doctype html>
- <html lang="zh">
- <head>
- <meta charset="UTF-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>afaa</title>
- <link rel="stylesheet" type="text/css" href="css/normalize.css"/>
- <link rel="stylesheet" type="text/css" href="css/default.css">
- <link rel="stylesheet" href="css/style.css">
- <link href="http://cdn.bootcss.com/font-awesome/4.4.0/css/font-awesome.min.css" rel="stylesheet">
- <link href="css/bootstrap.min.css" rel="stylesheet">
- <script src="https://npmcdn.com/tether@1.2.4/dist/js/tether.min.js"></script>
- <script src="js/jquery.min.js"></script>
- <script src="js/bootstrap.min.js"></script>
- <script src="js/jquery_cookie_min.js"></script>
- <script src="js/scripts.js"></script>
- <script src="js/jqhttpsdk.js"></script>
- <script src="js/jkcor.js"></script>
- <script src="js/pages.js"></script>
- </head>
- <body>
- <div class="clear-backend">
- <div class="avatar">
- <div>
- <a href="#" target="_blank">
- <img src="img/admin.png" alt="">
- </a>
- </div>
- </div>
- <input type="radio" class="tab-1" name="tab" onclick="location.href='index.html'">
- <span>Home</span><i class="fa fa-home"></i>
- <input type="radio" class="tab-2" name="tab" onclick="location.href='langTab.html'">
- <span>Lang</span><i class="fa fa-medium"></i>
- <input type="radio" class="tab-3" name="tab" checked="checked">
- <span>Users</span><i class="fa fa-user"></i>
- <input type="radio" class="tab-4" name="tab" onclick="location.href='imgTab.html'">
- <span>Azimg</span><i class="fa fa-image"></i>
- <!-- tab-top-bar -->
- <div class="top-bar">
- <ul>
- <li>
- <a href="login.html" title="Log Out">
- <i class="fa fa-sign-out"></i>
- </a>
- </li>
- <!--
- <li>
- <a href="" title="Messages">
- <i class="fa fa-envelope"></i>
- </a>
- </li>
- <li>
- <a href="" title="Edit">
- <i class="fa fa-edit"></i>
- </a>
- </li>
- -->
- </ul>
- </div>
- <!-- tab-content -->
- <div class="tab-content" style="overflow: auto">
- <section class="tab-item-3" style="height: 100%;width: 100%">
- <div class="container-fluid">
- <div class="row">
- <div class="col-md-12">
- <form role="form">
- <div class="form-group">
- <label for="InputUsername">
- 用户
- </label>
- <input type="text" class="form-control" id="InputUsername"/>
- <label for="InputPassword">
- 密码
- </label>
- <input type="text" class="form-control" id="InputPassword"/>
- <label for="InputRole">
- 角色
- </label>
- <input type="text" class="form-control" id="InputRole"/>
- </div>
- <button type="submit" class="btn btn-primary" onclick="subRegAction();return false;">
- 保存
- </button>
- </form>
- </div>
- </div>
- </div>
- <hr>
- <div class="container-fluid">
- <div class="row">
- <div class="col-md-12">
- <table class="table table-bordered table-hover">
- <thead id="tabHead">
- <tr>
- <th>编号</th>
- <th>用户</th>
- <th>语言</th>
- <th>角色</th>
- <th>操作</th>
- </tr>
- </thead>
- <tbody id="tabBody"></tbody>
- </table>
- </div>
- </div>
- </div>
- <!--模态框start-->
- <div class="container-fluid">
- <div class="row">
- <div class="col-md-12">
- <div class="modal fade" id="modal-container-edit" role="dialog"
- aria-labelledby="myModalLabel"
- aria-hidden="true">
- <div class="modal-dialog" role="document">
- <div class="modal-content">
- <div class="modal-header">
- <h5 class="modal-title" id="myModalLabel">
- EDIT
- </h5>
- <button type="button" class="close" data-dismiss="modal">
- <span aria-hidden="true">×</span>
- </button>
- </div>
- <div class="modal-body">
- <div class="form-group" id="edit_model_form">
- </div>
- </div>
- <div class="modal-footer">
- <button type="button" class="btn btn-primary editRowSaveBtn"
- onclick="editRow(this);return false;">
- Save changes
- </button>
- <button type="button" class="btn btn-secondary" data-dismiss="modal">
- Close
- </button>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- <!--模态框end-->
- </section>
- </div>
- </div>
- <script type="text/javascript">
- let index_data
- let lang_data
- $(function () {
- let post_data = {
- 'token': $.cookie('access_token'),
- };
- $.postJSON(
- http_ip_prot + 'user/query', JSON.stringify(post_data),
- function (data) {
- if (data['code'] == 0) {
- console.log(data)
- index_data = data['res']
- addTable(data['res'])
- } else {
- alert(data['msg'])
- }
- }
- );
- $.postJSON(
- http_ip_prot + 'langArea/query', JSON.stringify(post_data),
- function (data) {
- if (data['code'] == 0) {
- lang_data = data['res']
- console.log(lang_data)
- } else {
- alert(data['msg'])
- }
- }
- );
- });
- function addTable(data) {
- let body_html = ''
- $.each(data, function (idx, obj) {
- let edit_btn = '<a href="#" title="Edit" onclick="editFunc(\'' + obj['id'] + '\')"><i class="fa fa-edit"></i></a>';
- let del_btn = '<a href="#" title="Delete" onclick="delArea(\'' + obj['id'] + '\')"><i class="fa fa-ban"></i></a>';
- let langArr_td = '<td>';
- $.each(obj['lang_arr'], function (x, y) {
- langArr_td += (y + '  ')
- });
- langArr_td += '</td>';
- body_html += '<tr><td>' + obj['id'] + '</td><td>' + obj['username'] + '</td>' + langArr_td + '<td>' + obj['role_id'] + '</td><td>' + edit_btn + ' ' + del_btn + '</td> </tr>'
- })
- $('#tabBody').html(body_html)
- }
- function subLangAre() {
- let access_token = $.cookie('access_token')
- let langArea = $('#InputLangArea').val()
- let post_data = {
- 'token': access_token,
- 'lang': langArea,
- }
- console.log(post_data)
- $.postJSON(
- http_ip_prot + 'langArea/add',
- JSON.stringify(post_data),
- function (data) {
- if (data['code'] == 0) {
- alert(data['msg'])
- window.location.reload();
- } else {
- alert(data['msg'])
- }
- }
- );
- }
- function delArea(id) {
- let post_data = {
- 'token': $.cookie('access_token'),
- 'id': id
- }
- let cr = confirm('delete it ?')
- if (cr) {
- $.postJSON(
- http_ip_prot + 'user/delete', JSON.stringify(post_data),
- function (data) {
- if (data['code'] == 0) {
- console.log(data)
- // alert(data['msg'])
- window.location.reload()
- } else {
- alert(data['msg'])
- }
- }
- );
- }
- }
- function editFunc(id) {
- // alert(langKey)
- console.log(index_data)
- $('#modal-container-edit').modal('show')
- let user_lang_arr
- let html_edit = '<label for="editDataInput" class="form-group">用户名:</label>'
- let user_lang_perm
- $.each(index_data, function (idx, obj) {
- if (id == obj['id']) {
- user_lang_arr = obj['lang_arr']
- user_lang_perm = obj['lp_arr']
- html_edit += '<input type="text" class="form-control" id="editDataInput" value="' + obj['username'] + '" lid="' + id + '">'
- html_edit += '<label for="editDataRole" class="form-group">角色:</label>'
- html_edit += '<input type="text" class="form-control" id="editDataRole" value="' + obj['role_id'] + '" lid="' + id + '">'
- }
- });
- html_edit += '<hr><span class="form-group">显示语言:</span><span class="float-right">可否编辑</span>';
- $.each(lang_data, function (idx, obj) {
- let checkbox_val=''
- let check_perm_val=''
- if(user_lang_arr){
- let check_flag = $.inArray(obj['lang'],user_lang_arr)
- console.log(check_flag)
- if(check_flag>=0){
- checkbox_val+='checked="checked"'
- }
- }
- if(user_lang_perm){
- let check_perm_flag = $.inArray(obj['lang'],user_lang_perm)
- console.log(check_perm_flag)
- if(check_perm_flag>=0){
- check_perm_val+='checked="checked"'
- }
- }
- html_edit += ('<label class="form-control"><input name="langsetname" type="checkbox" '+checkbox_val+' aria-label="Checkbox for following text input" value="' + obj['id'] + '">' + obj['lang'] + '<input name="langpermname" type="checkbox" '+check_perm_val+' aria-label="Checkbox for following text input" class="float-right" value="' + obj['id'] + '"></label>')
- })
- //console.log(user_lang_arr)
- $('#edit_model_form').html(html_edit)
- }
- function editRow() {
- let sub_lang_arr = []
- let sub_perm_arr = []
- $.each($('input[name="langsetname"]:checked'), function () {
- sub_lang_arr.push($(this).val())
- });
- $.each($('input[name="langpermname"]:checked'), function () {
- sub_perm_arr.push($(this).val())
- });
- console.log('--------')
- console.log(sub_perm_arr)
- console.log('--------')
- let post_data = {
- 'token': $.cookie('access_token'),
- 'id': $('#editDataInput').attr('lid'),
- 'username': $('#editDataInput').val(),
- 'role_id': $('#editDataRole').val(),
- 'langSetArr': sub_lang_arr,
- 'langPermArr':sub_perm_arr,
- }
- console.log(post_data)
- $.postJSON(
- http_ip_prot + 'user/update', JSON.stringify(post_data),
- function (data) {
- if (data['code'] == 0) {
- console.log(data)
- // alert(data['msg'])
- window.location.reload()
- } else {
- alert(data['msg'])
- }
- }
- );
- }
- function subRegAction() {
- let username = $("#InputUsername").val();
- let password = $("#InputPassword").val();
- let role_id = $("#InputRole").val();
- let post_data = {
- 'username': username,
- 'password': password,
- 'role_id':role_id
- };
- $.postJSON(
- http_ip_prot + 'user/register',
- JSON.stringify(post_data),
- function (data) {
- if (data['code'] == 0) {
- alert(data['msg'])
- window.location.reload()
- } else {
- alert(data['msg'])
- }
- }
- );
- }
- </script>
- </body>
- </html>
|