zwl
2025-07-09 958883d6f4dac68fcbbccadb4e7f87e963eee0e8
zy-asrs-wms/src/main/webapp/static/js/mat/mat.js
@@ -16,8 +16,8 @@
layui.config({
    base: baseUrl + "/static/layui/lay/modules/"
}).extend({
    dropdown: 'dropdown/dropdown',
}).use(['table','laydate', 'form', 'treeTable', 'admin', 'xmSelect', 'dropdown', 'element'], function(){
    dropdown: 'dropdown/dropdown',notice: 'notice/notice',
}).use(['table','laydate', 'form', 'treeTable','notice', 'admin', 'xmSelect', 'dropdown', 'element'], function(){
    var table = layui.table;
    var $ = layui.jquery;
    var layer = layui.layer;
@@ -26,7 +26,7 @@
    admin = layui.admin;
    var treeTable = layui.treeTable;
    var xmSelect = layui.xmSelect;
    var notice = layui.notice;
    // 商品分类数据
    var insTb = treeTable.render({
        elem: '#tag',
@@ -52,7 +52,7 @@
        url: baseUrl+'/mat/page/auth',
        page: true,
        limit: 16,
        limits: [16, 30, 50, 100, 200, 500],
        limits: [16, 30, 50, 100, 200, 500,1000,2000,10000,100000],
        toolbar: '#toolbar',
        cellMinWidth: 50,
        height: 'full-105',
@@ -234,6 +234,36 @@
            case 'edit':
                showEditModel(data)
                break;
            case'sync':
            case 'sync':
                layer.confirm('确认同步库存?', function () {
                    notice.msg('正在同步库存......', {icon: 4}); // 加载提示
                    $.ajax({
                        url: baseUrl + "/mat/sync",
                        method: 'POST',
                        contentType: 'application/json', // 正确的Content-Type位置
                        headers: {
                            'token': localStorage.getItem('token')
                        },
                        data: JSON.stringify(data),
                        success: function (res) {
                            notice.destroy(); // 移除“正在同步”提示
                            if (res.code === 200) {
                                layer.msg('同步成功 ✅', {icon: 1}); // ✅ 成功提示
                                $(".layui-laypage-btn")[0].click(); // 触发表格刷新
                            } else {
                                layer.msg(res.msg || '同步失败 ❌', {icon: 2}); // ❌ 失败提示
                            }
                        },
                        error: function (xhr) {
                            notice.destroy();
                            layer.msg('请求失败:' + (xhr.responseText || '未知错误'), {icon: 2});
                        }
                    });
                });
                break;
        }
    });
@@ -367,11 +397,25 @@
    // 同步庫存
    form.on('submit(synchronous)', function (data) {
        layer.confirm('确认同步庫存?', function(){
            http.get(baseUrl+"/hand/control/wrkMast", {workNo: data.wrkNo, type:1}, function (res) {
                $(".layui-laypage-btn")[0].click();
                layer.msg(data.wrkNo + res.msg);
            notice.msg('正在同步庫存......', {icon: 4});
            $.ajax({
                url: baseUrl+"/mat/synchronous",
                headers: {'token': localStorage.getItem('token')},
                method: 'GET',
                success: function (res) {
                    notice.destroy();
                    // layer.close(loadIndex);
                    if (res.code === 200){
                        layer.close(dIndex);
                        layer.msg(res.msg, {icon: 1});
                        $(".layui-laypage-btn")[0].click();
                    } else if (res.code === 403){
                        top.location.href = baseUrl+"/";
                    }else {
                        layer.msg(res.msg, {icon: 2});
                    }
                }
            })
            layer.closeAll();
        });
    });