<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('选择待入库资产')" />
</head>
<body class="gray-bg">
    <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>资产编码：</label>
                                <input type="text" name="assetCode">
                            </li>
                            <li>
                                <label>资产名称：</label>
                                <input type="text" name="assetName">
                            </li>
                            <li>
                                <label>资产类别：</label>
                                <input type="text" name="categoryName">
                            </li>
                            <li>
                                <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()">
                                    <i class="fa fa-refresh"></i>&nbsp;重置
                                </a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "asset/inbound";
        // 编辑入库单时传入orderId，用于排除当前单据自身占用的资产
        var orderId = [[${orderId}]];

        $(function() {
            var url = prefix + "/availableAssetList";
            if (orderId) {
                url += "?orderId=" + orderId;
            }
            $.table.init({
                url: url,
                showSearch: false,
                showRefresh: true,
                showToggle: false,
                showColumns: false,
                modalName: "待入库资产",
                columns: [{
                    checkbox: true
                },
                {
                    field: "assetCode",
                    title: "资产编码"
                },
                {
                    field: "assetName",
                    title: "资产名称"
                },
                {
                    field: "categoryName",
                    title: "资产类别"
                },
                {
                    field: "specModel",
                    title: "规格型号"
                },
                {
                    field: "brand",
                    title: "品牌"
                },
                {
                    field: "tagCode",
                    title: "RFID标签"
                }]
            });
        });

        /**
         * 父窗口回调入口：返回当前勾选的资产行，由入库单页的 addSelectedAssets 接收并写入明细表。
         */
        function getSelectedAssets() {
            return $("#bootstrap-table").bootstrapTable("getSelections");
        }
    </script>
</body>
</html>
