#
luxiaotao1123
2020-06-12 0347b8c45a632564b4fac11abab8db25032aef11
src/main/webapp/static/js/pakStore/pakStore.js
@@ -9,6 +9,26 @@
    var layDate = layui.laydate;
    var form = layui.form;
    // 获取可用入库站点
    $.ajax({
        url: baseUrl+"/available/put/site",
        headers: {'token': localStorage.getItem('token')},
        method: 'POST',
        success: function (res) {
            if (res.code === 200){
                var tpl = $("#putSiteSelectTemplate").html();
                var template = Handlebars.compile(tpl);
                var html = template(res);
                $('#putSiteSelect').append(html);
                form.render('select');
            } else if (res.code === 403){
                top.location.href = baseUrl+"/";
            }else {
                layer.msg(res.msg)
            }
        }
    })
    tableIns = table.render({
        elem: '#chooseData',
        data: [],
@@ -17,25 +37,29 @@
        cellMinWidth: 50,
        toolbar: '#toolbar',
        cols: [[
            {fixed: 'left', title:'操作', align: 'center', toolbar: '#operate', width:80},
            {fixed: 'left', field: 'count', title: '数量(必填)', align: 'center', edit:'text', width: 120,  style:'color: blue;font-weight: bold'},
            {field: 'matNo', align: 'center', title: '物料编码'},
            {field: 'barcode', align: 'center', title: '条码'},
            {field: 'matName', align: 'center', title: '物料名称'},
            {field: 'str1', align: 'center', title: '物料单位'},
            {field: 'str2', align: 'center', title: '物料规格'},
            {fixed: 'right', field: 'count', title: '数量', align: 'center', edit:'text', width: 100}
            {fixed: 'right', title:'操作', align: 'center', toolbar: '#operate', width:80}
        ]],
        done: function (res, curr, count) {
            $('td[data-field=count] div').html(initCountVal);
            setMatCodeData(res.data);
            limit();
        }
    });
    // 页面修改
    table.on('edit(chooseData)', function (obj) {
        if (!isNaN(obj.value)) {
            updateMatCodeData(obj.data.matNo, Number(obj.value));
            tableIns.reload({data: matCodeData,done:function (res) {
                    limit();
                    // 覆盖render方法的done
                }});
        } else {
@@ -49,20 +73,32 @@
        var data = checkStatus.data;
        switch(obj.event) {
            case 'comb':
                if (data.length === 0){
                    layer.msg('请选择数据');
                } else {
                    layer.open({
                        type: 1,
                        title: '组盘',
                        maxmin: true,
                        shadeClose: true,
                        content: $('#combDiv'),
                        success: function (layero, index) {
                        }
                    })
                // 判断是否存在物料
                if (matCodeData.length === 0) {
                    layer.msg("请先添加物料");
                    return;
                }
                // 判断物料数量是否存在异常
                for (var i=0;i<matCodeData.length;i++){
                    if (isNaN(matCodeData[i].count)) {
                        layer.msg("请输入数字");
                        return;
                    }
                    if (matCodeData[i].count === 0){
                        layer.msg("数量不能为零");
                        return;
                    }
                }
                layer.open({
                    type: 1,
                    title: '选择入库站',
                    maxmin: true,
                    shadeClose: true,
                    content: $('#combDiv'),
                    success: function (layero, index) {
                    }
                })
                break;
        }
    });
@@ -79,6 +115,7 @@
                    }
                }
                tableIns.reload({data: matCodeData,done:function (res) {
                        limit();
                        // 覆盖render方法的done
                    }});
                break;
@@ -99,12 +136,38 @@
            }
        }
    }
    // 表单 --- 启动入库
    form.on('submit(combDo)', function (data) {
        $.ajax({
            url: baseUrl+"/full/store/start",
            headers: {'token': localStorage.getItem('token')},
            data: JSON.stringify({
                devpNo: $('#putSiteSelect').val(),
                list: matCodeData
            }),
            contentType:'application/json;charset=UTF-8',
            method: 'POST',
            async: false,
            success: function (res) {
                if (res.code === 200){
                    layer.closeAll();
                    layer.msg(res.msg);
                    matCodeData = [];
                    tableIns.reload({data: matCodeData,done:function (res) { limit();}});
                } else if (res.code === 403){
                    top.location.href = baseUrl+"/";
                }else {
                    layer.msg(res.msg)
                }
            }
        })
    });
});
// 提取物料
var matCodeLayerIdx;
function getMat() {
    // tableIns.reload({data: []});
    matCodeLayerIdx = layer.open({
        type: 2,
        title: '提取物料',
@@ -116,9 +179,3 @@
        }
    });
}
// 启动入库
function putMat() {
}