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/user/user.js | 155 +++++++++++++++++++++++++++++++++------------------
1 files changed, 99 insertions(+), 56 deletions(-)
diff --git a/src/main/webapp/static/js/user/user.js b/src/main/webapp/static/js/user/user.js
index 0e06c7e..6aaa795 100644
--- a/src/main/webapp/static/js/user/user.js
+++ b/src/main/webapp/static/js/user/user.js
@@ -1,6 +1,29 @@
var pageCurr;
var tableData;
var insTb2;
+
+function getCols() {
+ var t = typeof I18n !== 'undefined' ? I18n.t : function(k) { return k; };
+ return [[
+ {type: 'checkbox'}
+ // ,{field: 'hostName', align: 'center',title: '鎺堟潈鍟嗘埛', templet: '#hostTpl', width: 140}
+ // ,{field: 'nickname', align: 'center',title: '鐢ㄦ埛鍚�'}
+ ,{field: 'username', align: 'center',title: t('login_account')}
+ ,{field: 'mobile', align: 'center',title: t('mobile')}
+ // ,{field: 'deptName', align: 'center',title: '鎵�灞為儴闂�'}
+ ,{field: 'roleName', align: 'center',title: t('role')}
+ ,{field: 'email', align: 'center',title: t('email')}
+ // ,{field: 'sex$', align: 'center',title: '鎬у埆'}
+ ,{field: 'createTime$', align: 'center',title: t('register_time'), hide: true}
+ ,{field: 'status$', align: 'center',title: t('data_status'), width: 120, unresize: true, templet: function(d) {
+ var normal = t('normal');
+ var disabled = t('status_disabled');
+ return '<input type="checkbox" name="status" value="' + d.status + '" lay-skin="switch" lay-text="' + normal + '|' + disabled + '" lay-filter="statusSwitch" ' + (d.status === 1 ? 'checked' : '') + '>';
+ }}
+ ,{fixed: 'right', title: t('operation'), align: 'center', toolbar: '#operate', width:170}
+ ]];
+}
+
layui.config({
base: baseUrl + "/static/layui/lay/modules/"
}).use(['table','laydate', 'form', 'util', 'admin'], function(){
@@ -12,54 +35,72 @@
var admin = layui.admin;
var util = layui.util;
- insTb2 = table.render({
- elem: '#userTable',
- headers: {token: localStorage.getItem('token')},
- url: baseUrl+'/user/list/auth',
- page: true,
- limit: 15,
- limits: [15, 30, 50, 100, 200, 500],
- toolbar: '#userToolbar',
- height: 'full-100',
- cols: [[
- {type: 'checkbox'}
- // ,{field: 'hostName', align: 'center',title: '鎺堟潈鍟嗘埛', templet: '#hostTpl', width: 140}
- // ,{field: 'nickname', align: 'center',title: '鐢ㄦ埛鍚�'}
- ,{field: 'username', align: 'center',title: '鐧诲綍璐︽埛'}
- ,{field: 'mobile', align: 'center',title: '鎵嬫満鍙�'}
- // ,{field: 'deptName', align: 'center',title: '鎵�灞為儴闂�'}
- ,{field: 'roleName', align: 'center',title: '瑙掕壊'}
- ,{field: 'email', align: 'center',title: '閭'}
- // ,{field: 'sex$', align: 'center',title: '鎬у埆'}
- ,{field: 'createTime$', align: 'center',title: '娉ㄥ唽鏃堕棿', hide: true}
- ,{field: 'status$', align: 'center',title: '鐘舵��', templet: '#statusTpl', width: 120, unresize: true}
+ // Local translation helper
+ var t = typeof I18n !== 'undefined' ? I18n.t : function(k) { return k; };
- ,{fixed: 'right', title:'鎿嶄綔', align: 'center', toolbar: '#operate', width:170}
- ]],
- 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+"/";
- }
- tableData = table.cache.userTable;
- pageCurr=curr;
- limit();
}
});
+
+ var initTable = function() {
+ insTb2 = table.render({
+ elem: '#userTable',
+ headers: {token: localStorage.getItem('token')},
+ url: baseUrl+'/user/list/auth',
+ page: true,
+ limit: 15,
+ limits: [15, 30, 50, 100, 200, 500],
+ toolbar: '#userToolbar',
+ height: 'full-100',
+ 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+"/";
+ }
+ tableData = table.cache.userTable;
+ pageCurr=curr;
+ limit();
+ if (typeof I18n !== 'undefined') {
+ I18n.updateLayuiPagination();
+ }
+ }
+ });
+ }
+
+ if (typeof I18n !== 'undefined' && I18n.isReady()) {
+ initTable();
+ } else {
+ $(document).one('i18n:ready', initTable);
+ }
+
+ // Listen for language change
+ $(document).on('i18n:languageChanged', function() {
+ insTb2.reload({
+ cols: getCols()
+ });
+ });
+
/* 琛ㄦ牸2鎼滅储 */
form.on('submit(userTbSearch)', function (data) {
insTb2.reload({where: data.field, page: {curr: 1}});
@@ -73,7 +114,7 @@
showEditModel()
} else if (obj.event === 'del') { // 鍒犻櫎
if (checkStatus.length === 0) {
- layer.msg('璇烽�夋嫨瑕佸垹闄ょ殑鏁版嵁', {icon: 2});
+ layer.msg(t('please_select_data'), {icon: 2});
return;
}
del(checkStatus.map(function (d) {
@@ -88,7 +129,7 @@
var data = tableData[index];
data[this.name] = obj.elem.checked?1:0;
http.post(baseUrl+"/user/edit/auth", {id: data.id, status: data[this.name]}, function (res) {
- layer.msg(res.msg, {icon: 1});
+ layer.msg(typeof I18n !== 'undefined' ? I18n.t(res.msg, res.data) : res.msg, {icon: 1});
})
})
@@ -108,13 +149,14 @@
case 'resetPwd':
admin.open({
type: 1,
- title: '閲嶇疆瀵嗙爜',
+ title: t('reset_pwd'),
offset: '150px',
area: ['360px'],
shade: 0.1,
shadeClose: true,
content: $("#resetpwd-window").html(),
success: function(layero, index){
+ if (typeof I18n !== 'undefined') I18n.updatePage(layero);
layer.iframeAuto(index);
$('#resetUserId').val(data.id);
}
@@ -128,15 +170,16 @@
admin.open({
type: 1,
area: '600px',
- title: (mData ? '淇敼' : '娣诲姞') + '鐢ㄦ埛',
+ title: mData ? t('modify_user') : t('add_user'),
content: $('#editDialog').html(),
success: function (layero, dIndex) {
+ if (typeof I18n !== 'undefined') I18n.updatePage(layero);
// 鍥炴樉琛ㄥ崟鏁版嵁
form.val('detail', mData);
// 琛ㄥ崟鎻愪氦浜嬩欢
form.on('submit(editSubmit)', function (data) {
if (isEmpty(data.field.roleId)) {
- layer.msg('璇烽�夋嫨瑙掕壊', {icon: 2});
+ layer.msg(t('please_select_role'), {icon: 2});
return false;
}
var loadIndex = layer.load(2);
@@ -149,12 +192,12 @@
layer.close(loadIndex);
if (res.code === 200){
layer.close(dIndex);
- layer.msg(res.msg, {icon: 1});
+ layer.msg(typeof I18n !== 'undefined' ? I18n.t(res.msg, res.data) : res.msg, {icon: 1});
$(".layui-laypage-btn")[0].click();
} else if (res.code === 403){
top.location.href = baseUrl+"/";
}else {
- layer.msg(res.msg, {icon: 2});
+ layer.msg(typeof I18n !== 'undefined' ? I18n.t(res.msg, res.data) : res.msg, {icon: 2});
}
}
})
@@ -170,7 +213,7 @@
/* 鍒犻櫎璁㈠崟 */
function del(ids) {
- layer.confirm('纭畾瑕佸垹闄ら�変腑鏁版嵁鍚楋紵', {
+ layer.confirm(t('confirm_delete_selected'), {
skin: 'layui-layer-admin',
shade: .1
}, function (i) {
@@ -184,12 +227,12 @@
success: function (res) {
layer.close(loadIndex);
if (res.code === 200){
- layer.msg(res.msg, {icon: 1});
+ layer.msg(typeof I18n !== 'undefined' ? I18n.t(res.msg, res.data) : res.msg, {icon: 1});
$(".layui-laypage-btn")[0].click();
} else if (res.code === 403){
top.location.href = baseUrl+"/";
}else {
- layer.msg(res.msg, {icon: 2});
+ layer.msg(typeof I18n !== 'undefined' ? I18n.t(res.msg, res.data) : res.msg, {icon: 2});
}
}
})
@@ -210,11 +253,11 @@
success: function (res) {
if (res.code === 200){
layer.closeAll();
- layer.msg("閲嶇疆瀵嗙爜鎴愬姛", {icon: 1});
+ layer.msg(t('reset_pwd_success'), {icon: 1});
} else if (res.code === 403){
top.location.href = baseUrl+"/";
}else {
- layer.msg(res.msg, {icon: 2})
+ layer.msg(typeof I18n !== 'undefined' ? I18n.t(res.msg, res.data) : res.msg, {icon: 2})
}
}
})
--
Gitblit v1.9.1