From 35b1b26f1fe16550b4ee2881a26d599456fe59b4 Mon Sep 17 00:00:00 2001
From: lty <876263681@qq.com>
Date: 星期四, 22 一月 2026 17:01:11 +0800
Subject: [PATCH] #i18n翻译

---
 src/main/webapp/static/js/report/locMap.js |   80 ++++++++++++++++++++++++++++------------
 1 files changed, 56 insertions(+), 24 deletions(-)

diff --git a/src/main/webapp/static/js/report/locMap.js b/src/main/webapp/static/js/report/locMap.js
index 58b6171..d304e4a 100644
--- a/src/main/webapp/static/js/report/locMap.js
+++ b/src/main/webapp/static/js/report/locMap.js
@@ -13,10 +13,42 @@
     });
 
     // 鍒濆鍔犺浇
-    loadAreas();             // 鍔犺浇搴撳尯棰滆壊淇℃伅
-    loadRowsOptions();       // 鍔犺浇銆屾帓銆嶉�夐」锛堝缁堥渶瑕侊級
-    loadLayersOptions();     // 鍔犺浇銆屽眰銆嶉�夐」锛堟彁鍓嶅噯澶囷級
-    getLocTable('byRow', 1); // 榛樿鎸夋帓 + 绗�1鎺�
+    function initMap() {
+        loadAreas();             // 鍔犺浇搴撳尯棰滆壊淇℃伅
+        loadRowsOptions();       // 鍔犺浇銆屾帓銆嶉�夐」锛堝缁堥渶瑕侊級
+        loadLayersOptions();     // 鍔犺浇銆屽眰銆嶉�夐」锛堟彁鍓嶅噯澶囷級
+        getLocTable('byRow', 1); // 榛樿鎸夋帓 + 绗�1鎺�
+    }
+
+    if (I18n.isReady()) {
+        initMap();
+    } else {
+        $(document).on('i18n:ready', initMap);
+    }
+    
+    // Listen for dynamic language updates (no reload)
+    $(document).on('i18n:updated', function() {
+        // Update selection button text
+        if (isSelectionMode) {
+            $('#btnSelectMode').text(I18n.t('disable_selection'));
+        } else {
+            $('#btnSelectMode').text(I18n.t('enable_selection'));
+        }
+        
+        // Update assign button text if visible
+        if ($('.loc-selected').length > 0) {
+            $('#btnAssignZone').text(I18n.t('assign_zone') + ' (' + $('.loc-selected').length + ')');
+        } else {
+            $('#btnAssignZone').text(I18n.t('assign_zone'));
+        }
+
+        // Re-render legend to update text
+        loadAreas();
+        
+        // Re-render select options if needed (but options usually don't have text needing translation unless hardcoded)
+        // Re-render form to apply changes
+        form.render();
+    });
 
     // 鍔犺浇搴撳尯淇℃伅骞舵樉绀哄浘渚�
     function loadAreas() {
@@ -27,7 +59,7 @@
             success: function(res) {
                 if (res.code === 200) {
                     areaMap = {};
-                    var legendHtml = '<div class="area-legend-item" style="cursor:default;font-weight:bold;">搴撳尯鍥句緥:</div>';
+                    var legendHtml = '<div class="area-legend-item" style="cursor:default;font-weight:bold;">' + I18n.t('zone_legend') + ':</div>';
                     // 榛樿棰滆壊鍒楄〃锛岀敤浜庤嚜鍔ㄥ垎閰�
                     var defaultColors = ['#FF5733', '#33FF57', '#3357FF', '#FF33A1', '#A133FF', '#33FFF5', '#FFD700', '#FF8C00'];
                     var colorIndex = 0;
@@ -55,21 +87,21 @@
         
         var contentHtml = '<div style="padding: 20px;"><form class="layui-form">' +
             '<div class="layui-form-item">' +
-            '<label class="layui-form-label" style="width: auto; padding-left: 0;">搴撳尯鍚嶇О:</label>' +
+            '<label class="layui-form-label" style="width: auto; padding-left: 0;">' + I18n.t('zone_name') + ':</label>' +
             '<div class="layui-input-inline" style="line-height: 45px;">' + areaData.name + '</div>' +
             '</div>' +
             '<div class="layui-form-item">' +
-            '<label class="layui-form-label" style="width: auto; padding-left: 0;">閫夋嫨棰滆壊</label>' +
+            '<label class="layui-form-label" style="width: auto; padding-left: 0;">' + I18n.t('select_color') + '</label>' +
             '<div class="layui-input-inline"><input type="color" id="singleAreaColorPicker" value="' + (areaData.color || '#cccccc') + '" style="height: 38px; width: 100%;"></div>' +
             '</div>' +
             '</form></div>';
 
         layer.open({
             type: 1,
-            title: '淇敼搴撳尯棰滆壊',
+            title: I18n.t('modify_zone_color'),
             area: ['350px', '250px'],
             content: contentHtml,
-            btn: ['淇濆瓨', '鍙栨秷'],
+            btn: [I18n.t('save'), I18n.t('cancel')],
             yes: function(index) {
                 var newColor = $('#singleAreaColorPicker').val();
                 if (newColor !== areaData.color) {
@@ -80,7 +112,7 @@
                         data: { id: areaId, backup1: newColor },
                         success: function(res) {
                             if (res.code === 200) {
-                                layer.msg('棰滆壊宸叉洿鏂�');
+                                layer.msg(I18n.t('color_updated'));
                                 layer.close(index);
                                 loadAreas(); // 鍒锋柊鍥句緥鍜岀紦瀛�
                                 // 鍒锋柊鍦板浘浠ュ簲鐢ㄦ柊棰滆壊
@@ -88,7 +120,7 @@
                                 if (mode === 'byRow') getLocTable('byRow', $('#rowSelect').val());
                                 else getLocTable('byLayer', $('#layerSelect').val());
                             } else {
-                                layer.msg(res.msg || '鏇存柊澶辫触');
+                                layer.msg(res.msg || I18n.t('update_failed'));
                             }
                         }
                     });
@@ -160,7 +192,7 @@
                 } else if (res.code === 403) {
                     top.location.href = baseUrl + "/";
                 } else {
-                    layer.msg(res.msg || '鍔犺浇澶辫触');
+                    layer.msg(res.msg || I18n.t('load_failed'));
                 }
             }
         });
@@ -208,15 +240,15 @@
     $('#btnSelectMode').click(function () {
         isSelectionMode = !isSelectionMode;
         if (isSelectionMode) {
-            $(this).text('鍏抽棴妗嗛��').addClass('layui-btn-danger').removeClass('layui-btn-normal');
+            $(this).text(I18n.t('disable_selection')).addClass('layui-btn-danger').removeClass('layui-btn-normal');
             // 绂佺敤鍘熸湁鐐瑰嚮浜嬩欢锛岄槻姝㈠啿绐� (閫氳繃 CSS pointer-events 鎴栫Щ闄� onclick)
             // 杩欓噷閫夋嫨绉婚櫎 onclick 灞炴��
             $('.a-loc').each(function(){
                 $(this).attr('data-onclick', $(this).attr('onclick')).removeAttr('onclick');
             });
-            layer.msg('宸插紑鍚閫夋ā寮忥紝璇峰湪搴撲綅鍥句笂鎷栨嫿閫夋嫨');
+            layer.msg(I18n.t('selection_mode_tip'));
         } else {
-            $(this).text('寮�鍚閫�').addClass('layui-btn-normal').removeClass('layui-btn-danger');
+            $(this).text(I18n.t('enable_selection')).addClass('layui-btn-normal').removeClass('layui-btn-danger');
             $('.loc-selected').removeClass('loc-selected');
             $('#btnAssignZone').hide();
             // 鎭㈠鐐瑰嚮浜嬩欢
@@ -307,7 +339,7 @@
         });
 
         if ($('.loc-selected').length > 0) {
-            $('#btnAssignZone').show().text('鍒嗛厤搴撳尯 (' + $('.loc-selected').length + ')');
+            $('#btnAssignZone').show().text(I18n.t('assign_zone') + ' (' + $('.loc-selected').length + ')');
         } else {
             $('#btnAssignZone').hide();
         }
@@ -328,7 +360,7 @@
             headers: {'token': localStorage.getItem('token')},
             success: function(listRes) {
                 if (listRes.code === 200) {
-                        var optionsHtml = '<option value="">璇烽�夋嫨搴撳尯</option>';
+                        var optionsHtml = '<option value="">' + I18n.t('please_select_zone') + '</option>';
                         var areas = listRes.data.records;
                         areas.forEach(function(area) {
                             optionsHtml += '<option value="' + area.id + '">' + area.areaName + ' (' + area.areaId + ')</option>';
@@ -337,17 +369,17 @@
                         var contentHtml = '<div style="padding: 20px;"><form class="layui-form">' +
                             '<div class="layui-form-item"><select id="selectArea" lay-filter="selectArea">' + optionsHtml + '</select></div>' +
                             '<div class="layui-form-item">' +
-                            '<label class="layui-form-label" style="width: auto; padding-left: 0;">搴撳尯棰滆壊</label>' +
+                            '<label class="layui-form-label" style="width: auto; padding-left: 0;">' + I18n.t('zone_color') + '</label>' +
                             '<div class="layui-input-inline"><input type="color" id="areaColorPicker" value="#cccccc" style="height: 38px; width: 100%;"></div>' +
                             '</div>' +
                             '</form></div>';
 
                         layer.open({
                             type: 1,
-                            title: '鍒嗛厤搴撳尯鍙婇鑹�',
+                            title: I18n.t('assign_zone_and_color'),
                             area: ['400px', '350px'],
                             content: contentHtml,
-                            btn: ['纭畾', '鍙栨秷'],
+                            btn: [I18n.t('confirm'), I18n.t('cancel')],
                             success: function(layero, index) {
                                 form.render('select');
                                 form.on('select(selectArea)', function(data){
@@ -362,7 +394,7 @@
                                 var newColor = $('#areaColorPicker').val();
 
                                 if (!areaId) {
-                                    layer.msg('璇烽�夋嫨搴撳尯');
+                                    layer.msg(I18n.t('please_select_zone'));
                                     return;
                                 }
 
@@ -392,7 +424,7 @@
                                     }),
                                     success: function(updRes) {
                                         if (updRes.code === 200) {
-                                            layer.msg('鍒嗛厤鎴愬姛');
+                                            layer.msg(I18n.t('assign_success'));
                                             layer.close(index);
                                             // 鍒锋柊
                                             var mode = $('#viewMode').val();
@@ -412,14 +444,14 @@
                                                 }, 500); // 绠�鍗曞欢鏃剁瓑寰呮覆鏌�
                                             }
                                         } else {
-                                            layer.msg(updRes.msg || '鎿嶄綔澶辫触');
+                                            layer.msg(updRes.msg || I18n.t('operation_failed'));
                                         }
                                     }
                                 });
                             }
                         });
                 } else {
-                    layer.msg(listRes.msg || '鏃犳硶鑾峰彇搴撳尯鍒楄〃');
+                    layer.msg(listRes.msg || I18n.t('fetch_zone_list_failed'));
                 }
             }
         });

--
Gitblit v1.9.1