From 4504308403bfc9820c93492515841c6fa884b37f Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Sun, 18 Sep 2016 15:16:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=AE=A1=E7=90=86=E5=91=98?= =?UTF-8?q?=E7=95=8C=E9=9D=A2=EF=BC=8C=E9=A1=B9=E7=9B=AE=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E7=9A=84=E6=90=9C=E7=B4=A2=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/admin_controller.rb | 7 ++++++- app/views/admin/projects.html.erb | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 3f49abb23..01f16bc46 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -31,6 +31,7 @@ class AdminController < ApplicationController @no_configuration_data = Redmine::DefaultData::Loader::no_data? end + # 管理员界面 项目列表 def projects =begin @status = params[:status] || 1 @@ -39,7 +40,11 @@ class AdminController < ApplicationController scope = scope.like(params[:name]) if params[:name].present? @projects = scope.where(project_type: Project::ProjectType_project).reorder("created_on desc").all =end - @projects = Project.like(@name).order('created_on desc') + # 搜索功能 + @name = params[:name] || "" + condition = "#{@name.strip}".gsub(" ","") + @projects = Project.like(condition).order('created_on desc') + # 分页 @projects = paginateHelper @projects,30 @page = (params['page'] || 1).to_i - 1 render :action => "projects", :layout => false if request.xhr? diff --git a/app/views/admin/projects.html.erb b/app/views/admin/projects.html.erb index 80cc40fb0..4457eef59 100644 --- a/app/views/admin/projects.html.erb +++ b/app/views/admin/projects.html.erb @@ -18,7 +18,7 @@ - <%= text_field_tag 'name', params[:name], :size => 30 %> + <%= text_field_tag 'name', params[:name], :size => 30, :placeholder => '输入项目名称进行搜索' %> <%= submit_tag l(:button_apply), :class => "small", :name => nil %> <%= link_to l(:button_clear), {:controller => 'admin', :action => 'projects'}, :class => 'icon icon-reload' %>