<title>库存操作详情表</title>
<!--当前位置开始-->
<div class="layui-card layadmin-header">
    <div class="layui-breadcrumb" lay-filter="breadcrumb">
        <script type="text/html" template lay-done="layui.data.updateMainBreadcrumb();">
        </script>
    </div>
</div>
<!--当前位置结束-->
<style>
    /* 重写样式 */
</style>
<script type="text/html" template lay-type="Post" lay-url="{{ layui.setter.apiUrl }}Api/CoreCmsStockLog/GetIndex" lay-done="layui.data.done(d);">
    <div class="layui-form coreshop-search-form">
        <div class="layui-form-item">
            <div class="layui-inline">
                <div class="layui-input-inline">
                    <input type="text" name="stockId" placeholder="请输入关联单号" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <div class="layui-input-inline">
                    <select name="type">
                        <option value="">请选择类型</option>
                        {{# layui.each(d.data.stockType, function(index, item){ }}
                        <option value="{{ item.value }}">{{ item.description }}</option>
                        {{# }); }}
                    </select>
                </div>
            </div>

            <div class="layui-inline">
                <div class="layui-input-inline" style="width: 260px;">
                    <input type="text" name="createTime" id="searchTime-CoreCmsStock-createTime" placeholder="请输入时间段" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <button class="layui-btn layui-btn-sm" lay-submit lay-filter="LAY-app-CoreCmsStockLog-search"><i class="layui-icon layui-icon-search"></i>筛选</button>
            </div>
        </div>
    </div>
</script>
<div class="table-body">
    <table id="LAY-app-CoreCmsStockLog-tableBox" lay-filter="LAY-app-CoreCmsStockLog-tableBox"></table>
</div>

<script>
    var indexData;
    var debug = layui.setter.debug;
    layui.data.done = function (d) {
        //开启调试情况下获取接口赋值数据
        if (debug) { console.log(d); }

        indexData = d.data;
        layui.use(['index', 'table', 'laydate', 'util', 'coredropdown', 'coreHelper'],
            function () {
                var $ = layui.$
                    , admin = layui.admin
                    , table = layui.table
                    , form = layui.form
                    , laydate = layui.laydate
                    , setter = layui.setter
                    , coreHelper = layui.coreHelper
                    , util = layui.util
                    , view = layui.view;

                laydate.render({
                    elem: '#searchTime-CoreCmsStock-createTime',
                    type: 'datetime',
                    range: '到',
                });

                //重载form
                form.render();
                var where = { productId: d.params.data.id };
                //监听搜索
                form.on('submit(LAY-app-CoreCmsStockLog-search)',
                    function (data) {
                        var field = data.field;
                        field.productId = d.params.data.id;

                        //执行重载
                        table.reload('LAY-app-CoreCmsStockLog-tableBox', { where: field });
                    });
                //数据绑定
                table.render({
                    elem: '#LAY-app-CoreCmsStockLog-tableBox',
                    url: layui.setter.apiUrl + 'Api/CoreCmsStockLog/GetPageList',
                    method: 'POST',
                    where: where,
                    defaultToolbar: ['filter', 'print', 'exports'],
                    height: 'full-289',//面包屑142px,搜索框4行172,3行137,2行102,1行67
                    page: true,
                    limit: 30,
                    limits: [10, 15, 20, 25, 30, 50, 100, 200],
                    text: { none: '暂无相关数据' },
                    cols: [
                        [
                            { field: 'id', title: '序列', width: 40, sort: false },
                            { field: 'stockId', title: '关联单号', sort: false, width: 150 },
                            { field: 'goodsName', title: '商品名称', sort: false },
                            { field: 'spesDesc', title: '货品规格', sort: false },
                            //{ field: 'productId', title: '货品序列', sort: false, width: 105 },
                            //{ field: 'goodsId', title: '商品序列', sort: false, width: 105 },
                            { field: 'sn', title: '货品编码', sort: false, width: 130 },
                            { field: 'bn', title: '商品编码', sort: false, width: 130 },
                            { field: 'nums', title: '数量', sort: false, width: 85 },
                            { field: 'createTime', title: '时间', sort: false, width: 130 },
                        ]
                    ]
                });
                //监听排序事件
                table.on('sort(LAY-app-CoreCmsStockLog-tableBox)', function (obj) {
                    table.reload('LAY-app-CoreCmsStockLog-tableBox', {
                        initSort: obj, //记录初始排序，如果不设的话，将无法标记表头的排序状态。
                        where: { //请求参数（注意：这里面的参数可任意定义，并非下面固定的格式）
                            orderField: obj.field, //排序字段
                            orderDirection: obj.type //排序方式
                        }
                    });
                });

            });
    };
</script>

