#
luxiaotao1123
2021-04-01 725a9f8c9594399c613ea7bf1b7a606e290687ad
src/main/webapp/static/js/ioWorks/matQuery.js
@@ -9,12 +9,16 @@
    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',
@@ -41,22 +45,38 @@
        switch (obj.event) {
            case 'createDoc':
                if (data.length === 0){
                    layer.msg('请添加物料');
                } else {
                    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('');
                        }
                    notice.error({
                        title: '消息通知',
                        message: '请添加物料'
                    });
                } else {
                    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;
        }
@@ -83,48 +103,68 @@
    form.on('submit(confirm)', function (data) {
        var matDetls = [];
        matData.forEach(function(elem) {
            matDetls.push({matnr: elem.matnr, count: elem.count});
            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: JSON.stringify({
                number: data.field.orderNo,
                list: matDetls
            }),
            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);
                    layer.msg(res.msg, {icon: 1});
                } else if (res.code === 403){
                    top.location.href = baseUrl+"/";
                } else {
                    layer.msg(res.msg, {icon: 2})
                    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) {
@@ -183,7 +223,10 @@
            } else if (res.code === 403){
                top.location.href = baseUrl+"/";
            } else {
                layer.msg(res.msg, {icon: 2})
                notice.error({
                    title: '消息通知',
                    message: res.msg
                });
            }
        }
    });