<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('入库任务单列表')"/>
    <link th:href="@{/ruoyi/css/ry-ui-custom.css?v=4.7.3}" rel="stylesheet"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row pl0 pr0">
        <div class="col-sm-8 pr0 pl0">
            <div class="box-shadow">
                <div class="ibox float-e-margins" style="margin-bottom: 10px;">
                    <div class="ibox-title">
                        <h5>身份信息</h5>
                    </div>
                    <div class="ibox-content ibox-content-1" style="margin: 0;height: 45px">
                        <form th:object="${sysUser}">
                            <div class="col-sm-4 form-horizontal">
                                <label class="control-label">当前操作员：</label>
                                <label class="control-label" style="font-weight: bold" id="currentUser"
                                       th:text="*{userName}"></label>
                            </div>
                            <div class="col-sm-3 form-horizontal">
                                <label class="control-label">角色：</label>
                                <label class="control-label" style="font-weight: bold" id="userRoles"
                                       th:text="*{roleNames}"></label>
                            </div>
                            <div class=" form-horizontal">
                                <label class="control-label">上次登录时间：</label>
                                <label class="control-label" style="font-weight: bold" id="lastLoginTime"
                                       th:text="*{loginDateStr}"></label>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
            <div style="margin-top: 10px;" class="box-shadow">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>入库信息</h5>
                    </div>
                    <div class="ibox-content ibox-content-1">
                        <div class="select-table table-striped">
                            <table id="bootstrap-table"></table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-sm-4  pl5 pr0">
            <div class="ibox float-e-margins shadow">
                <div class="ibox-title">
                    <h5>入库操作</h5>
                </div>
                <ul class="nav nav-tabs">
                    <li class="active"><a href="#providerIn" class="nav-right-tabs-a" data-toggle="tab">ERP入库</a></li>
                    <li><a href="#noErpIn" class="nav-right-tabs-a" data-toggle="tab">无ERP入库</a></li>
                    <li><a href="#emptyPalletIn" class="nav-right-tabs-a" data-toggle="tab">空托入库</a></li>
                    <li><a href="#emptyPalletOut" class="nav-right-tabs-a" data-toggle="tab">空托出库</a>
                </ul>
                <div class="tab-content">
                    <div class="tab-pane active" id="providerIn">
                        <div class="row inner_row_style">
                            <div class="col-sm-6 form-group">
                                <label class="control-label">扫描：</label>
                                <div>
                                    <input type="text" id="scanIdProviderIn" name="scanIdProviderIn"
                                           class="form-control input-border-bottom"
                                           onkeydown="scanFunctionProviderIn()">
                                </div>
                            </div>
                            <div class="col-sm-6 form-group">
                                <label class="control-label">站台（必填项）：</label>
                                <div>
                                    <input type="text" id="inStandProviderIn" name="inStandProviderIn"
                                           class="form-control input-border-bottom">
                                </div>
                            </div>
                        </div>
                        <div class="row inner_row_style">
                            <div class="col-sm-6 form-group">
                                <label class="control-label">订单号：</label>
                                <div>
                                    <input type="text" id="orderNoProviderIn" name="orderNoProviderIn"
                                           class="form-control input-border-bottom">
                                </div>
                            </div>
                            <div class="col-sm-6 form-group">
                                <label class="control-label">物料编码：</label>
                                <div>
                                    <input type="text" id="goodsIdProviderIn" name="goodsIdProviderIn"
                                           class="form-control input-border-bottom">
                                </div>
                            </div>
                        </div>
                        <div class="row inner_row_style">
                            <div class="col-sm-6 form-group">
                                <label class="control-label">批次号：</label>
                                <div>
                                    <input type="text" id="produclotidProviderIn" name="produclotidProviderIn"
                                           class="form-control input-border-bottom">
                                </div>
                            </div>
                            <div class="col-sm-6 form-group">
                                <label class="control-label">供应商代码：</label>
                                <div>
                                    <input type="text" id="providerIdProviderIn" name="providerIdProviderIn"
                                           class="form-control input-border-bottom">
                                </div>
                            </div>
                        </div>
                        <div class="row inner_row_style">
                            <div class="col-sm-6 form-group">
                                <label class="control-label">生产日期：</label>
                                <div>
                                    <input type="text" id="productionDateProviderIn" name="productionDateProviderIn"
                                           class="form-control input-border-bottom">
                                </div>
                            </div>
                            <div class="col-sm-6 form-group">
                                <label class="control-label">有效日期：</label>
                                <div>
                                    <input type="text" id="expirationDateProviderIn" name="expirationDateProviderIn"
                                           class="form-control input-border-bottom">
                                </div>
                            </div>
                        </div>
                        <div class="row inner_row_style">
                            <div class="col-sm-6 form-group">
                                <label class="control-label">数量：</label>
                                <div>
                                    <input type="text" id="shelfNumProviderIn" name="shelfNumProviderIn"
                                           class="form-control input-border-bottom">
                                </div>
                            </div>
                            <div class="col-sm-6 form-group">
                                <label class="control-label">托盘号（必填项）：</label>
                                <div>
                                    <input type="text" id="ctl" name="ctl"
                                           class="form-control input-border-bottom">
                                </div>
                            </div>
                        </div>
<!--                        <div class="row inner_row_style">-->
<!--                            <div class="col-sm-6 form-group">-->
<!--                                <div class="checkbox">-->
<!--                                    <label><input type="checkbox" id="allowDiffErp" value="1"-->
<!--                                                  shiro:hasPermission="business:ongoodsshelf:difflot">是否允许不同批次</label>-->
<!--                                </div>-->
<!--                            </div>-->
<!--                        </div>-->
                        <div class="row tow-button-row-style">
                            <div class="col-sm-6">
                                <button type="button" class="btn btn-lg btn-ctl-print" onclick="clickProviderIn();">
                                    <span class="btn-ctl-color">确认入库</span></button>
                            </div>
                            <div class="col-sm-6">
                                <button type="button" class="btn btn-lg btn-ctl-print-red"
                                        onclick="finishIn();"><span
                                        class="btn-ctl-color">返库</span></button>
                            </div>
                        </div>
                    </div>
                    <div class="tab-pane fade" id="noErpIn">
                        <div class="row inner_row_style">
                            <div class="col-sm-6 form-group">
                                <label class="control-label">扫描：</label>
                                <div>
                                    <input type="text" id="scanIdNoErp" name="scanIdNoErp"
                                           class="form-control input-border-bottom"
                                           onkeydown="scanFunctionNoErp()">
                                </div>
                            </div>
                            <div class="col-sm-6 form-group">
                                <label class="control-label">站台（必填项）：</label>
                                <div>
                                    <input type="text" id="inStandNoErp" name="inStandNoErp"
                                           class="form-control input-border-bottom">
                                </div>
                            </div>
                        </div>
                        <div class="row inner_row_style">
                            <div class="col-sm-6 form-group">
                                <label class="control-label">订单号：</label>
                                <div>
                                    <input type="text" id="orderNoNoErp" name="orderNoNoErp" class="form-control input-border-bottom">
                                </div>
                            </div>
                            <div class="col-sm-6 form-group">
                                <label class="control-label">物料编码：</label>
                                <div>
                                    <input type="text" id="goodsIdNoErp" name="goodsIdNoErp" class="form-control input-border-bottom">
                                </div>
                            </div>
                        </div>
                        <div class="row inner_row_style">
                            <div class="col-sm-6 form-group">
                                <label class="control-label">批次号：</label>
                                <div>
                                    <input type="text" id="produclotidNoErp" name="produclotidProviderIn" class="form-control input-border-bottom">
                                </div>
                            </div>
                            <div class="col-sm-6 form-group">
                                <label class="control-label">供应商代码：</label>
                                <div>
                                    <input type="text" id="providerIdNoErp" name="providerIdNoErp" class="form-control input-border-bottom">
                                </div>
                            </div>
                        </div>
                        <div class="row inner_row_style">
                            <div class="col-sm-6 form-group">
                                <label class="control-label">生产日期：</label>
                                <div>
                                    <input type="text" id="productionDateNoErp" name="productionDateNoErp" class="form-control input-border-bottom">
                                </div>
                            </div>
                            <div class="col-sm-6 form-group">
                                <label class="control-label">有效日期：</label>
                                <div>
                                    <input type="text" id="expirationDateNoErp" name="expirationDateNoErp" class="form-control input-border-bottom">
                                </div>
                            </div>
                        </div>
                        <div class="row inner_row_style">
                            <div class="col-sm-6 form-group">
                                <label class="control-label">数量：</label>
                                <div>
                                    <input type="text" id="shelfNumNoErp" name="shelfNumNoErp" min="0"
                                           class="form-control input-border-bottom">
                                </div>
                            </div>
                            <div class="col-sm-6 form-group">
                                <label class="control-label">托盘号（必填项）：</label>
                                <div>
                                    <input type="text" id="ctlNoErp" name="ctl"
                                           class="form-control input-border-bottom">
                                </div>
                            </div>
                        </div>
<!--                        <div class="row inner_row_style">-->
<!--                            <div class="col-sm-6 form-group">-->
<!--                                <div class="checkbox">-->
<!--                                    <label><input type="checkbox" id="allowDiffNoErp" value="1"-->
<!--                                                  shiro:hasPermission="business:ongoodsshelf:difflot">是否允许不同批次</label>-->
<!--                                </div>-->
<!--                            </div>-->
<!--                        </div>-->
                        <div class="row tow-button-row-style">
                            <div class="col-sm-6">
                                <button type="button" class="btn btn-lg btn-ctl-print" onclick="clickNoErp();">
                                    <span class="btn-ctl-color">确认入库</span></button>
                            </div>
                            <div class="col-sm-6">
                                <button type="button" class="btn btn-lg btn-ctl-print-red"
                                        onclick="finishInNoErp();"><span
                                        class="btn-ctl-color">返库</span></button>
                            </div>
                        </div>
                    </div>
                    <div class="tab-pane fade" id="emptyPalletIn">
                        <div class="row inner_row_style">
                            <div class="col-sm-6 form-group">
                                <label class="control-label">站台：</label>
                                <div>
                                    <input type="text" id="inStandEmpty" name="inStandEmpty"
                                           class="form-control input-border-bottom">
                                </div>
                            </div>
                            <div class="col-sm-6 form-group">
                                <label class="control-label">托盘号：</label>
                                <div>
                                    <input type="text" id="emptyCtl" name="emptyCtl"
                                           class="form-control input-border-bottom">
                                </div>
                            </div>
                        </div>
                        <div class="row inner_row_style">
                            <div class="col-sm-6 form-group">
                                <label class="control-label">数量：</label>
                                <div>
                                    <input type="number" id="emptyNumber" name="emptyNumber" min="0"
                                           class="form-control input-border-bottom">
                                </div>
                            </div>
                        </div>
                        <div class="row tow-button-row-style">
                            <div class="col-sm-12">
                                <button type="button" class="btn btn-lg btn-ctl-print" onclick="clickEmptyPalletIn();">
                                    <span class="btn-ctl-color">空托入库</span></button>
                            </div>
                        </div>
                    </div>
                    <div class="tab-pane fade" id="emptyPalletOut">
                        <div class="row tow-button-row-style">
                            <div class="col-sm-12">
                                <button type="button" class="btn btn-lg btn-ctl-print" onclick="clickEmptyPalletOut();">
                                    <span class="btn-ctl-color">空托出库</span></button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('business:ongoodsshelf:edit')}]];
    var removeFlag = [[${@permission.hasPermi('business:ongoodsshelf:remove')}]];
    var prefix = ctx + "business/ongoodsshelf";
    var QrCode = null;
    // 当前物料编码
    var currentGoodsId = "";
    var currentLotId = null;
    var currentNum = 0;
    console.log(ctx)

    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "入库任务单",
            showSearch: false,
            showToggle: false,
            showRefresh: false,
            showColumns: false,
            search: false,
            columns: [
                {
                    field: 'wmsorderid',
                    title: '订单号'
                },
                {
                    field: 'goodsid',
                    title: '物料编码'
                },
                {
                    field: 'goodsname',
                    title: '物料描述',
                    formatter: function (value, row, index) {
                        return $.table.tooltip(value);
                    }

                },
                {
                    field: 'produclotid',
                    title: '生产批号'
                },
                {
                    field: 'productionDate',
                    title: '生产日期'
                },
                {
                    field: 'expirationDate',
                    title: '有效日期'
                },
                {
                    field: 'providerId',
                    title: '供应商编码'
                },
                {
                    field: 'shelfNum',
                    title: '数量'
                },
                {
                    field: 'ctl',
                    title: '托盘号'
                },
                {
                    field: 'agvbgn',
                    title: '站台号'
                },
                {
                    title: '操作',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-danger btn-xs' + '" href="javascript:void(0)" onclick="clearCurrRow()"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    // ERP入库
    function scanFunctionProviderIn() {
        let keycode = event.keyCode;
        console.log(keycode)
        if (keycode == 13) {
            let scanId = $('#scanIdProviderIn').val();
            let scanInfo = scanId.replace(/(\[GS\])|(\[RS\])|(\[EOT\])/g, " ")
            console.log(scanInfo)
            let s = scanInfo.trim();
            let arr = s.split(" ");
            console.log(arr)

            $("#orderNoProviderIn").val(arr[5]);
            $('#providerIdProviderIn').val(arr[1]);
            $('#goodsIdProviderIn').val(arr[0]);
            $('#produclotidProviderIn').val(arr[2]);
            $('#productionDateProviderIn').val(arr[3]);
            $('#expirationDateProviderIn').val(arr[4]);
            $('#shelfNumProviderIn').val(arr[6]);

            // var productionDate = "20" + arr[3].substr(0, 2) + "/" + arr[3].substr(2, 2) + "/" + arr[3].substr(4, 2);
            // var expiryDate = "20" + arr[4].substr(0, 2) + "/" + arr[4].substr(2, 2) + "/" + arr[4].substr(4, 2);
            // // 判断有效日期（有效日期-生产日期），>90天则判断剩余日期是否不足1/2，如果<=90天判断是否不足2/3。
            // var validDate = getDateDiff(productionDate, expiryDate, "day");
            // var remainDate = getDateDiff(new Date(), expiryDate, "day");
            // if (validDate > 90) {
            //     if (remainDate < validDate / 2) {
            //         $.modal.msgError('当前日期距离有效日期小于总有效期的1/2');
            //     }
            // } else {
            //     if (remainDate < validDate / 3) {
            //         $.modal.msgError('当前日期距离有效日期小于总有效期的1/3');
            //     }
            // }

            // QrCode = new Object();
            // QrCode.orderNo = $("#orderNoProviderIn").val();
            // QrCode.providerId = $('#providerIdProviderIn').val();
            // QrCode.goodsId = $('#goodsIdProviderIn').val();
            // QrCode.produclotid = $('#produclotidProviderIn').val();
            // QrCode.productionDate = $('#productionDateProviderIn').val();
            // QrCode.expirationDate = $('#expirationDateProviderIn').val();
        }

    }

    // 无ERP入库
    function scanFunctionNoErp() {
        let keycode = event.keyCode;
        console.log(keycode)
        if (keycode == 13) {
            let scanId = $('#scanIdNoErp').val();
            let scanInfo = scanId.replace(/(\[GS\])|(\[RS\])|(\[EOT\])/g, " ")
            console.log(scanInfo)
            let s = scanInfo.trim();
            let arr = s.split(" ");
            console.log(arr)

            $("#orderNoNoErp").val(arr[5]);
            $('#providerIdNoErp').val(arr[1]);
            $('#goodsIdNoErp').val(arr[0]);
            $('#produclotidNoErp').val(arr[2]);
            $('#productionDateNoErp').val(arr[3]);
            $('#expirationDateNoErp').val(arr[4]);
            $('#shelfNumNoErp').val(arr[6]);

            // var productionDate = "20" + arr[3].substr(0, 2) + "/" + arr[3].substr(2, 2) + "/" + arr[3].substr(4, 2);
            // var expiryDate = "20" + arr[4].substr(0, 2) + "/" + arr[4].substr(2, 2) + "/" + arr[4].substr(4, 2);
            // // 判断有效日期（有效日期-生产日期），>90天则判断剩余日期是否不足1/2，如果<=90天判断是否不足2/3。
            // var validDate = getDateDiff(productionDate, expiryDate, "day");
            // var remainDate = getDateDiff(new Date(), expiryDate, "day");
            // if (validDate > 90) {
            //     if (remainDate < validDate / 2) {
            //         $.modal.msgError('当前日期距离有效日期小于总有效期的1/2');
            //     }
            // } else {
            //     if (remainDate < validDate / 3) {
            //         $.modal.msgError('当前日期距离有效日期小于总有效期的1/3');
            //     }
            // }
            // QrCode = new Object();
            // QrCode.orderNo = $("#orderNoNoErp").val();
            // QrCode.providerId = $('#providerIdNoErp').val();
            // QrCode.goodsId = $('#goodsIdNoErp').val();
            // QrCode.produclotid = $('#produclotidNoErp').val();
            // QrCode.productionDate = $('#productionDateNoErp').val();
            // QrCode.expirationDate = $('#expirationDateNoErp').val();
        }

    }

    function getDateDiff(startTime, endTime, diffType) {
        //将计算间隔类性字符转换为小写
        diffType = diffType.toLowerCase();
        var sTime = new Date(startTime); //开始时间
        var eTime = new Date(endTime); //结束时间
        //作为除数的数字
        var timeType = 1;
        switch (diffType) {
            case"second":
                timeType = 1000;
                break;
            case"minute":
                timeType = 1000 * 60;
                break;
            case"hour":
                timeType = 1000 * 3600;
                break;
            case"day":
                timeType = 1000 * 3600 * 24;
                break;
            default:
                break;
        }
        return parseInt((eTime.getTime() - sTime.getTime()) / parseInt(timeType));
    }

    /** 清楚所有数据 */
    function clear() {
        $("#" + table.options.id).bootstrapTable('removeAll')
        QrCode = null;
        currentLotId = null;
        currentNum = 0;
        currentGoodsId = '';
        clearCodeDate();
    }

    /** 删除当前扫描的数据 */
    function clearCurrRow() {
        $("#" + table.options.id).bootstrapTable('removeAll');
        // 重置当前批次号
        currentLotId = null;
        // 重置当前数量
        currentNum = 0;
        currentGoodsId = '';
        clearCodeDate();
    }

    /** 清楚扫码数据 */
    function clearCodeDate() {
        $("#orderNoProviderIn").val('');
        $('#providerIdProviderIn').val('');
        $('#goodsIdProviderIn').val('');
        $('#produclotidProviderIn').val('');
        $('#productionDateProviderIn').val('');
        $('#expirationDateProviderIn').val('');
        $('#shelfNumProviderIn').val('');
        $('#ctl').val('');
        $("#orderNoNoErp").val('');
        $('#providerIdNoErp').val('');
        $('#goodsIdNoErp').val('');
        $('#produclotidNoErp').val('');
        $('#productionDateNoErp').val('');
        $('#expirationDateNoErp').val('');
        $('#shelfNumNoErp').val('');
        $('#ctlNoErp').val('');
    }

    // 供应商入库
    function clickProviderIn() {
        QrCode = new Object();
        QrCode.orderNo = $("#orderNoProviderIn").val();
        QrCode.providerId = $('#providerIdProviderIn').val();
        QrCode.goodsId = $('#goodsIdProviderIn').val();
        QrCode.produclotid = $('#produclotidProviderIn').val();
        QrCode.productionDate = $('#productionDateProviderIn').val();
        QrCode.expirationDate = $('#expirationDateProviderIn').val();
        // if (!$('#scanIdProviderIn').val()) {
        //     $.modal.msgError('无入库物料信息');
        //     return;
        // }
        // 判断站台是否输入
        if (!$('#inStandProviderIn').val()) {
            $.modal.msgError('未输入站台号');
            return;
        }
        QrCode.converyorId = $('#inStandProviderIn').val();
        // 判断托盘号
        if (!$('#ctl').val()) {
            $.modal.msgError('未扫描托盘码');
            return;
        }
        if ($('#ctl').val().length !== 8) {
            $.modal.msgError('托盘码格式不正确');
            return;
        }
        QrCode.ctl = $('#ctl').val().substring(0, 6);
        // 判断是否是同一物料
        if (currentGoodsId != '' && currentGoodsId != QrCode.goodsId) {
            $.modal.msgError('物料编码不一致');
            return;
        } else {
            currentGoodsId = QrCode.goodsId;
        }
        if (currentLotId != null && currentLotId != $('#produclotidProviderIn').val()) {
            $.modal.msgError('物料批次号不同')
            return;
        } else {
            // 可以更改数量
            QrCode.shelfNum = Number(currentNum) + Number($('#shelfNumProviderIn').val());
            currentNum = QrCode.shelfNum;
            // 更新当前批次号
            currentLotId = QrCode.produclotid;
            // 入库数据插入
            insertTable();
            // 扫码清空
            $('#scanIdProviderIn').val('')
            $('#scanIdProviderIn').focus()
            console.log("创建入库任务成功")
        }
    }

    // 无ERP入库
    function clickNoErp() {
        QrCode = new Object();
        QrCode.orderNo = $("#orderNoNoErp").val();
        QrCode.providerId = $('#providerIdNoErp').val();
        QrCode.goodsId = $('#goodsIdNoErp').val();
        QrCode.produclotid = $('#produclotidNoErp').val();
        QrCode.productionDate = $('#productionDateNoErp').val();
        QrCode.expirationDate = $('#expirationDateNoErp').val();
        // if (!$('#scanIdNoErp').val()) {
        //     $.modal.msgError('无入库物料信息');
        //     return;
        // }
        // 判断站台是否输入
        if (!$('#inStandNoErp').val()) {
            $.modal.msgError('未输入站台号');
            return;
        }
        QrCode.converyorId = $('#inStandNoErp').val();
        // 判断托盘号
        if (!$('#ctlNoErp').val()) {
            $.modal.msgError('未扫描托盘码');
            return;
        }
        if ($('#ctlNoErp').val().length !== 8) {
            $.modal.msgError('托盘码格式不正确');
            return;
        }
        QrCode.ctl = $('#ctlNoErp').val().substring(0, 6);
        // 判断是否是同一物料
        if (currentGoodsId != '' && currentGoodsId != QrCode.goodsId) {
            $.modal.msgError('物料编码不一致');
            return;
        } else {
            currentGoodsId = QrCode.goodsId;
        }
        if (currentLotId != null && currentLotId != $('#produclotidNoErp').val()) {
            $.modal.msgError('物料批次号不同')
            return;
        } else {
            // 可以更改数量
            QrCode.shelfNum = Number(currentNum) + Number($('#shelfNumNoErp').val());
            currentNum = QrCode.shelfNum;
            // 更新当前批次号
            currentLotId = QrCode.produclotid;
            // 入库数据插入
            insertTable();
            // 扫码清空
            $('#scanIdNoErp').val('')
            $('#scanIdNoErp').focus()
            console.log("创建入库任务成功")
        }
    }

    function insertTable() {
        $("#" + table.options.id).bootstrapTable('removeAll');
        $("#" + table.options.id).bootstrapTable('insertRow', {
            index: 0, // 你想插入到哪，0表示第一行
            row: {
                goodsid: QrCode.goodsId,
                providerId: QrCode.providerId,
                shelfNum: currentNum,
                ctl: QrCode.ctl,
                produclotid: currentLotId,
                expirationDate: QrCode.expirationDate,
                productionDate: QrCode.productionDate,
                agvbgn: QrCode.converyorId,
                wmsorderid: QrCode.orderNo,
                onshelfuserid: $('#loginName').text()
            }
        });
    }

    /** 供应商入库（需要对接ebs） */
    function finishIn() {
        console.log("入库开始")
        setTimeout(function () {
            var data = $("#" + table.options.id).bootstrapTable('getData');
            $.ajax({
                type: "post",
                url: ctx + "business/ongoodsshelf/finishIn",
                contentType: "application/json",
                dataType: "json",
                data: JSON.stringify(data),
                success: function (data) {
                    console.log(data)
                    $.modal.msgSuccess(data.msg)
                    clear();
                },
                error: function (data) {
                    $.modal.msgError('错误')
                }
            });
        }, 500)
        console.log("入库结束")
    }

    /** 非ERP入库 */
    function finishInNoErp() {
        console.log("入库开始")
        setTimeout(function () {
            var data = $("#" + table.options.id).bootstrapTable('getData');
            $.ajax({
                type: "post",
                url: ctx + "business/ongoodsshelf/finishNoErpIn",
                contentType: "application/json",
                dataType: "json",
                data: JSON.stringify(data),
                success: function (data) {
                    console.log(data)
                    $.modal.msgSuccess(data.msg)
                    clear();
                },
                error: function (data) {
                    $.modal.msgError('错误')
                }
            });
        }, 500)
        console.log("入库结束")
    }

    // 空托入库
    function clickEmptyPalletIn() {
        console.log("空托入库开始")
        // 判断站台号
        if (!$('#inStandEmpty').val()) {
            $.modal.msgError('请输入站台号');
            return;
        }
        // 判断托盘号
        if (!$('#emptyCtl').val()) {
            $.modal.msgError('请扫描托盘码');
            return;
        }
        // 判断数量
        if (!$('#emptyNumber').val()) {
            $.modal.msgError('请输入托盘数量');
            return;
        }
        $.ajax({
            type: "get",
            url: ctx + "business/ongoodsshelf/emptyPalletIn",
            data: {
                "agvbgn": $('#inStandEmpty').val(),
                "ctl": $('#emptyCtl').val(),
                "shelfNum": $('#emptyNumber').val()
            },
            success: function (data) {
                console.log(data);
                if (data.code == 0) {
                    $.modal.msgSuccess('提交空托入库成功');
                } else {
                    $.modal.msgError('空托入库错误');
                }
            }
        });
    }

    // 空托出库
    function clickEmptyPalletOut() {
        console.log("空托出库开始")
        $.ajax({
            type: "get",
            url: ctx + "business/ongoodsshelf/emptyPalletOut",
            success: function (data) {
                console.log(data);
                // $("#tasklist").html(data);
                if (data.code == 0) {
                    if (data.msg == "0") {
                        $.modal.msgError('当前站台有出库任务未完成');
                    } else {
                        $.modal.msgSuccess('提交空托出库任务成功');
                    }
                } else {
                    $.modal.msgError('错误');
                }
            }
        });
    }
</script>
</body>
</html>
<style>
    .inner_row_style {
        margin-left: 0px;
        margin-right: 0px;
        padding-top: 5px;
    }
</style>