任务列表搜索列表框优化刷新

This commit is contained in:
george
2018-08-31 12:57:41 +08:00
parent c483ab9972
commit 26637736ee
2 changed files with 15 additions and 13 deletions

View File

@@ -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)
}