返回任务列表页,显示原先搜索的列表结果

This commit is contained in:
郝大全
2018-08-30 23:00:50 +08:00
parent dbcc43aab2
commit c483ab9972
2 changed files with 28 additions and 15 deletions

View File

@@ -13,6 +13,7 @@ import (
"time" "time"
"fmt" "fmt"
"github.com/astaxie/beego" "github.com/astaxie/beego"
"github.com/george518/PPGo_Job/jobs" "github.com/george518/PPGo_Job/jobs"
"github.com/george518/PPGo_Job/models" "github.com/george518/PPGo_Job/models"
@@ -26,6 +27,11 @@ type TaskController struct {
func (self *TaskController) List() { func (self *TaskController) List() {
self.Data["pageTitle"] = "任务管理" self.Data["pageTitle"] = "任务管理"
self.Data["taskGroup"] = taskGroupLists(self.taskGroups, self.userId) 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() self.display()
} }
@@ -488,7 +494,16 @@ func (self *TaskController) Table() {
limit = 30 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") status, _ := self.GetInt("status")
@@ -514,28 +529,26 @@ func (self *TaskController) Table() {
filters = append(filters, "status__in", ids) filters = append(filters, "status__in", ids)
} }
if self.userId != 1 { if groupId > 0 {
groups := strings.Split(self.taskGroups, ",") filters = append(filters, "group_id", groupId)
} else {
if self.userId != 1 {
groups := strings.Split(self.taskGroups, ",")
groupsIds := make([]int, 0) groupsIds := make([]int, 0)
for _, v := range groups { for _, v := range groups {
id, _ := strconv.Atoi(v) id, _ := strconv.Atoi(v)
groupsIds = append(groupsIds, id) groupsIds = append(groupsIds, id)
}
filters = append(filters, "group_id__in", groupsIds)
} }
filters = append(filters, "group_id__in", groupsIds)
} }
if taskName != "" { if taskName != "" {
filters = append(filters, "task_name__icontains", 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...) result, count := models.TaskGetList(page, self.pageSize, filters...)
list := make([]map[string]interface{}, len(result)) list := make([]map[string]interface{}, len(result))
for k, v := range result { for k, v := range result {

View File

@@ -18,7 +18,7 @@
<select name="modules" lay-verify="required" lay-filter="select_group" id="group_id" lay-search=""> <select name="modules" lay-verify="required" lay-filter="select_group" id="group_id" lay-search="">
<option value="">直接选择或搜索选择</option> <option value="">直接选择或搜索选择</option>
{{range $k, $v := .taskGroup}} {{range $k, $v := .taskGroup}}
<option value="{{$k}}">{{$v}}</option> <option value="{{$k}}" {{if eq $k $.groupId}} selected {{end}}>{{$v}}</option>
{{end}} {{end}}
</select> </select>
</div> </div>