shippingCombination.html 11.3 KB
<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<style>
    .table-striped-left{
        width: 49%;
        /*margin-right: 4px;*/
    }
    .table-striped-right{
        /*right: -10px;*/
        width: 50%;
        float: right;
    }
    .info_text{
        float: right;
    }
    .info_text li{
        font-size: 16px;
    }
    .info_text li span{
        font-size: 20px;
        font-weight: bold;
        color: rgb(28,132,198);
    }
    .btn-default {
        color: #333;
        background-color: #fff;
        border-color: #ccc
    }
</style>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 select-info">
            <form id="dept-form">
                <div class="select-list">
                    <ul>
                        <li>
                            出库单号:<input type="text" id="code" name="code" th:value="${code}"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" id="list-btn"><i class="fa fa-search"></i>&nbsp;搜索</a>
                        </li>
                    </ul>
                    <ul class="info_text">
                        <li>物料总数:<span id="shipment_length"></span></li>
                        <li>总单据数量:<span id="qty_length"></span></li>
                        <li>已出库数量:<span id="qtyCompleted_length"></span></li>
                    </ul>
                </div>
            </form>
        </div>
        <div class="col-sm-12 select-info table-striped-left" style="padding-top: 20px;">
            <table id="bootstrap-table" data-mobile-responsive="true" class="table table-bordered  table-hover"></table>
        </div>
        <div class="col-sm-12 select-info table-striped-right">
            <ul class="select-list">
                <li style="display: none">id:<input type="text" id="detailId"  /></li>
                <li>出货数量:<input type="text" id="receiveNum"  /></li>
            </ul>
            <table id="bootstrap-table1" data-mobile-responsive="true" class="table table-bordered table-hover"></table>
        </div>
    </div>
</div>
<div th:include="include :: footer"></div>
<script th:inline="javascript">
    var addFlag = [[${@permission.hasPermi('shipment:shippingCombination:combination')}]];
    var cancelFlag = [[${@permission.hasPermi('shipment:shippingCombination:remove')}]];
    var taskTypeReal=[[${@dict.getType('taskType')}]];
    var containerHeaderStatus = [[${@dict.getType('shipmentContainerHeaderStatus')}]];
    var inventoryStatus = [[${@dict.getType('inventorySts')}]];

    var prefix = ctx + "shipment/shippingCombination";

    var list_select=function(code) {
        $("#bootstrap-table1").bootstrapTable('removeAll');
        $("#bootstrap-table").bootstrapTable('removeAll');
        $.ajax({
            url: prefix + "/listShipmentDetail?code="+code,
            type: 'get',
            success: function (value) {
                let qty_shipment=0;
                let qtyCompleted_shipment=0;
                for (let i=0;i<value.data.length;i++){
                    if(value.data[i].shipQty>value.data[i].requestQty){
                        $("#bootstrap-table").bootstrapTable('insertRow',{index:0,row:{id:value.data[i].id,
                                shipmentId:value.data[i].shipmentId,
                                shipmentCode:value.data[i].shipmentCode,
                                materialCode:value.data[i].materialCode,
                                materialName:value.data[i].materialName,
                                materialSpec:value.data[i].materialSpec,
                                shipQty:value.data[i].shipQty,
                                requestQty:value.data[i].requestQty,
                                inventorySts:value.data[i].inventorySts,
                                materialUnit:value.data[i].materialUnit}});
                    }
                     qty_shipment = qty_shipment + value.data[i].shipQty;
                     qtyCompleted_shipment = qtyCompleted_shipment + value.data[i].requestQty;

                }
                $("#shipment_length").text(value.data.length);
                $("#qty_length").text(qty_shipment);
                $("#qtyCompleted_length").text(qtyCompleted_shipment);
             }
        });
    };


    $("#bootstrap-table").bootstrapTable({
        contentType: "application/x-www-form-urlencoded",
        // search: true, //搜索
        // showRefresh: true,//刷新
        // showToggle:true, //视图切换
        clickToSelect: true,
        // showColumns:true, //列选择
        // detailView:true,
        // showExport: true, //导出
        // exportDataType: "all", //导出类型basic', 'all', 'selected'.当前页、所有数据、选中数据
        modalName: "出库组盘头",
        // sidePagination: "server",
        pagination: true,   // 是否显示分页(*)
        pageNumber: 1,                                      // 初始化加载第一页,默认第一页
        pageSize: 50,                                       // 每页的记录行数(*)
        pageList: [10, 25, 50,100],
        onClickRow:function(row,ele,field){
            let code=$("#code").val();
            $("#detailId").val(row.id);
            $("#receiveNum").val(row.shipQty-row.requestQty);
            $.ajax({
                url:prefix+'/getInventory',
                type:'post',
                data:{
                    code:code,
                    id:row.id
                },
                success:res=>{
                    if(res.code===200){
                        $("#bootstrap-table1").bootstrapTable('load',res.data)
                    }
                    else{
                        $.modal.alertError(res.msg)
                    }
                }
            })
        },
        columns: [
            {
                field : 'id',
                title : '明细id'
            },
            {
                field : 'materialCode',
                title : '物料编码'
            },
            {
                field:"materialName",
                title:"物料名称"
            },
            {
                field:'materialSpec',
                title:"物料规格"
            },
            {
                field : 'shipQty',
                title : '单据数量'
            },
            {
                field : 'requestQty',
                title : '已出数量'
            },
            {
                field : 'inventorySts',
                title : '库存状态',
                formatter: function(value, row, index) {
                    return $.table.selectDictLabel(inventoryStatus, value);
                },
            },
            {
                field : 'materialUnit',
                title : '单位'
            },
            ]
    });

    $("#bootstrap-table1").bootstrapTable({
        clickToSelect: true,
        showColumns:true, //列选择
        modalName: "库存",
        iconSize: "outline",
        toolbar: "#toolbar",
        contentType: "application/x-www-form-urlencoded",
        pagination: true,   // 是否显示分页(*)
        pageNumber: 1,                                      // 初始化加载第一页,默认第一页
        pageSize: 10,                                       // 每页的记录行数(*)
        pageList: [10, 25, 50],
        columns: [
            {
                title: '操作',
                align: 'center',
                events:'operateEvents',
                formatter: function(value, row, index) {
                    let actions = [];
                    actions.push('<a id="cancel" class="btn btn-success btn-xs" style="background-color: #ac2925" href="#" onclick="Combination(\'' + row.id + '\')"><i class="fa fa-edit"></i>组盘</a> ');
                    return actions.join('');
                }
            },
            {
                field : 'id',
                title : 'id'
            },
            {
                field : 'companyCode',
                title : '货主'
            },
            {
                field : 'locationCode',
                title : '库位编号'
            },
            {
                field : 'containerCode',
                title : '容器编号'
            },
            {
                field : 'qty',
                title : '数量'
            },
            {
                field : 'materialCode',
                title : '物料编码'
            },
            {
                field : 'materialName',
                title : '物料名称'
            },
            {
                field : 'materialSpec',
                title : '物料规格'
            },
            {
                field : 'supplierCode',
                title : '供应商编码',
                visible:false
            },
            {
                field : 'inventorySts',
                title : '库存状态' ,
                align: 'center',
                formatter: function(value, row, index) {
                    return $.table.selectDictLabel(inventoryStatus, value);
                }
            },
        ]
    });

    function Combination(id) {
        let num=$("#receiveNum").val();
        let shipmentDetailId=$("#detailId").val();
        $.ajax({
            url:ctx + "shipment/shippingCombination/Addcombination",
            type:'post',
            data:{
                shipmentDetailId:shipmentDetailId,
                inventoryDetailId:id,
                shipQty:num,
            },
            success:function (response) {
                if(response.code===200){
                    $.modal.msgSuccess('成功');
                    $("#list-btn").click();
                }
                else {
                    $.modal.msg(response.msg)
                }
            }
        })
    }

    function submit(url, type, dataType, data,content) {
        $.modal.loading("正在处理中,请稍后...");
        var config = {
            url: url,
            type: type,
            dataType: dataType,
            data: data,
            contentType: content,
            success: function(result) {
                if (result.code == web_status.SUCCESS) {
                    $("#list-btn").click();
                }
                else {
                    $.modal.alertError(result.msg);
                }
                $.modal.closeLoading();
            }
        };
        $.ajax(config)
    }

    function initPage() {
        let auto = localStorage.getItem("auto");
        let shipmentCode = localStorage.getItem("shipmentCode");
        $("#code").val(shipmentCode);
        if (auto == "true")   {
            let  url = prefix + "/autoCombination";
            let  type = "post";
            let  dataType = "json";
            let  data = {"shipmentCode" : shipmentCode};
            submit(url,type,dataType, data);
        }
        else{
            $("#list-btn").click();
        }
        localStorage.removeItem("shipmentCode");
        localStorage.removeItem("auto");
    }

    $(function() {

        $("#list-btn").click(function () {
            list_select($("#code").val());
        });

        initPage();
    });

</script>
</body>
</html>