#
luxiaotao1123
2021-09-09 e1749547c76a5d8bae94e47d38d4d75b481610c1
src/main/webapp/views/pda/stockIn.html
@@ -3,7 +3,7 @@
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no"/>
    <title>入库</title>
    <title>上架</title>
    <link rel="stylesheet" href="../../static/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../../static/css/pda.css" media="all">
    <script type="text/javascript" src="../../static/js/jquery/jquery-3.3.1.min.js"></script>
@@ -65,6 +65,24 @@
            transform:rotate(-45deg);
        }
        /**绿色勾*/
        #node-ok {
            float: left;
            width: 15px;
            height: 15px;
            border-radius: 50%;
            margin-top: 13px;
            background-color: #2ac845;
            display: none;
        }
        #typeSelect {
            padding: 10px 20px;
        }
        .layui-form-radio {
            width: 100%;
        }
    </style>
</head>
<body>
@@ -76,7 +94,8 @@
    </div>
    <div STYLE="margin: 5px 0" class="layui-input-inline">
        <label class="layui-form-label">上架货位</label>
        <input class="layui-input" type="text" id="node" onkeyup="findNode(this)" placeholder="扫码 / 输入" autocomplete="off">
        <input style="float: left" class="layui-input" type="text" id="node" onkeyup="findNode(this)" placeholder="扫码 / 输入" autocomplete="off">
        <span id="node-ok"></span>
    </div>
</header>
@@ -88,18 +107,26 @@
<footer>
    <div class="layui-btn-container">
        <button type="button" class="layui-btn layui-btn-primary" onclick="reset()">重置</button>
        <button id="empty-pakin" type="button" class="layui-btn layui-btn-normal" onclick="emptyPakIn()" style="margin-left: 15px">空板入库</button>
        <button id="pakin" type="button" class="layui-btn layui-btn-normal" onclick="pakIn()" style="margin-left: 15px">入库</button>
        <button id="pakin" type="button" class="layui-btn layui-btn-normal" onclick="pakIn()" style="margin-left: 15px">上架</button>
    </div>
</footer>
<div id="typeSelect" style="display: none">
    <form class="layui-form">
        <input type="radio" name="docType" value="34" title="采购单" checked="">
        <input type="radio" name="docType" value="45" title="销售退货单">
        <hr>
        <div style="text-align: center">
            <button class="layui-btn layui-btn-normal" onclick="pakIn()">确定</button>
        </div>
    </form>
</div>
</body>
<script>
    var tableIns;
    window.onload = function(){
        document.getElementById("code").focus();
        getInBound();
    }
    layui.use(['table','laydate', 'form'], function() {
        var table = layui.table;
@@ -113,9 +140,9 @@
            limit: 500,
            cellMinWidth: 50,
            cols: [[
                {fixed: 'left', align: 'center', field: 'count', title: '数量', style:'color: blue', width:50},
                {field: 'matNo', align: 'center', title: '物料编码'},
                {field: 'matName', align: 'center', title: '物料名称'}
                {fixed: 'left', align: 'center', field: 'anfme', title: '数量', style:'color: blue', width:50},
                {field: 'matnr', align: 'center', title: '商品编码'},
                {field: 'maktx', align: 'center', title: '商品名称'}
            ]],
            done: function (res, curr, count) {
@@ -137,8 +164,13 @@
            method: 'POST',
            success: function (res) {
                if (res.code === 200) {
                    if (res.data != null) {
                        console.log(res.data);
                    if (res.data.length > 0) {
                        matData = res.data;
                        tableIns.reload({data: res.data});
                        $('#node').focus();
                    } else {
                        matData = [];
                        tableIns.reload({data: res.data});
                    }
                } else if (res.code === 403) {
                    top.location.href = baseUrl + "/pda";
@@ -150,30 +182,28 @@
    }
    function findNode(el) {
        if (el.value.length === 7) {
            $('#mat-btn').focus();
            getMat();
        if (isEmpty(el.value)) {
            $('#node-ok').hide();
            return;
        }
    }
    // 获取入库口
    function getInBound(){
        $.ajax({
            url: baseUrl+"/available/put/site",
            url: baseUrl + "/mobile/inStock/node/auth",
            headers: {'token': localStorage.getItem('token')},
            data: {
                node: el.value
            },
            method: 'POST',
            async: false,
            success: function (res) {
                if (res.code === 200){
                    var tpl = $("#putSiteSelectTemplate").html();
                    var template = Handlebars.compile(tpl);
                    var html = template(res);
                    $('#putSiteSelect').append(html);
                    layui.form.render('select');
                } else if (res.code === 403){
                    top.location.href = baseUrl+"/pda";
                }else {
                    tips("获取入库口失败", true)
                if (res.code === 200) {
                    if (res.data != null) {
                        $('#node-ok').show();
                    } else {
                        $('#node-ok').hide();
                    }
                } else if (res.code === 403) {
                    top.location.href = baseUrl + "/pda";
                } else {
                    tips(res.msg, true);
                }
            }
        })
@@ -190,6 +220,7 @@
            content: 'matQuery.html',
            success: function(layero, index){
                $('.layui-layer-title').css('font-size', '16px');
                $('.layui-layer.layui-layer-iframe').css('border-radius', '8px');
            },
            end: function () {
                $('#mat-btn').focus();
@@ -200,62 +231,87 @@
    // 添加表格数据
    var matData = [];
    function addTableData(data) {
        if (isEmpty(data.matName)){
            tips("提取失败", true);
            return;
        if (matData.length > 0) {
            matData = [];
        }
        let toPush = true;
        for (var j=0;j<matData.length;j++){
            if (data.matNo === matData[j].matNo) {
                matData[j].count = Number(matData[j].count) + Number(data.count);
                toPush  = false;
        for (var i=0;i<data.length;i++) {
            var toPush = true;
            for (var j=0;j<matData.length;j++){
                if (data[i].matnr === matData[j].matnr) {
                    matData[j].count = Number(matData[j].count) + Number(data[i].anfme);
                    toPush  = false;
                }
            }
            if (toPush) {
                matData.push(data[i]);
            }
        }
        if (toPush) {
            matData.push(data);
        }
        tips("提取成功");
        tableIns.reload({data: matData});
        $("#comb-btn").focus();
    }
    // 重置
    function reset() {
        $('#code').val("");
        $('#node').val("");
        matData = [];
        tableIns.reload({data: matData});
        $('#putSiteSelect').val("");
        $('#node-ok').hide();
        layui.form.render('select');
        // tips("");
    }
    // 入库
    function pakIn() {
        var barcode = $('#code').val();
        if (isEmpty(barcode)) {
    function confirm() {
        var zpallet = $('#code').val();
        if (isEmpty(zpallet)) {
            tips("托盘条码为空", true);
            return;
        }
        if (barcode.length !== 7) {
            tips("条码必须为7位", true);
        var node = $('#node').val();
        if (isEmpty(node)) {
            tips("货位为空", true);
            return;
        }
        if (matData.length === 0) {
            tips("请提取物料", true);
            return;
        }
        // var site = $('input:radio[name="site"]:checked').next("span").html();
        var site = $('#putSiteSelect').val();
        if (null === site || undefined === site || site === "") {
            tips("请选择入库口", true);
        layer.open({
            type: 1,
            title: '单据类型',
            shade: [0.3,'#000'],
            area: ['70%'],
            content: $('#typeSelect'),
            success: function(layero, index){
            }
        });
    }
    // 上架
    function pakIn() {
        var docType = $('input:radio[name="docType"]:checked').val();
        var zpallet = $('#code').val();
        if (isEmpty(zpallet)) {
            tips("托盘条码为空", true);
            return;
        }
        var node = $('#node').val();
        if (isEmpty(node)) {
            tips("货位为空", true);
            return;
        }
        if (matData.length === 0) {
            tips("请提取物料", true);
            return;
        }
        layer.closeAll();
        $.ajax({
            url: baseUrl+"/full/store/put/start",
            url: baseUrl+"/work/stock/in",
            headers: {'token': localStorage.getItem('token')},
            data: JSON.stringify({
                barcode: barcode,
                devpNo: site,
                list: matData
                nodeId: node,
                zpallet: zpallet,
                docType: docType
            }),
            contentType:'application/json;charset=UTF-8',
            method: 'POST',
@@ -263,7 +319,7 @@
            success: function (res) {
                if (res.code === 200) {
                    reset();
                    tips("入库启动成功")
                    tips("上架成功")
                } else if (res.code === 403) {
                    top.location.href = baseUrl + "/pda";
                } else {
@@ -273,42 +329,8 @@
        })
    }
    // 空板入库
    function emptyPakIn() {
        var barcode = $('#code').val();
        if (isEmpty(barcode)) {
            tips("托盘条码为空", true);
            return;
        }
        if (barcode.length !== 7) {
            tips("条码必须为7位", true);
            return;
        }
        var site = $('#putSiteSelect').val();
        if (null === site || undefined === site || site === "") {
            tips("请选择入库口", true);
            return;
        }
        $.ajax({
            url: baseUrl+"/empty/plate/in/start",
            headers: {'token': localStorage.getItem('token')},
            data: {
                barcode: barcode,
                sourceStaNo: site
            },
            method: 'POST',
            async: false,
            success: function (res) {
                if (res.code === 200) {
                    reset();
                    tips("空板入库启动成功")
                } else if (res.code === 403) {
                    top.location.href = baseUrl + "/pda";
                } else {
                    tips(res.msg, true)
                }
            }
        })
    function doPost() {
    }
    /**
@@ -335,10 +357,5 @@
            $("#code").focus();
        }
    }
</script>
<script type="text/template" id="putSiteSelectTemplate">
    {{#each data}}
    <option value="{{this}}">{{this}}</option>
    {{/each}}
</script>
</html>