user center project package list

project_pack
p31729568 5 years ago
parent 17231d64b8
commit 05bd1ca0c8

@ -21,6 +21,10 @@ class ProjectPackagesController < ApplicationController
render_react
end
def apply_success
render_react
end
private
def render_react
render file: 'public/react/build/index.html', :layout => false

@ -2558,6 +2558,56 @@ class UsersController < ApplicationController
@tag = params[:tag]
@objects = @objects.where(:course_list_id => params[:tag]).order("#{@sort} #{order}")
end
when 'a_package'
bidding_packages = @user.bidding_project_packages
bidding_packages = bidding_packages.none if @show_all && params[:q] == 0 # 参与的不存在未发布的
packages = @user.project_packages
if @show_all
status =
case params[:q]
when '0' then %w(pending applying refused)
when '1' then %w(published)
when '2' then %w(bidding_ended bidding_finished)
end
if status.present?
packages = packages.where(status: status)
bidding_packages = bidding_packages.where(status: status)
end
else
packages = packages.where(status: %w(published bidding_ended bidding_finished))
end
ids = bidding_packages.pluck(:id) + packages.pluck(:id)
@objects = ProjectPackage.where(id: ids).order("published_at #{order}")
when 'p_package'
packages = @user.project_packages
if @show_all
status =
case params[:q]
when '0' then %w(pending applying refused)
when '1' then %w(published)
when '2' then %w(bidding_ended bidding_finished)
end
if status.present?
packages = packages.where(status: status)
end
else
packages = packages.where(status: %w(published bidding_ended bidding_finished))
end
@objects = packages.order("published_at #{order}")
when 'l_package'
packages = @user.bidding_project_packages
if @show_all
status =
case params[:q]
when '0' then %w(bidding_lost)
when '1' then %w(bidding_won)
end
packages = packages.where(bidding_users: { status: status }) if status.present?
end
@objects = packages.order("published_at #{order}")
end
@objects_count = @objects.size

@ -17,4 +17,8 @@ class BiddingUser < ActiveRecord::Base
transitions from: [:pending], to: :bid_lost
end
end
def status_text
I18n.t("bidding_user.status.#{status}")
end
end

@ -276,6 +276,8 @@ class User < Principal
# 众包
has_many :project_packages, foreign_key: :creator_id, dependent: :destroy
has_many :bidding_users, dependent: :destroy
has_many :bidding_project_packages, through: :bidding_users, source: :project_package
## end

@ -0,0 +1,82 @@
<% if @type == 'p_package' && User.current == @user %>
<div class="edu-back-white padding20-30 clearfix secondNav educontent bor-top-greyE">
<li class="<%= @p == 'a' ? 'active' : '' %>"><%= link_to "全部", user_path(@user, :type => @type), :remote => true %></li>
<li class="<%= @p == '0' ? 'active' : '' %>"><%= link_to "未发布", user_path(@user, :type => @type, :p => "0"), :remote => true %></li>
<li class="<%= @p == '1' ? 'active' : '' %>"><%= link_to "竞标中", user_path(@user, :type => @type, :p => "1"), :remote => true %></li>
<li class="<%= @p == '2' ? 'active' : '' %>"><%= link_to "已完成", user_path(@user, :type => @type, :p => "2"), :remote => true %></li>
</div>
<% elsif @type == 'l_package' && User.current == @user %>
<div class="edu-back-white padding20-30 clearfix secondNav educontent bor-top-greyE">
<li class="<%= @p == 'a' ? 'active' : '' %>"><%= link_to "全部", user_path(@user, :type => @type, :p => "a"), :remote => true %></li>
<li class="<%= @p == '0' ? 'active' : '' %>"><%= link_to "未中标", user_path(@user, :type => @type, :p => "0"), :remote => true %></li>
<li class="<%= @p == '1' ? 'active' : '' %>"><%= link_to "已中标", user_path(@user, :type => @type, :p => "1"), :remote => true %></li>
</div>
<% end %>
<div class="pl25 pr25 clearfix font-12 mt20 mb20 educontent">
<span class="fl color-grey-9">共<%= @objects_count %>个</span>
<div class="fr edu-menu-panel">
<%= link_to '发布时间', user_path(@user, :order => @new_order, :sort => @sort, :type => @type), :class => "fl color-grey-9", :remote => true %>
</div>
</div>
<% if @objects_count > 0 %>
<div class="educontent project-packages-list">
<% @objects.each do |object| %>
<div class="project-package-item">
<div class="item-image">
<%= image_tag("educoder/project_packages/#{object.category}.png") %>
</div>
<div class="item-body">
<div class="item-head">
<div class="item-head-title">
<%= link_to object.title, project_package_path(object) %>
</div>
<div class="item-head-tags">
<% if object.creator_id != @user.id %>
<% bidding_user = object.bidding_users.find_by_user_id(@user.id) %>
<%= raw content_tag(:span, bidding_user.status_text, class: bidding_user.status) %>
<% end %>
</div>
<div class="item-head-blank"></div>
<div class="item-head-price">
<span>¥</span><%= object.min_price %>
<% if object.max_price && object.max_price != object.min_price %>
~<span>¥</span><%= object.max_price %>
<% end %>
</div>
</div>
<div class="item-category">
<div class="item-category-item">人工智能</div>
</div>
<div class="item-other">
<div class="item-group item-other-visit">
<span class="item-group-icon"><i class="fa fa-eye"></i></span>
<span class="item-group-text"><%= object.visit_count %>人浏览</span>
</div>
<div class="item-group item-other-deadline">
<% if object.published? %>
<span class="item-group-icon"><i class="fa fa-clock-o"></i></span>
<span class="item-group-text">内竞标截止</span>
<% end %>
</div>
<div class="item-group item-other-bidding">
<% if object.bidding_users_count > 0 %>
<span class="item-group-icon"><i class="fa fa-user-o"></i></span>
<span class="item-group-text"><%= object.bidding_users_count %>人竞标</span>
<% end %>
</div>
<div class="item-other-blank"></div>
<div class="item-group item-other-publish-at">
<% if object.published_at.present? %>
<span class="item-group-text">发布日期:<%= object.published_at.try(:strftime, '%Y-%m-%d') %></span>
<% end %>
</div>
</div>
</div>
</div>
<% end %>
</div>
<% else %>
<%= render :partial => "welcome/no_data" %>
<% end %>

@ -1,6 +1,8 @@
<% current_user = @user == User.current %>
<% str = current_user ? '我' : 'TA' %>
<% show_package = @user.project_packages.count.nonzero? || @user.bidding_project_packages.count.nonzero? %>
<script>
function showedit_headphoto() {
var html = "<%= escape_javascript(render :partial => "users/upload_avatar") %>";
@ -170,6 +172,9 @@
<% if @user.user_extensions.try(:identity) == 0 && current_user %>
<li class="<%= @type == 'm_bank' ? 'active' : '' %>" id="user_bank"><%= link_to "题库", user_path(@user, :type => "m_bank"), :remote => true %></li>
<% end %>
<% if show_package %>
<li class="<%= %w(a_package p_package l_package).include?(@type) ? 'active' : '' %>" id="user_package"><%= link_to "众包", user_path(@user, :type => "a_package"), :remote => true %></li>
<% end %>
</div>
</div>
</div>
@ -235,6 +240,15 @@
<li class="<%= @type == 'p_bank' ? 'active' : '' %>" id="p_bank"><%= link_to "公共题库", user_path(@user, :type => "p_bank"), :remote => true %></li>
</div>
<% end %>
<% if show_package %>
<!-- 众包 -->
<div class="white-panel edu-back-white pt25 pb25 clearfix <%= %w(a_package p_package l_package).include?(@type) ? '' : 'none' %>">
<li class="active" id="a_package"><%= link_to "全部", user_path(@user, :type => "a_package"), :remote => true %></li>
<li id="p_package"><%= link_to str + "管理的", user_path(@user, :type => "p_package"), :remote => true %></li>
<li id="l_package"><%= link_to str + "参与的", user_path(@user, :type => "l_package"), :remote => true %></li>
</div>
<% end %>
</div>
<div id="user_object_list">
@ -248,6 +262,8 @@
<%= render :partial => "users/l_shixun" %>
<% elsif @type == 'a_path' || @type == 'l_path' || @type == "p_path" %>
<%= render :partial => "users/p_path" %>
<% elsif %w(a_package p_package l_package).include?(@type) %>
<%= render :partial => "users/project_package" %>
<% end %>
</div>

@ -14,6 +14,8 @@
$("#user_project").addClass("active");
<% when "m_bank", "p_bank" %>
$("#user_bank").addClass("active");
<% when "p_package", "l_package" %>
$("#user_package").addClass("active");
<% end %>
$(".white-panel").hide();
$("#<%= @type %>").parent().show();
@ -29,5 +31,7 @@
$("#user_object_list").html("<%= j (render :partial => "p_path") %>");
<% when "m_bank", "p_bank" %>
$("#user_object_list").html("<%= j (render :partial => "m_bank") %>");
<% when "a_package", "p_package", 'l_package' %>
$("#user_object_list").html("<%= j (render :partial => "project_package") %>");
<% end %>
<% end %>

@ -0,0 +1,6 @@
'zh':
bidding_user:
status:
pending: 竞标中
bidding_won: 已中标
bidding_lost: 未中标

@ -57,7 +57,9 @@ RedmineApp::Application.routes.draw do ## oauth相关
get :publish_success, on: :collection
end
resources :project_packages, only: [:index, :show, :new, :edit]
resources :project_packages, only: [:index, :show, :new, :edit] do
get :apply_success, on: :member
end
resources :ec_course_evaluations do
member do

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

@ -969,3 +969,94 @@ html>body #ajax-indicator { position: fixed; }
.radio-check input[type='checkbox']:checked + label:after {
background: #29BD8B;
}
/* 个人中心-众包 */
.project-packages-list {
}
.project-packages-list .project-package-item {
display: -webkit-flex;
display: flex;
flex-direction: row;
margin-bottom: 20px;
padding: 20px;
background: white;
box-shadow:1px 3px 3px 1px rgba(156,156,156,0.16);
}
.project-packages-list .project-package-item:hover{
box-shadow:2px 6px 6px 3px rgba(156,156,156,0.16);
opacity: 1;
border-radius: 2px;
}
.project-packages-list .project-package-item .item-image {
width: 150px;
height: 110px;
}
.project-packages-list .project-package-item .item-body {
margin-left: 20px;
flex: 1;
}
.project-package-item .item-body {
display: -webkit-flex;
display: flex;
flex-direction: column;
justify-content: space-between;
}
.project-package-item .item-body .item-head {
display: -webkit-flex;
display: flex;
justify-content: space-between;
font-size: 20px;
height: 40px;
}
.project-package-item .item-head-title {
max-width: 700px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.project-package-item .item-head-tags span {
color: white;
}
.project-package-item .item-head-tags span.pending { color: red; }
.project-package-item .item-head-tags span.bidding_won { color: lightgreen; }
.project-package-item .item-head-tags span.bidding_lost { color: grey; }
.project-package-item .item-head-blank {
flex: 1;
}
.project-package-item .item-head-price {
margin-left: 20px;
color: #F83B2D;
font-size: 28px;
font-weight: bold;
}
.project-package-item .item-head-price span {
font-size: 18px;
}
.project-package-item .item-category {
display: -webkit-flex;
display: flex;
}
.project-package-item .item-category-item {
padding: 0 10px;
color: #FF6800;
font-size: 14px;
background:rgba(255,235,213,1);
border-radius:13px;
}
.project-package-item .item-other {
display: -webkit-flex;
display: flex;
justify-content: space-between;
color: #999999;
}
.project-package-item .item-group {
flex: 1;
}
.project-package-item .item-other-blank {
flex: 2
}
Loading…
Cancel
Save