From dcd7fcf596005d0c7cf66558bee97edf6c3b03a0 Mon Sep 17 00:00:00 2001
From: wang..123 <brook_w@163.com>
Date: 星期四, 10 三月 2022 18:12:09 +0800
Subject: [PATCH] #物料状态维护

---
 src/main/webapp/static/js/locNormal/locNormal.js |  233 +++++++++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 199 insertions(+), 34 deletions(-)

diff --git a/src/main/webapp/static/js/locNormal/locNormal.js b/src/main/webapp/static/js/locNormal/locNormal.js
index 0fc0998..6746562 100644
--- a/src/main/webapp/static/js/locNormal/locNormal.js
+++ b/src/main/webapp/static/js/locNormal/locNormal.js
@@ -1,14 +1,18 @@
 var pageCurr;
 var locNormalList = [];
+var locArea = [];
 
 function getCol() {
     var cols = [];
     cols.push(
+        {type: 'checkbox', fixed: 'left'},
         {field: 'anfme', align: 'center', title: '鏁伴噺', sort: true, edit: 'text'}
     )
     cols.push.apply(cols, locNormalCols);
     cols.push(
-        {field: 'state', align: 'center', title: '鍑哄叆搴撶姸鎬�', templet: '#locNormalState'}
+        {field: 'warehouse$', align: 'center', title: '搴撳尯'}
+        , {field: 'state$', align: 'center', title: '鍑哄叆搴撶姸鎬�', templet: '#locNormalState'}
+        ,{field: 'matStatus', align: 'center',title: '鐗╂枡鐘舵��', width: 100, templet: '#matStatus'}
         , {field: 'modiUser$', align: 'center', title: '淇敼浜哄憳', hide: true}
         , {field: 'modiTime$', align: 'center', title: '淇敼鏃堕棿', hide: true}
         , {field: 'appeTime$', align: 'center', title: '鍒涘缓鏃堕棿', hide: true}
@@ -17,6 +21,7 @@
     return cols;
 }
 
+
 layui.use(['table', 'laydate', 'form', 'upload'], function () {
     var table = layui.table;
     var $ = layui.jquery;
@@ -24,6 +29,31 @@
     var layDate = layui.laydate;
     var form = layui.form;
     var upload = layui.upload;
+
+    // 搴撳尯涓嬫媺
+    // 鑾峰彇浠撳簱涓嬫媺
+    $.ajax({
+        url: baseUrl + "/locArea/query/allArea",
+        headers: {'token': localStorage.getItem('token')},
+        method: 'POST',
+        success: function (res) {
+            if (res.code === 200) {
+                var html = "";
+                if (res.data && res.data.length > 0) {
+                    locArea = res.data;
+                    html += res.data.map(function (item) {
+                        return "<Option value=" + item.uuid + ">" + item.name + "</Option>";
+                    });
+                }
+                $('#putSiteSelect').append(html);
+                layui.form.render('select');
+            } else if (res.code === 403) {
+                top.location.href = baseUrl + "/";
+            } else {
+                layer.msg(res.msg)
+            }
+        }
+    });
 
     // 瀵煎叆excel
     var uploader = upload.render({
@@ -34,14 +64,14 @@
         , exts: 'xls|excel|xlsx'
         , auto: false
         , bindAction: '#uploadDo'
-        , before: function(obj){
+        , before: function (obj) {
             layer.closeAll();
-            layer.load(1, {shade: [0.1,'#fff']});
+            layer.load(1, {shade: [0.1, '#fff']});
         }
-        , choose: function(obj){
+        , choose: function (obj) {
             $('#uploadDesc').hide();
             $('#uploadDemoView').show();
-            obj.preview(function(index, file, result){
+            obj.preview(function (index, file, result) {
                 $('#fileMame').html(file.name);
             });
         }
@@ -54,15 +84,14 @@
             layer.msg(res.msg);
             tableReload(false);
         }
-        , error: function(index, upload){
+        , error: function (index, upload) {
             layer.closeAll('loading');
         }
     });
 
     /* 瀵煎叆 */
     table.on('toolbar(locNormal)', function (obj) {
-        debugger
-        switch(obj.event) {
+        switch (obj.event) {
             // 瀵煎叆
             case 'intoData':
                 layer.open({
@@ -70,7 +99,7 @@
                     title: '鏁版嵁瀵煎叆',
                     shadeClose: true,
                     content: $('#importDataDiv'),
-                    success: function(layero, index){
+                    success: function (layero, index) {
                         uploader.reload();
                     },
                     end: function () {
@@ -78,6 +107,45 @@
                         $('#uploadDemoView').hide();
                         $('#fileMame').html("");
                     }
+                });
+                break;
+            // 瀵煎嚭
+            case 'exportData':
+                layer.confirm('纭畾瀵煎嚭Excel鍚�', {shadeClose: true}, function(){
+                    var fields=[];
+                    var titles=[];
+                    var exportData = {};
+                    obj.config.cols[0].map(function (col) {
+                        if (col.type === 'normal' && col.hide === false && col.toolbar == null) {
+                            titles.push(col.title);
+                            fields.push(col.field);
+                        }
+                    });
+                    $.each($('#search-box [name]').serializeArray(), function() {
+                        exportData[this.name] = this.value;
+                    });
+                    var param = {
+                        'exportData': exportData,
+                        'fields': fields
+                    };
+                    $.ajax({
+                        url: baseUrl+"/locNormal/export/auth",
+                        headers: {'token': localStorage.getItem('token')},
+                        data: JSON.stringify(param),
+                        dataType:'json',
+                        contentType:'application/json;charset=UTF-8',
+                        method: 'POST',
+                        success: function (res) {
+                            layer.closeAll();
+                            if (res.code === 200) {
+                                table.exportFile(titles,res.data,'xls');
+                            } else if (res.code === 403) {
+                                top.location.href = baseUrl+"/";
+                            } else {
+                                layer.msg(res.msg)
+                            }
+                        }
+                    });
                 });
                 break;
         }
@@ -105,13 +173,14 @@
                 'code': res.code,
                 'msg': res.msg,
                 'count': res.data.total,
-                'data': res.data.records
+                'data': res.data.records,
             }
         },
         response: {
             statusCode: 200
         },
         done: function (res, curr, count) {
+            console.log(res);
             if (res.code === 403) {
                 top.location.href = baseUrl + "/";
             }
@@ -151,6 +220,7 @@
     table.on('edit(locNormal)', function (obj) {
         var count = obj.value;
         var matnr = obj.data.matnr;
+        var id = obj.data.id;
 
         if (isNaN(count)) {
             layer.msg("璇疯緭鍏ユ暟瀛�");
@@ -175,14 +245,27 @@
         const param = {
             matnr: matnr,
             anfme: count,
+            id: id,
+            warehouse: obj.data.warehouse,
+            supplier: obj.data.supplier,
+            mnemonic: obj.data.mnemonic,
         }
-        $.ajax({
-            url: baseUrl + "/locNormal/update/auth",
-            headers: {'token': localStorage.getItem('token')},
-            data: top.reObject(param),
-            method: 'POST',
-            success: function (res) {
-            },
+        layer.confirm("纭畾淇敼" + obj.data.maktx + "鐨勬暟閲忓悧", {
+            btn: ['纭畾', '鍙栨秷']
+        }, function () {
+            // 鎸夐挳1鐨勪簨浠�
+            $.ajax({
+                url: baseUrl + "/locNormal/update/auth",
+                headers: {'token': localStorage.getItem('token')},
+                data: top.reObject(param),
+                method: 'POST',
+                success: function (res) {
+                    layer.msg("淇敼鎴愬姛");
+                },
+            });
+        }, function () {
+            // 鎸夐挳2鐨勪簨浠�
+            tableIns.reload();
         });
     });
 
@@ -204,30 +287,54 @@
         var data = obj.data;
         var param = {
             matnr: data.matnr,
+            id: data.id,
         }
         switch (obj.event) {
             case 'outLocNormal':
-                // 鍑哄簱
-                $.ajax({
-                    url: baseUrl + "/locNormal/outLoc/auth",
-                    headers: {'token': localStorage.getItem('token')},
-                    data: top.reObject(param),
-                    method: 'POST',
-                    success: function (res) {
-                        tableReload(false);
-                    },
+                var warehourse = data.warehouse;
+                if(warehourse !== 'cs'){
+                    layer.msg("鍙兘鍑烘潗鏂欏钩浠�");
+                    return;
+                }
+
+                layer.confirm('纭畾瑕佸嚭搴揫' + data.matnr + ']鍚楋紵', {
+                    btn: ['纭畾', '鍙栨秷'] //鍙互鏃犻檺涓寜閽�
+                }, function (index, layero) {
+                    //纭畾鍥炶皟-鍑哄簱
+                    $.ajax({
+                        url: baseUrl + "/locNormal/outLoc/auth",
+                        headers: {'token': localStorage.getItem('token')},
+                        data: top.reObject(param),
+                        method: 'POST',
+                        success: function (res) {
+                            tableReload(false);
+                            layer.closeAll();
+                            layer.msg("鍑哄簱鎴愬姛");
+                        },
+                    });
+                }, function (index) {
+                    //鎸夐挳銆愭寜閽簩銆戠殑鍥炶皟
                 });
                 break;
             case 'removeLocNormal':
                 // 绉婚櫎
-                $.ajax({
-                    url: baseUrl + "/locNormal/removeLoc/auth",
-                    headers: {'token': localStorage.getItem('token')},
-                    data: top.reObject(param),
-                    method: 'POST',
-                    success: function (res) {
-                        tableReload(false);
-                    },
+                layer.confirm('纭畾瑕佺Щ闄' + data.matnr + ']鍚楋紵', {
+                    btn: ['纭畾', '鍙栨秷'] //鍙互鏃犻檺涓寜閽�
+                }, function (index, layero) {
+                    //纭畾鍥炶皟-绉婚櫎
+                    $.ajax({
+                        url: baseUrl + "/locNormal/removeLoc/auth",
+                        headers: {'token': localStorage.getItem('token')},
+                        data: top.reObject(param),
+                        method: 'POST',
+                        success: function (res) {
+                            tableReload(false);
+                            layer.closeAll();
+                            layer.msg("绉婚櫎鎴愬姛");
+                        },
+                    });
+                }, function (index) {
+                    //鎸夐挳銆愭寜閽簩銆戠殑鍥炶皟
                 });
                 break;
         }
@@ -291,4 +398,62 @@
     });
 }
 
+var matStatusConfirm;
+function showMatStatus1() {
+    var layer = layui.layer;
+    var table = layui.table;
+    // 鑾峰彇閫変腑琛�
+    var checkStatus = table.checkStatus('locNormal');
+    // 閫夋嫨琛屾暟鎹�
+    var checkData = checkStatus.data;
+    if (checkData.length == 0) {
+        layer.msg("璇烽�夋嫨鏁版嵁");
+        return;
+    }
+    matStatusConfirm = layer.open({
+        type: 2,
+        title: '閫夋嫨鐗╂枡鐘舵��',
+        area: ['300px', '175px'],
+        content: '../pakStore/matStatus.html',
+        btn: ['纭畾'],
+        success: function (layero, index) {
+            // 鎴愬姛鎵撳紑寮圭獥
+            // tableReload(false);
+        },
+        yes: function (index, layero) {
+            // 瀛愰〉闈�
+            var matStatus = layero.find('iframe')[0].contentDocument;
+            // 瀛愰〉闈㈤�夋嫨鏁版嵁鐩戞帶
+            var forms = matStatus.forms;
+            var cho = forms[0][0].value;
+            // 鍏ュ弬鎷兼帴
+            if (checkData && checkData.length > 0) {
+                checkData.map(function (item) {
+                    item.matStatus = cho;
+                });
+            }
+            param = {
+                list: checkData,
+            };
+            // 鏇存柊鐗╂枡鐘舵��
+            console.log('閫夋嫨鏁版嵁', checkData);
+            $.ajax({
+                url: baseUrl+"/locNormal/getAllLocDetlData",
+                headers: {'token': localStorage.getItem('token')},
+                data: JSON.stringify(param),
+                dataType:'json',
+                contentType:'application/json;charset=UTF-8',
+                method: 'POST',
+                success: function (res) {
+                    console.log('杩斿洖鍊�', res);
+                    // 鍏抽棴寮圭獥
+                    layer.close(index);
+                    // 琛ㄦ牸鏁版嵁閲嶇疆
+                    tableReload(false);
+                }
+            });
+        }
+    });
+}
+
 

--
Gitblit v1.9.1