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
|
@ -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') %>")
|
Loading…
Reference in new issue