数据首页筛选优化

This commit is contained in:
daiao 2018-02-08 16:25:49 +08:00
parent 75f9f867e8
commit afe708eb86
4 changed files with 5 additions and 6 deletions

View File

@ -103,11 +103,11 @@ class StatisticsController < ApplicationController
end
def get_sub_category
if params[:main_category_id] == "-1"
@sub_categories = SubCategory.all
else
if params[:main_category_id].present?
main_category = MainCategory.find(params[:main_category_id])
@sub_categories = main_category.sub_categories
else
@sub_categories = SubCategory.all
end
respond_to do |format|
format.js

View File

@ -6,7 +6,6 @@
<% if @statistic.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@statistic.errors.count, "error") %> prohibited this statistic from being saved:</h2>
<ul>
<% @statistic.errors.full_messages.each do |msg| %>
<li><%= msg %></li>

View File

@ -1,4 +1,4 @@
<span class="active">不限</span>
<span class="active" onclick="get_sub_categories_list('')">不限</span>
<% @sub_categories.each do |mc| %>
<span onclick="get_sub_categories_list(<%= mc.id %>)"><%= mc.name %></span>
<% end %>

View File

@ -3,7 +3,7 @@
<div class="data_half cl">
<span class="fl data_name">数据类型</span>
<div class="fl data_line">
<span class="active" onclick="get_sub_categories(-1)">不限</span>
<span class="active" onclick="get_sub_categories('')">不限</span>
<% @main_categories.each do |mc| %>
<span onclick="get_sub_categories(<%= mc.id %>);"><%= mc.name %></span>
<% end %>