@page
@model Waste.Web.Entry.Pages.Device.ProductModel
@{
    ViewData["Title"] = "标准秤列表";
}
<div class="layui-card">
    <div class="layui-form layui-card-header layuiadmin-card-header-auto">
        <div class="layui-form-item">
            <div class="layui-inline">
                <div class="layui-input-inline">
                    <input type="text" class="layui-input" name="Name" id="Name" placeholder="请输入产品名称" />
                </div>
            </div>
            <div class="layui-inline">
                <button class="btn btn-primary btn-lg  js-search" type="button">查询</button>
                @*<button class="btn btn-primary btn-lg  js-add" type="button">添加</button> *@
            </div>
        </div>
    </div>
    <div class="layui-card-body">
        <table class="layui-table" id="list" lay-filter="list">
        </table>
    </div>
</div>
@section Scripts {
        <script type="text/javascript">
            layui.use(['common'], function () {
                var common = layui.common;
               common.initTable({
                url: '/api/open/getproduct', method: 'post',
                cols: [[
                {
                        field: 'image', title: '图片',templet: function(d) { // 自定义渲染逻辑
                                    return '<img src="' + d.image + '" style="width: 50px; height: 50px;">';
                                }
                },
                {
                    field: 'video', title: '视频'
                },
                {
                    field: 'productname', title: '产品名称'
                },
                {
                    field: 'netweight', title: '净重'
                },
                {
                    field: 'weight', title: '毛重'
                },
                {
                    field: 'amount', title: '数量'
                },
                {
                    field: 'unit', title: '重量单位'
                },
                {
                    field: 'upperlimit', title: '上限'
                },
                {
                    field: 'username', title: '用户名称'
                },
                {
                    field: 'createtime', title: '创建时间'
                },
                ]],
                parseData: function(n) {
                   console.log("接口返回的原始数据：", n);
                   return {
                    data: n.items, // 数据列表在 n.Items 中
                    totalnum: n.totalnum, // 数据总数在 n.totalnum 中
                    statuscode: 200
                  };
                 },
              });
               $(".js-search").on("click", function () {
                    common.reloadtable("list", {
                        where: {
                            queryParam: [{
                                "Name": 'ProductName',
                                "Type": QueryCond.Like,
                                "Value": $("#Name").val()
                            }]
                        }
                    });
                });
            });
        </script>
}