displace.html 9.44 KB
<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head>
    <th:block th:include="include :: header" />
    <th:block th:include="include :: select2-css" />
</head>
<body class="white-bg">
<form class="form-horizontal m" id="form-task-emptyIn" th:object="${inventoryTransaction}">
    <span style="color:red;margin-left:16%;">*点击提交后,会生成出库查看任务,要置换的托盘会送下来,置换物料后,将托盘回库,系统将自动为两个物料数据置换</span>
    <br>
    <span style="color:red;margin-left:16%;">*生成有延迟,不要关闭和重复点击,等待几秒</span>
    <br>
    <input id="id" name="id" th:field="*{id}" type="hidden">
    <input id="inventoryDetailId" name="inventoryDetailId" type="hidden">
        <br>
        <div class="form-group">
            <label class="col-sm-3 control-label">原物料颜色:</label>
            <div class="col-sm-7">
                <input id="materialColor" name="materialColor" th:field="*{materialColor}" readonly class="form-control" type="text">
            </div>
            <!--            <input type="button" class="btn-success btn" onclick="selectEmptyOut()" value="选取库存"/>-->
            <button type="button" class="btn btn-primary" onclick="getInventoryTransaction()">查看物料详情</button>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label">置换的物料颜色:</label>
            <div class="col-sm-6">
                <input id="displaceColor" name="displaceColor" readonly class="form-control"  type="text">
            </div>
            <input type="button" class="btn-success btn" onclick="selectInventoryDetail()" value="选取置换的库存"/>
            <button type="button" style="margin-right: 10px" class="btn btn-primary" onclick="getInventoryDetail()">查看物料详情</button>
        </div>
    <div class="form-group">
        <label class="col-sm-3 control-label">置换的数量:</label>
        <div class="col-sm-2">
            <input id="qty" name="qty" class="form-control"  type="text">
        </div>
    </div>

        <div class="form-group">
            <label class="col-sm-3 control-label">出库口:</label>
            <div class="col-sm-2">
                <select id="port" name="port" class="form-control"></select>
            </div>
        </div>


        <div class="col-sm-12 select-info" id="selecttable">
            <table id="bootstrap-table" data-mobile-responsive="true" class="table table-bordered table-hover"></table>
        </div>
        <div class="form-group">
            <div class="form-control-static col-sm-offset-9">
                <button type="submit" class="btn btn-primary" id="btn-submit">提交置换</button>
<!--                <button onclick="$.modal.close()" class="btn btn-danger" type="button">关闭</button>-->
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: select2-js" />
<script th:inline="javascript">
    var prefix = ctx + "inventory/inventoryTransaction";
    var prefix_inventoryDetail = ctx + "inventory/inventoryDetail"
    var prefix_header = ctx + "inventory/inventoryTransaction";
    var inventoryStatus = [[${@dict.getType('inventorySts')}]];
    var company = [[${@companyService.getCode()}]];
    var originalWarehouse = [[${@dict.getType('originalWarehouse')}]];


    function getInventoryTransaction() {
        var id = $("#id").val();
        $.ajax({
            url: prefix + '/inventoryTransactionList',
            type: "post",
            data: {
                "id": id,
            },
            success: function (value) {
                $("#bootstrap-table").bootstrapTable('load', value.data);
            }
        });
    }
    function getInventoryDetail() {
        var inventoryDetailId = $("#inventoryDetailId").val();
        inventoryDetailId==''?$.modal.alertError("请先选取库存"):
        $.ajax({
            url: prefix_inventoryDetail + '/inventoryDetailLook',
            type: "post",
            data: {
                "id": inventoryDetailId
            },
            success: function (value) {
                $("#bootstrap-table").bootstrapTable('load', value.data);
            }
        });
    }

    $("#bootstrap-table").bootstrapTable({
        sortable: true, //排序
        clickToSelect: true,
        exportDataType: "all",  //导出类型basic', 'all', 'selected'.当前页、所有数据、选中数据
        modalName: "入库明细",
        sortName: "lastUpdated",
        sortOrder: "desc",
        iconSize: "outline",
        toolbar: "#toolbar1",
        contentType: "application/x-www-form-urlencoded",
        pagination: true,   // 是否显示分页(*)
        pageNumber: 1,                                      // 初始化加载第一页,默认第一页
        pageSize: 10,                                       // 每页的记录行数(*)
        pageList: [10, 25, 50],                             // 可供选择的每页的行数(*)
        onRefresh: function () {
            loadDetail();
        },
        columns: [

            {
                field: 'materialColor',
                title: '主体颜色'
            },
            {
                field: 'warehouse',
                title: '原仓库',
                align: 'center',
                formatter: function (value, row, index) {
                    return $.table.selectDictLabel(originalWarehouse, value);
                }
            },
            {
                field: 'locationCode',
                title: '库位编号'
            },
            {
                field: 'containerCode',
                title: '容器编号'
            },
            {
                field: 'materialCode',
                title: '物料编码'
            },
            {
                field: 'materialName',
                title: '物料名称'
            },
            {
                field: 'qty',
                title: '库存数量'
            },
            {
                field: 'taskQty',
                title: '预定执行数量(或出库数)'
            },
            {
                field: 'materialSpec',
                title: '物料规格'
            },
            {
                field: 'materialUnit',
                title: '物料单位'
            },
            {
                field: 'receiptCode',
                title: '入库单号'
            },
            {
                field: 'noticeNo',
                title: '通知单号'
            },
            {
                field: 'id',
                title: '库存交易ID或库存明细ID',
                sortable: false
            },
            {
                field: 'inventoryHeaderId',
                title: '库存头ID',
            },
            {
                field: 'created',
                title: '创建时间',
                align: 'center',
            },
            {
                field: 'createdBy',
                title: '创建用户',
                align: 'center',
            },
            {
                field: 'lastUpdated',
                title: '更新时间',
                align: 'center',
            },
        ]
    });

    $("#form-task-emptyIn").validate({
        rules:{
            port:{
                required:true,
            },
        },
        submitHandler: function (form) {
            $("#btn-submit").attr("disabled", true);
            var inventoryDetailId = $("#inventoryDetailId").val();
            var inventoryTransactionId = $("#id").val();
            var port = $("#port").val();
            if (inventoryDetailId === '' || inventoryTransactionId === '') {
                $.modal.alertError("请先选取库存");
                $("#btn-submit").attr("disabled", false);
                return;
            }
            $.ajax({
                url: prefix_header + "/inventoryDisplace",
                type: "post",
                data: {
                    "inventoryTransactionId": inventoryTransactionId,
                    "inventoryDetailId": inventoryDetailId,
                    "port":port
                },
                success: function (result) {
                    // console.log(result)
                    if (result.code === web_status.SUCCESS) {
                        $.modal.enable();
                        $.modal.alertSuccess(result.msg);
                        // $.modal.close();
                    } else if (result.code === web_status.WARNING) {
                        $.modal.enable();
                        $.modal.alertWarning(result.msg)
                    } else {
                        $.modal.enable();
                        $.modal.alertError(result.msg);
                    }
                    $("#btn-submit").attr("disabled", false);
                }
            });
        }
    });

    function selectInventoryDetail() {
        var inventoryTransactionId = $("#id").val();
        var url = prefix_inventoryDetail + "/inventoryDetailChoose?inventoryTransactionId=" + inventoryTransactionId;
        $.modal.openFull("库存选取", url);
    }
    function myFunction() {
        $('#port').select2({
            ajax: {
                url: ctx+'config/station/getAllStation',
                type: 'post',
                // data: {},
                success: function(data) {
                }
            }
        });
    }

    $(function () {
        myFunction();
    })
</script>
</body>
</html>