From 82e3d32282cd6bc07e36564306fe5c35fdfb89da Mon Sep 17 00:00:00 2001
From: ZY <zc857179121@qq.com>
Date: 星期一, 23 九月 2024 17:16:32 +0800
Subject: [PATCH] bug修改,初步完成

---
 zy-asrs-wms/src/main/webapp/static/js/safeSto/safeSto.js |  150 ++++++++++++++++++++++++++++++++++---------------
 1 files changed, 104 insertions(+), 46 deletions(-)

diff --git a/zy-asrs-wms/src/main/webapp/static/js/safeSto/safeSto.js b/zy-asrs-wms/src/main/webapp/static/js/safeSto/safeSto.js
index 6be70a5..bad03ce 100644
--- a/zy-asrs-wms/src/main/webapp/static/js/safeSto/safeSto.js
+++ b/zy-asrs-wms/src/main/webapp/static/js/safeSto/safeSto.js
@@ -1,21 +1,23 @@
 var pageCurr;
+var admin;
 layui.config({
     base: baseUrl + "/static/layui/lay/modules/"
-}).use(['table','laydate', 'form', 'element', 'admin', 'xmSelect'], function(){
+}).use(['table', 'laydate', 'form', 'element', 'admin', 'xmSelect'], function () {
     var table = layui.table;
     var $ = layui.jquery;
     var layer = layui.layer;
     var layDate = layui.laydate;
     var form = layui.form;
     var element = layui.element;
-    var admin = layui.admin;
+    admin = layui.admin;
     var xmSelect = layui.xmSelect;
+
 
     // 鏁版嵁娓叉煋
     tableIns = table.render({
         elem: '#safeSto',
         headers: {token: localStorage.getItem('token')},
-        url: baseUrl+'/safeSto/list/auth',
+        url: baseUrl + '/safeSto/list/auth',
         page: true,
         limit: 16,
         limits: [16, 30, 50, 100, 200, 500],
@@ -23,14 +25,14 @@
         cellMinWidth: 50,
         cols: [[
             {type: 'numbers', fixed: 'left'}
-            ,{field: 'locNo$', align: 'center',title: '搴撲綅'}
-            ,{field: 'matnr', align: 'center',title: '鍝佸彿'}
-            ,{field: 'maktx', align: 'center',title: '鍚嶇О'}
-            ,{field: 'progress', align: 'center',title: '浣跨敤鎯呭喌', templet: '#progressTpl', width: 350}
-            ,{field: 'status', align: 'center',title: '璀︽姤', templet: '#statusTpl', width: 100}
-            ,{field: 'safeQua', align: 'center',title: '瀹夊叏搴撳瓨閲�', style: 'font-weight: bold'}
-            ,{field: 'amount', align: 'center',title: '褰撳墠搴撳瓨閲�', style: 'font-weight: bold; color: #2d8cf0'}
-            ,{fixed: 'right', title:'鎿嶄綔', align: 'center', toolbar: '#operate', width:120}
+            , {field: 'locNo$', align: 'center', title: '搴撲綅'}
+            , {field: 'matnr', align: 'center', title: '鍝佸彿'}
+            , {field: 'maktx', align: 'center', title: '鍚嶇О'}
+            , {field: 'progress', align: 'center', title: '浣跨敤鎯呭喌', templet: '#progressTpl', width: 350}
+            , {field: 'status', align: 'center', title: '璀︽姤', templet: '#statusTpl', width: 100}
+            , {field: 'safeQua', align: 'center', title: '瀹夊叏搴撳瓨閲�', style: 'font-weight: bold'}
+            , {field: 'amount', align: 'center', title: '褰撳墠搴撳瓨閲�', style: 'font-weight: bold; color: #2d8cf0'}
+            , {fixed: 'right', title: '鎿嶄綔', align: 'center', toolbar: '#operate', width: 120}
         ]],
         request: {
             pageName: 'curr',
@@ -47,12 +49,12 @@
         response: {
             statusCode: 200
         },
-        done: function(res, curr, count) {
+        done: function (res, curr, count) {
             if (res.code === 403) {
-                top.location.href = baseUrl+"/";
+                top.location.href = baseUrl + "/";
             }
             element.render('progress')
-            pageCurr=curr;
+            pageCurr = curr;
             limit();
         }
     });
@@ -61,13 +63,13 @@
     // 鐩戝惉澶村伐鍏锋爮浜嬩欢
     table.on('toolbar(safeSto)', function (obj) {
         var checkStatus = table.checkStatus(obj.config.id);
-        switch(obj.event) {
+        switch (obj.event) {
             case 'add':
                 showEditModel();
                 break;
             case 'exportData':
-                layer.confirm('纭畾瀵煎嚭Excel鍚�', {shadeClose: true}, function(){
-                    window.location.href = baseUrl + '/safeSto/excel/export/auth?token='+localStorage.getItem('token');
+                layer.confirm('纭畾瀵煎嚭Excel鍚�', {shadeClose: true}, function () {
+                    window.location.href = baseUrl + '/safeSto/excel/export/auth?token=' + localStorage.getItem('token');
                     layer.closeAll();
                 });
                 break;
@@ -75,7 +77,7 @@
     });
 
     // 鐩戝惉琛屽伐鍏蜂簨浠�
-    table.on('tool(safeSto)', function(obj){
+    table.on('tool(safeSto)', function (obj) {
         var data = obj.data;
         switch (obj.event) {
             // 淇敼
@@ -94,26 +96,26 @@
                 break;
             // 琛ヤ粨
             case 'allot':
-                layer.confirm(data.node_name +'琛ヤ粨 '+ data.matnr + '锛屾暟閲忥細' + (data.safe_qua - data.amount), function(){
-                    var index = layer.load(1, {shade: [0.1,'#000']});
+                layer.confirm(data.node_name + '琛ヤ粨 ' + data.matnr + '锛屾暟閲忥細' + (data.safe_qua - data.amount), function () {
+                    var index = layer.load(1, {shade: [0.1, '#000']});
                     $.ajax({
-                        url: baseUrl+"/work/stock/transfer",
+                        url: baseUrl + "/work/stock/transfer",
                         headers: {'token': localStorage.getItem('token')},
-                        contentType:'application/json;charset=UTF-8',
+                        contentType: 'application/json;charset=UTF-8',
                         data: JSON.stringify({
                             node_id: data.node_id,
                             matnr: data.matnr,
                             safe_qua: data.safe_qua,
                             amount: data.amount
                         }),
-                        dataType:'json',
+                        dataType: 'json',
                         method: 'POST',
                         success: function (res) {
                             if (res.code === 200) {
                                 layer.msg(res.msg, {icon: 1})
                                 $(".layui-laypage-btn")[0].click();
                             } else if (res.code === 403) {
-                                top.location.href = baseUrl+"/";
+                                top.location.href = baseUrl + "/";
                             } else {
                                 layer.msg(res.msg, {icon: 2})
                             }
@@ -141,20 +143,20 @@
                     data.field.matId = matXmSelect.getValue()[0] ? matXmSelect.getValue()[0].value : null;
                     var loadIndex = layer.load(2);
                     $.ajax({
-                        url: baseUrl+"/safeSto/"+(mData?'update':'add')+"/auth",
+                        url: baseUrl + "/safeSto/" + (mData ? 'update' : 'add') + "/auth",
                         headers: {'token': localStorage.getItem('token')},
                         data: JSON.stringify(data.field),
-                        contentType:'application/json;charset=UTF-8',
+                        contentType: 'application/json;charset=UTF-8',
                         method: 'POST',
                         success: function (res) {
                             layer.close(loadIndex);
-                            if (res.code === 200){
+                            if (res.code === 200) {
                                 layer.close(dIndex);
                                 layer.msg(res.msg, {icon: 1});
                                 tableReload();
-                            } else if (res.code === 403){
-                                top.location.href = baseUrl+"/";
-                            }else {
+                            } else if (res.code === 403) {
+                                top.location.href = baseUrl + "/";
+                            } else {
                                 layer.msg(res.msg, {icon: 2});
                             }
                         }
@@ -166,23 +168,23 @@
                     el: '#locNo',
                     radio: true,
                     autoRow: true,
-                    toolbar: { show: true },
+                    toolbar: {show: true},
                     filterable: true,
                     remoteSearch: true,
-                    remoteMethod: function(val, cb, show){
+                    remoteMethod: function (val, cb, show) {
                         //杩欓噷濡傛灉val涓虹┖, 鍒欎笉瑙﹀彂鎼滅储
                         // if(!val){
                         //     return cb([]);
                         // }
                         $.ajax({
-                            url: baseUrl+"/locMast/all/get/kv",
+                            url: baseUrl + "/locMast/all/get/kv",
                             headers: {'token': localStorage.getItem('token')},
                             data: {
                                 condition: val
                             },
                             method: 'POST',
                             success: function (res) {
-                                if (res.code === 200){
+                                if (res.code === 200) {
                                     cb(res.data)
                                 } else {
                                     cb([]);
@@ -197,23 +199,23 @@
                     el: '#mat',
                     radio: true,
                     autoRow: true,
-                    toolbar: { show: true },
+                    toolbar: {show: true},
                     filterable: true,
                     remoteSearch: true,
-                    remoteMethod: function(val, cb, show){
+                    remoteMethod: function (val, cb, show) {
                         //杩欓噷濡傛灉val涓虹┖, 鍒欎笉瑙﹀彂鎼滅储
                         // if(!val){
                         //     return cb([]);
                         // }
                         $.ajax({
-                            url: baseUrl+"/mat/all/get/kv",
+                            url: baseUrl + "/mat/all/get/kv",
                             headers: {'token': localStorage.getItem('token')},
                             data: {
                                 condition: val
                             },
                             method: 'POST',
                             success: function (res) {
-                                if (res.code === 200){
+                                if (res.code === 200) {
                                     cb(res.data)
                                 } else {
                                     cb([]);
@@ -240,18 +242,18 @@
             layer.close(i);
             var loadIndex = layer.load(2);
             $.ajax({
-                url: baseUrl+"/safeSto/delete/auth",
+                url: baseUrl + "/safeSto/delete/auth",
                 headers: {'token': localStorage.getItem('token')},
                 data: JSON.stringify(params),
-                contentType:'application/json;charset=UTF-8',
+                contentType: 'application/json;charset=UTF-8',
                 method: 'POST',
                 success: function (res) {
                     layer.close(loadIndex);
-                    if (res.code === 200){
+                    if (res.code === 200) {
                         layer.msg(res.msg, {icon: 1});
                         $(".layui-laypage-btn")[0].click();
-                    } else if (res.code === 403){
-                        top.location.href = baseUrl+"/";
+                    } else if (res.code === 403) {
+                        top.location.href = baseUrl + "/";
                     } else {
                         layer.msg(res.msg, {icon: 2});
                     }
@@ -287,13 +289,13 @@
 });
 
 // 鍏抽棴鍔ㄤ綔
-$(document).on('click','#data-detail-close', function () {
+$(document).on('click', '#data-detail-close', function () {
     parent.layer.closeAll();
 });
 
 function tableReload() {
     var searchData = {};
-    $.each($('#search-box [name]').serializeArray(), function() {
+    $.each($('#search-box [name]').serializeArray(), function () {
         searchData[this.name] = this.value;
     });
     tableIns.reload({
@@ -305,9 +307,65 @@
 }
 
 
-
 $('body').keydown(function () {
     if (event.keyCode === 13) {
         $("#search").click();
     }
 });
+
+// excel瀵煎叆妯℃澘涓嬭浇
+function downloadData() {
+    layer.load(1, {shade: [0.1, '#fff']});
+    location.href = baseUrl + "/safeSto/excel/import/mould";
+    layer.closeAll('loading');
+}
+
+// excel瀵煎叆
+function importData() {
+    $("#btn-import").trigger("click");
+}
+
+function upload(obj) {
+    if (!obj.files) {
+        return;
+    }
+    var file = obj.files[0];
+    admin.confirm('纭鍚屾 [' + file.name + '] 鏂囦欢鍚楋紵', function (index) {
+        layer.load(1, {shade: [0.1, '#fff']});
+        var url = baseUrl + "/safeSto/excel/import/auth";
+        var form = new FormData();
+        form.append("file", file);
+        xhr = new XMLHttpRequest();
+        xhr.open("post", url, true); //post鏂瑰紡锛寀rl涓烘湇鍔″櫒璇锋眰鍦板潃锛宼rue 璇ュ弬鏁拌瀹氳姹傛槸鍚﹀紓姝ュ鐞嗐��
+        xhr.setRequestHeader('token', localStorage.getItem('token'));
+        xhr.onload = uploadComplete; //璇锋眰瀹屾垚
+        xhr.onerror = uploadFailed; //璇锋眰澶辫触
+        xhr.onloadend = function () { // // 涓婁紶瀹屾垚閲嶇疆鏂囦欢娴�
+            layer.closeAll('loading');
+            $("#importExcel").val("");
+        };
+        // xhr.upload.onprogress = progressFunction;//銆愪笂浼犺繘搴﹁皟鐢ㄦ柟娉曞疄鐜般��
+        xhr.upload.onloadstart = function () {//涓婁紶寮�濮嬫墽琛屾柟娉�
+            ot = new Date().getTime();   //璁剧疆涓婁紶寮�濮嬫椂闂�
+            oloaded = 0;//璁剧疆涓婁紶寮�濮嬫椂锛屼互涓婁紶鐨勬枃浠跺ぇ灏忎负0
+        };
+        xhr.send(form);
+    }, function (index) {
+        $("#btn-import").val("");
+    });
+}
+
+function uploadComplete(evt) {
+    var res = JSON.parse(evt.target.responseText);
+    if(res.code === 200) {
+        layer.msg(res.msg, {icon: 1});
+        loadTree("");
+    } else {
+        layer.msg(res.msg, {icon: 2});
+    }
+}
+
+function uploadFailed(evt) {
+    var res = JSON.parse(evt.target.responseText);
+    layer.msg(res.msg, {icon: 2});
+}

--
Gitblit v1.9.1