<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>时间轴</title>
	<link href="../static/css/bootstrap.min.css" th:href="@{/css/bootstrap.min.css}" rel="stylesheet"/>
    <link href="../static/css/font-awesome.min.css" th:href="@{/css/font-awesome.min.css}" rel="stylesheet"/>
    <link href="../static/css/main/animate.min.css" th:href="@{/css/main/animate.min.css}" rel="stylesheet"/>
    <link th:href="@{/css/style.css}" rel="stylesheet"/>
</head>
<body class="gray-bg">
<div th:if="${#lists.isEmpty(todoItemList)}" style="text-align: center; height: 600px; line-height: 600px;">暂无任务</div>
<div th:unless="${#lists.isEmpty(todoItemList)}" class="row animated fadeInRight">
        <div class="ibox float-e-margins">
            <div id="ibox-content">
                <div id="vertical-timeline" class="vertical-container light-timeline">
                     <div th:each="todoItem: ${todoItemList}" class="vertical-timeline-block">
                         <div class="vertical-timeline-icon navy-bg">
                             <i class="fa fa-file-text"></i>
                         </div>
                         <div class="vertical-timeline-content">
                             <h2>【[[${ todoItem.nodeName }]]】[[${ todoItem.itemName }]]</h2>
                             <p style="word-break: break-word;">[[${ todoItem.itemContent }]]
                             </p>
                             <!--<a href="javascript:void(0)" class="btn btn-sm btn-warning" th:onclick="selectUser([[${todoItem.taskId}]])" style="margin-left: 5px;"> 委托</a>-->
                             <a href="javascript:void(0)" class="btn btn-sm btn-primary" th:onclick="showVerifyDialog([[${todoItem.taskId}]], [[${todoItem.module}]], [[${todoItem.taskName}]], [[${todoItem.nodeName}]])"> 办理</a>
                           <span class="vertical-date">
                         	<!--今天--><span class="todoTimeSpan" th:text="${#dates.format(todoItem.todoTime, 'yyyy-MM-dd HH:mm:ss')}"></span> <br>
                         <small th:text="${#dates.format(todoItem.todoTime, 'yyyy-MM-dd HH:mm:ss')}"></small>
                     </span>
                         </div>
                     </div>
                 </div>
             </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script>
        var prefix = ctx + "todoitem";
        $(document).ready(function(){
          transDate();
        });

        function showVerifyDialog(taskId, module, pageName, nodeName) {
            var url = ctx + module + "/showVerifyDialog/" + taskId;
            $.modal.open(nodeName, url);
        }

        function transDate() {
          var $times =document.getElementsByClassName("todoTimeSpan");
          if ($times && $times.length > 0) {
            for (var i = 0; i < $times.length; i++) {
              $time = $times[i];
              var date = $time.innerHTML.trim();
              date = new Date(date);
              var tt = date;
              var days = parseInt((new Date().getTime() - date) / 86400000);
              var today = new Date().getDate();
              var year = tt.getFullYear();
              var mouth = tt.getMonth() + 1;
              var day = tt.getDate();
              var time = tt.getHours() < 10 ? "0" + tt.getHours() : tt.getHours();
              var min = tt.getMinutes() < 10 ? "0" + tt.getMinutes() : tt.getMinutes();
              var result, offset;
              offset = Math.abs(today - day);
              if (days < 4&&offset<4) {
                if (offset === 0) {
                  result = "今天" + time + ":" + min;
                } else if (offset === 1) {
                  result = "昨天" + time + ":" + min;
                } else if (offset === 2) {
                  result = "前天" + time + ":" + min;
                } else if (offset === 3) {
                  result = "3天前" + time + ":" + min;
                }
              } else {
                // result = year + "-" + mouth + "-" + day + " " + time + ":" + min;
                result = "3天以前";
              }
              $time.innerHTML = result;
            }
          }
        }

    </script>
</body>
</html>
