<%= (@obj_pages.page - 1) * @obj_pages.per_page + index + 1 %> |
<%= link_to package.title, project_package_path(package), target: '_blank',
@@ -30,7 +30,7 @@
| <%= package.created_at.strftime('%Y-%m-%d %H:%M') %> |
<%= package.published_at.try(:strftime, '%Y-%m-%d %H:%M') || '--' %> |
<%= package.deadline_at.try(:strftime, '%Y-%m-%d %H:%M') || '--' %> |
- |
+ <%= link_to '删除', 'javascript:void(0)', class: 'delete-btn', data: { id: package.id } %> |
<% end %>
<% else %>
diff --git a/app/views/managements/project_packages/index.html.erb b/app/views/managements/project_packages/index.html.erb
index ff58fef7..01f38b7b 100644
--- a/app/views/managements/project_packages/index.html.erb
+++ b/app/views/managements/project_packages/index.html.erb
@@ -36,6 +36,11 @@
$(".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: '清除已选日期',
@@ -86,4 +91,25 @@
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;
+ }
\ No newline at end of file
diff --git a/app/views/users/_project_package.html.erb b/app/views/users/_project_package.html.erb
index 00e69709..db21fd0a 100644
--- a/app/views/users/_project_package.html.erb
+++ b/app/views/users/_project_package.html.erb
@@ -130,7 +130,7 @@
$('.project-packages-list .project-package-item.project-package-' + id).remove();
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 {
notice_box(data.message);