From 8c57e3363e06df7342aacc0876589ab4c8ab5b9d Mon Sep 17 00:00:00 2001
From: daiao <358551898@qq.com>
Date: Tue, 18 Jun 2019 19:26:25 +0800
Subject: [PATCH] =?UTF-8?q?=E5=90=88=E4=BD=9C=E4=BC=99=E4=BC=B4=E5=A2=9E?=
=?UTF-8?q?=E5=8A=A0=E4=BA=A7=E5=AD=A6=E8=81=94=E7=9B=9F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/account_controller.rb | 4 +-
.../account/_cooperative_partner_show.erb | 59 ++++++++++++++++++-
app/views/account/update_help.js.erb | 5 +-
3 files changed, 64 insertions(+), 4 deletions(-)
diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb
index 128475e6..649cf19d 100644
--- a/app/controllers/account_controller.rb
+++ b/app/controllers/account_controller.rb
@@ -145,6 +145,7 @@ class AccountController < ApplicationController
@com_coop_img = CooImg.where(:img_type => 'com_coop').order("position asc")
@edu_coop_img = CooImg.where(:img_type => 'edu_coop').order("position asc")
+ @alliance_img = CooImg.where(:img_type => 'alliance_coop').order("position asc")
render :layout => 'base_edu'
end
@@ -152,6 +153,7 @@ class AccountController < ApplicationController
def update_help
@edu_coop = "edu_coop"
@com_coop = "com_coop"
+ @alliance_coop = "alliance_coop"
end
def update_agreement
@@ -232,7 +234,7 @@ class AccountController < ApplicationController
end
if File.exist?(diskfile1)
pos = CooImg.order("position asc").last.position
- CooImg.create(:src_states =>params[:img_url] ,:url_states => diskfile2,:img_type =>params[:sourse_type], :position => pos)
+ CooImg.create(:src_states =>params[:img_url] ,:url_states => diskfile2,:img_type => params[:sourse_type], :position => pos)
end
redirect_to help_path(:index => 3)
end
diff --git a/app/views/account/_cooperative_partner_show.erb b/app/views/account/_cooperative_partner_show.erb
index 67452b18..1d3bff9b 100644
--- a/app/views/account/_cooperative_partner_show.erb
+++ b/app/views/account/_cooperative_partner_show.erb
@@ -1,8 +1,28 @@
<%= stylesheet_link_tag 'css/public','css/common'%>
合作伙伴
+
+
产学联盟
+
+ <% @alliance_img.each do |alliance_img| %>
+ -
+ <% if User.current.admin? %>
+
+ <% end %>
+
+
+
+
+ <% end %>
+ <% if User.current.admin? %>
+ - + 新建
+ <% end %>
+
+
+
+
-
企业合作
+
知名企业
<% @com_coop_img.each do |coop_img| %>
-
@@ -21,7 +41,7 @@
-
高校合作
+
各类院校
<% @edu_coop_img.each do |coop_img| %>
-
@@ -51,6 +71,8 @@
var id = 0;
var pos_1 = 0;
var id_1 = 0;
+ var pos_2 = 0;
+ var id_2 = 0;
$( "#sortable" ).sortable({
containment:".cooperation-item",
sort:function(e, ui){
@@ -121,7 +143,40 @@
});
$( "#sortable1" ).disableSelection();
+ $( "#sortable2" ).sortable({
+ containment:".cooperation-school",
+ sort:function(e, ui){
+ select_item = ui.item; //当前拖动的元素
+ pos_2 = $(select_item[0]).prev().attr("data-position");
+ id_2 = $(select_item[0]).attr("data-id");
+ if(pos == undefined || id == undefined){
+ pos_2 = 0;
+ }
+ },
+ stop:function(e, ui){
+ select_item = ui.item; //当前拖动的元素
+ console.log(ui.item);
+ pos_2 = $(select_item[0]).prev().attr("data-position");
+ id_2 = $(select_item[0]).attr("data-id");
+ if(pos_2 == undefined || id_2 == undefined){
+ pos_2 = 0;
+ }
+ console.log("pos: " + pos_2);
+ $.ajax({
+ url: "<%= change_coop_position_path %>",
+ data: {id: id_2, position: pos_2, type: "alliance_coop"},
+ success: function(data) {
+ if(data.status == 1){
+ console.log("更新成功!");
+ $(select_item[0]).attr("data-position", pos_2+1)
+ }
+ }
+
+ });
+ }
+ });
+ $( "#sortable2" ).disableSelection();
})
diff --git a/app/views/account/update_help.js.erb b/app/views/account/update_help.js.erb
index 39aa679a..d076eeed 100644
--- a/app/views/account/update_help.js.erb
+++ b/app/views/account/update_help.js.erb
@@ -1,7 +1,10 @@
<% if params[:tab] == '1' %>
var htmlvalue = "<%= escape_javascript(render :partial => 'account/new_coop',:locals => {:resubmit =>params[:resubmit],:sourse_type => @com_coop}) %>";
pop_box_new(htmlvalue, 400, 260);
-<% else %>
+<% elsif params[:tab] == '2' %>
var htmlvalue = "<%= escape_javascript(render :partial => 'account/new_coop',:locals => {:resubmit => params[:resubmit],:sourse_type => @edu_coop}) %>";
pop_box_new(htmlvalue, 400, 260);
+<% else %>
+var htmlvalue = "<%= escape_javascript(render :partial => 'account/new_coop',:locals => {:resubmit => params[:resubmit],:sourse_type => @alliance_coop}) %>";
+pop_box_new(htmlvalue, 400, 260);
<% end %>
\ No newline at end of file