<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

    <link rel="stylesheet" type="text/css"
          href="${pageContext.request.contextPath}/static/admin/manage/h-ui/css/H-ui.min.css"/>
    <link rel="stylesheet" type="text/css"
          href="${pageContext.request.contextPath}/static/admin/manage/h-ui.admin/css/H-ui.admin.css"/>
    <link rel="stylesheet" type="text/css"
          href="${pageContext.request.contextPath}/static/admin/manage/Hui-iconfont/1.0.7/iconfont.css"/>
    <link rel="stylesheet" type="text/css"
          href="${pageContext.request.contextPath}/static/admin/manage/icheck/icheck.css"/>
    <link rel="stylesheet" type="text/css"
          href="${pageContext.request.contextPath}/static/admin/manage/h-ui.admin/skin/default/skin.css"
          id="skin"/>
    <link rel="stylesheet" type="text/css"
          href="${pageContext.request.contextPath}/static/admin/manage/h-ui.admin/css/style.css"/>

    <script type="text/javascript"
            src="${pageContext.request.contextPath}/static/admin/manage/js/jquery.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/admin/manage/js/layer.js"></script>

    <title>后台管理</title>
</head>
<script type="application/javascript">
    $(function () {
        $(".ml-51").click(function () {
            var fale = confirm("是否确认删除?");
            if (fale) {
                var id = $(this).attr("id");
                $.post("delPrize.html", {"id": id}, function (date) {
                })
                $("#" + id).remove();
            }
        })
        $(".ml-5").click(function () {
            var id = $(this).attr("id");
            window.location.href = "prizeEdit/" + id;
        })
    })

    function add() {
        window.location.href = "prizeEdit.html";
    }
</script>
<body>
<nav class="breadcrumb">
    <i class="Hui-iconfont">&#xe67f;</i> 首页
    <span class="c-gray en">&gt;</span> 转盘格
    <span class="c-gray en">&gt;</span> 列表
    <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px"
       href="javascript:location.replace(location.href);" title="刷新"><i class="Hui-iconfont">&#xe68f;</i></a>
</nav>
<div class="page-container">
    <div class="cl pd-5 bg-1 bk-gray mt-20">
        <!-- <span class="l">
            <a onclick="datadel()" class="btn btn-danger radius"><i class="Hui-iconfont">&#xe6e2;</i> 批量删除</a>
            <a class="btn btn-primary radius" href="zhuanadd.html"><i class="Hui-iconfont">&#xe600;</i> 添加</a>
        </span>  -->
        <span class="r">共有数据：<strong>${prizecount}</strong> 条</span>
    </div>
    <div class="mt-20">
        <table class="table table-border table-bordered table-bg table-hover table-sort">
            <thead>
            <tr class="text-c">
                <th width="40"><input id="sltall" type="checkbox"></th>
                <th width="80">ID</th>
                <th>奖品名称</th>
                <th>奖品数量</th>
                <th>中奖率</th>
                <th width="200">更新时间</th>
                <th width="100">操作</th>
            </tr>
            </thead>
            <tbody>
            <c:forEach items="${prizeList}" var="prizeList">
                <tr class="text-c" id="${prizeList.pid}">
                    <td><input name="allid" type="checkbox" value="1"></td>
                    <td>${prizeList.pid}</td>
                    <td class="text-l">${prizeList.pname}</td>
                    <td class="text-l">${prizeList.pnub}</td>
                    <td class="text-l">${prizeList.prate}</td>
                    <td>${prizeList.pdate}</td>
                    <td class="td-manage">
                        <a style="text-decoration:none" class="ml-5" href="#" title="编辑" id="${prizeList.pid}"><i
                                class="Hui-iconfont">&#xe6df;</i></a>
                    </td>
                </tr>
            </c:forEach>
            </tbody>
        </table>
    </div>
</div>
<script type="text/javascript">
    /*图片-删除*/
    function picture_del(obj, id) {
        layer.confirm('确认要删除吗？', function (index) {
            $.post("delzhuan.html", {id: id}, function (data) {
                if (data.is) {
                    $(obj).parents("tr").remove();
                    layer.msg(data.msg, {icon: 1, time: 1000});
                } else {
                    layer.msg(data.msg, {icon: 2, time: 1000});
                }
            }, "json");
        });
    }

    //全选与反选
    $("#sltall").click(function () {
        if ($(this).prop("checked")) {
            $("[name='allid']").prop("checked", true);//全选
        } else {
            $("[name='allid']").prop("checked", false);//取消全选
        }
    });

    //批量删除
    function datadel() {
        //jquery获取复选框值
        var chk_value = [];//定义一个数组
        $('input[name="allid"]:checked').each(function () {
            chk_value.push($(this).val());
        });
        if (chk_value == '') {
            layer.msg("请选择你要删除的信息！", {icon: 2, time: 1000});
        } else {
            layer.confirm('确认要删除所选中的吗？', function (index) {
                $.post("delzhuans.html", {ids: chk_value.join(",")}, function (data) {
                    if (data.is) {
                        layer.alert(data.msg, {skin: 'layui-layer-molv', closeBtn: 0, anim: 4}, function () {
                            window.location = window.location;
                        });
                    } else {
                        layer.msg(data.msg, {icon: 2, time: 1000});
                    }
                }, "json");
            });
        }
    }
</script>
</body>
</html>