<%-- 
  Created by IntelliJ IDEA.
  User: 周训凯
  Date: 2019/4/28
  Time: 10:30
  To change this template use File | Settings | File Templates.
--%>

<%@ page contentType="text/html;charset=UTF-8" language="java"  import="com.itheima.po.DormRepair" %> <!-- 设置页面内容类型为HTML并指定字符集为UTF-8，同时导入Java类DormRepair -->
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> <!-- 引入JSTL核心标签库 -->
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%> <!-- 引入JSTL格式化标签库，用于格式化日期等内容 -->

<html>
<head>
    <title>后台登录</title> <!-- 页面标题 -->
    <meta name="renderer" content="webkit|ie-comp|ie-stand"> <!-- 兼容不同浏览器的渲染引擎 -->
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <!-- 兼容性设置，使页面能够在IE的最新版本中正常显示 -->
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" /> <!-- 响应式设计，设置视口 -->
    
    <link rel="icon" href="/images/favicon.ico" sizes="32x32" /> <!-- 页面图标 -->
    <link rel="stylesheet" href="./css/font.css"> <!-- 引入字体样式 -->
    <link rel="stylesheet" href="./css/xadmin.css"> <!-- 引入后台管理系统的CSS样式 -->
    <script type="text/javascript" src="./js/jquery-1.3.2.min.js"></script> <!-- 引入jQuery -->
    <script src="lib/layui/layui.js"></script> <!-- 引入layui框架 -->
    <script type="text/javascript" src="./js/xadmin.js"></script> <!-- 引入后台管理系统的JavaScript -->
    <script src="/layui_exts/excel.js"></script> <!-- 引入Excel导出相关的脚本 -->

    <!-- 样式定义 -->
    <style type="text/css">
        .layui-table{
            text-align: center; <!-- 设置表格内容居中显示 -->
        }
        .layui-table th{
            text-align: center; <!-- 设置表头居中显示 -->
        }
    </style>
</head>

<body>

<!-- 导航条部分 -->
<div class="x-nav">
    <span class="layui-breadcrumb">
        <a href="">首页</a>
        <a href="/findDormRepair">维修信息</a> <!-- 导航菜单 -->
    </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="/findDormRepair" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i> <!-- 刷新按钮 -->
    </a>
</div>

<!-- 页面主体部分 -->
<div class="x-body">
    <div class="layui-row">
        <!-- 搜索表单 -->
        <form class="layui-form layui-col-md12 x-so" action="/findDormRepair">
            <input class="layui-input" placeholder="请输入宿舍编号" name="d_id" id="d_id"> <!-- 宿舍编号搜索框 -->
            <input class="layui-input" placeholder="请输入宿舍楼" name="d_dormbuilding" id="d_dormbuilding"> <!-- 宿舍楼搜索框 -->
            <input class="layui-input" type="hidden" name="pageIndex" value="1"> <!-- 当前页 -->
            <input class="layui-input" type="hidden" name="pageSize" value="3"> <!-- 每页显示的条数 -->
            <button class="layui-btn" lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button> <!-- 提交按钮 -->
        </form>
    </div>

    <!-- 按钮区 -->
    <xblock>
        <button id="addStudnetBtn" class="layui-btn layui-btn-normal"> <i class="layui-icon">&#xe654;</i>添加 </button> <!-- 添加按钮 -->
        <button class="layui-btn layui-btn-warm" lay-filter="toolbarDemo" lay-submit=""><i class="layui-icon">&#xe67c;</i>导出</button> <!-- 导出按钮 -->
        <span class="x-right" style="line-height:40px">共有数据：${di.totalCount} 条</span> <!-- 显示总数据条数 -->
    </xblock>

    <!-- 添加模态框 -->
    <div class="layui-row" id="test" style="display: none;">
        <div class="layui-col-md10">
            <form class="layui-form" id="addEmployeeForm">
                <!-- 宿舍编号输入项 -->
                <div class="layui-form-item">
                    <label class="layui-form-label">宿舍编号：</label>
                    <div class="layui-input-block">
                        <input type="text" name="d_id" class="layui-input" placeholder="请输入宿舍编号"> <!-- 输入框，宿舍编号 -->
                    </div>
                </div>

                <!-- 宿舍楼输入项 -->
                <div class="layui-form-item">
                    <label class="layui-form-label">宿舍楼：</label>
                    <div class="layui-input-block">
                        <input type="text" name="d_dormbuilding" class="layui-input" placeholder="请输入宿舍楼"> <!-- 输入框，宿舍楼 -->
                    </div>
                </div>

                <!-- 维修人员输入项 -->
                <div class="layui-form-item">
                    <label class="layui-form-label">维修人员：</label>
                    <div class="layui-input-block">
                        <input type="text" lay-verify="required" name="r_name"  class="layui-input" placeholder="请输入维修人员"> <!-- 输入框，维修人员 -->
                    </div>
                </div>

                <!-- 报修事由输入项 -->
                <div class="layui-form-item">
                    <label class="layui-form-label">报修事由：</label>
                    <div class="layui-input-block">
                        <input type="text" name="reason" class="layui-input" placeholder="请输入报修事由"> <!-- 输入框，报修事由 -->
                    </div>
                </div>

                <!-- 提交按钮和重置按钮 -->
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button type="button" class="layui-btn layui-btn-normal" lay-submit lay-filter="formDemo">提交</button> <!-- 提交按钮 -->
                        <button type="reset" class="layui-btn layui-btn-primary">重置</button> <!-- 重置按钮 -->
                    </div>
                </div>
            </form>
        </div>
    </div>

    <!-- 表格部分 -->
    <table class="layui-table">
        <thead>
        <tr>
            <!-- 表格头 -->
            <th>ID</th>
            <th>宿舍编号</th>
            <th>宿舍楼</th>
            <th>维修人员</th>
            <th>报修事由</th>
            <th>报修时间</th>
            <th>更新时间</th>
            <th>操作</th>
        </thead>
        <tbody>
        <c:forEach items="${di.list}" var="di">
            <tr>
                <td>${di.r_id}</td>
                <td>${di.d_id}</td>
                <td>${di.d_dormbuilding}</td>
                <td>${di.r_name}</td>
                <td>${di.reason}</td>
                <td><fmt:formatDate pattern="yyyy-MM-dd HH:mm:ss" value="${di.create_time}"/></td> <!-- 格式化报修时间 -->
                <td><fmt:formatDate pattern="yyyy-MM-dd HH:mm:ss" value="${di.update_time}"/></td> <!-- 格式化更新时间 -->
                <td>
                    <a title="编辑" id= "updateEdit" href="/findDormRepairById?r_id=${di.r_id}">
                        <i class="layui-icon">&#xe642;</i>
                    </a>
                    <a title="删除" onclick="member_del(this,'${di.r_id}')" href="javascript:;">
                        <i class="layui-icon">&#xe640;</i>
                    </a>
                </td>
            </tr>
        </c:forEach>
        </tbody>
    </table>

    <!-- 分页按钮部分 -->
    <div class="" >
        <input type="hidden" id="totalPageCount" value="${di.pageTotalCount}"/>
        <c:import url="pageBtn.jsp">
            <c:param name="totalCount" value="${di.totalCount}"/>
            <c:param name="currentPageNo" value="${di.pageIndex}"/>
            <c:param name="totalPageCount" value="${di.pageTotalCount}"/>
        </c:import>
    </div>

    <script>
        layui.config({
            base: 'layui_exts/', <!-- 配置layui的扩展目录 -->
        }).extend({
            excel: 'excel', <!-- 引入Excel导出功能 -->
        });

        layui.use(['jquery', 'excel', 'form', 'layer', 'laydate'], function(){
            var form = layui.form,
                $ = layui.jquery,
                laydate = layui.laydate;
            var excel = parent.layui.excel;

            // 执行日期选择器实例
            laydate.render({
                elem: '#start' //指定元素
            });

            form.on('submit(toolbarDemo)', function(){
                $.ajax({
                    url: '/exportdormrepairlist', <!-- 导出数据请求 -->
                    type: 'post',
                    dataType: 'json',
                    contentType: "application/json; charset=utf-8",
                    success: function (data) {
                        var dt = excel.filterExportData(data, [ /* 导出的数据字段 */ ]);
                        dt.unshift({r_id: 'ID', d_id: '宿舍编号', d_dormbuilding: '宿舍楼', r_name: '维修人员', reason: '报修事由', create_time: '报修时间', update_time: '更新时间'});
                        var colConf = excel.makeColConfig({ /* 设置列宽 */ }, 60);

