From c483ab9972b96c649e0b9a07f741c92353b8bfad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=9D=E5=A4=A7=E5=85=A8?= Date: Thu, 30 Aug 2018 23:00:50 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=94=E5=9B=9E=E4=BB=BB=E5=8A=A1=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E9=A1=B5=EF=BC=8C=E6=98=BE=E7=A4=BA=E5=8E=9F=E5=85=88?= =?UTF-8?q?=E6=90=9C=E7=B4=A2=E7=9A=84=E5=88=97=E8=A1=A8=E7=BB=93=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controllers/task.go | 41 +++++++++++++++++++++++++++-------------- views/task/list.html | 2 +- 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/controllers/task.go b/controllers/task.go index 24f2e5c..7560c52 100644 --- a/controllers/task.go +++ b/controllers/task.go @@ -13,6 +13,7 @@ import ( "time" "fmt" + "github.com/astaxie/beego" "github.com/george518/PPGo_Job/jobs" "github.com/george518/PPGo_Job/models" @@ -26,6 +27,11 @@ type TaskController struct { func (self *TaskController) List() { self.Data["pageTitle"] = "任务管理" self.Data["taskGroup"] = taskGroupLists(self.taskGroups, self.userId) + self.Data["groupId"] = 0 + arr := strings.Split(self.Ctx.GetCookie("groupid"), "|") + if len(arr) > 0 { + self.Data["groupId"], _ = strconv.Atoi(arr[0]) + } self.display() } @@ -488,7 +494,16 @@ func (self *TaskController) Table() { limit = 30 } - groupId, _ := self.GetInt("group_id") + groupId, _ := self.GetInt("group_id", 0) + + if groupId > 0 { + self.Ctx.SetCookie("groupid", strconv.Itoa(groupId)+"|job") + } else { + arr := strings.Split(self.Ctx.GetCookie("groupid"), "|") + if len(arr) > 0 { + groupId, _ = strconv.Atoi(arr[0]) + } + } status, _ := self.GetInt("status") @@ -514,28 +529,26 @@ func (self *TaskController) Table() { filters = append(filters, "status__in", ids) } - if self.userId != 1 { - groups := strings.Split(self.taskGroups, ",") + if groupId > 0 { + filters = append(filters, "group_id", groupId) + } else { + if self.userId != 1 { + groups := strings.Split(self.taskGroups, ",") - groupsIds := make([]int, 0) - for _, v := range groups { - id, _ := strconv.Atoi(v) - groupsIds = append(groupsIds, id) + groupsIds := make([]int, 0) + for _, v := range groups { + id, _ := strconv.Atoi(v) + groupsIds = append(groupsIds, id) + } + filters = append(filters, "group_id__in", groupsIds) } - filters = append(filters, "group_id__in", groupsIds) } if taskName != "" { filters = append(filters, "task_name__icontains", taskName) } - if groupId > 0 { - self.Ctx.SetCookie("group_id", strconv.Itoa(groupId)+"|job") - filters = append(filters, "group_id", groupId) - } - result, count := models.TaskGetList(page, self.pageSize, filters...) - list := make([]map[string]interface{}, len(result)) for k, v := range result { diff --git a/views/task/list.html b/views/task/list.html index d0371d8..4def465 100644 --- a/views/task/list.html +++ b/views/task/list.html @@ -18,7 +18,7 @@