From 8e943b7104561c3b14cf223016698709c5ade4b5 Mon Sep 17 00:00:00 2001
From: lty <876263681@qq.com>
Date: 星期二, 03 二月 2026 15:37:26 +0800
Subject: [PATCH] #pda料箱组托和换码

---
 src/main/webapp/static/js/mat/mat.js |  163 +++++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 123 insertions(+), 40 deletions(-)

diff --git a/src/main/webapp/static/js/mat/mat.js b/src/main/webapp/static/js/mat/mat.js
index ecf879f..f6769ab 100644
--- a/src/main/webapp/static/js/mat/mat.js
+++ b/src/main/webapp/static/js/mat/mat.js
@@ -1,14 +1,28 @@
 var pageCurr;
 var printMatCodeNos = [];
 var admin;
+
+// Local translation helper
+function t(key, params) {
+    if (typeof I18n !== 'undefined' && typeof I18n.t === 'function') {
+        return I18n.t(key, params);
+    }
+    return key;
+}
+
 function getCol() {
     var cols = [
         {type: 'checkbox'}
-        ,{field: 'tagId$', align: 'center',title: '褰掔被', templet: '#tagTpl'}
+        ,{field: 'tagId$', align: 'center',title: t('classification'), templet: '#tagTpl'}
+        // ,{field: 'store_max', align: 'center',title: t('stock_upper_limit')}
+        // ,{field: 'store_min', align: 'center',title: t('stock_lower_limit')}
+        // ,{field: 'store_max_date', align: 'center',title: t('stock_age_upper_limit_days')}
+        ,{field: 'areaId$', align: 'center',title: t('area'), templet: '#areaTpl'}
+
     ];
-    cols.push.apply(cols, matCols);
+    cols.push.apply(cols, getMatCols());
     cols.push(
-        {fixed: 'right', title:'鎿嶄綔', align: 'center', toolbar: '#operate', width:150}
+        {fixed: 'right', title: t('operation'), align: 'center', toolbar: '#operate', width:150}
     )
     return cols;
 }
@@ -26,6 +40,31 @@
     admin = layui.admin;
     var treeTable = layui.treeTable;
     var xmSelect = layui.xmSelect;
+
+    // 鍖哄煙鏁版嵁
+    var areaData = [];
+    
+    // 鍔犺浇鍖哄煙鏁版嵁
+    $.ajax({
+        url: baseUrl+'/area/list/auth',
+        headers: {token: localStorage.getItem('token')},
+        method: 'GET',
+        async: false,
+        success: function (res) {
+            if (res.code === 200 && res.data && res.data.records) {
+                // 杩囨护鎺夌┖鍊�
+                areaData = res.data.records.filter(function(item) {
+                    return item != null && item.areaId != null;
+                });
+                console.log('鍖哄煙鏁版嵁鍔犺浇鎴愬姛:', areaData);
+            } else {
+                console.error('鍖哄煙鏁版嵁鍔犺浇澶辫触:', res);
+            }
+        },
+        error: function(err) {
+            console.error('鍖哄煙鏁版嵁璇锋眰澶辫触:', err);
+        }
+    });
 
     // 鍟嗗搧鍒嗙被鏁版嵁
     var insTb = treeTable.render({
@@ -46,6 +85,26 @@
     });
 
     // 鏁版嵁娓叉煋
+    var tableDone = function(res, curr, count) {
+        if (res.code === 403) {
+            top.location.href = baseUrl+"/";
+        }
+        pageCurr=curr;
+        limit();
+        form.on('checkbox(tableCheckbox)', function (data) {
+            var _index = $(data.elem).attr('table-index')||0;
+            if(data.elem.checked){
+                res.data[_index][data.value] = 'Y';
+            }else{
+                res.data[_index][data.value] = 'N';
+            }
+        });
+        if (typeof I18n !== 'undefined') {
+            I18n.updatePage();
+            I18n.updateLayuiPagination();
+        }
+    };
+
     tableIns = table.render({
         elem: '#mat',
         headers: {token: localStorage.getItem('token')},
@@ -72,21 +131,7 @@
         response: {
             statusCode: 200
         },
-        done: function(res, curr, count) {
-            if (res.code === 403) {
-                top.location.href = baseUrl+"/";
-            }
-            pageCurr=curr;
-            limit();
-            form.on('checkbox(tableCheckbox)', function (data) {
-                var _index = $(data.elem).attr('table-index')||0;
-                if(data.elem.checked){
-                    res.data[_index][data.value] = 'Y';
-                }else{
-                    res.data[_index][data.value] = 'N';
-                }
-            });
-        }
+        done: tableDone
     });
 
     // 鐩戝惉鎺掑簭浜嬩欢
@@ -102,13 +147,15 @@
             page: {
                 curr: 1
             },
-            done: function (res, curr, count) {
-                if (res.code === 403) {
-                    top.location.href = baseUrl+"/";
-                }
-                pageCurr=curr;
-                limit();
-            }
+            done: tableDone
+        });
+    });
+
+    // 鐩戝惉璇█鍒囨崲
+    $(document).on('i18n:languageChanged i18n:ready', function() {
+        tableIns.reload({
+            cols: [getCol()],
+            done: tableDone
         });
     });
 
@@ -122,9 +169,9 @@
             case 'deleteData':
                 var data = checkStatus.data;
                 if (data.length === 0){
-                    layer.msg('璇烽�夋嫨鏁版嵁');
+                    layer.msg(I18n.t('please_select_data'));
                 } else {
-                    layer.confirm('纭畾鍒犻櫎'+(data.length===1?'姝�':data.length)+'鏉℃暟鎹悧', function(){
+                    layer.confirm(I18n.t('confirm_delete_prefix') + (data.length===1?I18n.t('this'):data.length) + I18n.t('confirm_delete_suffix'), function(){
                         $.ajax({
                             url: baseUrl+"/mat/delete/auth",
                             headers: {'token': localStorage.getItem('token')},
@@ -138,7 +185,7 @@
                                 } else if (res.code === 403){
                                     top.location.href = baseUrl+"/";
                                 } else {
-                                    layer.msg(res.msg)
+                                    layer.msg(typeof I18n !== 'undefined' ? I18n.t(res.msg) : res.msg, {icon: 2})
                                 }
                             }
                         })
@@ -146,7 +193,7 @@
                 }
                 break;
             case 'exportData':
-                layer.confirm('纭畾瀵煎嚭Excel鍚�', {shadeClose: true}, function(){
+                layer.confirm(I18n.t('confirm_export_excel'), {shadeClose: true}, function(){
                     var titles=[];
                     var fields=[];
                     obj.config.cols[0].map(function (col) {
@@ -177,7 +224,7 @@
                             } else if (res.code === 403) {
                                 top.location.href = baseUrl+"/";
                             } else {
-                                layer.msg(res.msg)
+                                layer.msg(typeof I18n !== 'undefined' ? I18n.t(res.msg) : res.msg, {icon: 2})
                             }
                         }
                     });
@@ -188,11 +235,11 @@
                 printMatCodeNos = [];
                 var data = checkStatus.data;
                 if (data.length === 0){
-                    layer.msg('璇烽�夋嫨鎵撳嵃鏁版嵁');
+                    layer.msg(I18n.t('please_select_print_data'));
                 } else {
                     layer.open({
                         type: 1,
-                        title: '鎵归噺鎵撳嵃 [鏁伴噺'+ data.length +']',
+                        title: I18n.t('batch_print_count', {count: data.length}),
                         area: ['500px'],
                         shadeClose: true,
                         content: $('#printDataDiv'),
@@ -218,13 +265,17 @@
                 printMatCodeNos = [];
                 layer.open({
                     type: 1,
-                    title: data.matnr + ' [鏁伴噺锛�1]',
+                    title: data.matnr + ' [' + I18n.t('count') + '锛�1]',
                     area: ['500px'],
                     shadeClose: true,
                     content: $('#printDataDiv'),
                     success: function(layero, index){
                         layer.iframeAuto(index);
                         printMatCodeNos.push(data.matnr);
+                        if (typeof I18n !== 'undefined' && I18n.updatePage) {
+                            I18n.updatePage($(layero));
+                            form.render();
+                        }
                     },
                     end: function () {
                     }
@@ -242,7 +293,7 @@
         admin.open({
             type: 1,
             area: '600px',
-            title: (mData ? '淇敼' : '娣诲姞') + '鍟嗗搧',
+            title: (mData ? I18n.t('edit') : I18n.t('add')) + I18n.t('material'),
             content: $('#editDialog').html(),
             success: function (layero, dIndex) {
                 // 鍥炴樉琛ㄥ崟鏁版嵁
@@ -250,14 +301,23 @@
                 // 鏂板鑷姩鐢熸垚鍟嗗搧缂栧彿
                 if (!mData) {
                     http.get(baseUrl + "/mat/auto/matnr/auth", null, function (res) {
-                        $('#matnr').val(res.data);
+                        $(layero).find('#matnr').val(res.data);
                     })
                 }
+                
+                if (typeof I18n !== 'undefined') {
+                    setTimeout(function() {
+                        I18n.updatePage($(layero));
+                    }, 50);
+                }
+
                 // 琛ㄥ崟鎻愪氦浜嬩欢
                 form.on('submit(editSubmit)', function (data) {
+                    console.log(data)
                     data.field.tagId = insXmSel.getValue('valueStr');
+                    data.field.areaId = areaXmSel.getValue('valueStr');
                     if (isEmpty(data.field.tagId)) {
-                        layer.msg('鍒嗙被涓嶈兘涓虹┖', {icon: 2});
+                        layer.msg(I18n.t('category_cannot_be_empty'), {icon: 2});
                         return false;
                     }
                     var loadIndex = layer.load(2);
@@ -270,7 +330,7 @@
                             layer.close(loadIndex);
                             if (res.code === 200){
                                 layer.close(dIndex);
-                                layer.msg(res.msg, {icon: 1});
+                                layer.msg(t('response.operation_success'), {icon: 1});
                                 $(".layui-laypage-btn")[0].click();
                             } else if (res.code === 403){
                                 top.location.href = baseUrl+"/";
@@ -283,7 +343,7 @@
                 });
                 // 娓叉煋涓嬫媺鏍�
                 var insXmSel = xmSelect.render({
-                    el: '#tagSel',
+                    el: $(layero).find('#tagSel')[0],
                     height: '250px',
                     data: insTb.options.data,
                     initValue: mData ? [mData.tagId] : [],
@@ -299,6 +359,22 @@
                         indent: 15,
                         strict: false,
                         expandedKeys: true
+                    }
+                });
+                // 娓叉煋鍖哄煙涓嬫媺閫夋嫨
+                var areaXmSel = xmSelect.render({
+                    el: $(layero).find('#areaSel')[0],
+                    height: '250px',
+                    data: areaData.length > 0 ? areaData : [],
+                    initValue: mData && mData.areaId ? [mData.areaId] : [],
+                    model: {label: {type: 'text'}},
+                    prop: {
+                        name: 'areaName',
+                        value: 'areaId'
+                    },
+                    radio: true,
+                    clickClose: true,
+                    on: function(data) {
                     }
                 });
                 // 寮圭獥涓嶅嚭鐜版粴鍔ㄦ潯
@@ -340,12 +416,15 @@
                     var html = template(res);
                     var box = $("#box");
                     box.html(html);box.show();
+                    if (typeof I18n !== 'undefined' && I18n.updatePage) {
+                        I18n.updatePage(box[0]);
+                    }
                     box.print({mediaPrint:true});
                     box.hide();
                 } else if (res.code === 403){
                     top.location.href = baseUrl+"/";
                 }else {
-                    layer.msg(res.msg)
+                    layer.msg(typeof I18n !== 'undefined' ? I18n.t(res.msg) : res.msg, {icon: 2})
                 }
             }
         })
@@ -393,7 +472,7 @@
         return;
     }
     var file = obj.files[0];
-    admin.confirm('纭鍚屾 [' + file.name +'] 鏂囦欢鍚楋紵', function (index) {
+    admin.confirm(I18n.t('confirm_sync_file', {filename: file.name}), function (index) {
         layer.load(1, {shade: [0.1,'#fff']});
         var url = baseUrl + "/mat/excel/import/auth";
         var form = new FormData();
@@ -462,6 +541,10 @@
                 pageCurr -= 1;
             }
             limit(child);
+            if (typeof I18n !== 'undefined') {
+                I18n.updatePage();
+                I18n.updateLayuiPagination();
+            }
         }
     });
 }

--
Gitblit v1.9.1