<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>库存动态</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="../../layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../../layuiadmin/style/admin.css" media="all">
</head>
<body>

<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body">
            <div class="layui-row layui-col-space15">
                <div class="layui-col-md12">
                    <form class="layui-form" lay-filter="query-form-element">
                        <div class="layui-form-item">
                            <div class="layui-inline">
                                <label class="layui-form-label">操作:</label>
                                <div class="layui-input-inline">
                                    <select name="action" id="id_action">
                                        <option value="">全部</option>
                                        <option value="0">直接入库</option>
                                        <option value="1">采购入库</option>
                                        <option value="2">盘盈入库</option>
                                        <option value="3">直接出库</option>
                                        <option value="4">销售出库</option>
                                        <option value="5">盘亏出库</option>
                                        <option value="6">退货</option>
                                        <option value="7">退料</option>
                                    </select>
                                </div>
                            </div>
                            <div class="layui-inline">
                                <label class="layui-form-label">描述:</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="keyword" class="layui-input" autocomplete="off">
                                </div>
                            </div>
                            <div class="layui-inline">
                                <label class="layui-form-label">时间:</label>
                                <div class="layui-input-inline">
                                    <input type="text" class="layui-input" name="happen_time" id="id_happen_time" placeholder=" - ">
                                </div>
                            </div>
                            <div class="layui-inline">
                                <label class="layui-form-label"></label>
                                <button class="layui-btn" lay-submit lay-filter="query-form-element">查询</button>
                            </div>
                        </div>
                    </form>
                    <table class="layui-hide" id="datagrid"></table>
                </div>
            </div>
        </div>
    </div>
</div>

<script src="../../layuiadmin/layui/layui.js?t=1"></script>
<script>
    layui.config({
        base: '../../../layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'table', 'laydate', 'form', 'utils'], function(){
        var $ = layui.$;
        var table = layui.table
            ,laydate = layui.laydate
            ,form = layui.form
            ,utils = layui.utils
            ,admin = layui.admin;

        var data = JSON.parse(JSON.stringify(parent.layui.table.editdata));
        var cols = [];
        cols.push({field:'action_text', title:'操作', width:100, align:'left'}
            ,{field:'create_time', title:'时间', width: 150, align:'left'}
            ,{field:'text', title:'描述', width: 250, align:'left'}
            ,{field:'count', title:'数量', width:80, align:'right'}
            ,{field:'price', title:'单价', width:100, align:'right'});
        if(utils.isHasPermissions('goods.view_goods_cost')){
            cols.push({field:'cost', title:'成本价', width:80, align:'right'})
        }
        cols.push({field:'warehouse_text', title:'仓别', width:120, align:'left'});
        cols.push({field:'cur_count', title:'剩余数量', width:100, align:'right'});
        if(utils.isHasPermissions('goods.view_goods_cost')){
            cols.push({field:'cur_amount', title:'剩余金额', width:130, align:'right'});
        }
        table.render({
            elem: '#datagrid'
            ,url: '/goods/stock_log/?product_id='+data.product_id+'&warehouse_id='+data.warehouse_id
            ,cols: [cols]
            ,page: true
        });

        form.on('submit(query-form-element)', function(data){
            table.reload('datagrid', {
                where: data.field
                ,page:{curr:1}
            });

            return false;
        });

        laydate.render({
            elem: '#id_happen_time'
            ,range: true
        });

    });
</script>
</body>
</html>

