自动化立体仓库 - WMS系统
IZCD4L12RTSW0VZ\Administrator
22 小时以前 290e5fd2e74efe19326f56e38c3391aaae23ffc5
src/main/webapp/static/js/adjustOrder/adjustOrder.js
@@ -3,7 +3,7 @@
    base: baseUrl + "/static/layui/lay/modules/"
}).extend({
    notice: 'notice/notice',
}).use(['layer', 'form', 'table', 'util', 'admin', 'xmSelect', 'laydate','tableMerge','notice'], function () {
}).use(['layer', 'form', 'table', 'util', 'admin', 'xmSelect', 'laydate', 'tableMerge', 'notice'], function () {
    var $ = layui.jquery;
    var layer = layui.layer;
    var form = layui.form;
@@ -18,21 +18,21 @@
    // 渲染搜索模板
    $.ajax({
        url: baseUrl+"/docType/list/auth",
        headers: {'token': localStorage.getItem('token')},
        url: baseUrl + "/docType/list/auth",
        headers: { 'token': localStorage.getItem('token') },
        data: {
            limit: 9999
        },
        method: 'POST',
        success: function (res) {
            if (res.code === 200){
            if (res.code === 200) {
                let template = Handlebars.compile($('#docTypeTpl').html());
                $('#docType-query').html(template(res.data));
                layui.form.render('select');
            } 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})
                layer.msg(res.msg, { icon: 2 })
            }
        }
    })
@@ -40,19 +40,22 @@
    // 渲染表格
    var insTb = table.render({
        elem: '#order',
        url: baseUrl+'/adjustOrder/list/auth',
        headers: {token: localStorage.getItem('token')},
        url: baseUrl + '/adjustOrder/list/auth',
        headers: { token: localStorage.getItem('token') },
        page: true,
        cellMinWidth: 100,
        cols: [[
            {type: 'numbers'},
            {field: 'orderNo', title: '单据编号'},
            {field: 'docType$', align: 'center', title: '类型',  minWidth: 160, width: 160},
            {align: 'center', title: '明细', toolbar: '#tbLook', minWidth: 160, width: 160},
            {field: 'createTime$', title: '创建时间', minWidth: 200, width: 200},
            {field: 'settle$', align: 'center', title: '状态', templet: '#settleTpl',  minWidth: 160, width: 160},
            {field: 'memo', align: 'center',title: '备注', hide: true},
            {align: 'center', title: '操作', toolbar: '#operate',}
            { type: 'numbers' },
            { field: 'orderNo', title: '单据编号' },
            { field: 'docType$', align: 'center', title: '类型', minWidth: 120, width: 120 },
            { field: 'defNumber', align: 'center', title: '流水号', minWidth: 160, width: 160 },
            { field: 'cstmrName', align: 'center', title: '公司', minWidth: 160, width: 160 },
            { field: 'orderTime', title: '订单时间', minWidth: 200, width: 200 },
            { field: 'shipName', align: 'center', title: '调整原因' },
            { field: 'memo', align: 'center', title: '原因描述' },
            { field: 'settle$', align: 'center', title: '状态', templet: '#settleTpl', minWidth: 120, width: 120 },
            { align: 'center', title: '明细', toolbar: '#tbLook', minWidth: 160, width: 160 },
            { align: 'center', title: '操作', toolbar: '#operate', }
        ]],
        request: {
            pageName: 'curr',
@@ -72,7 +75,7 @@
        done: function (res, curr, count) {
            limit();
            if (res.code === 403) {
                top.location.href = baseUrl+"/";
                top.location.href = baseUrl + "/";
            }
            insTbCount = count;
        }
@@ -80,7 +83,7 @@
    // 搜索
    form.on('submit(tbSearch)', function (data) {
        insTb.reload({where: data.field, page: {curr: 1}});
        insTb.reload({ where: data.field, page: { curr: 1 } });
    });
    // 添加
@@ -94,11 +97,11 @@
        var layEvent = obj.event;
        if (layEvent === 'edit') {
            showEditModel(data);
        }else if (layEvent === 'adjust') {
        } else if (layEvent === 'adjust') {
            adjustComplete(data.id);
        }else if (layEvent === 'export') {
        } else if (layEvent === 'export') {
            export1(data.id);
        }else if (layEvent === 'del') {
        } else if (layEvent === 'del') {
            doDel(data.id);
        } else if (layEvent === 'complete') {
            doModify(data.id, data.orderNo, 4);
@@ -125,15 +128,17 @@
                        height: '450px;',
                        cellMinWidth: 100,
                        cols: [[
                            {type: 'numbers'},
                            {field: 'locNo', title: '库位号', width: 120},
                            {field: 'zpallet', title: '容器码', width: 120},
                            {field: 'matnr', title: '商品编码', width: 160},
                            {field: 'maktx', title: '商品名称', width: 160},
                            {field: 'batch', title: '批号'},
                            {field: 'diffQty', title: '差异数量', style: 'font-weight: bold'},
                            {field: 'specs', title: '规格'},
                            {field: 'status$', title: '状态'}
                            { type: 'numbers' },
                            { field: 'locNo', title: '库位号', width: 120 },
                            { field: 'zpallet', title: '容器码', width: 120 },
                            { field: 'matnr', title: '商品编码', width: 160 },
                            { field: 'maktx', title: '商品名称', width: 160 },
                            { field: 'suppCode', title: '供应商编码' },
                            { field: 'length', align: 'center', title: '重量', hide: false }
                            ,{ field: 'volume', align: 'center', title: '尺寸', hide: false }
                            ,{ field: 'diffQty', title: '差异数量', style: 'font-weight: bold' },
                            { field: 'specs', title: '规格' },
                            { field: 'status$', title: '状态' }
                        ]],
                        request: {
                            pageName: 'curr',
@@ -179,58 +184,58 @@
                form.on('submit(orderEditSubmit)', function (data) {
                    // 组装数据
                    if (xxDataList.length <= 0) {
                        layer.tips('请添加单据明细', '#matAddBtnComment', {tips: [1, '#ff4c4c']});
                        layer.tips('请添加单据明细', '#matAddBtnComment', { tips: [1, '#ff4c4c'] });
                        return false;
                    }
                    let nList = admin.util.deepClone(xxDataList);
                    layer.load(2);
                    if (isExpAdd){
                    if (isExpAdd) {
                        $.ajax({
                            url: baseUrl+"/checkOrder/form/" + "add" + "/auth",
                            headers: {'token': localStorage.getItem('token')},
                            url: baseUrl + "/checkOrder/form/" + "add" + "/auth",
                            headers: { 'token': localStorage.getItem('token') },
                            data: JSON.stringify({
                                orderId: Number(data.field.id),
                                docType: Number(data.field.docType),
                                orderNo: data.field.orderNo,
                                locDetlList: nList
                            }),
                            contentType:'application/json;charset=UTF-8',
                            contentType: 'application/json;charset=UTF-8',
                            method: 'POST',
                            success: function (res) {
                                layer.closeAll('loading');
                                if (res.code === 200){
                                if (res.code === 200) {
                                    layer.close(dIndex);
                                    $(".layui-laypage-btn")[0].click();
                                    layer.msg(res.msg, {icon: 1});
                                } else if (res.code === 403){
                                    top.location.href = baseUrl+"/";
                                }else {
                                    layer.msg(res.msg, {icon: 2});
                                    layer.msg(res.msg, { icon: 1 });
                                } else if (res.code === 403) {
                                    top.location.href = baseUrl + "/";
                                } else {
                                    layer.msg(res.msg, { icon: 2 });
                                }
                            }
                        })
                    }else {
                    } else {
                        $.ajax({
                            url: baseUrl+"/checkOrder/form/" + "modify" + "/auth",
                            headers: {'token': localStorage.getItem('token')},
                            url: baseUrl + "/checkOrder/form/" + "modify" + "/auth",
                            headers: { 'token': localStorage.getItem('token') },
                            data: JSON.stringify({
                                orderId: Number(data.field.id),
                                docType: Number(data.field.docType),
                                orderNo: data.field.orderNo,
                                checkOrderDetls: nList
                            }),
                            contentType:'application/json;charset=UTF-8',
                            contentType: 'application/json;charset=UTF-8',
                            method: 'POST',
                            success: function (res) {
                                layer.closeAll('loading');
                                if (res.code === 200){
                                if (res.code === 200) {
                                    layer.close(dIndex);
                                    $(".layui-laypage-btn")[0].click();
                                    layer.msg(res.msg, {icon: 1});
                                } else if (res.code === 403){
                                    top.location.href = baseUrl+"/";
                                }else {
                                    layer.msg(res.msg, {icon: 2});
                                    layer.msg(res.msg, { icon: 1 });
                                } else if (res.code === 403) {
                                    top.location.href = baseUrl + "/";
                                } else {
                                    layer.msg(res.msg, { icon: 2 });
                                }
                            }
                        })
@@ -242,21 +247,21 @@
                var xxDataList = [];
                var tbOptions = {
                    elem: '#formSSXMTable',
                    headers: {token: localStorage.getItem('token')},
                    headers: { token: localStorage.getItem('token') },
                    data: xxDataList,
                    page: true,
                    height: '350px;',
                    cellMinWidth: 100,
                    cols: [[
                        {type: 'numbers', title: '#'},
                        {field: 'locNo', title: '库位号'},
                        {field: 'matnr', title: '商品编码', width: 160},
                        {field: 'maktx', title: '商品名称', width: 200},
                        {field: 'batch', title: '批号'},
                        {field: 'specs', title: '规格'},
                        {field: 'anfme', title: '数量', minWidth: 110, width: 110},
                        { type: 'numbers', title: '#' },
                        { field: 'locNo', title: '库位号' },
                        { field: 'matnr', title: '商品编码', width: 160 },
                        { field: 'maktx', title: '商品名称', width: 200 },
                        { field: 'batch', title: '批号' },
                        { field: 'specs', title: '规格' },
                        { field: 'anfme', title: '数量', minWidth: 110, width: 110 },
                        // {field: 'unit', title: '单位', width: 80},
                        {align: 'center', title: '操作', toolbar: '#formSSXMTableBar', minWidth: 80, width: 80, fixed: 'right'}
                        { align: 'center', title: '操作', toolbar: '#formSSXMTableBar', minWidth: 80, width: 80, fixed: 'right' }
                    ]],
                    done: function (res) {
                        $(layero).find('.layui-table-view').css('margin', '0');
@@ -265,18 +270,18 @@
                };
                if (!isExpAdd) {
                    $.ajax({
                        url: baseUrl+"/checkOrderDetl/select/all?orderId=" + expTpe.id,
                        headers: {'token': localStorage.getItem('token')},
                        url: baseUrl + "/checkOrderDetl/select/all?orderId=" + expTpe.id,
                        headers: { 'token': localStorage.getItem('token') },
                        method: 'GET',
                        async: false,
                        success: function (res) {
                            if (res.code === 200){
                            if (res.code === 200) {
                                xxDataList = res.data;
                                tbOptions.data = xxDataList;
                            } else if (res.code === 403){
                                top.location.href = baseUrl+"/";
                            }else {
                                layer.msg(res.msg, {icon: 2})
                            } else if (res.code === 403) {
                                top.location.href = baseUrl + "/";
                            } else {
                                layer.msg(res.msg, { icon: 2 })
                            }
                        }
                    })
@@ -287,8 +292,8 @@
                    var data = obj.data;
                    var layEvent = obj.event;
                    if (layEvent === 'del') {
                        if(data.workQty > 0){
                            layer.msg("已存在作业数量,不能删除", {icon: 2});
                        if (data.workQty > 0) {
                            layer.msg("已存在作业数量,不能删除", { icon: 2 });
                            return;
                        }
                        layer.confirm('确定要删除吗?', {
@@ -302,13 +307,13 @@
                                    break;
                                }
                            }
                            insTbSSXM.reload({data: xxDataList, page: {curr: 1}});
                            insTbSSXM.reload({ data: xxDataList, page: { curr: 1 } });
                        });
                    }
                });
                // 全局函数,用于接收从库存查询页面返回的数据
                window.addCheckOrderTableData = function(data) {
                window.addCheckOrderTableData = function (data) {
                    // 处理选中的库存数据
                    var addedCount = 0;
                    var duplicateCount = 0;
@@ -317,7 +322,7 @@
                        var isDuplicate = false;
                        for (var j = 0; j < xxDataList.length; j++) {
                            if (xxDataList[j].locNo === data[i].locNo && xxDataList[j].matnr === data[i].matnr && xxDataList[j].batch === data[i].batch) {
                                if (xxDataList[j].diffQty !== 0){
                                if (xxDataList[j].diffQty !== 0) {
                                    isDuplicate = true;
                                    duplicateCount++;
                                    break;
@@ -325,22 +330,22 @@
                            }
                        }
                        if (data[j].diffQty !== 0){
                        if (data[j].diffQty !== 0) {
                            isDuplicate = true;
                            duplicateCount++;
                        }
                        // 如果不重复,则添加到列表
                        if (!isDuplicate) {
                            xxDataList.push({...data[i]});
                            xxDataList.push({ ...data[i] });
                            addedCount++;
                        }
                    }
                    insTbSSXM.reload({data: xxDataList, page: {curr: 1}});
                    insTbSSXM.reload({ data: xxDataList, page: { curr: 1 } });
                    // 提示添加结果
                    if (duplicateCount > 0) {
                        layer.msg('成功添加 ' + addedCount + ' 条数据,' + duplicateCount + ' 条数据已忽略', {icon: 1});
                        layer.msg('成功添加 ' + addedCount + ' 条数据,' + duplicateCount + ' 条数据已忽略', { icon: 1 });
                    } else if (addedCount > 0) {
                        layer.msg('成功添加 ' + addedCount + ' 条数据', {icon: 1});
                        layer.msg('成功添加 ' + addedCount + ' 条数据', { icon: 1 });
                    }
                };
@@ -350,7 +355,7 @@
                // 显示添加明细表单弹窗 - 提取库存
                function showEditModel2(exp) {
                    let loadIndex = layer.msg('请求中...', {icon: 16, shade: 0.01, time: false});
                    let loadIndex = layer.msg('请求中...', { icon: 16, shade: 0.01, time: false });
                    layer.open({
                        type: 2,
                        title: '提取库存',
@@ -359,7 +364,7 @@
                        area: ['90%', '85%'],
                        shadeClose: true,
                        content: 'checkOrderLocQuery.html',
                        success: function(layero, index){
                        success: function (layero, index) {
                            layer.close(loadIndex);
                        }
                    });
@@ -378,25 +383,25 @@
            layer.close(i);
            layer.load(2);
            $.ajax({
                url: baseUrl+"/checkOrder/delete/auth",
                headers: {'token': localStorage.getItem('token')},
                url: baseUrl + "/checkOrder/delete/auth",
                headers: { 'token': localStorage.getItem('token') },
                data: {
                    orderId: orderId
                },
                method: 'POST',
                success: function (res) {
                    layer.closeAll('loading');
                    if (res.code === 200){
                    if (res.code === 200) {
                        if (insTbCount === 0) {
                            insTb.reload({page: {curr: 1}});
                            insTb.reload({ page: { curr: 1 } });
                        } else {
                            $(".layui-laypage-btn")[0].click();
                        }
                        layer.msg(res.msg, {icon: 1});
                    } else if (res.code === 403){
                        top.location.href = baseUrl+"/";
                    }else {
                        layer.msg(res.msg, {icon: 2});
                        layer.msg(res.msg, { icon: 1 });
                    } else if (res.code === 403) {
                        top.location.href = baseUrl + "/";
                    } else {
                        layer.msg(res.msg, { icon: 2 });
                    }
                }
            })
@@ -412,25 +417,25 @@
            layer.close(i);
            layer.load(2);
            $.ajax({
                url: baseUrl+"/checkOrder/complete/auth",
                headers: {'token': localStorage.getItem('token')},
                url: baseUrl + "/checkOrder/complete/auth",
                headers: { 'token': localStorage.getItem('token') },
                data: {
                    orderId: orderId
                },
                method: 'POST',
                success: function (res) {
                    layer.closeAll('loading');
                    if (res.code === 200){
                    if (res.code === 200) {
                        if (insTbCount === 0) {
                            insTb.reload({page: {curr: 1}});
                            insTb.reload({ page: { curr: 1 } });
                        } else {
                            $(".layui-laypage-btn")[0].click();
                        }
                        layer.msg(res.msg, {icon: 1});
                    } else if (res.code === 403){
                        top.location.href = baseUrl+"/";
                    }else {
                        layer.msg(res.msg, {icon: 2});
                        layer.msg(res.msg, { icon: 1 });
                    } else if (res.code === 403) {
                        top.location.href = baseUrl + "/";
                    } else {
                        layer.msg(res.msg, { icon: 2 });
                    }
                }
            })
@@ -442,31 +447,31 @@
        let loadIndex = layer.load(2);
        $.ajax({
            url: baseUrl + "/adjustOrder/complete/auth",
            headers: {'token': localStorage.getItem('token')},
            headers: { 'token': localStorage.getItem('token') },
            data: {
                orderId: id
            },
            method: 'POST',
            success: function (res) {
                if (res.code === 200){
                if (res.code === 200) {
                    layer.close(loadIndex);
                    layer.msg(res.msg, {icon: 1});
                    insTb.reload({where: null});
                } else if (res.code === 403){
                    top.location.href = baseUrl+"/";
                    layer.msg(res.msg, { icon: 1 });
                    insTb.reload({ where: null });
                } else if (res.code === 403) {
                    top.location.href = baseUrl + "/";
                } else {
                    layer.close(loadIndex);
                    layer.msg(res.msg, {icon: 2})
                    layer.msg(res.msg, { icon: 2 })
                }
            }
        })
    }
    function export1(id) {
        notice.msg('正在导出文件......', {icon: 4});
        notice.msg('正在导出文件......', { icon: 4 });
        $.ajax({
            url: baseUrl + "/checkOrder/export/auth",
            headers: {'token': localStorage.getItem('token')},
            headers: { 'token': localStorage.getItem('token') },
            data: {
                orderId: id
            },
@@ -486,9 +491,9 @@
                        filename = decodeURIComponent(matches[1].replace(/['"]/g, ''));
                    }
                }
                // 创建下载链接
                var blob = new Blob([data], {type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'});
                var blob = new Blob([data], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' });
                var link = document.createElement('a');
                link.href = window.URL.createObjectURL(blob);
                link.download = filename;
@@ -496,15 +501,15 @@
                link.click();
                document.body.removeChild(link);
                window.URL.revokeObjectURL(link.href);
                layer.msg('导出成功', {icon: 1});
                layer.msg('导出成功', { icon: 1 });
            },
            error: function (xhr, status, error) {
                notice.destroy();
                if (xhr.status === 403) {
                    top.location.href = baseUrl + "/";
                } else {
                    layer.msg('导出失败:' + error, {icon: 2});
                    layer.msg('导出失败:' + error, { icon: 2 });
                }
            }
        });
@@ -512,10 +517,10 @@
    function pakout(tableCache, layerIndex) {
        // let loadIndex = layer.load(2);
        notice.msg('正在生成盘点出库任务......', {icon: 4});
        notice.msg('正在生成盘点出库任务......', { icon: 4 });
        $.ajax({
            url: baseUrl + "/out/checkPakOut/auth",
            headers: {'token': localStorage.getItem('token')},
            headers: { 'token': localStorage.getItem('token') },
            contentType: 'application/json;charset=UTF-8',
            data: JSON.stringify(tableCache),
            method: 'POST',
@@ -523,12 +528,12 @@
                notice.destroy();
                if (res.code === 200) {
                    layer.close(layerIndex);
                    layer.msg(res.msg, {icon: 1});
                    insTb.reload({where: null});
                    layer.msg(res.msg, { icon: 1 });
                    insTb.reload({ where: null });
                } else if (res.code === 403) {
                    top.location.href = baseUrl + "/";
                } else {
                    layer.msg(res.msg, {icon: 2})
                    layer.msg(res.msg, { icon: 2 })
                }
            }
        });
@@ -536,7 +541,7 @@
    layDate.render({
        elem: '.layui-laydate-range'
        ,type: 'datetime'
        ,range: true
        , type: 'datetime'
        , range: true
    });
});