<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<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">
                    <input id="mercId" name="mercId" type="hidden" th:value="${mercId}">
                    <div class="select-list">
                        <ul>
                            <li>
                                商品名称：<input type="text" name="prodName" placeholder="商品名称">
                            </li>
                            <li>
                                商品属性：<input type="text" name="attrName" placeholder="商品属性">
                            </li>
                            <li>
                                上架状态：
                                <select name="shelf_flag" th:with="type=${@dict.getType('shelf_flag')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                上架时间：
                                <input type="text" class="time-input" placeholder="开始时间" id="shelfTimeFrom" name="params[shelfTimeFrom]"/>
                                <span>-</span>
                                <input type="text" class="time-input" placeholder="结束时间" id="shelfTimeTo" name="params[shelfTimeTo]"/>
                            </li>
                        </ul>
                        <ul>
                            <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="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="addProduct()" shiro:hasPermission="master:product:prod:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="master:product:prod:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
            </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 + "master/merchant/prod";
        var removeFlag = [[${@permission.hasPermi('master:merchant:prod:remove')}]];
        var shelfFlags = [[${@dict.getType('shelf_flag')}]];

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add/{id}",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                uniqueId: "mercProdId",
                modalName: "商品属性",
                columns: [
                    {
                        checkbox: true
                    },
                    {
                        field: 'prodName',
                        title: '商品名称'
                    },
                    {
                        field: 'attrName',
                        title: '属性名称'
                    },
                    {
                        field: 'shelfFlag',
                        title: '上架状态',
                        formatter: function (value, row, index) {
                            return $.table.selectDictLabel(shelfFlags, value);
                        }
                    },
                    {
                        field: 'shelfTime',
                        title: '上架时间'
                    },
                    {
                        title: '操作',
                        align: 'center',
                        formatter: function(value, row, index) {
                            var actions = [];
                            actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.mercProdId + '\')"><i class="fa fa-remove"></i>删除</a> ');
                            return actions.join('');
                        }
                    }
                ]
            };
            $.table.init(options);
        });

        function addProduct() {
            $.modal.open("添加商品", prefix + "/edit/" + $("#mercId").val());
        }
    </script>
</body>
</html>