shipmentContainerHeader.html 15.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>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 select-info">
            <ul id="myTab" class="nav nav-tabs">
                <li class="active"><a href="#tabHeader" data-toggle="tab">主表</a></li>
                <li><a href="#tabDetail" data-toggle="tab">明细</a></li>
            </ul>
            <div id="myTabContent" class="tab-content">
                <div class="tab-pane fade in active" id="tabHeader">
                    <div class="col-sm-12 select-info">
                        <form id="shipmentContainerHeader-form" autocomplete="off">
                            <div class="select-list">
                                <ul>
                                    <li>
                                        <label>载具编码:</label>
                                        <input type="text" name="containerCode"/>
                                    </li>
                                    <li>
                                        <label>库位编码:</label>
                                        <input type="text" name="locationCode"/>
                                    </li>
                                    <li>
                                        <label>任务类型:</label>
                                        <select name="taskType"
                                                th:with="type=${@dict.getType('shipmentTaskType')}">
                                            <option value="">所有</option>
                                            <option th:each="e : ${type}" th:text="${e['dictLabel']}"
                                                    th:value="${e['dictValue']}">
                                            </option>
                                        </select>
                                    </li>
                                    <li>
                                        <label>载具任务状态:</label>
                                        <select name="status"
                                                th:with="firstStatus=${@dict.getType('shipmentContainerHeaderStatus')}">
                                            <option value="">所有</option>
                                            <option th:each="e : ${firstStatus}" th:text="${e['dictLabel']}"
                                                    th:value="${e['dictValue']}">
                                            </option>
                                        </select>
                                    </li>
                                    <li>
                                        <label>创 建 人:</label>
                                        <input type="text" name="createdBy"/>
                                    </li>
                                    <li class="select-time">
                                        <label>创建时间: </label>
                                        <input type="text" class="time-input" id="startTime" placeholder="开始时间"
                                               name="createdBegin"/>
                                        <span>-</span>
                                        <input type="text" class="time-input" id="endTime" placeholder="结束时间"
                                               name="createdEnd"/>
                                    </li>
                                    <li style="float: right; margin-right: 45px">
                                        <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()">
                                            <i class="fa fa-search"></i>&nbsp;搜索
                                        </a>
                                        <a class="btn btn-warning btn-rounded btn-sm"
                                           onclick="$.form.reset('shipmentContainerHeader-form')">
                                            <i class="fa fa-refresh"></i>&nbsp;重置
                                        </a>
                                    </li>
                                </ul>
                            </div>
                        </form>
                    </div>
                    <div class="btn-group hidden-xs" id="toolbar" role="group">
                        <a class="btn btn-outline btn-success btn-rounded" onclick="batchCreateTask()"
                           shiro:hasPermission="shipment:container:add">
                            <i class="fa fa-edit"></i> 批量生成任务
                        </a>
                        <a class="btn btn-outline btn-danger btn-rounded" onclick="batchRemoveHead()"
                           shiro:hasPermission="shipment:container:remove">
                            <i class="fa fa-remove"></i> 批量撤销组盘
                        </a>
                    </div>
                    <table id="bootstrap-table" data-mobile-responsive="true"
                           class="table table-bordered table-hover">
                    </table>
                </div>
                <div class="tab-pane fade" id="tabDetail">
                    <div class="btn-group hidden-xs" id="toolbar1" role="group">
                        <a class="btn btn-outline btn-danger btn-rounded" onclick="detailBatRemove()">
                            <i class="fa fa-trash-o"></i> 删除
                        </a>
                    </div>
                    <table id="bootstrap-table1" data-mobile-responsive="true"
                           class="table table-bordered table-hover"></table>
                </div>
            </div>

        </div>
    </div>
</div>
<div th:include="include :: footer"></div>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('shipment:container:edit')}]];
    var removeFlag = [[${@permission.hasPermi('shipment:container:remove')}]];
    var prefix = ctx + "shipment/shipmentContainerHeader"
    var detailPrefix = ctx + "shipment/shipmentContainerDetail";
    var locationCode;
    var shipmentTaskType = [[${@dict.getType('shipmentTaskType')}]];
    var shipmentContainerHeaderStatus = [[${@dict.getType('shipmentContainerHeaderStatus')}]];
    var createTaskFlag = [[${@permission.hasPermi('shipment:container:add')}]]
    var shippingContainerId;

    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            modalName: "出库组盘",
            sortName: "created",
            sortOrder: "desc",
            search: false,
            clickToSelect: true,
            columns: [
                {
                    checkbox: true
                },
                {
                    field: 'id',
                    title: '组盘头id'
                },
                {
                    field: 'locationCode',
                    title: '库位编码',
                    sortable: true
                },
                {
                    field: 'containerCode',
                    title: '载具编码',
                    sortable: true
                },
                {
                    field: 'warehouseId',
                    title: '仓库id',
                    visible: false
                },
                {
                    field: 'warehouseCode',
                    title: '仓库编码',
                    visible: false
                },
                {
                    field: 'port',
                    title: '出库口'
                },
                {
                    field: 'status',
                    title: '载具任务状态',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(shipmentContainerHeaderStatus, value);
                    }, sortable: true
                },
                {
                    field: 'created',
                    title: '创建日期',
                    sortable: true
                },
                {
                    field: 'createdBy',
                    title: '创建人',
                    sortable: true
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        //	actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-info btn-xs " href="#" onclick="detail(\'' + row.id + '\')"><i class="fa fa-list-ul"></i>明细</a> ');
                        if (row.status == 0) {
                            actions.push('<a class="btn btn-success btn-xs ' + createTaskFlag + '" href="#" onclick="chooseStation(\'' + row.id + '\')"><i class="fa fa-cab"></i>生成任务</a> ');
                            actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="#" onclick="removeHead(\'' + row.id + '\')"><i class="fa fa-remove"></i>取消配盘</a>');
                        }
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    $("#bootstrap-table1").bootstrapTable({
        sortable: true, //排序
        showRefresh: true, //刷新
        showToggle: true, //视图切换
        clickToSelect: false,
        showColumns: true, //列选择
        // detailView:true,
        showExport: true, //导出
        exportDataType: "all",  //导出类型basic', 'all', 'selected'.当前页、所有数据、选中数据
        modalName: "出库明细",
        iconSize: "outline",
        toolbar: "#toolbar1",
        contentType: "application/x-www-form-urlencoded",
        columns: [{
            checkbox: true
        },
            {
                field: 'shipmentDetailId',
                title: '明细id',
                sortable: true
            },
            {
                field: 'shipmentCode',
                title: '出库单号'
            },
            {
                field: 'materialCode',
                title: '物料编码',

            },
            {
                field: 'materialName',
                title: '物料名称',

            },
            {
                field: 'project',
                title: '项目号',
            },
            {
                field: 'qty',
                title: '组盘数量',

            },
            {
                field: 'created',
                title: '创建时间',
                sortable: true
            },
            {
                field: 'createdBy',
                title: '创建用户',

            }
        ]
    });

    function createtable(url, shippingContainerId) {
        $("#myTab li").removeClass("active");
        $(".tab-pane").removeClass("in active");
        $("#myTab li:eq(1)").addClass("active");
        $("#tabDetail").addClass("in active");
        $.ajax({
            url: url,
            type: 'post',
            data: {
                shippingContainerId: shippingContainerId
            },
            success: function (value) {
                $("#bootstrap-table1").bootstrapTable('load', value.data);
            }
        })
    }

    /*入库单列表-详细*/
    function detail(id) {
        var url = detailPrefix + '/list/';
        shippingContainerId = id;
        createtable(url, shippingContainerId);
    }


    function chooseStation(id) {
        let url = ctx + "shipment/shippingCombination/chooseStation" + "/" + id;
        $.modal.open("选择站台", url);
    }

    function refresh() {
        $.table.search();
    }

    /* 单个生成任务 */
    function createTask(id) {

        var url = prefix + "/createTask";
        var data = {"ids": id};
        $.operate.post(url, data);
    }

    /* 批量生成任务 */
    function batchCreateTask() {
        var rows = $("#bootstrap-table").bootstrapTable('getSelections');
        if (rows.length == 0) {
            $.modal.alertWarning("请至少选择一条记录");
            return;
        }
        var ids = "";
        for (var i = 0; i < rows.length; i++) {
            if (ids == "") {
                ids = rows[i].id;
            } else {
                ids = ids + "," + rows[i].id;
            }
        }
        chooseStation(ids);
    }

    /* 单个取消组盘 */
    function removeHead(id) {
        $.modal.confirm("确定删除该条明细信息吗?", function () {
            var url = prefix + "/remove";
            var data = {"ids": id};
            submit(url, "post", "json", data, false);
        });
    }

    /* 批量取消组盘 */
    function batchRemoveHead() {
        var rows = $("#bootstrap-table").bootstrapTable('getSelections');
        if (rows.length == 0) {
            $.modal.alertWarning("请至少选择一条记录");
            return;
        }
        $.modal.confirm("确认要撤销选中的" + rows.length + "条组盘吗?", function () {
            var url = prefix + "/remove";
            var ids = "";
            for (var i = 0; i < rows.length; i++) {
                ids = ids + rows[i].id + ","
            }
            var data = {"ids": ids.substring(0, ids.length - 1)};
            $.operate.post(url, data);
            // submit(url, "post", "json", data);
        });
    }

    /* 取消单个组盘明细 */
    function removeDetail(id) {
        $.modal.confirm("确定删除该条明细信息吗?", function () {
            var url = detailPrefix + "/remove";
            var data = {"ids": id};
            submit(url, "post", "json", data, true);
        });
    }

    function submit(url, type, dataType, data, flag) {
        $.modal.loading("正在处理中,请稍后...");
        var config = {
            url: url,
            type: type,
            dataType: dataType,
            data: data,
            success: function (result) {
                if (result.code == web_status.SUCCESS) {
                    $.modal.msgSuccess(result.msg);
                } else {
                    $.modal.alertError(result.msg);
                }
                $.modal.closeLoading();
            }
        };
        if (flag) {
            $.ajax(config).then(function (value) {
                detail(headerId);
                $.table.refresh();
            })
        } else {
            $.ajax(config).then(function (value) {
                $("#bootstrap-table1").bootstrapTable('removeAll');
                $.table.refresh();
            })
        }

    }

    function detailBatRemove() {
        var rows = $("#bootstrap-table1").bootstrapTable('getSelections');
        if (rows.length == 0) {
            $.modal.alertWarning("请至少选择一条记录");
            return;
        }
        $.modal.confirm("确认要撤销选中的" + rows.length + "条组盘吗?", function () {
            var url = detailPrefix + "/remove";
            var ids = "";
            for (var i = 0; i < rows.length; i++) {
                ids = ids + rows[i].id + ","
            }
            var data = {"ids": ids.substring(0, ids.length - 1)};
            $.operate.post(url, data);
        });
    }
</script>
</body>
</html>