commit
9c29d2de28
@ -0,0 +1,5 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
if ($('body.admins-abouts-edit-page, body.admins-abouts-update-page').length > 0) {
|
||||
createMDEditor('about-us-editor', {});
|
||||
}
|
||||
})
|
@ -0,0 +1,5 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
if ($('body.admins-agreements-edit-page, body.admins-agreements-update-page').length > 0) {
|
||||
createMDEditor('agreement-editor', {});
|
||||
}
|
||||
})
|
@ -0,0 +1,96 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
if ($('body.admins-cooperatives-index-page').length > 0) {
|
||||
// ------------ 保存链接 -----------
|
||||
$('.coo-img-card').on('click', '.save-url-btn', function(){
|
||||
var $link = $(this);
|
||||
var cooId = $link.data('id');
|
||||
var url = $('.coo-img-item-' + cooId).find('.url-input').val();
|
||||
$link.attr('disabled', true);
|
||||
|
||||
$.ajax({
|
||||
url: '/admins/cooperatives/' + cooId,
|
||||
method: 'PATCH',
|
||||
dataType: 'json',
|
||||
data: { url: url },
|
||||
success: function(data){
|
||||
$.notify({ message: '保存成功' });
|
||||
},
|
||||
error: ajaxErrorNotifyHandler,
|
||||
complete: function(){
|
||||
$link.removeAttr('disabled');
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
// ------------ 拖拽 -------------
|
||||
var onDropFunc = function(el, _target, _source, sibling){
|
||||
var moveId = $(el).data('id');
|
||||
var insertId = $(sibling).data('id') || '';
|
||||
|
||||
$.ajax({
|
||||
url: '/admins/cooperatives/drag',
|
||||
method: 'POST',
|
||||
dataType: 'json',
|
||||
data: { move_id: moveId, after_id: insertId },
|
||||
success: function(data){
|
||||
},
|
||||
error: function(res){
|
||||
var data = res.responseJSON;
|
||||
$.notify({message: '移动失败,原因:' + data.message}, {type: 'danger'});
|
||||
}
|
||||
})
|
||||
};
|
||||
var ele1 = document.getElementById('coo-img-container-alliance_coop');
|
||||
dragula([ele1], { mirrorContainer: ele1 }).on('drop', onDropFunc);
|
||||
var ele2 = document.getElementById('coo-img-container-com_coop');
|
||||
dragula([ele2], { mirrorContainer: ele2 }).on('drop', onDropFunc);
|
||||
var ele3 = document.getElementById('coo-img-container-edu_coop');
|
||||
dragula([ele3], { mirrorContainer: ele3 }).on('drop', onDropFunc);
|
||||
|
||||
|
||||
// ----------- 新增 --------------
|
||||
var $createModal = $('.modal.admin-add-cooperative-modal');
|
||||
var $createForm = $createModal.find('form.admin-add-cooperative-form');
|
||||
|
||||
$createForm.validate({
|
||||
errorElement: 'span',
|
||||
errorClass: 'danger text-danger',
|
||||
rules: {
|
||||
"coo_img[image]": {
|
||||
required: true
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$createModal.on('show.bs.modal', function(event){
|
||||
resetFileInputFunc($createModal.find('.img-file-input'));
|
||||
$createModal.find('.file-names').html('选择文件');
|
||||
|
||||
var $link = $(event.relatedTarget);
|
||||
var imgType = $link.data('imgType');
|
||||
$createForm.find('input[name="coo_img[img_type]"]').val(imgType);
|
||||
});
|
||||
|
||||
$createModal.on('click', '.submit-btn', function() {
|
||||
$createForm.find('.error').html('');
|
||||
|
||||
if ($createForm.valid()) {
|
||||
$createForm.submit();
|
||||
} else {
|
||||
$createForm.find('.error').html('请选择图片');
|
||||
}
|
||||
});
|
||||
$createModal.on('change', '.img-file-input', function(){
|
||||
var file = $(this)[0].files[0];
|
||||
$createModal.find('.file-names').html(file ? file.name : '请选择文件');
|
||||
})
|
||||
|
||||
// -------------- 重新上传图片 --------------
|
||||
//replace_image_url
|
||||
$('.modal.admin-upload-file-modal').on('upload:success', function(e, data){
|
||||
var $cooImgItem = $('.coo-img-item-' + data.source_id);
|
||||
$.post('/admins/cooperatives/'+ data.source_id + '/replace_image_url');
|
||||
$cooImgItem.find('.coo-img-item-img img').attr('src', data.url);
|
||||
})
|
||||
}
|
||||
})
|
@ -1,22 +0,0 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
var $editModal = $('.department-apply-edit-modal');
|
||||
if($editModal.length > 0){
|
||||
var $form = $editModal.find('form.department-apply-form');
|
||||
var $applyIdInput = $form.find('input[name="id"]');
|
||||
$editModal.on('show.bs.modal', function (event) {
|
||||
var $link = $(event.relatedTarget);
|
||||
var applyId = $link.data('id');
|
||||
$applyIdInput.val(applyId);
|
||||
});
|
||||
$editModal.on('click', '.submit-btn', function(){
|
||||
$.ajax({
|
||||
method: "PUT",
|
||||
dataType: 'script',
|
||||
url: "/admins/department_applies/"+ $applyIdInput.val(),
|
||||
data: $form.serialize(),
|
||||
}).done(function(){
|
||||
$editModal.modal('hide');
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
@ -0,0 +1,5 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
if ($('body.admins-help-centers-edit-page, body.admins-help-centers-update-page').length > 0) {
|
||||
createMDEditor('help-center-editor', {});
|
||||
}
|
||||
})
|
@ -0,0 +1,35 @@
|
||||
.admins-cooperatives-index-page {
|
||||
.coo-img-card {
|
||||
.coo-img-item {
|
||||
& > .drag {
|
||||
cursor: move;
|
||||
background: #fff;
|
||||
box-shadow: 1px 2px 5px 3px #f0f0f0;
|
||||
}
|
||||
|
||||
&-img {
|
||||
cursor: pointer;
|
||||
width: 100%;
|
||||
height: 40px;
|
||||
margin-bottom: 10px;
|
||||
|
||||
& > img {
|
||||
width: 100%;
|
||||
height: 40px;
|
||||
}
|
||||
}
|
||||
|
||||
.delete-btn {
|
||||
position: absolute;
|
||||
top: 3px;
|
||||
right: 20px;
|
||||
color: red;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.save-url-btn {
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
class Admins::AboutsController < Admins::BaseController
|
||||
def edit
|
||||
current_doc
|
||||
end
|
||||
|
||||
def update
|
||||
current_doc.update!(about_us: params[:about_us])
|
||||
|
||||
flash[:success] = '保存成功'
|
||||
redirect_to edit_admins_about_path
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def current_doc
|
||||
@doc ||= Help.first || Help.create
|
||||
end
|
||||
end
|
@ -0,0 +1,18 @@
|
||||
class Admins::AgreementsController < Admins::BaseController
|
||||
def edit
|
||||
current_doc
|
||||
end
|
||||
|
||||
def update
|
||||
current_doc.update!(agreement: params[:agreement])
|
||||
|
||||
flash[:success] = '保存成功'
|
||||
redirect_to edit_admins_agreement_path
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def current_doc
|
||||
@doc ||= Help.first || Help.create
|
||||
end
|
||||
end
|
@ -0,0 +1,28 @@
|
||||
class Admins::ContactUsController < Admins::BaseController
|
||||
def edit
|
||||
@cooperations = Cooperation.all.group(:user_type)
|
||||
@help = Help.first
|
||||
end
|
||||
|
||||
def update
|
||||
cooperation = Cooperation.find(params[:id])
|
||||
cooperation.update!(update_cooperation_params)
|
||||
|
||||
flash[:success] = '保存成功'
|
||||
redirect_to edit_admins_contact_us_path
|
||||
end
|
||||
|
||||
def update_address
|
||||
help = Help.first || Help.create
|
||||
help.update!(status: params.dig('help', 'status'))
|
||||
|
||||
flash[:success] = '保存成功'
|
||||
redirect_to edit_admins_contact_us_path
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def update_cooperation_params
|
||||
params.require(:cooperation).permit(:name, :qq, :mail)
|
||||
end
|
||||
end
|
@ -0,0 +1,84 @@
|
||||
class Admins::CooperativesController < Admins::BaseController
|
||||
before_action :convert_file!, only: [:create]
|
||||
|
||||
def index
|
||||
@data = { 'alliance_coop' => [], 'com_coop' => [], 'edu_coop' => [] }
|
||||
@data = @data.merge CooImg.all.group_by(&:img_type)
|
||||
end
|
||||
|
||||
def create
|
||||
position = CooImg.where(img_type: create_params[:img_type]).count + 1
|
||||
|
||||
ActiveRecord::Base.transaction do
|
||||
coo = CooImg.create!(create_params.merge(position: position))
|
||||
|
||||
file_path = Util::FileManage.disk_filename('CooImg', coo.id)
|
||||
File.delete(file_path) if File.exist?(file_path) # 删除之前的文件
|
||||
Util.write_file(@file, file_path)
|
||||
|
||||
coo.update!(url_states: Util::FileManage.disk_file_url('CooImg', coo.id))
|
||||
end
|
||||
|
||||
flash[:success] = '保存成功'
|
||||
redirect_to admins_cooperatives_path
|
||||
end
|
||||
|
||||
def update
|
||||
current_coo.update!(src_states: params[:url])
|
||||
render_ok
|
||||
end
|
||||
|
||||
def destroy
|
||||
ActiveRecord::Base.transaction do
|
||||
current_coo.destroy!
|
||||
# 前移
|
||||
CooImg.where(img_type: current_coo.img_type).where('position > ?', current_coo.position)
|
||||
.update_all('position = position - 1')
|
||||
|
||||
file_path = Util::FileManage.disk_filename('CooImg', current_coo.id)
|
||||
File.delete(file_path) if File.exist?(file_path)
|
||||
end
|
||||
render_delete_success
|
||||
end
|
||||
|
||||
def drag
|
||||
move = CooImg.find_by(id: params[:move_id])
|
||||
after = CooImg.find_by(id: params[:after_id])
|
||||
|
||||
Admins::DragCooperativeService.call(move, after)
|
||||
render_ok
|
||||
rescue Admins::DragCooperativeService::Error => e
|
||||
render_error(e.message)
|
||||
end
|
||||
|
||||
def replace_image_url
|
||||
current_coo.update!(url_states: Util::FileManage.disk_file_url('CooImg', current_coo.id))
|
||||
render_ok
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def current_coo
|
||||
@_current_coo ||= CooImg.find(params[:id])
|
||||
end
|
||||
|
||||
def create_params
|
||||
params.require(:coo_img).permit(:img_type, :src_states)
|
||||
end
|
||||
|
||||
def convert_file!
|
||||
max_size = 10 * 1024 * 1024 # 10M
|
||||
file = params.dig('coo_img', 'image')
|
||||
if file.class == ActionDispatch::Http::UploadedFile
|
||||
@file = file
|
||||
render_error('请上传文件') if @file.size.zero?
|
||||
render_error('文件大小超过限制') if @file.size > max_size
|
||||
else
|
||||
file = file.to_s.strip
|
||||
return render_error('请上传正确的图片') if file.blank?
|
||||
@file = Util.convert_base64_image(file, max_size: max_size)
|
||||
end
|
||||
rescue Base64ImageConverter::Error => ex
|
||||
render_error(ex.message)
|
||||
end
|
||||
end
|
@ -0,0 +1,18 @@
|
||||
class Admins::HelpCentersController < Admins::BaseController
|
||||
def edit
|
||||
current_doc
|
||||
end
|
||||
|
||||
def update
|
||||
current_doc.update!(help_center: params[:help_center])
|
||||
|
||||
flash[:success] = '保存成功'
|
||||
redirect_to edit_admins_help_center_path
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def current_doc
|
||||
@doc ||= Help.first || Help.create
|
||||
end
|
||||
end
|
@ -0,0 +1,122 @@
|
||||
class Admins::UnitAppliesController < Admins::BaseController
|
||||
before_action :get_apply,only: [:agree,:destroy,:edit,:update]
|
||||
|
||||
def index
|
||||
params[:sort_by] ||= 'created_at'
|
||||
params[:sort_direction] ||= 'desc'
|
||||
unit_applies = Admins::UnitApplyQuery.call(params)
|
||||
@unit_applies = paginate unit_applies.preload(:school, :user)
|
||||
end
|
||||
|
||||
def agree
|
||||
ActiveRecord::Base.transaction do
|
||||
begin
|
||||
@unit_apply.update_attribute("status",1)
|
||||
@unit_apply&.applied_messages&.update_all(status:1)
|
||||
@unit_apply&.school&.update_attribute("province",@unit_apply.province)
|
||||
|
||||
# #申请信息的创建
|
||||
apply_message_params = {
|
||||
user_id: @unit_apply&.user_id,
|
||||
status: 1,
|
||||
viewed: 0,
|
||||
applied_id: @unit_apply.school_id,
|
||||
applied_type: "ApplyAddSchools",
|
||||
name: @unit_apply.name,
|
||||
}
|
||||
AppliedMessage.new(apply_message_params).save(validate: false)
|
||||
|
||||
Tiding.where(user_id: 1, trigger_user_id: @unit_apply.user_id, container_id: @unit_apply.id,
|
||||
container_type: 'ApplyAddSchools', status: 0, tiding_type: "Apply").update_all(status: 1)
|
||||
#消息的创建
|
||||
tiding_params = {
|
||||
user_id: @unit_apply.user_id,
|
||||
trigger_user_id: 0,
|
||||
container_id: @unit_apply.id,
|
||||
container_type: 'ApplyAddSchools',
|
||||
belong_container_id: @unit_apply.school_id,
|
||||
belong_container_type: "School",
|
||||
tiding_type: "System",
|
||||
status: 1
|
||||
}
|
||||
Tiding.create(tiding_params)
|
||||
render_success_js
|
||||
rescue Exception => e
|
||||
Rails.logger.info("############_________________#########{e}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
Admins::DeleteUnitApplyService.call(@unit_apply, params)
|
||||
render_success_js
|
||||
end
|
||||
|
||||
def edit
|
||||
@all_schools = School.where.not(id: @unit_apply.school_id).pluck("name","id")
|
||||
|
||||
end
|
||||
|
||||
def update
|
||||
school = School.find_by(id: params[:school_id])
|
||||
ActiveRecord::Base.transaction do
|
||||
@unit_apply&.applied_messages&.update_all(status:4)
|
||||
Tiding.where(user_id: 1, trigger_user_id: @unit_apply.user_id, container_id: @unit_apply.id,
|
||||
container_type: 'ApplyAddSchools', status: 0, tiding_type: "Apply").update_all(status: 1)
|
||||
|
||||
#消息的创建
|
||||
tiding_params = {
|
||||
user_id: @unit_apply.user_id,
|
||||
trigger_user_id: 0,
|
||||
container_id: @unit_apply.id,
|
||||
container_type: 'ApplyAddSchools',
|
||||
belong_container_id: params[:school_id],
|
||||
belong_container_type: "School",
|
||||
tiding_type: "System",
|
||||
status: 3,
|
||||
extra: school.try(:name).to_s
|
||||
}
|
||||
Tiding.create(tiding_params)
|
||||
|
||||
UserExtension.where(school_id: @unit_apply.school_id).update_all(school_id: params[:school_id].to_i)
|
||||
ApplyAddDepartment.where(:school_id => @unit_apply.school_id).update_all(school_id: params[:school_id].to_i)
|
||||
|
||||
# 判断重复
|
||||
before_apply_departments = Department.where(school_id: @unit_apply.school_id)
|
||||
before_apply_departments.each do |department|
|
||||
after_dep = Department.where(school_id: params[:school_id].to_i, name: department.name)&.first
|
||||
if after_dep.present?
|
||||
UserExtension.where(school_id: @unit_apply.school_id, department_id: department.id).update_all(department_id: after_dep.id)
|
||||
department.destroy
|
||||
department.apply_add_departments.destroy_all
|
||||
else
|
||||
department.apply_add_departments.update_all(school_id: school.id)
|
||||
department.update_attribute(:school_id, school.id)
|
||||
end
|
||||
end
|
||||
|
||||
@unit_apply&.school&.destroy
|
||||
apply_params = {
|
||||
status: 2,
|
||||
name: school&.name.to_s,
|
||||
school_id: params[:school_id],
|
||||
province: params[:province],
|
||||
city: params[:city],
|
||||
address: params[:address]
|
||||
}
|
||||
@unit_apply.update_attributes(apply_params)
|
||||
# render_success_js
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def get_apply
|
||||
@unit_apply = ApplyAddSchool.find_by(id:params[:id])
|
||||
end
|
||||
|
||||
def disk_auth_filename(source_type, source_id, type)
|
||||
File.join(storage_path, "#{source_type}", "#{source_id}#{type}")
|
||||
end
|
||||
end
|
||||
|
@ -1,7 +1,10 @@
|
||||
class Wechats::JsSdkSignaturesController < ApplicationController
|
||||
def create
|
||||
signature = Util::Wechat.js_sdk_signature(params[:url], params[:noncestr], params[:timestamp])
|
||||
render_ok(signature: signature)
|
||||
timestamp = (Time.now.to_f * 1000).to_i
|
||||
noncestr = ('A'..'z').to_a.sample(8).join
|
||||
signature = Util::Wechat.js_sdk_signature(params[:url], noncestr, timestamp)
|
||||
|
||||
render_ok(appid: Util::Wechat.appid, timestamp: timestamp, noncestr: noncestr, signature: signature)
|
||||
rescue Util::Wechat::Error => ex
|
||||
render_error(ex.message)
|
||||
end
|
||||
|
@ -0,0 +1,5 @@
|
||||
class CooImg < ApplicationRecord
|
||||
extend Enumerize
|
||||
|
||||
enumerize :img_type, in: %i[com_coop edu_coop alliance_coop]
|
||||
end
|
@ -0,0 +1,9 @@
|
||||
class Cooperation < ApplicationRecord
|
||||
def user_type_text
|
||||
case user_type.to_i
|
||||
when 1 then '高校合作'
|
||||
when 2 then '企业合作'
|
||||
when 3 then '实训投稿'
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,3 @@
|
||||
class Help < ApplicationRecord
|
||||
|
||||
end
|
@ -0,0 +1,24 @@
|
||||
class Admins::UnitApplyQuery < ApplicationQuery
|
||||
include CustomSortable
|
||||
|
||||
attr_reader :params
|
||||
|
||||
sort_columns :created_at, default_by: :created_at, default_direction: :desc
|
||||
|
||||
def initialize(params)
|
||||
@params = params
|
||||
end
|
||||
|
||||
def call
|
||||
unit_applies = ApplyAddSchool.where(status:0)
|
||||
|
||||
# 关键字模糊查询
|
||||
keyword = params[:keyword].to_s.strip
|
||||
if keyword.present?
|
||||
unit_applies = unit_applies.where("name like ?","%#{keyword}%")
|
||||
end
|
||||
|
||||
custom_sort(unit_applies, params[:sort_by], params[:sort_direction])
|
||||
end
|
||||
end
|
||||
|
@ -0,0 +1,56 @@
|
||||
class Admins::DeleteUnitApplyService < ApplicationService
|
||||
|
||||
attr_reader :department, :params
|
||||
|
||||
def initialize(unit_apply, params)
|
||||
@unit_apply = unit_apply
|
||||
@params = params
|
||||
end
|
||||
|
||||
def call
|
||||
ActiveRecord::Base.transaction do
|
||||
@unit_apply.update_attribute("status",3)
|
||||
@unit_apply&.applied_messages&.update_all(status:3)
|
||||
@unit_apply&.school&.apply_add_departments&.update_all(status:3)
|
||||
|
||||
applied_departments = ApplyAddDepartment.where(school_id: @unit_apply.school_id)
|
||||
applied_departments.update_all(status: 3)
|
||||
|
||||
use_extensions = UserExtension&.where(school_id: @unit_apply.school_id)
|
||||
user_ids = UserExtension&.where(school_id: @unit_apply.school_id)&.pluck(:user_id)
|
||||
User.where(id: user_ids).update_all(profile_completed: false)
|
||||
use_extensions.update_all(school_id: nil,department_id: nil)
|
||||
|
||||
@unit_apply&.user&.user_extension&.update_attribute("department_id", nil)
|
||||
|
||||
# 申请了职业认证的用户撤销申请
|
||||
apply_user_auth = ApplyUserAuthentication.where(user_id: user_ids, auth_type: 2, status: 0)
|
||||
apply_user_auth.each do |apply|
|
||||
apply.tidings.destroy_all
|
||||
apply.update_attribute('status', 3)
|
||||
diskfile2 = disk_auth_filename('UserAuthentication', apply.user_id, 'PRO')
|
||||
diskfilePRO = diskfile2 + 'temp'
|
||||
File.delete(diskfilePRO) if File.exist?(diskfilePRO)
|
||||
File.delete(diskfile2) if File.exist?(diskfile2)
|
||||
end
|
||||
|
||||
# 未审批删除
|
||||
if params[:tip] == "unapplied"
|
||||
Tiding.where(:user_id => 1, :trigger_user_id => @unit_apply.user_id, :container_id => @unit_apply.id, :container_type => 'ApplyAddSchools', :status => 0, :tiding_type => "Apply").update_all(status: 1)
|
||||
Tiding.create(:user_id => @unit_apply.user_id, :trigger_user_id => 0, :container_id => @unit_apply.id, :container_type =>'ApplyAddSchools', :belong_container_id => @unit_apply.school_id, :belong_container_type=> 'School', :tiding_type => "System", :status => 2, :extra => params[:reason])
|
||||
|
||||
Tiding.where(:user_id => 1, :container_id => applied_departments.pluck(:id), :container_type => 'ApplyAddDepartment', :status => 0, :tiding_type => "Apply").update_all(status: 1)
|
||||
if applied_departments&.first.present?
|
||||
Tiding.create(:user_id => applied_departments.first.user_id, :trigger_user_id => 0, :container_id => applied_departments.first.id, :container_type =>'ApplyAddDepartment', :belong_container_id => @unit_apply.school_id, :belong_container_type=> 'School', :tiding_type => "System", :status => 2)
|
||||
AppliedMessage.create(:user_id => applied_departments.first.user_id, :status => 3, :viewed => 0, :applied_id => applied_departments.first.id, :applied_type => "ApplyAddDepartment", :name => applied_departments.first.name )
|
||||
end
|
||||
@unit_apply&.school&.destroy
|
||||
@unit_apply&.school&.departments&.destroy_all
|
||||
elsif params[:tip] == "applied"
|
||||
applied_departments.destroy_all
|
||||
@unit_apply.destroy
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
@ -0,0 +1,35 @@
|
||||
class Admins::DragCooperativeService < ApplicationService
|
||||
Error = Class.new(StandardError)
|
||||
|
||||
attr_reader :move, :after
|
||||
|
||||
def initialize(move, after)
|
||||
@move = move
|
||||
@after = after # 移动后下一个位置的元素
|
||||
end
|
||||
|
||||
def call
|
||||
return if move.position + 1 == after&.position # 未移动
|
||||
raise Error, '未知错误' if after && move.img_type != after.img_type
|
||||
|
||||
coo_imgs = CooImg.where(img_type: move.img_type)
|
||||
|
||||
ActiveRecord::Base.transaction do
|
||||
if after.blank? # 移动至末尾
|
||||
total = coo_imgs.count
|
||||
|
||||
coo_imgs.where('position > ?', move.position).update_all('position = position - 1')
|
||||
move.update!(position: total)
|
||||
return
|
||||
end
|
||||
|
||||
if move.position > after.position # 前移
|
||||
coo_imgs.where('position >= ? AND position < ?', after.position, move.position).update_all('position = position + 1')
|
||||
move.update!(position: after.position)
|
||||
else # 后移
|
||||
coo_imgs.where('position > ? AND position <= ?', move.position, after.position).update_all('position = position - 1')
|
||||
move.update!(position: after.position)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,15 @@
|
||||
<% define_admin_breadcrumbs do %>
|
||||
<% add_admin_breadcrumb('关于我们') %>
|
||||
<% end %>
|
||||
|
||||
<div class="box edit-about-us-container">
|
||||
<%= simple_form_for(@doc, url: admins_about_path) do |f| %>
|
||||
<div class="form-group" id="about-us-editor">
|
||||
<%= text_area_tag('about_us', @doc.about_us, style: 'display: none') %>
|
||||
</div>
|
||||
|
||||
<div class="form-row mt-4">
|
||||
<%= f.button :submit, value: '保存', class: 'btn-primary mr-3 px-4', 'data-disable-with': '保存中...' %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
@ -0,0 +1,15 @@
|
||||
<% define_admin_breadcrumbs do %>
|
||||
<% add_admin_breadcrumb('服务协议') %>
|
||||
<% end %>
|
||||
|
||||
<div class="box edit-agreement-container">
|
||||
<%= simple_form_for(@doc, url: admins_agreement_path) do |f| %>
|
||||
<div class="form-group" id="agreement-editor">
|
||||
<%= text_area_tag('agreement', @doc.agreement, style: 'display: none') %>
|
||||
</div>
|
||||
|
||||
<div class="form-row mt-4">
|
||||
<%= f.button :submit, value: '保存', class: 'btn-primary mr-3 px-4', 'data-disable-with': '保存中...' %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
@ -0,0 +1,41 @@
|
||||
<%
|
||||
define_admin_breadcrumbs do
|
||||
add_admin_breadcrumb('联系我们')
|
||||
end
|
||||
%>
|
||||
|
||||
<div class="row">
|
||||
<% @cooperations.each do |cooperation| %>
|
||||
<div class="mb-4 col-12 col-lg-6">
|
||||
<div class="card">
|
||||
<div class="card-header"><%= cooperation.user_type_text %></div>
|
||||
<div class="card-body">
|
||||
<%= simple_form_for(cooperation, url: admins_contact_us_path(id: cooperation.id), wrapper: :horizontal_form) do |f| %>
|
||||
<%= f.input :name, label: '联系人:' %>
|
||||
<%= f.input :qq, label: 'QQ:' %>
|
||||
<%= f.input :mail, label: 'Email:' %>
|
||||
|
||||
<div class="text-right">
|
||||
<%= f.button :submit, value: '保存', class: 'btn-primary btn-sm', 'data-disable-with': '保存中...' %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div class="mb-4 col-12 col-lg-6">
|
||||
<div class="card">
|
||||
<div class="card-header">公司地址</div>
|
||||
<div class="card-body">
|
||||
<%= simple_form_for(@help, url: update_address_admins_contact_us_path, wrapper: :horizontal_form) do |f| %>
|
||||
<%= f.input :status, label: '地址:' %>
|
||||
|
||||
<div class="text-right">
|
||||
<%= f.button :submit, value: '保存', class: 'btn-primary btn-sm', 'data-disable-with': '保存中...' %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
@ -0,0 +1,38 @@
|
||||
<%
|
||||
define_admin_breadcrumbs do
|
||||
add_admin_breadcrumb('合作伙伴')
|
||||
end
|
||||
%>
|
||||
|
||||
<% @data.each do |type, objs| %>
|
||||
<div class="card mb-5 coo-img-card">
|
||||
<div class="card-header d-flex justify-content-between align-items-center">
|
||||
<span class="flex-1"><%= t("enumerize.coo_img.img_type.#{type}") %></span>
|
||||
<%= javascript_void_link '添加', class: 'btn btn-primary btn-sm add-btn', data: { img_type: type, toggle: 'modal', target: '.admin-add-cooperative-modal' } %>
|
||||
</div>
|
||||
<div class="card-body row" id="coo-img-container-<%= type %>">
|
||||
<% objs.sort_by(&:position).each do |obj| %>
|
||||
<div class="col-12 col-md-6 col-lg-3 coo-img-item coo-img-item-<%= obj.id %>" data-id="<%= obj.id %>">
|
||||
<div class="border rounded relative p-3 mb-3 drag">
|
||||
<%= delete_link '删除', admins_cooperative_path(obj, element: ".coo-img-item-#{obj.id}", not_refresh: true) do %>
|
||||
<i class="fa fa-trash-o delete-btn" data-id="<%= obj.id %>"></i>
|
||||
<% end %>
|
||||
|
||||
<div class="coo-img-item-img" data-source-id="<%= obj.id %>" data-source-type="CooImg" data-toggle="modal" data-target=".admin-upload-file-modal">
|
||||
<img src="<%= obj.url_states || (Util::FileManage.exist?('CooImg', obj.id) ? Util::FileManage.disk_file_url('CooImg', obj.id) : '') %>" data-toggle="tooltip" data-title="重新上传"/>
|
||||
</div>
|
||||
<div class="input-group input-group-sm">
|
||||
<input type="text" value="<%= obj.src_states %>" class="form-control url-input" placeholder="请输入跳转地址">
|
||||
<div class="input-group-prepend">
|
||||
<button class="input-group-text save-url-btn" data-id="<%= obj.id %>">保存</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<%= render partial: 'admins/cooperatives/shared/add_cooperative_modal' %>
|
||||
<%= render partial: 'admins/shared/modal/upload_file_modal' %>
|
@ -0,0 +1,37 @@
|
||||
<div class="modal fade admin-add-cooperative-modal" tabindex="-1" role="dialog" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">添加合作伙伴</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<%= simple_form_for(CooImg.new, url: admins_cooperatives_path, html: { class: 'admin-add-cooperative-form', enctype: 'multipart/form-data' }) do |f| %>
|
||||
<%= f.input :img_type, as: :hidden %>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text">图片</span>
|
||||
</div>
|
||||
<div class="custom-file flex-row-reverse">
|
||||
<input type="file" name="coo_img[image]" class="img-file-input" id="img-file-input" accept="image/*">
|
||||
<label class="custom-file-label file-names" for="img-file-input">选择文件</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%= f.input :src_states, as: :url, label: '链接地址', placeholder: '请输入跳转地址' %>
|
||||
|
||||
<div class="error text-danger"></div>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
|
||||
<button type="button" class="btn btn-primary submit-btn">确认</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
@ -1,2 +0,0 @@
|
||||
//$("#apply-id-<%= @depart_apply.id %>").remove()
|
||||
//pop_box_new("批准成功", 400, 248);
|
@ -1,26 +0,0 @@
|
||||
<div class="modal fade department-apply-edit-modal" tabindex="-1" role="dialog" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">修改为</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form class="department-apply-form" data-remote="true">
|
||||
<%= hidden_field_tag(:id, nil) %>
|
||||
<div class="form-group">
|
||||
<label for="grade" class="col-form-label">名称:</label>
|
||||
<%= text_field_tag(:name,nil,class:"form-control",placeholder:"输入新的名称") %>
|
||||
</div>
|
||||
<div class="error text-danger"></div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
|
||||
<button type="button" class="btn btn-primary submit-btn">确认</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
@ -0,0 +1,15 @@
|
||||
<% define_admin_breadcrumbs do %>
|
||||
<% add_admin_breadcrumb('帮助中心') %>
|
||||
<% end %>
|
||||
|
||||
<div class="box edit-help-center-container">
|
||||
<%= simple_form_for(@doc, url: admins_help_center_path) do |f| %>
|
||||
<div class="form-group" id="help-center-editor">
|
||||
<%= text_area_tag('help_center', @doc.help_center, style: 'display: none') %>
|
||||
</div>
|
||||
|
||||
<div class="form-row mt-4">
|
||||
<%= f.button :submit, value: '保存', class: 'btn-primary mr-3 px-4', 'data-disable-with': '保存中...' %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
@ -1,4 +1,4 @@
|
||||
;
|
||||
$('[data-toggle="tooltip"]').tooltip();
|
||||
$('[data-toggle="tooltip"]').tooltip({ trigger : 'hover' });
|
||||
$('[data-toggle="popover"]').popover();
|
||||
$('img.preview-image').bootstrapViewer();
|
@ -1,22 +1,27 @@
|
||||
var deleteRow = $('<%= params[:element] %>');
|
||||
var refreshUrl = '<%= params[:refresh_url] %>';
|
||||
var notRefresh = <%= !!params[:not_refresh] %>;
|
||||
|
||||
$.notify({ message: '操作成功' },{ type: 'success' });
|
||||
|
||||
var refreshFunc = function(url) {
|
||||
$.ajax({
|
||||
url: url.length > 0 ? url : window.location.href,
|
||||
method: 'GET',
|
||||
dataType: "script"
|
||||
})
|
||||
}
|
||||
if (!notRefresh) {
|
||||
var refreshFunc = function(url) {
|
||||
$.ajax({
|
||||
url: url.length > 0 ? url : window.location.href,
|
||||
method: 'GET',
|
||||
dataType: "script"
|
||||
})
|
||||
}
|
||||
|
||||
if(deleteRow.length > 0){
|
||||
var needRefresh = deleteRow.siblings().length == 0;
|
||||
if(deleteRow.length > 0){
|
||||
var needRefresh = deleteRow.siblings().length == 0;
|
||||
|
||||
deleteRow.remove();
|
||||
deleteRow.remove();
|
||||
|
||||
if(needRefresh){ refreshFunc(refreshUrl); }
|
||||
if(needRefresh){ refreshFunc(refreshUrl); }
|
||||
} else {
|
||||
refreshFunc(refreshUrl);
|
||||
}
|
||||
} else {
|
||||
refreshFunc(refreshUrl);
|
||||
deleteRow.remove();
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
$("body").append("<%= j render partial: "admins/unit_applies/shared/edit_modal",locals: {apply: @unit_apply, schools: @all_schools} %>")
|
||||
var uni_edit_modal = $(".admin-unit-edit-modal")
|
||||
uni_edit_modal.modal("show")
|
||||
|
||||
uni_edit_modal.on("hidden.bs.modal",function () {
|
||||
$(".admin-unit-edit-modal").remove()
|
||||
$("body").removeClass("modal-open")
|
||||
})
|
||||
|
||||
// 初始化学校选择器
|
||||
var matcherFunc = function(params, data){
|
||||
if ($.trim(params.term) === '') {
|
||||
return data;
|
||||
}
|
||||
if (typeof data.text === 'undefined') {
|
||||
return null;
|
||||
}
|
||||
if (data.name && data.name.indexOf(params.term) > -1) {
|
||||
var modifiedData = $.extend({}, data, true);
|
||||
return modifiedData;
|
||||
}
|
||||
|
||||
// Return `null` if the term should not be displayed
|
||||
return null;
|
||||
}
|
||||
$.ajax({
|
||||
url: '/api/schools/for_option.json',
|
||||
dataType: 'json',
|
||||
type: 'GET',
|
||||
success: function(data) {
|
||||
$("#all-schools").select2({
|
||||
theme: 'bootstrap4',
|
||||
placeholder: '查询学校/单位',
|
||||
minimumInputLength: 1,
|
||||
data: data.schools,
|
||||
templateResult: function (item) {
|
||||
if(!item.id || item.id === '') return item.text;
|
||||
return item.name;
|
||||
},
|
||||
templateSelection: function(item){
|
||||
return item.name || item.text;
|
||||
},
|
||||
matcher: matcherFunc
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
$("#all-schools").select2({})
|
||||
$("#show-province-<%= @unit_apply.id %>").select2()
|
||||
$("#schoolCity_<%= @unit_apply.id %>").select2()
|
||||
|
||||
// **************** 地区选择 ****************
|
||||
$('.province-city-select').cxSelect({
|
||||
url: '/javascripts/educoder/province-data.json',
|
||||
selects: ['province-select', 'city-select']
|
||||
});
|
@ -0,0 +1,17 @@
|
||||
<% define_admin_breadcrumbs do %>
|
||||
<% add_admin_breadcrumb('单位审批') %>
|
||||
<% end %>
|
||||
|
||||
<div class="box search-form-container flex-column mb-0 pb-0 unit-applies-list-form">
|
||||
<%= form_tag(admins_unit_applies_path(unsafe_params), method: :get, class: 'form-inline search-form mt-3', remote: true) do %>
|
||||
<%= text_field_tag(:keyword, params[:keyword], class: 'form-control col-sm-2 ml-3', placeholder: '单位名称检索') %>
|
||||
<%= submit_tag('搜索', class: 'btn btn-primary ml-3','data-disable-with':"搜索中...") %>
|
||||
<%= link_to "清除",admins_unit_applies_path(keyword:nil),class:"btn btn-default",remote:true %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<div class="box unit-applies-list-container">
|
||||
<%= render(partial: 'admins/unit_applies/shared/list', locals: { applies: @unit_applies }) %>
|
||||
</div>
|
||||
|
||||
<%= render(partial: 'admins/shared/admin_common_refuse_modal') %>
|
@ -0,0 +1 @@
|
||||
$(".unit-applies-list-container").html("<%= j render partial: "admins/unit_applies/shared/list", locals: {applies: @unit_applies} %>")
|
@ -0,0 +1,17 @@
|
||||
<td><%= apply.id %></td>
|
||||
<td class="text-left"><%= overflow_hidden_span apply.name %></td>
|
||||
<td class="text-left">
|
||||
<%= "#{apply&.province.to_s}"+"#{apply&.city.to_s}" %>
|
||||
</td>
|
||||
<td class="text-left"><%= overflow_hidden_span apply.address %></td>
|
||||
<td><%= apply.user.try(:show_real_name) %></td>
|
||||
<td><%= format_time apply.created_at %></td>
|
||||
<td class="action-container">
|
||||
<%= agree_link '批准', agree_admins_unit_apply_path(apply, element: ".unit-apply-#{apply.id}"), 'data-confirm': '确认批准通过?' %>
|
||||
<%= javascript_void_link('删除', class: 'action refuse-action',
|
||||
data: {
|
||||
toggle: 'modal', target: '.admin-common-refuse-modal', id: apply.id, title: "删除原因", type: "delete",
|
||||
url: admins_unit_apply_path(apply, tip: "unapplied", element: ".unit-apply-#{apply.id}")
|
||||
}) %>
|
||||
<%= link_to "更改",edit_admins_unit_apply_path(apply), remote: true, class:"action",'data-disable-with': '打开中...' %>
|
||||
</td>
|
@ -0,0 +1,43 @@
|
||||
<div class="modal fade admin-unit-edit-modal" tabindex="-1" role="dialog" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">修改申请</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<%= form_tag(admins_unit_apply_path, method: :put, remote: true) do %>
|
||||
<div class="modal-body">
|
||||
<div class="form-group d-flex">
|
||||
<label for="school_id" class="col-form-label">更改学校:</label>
|
||||
<div class="d-flex flex-column-reverse w-75">
|
||||
<%= select_tag :school_id, [apply&.school_id], class: 'form-control school-select optional',id: "all-schools" %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group d-flex">
|
||||
<label for="school_id" class="col-form-label">更改城市:</label>
|
||||
<div class="d-flex w-75 province-city-select">
|
||||
<div class="w-50 mr-3">
|
||||
<%= select_tag('province', [], class: 'form-control province-select optional', 'data-value': apply.province, 'data-first-title': '请选择', id:"show-province-#{apply.id}") %>
|
||||
</div>
|
||||
<div class="w-50">
|
||||
<%= select_tag('city', [], class: 'form-control city-select optional', 'data-value': apply.city, id: "schoolCity_#{apply.id}") %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group d-flex">
|
||||
<label for="school_id" class="col-form-label">更改地址:</label>
|
||||
<div class="d-flex w-75 flex-column-reverse">
|
||||
<%= text_field_tag :address,apply.address,class:"form-control" %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
|
||||
<%= submit_tag "确认",class:"btn btn-primary" %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
@ -0,0 +1,26 @@
|
||||
<table class="table table-hover text-center unit-applies-list-table">
|
||||
<thead class="thead-light">
|
||||
<tr>
|
||||
<th width="8%">ID</th>
|
||||
<th width="20%" class="text-left">单位名称</th>
|
||||
<th width="12%" class="text-left">地区</th>
|
||||
<th width="20%" class="text-left">详细地址</th>
|
||||
<th width="10%">申请者</th>
|
||||
<th width="15%"><%= sort_tag('创建于', name: 'created_at', path: admins_unit_applies_path) %></th>
|
||||
<th width="15%">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% if applies.present? %>
|
||||
<% applies.each do |apply| %>
|
||||
<tr class="unit-apply-<%= apply.id %>">
|
||||
<%= render partial: "admins/unit_applies/shared/apply_item", locals: {apply: apply} %>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<%= render 'admins/shared/no_data_for_table' %>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<%= render partial: 'admins/shared/paginate', locals: { objects: applies } %>
|
@ -0,0 +1,3 @@
|
||||
$('.modal.admin-unit-edit-modal').modal('hide');
|
||||
$('.unit-applies-list-table .unit-apply-<%= @unit_apply.id %>').remove()
|
||||
$.notify({ message: '操作成功' });
|
@ -1,5 +1,6 @@
|
||||
json.(@bank, :id, :name, :description, :is_public, :topic_type, :topic_source, :topic_property_first, :topic_property_second,
|
||||
:source_unit, :topic_repeat, :province, :city)
|
||||
json.authorize @bank.user_id == current_user.id || current_user.admin?
|
||||
|
||||
json.attachment_list @bank_attachments do |attachment|
|
||||
json.partial! "attachments/attachment_simple", locals: {attachment: attachment}
|
||||
|
@ -0,0 +1,17 @@
|
||||
json.shixuns_count @total_count
|
||||
|
||||
json.shixun_list do
|
||||
json.array! @shixuns.with_highlights(multiple: true) do |obj, highlights|
|
||||
puts obj
|
||||
json.merge! obj.to_searchable_json
|
||||
json.challenge_names obj.challenges.pluck(:subject)
|
||||
|
||||
json.title highlights.delete(:name)&.join('...') || obj.searchable_title
|
||||
# json.description highlights.values[0,5].each { |arr| arr.is_a?(Array) ? arr.join('...') : arr }.join('<br/>')
|
||||
json.content highlights
|
||||
json.level level_to_s(obj.trainee)
|
||||
json.subjects obj.subjects do |subject|
|
||||
json.(subject, :id, :name)
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,7 @@
|
||||
zh-CN:
|
||||
enumerize:
|
||||
coo_img:
|
||||
img_type:
|
||||
com_coop: '知名企业'
|
||||
edu_coop: '各类院校'
|
||||
alliance_coop: '产学联盟'
|
@ -0,0 +1,9 @@
|
||||
class ReorderCooImgPosition < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
CooImg.all.group_by(&:img_type).each do |_type, objs|
|
||||
objs.sort_by(&:position).each_with_index do |obj, index|
|
||||
obj.update!(position: index + 1)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,20 @@
|
||||
class ChangePublicModelDefaultValue < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
#试卷的默认值的修改
|
||||
change_column_default :exercises,:show_result,0
|
||||
change_column_default :exercises, :answer_open, false
|
||||
change_column_default :exercises, :score_open, false
|
||||
|
||||
#问卷的默认值的修改
|
||||
change_column_default :polls, :show_result, 0
|
||||
|
||||
#实训作业/普通作业/分组作业
|
||||
change_column_default :homework_commons, :score_open, false
|
||||
change_column_default :homework_commons, :work_public, false
|
||||
change_column_default :homework_commons, :answer_public, false
|
||||
|
||||
#毕设任务
|
||||
change_column_default :graduation_tasks, :open_score, false
|
||||
change_column_default :graduation_tasks, :open_work, false
|
||||
end
|
||||
end
|
File diff suppressed because one or more lines are too long
Binary file not shown.
File diff suppressed because one or more lines are too long
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue