#
luxiaotao1123
2021-04-01 725a9f8c9594399c613ea7bf1b7a606e290687ad
src/main/webapp/static/js/ioWorks/matQuery.js
@@ -9,17 +9,22 @@
    cols.push({fixed: 'right', title:'操作', align: 'center', toolbar: '#operate', width:65})
    return cols;
}
layui.use(['table','laydate', 'form'], function() {
layui.config({
    base: baseUrl + "/static/layui/lay/modules/"
}).extend({
    notice: 'notice/notice',
}).use(['table','laydate', 'form',  'notice'], function() {
    var table = layui.table;
    var $ = layui.jquery;
    var layer = layui.layer;
    var form = layui.form;
    var notice = layui.notice;
    tableIns = table.render({
        elem: '#chooseData',
        headers: {token: localStorage.getItem('token')},
        data: [],
        limit: 100,
        even: true,
        toolbar: '#toolbar',
        cellMinWidth: 50,
@@ -38,34 +43,40 @@
    table.on('toolbar(chooseData)', function (obj) {
        var data = matData;
        switch (obj.event) {
            case 'outbound':
            case 'createDoc':
                if (data.length === 0){
                    layer.msg('请先添加物料');
                    notice.error({
                        title: '消息通知',
                        message: '请添加物料'
                    });
                } else {
                    var locDetls = [];
                    data.forEach(function(elem) {
                        locDetls.push({nodeId: elem.nodeId, matnr: elem.matnr, count: elem.count});
                    });
                    $.ajax({
                        url: baseUrl+"/work/pakout/init",
                        headers: {'token': localStorage.getItem('token')},
                        data: JSON.stringify(locDetls),
                        contentType:'application/json;charset=UTF-8',
                        method: 'POST',
                        success: function (res) {
                            if (res.code === 200){
                                matData = [];
                                tableIns.reload({data: matData,done:function (res) {
                                    limit();
                                }});
                                layer.msg(res.msg, {icon: 1});
                            } else if (res.code === 403){
                                top.location.href = baseUrl+"/";
                            } else {
                                layer.msg(res.msg)
                            }
                    var success = true;
                    for (var i=0;i<matData.length;i++) {
                        if (matData[i].count <= 0) {
                            notice.error({
                                title: '消息通知',
                                message: matData[i].matnr + '物料数量必须大于零!'
                            });
                            success = false;
                            return false;
                        }
                    });
                    }
                    if (success) {
                        layer.open({
                            type: 1,
                            title: '定义采购退货单编号',
                            offset: '100px',
                            area: ['360px'],
                            shade: 0.1,
                            content: $('#getOrderNo'),
                            success: function(layero, index){
                                layer.iframeAuto(index)
                            },
                            cancel: function () {
                                $('#orderNo').val('');
                            }
                        });
                    }
                }
                break;
        }
@@ -88,23 +99,72 @@
        }
    });
    // 开始生成拣货单
    form.on('submit(confirm)', function (data) {
        var matDetls = [];
        matData.forEach(function(elem) {
            matDetls.push({matnr: elem.matnr
                , count: elem.count
            });
        });
        var number = data.field.orderNo; // 单号
        if (number.substring(0, 3) !== 'PR-') {
            notice.error({
                title: '消息通知',
                message: '单号不符合规则,请以 PR- 开头'
            });
            return false;
        }
        var req = JSON.stringify({
            number: number
            , customerTypeId: data.field.customerTypeId
            , list: matDetls
        })
        $.ajax({
            url: baseUrl+"/work/order/init",
            headers: {'token': localStorage.getItem('token')},
            data: req,
            contentType:'application/json;charset=UTF-8',
            method: 'POST',
            success: function (res) {
                if (res.code === 200){
                    notice.success({
                        title: '消息通知',
                        message: res.msg
                    });
                    top.layui.layer.close(top.popupRight);
                } else if (res.code === 403){
                    top.location.href = baseUrl+"/";
                } else {
                    notice.error({
                        title: '消息通知',
                        message: res.msg
                    });
                }
            }
        });
    })
    function updateMatData(locNo, matnr, count) {
        if (isNaN(count)) {
            layer.msg("请输入数字");
            notice.error({
                title: '消息通知',
                message: '请输入数字'
            });
        } else {
            if (count > 0) {
                for (var i=0;i<matData.length;i++){
                    if (matData[i]["matnr"] === matnr){
                        // if (count > locDetlData[i]["anfme"]) {
                        //     layer.msg("不能超过原数量");
                        // } else {
                            matData[i]["count"] = count;
                        // }
                        matData[i]["count"] = count;
                        break;
                    }
                }
            } else {
                layer.msg("数量必须大于零");
                notice.error({
                    title: '消息通知',
                    message: '数量必须大于零'
                });
            }
        }
        tableIns.reload({data: matData,done:function (res) {
@@ -149,4 +209,25 @@
    matData.push.apply(matData, data);
    tableIns.reload({data: matData});
    layer.close(matDetlLayerIdx);
}
function initOrderNo() {
    $.ajax({
        url: baseUrl+"/work/orderNo/init",
        headers: {'token': localStorage.getItem('token')},
        async: false,
        method: 'GET',
        success: function (res) {
            if (res.code === 200){
                $('#orderNo').val(res.data)
            } else if (res.code === 403){
                top.location.href = baseUrl+"/";
            } else {
                notice.error({
                    title: '消息通知',
                    message: res.msg
                });
            }
        }
    });
}