<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
    <head>
        <script th:replace="common/head"></script>
    </head>
    <body>
    <div class="layui-fluid">
        <div class="layui-card">
            <!-- 查询条件 -->
            <div class="layui-form layui-card-header layuiadmin-card-header-auto"  style="padding:0;">
                <div class="layui-form-item border-b">
                    <div class="layui-inline">
                        <label class="layui-form-label">广告名称</label>
                        <div class="layui-input-block">
                            <input type="text" name="adName" placeholder="请输入" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">发布机构</label>
                        <div class="layui-input-block">
                            <input type="text" name="orgName" placeholder="请输入" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">发布时间</label>
                        <div class="layui-input-block">
                            <input type="text" name="publishTime" class="layui-input" id="date_range" placeholder="请选择发布时间" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">状态</label>
                        <div class="layui-input-block" >
                            <select name="status">
                                <option value="" selected>全部</option>
                                <option value="0" >待投放</option>
                                <option value="1" >投放中</option>
                                <option value="2" >投放结束</option>
                                <option value="-1" >已删除</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-inline" style="margin-left: 38px;">
                        <button class="layui-btn layuiadmin-btn-useradmin"  lay-submit lay-filter="query">查询</button>
                        <button class="layui-btn  layui-btn-primary"  lay-submit lay-filter="reset">重置</button>
                    </div>
                </div>
                <!-- 表格+头部按钮 -->
                <div class="layui-card-body"  style="padding:0;">
                    <table id="data_table" lay-filter="data_table_event"></table>
                </div>
            </div>
            <input type="hidden" name="taskType" th:value="${taskType}" />
            <input type="hidden" name="serialNumber" th:value="${serialNumber}" />
        </div>
    </div>
    </body>

    <!-- 状态 -->
    <script type="text/html" id="status">
        {{#  if(d.status == -1){ }}
        <span style="color: red;" >已删除</span>
        {{#  } else { }}
            {{# var beginTime = new Date(d.beginTime).getTime();  }}
            {{# var newTime = new Date().getTime();  }}
            {{# if(newTime >= beginTime){ }}
                {{# var endTime = new Date(d.endTime).getTime();  }}
                {{# if(endTime > newTime){ }}
                    <span style="color: green;" >投放中</span>
                    {{# d.status = 1; }}
                {{# } else { }}
                    <span style="color: green;" >投放结束</span>
                    {{# d.status = 2; }}
                {{# } }}
            {{# } else { }}
                <span style="color: green;" >待投放</span>
            {{# } }}
        {{#  } }}
    </script>

    <!--操作-->
    <script type="text/html" id="table-operate">
        {{#  if(d.status != -1){ }}
            {{# var beginTime = new Date(d.beginTime).getTime();  }}
            {{# var newTime = new Date().getTime();  }}
            {{# if(newTime >= beginTime){ }}
                {{# var endTime = new Date(d.endTime).getTime();  }}
                {{# if(endTime > newTime){ }}
                    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="delete">删除</a>
                {{# } }}
            {{# } else { }}
                <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="delete">删除</a>
            {{#  } }}
        {{#  } }}
    </script>

    <!-- javascript -->
    <script type="text/javascript" th:src="@{'/layui/layui.js'}"></script>
    <script type="text/javascript">
        layui.config({
            base: '/' //静态资源所在路径
        });
    </script>
    <script type="text/javascript" th:src="@{'/js/ad/device-advert-list.js'}"></script>
</html>
