From 26637736ee12f8cb5a7b817ed62dbe6561b3749d Mon Sep 17 00:00:00 2001 From: george Date: Fri, 31 Aug 2018 12:57:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E5=88=97=E8=A1=A8=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=E5=88=97=E8=A1=A8=E6=A1=86=E4=BC=98=E5=8C=96=E5=88=B7?= =?UTF-8?q?=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controllers/task.go | 22 +++++++++++++--------- views/task/list.html | 6 ++---- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/controllers/task.go b/controllers/task.go index 7560c52..2af5141 100644 --- a/controllers/task.go +++ b/controllers/task.go @@ -494,17 +494,22 @@ func (self *TaskController) Table() { limit = 30 } - groupId, _ := self.GetInt("group_id", 0) + groupId, _ := self.GetInt("group_id", -1) - if groupId > 0 { - self.Ctx.SetCookie("groupid", strconv.Itoa(groupId)+"|job") - } else { + //0-全部,-1如果存在,n,如果不存在,0 + + if groupId == -1 { + groupId = 0 arr := strings.Split(self.Ctx.GetCookie("groupid"), "|") if len(arr) > 0 { groupId, _ = strconv.Atoi(arr[0]) } } + if groupId > 0 { + self.Ctx.SetCookie("groupid", strconv.Itoa(groupId)+"|job") + } + status, _ := self.GetInt("status") taskName := strings.TrimSpace(self.GetString("taskName")) @@ -528,10 +533,8 @@ func (self *TaskController) Table() { ids := []int{0, 1} filters = append(filters, "status__in", ids) } - - if groupId > 0 { - filters = append(filters, "group_id", groupId) - } else { + //搜索全部 + if groupId == 0 { if self.userId != 1 { groups := strings.Split(self.taskGroups, ",") @@ -542,8 +545,9 @@ func (self *TaskController) Table() { } filters = append(filters, "group_id__in", groupsIds) } + } else if groupId > 0 { + filters = append(filters, "group_id", groupId) } - if taskName != "" { filters = append(filters, "task_name__icontains", taskName) } diff --git a/views/task/list.html b/views/task/list.html index 4def465..0fcd852 100644 --- a/views/task/list.html +++ b/views/task/list.html @@ -16,7 +16,7 @@ {{/**/}}