From 539a56279625242c497b4b4093f2defbb9d80334 Mon Sep 17 00:00:00 2001
From: lty <876263681@qq.com>
Date: 星期四, 29 一月 2026 14:05:44 +0800
Subject: [PATCH] #i18n翻译
---
src/main/webapp/static/js/operateLog/operateLog.js | 159 +++++++++++++++++++++++++++++++++++------------------
1 files changed, 105 insertions(+), 54 deletions(-)
diff --git a/src/main/webapp/static/js/operateLog/operateLog.js b/src/main/webapp/static/js/operateLog/operateLog.js
index d8c9acf..d79314a 100644
--- a/src/main/webapp/static/js/operateLog/operateLog.js
+++ b/src/main/webapp/static/js/operateLog/operateLog.js
@@ -1,4 +1,28 @@
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;
@@ -7,56 +31,64 @@
var form = layui.form;
// 鏁版嵁娓叉煋
- 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: [[
- // {type: 'checkbox'}
- {field: 'id', title: 'ID', sort: true,align: 'center', width: 80}
- ,{field: 'userId$', align: 'center',title: '鐢ㄦ埛'}
- ,{field: 'action', align: 'center',title: '鎿嶄綔鍐呭'}
- ,{field: 'ip', align: 'center',title: '瀹㈡埛绔疘P'}
- ,{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:100}
- ]],
- 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();
- }
+ 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(){
});
}
@@ -82,6 +114,10 @@
}
pageCurr=curr;
limit();
+ // Update pagination text
+ if (typeof I18n !== 'undefined' && I18n.updateLayuiPagination) {
+ I18n.updateLayuiPagination();
+ }
}
});
});
@@ -93,7 +129,7 @@
case 'addData':
layer.open({
type: 2,
- title: '鏂板',
+ title: typeof I18n !== 'undefined' ? I18n.t('add') : '鏂板',
maxmin: true,
area: [top.detailWidth, top.detailHeight],
shadeClose: false,
@@ -119,9 +155,12 @@
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')},
@@ -143,7 +182,7 @@
}
break;
case 'exportData':
- layer.confirm('纭畾瀵煎嚭Excel鍚�', {shadeClose: true}, 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) {
@@ -170,6 +209,11 @@
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 = baseUrl+"/";
@@ -191,13 +235,17 @@
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"});
@@ -209,7 +257,7 @@
case 'edit':
layer.open({
type: 2,
- title: '淇敼',
+ title: typeof I18n !== 'undefined' ? I18n.t('edit') : '淇敼',
maxmin: true,
area: [top.detailWidth, top.detailHeight],
shadeClose: false,
@@ -225,11 +273,11 @@
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,
@@ -353,6 +401,10 @@
pageCurr -= 1;
}
limit(child);
+ // Update pagination text
+ if (typeof I18n !== 'undefined' && I18n.updateLayuiPagination) {
+ I18n.updateLayuiPagination();
+ }
}
});
}
@@ -393,4 +445,3 @@
});
$(".layui-layer-shade").remove();
}
-
--
Gitblit v1.9.1