<%@ page import="com.censoft.db.DBUtil" %><%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2020/9/11
  Time: 12:54
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.sql.Connection" %>
<%@ page import="java.util.*" %>
<%@ page import="com.censoft.common.db.ConnectionFactory" %>
<%@ page import="com.censoft.common.base.Pub" %>
<%
    ConnectionFactory cf = new ConnectionFactory();
    Pub pub = new Pub();
    Connection conn = null;
    Vector v_list = null;
    String page_number = pub.trimNull(request.getParameter("page_number"));
    String menu_id = pub.trimNull(request.getParameter("menu_id"));
    if ("".equals(page_number)) page_number = "1";
    String page_size = pub.trimNull(request.getParameter("page_size"));
    if ("".equals(page_size)) page_size = "4";
    try {
        conn = com.censoft.db.DBUtil.getConnection();
        String sql = "select * from   t_book_btn  where menu_id=? order by add_time desc";
        v_list = cf.doQuery(conn, sql, null, new Object[]{menu_id});
        if (v_list == null) {
            out.println("查询用户出错");
            return;
        }
    } catch (Exception e) {
        out.println("查询用户信息异常" + e);
        return;
    } finally {
        if (conn != null) {
            try {
                conn.close();
            } catch (Exception e) {
            }
        }
    }
%>
<div class="page-container">
    <div class="cl pd-5 bg-1 bk-gray mt-20"><span class="l"><a
            href="javascript:;" onclick="member_add('添加按钮','./btn_add-t.jsp?menu_id=<%=menu_id%>','600','300')"
            class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i> 添加按钮</a></span></div>
    <div class="mt-20" id="datalist">
        <table class="table table-border table-bordered table-hover table-bg table-sort">
            <thead>
            <tr class="text-c">
                <th width="25">序号</th>
                <th width="">按钮名称</th>
                <th width="200">按钮NAME</th>
                <th width="130">添加时间</th>
                <th width="100">操作</th>
            </tr>
            </thead>
            <tbody>
            <%
                if (v_list != null && v_list.size() > 0) {
                    for (int i = 0; i < v_list.size(); i++) {
                        Hashtable ht = (Hashtable) v_list.get(i);
                        String btn_name = pub.trimNull((String) ht.get("btn_name"));
                        String add_time = pub.trimNull((String) ht.get("add_time"));
                        String btn_id = pub.trimNull((String) ht.get("btn_id"));
                        String id = pub.trimNull((String) ht.get("id"));
            %>
            <tr class="text-c">
                <td><%=i + 1%>
                </td>
                <td><%=btn_name%>
                </td>
                <td><%=btn_id%>
                </td>
                <td><%=add_time%>
                </td>
                <td class="td-manage">
                    <a
                            title="编辑" href="javascript:;" onclick="member_edit('编辑','./btn_add-t.jsp?action=toupdate&id=<%=id%>&menu_id=<%=menu_id%>','600','','300')"
                            class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">编辑</i></a>
                    <a title="删除" href="javascript:;" onclick="member_del(this,'<%=id%>')" class="ml-5"
                       style="text-decoration:none"><i
                            class="Hui-iconfont">删除</i></a></td>
            </tr>
            <%
                    }
                }
            %>
            </tbody>
        </table>

    </div>
</div>

<script type="text/javascript">


    /*用户-添加*/
    function member_add(title, url, w, h) {
        var abc = layer_show(title, url, w, h);
    }

    /*用户-查看*/
    function member_show(title, url, id, w, h) {
        layer_show(title, url, w, h);
    }

    /*用户-编辑*/
    function member_edit(title, url, id, w, h) {
        layer_show(title, url, w, h);
    }

    /*用户-删除*/
    function member_del(obj, id) {
        layer.confirm('确认要删除吗？', function (index) {
            $.ajax({
                type: 'POST',
                url: './btn_add-t.jsp?action=delete&id=' + id,
                success: function (data) {
                    layer.msg('已删除!', {
                        icon: 1, time: 1000
                    }, function () {
                        window.location.reload();
                    });
                },
                error: function (data) {
                    layer.msg('删除失败!', {
                        icon: 1, time: 1000
                    });
                },
            });
        });
    }
</script>