<!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">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>仓库名称：</label>
                                <input type="text" name="params[storageName]"/>
                            </li>
                            <li>
                                <label>产品名称：</label>
                                <input type="text" id="productName"  name="params[productName]"/>
                            </li>
                            <li>
                                <label>操作类型：</label>
                                <select name="historyType" th:with="type=${@dict.getType('stock_history_type')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li class="select-time">
                                <label>入库/出库日期：</label>
                                <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginHistoryDate]"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endHistoryDate]"/>
                            </li>
                            <li>
                                <label>负责人：</label>
                                <input type="text" name="historyBy"/>
                            </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="btn-group-sm" id="toolbar" role="group">
                <!-- <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="crm:stockHistory:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="crm:stockHistory:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="crm:stockHistory:remove">
                    <i class="fa fa-remove"></i> 删除
                </a> -->
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="crm:stockHistory:export">
                    <i class="fa fa-download"></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 editFlag = [[${@permission.hasPermi('crm:stockHistory:edit')}]];
        var removeFlag = [[${@permission.hasPermi('crm:stockHistory:remove')}]];
        var historyTypeDatas = [[${@dict.getType('stock_history_type')}]];
        var allocationStatusDatas = [[${@dict.getType('allocation_status')}]];
        var productCategoryDatas = [[${@dict.getType('product_category')}]];
        var productUnitDatas = [[${@dict.getType('product_unit')}]];
        var prefix = ctx + "crm/stockHistory";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
		        showSearch: false,
		        showRefresh: false,
		        showToggle: false,
		        showColumns: false,
		        clickToSelect: true,
		        sortName: "createTime",
		        sortOrder: "desc",
                modalName: "库存记录",
                columns: [
                {
                    field: 'historyId',
                    title: '记录ID',
                    visible: false
                },
                {
                    field: 'storageId',
                    title: '仓库ID',
                    visible: false
                },
                {
                    field: 'productId',
                    title: '产品ID',
                    visible: false
                },
                {
                    field : 'product.productName', 
                    title : '产品名称',
		            sortable: true
                },
                {
                    field : 'product.productNo', 
                    title : '产品货号',
		            sortable: true
                },
                {
                    field: 'historyType',
                    title: '操作类型',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(historyTypeDatas, value);
                    },
		            sortable: true
                },
                {
                    field: 'numBefore',
                    title: '操作前数量',
		            sortable: true
                },
                {
                    field : 'storage.storageName', 
                    title : '仓库名称',
		            sortable: true
                },
                {
                    field: 'numAfter',
                    title: '仓库剩余数量',
		            sortable: true
                },
                {
                    field: 'historyDate',
                    title: '入库/出库日期',
		            sortable: true,
                    formatter: function(value, row, index) {
                        return value.substring(0,10);
                     }
                },
                {
                    field: 'historyBy',
                    title: '负责人',
		            sortable: true
                }]
            };
            $.table.init(options);
        });
    </script>
</body>
</html>