修复任务列表搜索功能

This commit is contained in:
郝大全
2017-07-18 18:09:21 +08:00
parent 980f49b486
commit 4640d29d7b
2 changed files with 7 additions and 7 deletions

View File

@@ -29,15 +29,15 @@ func (this *TaskController) List() {
page = 1 page = 1
} }
groupId, _ := this.GetInt("groupid") groupId, _ := this.GetInt("groupid")
if groupId>0 { if groupId > 0 {
this.Ctx.SetCookie("groupid", strconv.Itoa(groupId)+"|job") this.Ctx.SetCookie("groupid", strconv.Itoa(groupId)+"|job")
}else { } else {
arr := strings.Split(this.Ctx.GetCookie("groupid"), "|") arr := strings.Split(this.Ctx.GetCookie("groupid"), "|")
groupId,_= strconv.Atoi(arr[0]) groupId, _ = strconv.Atoi(arr[0])
} }
filters := make([]interface{}, 0) filters := make([]interface{}, 0)
if groupId > 0 { if groupId > 0 && groupId!=99 {
filters = append(filters, "group_id", groupId) filters = append(filters, "group_id", groupId)
} }
result, count := models.TaskGetList(page, this.pageSize, filters...) result, count := models.TaskGetList(page, this.pageSize, filters...)
@@ -46,7 +46,7 @@ func (this *TaskController) List() {
// 分组列表 // 分组列表
groups, _ := models.TaskGroupGetList(1, 100) groups, _ := models.TaskGroupGetList(1, 100)
groups_map := make(map[int]string) groups_map := make(map[int]string)
for _,gname := range groups { for _, gname := range groups {
groups_map[gname.Id] = gname.GroupName groups_map[gname.Id] = gname.GroupName
} }
for k, v := range result { for k, v := range result {
@@ -58,7 +58,7 @@ func (this *TaskController) List() {
row["description"] = v.Description row["description"] = v.Description
row["group_id"] = v.GroupId row["group_id"] = v.GroupId
row["group_name"] = groups_map[v.GroupId] row["group_name"] = groups_map[v.GroupId]
row["is_odd"] = k%2 row["is_odd"] = k % 2
e := jobs.GetEntryById(v.Id) e := jobs.GetEntryById(v.Id)
if e != nil { if e != nil {

View File

@@ -39,7 +39,7 @@
<div class=" btn-large pull-right" > <div class=" btn-large pull-right" >
<form method="post" name="s" action="{{urlfor "TaskController.List"}}"> <form method="post" name="s" action="{{urlfor "TaskController.List"}}">
<select name="groupid" class="btn-large form-control"> <select name="groupid" class="btn-large form-control">
<option value="0">全部分组</option> <option value="99">全部分组</option>
{{range $k, $v := .groups}} {{range $k, $v := .groups}}
<option value="{{$v.Id}}" {{if eq $v.Id $.groupid}}selected{{end}} >{{$v.GroupName}}</option> <option value="{{$v.Id}}" {{if eq $v.Id $.groupid}}selected{{end}} >{{$v.GroupName}}</option>
{{end}} {{end}}