@page
@model Waste.Web.Entry.Pages.Result.IndexModel
@{
    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" value="@Model.defaulttime" data-time="ysdatetime" autocomplete="off" name="time" id="time" placeholder="请选择时间" />
                </div>
            </div>
            <div class="layui-inline">
                <div class="layui-input-inline">
                    <input type="text" class="layui-input" name="FacEcode" id="FacEcode" placeholder="请输入设备编号" />
                </div>
            </div>
            <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>
<script type="text/html" id="optpl">
    <a href="#" class="js-edit" title="编辑" data-id="{{d.id}}">编辑</a>&nbsp;
    @*<a href="#" class="js-delete" title="删除" data-id="{{d.id}}">删除</a>&nbsp;*@
</script>
<script type="text/html" id="netstatustpl">
    {{#if (d.poststatus == 0){ }}
    <span style="color:red;">上报失败</span>
    {{# } else if(d.poststatus == 1){ }}
    <span style="color: #19be6b;">上报成功</span>
    {{# }else{ }}
    <span style="color: #b3b3b3;">未上报</span>
    {{#} }}
</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/result/getlist'
            , method: 'post',
            where: {
                queryParam: queryparam
            }
            , cols: [[
                {
                    field: 'devicefacecode', title: '设备编号'
                },
                {
                    field: 'deviceecode', title: '机器码', hide: true
                },
                {
                    field: 'devicename', title: '设备名称'
                }
                ,
                {
                    field: 'businessname', title: '所属商户'
                }
                //,
                //{
                //    field: 'nettype', title: '联网方式', templet: function (d) {
                //        return DeviceNetType[d.nettype];
                //    }
                //}
                ,
                {
                    field: 'wastetype', title: '物品编码'
                }
                ,
                {
                    field: 'grossweight', title: '毛重(KG)'
                }
                ,
                {
                    field: 'registration', title: '垃圾桶'
                }
                ,
                {
                    field: 'tare', title: '皮重(KG)', hide: true
                }
                ,
                {
                    field: 'netweight', title: '净重(KG)', hide: true
                }
                ,
                {
                    field: 'deviceaddress', title: '地址'
                }
                ,
                {
                    field: 'poststatus', title: '状态', templet:'#netstatustpl'
                }
                ,
                {
                    field: 'createtime', title: '回收时间'
                }
                //,
                //{
                //    title: '操作', templet: "#optpl"
                //}
            ]]
        });
        $(".js-search").on("click", function () {
            var queryparam = [{
                "Name": 'FacEcode',
                "Type": QueryCond.Like,
                "Value": $("#FacEcode").val()
            }, {
                "Name": 'Name',
                "Type": QueryCond.Like,
                "Value": $("#Name").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
                }
            });
        });
    });
    </script>
}
