Merge remote-tracking branch 'origin/project_pack' into project_pack

project_pack
杨树明 5 years ago
commit 3663314fc8

@ -0,0 +1,55 @@
class Managements::ProjectPackagesController < Managements::BaseController
before_filter :set_menu_type, only: [:index]
def index
packages = ProjectPackage.where(nil)
# 任务标题
keyword = params[:keyword].to_s.strip
packages = packages.where('title LIKE ?', "%#{keyword}%") if keyword.present?
# 发布者姓名
creator_name = params[:creator_name].to_s.strip
if creator_name.present?
sql = 'LOWER(concat(users.lastname, users.firstname)) LIKE ?'
packages = packages.joins(:creator).where(sql, "%#{creator_name}%")
end
# 状态
status =
case params[:status]
when 'pending' then %w(pending refused)
when 'applying' then %w(applying)
when 'published' then %w(published bidding_end)
when 'finished' then %w(bidding_finished)
end
packages = packages.where(status: status) if status.present?
# 发布时间
begin_date = (params[:begin_date].to_time.beginning_of_day rescue nil)
end_date = (params[:end_date].to_time.end_of_day rescue nil)
packages = packages.where('published_at >= ?', begin_date) if begin_date.present?
packages = packages.where('published_at <= ?', end_date) if end_date.present?
@count = packages.count
# 排序
params[:sort_by] ||= 'created_at'
params[:sort_direction] ||= 'desc'
packages = packages.order("#{params[:sort_by]} #{params[:sort_direction]}")
@packages = paginateHelper packages.preload(:creator)
end
def destroy
ProjectPackage.find(params[:id]).destroy
render json: { status: 0 }
end
private
def set_menu_type
@menu_type = 14
@sub_type = 1
end
end

@ -772,6 +772,10 @@ module ApplicationHelper
) )
) )
) )
when 14
case sub_type
when 1 then '任务列表'
end
end end
end end

@ -89,4 +89,8 @@ class ProjectPackage < ActiveRecord::Base
def category_text def category_text
I18n.t("project_package.category.#{category}") I18n.t("project_package.category.#{category}")
end end
def status_text
I18n.t("project_package.status.#{status}")
end
end end

@ -77,6 +77,11 @@
<li style="width: 100px"><%= link_to "竞赛列表", competition_managements_path %></li> <li style="width: 100px"><%= link_to "竞赛列表", competition_managements_path %></li>
</ul> </ul>
</li> </li>
<li class="fl edu-admin-nav-li edu-position <%= 'active' if @menu_type == 14 %>" style="width: 100px"><a href="javascript:void(0);" class="edu-admin-nav-a">众包+</a>
<ul class="edu-admin-nav-inner edu-absolute">
<li style="width: 100px"><%= link_to "任务列表", managements_project_packages_path %></li>
</ul>
</li>
<li class="fl edu-admin-nav-li edu-position"><a href="javascript:void(0);" class="edu-admin-nav-a">单位</a> <li class="fl edu-admin-nav-li edu-position"><a href="javascript:void(0);" class="edu-admin-nav-a">单位</a>
<ul class="edu-admin-nav-inner edu-absolute"> <ul class="edu-admin-nav-inner edu-absolute">
<li><%= link_to "单位列表", departments_part_managements_path, :class => "edu-admin-nav-a" %></li> <li><%= link_to "单位列表", departments_part_managements_path, :class => "edu-admin-nav-a" %></li>

@ -16,7 +16,7 @@
<div id="edu-tab-con-1"> <div id="edu-tab-con-1">
<div class="mt10"> <div class="mt10">
<div class="edu-position fr task-form-30 mb10 mr15"> <div class="edu-position fr task-form-30 mb10 mr15">
<input class="task-form-100 panel-box-sizing" placeholder="输入众包需求标题进行检索" type="text" id="search_name"> <input class="task-form-100 panel-box-sizing" placeholder="输入需求标题进行检索" type="text" id="search_name">
<a href="javascript:void(0);" class="edu-btn-search font-16 color-grey mt10" id="search"><i class="fa fa-search"></i></a> <a href="javascript:void(0);" class="edu-btn-search font-16 color-grey mt10" id="search"><i class="fa fa-search"></i></a>
</div> </div>
<div class="cl"></div> <div class="cl"></div>
@ -34,7 +34,7 @@
<%= link_to "拒绝", project_package_applies_path(status: :refused), :class => "edu-filter-cir-grey mr5 fl font-12", :id => "project_package_reject_authentication", :remote => true %> <%= link_to "拒绝", project_package_applies_path(status: :refused), :class => "edu-filter-cir-grey mr5 fl font-12", :id => "project_package_reject_authentication", :remote => true %>
</p> </p>
<div class="edu-position fr task-form-30 mb10 fr mr15"> <div class="edu-position fr task-form-30 mb10 fr mr15">
<input class="task-form-100 panel-box-sizing" placeholder="输入教学案例标题、编号进行检索" type="text" id="project_package_search_name"> <input class="task-form-100 panel-box-sizing" placeholder="输入需求标题进行检索" type="text" id="project_package_search_name">
<a href="javascript:void(0);" class="edu-btn-search font-16 color-grey mt10" id="project_package_search"><i class="fa fa-search"></i></a> <a href="javascript:void(0);" class="edu-btn-search font-16 color-grey mt10" id="project_package_search"><i class="fa fa-search"></i></a>
</div> </div>
<div class="cl"></div> <div class="cl"></div>

@ -0,0 +1,53 @@
<div class="list-count">共<span><%= @obj_count %></span>条搜索结果</div>
<table class="edu-pop-table edu-txt-center" cellpadding="0" cellspacing="0" style="table-layout: fixed">
<thead>
<tr>
<th width="6%">序号</th>
<th width="20%" class="edu-txt-left">任务标题</th>
<th width="8%">状态</th>
<th width="8%">竞标人数</th>
<th width="8%">发布者</th>
<th width="12%"><%= sort_tag('创建时间', name: 'created_at', path: managements_project_packages_path) %></th>
<th width="12%"><%= sort_tag('发布时间', name: 'published_at', path: managements_project_packages_path) %></th>
<th width="12%"><%= sort_tag('竞标截止时间', name: 'deadline_at', path: managements_project_packages_path) %></th>
<th width="14%">操作</th>
</tr>
</thead>
<tbody>
<% if @packages.present? %>
<% @packages.each_with_index do |package, index| %>
<tr class="project-package-item project-package-<%= package.id %>">
<td><%= (@obj_pages.page - 1) * @obj_pages.per_page + index + 1 %></td>
<td class="edu-txt-left">
<%= link_to package.title, project_package_path(package), target: '_blank',
style: "display: block;max-width: 250px;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;",
data: { tip_down: package.title } %>
</td>
<td><%= package.status_text %></td>
<td><%= package.bidding_users_count %></td>
<td><%= package.creator.show_real_name %></td>
<td><%= package.created_at.strftime('%Y-%m-%d %H:%M') %></td>
<td><%= package.published_at.try(:strftime, '%Y-%m-%d %H:%M') || '--' %></td>
<td><%= package.deadline_at.try(:strftime, '%Y-%m-%d %H:%M') || '--' %></td>
<td> <%= link_to '删除', 'javascript:void(0)', class: 'delete-btn', data: { id: package.id } %></td>
</tr>
<% end %>
<% else %>
<tr>
<td colspan="100">
<%= render :partial => "welcome/no_data" %>
</td>
</tr>
<% end %>
</tbody>
</table>
<div style="text-align:center;" class="new_expand">
<div class="pages_user_show" style="width:auto; display:inline-block;margin: 18px 0;">
<ul id="school_report_ref_pages">
<%= pagination_links_full @obj_pages, @obj_count, per_page_links: false, remote: true, flag: true, is_new: true, path: managements_project_packages_path(params.except(:page)) %>
</ul>
<div class="cl"></div>
</div>
</div>

@ -0,0 +1,115 @@
<div class="edu-con-top clearfix xmt10 bor-grey-e mt10 padding10-20">
<%= form_tag(managements_project_packages_path,method: :get, remote: true, id: '', class: 'management-project-packages-form' ) do %>
<select name="status" class="fl winput-100-30">
<option value="">全部状态</option>
<option value="pending">草稿</option>
<option value="applying">待审核</option>
<option value="published">竞标中</option>
<option value="finished">已完成</option>
</select>
<%= text_field_tag :keyword, params[:keyword], placeholder: '请输入任务标题进行搜索', class: 'fl winput-200-30 ml10' %>
<%= text_field_tag :creator_name, params[:creator_name], placeholder: '请输入发布者进行搜索',
class: 'fl winput-200-30 ml10' %>
<div class="fl ml20 font-14">
<span>发布时间:</span>
<%= text_field_tag :begin_date, params[:begin_date],
class: 'winput-150-30', placeholder: '请选择开始时间'%>
<%= text_field_tag :end_date, params[:end_date],
class: 'winput-150-30', placeholder: '请选择结束时间'%>
</div>
<%= link_to '清除', 'javascript:clearSearchCondition()', class: 'fr task-btn ml5 reset-btn' %>
<%= link_to '搜索', 'javascript:void(0)', class: 'fr task-btn task-btn-orange ml5 search-btn' %>
<% end %>
</div>
<div class="edu-con-bg01 mt15" id="managements-project-packages-list" style="min-height: 400px;">
<%= render partial: 'managements/project_packages/project_package_list' %>
</div>
<script>
$(function(){
$('.search-btn').on('click', function() {
$(".management-project-packages-form").submit();
});
$('#managements-project-packages-list').on('click', '.delete-btn', function(){
var id = $(this).data("id");
op_confirm_tip_1("是否确认删除?", "deleteProjectPackage(" + id + ");")
});
var locale = {
clearText: '清除',
clearStatus: '清除已选日期',
closeText: '关闭',
closeStatus: '不改变当前选择',
prevText: '< 上月',
prevStatus: '显示上月',
prevBigText: '<<',
prevBigStatus: '显示上一年',
nextText: '下月>',
nextStatus: '显示下月',
nextBigText: '>>',
nextBigStatus: '显示下一年',
currentText: '今天',
currentStatus: '显示本月',
monthNames: ['一月','二月','三月','四月','五月','六月', '七月','八月','九月','十月','十一月','十二月'],
monthNamesShort: ['一月','二月','三月','四月','五月','六月', '七月','八月','九月','十月','十一月','十二月'],
monthStatus: '选择月份',
yearStatus: '选择年份',
weekHeader: '周',
weekStatus: '年内周次',
dayNames: ['星期日','星期一','星期二','星期三','星期四','星期五','星期六'],
dayNamesShort: ['周日','周一','周二','周三','周四','周五','周六'],
dayNamesMin: ['日','一','二','三','四','五','六'],
dayStatus: '设置 DD 为一周起始',
dateStatus: '选择 m月 d日, DD',
dateFormat: 'yy-mm-dd',
firstDay: 1,
initStatus: '请选择日期',
isRTL: false
};
var baseOptions = {
dateFormat: 'yy-mm-dd',
maxDate: -1
}
var options = $.extend({}, locale, baseOptions)
$('input[name="begin_date"]').datepicker(options);
$('input[name="end_date"]').datepicker(options);
});
function clearSearchCondition(){
var form = $(".management-project-packages-form");
form.find("select[name='status']").val("");
form.find("input[name='keyword']").val("");
form.find("input[name='creator_name']").val("");
form.find("input[name='begin_date']").val("");
form.find("input[name='end_date']").val("");
form.submit();
}
function deleteProjectPackage(id){
$.ajax({
type: "DELETE",
url: "<%= managements_project_packages_path %>/" + id,
success: function (data) {
$('.popupAll').remove();
if(data && data.status == 0){
$('#managements-project-packages-list .project-package-item.project-package-' + id).remove();
if($('#managements-project-packages-list .project-package-item').length == 0){
$.ajax({ dataType: 'script', url: "<%= raw managements_project_packages_path(params.except(:controller, :action)) %>" });
}
} else {
notice_box(data.message);
}
}
});
return true;
}
</script>

@ -0,0 +1 @@
$("#managements-project-packages-list").html("<%= j(render 'managements/project_packages/project_package_list') %>")

@ -130,7 +130,7 @@
$('.project-packages-list .project-package-item.project-package-' + id).remove(); $('.project-packages-list .project-package-item.project-package-' + id).remove();
if($('.project-packages-list .project-package-item').length == 0){ if($('.project-packages-list .project-package-item').length == 0){
$.ajax({ dataType: 'script', url: "<%= user_path(@user, params.except(:controller, :action)) %>" }); $.ajax({ dataType: 'script', url: "<%= raw user_path(@user, params.except(:controller, :action)) %>" });
} }
} else { } else {
notice_box(data.message); notice_box(data.message);

@ -9,3 +9,10 @@ zh:
devops_and_test: 运维与测试 devops_and_test: 运维与测试
ai: 人工智能 ai: 人工智能
other: 其它 other: 其它
status:
pending: 已创建
applying: 审核中
refused: 已拒绝
published: 竞标中
bidding_ended: 待选标
bidding_finished: 已完成

@ -531,6 +531,10 @@ RedmineApp::Application.routes.draw do ## oauth相关
end end
end end
namespace :managements do
resources :project_packages, only: [:index, :destroy]
end
resources :managements do resources :managements do
collection do collection do
get 'evaluate_simple' get 'evaluate_simple'
@ -760,6 +764,7 @@ RedmineApp::Application.routes.draw do ## oauth相关
end end
end end
end end
# Enable Grack support # Enable Grack support
# mount Trustie::Grack.new, at: '/', constraints: lambda { |request| /[-\/\w\.]+\.git\//.match(request.path_info) }, via: [:get, :post] # mount Trustie::Grack.new, at: '/', constraints: lambda { |request| /[-\/\w\.]+\.git\//.match(request.path_info) }, via: [:get, :post]

@ -301,6 +301,7 @@ a.color-red-dd:hover{color: #C61616!important;}
.winput-120-35{width: 120px;height: 35px;padding: 5px;box-sizing: border-box;} .winput-120-35{width: 120px;height: 35px;padding: 5px;box-sizing: border-box;}
.winput-120-30{width: 120px;height: 30px;padding: 5px;box-sizing: border-box;} .winput-120-30{width: 120px;height: 30px;padding: 5px;box-sizing: border-box;}
.winput-115-40{width: 115px;height: 40px;padding: 5px;box-sizing: border-box;} .winput-115-40{width: 115px;height: 40px;padding: 5px;box-sizing: border-box;}
.winput-100-30{width: 100px;height: 30px;padding: 5px;box-sizing: border-box;}
.winput-100-40{width: 100px;height: 40px;padding: 5px;box-sizing: border-box;} .winput-100-40{width: 100px;height: 40px;padding: 5px;box-sizing: border-box;}
.winput-90-40{width: 90px;height: 40px;padding: 5px;box-sizing: border-box;} .winput-90-40{width: 90px;height: 40px;padding: 5px;box-sizing: border-box;}
.winput-90-35{width: 90px;height: 35px;padding: 5px;box-sizing: border-box;} .winput-90-35{width: 90px;height: 35px;padding: 5px;box-sizing: border-box;}
@ -1106,3 +1107,11 @@ html>body #ajax-indicator { position: fixed; }
.project-package-item.with-operator:hover .item-head-title { .project-package-item.with-operator:hover .item-head-title {
max-width: 600px; max-width: 600px;
} }
.list-count {
background: #fafafa;
}
.list-count span {
color: coral;
padding: 0 3px;
}
Loading…
Cancel
Save