数据子类别与数据主类别的一些修改
This commit is contained in:
parent
a25dc9d6ce
commit
405b362470
|
@ -2,6 +2,7 @@ class StatisticsController < ApplicationController
|
|||
# GET /statistics
|
||||
# GET /statistics.json
|
||||
layout 'base_statistic'
|
||||
before_filter :get_date, :only => [:index, :new, :edit]
|
||||
|
||||
def index
|
||||
@statistics = Statistic.all
|
||||
|
@ -82,4 +83,16 @@ class StatisticsController < ApplicationController
|
|||
format.json { head :no_content }
|
||||
end
|
||||
end
|
||||
|
||||
def get_sub_category
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def get_date
|
||||
@main_categories = MainCategory.all
|
||||
@sub_categories = params[:main_category_id].present? ? SubCategory.where(:main_category_id => params[:main_category_id]) : SubCategory.all
|
||||
end
|
||||
end
|
||||
|
|
|
@ -18,25 +18,22 @@
|
|||
</div>
|
||||
<div class="field line_field">
|
||||
<label><span>*</span>数据分类:</label>
|
||||
<%= f.select :main_category_id, (@main_categories.collect { |mc| [mc.name, mc.id] }),
|
||||
{:no_label => true}, :onchange => "get_sub_category(this.options[this.options.selectedIndex].value)",
|
||||
:class => "w150" %>
|
||||
<%#= f.text_field :description %>
|
||||
<div class="fl pr wb20 change_sort">
|
||||
<input type="text" placeholder="请选择分类" class="wb100 c_sort_input" id="parent_down"/><span class="down"></span>
|
||||
<ul class="c_sort_list">
|
||||
<li>开发数据1</li>
|
||||
<li>开发数据2</li>
|
||||
<li>开发数据3</li>
|
||||
<li>开发数据4</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="fl pr wb20 ml20 change_sort">
|
||||
<input type="text" placeholder="请选择子类" class="wb100 c_sort_input" id="child_down"/><span class="down"></span>
|
||||
<ul class="c_sort_list">
|
||||
<li>开发数据1</li>
|
||||
<li>开发数据2</li>
|
||||
<li>开发数据3</li>
|
||||
<li>开发数据4</li>
|
||||
</ul>
|
||||
</div>
|
||||
<!--<div class="fl pr wb20 change_sort">-->
|
||||
<!--<input type="text" placeholder="请选择主类别" class="wb100 c_sort_input" id="parent_down"/><span class="down"></span>-->
|
||||
<!--<ul class="c_sort_list">-->
|
||||
|
||||
<!--</ul>-->
|
||||
<!--</div>-->
|
||||
<!--<div class="fl pr wb20 ml20 change_sort">-->
|
||||
<!--<input type="text" placeholder="请选择子类" class="wb100 c_sort_input" id="child_down"/><span class="down"></span>-->
|
||||
<!--<ul class="c_sort_list">-->
|
||||
|
||||
<!--</ul>-->
|
||||
<!--</div>-->
|
||||
</div>
|
||||
<div class="field line_field">
|
||||
<label>数据描述:</label>
|
||||
|
@ -70,6 +67,15 @@
|
|||
</div>
|
||||
|
||||
<script>
|
||||
// 获取子类别
|
||||
function get_sub_category(id) {
|
||||
alert(id);
|
||||
$.ajax({
|
||||
url: <%= get_sub_category_statistics_path %>,
|
||||
type: 'get',
|
||||
data: {main_category_id: id}
|
||||
});
|
||||
}
|
||||
//删除标签
|
||||
function tag_del(item){
|
||||
$(item).parents(".tag_span").remove();
|
||||
|
|
|
@ -4,29 +4,18 @@
|
|||
<span class="fl data_name">数据类型</span>
|
||||
<div class="fl data_line">
|
||||
<span class="active">不限</span>
|
||||
<span>开发数据</span>
|
||||
<span>发布数据</span>
|
||||
<span>应用数据</span>
|
||||
<span>发布数据</span>
|
||||
<span>开发数据</span>
|
||||
<span>发布数据</span>
|
||||
<span>应用数据</span>
|
||||
<span>发布数据</span>
|
||||
<span>开发数据</span>
|
||||
<span>应用数据</span>
|
||||
<% @main_categories.each do |mc| %>
|
||||
<span><%= mc.name %></span>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="data_half cl">
|
||||
<span class="fl data_name">子类型</span>
|
||||
<div class="fl data_line">
|
||||
<span class="active">不限</span>
|
||||
<span>开发数据</span>
|
||||
<span>发布数据</span>
|
||||
<span>应用数据</span>
|
||||
<span>发布数据</span>
|
||||
<span>开发数据</span>
|
||||
<span>发布数据</span>
|
||||
<span>应用数据</span>
|
||||
<% @sub_categories.each do |mc| %>
|
||||
<span><%= mc.name %></span>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="data_half cl">
|
||||
|
|
|
@ -32,7 +32,11 @@ RedmineApp::Application.routes.draw do
|
|||
resources :main_categories
|
||||
|
||||
|
||||
resources :statistics
|
||||
resources :statistics do
|
||||
collection do
|
||||
get 'get_sub_category'
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
mount Mobile::API => '/api'
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
class AddCatogoryToStatistics < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :statistics, :main_category_id, :integer
|
||||
add_column :statistics, :sub_category_id, :integer
|
||||
end
|
||||
end
|
10
db/schema.rb
10
db/schema.rb
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20180207030237) do
|
||||
ActiveRecord::Schema.define(:version => 20180207065530) do
|
||||
|
||||
create_table "activities", :force => true do |t|
|
||||
t.integer "act_id", :null => false
|
||||
|
@ -2642,9 +2642,11 @@ ActiveRecord::Schema.define(:version => 20180207030237) do
|
|||
t.string "name"
|
||||
t.text "description"
|
||||
t.integer "user_id"
|
||||
t.integer "status", :limit => 1, :default => 0
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.integer "status", :limit => 1, :default => 0
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.integer "main_category_id"
|
||||
t.integer "sub_category_id"
|
||||
end
|
||||
|
||||
create_table "student_work_projects", :force => true do |t|
|
||||
|
|
Loading…
Reference in New Issue