@page
@model Waste.Web.Entry.Pages.CountInfo.IndexModel
@{
    ViewData["Title"] = "统计报表";
}
<div class="layui-card">
    <div class="layui-card-header layuiadmin-card-header-auto">
        <h3>昨日整体汇总</h3>
    </div>
    <div class="layui-card-body">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-sm2 layui-col-md2">
                <div class="layui-card">
                    <div class="layui-card-header">
                        商户数量
                    </div>
                    <div class="layui-card-body layuiadmin-card-list">
                        <p class="layuiadmin-big-font">@Model.data.BusinessCnt</p>
                    </div>
                </div>
            </div>
            <div class="layui-col-sm2 layui-col-md2">
                <div class="layui-card">
                    <div class="layui-card-header">
                        设备台数
                    </div>
                    <div class="layui-card-body layuiadmin-card-list">
                        <p class="layuiadmin-big-font">@Model.data.DevCount</p>
                    </div>
                </div>
            </div>
            <div class="layui-col-sm2 layui-col-md2">
                <div class="layui-card">
                    <div class="layui-card-header">
                        测量次数
                    </div>
                    <div class="layui-card-body layuiadmin-card-list">
                        <p class="layuiadmin-big-font">@Model.data.YestodayCount</p>
                    </div>
                </div>
            </div>
            <div class="layui-col-sm2 layui-col-md2">
                <div class="layui-card">
                    <div class="layui-card-header">
                        毛重
                    </div>
                    <div class="layui-card-body layuiadmin-card-list">
                        <p class="layuiadmin-big-font">@Model.data.YestodayWeight</p>
                    </div>
                </div>
            </div>
            <div class="layui-col-sm2 layui-col-md2">
                <div class="layui-card">
                    <div class="layui-card-header">
                        净重
                    </div>
                    <div class="layui-card-body layuiadmin-card-list">
                        <p class="layuiadmin-big-font">@Model.data.YestodayPureWeight</p>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="layui-card">
    <div class="layui-card-header layuiadmin-card-header-auto">
        <h3>七日商户汇总</h3>
    </div>
    <div class="layui-card-body layui-form ">
        <div class="layui-form-item">
            <div class="layui-inline">
                <div class="layui-input-inline">
                    <input type="text" class="layui-input" value="@Model.defaulttime" data-time="ydatetime" autocomplete="off" name="time1" id="time1" placeholder="请选择时间" />
                </div>
            </div>
            <div class="layui-inline">
                <div class="layui-input-inline">
                    <select id="BusinessId1" name="BusinessId1" lay-search>
                        <option value="">请选择商户</option>
                        @foreach (var item in Model.businesslist)
                        {
                            <option value="@item.Id">@item.Name</option>
                        }
                    </select>
                </div>
            </div>
            <div class="layui-inline">
                <div class="layui-input-inline">
                    <select id="WasteType1" name="WasteType1" lay-search>
                        <option value="">请选择物品编码</option>
                        @foreach (var item in Model.wastetypelist)
                        {
                            <option value="@item.Name">@item.Name</option>
                        }
                    </select>
                </div>
            </div>
            <div class="layui-inline">
                <button class="btn btn-primary btn-lg  js-search1" type="button">查询</button>
            </div>
        </div>
        <table class="layui-table" id="list1" lay-filter="list1">
        </table>
    </div>
</div>
<div class="layui-card">
    <div class="layui-card-header layuiadmin-card-header-auto">
        <h3>七日设备汇总</h3>
    </div>
    <div class="layui-card-body layui-form ">
        <div class="layui-form-item">
            <div class="layui-inline">
                <div class="layui-input-inline">
                    <input type="text" class="layui-input" value="@Model.defaulttime" data-time="ydatetime" autocomplete="off" name="time" id="time" placeholder="请选择时间" />
                </div>
            </div>
            <div class="layui-inline">
                <div class="layui-input-inline">
                    <select id="BusinessId" name="BusinessId" lay-search>
                        <option value="">请选择商户</option>
                        @foreach (var item in Model.businesslist)
                        {
                            <option value="@item.Id">@item.Name</option>
                        }
                    </select>
                </div>
            </div>
            <div class="layui-inline">
                <div class="layui-input-inline">
                    <select id="WasteType" name="WasteType" lay-search>
                        <option value="">请选择物品编码</option>
                        @foreach (var item in Model.wastetypelist)
                        {
                            <option value="@item.Name">@item.Name</option>
                        }
                    </select>
                </div>
            </div>
            <div class="layui-inline">
                <div class="layui-input-inline">
                    <input type="text" class="layui-input" name="DevName" id="DevName" placeholder="请输入设备名称" />
                </div>
            </div>
            <div class="layui-inline">
                <button class="btn btn-primary btn-lg  js-search" type="button">查询</button>
            </div>
        </div>
        <table class="layui-table" id="list" lay-filter="list">
        </table>
    </div>
</div>
<script type="text/html" id="lefttoolbar">
    <div id="toolbar">
        合计:<span style="font-size:15px;color:#1798ca"></span>
    </div>
</script>
<script type="text/html" id="lefttoolbar1">
    <div id="toolbar1">
        合计:<span style="font-size:15px;color:#1798ca"></span>
    </div>
</script>
@section Scripts
{
    <script type="text/javascript">
        layui.use(['common'], function () {
            var common = layui.common;
            var queryparam = [];
            var starttime = $("#time").val();
            if (starttime != "") {
                var times = starttime.split('~');
                queryparam.push({
                    "Name": 'createtime',
                    "Type": QueryCond.GreaterThanOrEqual,
                    "Value": times[0].trim()
                });
                queryparam.push({
                    "Name": 'createtime',
                    "Type": QueryCond.LessThanOrEqual,
                    "Value": times[1].trim()
                });
            }
            common.initTable({
                url: '/api/report/getlist'
                , method: 'post',
                toolbar: "#lefttoolbar",
                ondone: function (res, curr, count) {
                    if (count > 0) {
                        var data = res.data[0];
                        $("#toolbar").find("span").text("次数:" + data.totaldaycount + ",毛重:" + data.totaldayweight + "kg,净重:" + data.totaldaypureweight + "kg");
                    } else {
                        $("#toolbar").find("span").text("无");
                    }
                },
                where: {
                    queryParam: queryparam
                }
                , cols: [[
                    {
                        field: 'businessname', title: '商户'
                    },
                    {
                        field: 'wastetype', title: '物品编码'
                    },
                    {
                        field: 'devname', title: '设备'
                    },
                    {
                        field: 'devcode', title: '设备编号', hide: true
                    },
                    {
                        field: 'devaddress', title: '设备地址', hide: false
                    }
                    ,
                    {
                        field: 'daycount', title: '测量次数'
                    }
                    ,
                    {
                        field: 'dayweight', title: '毛重'
                    }
                    ,
                    {
                        field: 'daypureweight', title: '净重'
                    }
                    ,
                    {
                        field: 'createtime', title: '时间', templet: function (d) {
                            return moment(d.createtime).format("YYYY/MM/DD");
                        }
                    }
                ]]
            });
            $(".js-search").on("click", function () {
                var queryparam = [{
                    "Name": 'BusinessId',
                    "Type": QueryCond.Equal,
                    "Value": $("#BusinessId").val()
                }, {
                    "Name": 'DevName',
                    "Type": QueryCond.Like,
                    "Value": $("#DevName").val()
                }, {
                    "Name": 'WasteType',
                    "Type": QueryCond.Equal,
                    "Value": $("#WasteType").val()
                }];
                var starttime = $("#time").val();
                if (starttime != "") {
                    var times = starttime.split('~');
                    queryparam.push({
                        "Name": 'createtime',
                        "Type": QueryCond.GreaterThanOrEqual,
                        "Value": times[0].trim()
                    });
                    queryparam.push({
                        "Name": 'createtime',
                        "Type": QueryCond.LessThanOrEqual,
                        "Value": times[1].trim()
                    });
                }
                common.reloadtable("list", {
                    where: {
                        queryParam: queryparam
                    }
                });
            });

            queryparam = [];
            var starttime = $("#time1").val();
            if (starttime != "") {
                var times = starttime.split('~');
                queryparam.push({
                    "Name": 'createtime',
                    "Type": QueryCond.GreaterThanOrEqual,
                    "Value": times[0].trim()
                });
                queryparam.push({
                    "Name": 'createtime',
                    "Type": QueryCond.LessThanOrEqual,
                    "Value": times[1].trim()
                });
            }
            common.initTable({
                url: '/api/report/getlistbybusiness'
                , method: 'post',
                toolbar: "#lefttoolbar1",
                elem: "#list1",
                id: 'list1',
                ondone: function (res, curr, count) {
                    if (count > 0) {
                        var data = res.data[0];
                        $("#toolbar1").find("span").text("次数:" + data.totaldaycount + ",毛重:" + data.totaldayweight + "kg,净重:" + data.totaldaypureweight + "kg");
                    } else {
                        $("#toolbar1").find("span").text("无");
                    }
                },
                where: {
                    queryParam: queryparam
                }
                , cols: [[
                    {
                        field: 'businessname', title: '商户'
                    },
                    {
                        field: 'wastetype', title: '物品编码'
                    }
                    ,
                    {
                        field: 'daycount', title: '测量次数'
                    }
                    ,
                    {
                        field: 'dayweight', title: '毛重'
                    }
                    ,
                    {
                        field: 'daypureweight', title: '净重'
                    }
                    ,
                    {
                        field: 'createtime', title: '时间', templet: function (d) {
                            return moment(d.createtime).format("YYYY/MM/DD");
                        }
                    }
                ]]
            });
            $(".js-search1").on("click", function () {
                var queryparam = [{
                    "Name": 'BusinessId',
                    "Type": QueryCond.Equal,
                    "Value": $("#BusinessId1").val()
                }, {
                    "Name": 'WasteType',
                    "Type": QueryCond.Equal,
                    "Value": $("#WasteType1").val()
                }];
                var starttime = $("#time1").val();
                if (starttime != "") {
                    var times = starttime.split('~');
                    queryparam.push({
                        "Name": 'createtime',
                        "Type": QueryCond.GreaterThanOrEqual,
                        "Value": times[0].trim()
                    });
                    queryparam.push({
                        "Name": 'createtime',
                        "Type": QueryCond.LessThanOrEqual,
                        "Value": times[1].trim()
                    });
                }
                common.reloadtable("list1", {
                    where: {
                        queryParam: queryparam
                    }
                });
            });
        });
    </script>
}
