Merge branch 'dev_aliyun' of https://bdgit.educoder.net/Hjqreturn/educoder into dev_aliyun
commit
16a6ea4563
@ -0,0 +1,126 @@
|
|||||||
|
$(document).on('turbolinks:load', function() {
|
||||||
|
if ($('body.admins-laboratory-shixuns-index-page').length > 0) {
|
||||||
|
var $searchForm = $('.laboratory-shixun-list-form .search-form');
|
||||||
|
var laboratoryId = $('.laboratory-shixun-list-container').data('id');
|
||||||
|
|
||||||
|
$searchForm.find('select#tag_id').select2({
|
||||||
|
placeholder: "请选择",
|
||||||
|
allowClear: true
|
||||||
|
});
|
||||||
|
|
||||||
|
// 定义状态切换监听事件
|
||||||
|
var defineStatusChangeFunc = function (doElement, undoElement, url, callback) {
|
||||||
|
$('.laboratory-shixun-list-container').on('click', doElement, function () {
|
||||||
|
var $doAction = $(this);
|
||||||
|
var $undoAction = $doAction.siblings(undoElement);
|
||||||
|
|
||||||
|
var laboratoryShixunId = $doAction.data('id');
|
||||||
|
customConfirm({
|
||||||
|
content: '确认进行该操作吗?',
|
||||||
|
ok: function () {
|
||||||
|
$.ajax({
|
||||||
|
url: '/admins/laboratories/' + laboratoryId + '/laboratory_shixuns/' + laboratoryShixunId + url,
|
||||||
|
method: 'POST',
|
||||||
|
dataType: 'json',
|
||||||
|
success: function () {
|
||||||
|
show_success_flash();
|
||||||
|
$doAction.hide();
|
||||||
|
$undoAction.show();
|
||||||
|
if (callback && typeof callback === "function") {
|
||||||
|
callback(laboratoryShixunId, url);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 首页展示与取消首页展示
|
||||||
|
var homepageShowCallback = function (laboratoryShixunId, url) {
|
||||||
|
var $laboratoryShixunItem = $('.laboratory-shixun-list-container').find('.laboratory-shixun-item-' + laboratoryShixunId);
|
||||||
|
|
||||||
|
if (url === '/homepage') {
|
||||||
|
$laboratoryShixunItem.find('.homepage-badge').show();
|
||||||
|
} else {
|
||||||
|
$laboratoryShixunItem.find('.homepage-badge').hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
defineStatusChangeFunc('.homepage-show-action', '.homepage-hide-action', '/homepage', homepageShowCallback);
|
||||||
|
defineStatusChangeFunc('.homepage-hide-action', '.homepage-show-action', '/cancel_homepage', homepageShowCallback);
|
||||||
|
|
||||||
|
// 添加实训功能
|
||||||
|
var $addModal = $('.modal.admin-add-laboratory-shixun-modal');
|
||||||
|
var $addForm = $addModal.find('form.admin-add-laboratory-user-form');
|
||||||
|
var $shixunSelect = $addForm.find('select.shixun-select');
|
||||||
|
|
||||||
|
$addModal.on('show.bs.modal', function(){
|
||||||
|
$addModal.find('.error').html('');
|
||||||
|
$shixunSelect.select2('val', ' ');
|
||||||
|
});
|
||||||
|
|
||||||
|
$shixunSelect.select2({
|
||||||
|
theme: 'bootstrap4',
|
||||||
|
placeholder: '请输入实训名称/创建者检索',
|
||||||
|
multiple: true,
|
||||||
|
closeOnSelect: false,
|
||||||
|
ajax: {
|
||||||
|
delay: 500,
|
||||||
|
url: '/admins/laboratories/' + laboratoryId + '/shixuns_for_select',
|
||||||
|
dataType: 'json',
|
||||||
|
data: function(params){
|
||||||
|
return { keyword: params.term, page: params.page || 1, per_page: 20 };
|
||||||
|
},
|
||||||
|
processResults: function(data, params){
|
||||||
|
params.page = params.page || 1;
|
||||||
|
|
||||||
|
return {
|
||||||
|
results: data.shixuns,
|
||||||
|
pagination: {
|
||||||
|
more: (params.page * 20) < data.count
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
},
|
||||||
|
templateResult: function (item) {
|
||||||
|
if(!item.id || item.id === '') return item.text;
|
||||||
|
var ele = '<span>'
|
||||||
|
ele += '<span>' + item.name + '</span>';
|
||||||
|
ele += '<span class="font-12"> -- ' + item.creator_name + '</span>';
|
||||||
|
ele += '<span class="font-12"> -- ' + item.status_text+ '</span>';
|
||||||
|
ele += '</span>';
|
||||||
|
|
||||||
|
return $(ele);
|
||||||
|
},
|
||||||
|
templateSelection: function(item){
|
||||||
|
if (item.id) {
|
||||||
|
}
|
||||||
|
var ele = '<span>' + (item.name || item.text) + '<span class="font-12"> -- ' + item.creator_name + '</span></span>'
|
||||||
|
return $(ele);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$addModal.on('click', '.submit-btn', function(){
|
||||||
|
$addModal.find('.error').html('');
|
||||||
|
|
||||||
|
var shixunIds = $shixunSelect.val();
|
||||||
|
if (shixunIds && shixunIds.length > 0) {
|
||||||
|
$.ajax({
|
||||||
|
method: 'POST',
|
||||||
|
dataType: 'json',
|
||||||
|
url: '/admins/laboratories/' + laboratoryId + '/laboratory_shixuns',
|
||||||
|
data: { shixun_ids: shixunIds },
|
||||||
|
success: function(){
|
||||||
|
show_success_flash();
|
||||||
|
window.location.reload();
|
||||||
|
},
|
||||||
|
error: function(res){
|
||||||
|
$addModal.find('.error').html(res.responseJSON.message);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
$addModal.find('.error').html('请选择实训');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})
|
@ -0,0 +1,148 @@
|
|||||||
|
$(document).on('turbolinks:load', function() {
|
||||||
|
if ($('body.admins-laboratory-subjects-index-page').length > 0) {
|
||||||
|
var $searchForm = $('.laboratory-subject-list-form .search-form');
|
||||||
|
var laboratoryId = $('.laboratory-subject-list-container').data('id');
|
||||||
|
|
||||||
|
// ************** 学校选择 *************
|
||||||
|
$searchForm.find('.school-select').select2({
|
||||||
|
theme: 'bootstrap4',
|
||||||
|
placeholder: '请选择创建者单位',
|
||||||
|
minimumInputLength: 1,
|
||||||
|
ajax: {
|
||||||
|
delay: 500,
|
||||||
|
url: '/api/schools/search.json',
|
||||||
|
dataType: 'json',
|
||||||
|
data: function (params) {
|
||||||
|
return {keyword: params.term};
|
||||||
|
},
|
||||||
|
processResults: function (data) {
|
||||||
|
return {results: data.schools}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
templateResult: function (item) {
|
||||||
|
if (!item.id || item.id === '') return item.text;
|
||||||
|
return item.name;
|
||||||
|
},
|
||||||
|
templateSelection: function (item) {
|
||||||
|
if (item.id) {
|
||||||
|
}
|
||||||
|
return item.name || item.text;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 定义状态切换监听事件
|
||||||
|
var defineStatusChangeFunc = function (doElement, undoElement, url, callback) {
|
||||||
|
$('.laboratory-subject-list-container').on('click', doElement, function () {
|
||||||
|
var $doAction = $(this);
|
||||||
|
var $undoAction = $doAction.siblings(undoElement);
|
||||||
|
|
||||||
|
var laboratorySubjectId = $doAction.data('id');
|
||||||
|
customConfirm({
|
||||||
|
content: '确认进行该操作吗?',
|
||||||
|
ok: function () {
|
||||||
|
$.ajax({
|
||||||
|
url: '/admins/laboratories/' + laboratoryId + '/laboratory_subjects/' + laboratorySubjectId + url,
|
||||||
|
method: 'POST',
|
||||||
|
dataType: 'json',
|
||||||
|
success: function () {
|
||||||
|
show_success_flash();
|
||||||
|
$doAction.hide();
|
||||||
|
$undoAction.show();
|
||||||
|
if (callback && typeof callback === "function") {
|
||||||
|
callback(laboratorySubjectId, url);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 首页展示与取消首页展示
|
||||||
|
var homepageShowCallback = function (laboratoryShixunId, url) {
|
||||||
|
var $laboratoryShixunItem = $('.laboratory-subject-list-container').find('.laboratory-subject-item-' + laboratoryShixunId);
|
||||||
|
|
||||||
|
if (url === '/homepage') {
|
||||||
|
$laboratoryShixunItem.find('.homepage-badge').show();
|
||||||
|
} else {
|
||||||
|
$laboratoryShixunItem.find('.homepage-badge').hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
defineStatusChangeFunc('.homepage-show-action', '.homepage-hide-action', '/homepage', homepageShowCallback);
|
||||||
|
defineStatusChangeFunc('.homepage-hide-action', '.homepage-show-action', '/cancel_homepage', homepageShowCallback);
|
||||||
|
|
||||||
|
// 添加实践课程功能
|
||||||
|
var $addModal = $('.modal.admin-add-laboratory-subject-modal');
|
||||||
|
var $addForm = $addModal.find('form.admin-add-laboratory-user-form');
|
||||||
|
var $subjectSelect = $addForm.find('select.subject-select');
|
||||||
|
|
||||||
|
$addModal.on('show.bs.modal', function(){
|
||||||
|
$addModal.find('.error').html('');
|
||||||
|
$subjectSelect.select2('val', ' ');
|
||||||
|
});
|
||||||
|
|
||||||
|
$subjectSelect.select2({
|
||||||
|
theme: 'bootstrap4',
|
||||||
|
placeholder: '请输入课程名称/创建者检索',
|
||||||
|
multiple: true,
|
||||||
|
closeOnSelect: false,
|
||||||
|
ajax: {
|
||||||
|
delay: 500,
|
||||||
|
url: '/admins/laboratories/' + laboratoryId + '/subjects_for_select',
|
||||||
|
dataType: 'json',
|
||||||
|
data: function(params){
|
||||||
|
return { keyword: params.term, page: params.page || 1, per_page: 20 }
|
||||||
|
},
|
||||||
|
processResults: function(data, params){
|
||||||
|
params.page = params.page || 1;
|
||||||
|
|
||||||
|
return {
|
||||||
|
results: data.subjects,
|
||||||
|
pagination: {
|
||||||
|
more: (params.page * 20) < data.count
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
},
|
||||||
|
templateResult: function (item) {
|
||||||
|
if(!item.id || item.id === '') return item.text;
|
||||||
|
var ele = '<span>'
|
||||||
|
ele += '<span>' + item.name + '</span>';
|
||||||
|
ele += '<span class="font-12"> -- ' + item.creator_name + '</span>';
|
||||||
|
ele += '<span class="font-12"> -- ' + item.status_text+ '</span>';
|
||||||
|
ele += '</span>';
|
||||||
|
|
||||||
|
return $(ele);
|
||||||
|
},
|
||||||
|
templateSelection: function(item){
|
||||||
|
if (item.id) {
|
||||||
|
}
|
||||||
|
var ele = '<span>' + (item.name || item.text) + '<span class="font-12"> -- ' + item.creator_name + '</span></span>'
|
||||||
|
return $(ele);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$addModal.on('click', '.submit-btn', function(){
|
||||||
|
$addModal.find('.error').html('');
|
||||||
|
|
||||||
|
var subjectIds = $subjectSelect.val();
|
||||||
|
if (subjectIds && subjectIds.length > 0) {
|
||||||
|
$.ajax({
|
||||||
|
method: 'POST',
|
||||||
|
dataType: 'json',
|
||||||
|
url: '/admins/laboratories/' + laboratoryId + '/laboratory_subjects',
|
||||||
|
data: { subject_ids: subjectIds },
|
||||||
|
success: function(){
|
||||||
|
show_success_flash();
|
||||||
|
window.location.reload();
|
||||||
|
},
|
||||||
|
error: function(res){
|
||||||
|
$addModal.find('.error').html(res.responseJSON.message);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
$addModal.find('.error').html('请选择课程');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})
|
@ -0,0 +1,41 @@
|
|||||||
|
class Admins::LaboratoryShixunsController < Admins::BaseController
|
||||||
|
helper_method :current_laboratory, :current_laboratory_shixun
|
||||||
|
|
||||||
|
def index
|
||||||
|
laboratory_shixuns = Admins::LaboratoryShixunQuery.call(current_laboratory, params)
|
||||||
|
@laboratory_shixuns = paginate laboratory_shixuns.includes(shixun: %i[tag_repertoires user])
|
||||||
|
end
|
||||||
|
|
||||||
|
def create
|
||||||
|
shixun_ids = Array.wrap(params[:shixun_ids])
|
||||||
|
shixun_ids = Shixun.where(id: shixun_ids).pluck(:id)
|
||||||
|
exist_shixun_id = current_laboratory.laboratory_shixuns.where(shixun_id: shixun_ids).pluck(:shixun_id)
|
||||||
|
|
||||||
|
LaboratoryShixun.bulk_insert(*%i[shixun_id laboratory_id created_at updated_at]) do |worker|
|
||||||
|
(shixun_ids - exist_shixun_id).each do |shixun_id|
|
||||||
|
worker.add(shixun_id: shixun_id, laboratory_id: current_laboratory.id)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
render_ok
|
||||||
|
end
|
||||||
|
|
||||||
|
def homepage
|
||||||
|
current_laboratory_shixun.update!(homepage: true)
|
||||||
|
render_ok
|
||||||
|
end
|
||||||
|
|
||||||
|
def cancel_homepage
|
||||||
|
current_laboratory_shixun.update!(homepage: false)
|
||||||
|
render_ok
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def current_laboratory
|
||||||
|
@_current_laboratory ||= Laboratory.find(params[:laboratory_id])
|
||||||
|
end
|
||||||
|
|
||||||
|
def current_laboratory_shixun
|
||||||
|
@_current_laboratory_shixun ||= current_laboratory.laboratory_shixuns.find(params[:id])
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,43 @@
|
|||||||
|
class Admins::LaboratorySubjectsController < Admins::BaseController
|
||||||
|
helper_method :current_laboratory, :current_laboratory_subject
|
||||||
|
|
||||||
|
def index
|
||||||
|
laboratory_subjects = Admins::LaboratorySubjectQuery.call(current_laboratory, params)
|
||||||
|
|
||||||
|
includes_tables = { subject: [:repertoire, :subject_level_system, user: {user_extension: :school}] }
|
||||||
|
@laboratory_subjects = paginate(laboratory_subjects.includes(includes_tables))
|
||||||
|
end
|
||||||
|
|
||||||
|
def create
|
||||||
|
subject_ids = Array.wrap(params[:subject_ids])
|
||||||
|
subject_ids = Subject.where(id: subject_ids).pluck(:id)
|
||||||
|
exist_subject_id = current_laboratory.laboratory_subjects.where(subject_id: subject_ids).pluck(:subject_id)
|
||||||
|
|
||||||
|
LaboratorySubject.bulk_insert(*%i[subject_id laboratory_id created_at updated_at]) do |worker|
|
||||||
|
(subject_ids - exist_subject_id).each do |subject_id|
|
||||||
|
worker.add(subject_id: subject_id, laboratory_id: current_laboratory.id)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
render_ok
|
||||||
|
end
|
||||||
|
|
||||||
|
def homepage
|
||||||
|
current_laboratory_subject.update!(homepage: true)
|
||||||
|
render_ok
|
||||||
|
end
|
||||||
|
|
||||||
|
def cancel_homepage
|
||||||
|
current_laboratory_subject.update!(homepage: false)
|
||||||
|
render_ok
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def current_laboratory
|
||||||
|
@_current_laboratory ||= Laboratory.find(params[:laboratory_id])
|
||||||
|
end
|
||||||
|
|
||||||
|
def current_laboratory_subject
|
||||||
|
@_current_laboratory_subject ||= current_laboratory.laboratory_subjects.find(params[:id])
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,4 @@
|
|||||||
|
class LaboratoryShixun < ApplicationRecord
|
||||||
|
belongs_to :laboratory
|
||||||
|
belongs_to :shixun
|
||||||
|
end
|
@ -0,0 +1,4 @@
|
|||||||
|
class LaboratorySubject < ApplicationRecord
|
||||||
|
belongs_to :laboratory
|
||||||
|
belongs_to :subject
|
||||||
|
end
|
@ -0,0 +1,36 @@
|
|||||||
|
class Admins::LaboratoryShixunQuery < ApplicationQuery
|
||||||
|
attr_reader :laboratory, :params
|
||||||
|
|
||||||
|
def initialize(laboratory, params)
|
||||||
|
@laboratory = laboratory
|
||||||
|
@params = params
|
||||||
|
end
|
||||||
|
|
||||||
|
def call
|
||||||
|
laboratory_shixuns = laboratory.laboratory_shixuns.joins(:shixun)
|
||||||
|
|
||||||
|
keyword = params[:keyword].to_s.strip
|
||||||
|
if keyword.present?
|
||||||
|
like_sql = 'shixuns.name LIKE :keyword OR CONCAT(users.lastname, users.firstname) LIKE :keyword'
|
||||||
|
laboratory_shixuns = laboratory_shixuns.joins(shixun: :user).where(like_sql, keyword: "%#{keyword}%")
|
||||||
|
end
|
||||||
|
|
||||||
|
# 实训状态
|
||||||
|
laboratory_shixuns = laboratory_shixuns.where(shixuns: { status: params[:status] }) if params[:status].present?
|
||||||
|
|
||||||
|
# 技术平台
|
||||||
|
if params[:tag_id].present?
|
||||||
|
laboratory_shixuns = laboratory_shixuns.joins(shixun: :shixun_mirror_repositories)
|
||||||
|
.where(shixun_mirror_repositories: { mirror_repository_id: params[:tag_id] })
|
||||||
|
end
|
||||||
|
|
||||||
|
# 首页展示、单位自建
|
||||||
|
%i[homepage ownership].each do |column|
|
||||||
|
if params[column].present? && params[column].to_s == 'true'
|
||||||
|
laboratory_shixuns = laboratory_shixuns.where(column => true)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
laboratory_shixuns
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,36 @@
|
|||||||
|
class Admins::LaboratorySubjectQuery < ApplicationQuery
|
||||||
|
attr_reader :laboratory, :params
|
||||||
|
|
||||||
|
def initialize(laboratory, params)
|
||||||
|
@laboratory = laboratory
|
||||||
|
@params = params
|
||||||
|
end
|
||||||
|
|
||||||
|
def call
|
||||||
|
laboratory_subjects = laboratory.laboratory_subjects.joins(:subject)
|
||||||
|
|
||||||
|
keyword = params[:keyword].to_s.strip
|
||||||
|
if keyword.present?
|
||||||
|
like_sql = 'subjects.name LIKE :keyword OR CONCAT(users.lastname, users.firstname) LIKE :keyword'
|
||||||
|
laboratory_subjects = laboratory_subjects.joins(subject: :user).where(like_sql, keyword: "%#{keyword}%")
|
||||||
|
end
|
||||||
|
|
||||||
|
# 状态
|
||||||
|
laboratory_subjects = laboratory_subjects.where(subjects: { status: params[:status] }) if params[:status].present?
|
||||||
|
|
||||||
|
# 创建者单位
|
||||||
|
if params[:school_id].present?
|
||||||
|
laboratory_subjects = laboratory_subjects.joins(subjects: { user: :user_extension })
|
||||||
|
.where(user_extensions: { school_id: params[:school_id] })
|
||||||
|
end
|
||||||
|
|
||||||
|
# 首页展示、单位自建
|
||||||
|
%i[homepage ownership].each do |column|
|
||||||
|
if params[column].present? && params[column].to_s == 'true'
|
||||||
|
laboratory_subjects = laboratory_subjects.where(column => true)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
laboratory_subjects
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,33 @@
|
|||||||
|
wb = xlsx_package.workbook
|
||||||
|
|
||||||
|
wb.styles do |s|
|
||||||
|
blue_cell = s.add_style :bg_color => "FAEBDC", :sz => 10,:height => 25,:b => true, :border => { :style => :thin, :color =>"000000" },:alignment => {wrap_text: true,:horizontal => :center,:vertical => :center}
|
||||||
|
wb.add_worksheet(name: "#{@competition.name}证书审批列表") do |sheet|
|
||||||
|
sheet.add_row %w(序号 排名 奖项 战队ID 战队名称 姓名 职业 学号 学校名称 学院名称 地区 实名认证 职业认证 手机号码 队长 签领/开户行及银行卡号 审批时间 审批人), :height => 25,:style => blue_cell
|
||||||
|
|
||||||
|
@all_prize_users.each_with_index do |prize_user, index|
|
||||||
|
user = prize_user.user
|
||||||
|
data = [
|
||||||
|
index + 1,
|
||||||
|
prize_user.rank,
|
||||||
|
prize_user.competition_prize.name,
|
||||||
|
prize_user.competition_team_id,
|
||||||
|
prize_user.competition_team.name,
|
||||||
|
user.real_name,
|
||||||
|
user.identity,
|
||||||
|
user.student_id,
|
||||||
|
user.school_name,
|
||||||
|
user.department_name,
|
||||||
|
user.location,
|
||||||
|
user.auth_status,
|
||||||
|
user.pro_status,
|
||||||
|
user.phone,
|
||||||
|
prize_user.leader? ? "是" : "-",
|
||||||
|
[prize_user.extra&.[]('bank'), prize_user.extra&.[]('second_bank'), prize_user.extra&.[]('card_no')].compact.join('/'),
|
||||||
|
prize_user.approved_at&.strftime('%Y-%m-%d %H:%M'),
|
||||||
|
prize_user.approver&.real_name
|
||||||
|
]
|
||||||
|
sheet.add_row(data)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,8 @@
|
|||||||
|
json.count @count
|
||||||
|
json.shixuns do
|
||||||
|
json.array! @shixuns do |shixun|
|
||||||
|
json.extract! shixun, :id, :name, :status
|
||||||
|
json.status_text I18n.t("shixun.status.#{shixun.status}")
|
||||||
|
json.creator_name shixun.user.real_name
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,8 @@
|
|||||||
|
json.count @count
|
||||||
|
json.subjects do
|
||||||
|
json.array! @subjects do |subject|
|
||||||
|
json.extract! subject, :id, :name, :status
|
||||||
|
json.status_text I18n.t("subject.status.#{subject.status}")
|
||||||
|
json.creator_name subject.user.real_name
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,45 @@
|
|||||||
|
<% define_admin_breadcrumbs do %>
|
||||||
|
<% add_admin_breadcrumb('云上实验室', admins_laboratories_path) %>
|
||||||
|
<% add_admin_breadcrumb("#{current_laboratory.name} - 实训项目") %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="box search-form-container laboratory-shixun-list-form">
|
||||||
|
<%= form_tag(admins_laboratory_laboratory_shixuns_path(current_laboratory), method: :get, class: 'form-inline search-form', remote: true) do %>
|
||||||
|
<div class="form-group mr-1">
|
||||||
|
<label for="status">状态:</label>
|
||||||
|
<% status_options = [['全部', ''], ['编辑中', 0], ['审核中', 1], ['已发布', 2], ['已关闭', 3]] %>
|
||||||
|
<%= select_tag(:status, options_for_select(status_options), class: 'form-control') %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group mr-4">
|
||||||
|
<label for="status">技术平台:</label>
|
||||||
|
<%= select_tag(:tag_id, options_for_select(MirrorRepository.pluck(:type_name,:id).unshift(['']), params[:tag_id]), class: 'form-control') %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<%= text_field_tag(:keyword, params[:keyword], class: 'form-control col-12 col-md-2 mr-3', placeholder: '创建者/实训名称检索') %>
|
||||||
|
|
||||||
|
<div class="form-check mr-2">
|
||||||
|
<%= hidden_field_tag(:homepage, false, id:'') %>
|
||||||
|
<%= check_box_tag(:homepage, true, params[:homepage].to_s == 'true', class: 'form-check-input') %>
|
||||||
|
<label class="form-check-label" for="homepage">只看首页展示</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-check mr-2">
|
||||||
|
<%= hidden_field_tag(:ownership, false, id:'') %>
|
||||||
|
<%= check_box_tag(:ownership, true, params[:ownership].to_s == 'true', class: 'form-check-input') %>
|
||||||
|
<label class="form-check-label" for="ownership">只看自建</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<%= submit_tag('搜索', class: 'btn btn-primary ml-3', 'data-disable-with': '搜索中...') %>
|
||||||
|
<%= link_to '清空', admins_laboratory_laboratory_shixuns_path(current_laboratory), class: 'btn btn-default','data-disable-with': '清空中...' %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<%= javascript_void_link('添加实训', class: 'btn btn-primary', data: { toggle: 'modal', target: '.admin-add-laboratory-shixun-modal' }) %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="box laboratory-shixun-list-container" data-id="<%= current_laboratory.id %>">
|
||||||
|
<%= render partial: 'admins/laboratory_shixuns/shared/list', locals: { laboratory_shixuns: @laboratory_shixuns } %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<%= render partial: 'admins/laboratory_shixuns/shared/add_laboratory_shixun_modal' %>
|
@ -0,0 +1 @@
|
|||||||
|
$('.laboratory-shixun-list-container').html("<%= j(render partial: 'admins/laboratory_shixuns/shared/list', locals: { laboratory_shixuns: @laboratory_shixuns }) %>");
|
@ -0,0 +1,28 @@
|
|||||||
|
<div class="modal fade admin-add-laboratory-shixun-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="admin-add-laboratory-user-form">
|
||||||
|
<div class="form-group d-flex">
|
||||||
|
<label class="col-form-label">选择实训:</label>
|
||||||
|
<div class="d-flex flex-column-reverse w-75">
|
||||||
|
<select id="shixun_ids" name="shixun_ids" class="form-control shixun-select" multiple></select>
|
||||||
|
</div>
|
||||||
|
</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,27 @@
|
|||||||
|
<table class="table text-center laboratory-shixun-list-table">
|
||||||
|
<thead class="thead-light">
|
||||||
|
<tr>
|
||||||
|
<th width="28%" class="text-left">实训名称</th>
|
||||||
|
<th width="12%">技术平台</th>
|
||||||
|
<th width="14%" class="text-left">技术体系</th>
|
||||||
|
<th width="10%">封面</th>
|
||||||
|
<th width="8%">创建者</th>
|
||||||
|
<th width="8%">状态</th>
|
||||||
|
<th width="10%">执行时间</th>
|
||||||
|
<th width="14%">操作</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<% if laboratory_shixuns.present? %>
|
||||||
|
<% laboratory_shixuns.each do |laboratory_shixun| %>
|
||||||
|
<tr class="laboratory-shixun-item-<%= laboratory_shixun.id %>">
|
||||||
|
<%= render partial: 'admins/laboratory_shixuns/shared/td', locals: { laboratory_shixun: laboratory_shixun } %>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
<% else %>
|
||||||
|
<%= render 'admins/shared/no_data_for_table' %>
|
||||||
|
<% end %>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<%= render partial: 'admins/shared/paginate', locals: { objects: laboratory_shixuns } %>
|
@ -0,0 +1,28 @@
|
|||||||
|
<%- shixun = laboratory_shixun.shixun -%>
|
||||||
|
|
||||||
|
<td class="text-left">
|
||||||
|
<%= link_to "/shixuns/#{shixun.identifier}", target: '_blank' do %>
|
||||||
|
<%= shixun.name %>
|
||||||
|
<span class="badge badge-pill badge-success homepage-badge" style="<%= laboratory_shixun.homepage? ? '' : 'display:none' %>">首页</span>
|
||||||
|
<span class="badge badge-pill badge-info ownership-badge" style="<%= laboratory_shixun.ownership ? '' : 'display:none' %>">自建</span>
|
||||||
|
<% end %>
|
||||||
|
</td>
|
||||||
|
<td><%= shixun.shixun_main_name %></td>
|
||||||
|
<td class="text-left">
|
||||||
|
<% shixun.tag_repertoires.each do |tag| %>
|
||||||
|
<span class="badge badge-secondary"><%= tag.name %></span>
|
||||||
|
<% end %>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<% imageExists = Util::FileManage.exists?(shixun) %>
|
||||||
|
<% imageUrl = imageExists ? '/' + url_to_avatar(shixun) : '' %>
|
||||||
|
<%= image_tag(imageUrl, width: 60, height: 40, class: "preview-image shixun-image-#{shixun.id}", data: { toggle: 'tooltip', title: '点击预览' }, style: imageExists ? '' : 'display:none') %>
|
||||||
|
</td>
|
||||||
|
<td><%= link_to shixun.user&.real_name, "/users/#{shixun.user&.login}", target:'_blank' %></td>
|
||||||
|
<td><span class="<%= shixun_status_class(shixun) %>"><%= t("shixun.status.#{shixun.status}") %></span></td>
|
||||||
|
<td><%= shixun.excute_time %></td>
|
||||||
|
<td class="action-container">
|
||||||
|
<%= link_to('去修改', admins_shixun_settings_path(id: laboratory_shixun.shixun_id)) %>
|
||||||
|
<%= javascript_void_link('首页展示', class: 'action homepage-show-action', data: { id: laboratory_shixun.id }, style: laboratory_shixun.homepage? ? 'display:none' : '') %>
|
||||||
|
<%= javascript_void_link('取消首页展示', class: 'action homepage-hide-action', data: { id: laboratory_shixun.id }, style: laboratory_shixun.homepage? ? '' : 'display:none') %>
|
||||||
|
</td>
|
@ -0,0 +1,45 @@
|
|||||||
|
<% define_admin_breadcrumbs do %>
|
||||||
|
<% add_admin_breadcrumb('云上实验室', admins_laboratories_path) %>
|
||||||
|
<% add_admin_breadcrumb("#{current_laboratory.name} - 实践课程") %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="box search-form-container laboratory-subject-list-form">
|
||||||
|
<%= form_tag(admins_laboratory_laboratory_subjects_path(current_laboratory), method: :get, class: 'form-inline search-form', remote: true) do %>
|
||||||
|
<div class="form-group mr-1">
|
||||||
|
<label for="status">状态:</label>
|
||||||
|
<% status_options = [['全部', ''], ['编辑中', 0], ['审核中', 1], ['已发布', 2]] %>
|
||||||
|
<%= select_tag(:status, options_for_select(status_options), class: 'form-control') %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group col-12 col-md-3">
|
||||||
|
<label for="school_name">单位:</label>
|
||||||
|
<%= select_tag :school_id, options_for_select([''], params[:school_id]), class: 'form-control school-select flex-1' %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<%= text_field_tag(:keyword, params[:keyword], class: 'form-control col-12 col-md-2 mr-3', placeholder: '创建者/课程名称检索') %>
|
||||||
|
|
||||||
|
<div class="form-check mr-2">
|
||||||
|
<%= hidden_field_tag(:homepage, false, id:'') %>
|
||||||
|
<%= check_box_tag(:homepage, true, params[:homepage].to_s == 'true', class: 'form-check-input') %>
|
||||||
|
<label class="form-check-label" for="homepage">只看首页展示</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-check mr-2">
|
||||||
|
<%= hidden_field_tag(:ownership, false, id:'') %>
|
||||||
|
<%= check_box_tag(:ownership, true, params[:ownership].to_s == 'true', class: 'form-check-input') %>
|
||||||
|
<label class="form-check-label" for="ownership">只看自建</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<%= submit_tag('搜索', class: 'btn btn-primary ml-3', 'data-disable-with': '搜索中...') %>
|
||||||
|
<%= link_to '清空', admins_laboratory_laboratory_subjects_path(current_laboratory), class: 'btn btn-default','data-disable-with': '清空中...' %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<%= javascript_void_link('添加课程', class: 'btn btn-primary', data: { toggle: 'modal', target: '.admin-add-laboratory-subject-modal' }) %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="box laboratory-subject-list-container" data-id="<%= current_laboratory.id %>">
|
||||||
|
<%= render partial: 'admins/laboratory_subjects/shared/list', locals: { laboratory_subjects: @laboratory_subjects } %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<%= render partial: 'admins/laboratory_subjects/shared/add_laboratory_subject_modal' %>
|
@ -0,0 +1 @@
|
|||||||
|
$('.laboratory-subject-list-container').html("<%= j(render partial: 'admins/laboratory_subjects/shared/list', locals: { laboratory_subjects: @laboratory_subjects }) %>");
|
@ -0,0 +1,28 @@
|
|||||||
|
<div class="modal fade admin-add-laboratory-subject-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="admin-add-laboratory-user-form">
|
||||||
|
<div class="form-group d-flex">
|
||||||
|
<label class="col-form-label">选择实践课程:</label>
|
||||||
|
<div class="d-flex flex-column-reverse w-75">
|
||||||
|
<select id="subject_ids" name="subject_ids" class="form-control subject-select" multiple></select>
|
||||||
|
</div>
|
||||||
|
</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,48 @@
|
|||||||
|
<table class="table text-center laboratory-subject-list-table">
|
||||||
|
<thead class="thead-light">
|
||||||
|
<tr>
|
||||||
|
<th width="28%" class="text-left">课程名称</th>
|
||||||
|
<th width="12%">技术体系</th>
|
||||||
|
<th width="10%">等级体系</th>
|
||||||
|
<th width="10%">封面</th>
|
||||||
|
<th width="8%">创建者</th>
|
||||||
|
<th width="10%">单位</th>
|
||||||
|
<th width="8%">状态</th>
|
||||||
|
<th width="14%">操作</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<% if laboratory_subjects.present? %>
|
||||||
|
<% laboratory_subjects.each do |laboratory_subject| %>
|
||||||
|
<tr class="laboratory-subject-item-<%= laboratory_subject.id %>">
|
||||||
|
<%- subject = laboratory_subject.subject -%>
|
||||||
|
|
||||||
|
<td class="text-left">
|
||||||
|
<%= link_to(subject.name, "/paths/#{subject.id}", target: '_blank') %>
|
||||||
|
<span class="badge badge-pill badge-success homepage-badge" style="<%= laboratory_subject.homepage? ? '' : 'display:none' %>">首页</span>
|
||||||
|
<span class="badge badge-pill badge-success ownership-badge" style="<%= laboratory_subject.ownership? ? '' : 'display:none' %>">自建</span>
|
||||||
|
</td>
|
||||||
|
<td><%= display_text subject.repertoire&.name %></td>
|
||||||
|
<td><%= display_text subject.subject_level_system&.name %></td>
|
||||||
|
<td>
|
||||||
|
<% image_exists = Util::FileManage.exists?(subject) %>
|
||||||
|
<%= image_tag(image_exists ? Util::FileManage.source_disk_file_url(subject) : '', height: 40, class: "w-100 preview-image subject-image-#{subject.id}", style: image_exists ? '' : 'display:none') %>
|
||||||
|
</td>
|
||||||
|
<td><%= subject.user.real_name %></td>
|
||||||
|
<td><%= subject.user.school_name %></td>
|
||||||
|
<td><%= display_subject_status(subject) %></td>
|
||||||
|
|
||||||
|
<td class="action-container">
|
||||||
|
<%= link_to('去修改', admins_subjects_path(id: laboratory_subject.subject_id)) %>
|
||||||
|
<%= javascript_void_link('首页展示', class: 'action homepage-show-action', data: { id: laboratory_subject.id }, style: laboratory_subject.homepage? ? 'display:none' : '') %>
|
||||||
|
<%= javascript_void_link('取消首页展示', class: 'action homepage-hide-action', data: { id: laboratory_subject.id }, style: laboratory_subject.homepage? ? '' : 'display:none') %>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
<% else %>
|
||||||
|
<%= render 'admins/shared/no_data_for_table' %>
|
||||||
|
<% end %>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<%= render partial: 'admins/shared/paginate', locals: { objects: laboratory_subjects } %>
|
@ -1,2 +1,2 @@
|
|||||||
json.extract! message, :id, :parent_id, :subject, :created_on, :total_replies_count, :total_praises_count,
|
json.extract! message, :id, :parent_id, :subject, :created_on, :total_replies_count, :total_praises_count,
|
||||||
:is_md, :praises_count, :visits, :sticky, :is_hidden, :is_public
|
:is_md, :praises_count, :visits, :sticky, :is_hidden, :is_public, :email_notify
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
admins-mirror_scripts: 'admins-mirror_repositories'
|
admins-mirror_scripts: 'admins-mirror_repositories'
|
||||||
admins-laboratory_settings: 'admins-laboratories'
|
admins-laboratory_settings: 'admins-laboratories'
|
||||||
admins-carousels: 'admins-laboratories'
|
admins-carousels: 'admins-laboratories'
|
||||||
|
admins-laboratory_shixuns: 'admins-laboratories'
|
||||||
|
admins-laboratory_subjects: 'admins-laboratories'
|
||||||
admins-competition_settings: 'admins-competitions'
|
admins-competition_settings: 'admins-competitions'
|
||||||
admins-enroll_lists: 'admins-competitions'
|
admins-enroll_lists: 'admins-competitions'
|
||||||
admins-competition_prize_users: 'admins-competitions'
|
admins-competition_prize_users: 'admins-competitions'
|
||||||
|
@ -0,0 +1,13 @@
|
|||||||
|
class CreateLaboratoryShixuns < ActiveRecord::Migration[5.2]
|
||||||
|
def change
|
||||||
|
create_table :laboratory_shixuns do |t|
|
||||||
|
t.references :laboratory
|
||||||
|
t.references :shixun
|
||||||
|
|
||||||
|
t.boolean :ownership, default: false
|
||||||
|
t.boolean :homepage, default: false
|
||||||
|
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,13 @@
|
|||||||
|
class CreateLaboratorySubjects < ActiveRecord::Migration[5.2]
|
||||||
|
def change
|
||||||
|
create_table :laboratory_subjects do |t|
|
||||||
|
t.references :laboratory
|
||||||
|
t.references :subject
|
||||||
|
|
||||||
|
t.boolean :ownership, default: false
|
||||||
|
t.boolean :homepage, default: false
|
||||||
|
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,5 @@
|
|||||||
|
class AddEmailNotifyToMessages < ActiveRecord::Migration[5.2]
|
||||||
|
def change
|
||||||
|
add_column :messages, :email_notify, :boolean, default: 0
|
||||||
|
end
|
||||||
|
end
|
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
After Width: | Height: | Size: 153 KiB |
@ -0,0 +1,111 @@
|
|||||||
|
import React, { Component } from 'react';
|
||||||
|
import {Button, Card, Row, Col ,Upload,Icon,message,Tabs,Form,Input} from 'antd';
|
||||||
|
import axios from 'axios';
|
||||||
|
import {getImageUrl,getUrl} from 'educoder';
|
||||||
|
import TPMMDEditor from '../tpm/challengesnew/TPMMDEditor';
|
||||||
|
class Osshackathonmd extends Component{
|
||||||
|
constructor(props) {
|
||||||
|
super(props)
|
||||||
|
this.contentMdRef = React.createRef();
|
||||||
|
this.state={
|
||||||
|
title_num: 0,
|
||||||
|
title_value: undefined
|
||||||
|
}
|
||||||
|
}
|
||||||
|
componentDidUpdate =(prevState)=>{
|
||||||
|
// if(prevState!=this.props){
|
||||||
|
// let url=`/osshackathon/edit_hackathon.json`;
|
||||||
|
// axios.get(url).then((result)=>{
|
||||||
|
// if(result.status==200){
|
||||||
|
// this.setState({
|
||||||
|
// title_value:result.data.name
|
||||||
|
// })
|
||||||
|
// this.contentMdRef.current.setValue(result.data.description);
|
||||||
|
// }
|
||||||
|
// })
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
componentDidMount(){
|
||||||
|
let url=`/osshackathon/edit_hackathon.json`;
|
||||||
|
axios.get(url).then((result)=>{
|
||||||
|
if(result.status==200){
|
||||||
|
this.setState({
|
||||||
|
title_value:result.data.name
|
||||||
|
})
|
||||||
|
this.contentMdRef.current.setValue(result.data.description);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 输入title
|
||||||
|
changeTitle = (e) => {
|
||||||
|
// title_num: 60 - parseInt(e.target.value.length),
|
||||||
|
this.setState({
|
||||||
|
title_num: e.target.value.length,
|
||||||
|
title_value: e.target.value
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
handleSubmit = () => {
|
||||||
|
let {title_value}=this.state;
|
||||||
|
const mdContnet = this.contentMdRef.current.getValue().trim();
|
||||||
|
// if(mdContnet.length>10000){
|
||||||
|
// this.props.showNotification("内容超过10000个字");
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
|
||||||
|
let url=`/osshackathon/update_hackathon.json`;
|
||||||
|
axios.post(url,{
|
||||||
|
name:title_value,
|
||||||
|
description:mdContnet,
|
||||||
|
}
|
||||||
|
).then((response) => {
|
||||||
|
if(response.data.status===0){
|
||||||
|
this.props.getosshackathon()
|
||||||
|
this.props.hidehackathonedit()
|
||||||
|
this.props.showNotification(`提交成功`);
|
||||||
|
}
|
||||||
|
}).catch((error) => {
|
||||||
|
console.log(error)
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
render() {
|
||||||
|
|
||||||
|
|
||||||
|
// console.log(this.props.tabkey)
|
||||||
|
// console.log(chart_rules)
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className={"mt20"}>
|
||||||
|
<Form>
|
||||||
|
<Form.Item label="标题">
|
||||||
|
<Input placeholder="请输入标题"
|
||||||
|
value={this.state.title_value}
|
||||||
|
onInput={this.changeTitle}
|
||||||
|
className="searchView searchViewAfter h45input" style={{"width": "100%"}} maxLength="60"
|
||||||
|
addonAfter={String(this.state.title_value===undefined?0:this.state.title_value.length)+"/60"}
|
||||||
|
/>
|
||||||
|
</Form.Item>
|
||||||
|
|
||||||
|
<Form.Item label="描述">
|
||||||
|
<TPMMDEditor ref={this.contentMdRef} placeholder="请输入描述" mdID={'courseContentMD'} refreshTimeout={1500}
|
||||||
|
className="courseMessageMD" initValue={this.state.description}></TPMMDEditor>
|
||||||
|
</Form.Item>
|
||||||
|
</Form>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div className="clearfix mt30 mb30">
|
||||||
|
<div className={"fr"}>
|
||||||
|
<Button type="primary" onClick={this.handleSubmit} className="defalutSubmitbtn fl mr20">提交</Button>
|
||||||
|
<a className="defalutCancelbtn fl" onClick={() => this.props.hidehackathonedit()}>取消</ a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export default Osshackathonmd;
|
@ -0,0 +1,217 @@
|
|||||||
|
import React, { Component } from 'react';
|
||||||
|
import {Button, Card, Row, Col ,Upload,Icon,message,Tabs,Form,Input,Modal} from 'antd';
|
||||||
|
import axios from 'axios';
|
||||||
|
import {getImageUrl,getUrl,WordNumberTextarea} from 'educoder';
|
||||||
|
|
||||||
|
class Osshackathonmodel extends Component{
|
||||||
|
constructor(props) {
|
||||||
|
super(props)
|
||||||
|
this.state={
|
||||||
|
title_num: 0,
|
||||||
|
title_value: undefined,
|
||||||
|
Textarea_comment:undefined
|
||||||
|
}
|
||||||
|
}
|
||||||
|
componentDidUpdate =(prevState)=>{
|
||||||
|
// if(prevState!=this.props){
|
||||||
|
// let name=this.props&&this.props.modelname;
|
||||||
|
// let mdvalue=this.props&&this.props.modeldescription;
|
||||||
|
// this.setState({
|
||||||
|
// title_value:name,
|
||||||
|
// Textarea_comment:mdvalue
|
||||||
|
// })
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
componentDidMount(){
|
||||||
|
if(this.props.modelid===undefined){
|
||||||
|
this.setState({
|
||||||
|
title_value:undefined,
|
||||||
|
Textarea_comment:undefined
|
||||||
|
})
|
||||||
|
}else{
|
||||||
|
let url=`/osshackathon/${this.props.modelid}/edit.json`;
|
||||||
|
axios.get(url).then((result)=>{
|
||||||
|
if(result.status==200){
|
||||||
|
this.setState({
|
||||||
|
title_value:result.data.name,
|
||||||
|
Textarea_comment:result.data.description
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
handleSubmit = () => {
|
||||||
|
let {title_value,Textarea_comment}=this.state;
|
||||||
|
// if(mdContnet.length>10000){
|
||||||
|
// this.props.showNotification("内容超过10000个字");
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
|
||||||
|
if(this.props.modelid===undefined){
|
||||||
|
let url=`/osshackathon.json`;
|
||||||
|
axios.post(url,{
|
||||||
|
name:title_value,
|
||||||
|
description:Textarea_comment,
|
||||||
|
}
|
||||||
|
).then((response) => {
|
||||||
|
if(response.data.status===0){
|
||||||
|
|
||||||
|
this.props.getosshackathon()
|
||||||
|
this.props.hideeditSignupentry()
|
||||||
|
this.props.showNotification(`提交成功`);
|
||||||
|
}
|
||||||
|
}).catch((error) => {
|
||||||
|
console.log(error)
|
||||||
|
})
|
||||||
|
}else{
|
||||||
|
let url=`/osshackathon/${this.props.modelid}.json`
|
||||||
|
axios.put(url,{
|
||||||
|
name:title_value,
|
||||||
|
description:Textarea_comment,
|
||||||
|
}
|
||||||
|
).then((response) => {
|
||||||
|
if(response.data.status===0){
|
||||||
|
|
||||||
|
this.props.getosshackathon()
|
||||||
|
this.props.hideeditSignupentry()
|
||||||
|
this.props.showNotification(`提交成功`);
|
||||||
|
}
|
||||||
|
}).catch((error) => {
|
||||||
|
console.log(error)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
changeTitle=(e)=>{
|
||||||
|
this.setState({
|
||||||
|
title_value:e.target.value,
|
||||||
|
title_num:e.target.value.length,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
Textarea_comment=(e)=>{
|
||||||
|
this.setState({
|
||||||
|
Textarea_comment:e.target.value,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
render() {
|
||||||
|
let {textareavaltype}=this.state;
|
||||||
|
// console.log(this.props.tabkey)
|
||||||
|
console.log(this.props.Osshackathonmodeltype)
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
{
|
||||||
|
`
|
||||||
|
@media (max-width: 2000px) {
|
||||||
|
.WordNumberTextarea{
|
||||||
|
height: 130px !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 1350px) {
|
||||||
|
.HomeworkModal{
|
||||||
|
top:10px !important;
|
||||||
|
}
|
||||||
|
.WordNumberTextarea{
|
||||||
|
height: 80px !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 1250px) {
|
||||||
|
.HomeworkModal{
|
||||||
|
top:0px !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.WordNumberTextarea{
|
||||||
|
height: 40px !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
`
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<Modal
|
||||||
|
keyboard={false}
|
||||||
|
className={"HomeworkModal"}
|
||||||
|
title={"新建项目"}
|
||||||
|
visible={this.props.Osshackathonmodeltype}
|
||||||
|
closable={false}
|
||||||
|
footer={null}
|
||||||
|
destroyOnClose={true}
|
||||||
|
>
|
||||||
|
|
||||||
|
<div className={"pd015"}>
|
||||||
|
<style>
|
||||||
|
{
|
||||||
|
`
|
||||||
|
.pd015{
|
||||||
|
padding: 0px 15px 15px 15px;
|
||||||
|
}
|
||||||
|
.font{
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 400;
|
||||||
|
color: rgba(5,16,26,1);
|
||||||
|
}
|
||||||
|
.newfont{
|
||||||
|
height: 16px;
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: 400;
|
||||||
|
color: rgba(5,16,26,1);
|
||||||
|
line-height: 16px;
|
||||||
|
margin-bottom: 5px;
|
||||||
|
}
|
||||||
|
.Osshackathonmodelinput .ant-input, .ant-input .ant-input-suffix{
|
||||||
|
background: #fff !important;
|
||||||
|
}
|
||||||
|
.Osshackathonmodelinput .ant-input-group-wrapper{
|
||||||
|
width:510px !important;
|
||||||
|
margin-left: 10px;
|
||||||
|
}
|
||||||
|
`
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<div className="clearfix">
|
||||||
|
<p className={"font mt10 mb10 ml10"}>
|
||||||
|
名称
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<Input placeholder="请输入项目名称"
|
||||||
|
value={this.state.title_value}
|
||||||
|
onInput={(e)=>this.changeTitle(e)}
|
||||||
|
className={"Osshackathonmodelinput"}
|
||||||
|
style={{"width": "100%"}} maxLength="60"
|
||||||
|
addonAfter={String(this.state.title_value===undefined?0:this.state.title_value.length)+"/60"}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<p className={"font mt10 mb10 ml10"}>
|
||||||
|
描述
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<WordNumberTextarea
|
||||||
|
placeholder={"请输入项目描述"}
|
||||||
|
onInput={(e)=>this.Textarea_comment(e)}
|
||||||
|
value={this.state.Textarea_comment}
|
||||||
|
maxlength={500}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<li style={{height:"20px",lineHeight:"20px"}} className={textareavaltype===true?"color-red mt20 mb10":"none"}><span>评阅内容至少有一个不为空</span></li>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className={textareavaltype===false?"mt20 clearfix edu-txt-center":"clearfix edu-txt-center mt20"}>
|
||||||
|
<a className="task-btn color-white mr30" onClick={()=>this.props.hideeditSignupentry()}>取消</a>
|
||||||
|
<a className="task-btn task-btn-orange" onClick={()=>this.handleSubmit()}>确定</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Modal>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export default Osshackathonmodel;
|
Loading…
Reference in new issue