dev_aliyun
p31729568 6 years ago
parent d0f4107b9b
commit 8c61d0d819

@ -1,22 +1,31 @@
module EcMajorSchoolsHelper
def total_graduation_count year
g_count = EcGraduationSubitem.where(:ec_graduation_requirement_id => year.ec_graduation_requirements).count
def total_graduation_count(year)
g_count = year.ec_graduation_subitems.count
g_count == 0 ? "--" : g_count
# 36
end
def sigle_graduation_count
'--'
# 30
def sigle_graduation_count(ec_year)
return '--' if ec_year.ec_graduation_subitems.count.zero?
subitem_ids = ec_year.ec_graduation_subitems.reorder(nil).pluck(:id)
relations = EcGraduationRequirementCalculation.joins(ec_course_support: :ec_graduation_subitem_courses).where('ec_graduation_subitem_id in (?)', subitem_ids)
reached_map = relations.where(status: true).group('ec_graduation_subitem_id').count
reached_map.keys.size
end
def total_graduation_course_count ec_year
ec_year.ec_courses.count == 0 ? '--' : ec_year.ec_courses.count
# 64
ec_year.ec_courses.count.zero? ? '--' : ec_year.ec_courses.count
end
def sigle_graduation_course_count
'--'
# 60
def sigle_graduation_course_count(ec_year)
return '--' if ec_year.ec_courses.count.zero?
course_ids = ec_year.ec_courses.map(&:id)
target_count_map = EcCourseTarget.where(ec_course_id: course_ids).group(:ec_course_id).count
ec_year.ec_courses.sum { |course| course.complete_target_count == target_count_map[course.id] ? 1 : 0 }
end
end

@ -9,6 +9,7 @@ class EcYear < ActiveRecord::Base
# 毕业要求
has_many :ec_graduation_requirements, :dependent => :destroy
has_many :ec_graduation_subitems, through: :ec_graduation_requirements
# 培养目标
has_one :ec_training_objective, :dependent => :destroy

@ -27,22 +27,30 @@
<%= courses > 0 ? courses : @btn_text %>
</a>
</span>
<%
reached_graduation_count = sigle_graduation_count(year)
graduation_count = total_graduation_count(year)
graduation_reached = reached_graduation_count.to_i == graduation_count.to_i
reached_course_count = sigle_graduation_course_count(year)
course_count = total_graduation_course_count(year)
%>
<span class="column-6 fl">
<a href="javascript:void(0)" class="color-grey-c" data-tip-down="<%= sigle_graduation_course_count %> 已达成课程 / <%= total_graduation_course_count(year) %> 总课程"><%= sigle_graduation_course_count %> / <%= total_graduation_course_count(year) %></a>
<a href="javascript:void(0)" class="color-grey-c" data-tip-down="<%= reached_course_count %> 已达成课程 / <%= course_count %> 总课程"><%= reached_course_count %> / <%= course_count %></a>
</span>
<span class="column-5 fl edu-txt-center task-hide">
<a href="javascript:void(0)" data-tip-down="<%= sigle_graduation_count %> 已达成毕业要求指标点 / <%= total_graduation_count(year) %> 总毕业要求指标点" class="<%= sigle_graduation_count == total_graduation_count(year) ? 'color-green' : 'color-orange' %>">
<%= sigle_graduation_count %> / <%= total_graduation_count(year) %>
<a href="javascript:void(0)" data-tip-down="<%= reached_graduation_count %> 已达成毕业要求指标点 / <%= graduation_count %> 总毕业要求指标点" class="<%= graduation_count != "--" && graduation_reached ? 'color-green' : 'color-orange' %>">
<%= reached_graduation_count %> / <%= graduation_count %>
</a>
</span>
<span class="column-5 fl edu-txt-center <%= (total_graduation_count(year) != "--" && sigle_graduation_count == total_graduation_count(year)) ? 'color-green' : 'color-orange' %>">
<% if year.ec_courses.count == 0 %>
<span class="column-5 fl edu-txt-center <%= graduation_count != "--" && graduation_reached ? 'color-green' : 'color-orange' %>">
<% if year.ec_courses.count == 0 || graduation_count == "--" %>
--
<% else %>
<%= sigle_graduation_count == total_graduation_count(year) ? '已达成' : '未达成' %>
<%= graduation_reached ? '已达成' : '未达成' %>
<% end %>
</span>
<span class="column-5 fl edu-txt-center <%= (total_graduation_count(year) != "--" && sigle_graduation_count == total_graduation_count(year)) ? 'color-green' : 'color-orange' %>">
<span class="column-5 fl edu-txt-center <%= graduation_count != "--" && graduation_reached ? 'color-green' : 'color-orange' %>">
<!--<span class="fl mr20 mt2">-->
<!--<input type="checkbox" name="role[]" value="9" id="join_course_role_9" class="ml-3 mr5 magic-checkbox" style="float:left; margin-top: 8px;"/>-->
<!--<label class="ListTablecheckbox" for="join_course_role_9"></label>-->

@ -28,21 +28,29 @@
</p>
<div class="minH-560">
<% @years.each do |year| %>
<%
reached_graduation_count = sigle_graduation_count(year)
graduation_count = total_graduation_count(year)
graduation_reached = reached_graduation_count.to_i == graduation_count.to_i
reached_course_count = sigle_graduation_course_count(year)
course_count = total_graduation_course_count(year)
%>
<li class="clearfix">
<span class="column-1"><%= year.year %>年份</span>
<span class="column-2">
<font data-tip-down="<%= sigle_graduation_course_count %> 已达成课程/<%= total_graduation_course_count %> 总课程"><%= sigle_graduation_course_count %>/<%= total_graduation_course_count %></font>
<font data-tip-down="<%= reached_course_count %> 已达成课程/<%= course_count %> 总课程"><%= reached_course_count %>/<%= course_count %></font>
</span>
<span class="column-3 edu-txt-center task-hide">
<font data-tip-down="<%= sigle_graduation_count %> 已达成毕业要求指标点/<%= total_graduation_count %> 总毕业要求指标点" class="<%= sigle_graduation_count == total_graduation_count ? 'color-green' : 'color-orange' %>">
<%= sigle_graduation_count %>/<%= total_graduation_count %></font>
<font data-tip-down="<%= reached_graduation_count %> 已达成毕业要求指标点/<%= graduation_count %> 总毕业要求指标点" class="<%= graduation_reached ? 'color-green' : 'color-orange' %>">
<%= reached_graduation_count %>/<%= graduation_count %></font>
</span>
<span class="column-2 fr edu-txt-center">
<%= link_to '删除', ec_major_ec_year_path(year, :ec_major_id => @ec_major), method: :delete, :class => "mr15 color-grey-c", data: { confirm: '您确定要删除吗' } %>
<a href="javascript:void(0)" data-tip-down="导出本学年所有数据" class="mr15 color-blue">导出</a>
<%= link_to "查看详情", training_objectives_ec_major_ec_year_path(year, :ec_major_id => @ec_major) %>
</span>
<span class="column-2 fr edu-txt-center <%= sigle_graduation_count == total_graduation_count ? 'color-green' : 'color-orange' %>"><%= sigle_graduation_count == total_graduation_count ? '已达成' : '未达成' %></span>
<span class="column-2 fr edu-txt-center <%= graduation_reached ? 'color-green' : 'color-orange' %>"><%= graduation_reached ? '已达成' : '未达成' %></span>
</li>
<% end %>
</div>

Loading…
Cancel
Save