xuzhiheng 5 年之前
父节点
当前提交
19aa377e8a

+ 14 - 0
src/history/historytask.go

@@ -12,6 +12,7 @@ import (
 type HistoryData struct {
 	*xweb.Action
 	historyTask xweb.Mapper `xweb:"/service/history/(.*)"`
+	historyList xweb.Mapper `xweb:"/service/historylog/list"`
 }
 
 func (this *HistoryData) HistoryTask(history_id string) {
@@ -65,3 +66,16 @@ func (this *HistoryData) HistoryTask(history_id string) {
 		log.Println("初始化客户信息失败")
 	}
 }
+
+func (this *HistoryData) HistoryList() {
+	id := this.GetString("id")
+	if this.Method() == "POST" {
+		data, _ := Mgo.Find("historylog", `{"user_id":"`+id+`"}`, `{updatetime: desc}`, nil, false, -1, -1)
+		this.ServeJson(map[string]interface{}{
+			"data": data,
+		})
+	} else {
+		this.T["id"] = id
+		this.Render("private/historylog_list.html", &this.T)
+	}
+}

+ 1 - 1
src/web/templates/private/customer_list.html

@@ -175,6 +175,6 @@
         })
     }
     function historyData(val) {
-        window.location.href = "/service/customer/history?id=" + val
+        window.location.href = "/service/historylog/list?id=" + val
     }
 </script>

+ 129 - 0
src/web/templates/private/historylog_list.html

@@ -0,0 +1,129 @@
+{{include "com/inc.html"}}
+<!-- Main Header -->
+{{include "com/header.html"}}
+<!-- Left side column. 权限菜单 -->
+{{include "com/menu.html"}}
+
+<div class="content-wrapper" id="showbtn">
+    <section class="content-header">
+        <h1>
+            <small><a id="addWork" class="btn btn-primary opr">新增任务</a></small>
+        </h1>
+        <ol class="breadcrumb">
+            <li><a href="#"><i class="fa fa-dashboard"></i> 首页</a></li>
+            <li><a href="/service/historylog/list?id={{.T.id}}"> 记录</a></li>
+        </ol>
+    </section>
+    <!-- Main content -->
+    <section class="content">
+        <div class="row">
+            <div class="col-xs-12">
+                <div class="box">
+                    <div class="box-body">
+                        <table id="dataTable" class="table table-bordered table-hover">
+                            <thead>
+                                <tr>
+                                    <th>序号</th>
+                                    <th>ID</th>
+                                    <th>操作人</th>
+                                    <th>状态</th>
+                                    <th>数据总量</th>
+                                    <th>创建时间</th>
+                                    <th>修改时间</th>
+                                </tr>
+                            </thead>
+                        </table>
+                    </div>
+                    <!-- /.box-body -->
+                </div>
+                <!-- /.box -->
+            </div>
+        </div>
+    </section>
+</div>
+{{include "com/footer.html"}}
+<script>
+    $(function() {
+        ttable = $('#dataTable').DataTable({
+            "paging": true,
+            "lengthChange": false,
+            "searching": false,
+            "ordering": false,
+            "info": true,
+            "autoWidth": false,
+            "ajax": {
+                "url": "/service/historylog/list",
+                "type": "post",
+                "data": {
+                    "id": {{.T.id}}
+                }
+            },
+            "language": {
+                "url": "/dist/js/dataTables.chinese.lang"
+            },
+            "fnDrawCallback": function() {
+                $("ul.pagination").prepend(
+                    "&nbsp;&nbsp;&nbsp;转到第 <input type='text' id='changePage'   style='width:20px;'> 页    <a type='text' href='javascript:void(0);' id='dataTable-btn' style='text-align:center'>GO</a>"
+                );
+                $('#dataTable-btn').click(function(e) {
+                    var redirectpage = 0
+                    if ($("#changePage").val() && $("#changePage").val() > 0) {
+                        var redirectpage = $("#changePage").val() - 1;
+                    }
+                    ttable.page(redirectpage).draw(false);
+                });
+                this.api().column(0).nodes().each(function(cell, i) {
+                    cell.innerHTML = i + 1;
+                });
+            },
+            "columns": [{
+                    "data": null,
+                    width: "5%"
+                },
+                {
+                    "data": "_id"
+                },
+                {
+                    "data": "create_user"
+                },
+                {
+                    "data": "state",
+                    render: function(val) {
+                        var str = "";
+                        if(val === 0){
+                            str = "未执行";
+                        }else if(val === 1){
+                            str = "未完成";
+                        }else if(val === 2){
+                            str = "已完成";
+                        }
+                        return str
+                    }
+                },
+                {
+                    "data": "result_count"
+                },
+                {
+                    "data": "createtime",
+                    render: function(val) {
+                        var dt = new Date()
+                        dt.setTime(parseInt(val) * 1000)
+                        return dt.format("yyyy-MM-dd hh:mm:ss")
+                    }
+                },
+                {
+                    "data": "updatetime",
+                    render: function(val) {
+                        var dt = new Date()
+                        dt.setTime(parseInt(val) * 1000)
+                        return dt.format("yyyy-MM-dd hh:mm:ss")
+                    }
+                }
+            ]
+        });
+        
+        $("#addWork").on("click",function(){
+            window.location.href = "/service/customer/history?id="+ {{.T.id}};
+        })
+    });
+</script>