getReceiptSI.html 10.7 KB
<!DOCTYPE HTML>
<html  lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<style></style>
<body class="gray-bg">
<div class="row">
    <div class="col-sm-12 select-info">
        <form class="form-horizontal m" id="form-receiptHeader-add">
            <div class="select-list">
                <ul>
                    <li></li>
                    <li></li>
                    <li>
                        货主:
                        <select id="companyCode" name="companyCode" class="form-control" th:with="companyList=${@companyService.selectCompanyByCurrentUserId()}">
                            <option th:each="company : ${companyList}" th:text="${company['name']}" th:value="${company['code']}" th:attr = " code = ${company['code']}"></option>
                        </select>
                    </li>
                    <li>
                        u8仓库:
                        <select name="uWarehouseCode" id="uWarehouseCode"  class="form-control" th:with="warehouse=${@warehouseWu.selectList()}">
                            <option value="">所有</option>
                            <option th:each="e : ${warehouse}" th:text="${e['uWarehouseName']}" th:value="${e['uWarehouseCode']}" th:attr = " code = ${e['uWarehouseCode']}"></option>
                        </select>
                    </li>
                    <li>
                        产成品入库单单号:
                        <input id="code" name="code" class="form-control" type="text" style="width: 260px">
                    </li>
                </ul>
            </div>
            <div class="select-list">
                <div class="form-control-static col-sm-offset-9">
                    <button type="submit" class="btn btn-primary">提交</button>
                    <button onclick="$.modal.close()" class="btn btn-danger" type="button">关闭</button>
                </div>
            </div>
            <div class="container-div">
                <table id="bootstrap-table" data-mobile-responsive="true" class="table table-bordered table-hover"></table>
            </div>
            <div class="container-div" id="toolbar1" role="group">
                <a class="btn btn-outline btn-success btn-rounded" onclick="receiptDetailPrint()">
                    <i class="fa fa-print"></i> 标签打印
                </a>
                <a class="btn btn-outline btn-primary btn-rounded" onclick="batchReceiptContainer()">
                    <i class="fa fa-save"></i> 批量组盘
                </a>
            </div>
            <div class="container-div">
                <table id="bootstrap-table1" data-mobile-responsive="true" class="table table-bordered table-hover"></table>
            </div>
        </form>
    </div>
</div>
<div th:include="include::footer"></div>
<script type="text/javascript">
    var detailPrefix = ctx + "receipt/receiptDetail";
    var prefix = ctx + "receipt/receiptHeader";
    $("#form-receiptHeader-add").validate({
        submitHandler: function (form) {
            $.ajax({
                cache: true,
                type: "POST",
                url: prefix + "/getReceiptSI",
                data: {
                    "code": $("input[name='code']").val(),
                    "companyCode": $("#companyCode option:selected").attr("code"),
                    "uWarehouseCode":$("#uWarehouseCode option:selected").val()
                },
                async: false,
                error: function (request) {
                    $.modal.alertError("请求失败!");
                },
                success: function (value) {
                    saveSuc(value);
                    let data = value.data;
                    let receiptHeader = data['receiptHeader'];
                    let receiptDetails = data['receiptDetails'];
                    $("#bootstrap-table").bootstrapTable('append',receiptHeader);
                    $("#bootstrap-table1").bootstrapTable('append',receiptDetails);
                }
            });
        }
    });
    function saveSuc(result){
        if (result.code == web_status.FAIL) {
            $.modal.alertError(result.msg);
        }
    }
    function unique(result) {
        return result.filter(function(item, index, arr) {
            //当前元素,在原始数组中的第一个索引==当前索引值,否则返回当前元素
            return result.indexOf(item, 0) === index;
        });
    }
    function batchReceiptContainer(){
        var rows=$("#bootstrap-table1").bootstrapTable('getSelections');
        if (rows.length == 0) {
            $.modal.alertWarning("请至少选择一条记录");
            return;
        }
        debugger;
        var sourceCodes="";
        var result= rows.map(function(row) {
            return row.sourceCode;
        })
        result=unique(result);
        debugger;
        for(var i=0; i<result.length; i++) {
            sourceCodes = sourceCodes + result[i] + ","
        }

        let storage=window.localStorage;
        storage.sourceCodes=sourceCodes;
        createMenuItem(ctx + "receipt/batchReceiving","产成品入库单批量组盘");
        debugger;
        parent.parent.$('.tabReload').click();
    }
    /* 打印*/
    function receiptDetailPrint() {
        var rows=$("#bootstrap-table1").bootstrapTable('getSelections');
        if (rows.length == 0) {
            $.modal.alertWarning("请至少选择一条记录");
            return;
        }
        var ids = "";
        for(var i=0; i<rows.length; i++) {
            ids = ids + rows[i].id + ","
        }

        var url = detailPrefix + "/report/" + ids;
        $.modal.open("历史入库铭牌打印" , url);
    }

    $("#bootstrap-table").bootstrapTable({
        modalName: "产成品入库单",
        sortName: "created",
        sortOrder: "desc",
        search: false,
        pageSize: 10,
        pagination:true,
        columns: [
            {
                field:"cDepName",
                title:"部门名称",
                visible:true
            },
            {
                field : 'sourceCode',
                title : 'U8单号',
                visible:true
            },
            {
                field : 'companyCode',
                title : '货主编码',
                visible:true
            },
            {
                field : 'companyName',
                title : '货主名称',
                sortable:true
            },
            {
                field : 'uWarehouseName',
                title : 'U8仓库',
                sortable:true
            },
            {
                field: 'type',
                title: '类型',
            }
        ]
    });

    $("#bootstrap-table1").bootstrapTable({
        modalName: "入库明细",
        sortName: "moCode",
        sortOrder: "desc",
        search: false,
        pageSize: 10,
        pagination:true,                        // 可供选择的每页的行数(*)
        columns: [
            {
                checkbox: true
            },
            {
                field:"id",
                title:"id",
                visible:false
            },
            {
                field:"moCode",
                title:"工作令号",
                visible:true
            },
            {
                field : 'sourceCode',
                title : 'U8单号',
                visible:true
            },
            {
                field : 'companyCode',
                title : '货主编码',
                visible:true
            },
            {
                field : 'uWarehouseName',
                title : 'U8仓库',
                sortable:true
            },
            {
                field:"materialCode",
                title:"物料编码",
                visible:true
            },
            {
                field : 'materialName',
                title : '物料名称',
                visible:true
            },
            {
                field : 'unit',
                title : '单位',
                visible:true
            },
            {
                field : 'sourceLine',
                title : '上游系统行号',
                sortable:true
            },
            {
                field : 'qty',
                title : '数量',
                sortable:true
            }
        ]

    });



    $(function () {
        //监听浏览器宽度的改变
        window.onresize = function(){
            resize();
        };
        resize();

        //货架input
        $("#code").bind('input propertychange keypress',function (e) {
            let theEvent = e || window.event;
            let code = theEvent.keyCode || theEvent.which || theEvent.charCode;
            if (code === 13) {
                e.preventDefault();
                //回车执行查询
                // getCode();
            }
        });
    });


    function resize(){
        $("#code").focus();
    }

    //货架
    // function getCode() {
    // 	resize();
    // 	let code=$("#code").val();
    // 	if(code){
    // 		$.ajax({
    // 			cache: true,
    // 			type: "POST",
    // 			url: prefix + "/getReceiptSI",
    // 			data:{
    // 				code:code,
    // 			},
    // 			async: false,
    // 			error: function (request) {
    // 				$.modal.alertError("请求失败!");
    // 			},
    // 			success: function (data) {
    // 				$.operate.saveSuccess(data);
    // 			}
    // 		});
    // 	}
    // 	else{
    // 		layer.tips('请输入单号!','#code',{tips:[1,"rgb(28,132,198)"],time:1000,area:'auto',maxWidth: '1000'})
    // 	}
    // }
    $(function () {
        layui.use('laydate', function() {
            var laydate = layui.laydate;
            laydate.render({ elem: '#appointmentTime',min: 0, theme: 'molv' ,type: 'datetime'});
        });

        $("select[name='companyCode']").change(function (e) {
            let companyCode=$("select[name='companyCode'] option:selected").attr('code');
            $.ajax({
                url: ctx + "receipt/receiptHeader/getwarehouse",
                type:'post',
                data:{code:companyCode},
                success:function (response) {
                    if(response.code===200){
                        $("select[name='uWarehouseCode']").children().remove();
                        $("select[name='uWarehouseCode']").append(`<option value="">所有</option>`);
                        for (let item of response.data) {
                            let option=`<option value="${item.uWarehouseCode}">${item.uWarehouseName}</option>`;
                            $("select[name='uWarehouseCode']").append(option);
                        }
                    }
                    else {$.modal.msgError(response.msg)}
                }
            })
        })
    })


</script>

</body>
</html>