123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <title>langTable</title>
- <meta name="description" content="Source code generated using layoutit.com">
- <meta name="author" content="LayoutIt!">
- <link href="css/bootstrap.min.css" rel="stylesheet">
- </head>
- <body>
- <div class="container-fluid">
- <div class="row">
- <div class="col-md-12">
- <div class="input-group">
- <div class="input-group-prepend">
- <div class="input-group-text">
- </div>
- </div>
- </div>
- </div>
- <!--add-->
- <div class="col-md-12">
- <table class="table">
- <thead id="langTableHead"></thead>
- <tbody id="langTableBody"></tbody>
- </table>
- </div>
- </div>
- </div>
- <table id="aacccxx"></table>
- <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 type="text/javascript">
- $(function () {
- let post_data = {
- 'token': $.cookie('access_token'),
- 'page': 1,
- 'line': 10
- }
- $.postJSON(
- http_ip_prot + 'langWord/query', JSON.stringify(post_data),
- function (data) {
- if (data['code'] == 0) {
- // console.log(data['res'])
- console.log(data)
- addTable(data['res'])
- } else {
- alert(data['msg'])
- }
- }
- )
- })
- let la_list
- let checkboxInput = '<input type="checkbox" aria-label="Checkbox for following text input">'
- function addTable(data) {
- //头部多区域语言
- let head_data = data['la_list'];
- la_list = head_data
- // body部详细语言
- let body_data = data['lw_dict'];
- console.log(body_data)
- let head_html = '<tr><th>en</th>';
- //头部标签添加
- $.each(head_data, function (idx, obj) {
- // console.log(idx)
- head_html += ('<th>' + obj['lang'] + '</th>')
- })
- let body_html = ''
- $.each(body_data, function (idx, obj) {
- // console.log(idx)
- // console.log(obj)
- body_html += '<tr>';
- body_html += ('<td>' + idx + '</td>');
- console.log('--------')
- $.each(la_list,function (x, y) {
- if(obj[y['lang']]){
- body_html += ('<td>' + obj[y['lang']] + '</td>')
- }else{
- body_html += ('<td></td>')
- }
- })
- body_html += '<td><a href="#" on>del</a></td></tr>';
- });
- head_html += '<th><a href="#" onclick="addRow()">add</a></th></tr>';
- $('#langTableHead').html(head_html)
- $('#langTableBody').html(body_html)
- addDelFunc()
- }
- function addRow() {
- let newRow = '<tr><td><input class="form-control" type="text" langID="key" id="newRow_key"></td>'
- $.each(la_list, function (idx, obj) {
- // console.log(idx)
- // newRow += ('<td>' + obj['id'] + '</td>')
- newRow += ('<td>' +
- '<input class="form-control" type="text" langID="' + obj['id'] + '" id="newRow_lang_' + obj['id'] + '">' +
- '</td>')
- })
- let saveBtn = '<button type="button" class="btn btn-primary">save</button>'
- let delBtn = '<button type="button" class="btn btn-danger">del</button>'
- newRow += '<td>' + saveBtn + delBtn + '</td></tr>'
- $('#langTableBody').append(newRow)
- addDelFunc()
- addSaveFunc()
- }
- function addDelFunc() {
- $(".btn-danger").bind("click", function () {
- let trRow = $(this).parent().parent()
- trRow.remove()
- });
- }
- function addSaveFunc() {
- $(".btn-primary").bind("click", function () {
- let post_data = {
- 'token': $.cookie('access_token')
- }
- let post_list = []
- let trRow = $(this).parent().parent()
- trRow.find('input').each(function () {
- // console.log($(this).attr('id'))
- // console.log($(this).attr('langID'))
- let inputVal = $(this).val()
- let langID = $(this).attr('langID')
- if (langID === 'key') {
- post_data['word_key'] = inputVal
- } else {
- post_list.push({'la_id': langID, 'val': inputVal})
- }
- })
- post_data['word_arr'] = post_list
- console.log(post_data)
- $.postJSON(
- http_ip_prot + 'langWord/add', JSON.stringify(post_data),
- function (data) {
- if (data['code'] == 0) {
- // console.log(data['res'])
- window.location.reload();
- console.log(data)
- } else {
- alert(data['msg'])
- }
- }
- )
- })
- }
- </script>
- </body>
- </html>
|