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/role/role.js | 142 +++++++++++++++++++++++++++++++----------------
1 files changed, 94 insertions(+), 48 deletions(-)
diff --git a/src/main/webapp/static/js/role/role.js b/src/main/webapp/static/js/role/role.js
index 3bdce29..6ebc783 100644
--- a/src/main/webapp/static/js/role/role.js
+++ b/src/main/webapp/static/js/role/role.js
@@ -1,6 +1,21 @@
var pageCurr;
var roleId;
var powerTreeData;
+
+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', fixed: 'left', width: 80}
+ ,{field: 'code', align: 'center',title: t('role_code')}
+ ,{field: 'name', align: 'center',title: t('role_name')}
+ ,{field: 'leader$', align: 'center',title: t('leader')}
+ // ,{field: 'level$', align: 'center',title: '瑙掕壊绛夌骇'}
+
+ ,{fixed: 'right', title: t('operation'), align: 'center', toolbar: '#operate', width:150}
+ ]];
+}
+
$(function (){
$.ajax({
url: baseUrl+"/power/list/auth",
@@ -25,48 +40,74 @@
var layDate = layui.laydate;
var form = layui.form;
- // 鏁版嵁娓叉煋
- tableIns = table.render({
- elem: '#role',
- headers: {token: localStorage.getItem('token')},
- url: baseUrl+'/role/list/auth',
- page: true,
- limit: 16,
- limits: [16, 30, 50, 100, 200, 500],
- toolbar: '#toolbar',
- cellMinWidth: 50,
- cols: [[
- {type: 'checkbox', fixed: 'left'}
- ,{field: 'id', title: 'ID', sort: true,align: 'center', fixed: 'left', width: 80}
- ,{field: 'code', align: 'center',title: '缂栫爜'}
- ,{field: 'name', align: 'center',title: '鍚嶇О'}
- ,{field: 'leader$', align: 'center',title: '涓婄骇'}
- // ,{field: 'level$', align: 'center',title: '瑙掕壊绛夌骇'}
+ // Local translation helper
+ var t = typeof I18n !== 'undefined' ? I18n.t : function(k) { return k; };
- ,{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
+ form.verify({
+ required: function (value) {
+ if (!value || $.trim(value) === '') {
+ return typeof I18n !== 'undefined'
+ ? I18n.t('form_required')
+ : '蹇呭~椤逛笉鑳戒负绌�';
}
- },
- response: {
- statusCode: 200
- },
- done: function(res, curr, count) {
- if (res.code === 403) {
- top.location.href = baseUrl+"/";
- }
- pageCurr=curr;
- limit();
}
+ });
+
+ // 鏁版嵁娓叉煋
+ var initTable = function() {
+ tableIns = table.render({
+ elem: '#role',
+ headers: {token: localStorage.getItem('token')},
+ url: baseUrl+'/role/list/auth',
+ page: true,
+ limit: 16,
+ limits: [16, 30, 50, 100, 200, 500],
+ 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();
+ if (typeof I18n !== 'undefined') {
+ I18n.updateLayuiPagination();
+ } else {
+ $(document).one('i18n:ready', function() {
+ I18n.updateLayuiPagination();
+ });
+ }
+ }
+ });
+ }
+
+ 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()
+ });
});
// 鐩戝惉鎺掑簭浜嬩欢
@@ -99,12 +140,13 @@
case 'addData':
layer.open({
type: 2,
- title: '鏂板',
+ title: t('add'),
maxmin: true,
area: [top.detailWidth, top.detailHeight],
shadeClose: false,
content: 'role_detail.html',
success: function(layero, index){
+ if (typeof I18n !== 'undefined') I18n.updatePage(layero);
clearFormVal(layer.getChildFrame('#detail', index));
layer.iframeAuto(index);layer.style(index, {top: (($(window).height()-layer.getChildFrame('#data-detail', index).height())/3)+"px"});
}
@@ -125,9 +167,9 @@
ids.push(track.id);
});
if (ids.length === 0){
- layer.msg('璇烽�夋嫨鏁版嵁');
+ layer.msg(t('please_select_data'));
} else {
- layer.confirm('纭畾鍒犻櫎'+(ids.length===1?'姝�':ids.length)+'鏉℃暟鎹悧', function(){
+ layer.confirm(t('confirm_delete_prefix')+(ids.length===1?t('this'):ids.length)+t('confirm_delete_suffix'), function(){
$.ajax({
url: baseUrl+"/role/delete/auth",
headers: {'token': localStorage.getItem('token')},
@@ -149,7 +191,7 @@
}
break;
case 'exportData':
- layer.confirm('纭畾瀵煎嚭Excel鍚�', {shadeClose: true}, function(){
+ layer.confirm(t('confirm_export_excel'), {shadeClose: true}, function(){
var titles=[];
var fields=[];
obj.config.cols[0].map(function (col) {
@@ -197,12 +239,13 @@
case 'detail':
layer.open({
type: 2,
- title: '璇︽儏',
+ title: t('detail'),
maxmin: true,
area: [top.detailWidth, top.detailHeight],
shadeClose: false,
content: 'role_detail.html',
success: function(layero, index){
+ if (typeof I18n !== 'undefined') I18n.updatePage(layero);
setFormVal(layer.getChildFrame('#detail', index), data, true);
top.convertDisabled(layer.getChildFrame('#data-detail :input', index), true);
layer.getChildFrame('#data-detail-submit,#prompt', index).hide();
@@ -215,12 +258,13 @@
case 'edit':
layer.open({
type: 2,
- title: '淇敼',
+ title: t('modify'),
maxmin: true,
area: [top.detailWidth, top.detailHeight],
shadeClose: false,
content: 'role_detail.html',
success: function(layero, index){
+ if (typeof I18n !== 'undefined') I18n.updatePage(layero);
setFormVal(layer.getChildFrame('#detail', index), data, false);
top.convertDisabled(layer.getChildFrame('#data-detail :input', index), false);
layer.iframeAuto(index);layer.style(index, {top: (($(window).height()-layer.getChildFrame('#data-detail', index).height())/3)+"px"});
@@ -231,16 +275,17 @@
case 'leader':
var param = top.reObject(data).leader;
if (param === undefined) {
- layer.msg("鏃犳暟鎹�");
+ layer.msg(t('no_data'));
} else {
layer.open({
type: 2,
- title: '璇︽儏',
+ title: t('detail'),
maxmin: true,
area: [top.detailHeight, top.detailWidth],
shadeClose: false,
content: '../role/role_detail.html',
success: function(layero, index){
+ if (typeof I18n !== 'undefined') I18n.updatePage(layero);
$.ajax({
url: baseUrl+"/role/"+ param +"/auth",
headers: {'token': localStorage.getItem('token')},
@@ -267,12 +312,13 @@
roleId = data.id;
layer.open({
type: 2,
- title: data.name + ' 鏉冮檺鍒嗛厤',
+ title: data.name + ' ' + t('permission_assignment'),
maxmin: true,
area: [top.detailWidth/2, '85%'],
shadeClose: false,
content: 'role_power_detail.html',
success: function(layero, index){
+ if (typeof I18n !== 'undefined') I18n.updatePage(layero);
}
});
break;
--
Gitblit v1.9.1