<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <meta charset="UTF-8">
    <meta name="format-detection" content="telephone=no">
    <th:block th:include="include :: header('商品列表')" />
    <th:block th:include="include :: layout-latest-css" />
    <th:block th:include="include :: ztree-css" />
</head>

<body class="gray-bg">
<div class="ui-layout-center">
    <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse" >
                <div class="query-condition-container">
                    <h4 class="query-condition-title">查询条件</h4>
                    <div class="query-buttons">
                        <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="resetPre()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                    </div>
                </div>
                <form id="SSpglJfspProductinfo-form" class="customize-search-form">
                <div class="customize-form-group-container">

                <div class="customize-form-group">
                    <label>商品编码:</label>
                    <input type="text" class="styled-input" placeholder="请输入商品编码" name="product_code"/>
                </div>

                <div class="customize-form-group">
                    <label>商品名称:</label>
                    <input type="text" class="styled-input" placeholder="请输入商品名称" name="product_name"/>
                </div>
             </div>
             </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.addTab()" shiro:hasPermission="sp:sp:add">
                    <i class="fa fa-plus"></i> 新增商品
                </a>
<!--                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:user:remove">-->
<!--                    <i class="fa fa-remove"></i> 删除-->
<!--                </a>-->

            </div>

            <div class="col-sm-12 select-table table-striped" style="width: 100%; overflow-x: hidden;">
                <table id="bootstrap-table" class="fixed-layout-table" data-reorderable-columns="true"></table>
            </div>
            <!--拖拽表格-->
            <!--<div class="col-sm-12 select-table table-bordered">
                <p class="select-title">按住表格列拖拽</p>
                <table id="bootstrap-table" data-reorderable-columns="true"></table>
            </div>-->
            <!--拖拽表格-->
        </div>
    </div>
</div>

<th:block th:include="include :: footer" />
<th:block th:include="include :: layout-latest-js" />
<th:block th:include="include :: bootstrap-table-fixed-columns-js" />
<!--拖拽表格-->
<script th:src="@{/js/jquery-ui-1.10.4.min.js}"></script>
<th:block th:include="include :: bootstrap-table-reorder-columns-js" />
<!--拖拽表格-->
<th:block th:include="include :: ztree-js" />
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('sp:sp:edit')}]];
    var removeFlag = [[${@permission.hasPermi('sp:sp:remove')}]];
    var prefix = ctx + "sp/sp";
    $(function() {
        var panehHidden = false;
        if ($(this).width() < 1590) {
            panehHidden = true;
        }
        $('body').layout({ initClosed: panehHidden, west__size: 185, resizeWithWindow: false });
        // 回到顶部绑定
        if ($.fn.toTop !== undefined) {
            var opt = {
                win:$('.ui-layout-center'),
                doc:$('.ui-layout-center')
            };
            $('#scroll-up').toTop(opt);
        }
        queryArchivesList();
    });

    function queryArchivesList() {
        var options = {
            url: prefix + "/SPProductinfoList",
            viewUrl: prefix + "/sSpglJfspProductinfoView/{id}",
            createUrl: prefix + "/SPProductAdd",
            updateUrl: prefix + "/SPProductEdit/{id}",
            removeUrl: prefix + "/SPProductRemove",
            /*exportUrl: prefix + "/export",
            importUrl: prefix + "/importData",
            importTemplateUrl: prefix + "/importTemplate",*/
            sortName: "id",
            sortOrder: "asc",
            modalName: "药品",
            fitColumns: true,
            striped: true,
            autoRowHeight: true,
            rowNumbers: true,
            showFooter:true,  //是否显示表格底部区域。
            clickToSelect: true, //是否启用点击行时选中整行的功能。
            singleSelect: false, //是否仅允许选择一行
            fixedColumns: true,
            //fixedNumber: 3,
            fixedRightNumber: 1,
            columns: [{
                checkbox: true
            },
                { field: 'id', title: '主键', align: 'center', visible: false },
                { field: 'product_code', title: '商品编码', align: 'center' },
                { field: 'product_name', title: '商品名称', align: 'center' },
                { field: 'manufacturer', title: '生产厂家', align: 'center' },
                { field: 'product_status', title: '商品状态', align: 'center' },
                { field: 'category_maj', title: '商品大类', align: 'center' },
                { field: 'category_min', title: '商品子类', align: 'center' },
                { field: 'specification', title: '规格', align: 'center' },
                { field: 'packaging', title: '包装', align: 'center' },

                { field: 'reference_purchase_price', title: '参考进价', align: 'center' },
                { field: 'national_negotiated_price', title: '国谈价格', align: 'center' },

                { field: 'storage_category', title: '存储分类', align: 'center' },

                { field: 'approval_number_1', title: '批准文号1', align: 'center' },

                {
                    title: '操作',
                    align: 'center',
                    width: 165,
                    formatter: function(value, row, index) {
                        if (row.id) {
                            var actions = [];
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.editTab(\'' + row.id + '\')"><i class="fa fa-edit"></i>修改</a> ');
                            /*actions.push('<a class="btn btn-info btn-xs" href="javascript:void(0)" onclick="$.operate.view(\'' + row.id + '\')"><i class="fa fa-eye"></i>详情</a> ');*/
                            actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a> ');
                            return actions.join('');
                        } else {
                            return "";
                        }
                    }
                }]
        };
        $.table.init(options);
    }

    /* 自定义重置-表单重置/隐藏框/树节点选择色/搜索 */
    function resetPre() {
        resetDate();
        $("#SSpglJfspProductinfo-form")[0].reset();
        $.table.search();
        _refresh();
    }
    function edit_page(id){
        table.set();
        var url = "/404.html";
        if ($.common.isNotEmpty(id)) {
            url = table.options.updateUrl.replace("{id}", id);
        } else {
            var id = $.common.isEmpty(table.options.uniqueId) ? $.table.selectFirstColumns() : $.table.selectColumns(table.options.uniqueId);
            if (id.length == 0) {
                $.modal.alertWarning("请至少选择一条记录");
                return;
            }
            url = table.options.updateUrl.replace("{id}", id);
        }
        $.modal.openTab("修改" + table.options.modalName, url + "?editTage=1" );
    }

    /* 用户状态显示 */
    function statusTools(row) {
        if (row.status == 1) {
            return '<i class=\"fa fa-toggle-off text-info fa-2x\" onclick="enable(\'' + row.userId + '\')"></i> ';
        } else {
            return '<i class=\"fa fa-toggle-on text-info fa-2x\" onclick="disable(\'' + row.userId + '\')"></i> ';
        }
    }
</script>
</body>

</html>
