<%--
  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 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"));
    if ("".equals(page_number)) page_number = "1";
    String page_size = pub.trimNull(request.getParameter("page_size"));
    if ("".equals(page_size)) page_size = "10";
    String zd_id = pub.trimNull(request.getParameter("zd_id"));
    List list_s = new ArrayList();
    try {
        StringBuffer sb = new StringBuffer();
        sb.append("select t1.*,t2.zd_name from zc_zd_col t1 join zc_zd t2 on t1.zd_id=t2.id");
        if(!"".equals(zd_id)){
            sb.append(" where t1.zd_id=? ");
            list_s.add(zd_id);
        }
        sb.append(" order by t1.col_order asc,t1.add_time desc");
        conn = com.censoft.db.DBUtil.getConnection();
        v_list = cf.doPageQueryWithCount(conn, sb.toString(), page_number, page_size, null, list_s.toArray());
        if (v_list == null) {
            out.println("查询出错" + cf.getMsg());
            return;
        }
    } catch (Exception e) {
        out.println("查询异常" + e);
        return;
    } finally {
        if (conn != null) {
            try {
                conn.close();
            } catch (Exception e) {
            }
        }
    }
    Hashtable ht_row = (Hashtable) v_list.get(0);
    String rowCnt = pub.trimNull((String) ht_row.get("ROWCOUNT"));
    String pageCnt = pub.trimNull((String) ht_row.get("PAGECOUNT"));
    String telSegmentUrl="./zd_col_add-t.jsp?zd_id="+zd_id;
%>
<div>
    <a class="btn btn-primary radius" onclick="addRules('新增元素','<%=telSegmentUrl%>');" >
        新增元素
    </a>
</div>
<div class="table-list">
    <table class="table  table-hover table-bg">
        <thead>
        <tr class="text-c">
            <th width="30px">序号</th>
            <th width="150px">字典名称</th>
            <th width="150px">字典元素名称</th>
            <th width="150px">备注</th>
            <th width="50px">操作</th>
        </tr>
        </thead>
        <tbody>
        <%
            if (v_list != null && v_list.size() > 0) {
                for (int i = 1; i < v_list.size(); i++) {
                    Hashtable ht = (Hashtable) v_list.get(i);
                    String id = pub.trimNull((String) ht.get("id"));
                    String zd_name = pub.trimNull((String) ht.get("zd_name"));
                    String col_name = pub.trimNull((String) ht.get("col_name"));
                    String beizhu = pub.trimNull((String) ht.get("beizhu"));
        %>
        <tr <%if(i%2==0){%>id="tr_doub"<%}else{%>id="tr_single"<%}%> class="text-c">
            <td><%=i%>
            </td>
            <td><%=zd_name%>
            </td>
            <td><%=col_name%>
            </td>
            <td><%=beizhu%>
            </td>
            <td>
                <a title="修改" href="javascript:void(0);" onclick="updateById('<%=id%>','<%=zd_id%>');" class="ml-5" >
                    <i class="Hui-iconfont">修改</i>
                </a>
                <a title="删除" href="javascript:void(0);" onclick="deleteById('<%=id%>');" class="ml-5" >
                    <i class="Hui-iconfont">删除</i>
                </a>
            </td>
        </tr>
        <%
                }
            }
        %>
        </tbody>
    </table>
</div>
<jsp:include page="/common/page_ajax.jsp" >
    <jsp:param name="page_number" value="<%=page_number%>" />
    <jsp:param name="rowCnt" value="<%=rowCnt%>" />
    <jsp:param name="page_size" value="<%=page_size%>" />
</jsp:include>
