<!DOCTYPE html>
<html>
<meta charset="UTF-8">
<link rel="stylesheet" href="../../lib/app/css/app.min.css">
<link rel="stylesheet" href="../../lib/simple-line-icons/css/simple-line-icons.css">
<link rel="stylesheet" href="../../lib/bootable/bootstrap-table.css">
<link rel="stylesheet" href="../../lib/webo/css/ui.css">
<link rel="stylesheet" href="../../lib/toastr/toastr.css">
<style>
    .app-content, .app-footer {
        margin-left: 0px;
    }
    .app-content {
        position: absolute;
        top: 42px;
        height: auto;
        width: 100% !important;
    }
    @media (min-width: 768px) {
        .navbar {
            min-height: 40px
        }

        .navbar-nav > li > a {
            font-size: 14px;
            padding-top: 11px;
            padding-bottom: 11px
        }
        .navbar-brand {
            padding-top: 0;
            padding-bottom: 0;
            line-height: 42px;
            height: 42px
        }
    }
</style>
<body>
<div class="app app-header-fixed app-aside-fixed">
    <header id="header" class="app-header navbar" role="menu">
        {{template "com/nav.tpl" .}}
    </header>
    <div id="content" class="app-content" role="main">
        <p class="toolbar">
            <a id="add_item" class="btn btn-primary">新建</a>
            <a class="btn btn-default" href="/product/ui/bom/add">物料新建</a>
            <a class="btn btn-default" href="/product/ui/cost/list">结构成本</a>
            <a class="btn btn-default" href="/product/ui/new/add">new</a>
        </p>
        <div>
            <table id="item_table"
                   data-show-refresh="false"
                   data-show-columns="false"
                   data-show-export="false"
                   data-search="false"
                   data-page-size="100"
                   data-row-style="rowStyleOvertime"
                   data-filter-control="true"
                   data-query-params="queryParams"
                   data-show-footer="true"
                   data-toolbar=".toolbar">
                <thead>
                    <tr>
                    <th data-field="action"
                        data-align="center"
                        data-formatter="actionFormatter"
                        data-events="actionEvents"
                        data-sortable="false"
                        data-width="10px"> [ 操作 ]
                    </th>
                    <th data-field="type" data-filter-control="input" data-sortable="false">产品类型</th>
                    <th data-field="brand" data-filter-control="input" data-sortable="false">品牌</th>
                    <th data-field="name" data-filter-control="input" data-sortable="false">名称</th>
                    <th data-field="specification" data-filter-control="input" data-sortable="false">规格</th>
                    <th data-field="model" data-filter-control="input" data-sortable="false">型号</th>
                    <th data-field="unit" data-filter-control="input" data-sortable="false">计量单位</th>
                    <th data-field="sellingprice" data-filter-control="input" data-sortable="false">销售价格</th>
                    <th data-field="costprice" data-filter-control="input" data-sortable="false">成本价格</th>
                    <th data-field="6" data-filter-control="input" data-sortable="false">手上数量</th>
                    <th data-field="internalnote" data-filter-control="input" data-sortable="false">内部标记</th>
                </tr>
                </thead>
            </table>
        </div>
    </div>
    <!-- /content -->
</div>
<script src="../../lib/app/js/app.min.js"></script>
<script src="../../lib/bootable/bootstrap-table.js"></script>
<script src="../../lib/webo/js/ui.js"></script>
<script src="../../lib/toastr/toastr.js"></script>
<script src="../../lib/jquery/jquery/validate/jquery.metadata.js"></script>
<script src="../../lib/jquery/jquery/jquery.form.js"></script>
<script src="../../lib/jquery/jquery-ui/jquery-ui.min.js"></script>
<script src="../../lib/webo/js/validate.js"></script>
<script>
    var $table = $("#item_table");
    $(function () {
        $table.bootstrapTable({
            url: "/product/item/list",
            method: "post",
            sidePagination: "server",
            pagination: true,
            height: getTableHeight(),
            fixedColumns: true,
            fixedNumber: 1
        });
        $("#add_item").on("click", function () {
            window.location.href = "/product/ui/add"
        });
        $(window).resize(function () {
            $table.bootstrapTable('resetView', {
                height: getTableHeight()
            });
        });
    });
    function getTableHeight() {
        return 800;
        var window_height = $(window).height();
        var obj_off_y = $(".fit-body").offset().top();
        var result_height = window_height - obj_off_y;
        return result_height;
    }
    function refreshContent(options) {
        $table.bootstrapTable("refresh")
    }
    function actionFormatter(value, row) {
        str ='<a class ="update text-primary" href="javascript:" title="修改" style="margin-right: 5px;">修改</a>';
        return str
    }
    window.actionEvents = {
        'click .update': function (e, value, row) {
            window.location = "/product/ui/update?sn=" + row.sn
        }
    }
</script>
</body>
</html>