From c54fbb99cc0735bb8388895ed2a0f76bb2b012fd Mon Sep 17 00:00:00 2001
From: yangle <admin@YINMOU>
Date: 星期三, 02 四月 2025 09:58:28 +0800
Subject: [PATCH] 墨西哥模块翻译

---
 WebTM/layuiadmin/MESLanguage.js |  437 +++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 410 insertions(+), 27 deletions(-)

diff --git a/WebTM/layuiadmin/MESLanguage.js b/WebTM/layuiadmin/MESLanguage.js
index 98ce07a..8dda3cc 100644
--- a/WebTM/layuiadmin/MESLanguage.js
+++ b/WebTM/layuiadmin/MESLanguage.js
@@ -1,35 +1,418 @@
-//纭繚DOM瀹屽叏鍔犺浇鍚庡啀鎵ц
-//document.addEventListener('DOMContentLoaded', function () {
-//    initFunction();
-//});
-//$(document).on('click', '.layui-btn', function () {
-//    initFunction();
-//});
- 
+
+var HModNameData = "";
+var HLanguageType_Data = "";
 document.addEventListener('click', function (event) {
-    Btn();
+    var data = localStorage.getItem("data");
+    var data2 = JSON.parse(data);
+    if (HModNameData != "indexMenu") {
+        if (data == null || data2.HTranSlate != HLanguageType_Data) {
+            ClickFunction(2,HModNameData, HLanguageType_Data);
+        } else {
+            ClickFunction(2,HModNameData, data2.HTranSlate);
+        }
+    }
 });
 
-function Lable() {
-    var Lable = document.querySelectorAll('.layui-form-label').length;
-    for (var i = 0; i < Lable; i++) {
-        console.log(document.querySelectorAll('.layui-form-label')[i].innerHTML);
+
+//鐐瑰嚮浜嬩欢瑙﹀彂鐨勬柟娉�
+function ClickFunction(InitiaType,HModName,HLanguageType) {
+    var data = localStorage.getItem(HModName);
+    if (data != null) {
+        var data2 = JSON.parse(data)
+        if (HModName == "login") {
+            LoginDataShow(data2, HLanguageType);
+        } else {
+            ModelDataShow(InitiaType,data2, HLanguageType);
+        }
     }
-    for (var i = 0; i < Lable; i++) {
-        document.querySelectorAll('.layui-form-label')[i].innerHTML = document.querySelectorAll('.layui-form-label')[i].textContent + "1";
-    }
-}
-function initFunction() {
-    Btn();
-    Lable();
 }
 
-function Btn() {
-    var Btn = document.querySelectorAll('button>text').length;
-    for (var i = 0; i < Btn; i++) {
-        console.log(document.querySelectorAll('button>text')[i].innerHTML);
-    }
-    for (var i = 0; i < Btn; i++) {
-        document.querySelectorAll('button>text')[i].innerHTML = document.querySelectorAll('button>text')[i].textContent + "1";
+//鍒濆鍖栭〉闈㈠姞杞芥暟鎹�  InitiaType 鍒濆鍖� 榛樿1  2=鐐瑰嚮浜嬩欢
+function initFunction(InitiaType,HModName, HLanguageType) {
+    HModNameData = HModName;
+    HLanguageType_Data = HLanguageType;
+    get_ReadConfigFile(InitiaType,HModName, HLanguageType);
+}
+
+//鐧诲綍椤甸潰 鏄剧ず鏁版嵁
+function LoginDataShow(data, HLanguageType) {
+    for (var i = 0; i < data.length; i++) {
+        var HTranslationText = "";
+
+        if (HLanguageType == 1) {
+            HTranslationText = data[i].HFieldName;
+        } else if (HLanguageType == 2) {
+            HTranslationText = data[i].HTranslationText_English;
+        } else if (HLanguageType == 3) {
+            HTranslationText = data[i].HTranslationText_Spain;
+        }
+
+        if (data[i].HFieldModelType == "id") {
+            $("#" + data[i].HFieldCode).text(data[i].HFieldName)
+        } else if (data[i].HFieldModelType == "class") {
+            if (data[i].HFieldCode != "select option") {
+                var count = document.querySelectorAll(data[i].HFieldCode).length;
+                for (var j = 0; j < count; j++) {
+                    document.querySelectorAll(data[i].HFieldCode)[j].innerText = data[i].HFieldName;
+                }
+            }
+        }
+       
+        if (data[i].HFieldModelType == "id") {
+            if ($("#" + data[i].HFieldCode).text().trim() == data[i].HFieldName) {
+                $("#" + data[i].HFieldCode).text(HTranslationText)
+            }
+        } else if (data[i].HFieldModelType == "class") {
+            if (data[i].HFieldCode != "select option") {
+                var count = document.querySelectorAll(data[i].HFieldCode).length;
+                for (var j = 0; j < count; j++) {
+                    if (document.querySelectorAll(data[i].HFieldCode)[j].innerText.trim() == data[i].HFieldName) {
+                        document.querySelectorAll(data[i].HFieldCode)[j].innerText = HTranslationText;
+                        //break;
+                    }
+                }
+            }
+        }
     }
 }
+
+//妯″潡 鏄剧ず鏁版嵁
+function ModelDataShow(InitiaType, data, HLanguageType) {
+    //涓嬫媺妗嗘墍鏈夊��  .layui-unselect dd
+    var OptionData = [];
+    const ddElementsOptionData = document.querySelectorAll(".layui-unselect dd");
+    // 閬嶅巻鍏冪礌骞惰幏鍙栧唴瀹�
+    ddElementsOptionData.forEach((dd, index) => {
+        OptionData.push(dd.innerText.trim());
+    });
+
+    //涓嬫媺妗嗘墍鏈夊��  select option
+    var OptionList = [];
+    const ddElementsOptionList = document.querySelectorAll("select option");
+
+    // 閬嶅巻鍏冪礌骞惰幏鍙栧唴瀹�
+    ddElementsOptionList.forEach((dd, index) => {
+        OptionList.push(dd.innerText.trim());
+    });
+ 
+    for (var i = 0; i < data.length; i++) {
+        var HTranslationText = "";
+
+        if (HLanguageType == 1) {
+            HTranslationText = data[i].HFieldName;
+        } else if (HLanguageType == 2) {
+            HTranslationText = data[i].HTranslationText_English;
+        } else if (HLanguageType == 3) {
+            HTranslationText = data[i].HTranslationText_Spain;
+        }
+
+        if (data[i].HFieldModelType == "id") {
+            if ($("#" + data[i].HFieldCode).text().trim() == data[i].HFieldName) {
+                if (document.querySelectorAll("#" + data[i].HFieldCode)[0].innerHTML == data[i].HFieldName) {
+                    document.querySelectorAll("#" + data[i].HFieldCode)[0].innerHTML = document.querySelectorAll("#" + data[i].HFieldCode)[0].innerHTML.replace(data[i].HFieldName.replace('*', ''), HTranslationText.replace('*', ''));
+                } else if (document.querySelectorAll("#" + data[i].HFieldCode)[0].innerText == data[i].HFieldName) {
+                    document.querySelectorAll("#" + data[i].HFieldCode)[0].innerHTML = document.querySelectorAll("#" + data[i].HFieldCode)[0].innerHTML.replace(data[i].HFieldName.replace('*', ''), HTranslationText.replace('*', ''));
+                } else {
+                    document.querySelectorAll("#" + data[i].HFieldCode)[0].innerText = document.querySelectorAll("#" + data[i].HFieldCode)[0].innerText.replace(data[i].HFieldName.replace('*', ''), HTranslationText.replace('*', ''));
+                }
+            }
+        } else if (data[i].HFieldModelType == "class") {
+
+            if (InitiaType != 2) {
+                if (data[i].HFieldCode != "select option") {
+                    var count = document.querySelectorAll(data[i].HFieldCode).length;
+                    for (var j = 0; j < count; j++) {
+                        if (document.querySelectorAll(data[i].HFieldCode)[j].innerText.trim() == data[i].HFieldName) {
+                            document.querySelectorAll(data[i].HFieldCode)[j].innerHTML = document.querySelectorAll(data[i].HFieldCode)[j].innerHTML.replace(data[i].HFieldName, HTranslationText);
+                        }
+                    }
+                } else {
+
+                    //涓嬫媺妗嗙殑鎵�鏈夊��
+                    var indicesData = [];
+                    var currentIndex = -1;
+                    while ((currentIndex = OptionData.indexOf(data[i].HFieldName, currentIndex + 1)) !== -1) {
+                        indicesData.push(currentIndex);
+                    }
+
+                    for (var j = 0; j < indicesData.length; j++) {
+                        document.querySelectorAll(".layui-unselect dd")[indicesData[j]].innerHTML = document.querySelectorAll(".layui-unselect dd")[indicesData[j]].innerHTML.replace(data[i].HFieldName, HTranslationText);
+                      
+                    }
+
+                    var indicesList = [];
+                    currentIndex = -1;
+                    while ((currentIndex = OptionList.indexOf(data[i].HFieldName, currentIndex + 1)) !== -1) {
+                        indicesList.push(currentIndex);
+                    }
+
+                    for (var j = 0; j < indicesList.length; j++) {
+                        document.querySelectorAll(data[i].HFieldCode)[indicesList[j]].innerHTML = document.querySelectorAll(data[i].HFieldCode)[indicesList[j]].innerHTML.replace(data[i].HFieldName, HTranslationText);
+                    }
+
+                }
+            } else {
+                if (data[i].HFieldCode != "select option") {
+                    var count = document.querySelectorAll(data[i].HFieldCode).length;
+                    for (var j = 0; j < count; j++) {
+                        if (document.querySelectorAll(data[i].HFieldCode)[j].innerText.trim() == data[i].HFieldName) {
+                            document.querySelectorAll(data[i].HFieldCode)[j].innerHTML = document.querySelectorAll(data[i].HFieldCode)[j].innerHTML.replace(data[i].HFieldName, HTranslationText);
+                        }
+                    }
+                }
+            }
+
+            //涓嬫媺妗嗙殑榛樿鍊�
+            if (data[i].HFieldCode == ".layui-unselect input") {
+                var uncount = document.querySelectorAll(".layui-unselect input").length;
+                for (var j = 0; j < uncount; j++) {
+                    if (document.querySelectorAll(".layui-unselect input")[j].placeholder.trim() == data[i].HFieldName) {
+                        document.querySelectorAll(".layui-unselect input")[j].placeholder = document.querySelectorAll(".layui-unselect input")[j].placeholder.replace(data[i].HFieldName, HTranslationText);
+                    }
+                }
+            }
+        }
+    }
+}
+
+//鑾峰彇椤甸潰鐨勬墍鏈夋爣绛緄d 瀵瑰簲瑕佺炕璇戠殑瀛楁
+function SelectData() {
+    var DataList = "";
+
+    //#region  鐧诲綍鐣岄潰  鑷畾涔� 绫� FY_BT  涓轰簡缁熶竴 
+    //鍒峰崱 瀛楁鍙互鑾峰彇 鎵�浠� 涓嶇敤鑷畾涔�
+    var logCount = document.querySelectorAll('.FY_BT').length;
+    for (var i = 0; i < logCount; i++) {
+        var id = document.querySelectorAll('.FY_BT')[i].id;
+        var data = document.querySelectorAll('.FY_BT')[i].innerText.trim();
+        var type = "id";
+        DataList += id + "|" + data + "|" + type + ","
+    }
+
+    //#endregion
+
+    //鏂囨湰鏍囩鐨勬暟鎹幏鍙� 閫氳繃id
+    var LableCount = document.querySelectorAll('.layui-form-label').length;
+    for (var i = 0; i < LableCount; i++) {
+        var id = document.querySelectorAll('.layui-form-label')[i].id;
+        var data = document.querySelectorAll('.layui-form-label')[i].innerText.trim();
+        var type = "id";
+        DataList += id + "|" + data + "|" + type + ","
+    }
+
+    //澶嶉�夋鏍囩鐨勭殑鏁版嵁鑾峰彇  閫氳繃id
+    var CheckCount = document.querySelectorAll("input[type='checkbox']").length;
+    for (var i = 0; i < CheckCount; i++) {
+        var data = document.querySelectorAll("input[type='checkbox']")[i].title.trim();
+        if (data != "") {
+            var id = document.querySelectorAll("input[type='checkbox']")[i].id;
+            var type = "id";
+            DataList += id + "|" + data + "|" + type + ","
+        }
+      
+    }
+   
+    //#region 鍗曟嵁椤甸潰  鎸夐挳鐨勮幏鍙�
+
+    //鍗曟嵁椤甸潰 鏍囬鏍囩鑾峰彇 閫氳繃id
+    var BTCount = document.querySelectorAll('.layui-tab h1').length
+    for (var i = 0; i < BTCount; i++) {
+        if (document.querySelectorAll('.layui-tab h1')[i].innerText.trim() != '') {
+            var id = document.querySelectorAll('.layui-tab h1')[i].id;
+            var data = document.querySelectorAll('.layui-tab h1')[i].innerText.trim();
+            var type = "id";
+            DataList += id + "|" + data + "|" + type + ","
+        }
+    }
+
+    //#endregion
+
+    //鎸夐挳鏍囩鐨勬暟鎹幏鍙� 閫氳繃id
+    //鎸夐挳鏍囩鐨勬暟鎹幏鍙� 閫氳繃class 渚嬪 瀛愯〃鍒犻櫎 浠栫殑id浼氬彉
+    var BtnCount = document.querySelectorAll('.layui-btn').length;
+    for (var i = 0; i < BtnCount; i++) {
+        if (document.querySelectorAll('.layui-btn')[i].innerText.trim() != "") {
+            var id = document.querySelectorAll('.layui-btn')[i].id.trim();
+            var type = "";
+            if (id != "") {
+                type = "id";
+            } else {
+                id = ".layui-btn";
+                type = "class";
+            }
+            var data = document.querySelectorAll('.layui-btn')[i].innerText.trim();
+
+            DataList += id + "|" + data + "|" + type + ","
+        }
+    }
+
+    //椤电鏍囩鐨勬暟鎹幏鍙� 閫氳繃class
+    var YQCount = document.querySelectorAll('.layui-tab-title>li').length;
+    for (var i = 0; i < YQCount; i++) {
+        if (document.querySelectorAll('.layui-tab-title>li')[i].innerText.trim() != '') {
+            var id = ".layui-tab-title>li"
+            var data = document.querySelectorAll('.layui-tab-title>li')[i].innerText.trim();
+            var type = "class";
+            DataList += id + "|" + data + "|" + type + ","
+        }
+    }
+
+    //琛ㄦ牸鍒楁爣绛剧殑鏁版嵁鑾峰彇 閫氳繃class
+    var ColCount = document.querySelectorAll('.layui-table tr span').length
+    for (var i = 0; i < ColCount; i++) {
+        if (document.querySelectorAll('.layui-table tr span')[i].innerText.trim() != '') {
+            var id = ".layui-table tr span"
+            var data = document.querySelectorAll('.layui-table tr span')[i].innerText.trim();
+            var type = "class";
+            DataList += id + "|" + data + "|" + type + ","
+        }
+    }
+
+    //鎵�鏈夐〉闈� 涓嬫媺妗嗙殑鎵�鏈夊��  閫氳繃class
+    var ModelCount = document.querySelectorAll('select option').length
+    for (var i = 0; i < ModelCount; i++) {
+        if (document.querySelectorAll('select option')[i].innerText.trim() != '') {
+            var id = "select option"
+            var data = document.querySelectorAll('select option')[i].innerText.trim();
+            var type = "class";
+            DataList += id + "|" + data + "|" + type + ","
+        }
+    }
+
+
+    ////鑾峰彇椤甸潰椤电鐨勬爣绛� 鑾峰彇鏁版嵁 閫氳繃 class
+    //var YMBQCount = document.querySelectorAll('.layui-tab-title li span').length
+    //for (var i = 0; i < YMBQCount; i++) {
+    //    if (document.querySelectorAll('.layui-tab-title li span')[i].innerText.trim() != '') {
+    //        var id = ".layui-tab-title li span"
+    //        var data = document.querySelectorAll('.layui-tab-title li span')[i].innerText.trim();
+    //        var type = "class";
+    //        DataList += id + "|" + data + "|" + type + ","
+    //    }
+    //}
+
+    return DataList;
+}
+
+
+//鏌ヨ褰撳墠椤甸潰鐨勬暟鎹�
+function Select(InitiaType,HModName, HLanguageType) {
+    var sWhere = " and HModuleCode in('" + HModName + "','GYModel') ";
+    //1  涓枃   2  鑻辫  3 瑗跨彮鐗欒
+    if (HLanguageType == "1") {
+        return false;
+    } 
+
+    $.ajax({
+        url: GetWEBURlLanguage() + '/Xt_grdAlignment_WMES/SelectMESLanguage',
+        type: "GET",
+        async: false,
+        data: { "sWhere": sWhere},
+        success: function (data1) {
+            if (data1.data.length > data1.count) {
+                get_WriteConfigFile(HModName, data1.data);
+                //var data=
+                ClickFunction(InitiaType, HModName, HLanguageType);
+
+            } else {
+                //淇濆瓨褰撳墠椤甸潰鐨勬暟鎹�
+                Save(HModName);
+            }
+        }, error: function () {
+            layer.alert("鎺ュ彛璇锋眰澶辫触!", { icon: 5 });
+        }
+    })
+}
+
+
+
+//淇濆瓨褰撳墠椤甸潰鐨勬暟鎹�
+function Save(HModName) {
+    var DataList = SelectData();
+    DataList = DataList.substring(0, DataList.length - 1);
+    DataList += ";"+HModName;
+    $.ajax({
+        url: GetWEBURlLanguage() + '/Xt_grdAlignment_WMES/SaveMESLanguage',
+        type: "Post",
+        async: false,
+        data: { "sMainSub": DataList},
+        success: function (data1) {
+            if (data1.count != 0) {
+
+            } else {
+
+            }
+        }, error: function () {
+            layer.alert("鎺ュ彛璇锋眰澶辫触!", { icon: 5 });
+        }
+    })
+}
+
+//瀛樺偍閰嶇疆鏂囦欢
+function get_WriteConfigFile(HModName, SqlDataList) {
+    //娓呯┖鏈湴瀛樺偍鐨勬暟鎹�
+    localStorage.removeItem(HModName);
+    var data = [];
+    for (var i = 0; i < SqlDataList.length; i++) {
+        var HFieldCode = SqlDataList[i].HFieldCode;
+        var HFieldName = SqlDataList[i].HFieldName;
+        var HFieldModelType = SqlDataList[i].HFieldModelType;
+        var HTranslationText_English = SqlDataList[i].HTranslationText_English;
+        var HTranslationText_Spain = SqlDataList[i].HTranslationText_Spain;
+
+        data.push({ HFieldCode: HFieldCode, HFieldName: HFieldName, HFieldModelType: HFieldModelType, HTranslationText_English: HTranslationText_English, HTranslationText_Spain: HTranslationText_Spain })
+    }
+
+    //鏈湴瀛樺偍
+    localStorage.setItem(HModName, JSON.stringify(data));
+}
+
+//璇诲彇閰嶇疆鏂囦欢
+function get_ReadConfigFile(InitiaType,HModName, HLanguageType) {
+    //鑾峰彇鏈湴瀛樺偍鐨勬暟鎹�
+    var data = localStorage.getItem(HModName);
+    if (data == null) {
+        Select(InitiaType,HModName, HLanguageType);
+    } else {
+        ClickFunction(InitiaType,HModName,HLanguageType);
+    }
+}
+
+//鎶ラ敊淇℃伅 閫氳繃浠g爜鏌ヨ
+//ErrorCode  鎶ラ敊淇℃伅
+//HLanguageType  缈昏瘧绫诲瀷
+function get_MessageError(ErrorCode, HLanguageType) {
+    var result = "";
+    var Message = "";
+
+    const match = ErrorCode.match(/\[(.*?)\]/);
+    if (match) {
+        result= match[1];  
+    }
+    if (result == "") {
+        return ErrorCode;
+    }
+   
+    $.ajax({
+        url: GetWEBURlLanguage() + '/Xt_grdAlignment_WMES/SelectMessageError',
+        type: "get",
+        async: false,
+        data: { "ErrorCode": result },
+        success: function (data1) {
+          
+            if (data1.count != 0) {
+                if (HLanguageType == 1) {
+                    Message = data1.data[0].HErrorName;
+                } else if (HLanguageType == 2) {
+                    Message = data1.data[0].HTranslationText_English;
+                } else if (HLanguageType == 3) {
+                    Message = data1.data[0].HTranslationText_Spain;
+                }  
+            }
+        }, error: function () {
+            layer.alert("鎺ュ彛璇锋眰澶辫触!", { icon: 5 });
+        }
+    })
+    return Message;
+}
+

--
Gitblit v1.9.1