Merge branch 'develop' of https://git.trustie.net/jacknudt/trustieforge into develop

This commit is contained in:
daiao 2018-02-08 15:12:46 +08:00
commit d54020d32d
4 changed files with 17 additions and 40 deletions

View File

@ -2,7 +2,7 @@ class StatisticsController < ApplicationController
# GET /statistics
# GET /statistics.json
layout 'base_statistic'
before_filter :get_date, :only => [:index, :new, :edit]
before_filter :get_date, :only => [:index, :new]
def index
if params[:sub_category_id].present?
@ -51,7 +51,10 @@ class StatisticsController < ApplicationController
# GET /statistics/1/edit
def edit
@main_categories = MainCategory.all
@statistic = Statistic.find(params[:id])
main_category = MainCategory.find(@statistic.main_category_id)
@sub_categories = main_category.sub_categories
end
# POST /statistics

View File

@ -17,53 +17,27 @@
<%= f.text_field :name, :class => "wb85" %>
<p class="cl" style="padding-left: 10%;color: red;height: 20px"><span id="input_name_notice" class="none">请输入数据名称</span></p>
</div>
<div class="field line_field">
<div class="field line_field mb50">
<label><span>*</span>数据分类:</label>
<%= f.select :main_category_id, (@main_categories.collect { |mc| [mc.name, mc.id] }),
{:no_label => true}, :onchange => 'getSubCategory(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">-->
<!--</ul>-->
<!--</div>-->
<div class="fl pr wb20 ml20 change_sort" id="sub_category">
<%= f.select :sub_category_id, (@sub_categories.collect { |mc| [mc.name, mc.id] }),
{:no_label => true}, :class => "w150" %>
<%#= render :partial => "statistics/sub_category", :locals => { :f => f } %>
<p class="cl" style="padding-left: 10%;color: red;height: 20px"><span id="input_cate_notice" class="none">请选择数据分类</span></p>
<div class="fl pr wb20 ml20 change_sort" id="sub_category" style="display: <%= @sub_categories.blank? ? 'none' : '' %>">
<%= f.select :sub_category_id, (@sub_categories.present? ? @sub_categories.collect { |mc| [mc.name, mc.id] } : []),
{:no_label => true}, :class => "w150" %>
</div>
</div>
<div class="field line_field">
<label>数据描述:</label>
<%= f.text_area :description, :class => "wb85 h200 mb20" %>
<!--<textarea class=""></textarea>-->
</div>
<!--<div class="field line_field">-->
<!--<label>标签:</label>-->
<!--<%#= f.number_field :status %>-->
<!--<div class="tag_modal fl" id="tag_modal">-->
<!--<span class="tag_span">数据结构<input type="hidden" value="数据结构" class="tag_hide"><a class="tag_del ml3" onclick="tag_del(this)">×</a></span>-->
<!--</div>-->
<!--<div class="mr10 save_tag_all none" id="save_tag_all">-->
<!--<input type="text" class="input_tag" id="input_tag"/>-->
<!--<a class="blue_btn_big c_white ml10 fl mr20" href="javascript:void(0)" onclick="save_tag();">确定</a>-->
<!--</div>-->
<!--<a href="javascript:void(0)" onclick="show_inputContent();" class="mb15 c_blue mt6 fl">+&nbsp;标签</a>-->
<!--</div>-->
<div class="field cl">
<%#= f.label :label_attachment_plural %>
<label>&nbsp;</label>
<%= render :partial => 'attachments/form_statistic', :locals => {:container => @statistic, :isReply => @isReply} %>
</div>
<div class="actions cl mb20">
<%#= f.submit %>
<a href="javascript:void(0)" class="blue_btn_big c_white fr mr45" onclick="submit_cate();">保存</a>
<!--<input type="submit" class="blue_btn_big c_white fr mr45" value="保存" onclick="$('#create_new_statis').submit()"/>-->
<%= link_to '取消', statistics_path ,:class=>"grey_btn_big fr c_white mr10" %>
</div>
<% end %>
@ -77,12 +51,8 @@
$("#input_name_notice").removeClass("none");
return;
}
if(cate == ""){
$("#input_cate_notice").removeClass("none");
return;
}
$("#new_statistic").submit();
$("#edit_statistic_1").submit();
$("#edit_statistic_<%= @statistic.id %>").submit();
}
// 获取子类别
function getSubCategory(id){

View File

@ -1,6 +1,5 @@
<h1>Editing statistic</h1>
<div class="banner-big f18 fontGrey3 mb15 fb mt15">
<span>新建</span>
</div>
<%= render 'form' %>
<%= link_to 'Show', @statistic %> |
<%= link_to 'Back', statistics_path %>

View File

@ -1,7 +1,12 @@
<% if @sub_categories.blank? %>
$("#statistic_sub_category_id").hide();
$('#statistic_sub_category_id option:selected').val('');
<% elsif params[:come_from] == "statistics_index" %>
$("#sub_categories_list").html('<%= j(render :partial => "sub_categories_list") %>');
<% else %>
<% if @sub_categories.present? %>
$("#sub_category").show();
<% end %>
$("#statistic_sub_category_id").show();
$("#statistic_sub_category_id").html('<%= escape_javascript( render :partial => 'statistics/sub_category') %>');
<% end %>