| | |
| | | var pageCurr; |
| | | function getCols() { |
| | | var t = typeof I18n !== 'undefined' ? I18n.t : function(k) { return k; }; |
| | | return [[ |
| | | {type:'checkbox', fixed: 'left'} |
| | | ,{field: 'id', title: 'ID', sort: true,align: 'center', width: 80} |
| | | ,{field: 'userId$', align: 'center',title: t('user')} |
| | | ,{field: 'action', align: 'center',title: t('action'), templet: function(d) { |
| | | return t(d.action); |
| | | }} |
| | | ,{field: 'ip', align: 'center',title: t('client_ip')} |
| | | ,{field: 'request', align: 'center',title: t('request_data')} |
| | | ,{field: 'response', align: 'center',title: t('response_data'), templet: function(d) { |
| | | if (!d.response) return ''; |
| | | try { |
| | | var res = JSON.parse(d.response); |
| | | return res && res.msg ? t(res.msg) : d.response; |
| | | } catch (e) { |
| | | return d.response; |
| | | } |
| | | }} |
| | | ,{field: 'createTime$', align: 'center',title: t('add_time')} |
| | | ,{fixed: 'right', title: t('operation'), align: 'center', toolbar: '#operate', width:100} |
| | | ]]; |
| | | } |
| | | layui.use(['table','laydate', 'form'], function(){ |
| | | var table = layui.table; |
| | | var $ = layui.jquery; |
| | |
| | | var form = layui.form; |
| | | |
| | | // 数据渲染 |
| | | tableIns = table.render({ |
| | | elem: '#operateLog', |
| | | headers: {token: localStorage.getItem('token')}, |
| | | url: baseUrl+'/operateLog/list/auth', |
| | | page: true, |
| | | limit: 16, |
| | | // even: true, |
| | | toolbar: '#toolbar', |
| | | cellMinWidth: 50, |
| | | cols: [[ |
| | | {type: 'checkbox', fixed: 'left'} |
| | | ,{field: 'id', title: 'ID', sort: true,align: 'center', fixed: 'left', width: 80} |
| | | ,{field: 'action', align: 'center',title: '访问地址'} |
| | | ,{field: 'userId$', align: 'center',title: '用户',event: 'userId', style: 'text-decoration: underline;cursor:pointer'} |
| | | ,{field: 'ip', edit:'text', align: 'center',title: '客户端IP'} |
| | | ,{field: 'request', align: 'center',title: '请求数据'} |
| | | ,{field: 'response', align: 'center',title: '响应数据'} |
| | | ,{field: 'createTime$', align: 'center',title: '添加时间'} |
| | | var initTable = function() { |
| | | tableIns = table.render({ |
| | | elem: '#operateLog', |
| | | headers: {token: localStorage.getItem('token')}, |
| | | url: baseUrl+'/operateLog/list/auth', |
| | | page: true, |
| | | limit: 16, |
| | | limits: [16, 30, 50, 100, 200, 500], |
| | | even: true, |
| | | toolbar: '#toolbar', |
| | | cellMinWidth: 50, |
| | | cols: getCols(), |
| | | request: { |
| | | pageName: 'curr', |
| | | pageSize: 'limit' |
| | | }, |
| | | parseData: function (res) { |
| | | return { |
| | | 'code': res.code, |
| | | 'msg': res.msg, |
| | | 'count': res.data.total, |
| | | 'data': res.data.records |
| | | } |
| | | }, |
| | | response: { |
| | | statusCode: 200 |
| | | }, |
| | | done: function(res, curr, count) { |
| | | if (res.code === 403) { |
| | | top.location.href = baseUrl+"/"; |
| | | } |
| | | pageCurr=curr; |
| | | limit(); |
| | | // Update pagination text |
| | | if (typeof I18n !== 'undefined' && I18n.updateLayuiPagination) { |
| | | I18n.updateLayuiPagination(); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | ,{fixed: 'right', title:'操作', align: 'center', toolbar: '#operate', width:150} |
| | | ]], |
| | | request: { |
| | | pageName: 'curr', |
| | | pageSize: 'limit' |
| | | }, |
| | | parseData: function (res) { |
| | | return { |
| | | 'code': res.code, |
| | | 'msg': res.msg, |
| | | 'count': res.data.total, |
| | | 'data': res.data.records |
| | | } |
| | | }, |
| | | response: { |
| | | statusCode: 200 |
| | | }, |
| | | done: function(res, curr, count) { |
| | | if (res.code === 403) { |
| | | top.location.href = "/"; |
| | | } |
| | | pageCurr=curr; |
| | | limit(); |
| | | } |
| | | if (typeof I18n !== 'undefined' && I18n.isReady()) { |
| | | initTable(); |
| | | } else { |
| | | $(document).one('i18n:ready', initTable); |
| | | } |
| | | |
| | | // Listen for language change |
| | | $(document).on('i18n:languageChanged', function() { |
| | | tableIns.reload({ |
| | | cols: getCols() |
| | | }); |
| | | }); |
| | | |
| | | table.on('edit(operateLog)', function (obj) { |
| | | $('body').keydown(function () { |
| | | if (event.keyCode === 13) { |
| | | layer.confirm('保存修改?', function(){ |
| | | layer.confirm(typeof I18n !== 'undefined' ? I18n.t('confirm_save_change') : '保存修改?', function(){ |
| | | |
| | | }); |
| | | } |
| | |
| | | }, |
| | | done: function (res, curr, count) { |
| | | if (res.code === 403) { |
| | | top.location.href = "/"; |
| | | top.location.href = baseUrl+"/"; |
| | | } |
| | | pageCurr=curr; |
| | | limit(); |
| | | // Update pagination text |
| | | if (typeof I18n !== 'undefined' && I18n.updateLayuiPagination) { |
| | | I18n.updateLayuiPagination(); |
| | | } |
| | | } |
| | | }); |
| | | }); |
| | |
| | | case 'addData': |
| | | layer.open({ |
| | | type: 2, |
| | | title: '新增', |
| | | title: typeof I18n !== 'undefined' ? I18n.t('add') : '新增', |
| | | maxmin: true, |
| | | area: [top.detailWidth, top.detailHeight], |
| | | shadeClose: false, |
| | |
| | | ids.push(track.id); |
| | | }); |
| | | if (ids.length === 0){ |
| | | layer.msg('请选择数据'); |
| | | layer.msg(typeof I18n !== 'undefined' ? I18n.t('please_select_data') : '请选择数据'); |
| | | } else { |
| | | layer.confirm('确定删除'+(ids.length===1?'此':ids.length)+'条数据吗', function(){ |
| | | var confirmMsg = typeof I18n !== 'undefined' ? |
| | | (I18n.t('confirm_delete_prefix') + (ids.length===1 ? I18n.t('this') : ids.length) + I18n.t('confirm_delete_suffix')) |
| | | : ('确定删除'+(ids.length===1?'此':ids.length)+'条数据吗'); |
| | | layer.confirm(confirmMsg, function(){ |
| | | $.ajax({ |
| | | url: baseUrl+"/operateLog/delete/auth", |
| | | headers: {'token': localStorage.getItem('token')}, |
| | |
| | | layer.closeAll(); |
| | | tableReload(false); |
| | | } else if (res.code === 403){ |
| | | top.location.href = "/"; |
| | | top.location.href = baseUrl+"/"; |
| | | } else { |
| | | layer.msg(res.msg) |
| | | layer.msg(typeof I18n !== 'undefined' ? I18n.t(res.msg) : res.msg, {icon: 2}) |
| | | } |
| | | } |
| | | }) |
| | |
| | | } |
| | | break; |
| | | case 'exportData': |
| | | layer.confirm('确定导出Excel吗', function(){ |
| | | layer.confirm(typeof I18n !== 'undefined' ? I18n.t('confirm_export') : '确定导出Excel吗', {shadeClose: true}, function(){ |
| | | var titles=[]; |
| | | var fields=[]; |
| | | obj.config.cols[0].map(function (col) { |
| | |
| | | success: function (res) { |
| | | layer.closeAll(); |
| | | if (res.code === 200) { |
| | | if (typeof I18n !== 'undefined') { |
| | | $.each(res.data, function(index, item) { |
| | | item.action = I18n.t(item.action); |
| | | }); |
| | | } |
| | | table.exportFile(titles,res.data,'xls'); |
| | | } else if (res.code === 403) { |
| | | top.location.href = "/"; |
| | | top.location.href = baseUrl+"/"; |
| | | } else { |
| | | layer.msg(res.msg) |
| | | layer.msg(typeof I18n !== 'undefined' ? I18n.t(res.msg) : res.msg, {icon: 2}) |
| | | } |
| | | } |
| | | }); |
| | |
| | | case 'detail': |
| | | layer.open({ |
| | | type: 2, |
| | | title: '详情', |
| | | title: typeof I18n !== 'undefined' ? I18n.t('detail') : '详情', |
| | | maxmin: true, |
| | | area: [top.detailWidth, top.detailHeight], |
| | | shadeClose: false, |
| | | content: 'operateLog_detail.html', |
| | | success: function(layero, index){ |
| | | setFormVal(layer.getChildFrame('#detail', index), data, true); |
| | | var formData = $.extend({}, data); |
| | | if (typeof I18n !== 'undefined') { |
| | | formData.action = I18n.t(formData.action); |
| | | } |
| | | setFormVal(layer.getChildFrame('#detail', index), formData, true); |
| | | top.convertDisabled(layer.getChildFrame('#data-detail :input', index), true); |
| | | layer.getChildFrame('#data-detail-submit,#prompt', index).hide(); |
| | | layer.iframeAuto(index);layer.style(index, {top: (($(window).height()-layer.getChildFrame('#data-detail', index).height())/3)+"px"}); |
| | |
| | | case 'edit': |
| | | layer.open({ |
| | | type: 2, |
| | | title: '修改', |
| | | title: typeof I18n !== 'undefined' ? I18n.t('edit') : '修改', |
| | | maxmin: true, |
| | | area: [top.detailWidth, top.detailHeight], |
| | | shadeClose: false, |
| | |
| | | case 'userId': |
| | | var param = top.reObject(data).userId; |
| | | if (param === undefined) { |
| | | layer.msg("无数据"); |
| | | layer.msg(typeof I18n !== 'undefined' ? I18n.t('no_data_found') : "无数据"); |
| | | } else { |
| | | layer.open({ |
| | | type: 2, |
| | | title: '详情', |
| | | title: typeof I18n !== 'undefined' ? I18n.t('detail') : '详情', |
| | | maxmin: true, |
| | | area: [top.detailHeight, top.detailWidth], |
| | | shadeClose: false, |
| | |
| | | } else if (res.code === 403){ |
| | | parent.location.href = "/"; |
| | | }else { |
| | | layer.msg(res.msg) |
| | | layer.msg(typeof I18n !== 'undefined' ? I18n.t(res.msg) : res.msg, {icon: 2}) |
| | | } |
| | | } |
| | | }) |
| | |
| | | $(this).val(""); |
| | | }); |
| | | } else if (res.code === 403){ |
| | | top.location.href = "/"; |
| | | top.location.href = baseUrl+"/"; |
| | | }else { |
| | | layer.msg(res.msg) |
| | | layer.msg(typeof I18n !== 'undefined' ? I18n.t(res.msg) : res.msg, {icon: 2}) |
| | | } |
| | | layer.close(index); |
| | | } |
| | |
| | | elem: '#createTime\\$', |
| | | type: 'datetime' |
| | | }); |
| | | |
| | | layDate.render({ |
| | | elem: '.layui-laydate-range' |
| | | ,type: 'datetime' |
| | | ,range: true |
| | | }); |
| | | }); |
| | | |
| | | // 关闭动作 |
| | |
| | | }, |
| | | done: function (res, curr, count) { |
| | | if (res.code === 403) { |
| | | top.location.href = "/"; |
| | | top.location.href = baseUrl+"/"; |
| | | } |
| | | pageCurr=curr; |
| | | if (res.data.length === 0 && count !== 0) { |
| | |
| | | pageCurr -= 1; |
| | | } |
| | | limit(child); |
| | | // Update pagination text |
| | | if (typeof I18n !== 'undefined' && I18n.updateLayuiPagination) { |
| | | I18n.updateLayuiPagination(); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | |
| | | }); |
| | | $(".layui-layer-shade").remove(); |
| | | } |
| | | |