diff --git a/app/assets/javascripts/admins/laboratory_subjects/index.js b/app/assets/javascripts/admins/laboratory_subjects/index.js
index a8b229d1f..b5fa3bffb 100644
--- a/app/assets/javascripts/admins/laboratory_subjects/index.js
+++ b/app/assets/javascripts/admins/laboratory_subjects/index.js
@@ -7,6 +7,7 @@ $(document).on('turbolinks:load', function() {
$searchForm.find('.school-select').select2({
theme: 'bootstrap4',
placeholder: '请选择创建者单位',
+ allowClear: true,
minimumInputLength: 1,
ajax: {
delay: 500,
diff --git a/app/assets/javascripts/cooperative/laboratory_shixuns/index.js b/app/assets/javascripts/cooperative/laboratory_shixuns/index.js
new file mode 100644
index 000000000..ef6018a8a
--- /dev/null
+++ b/app/assets/javascripts/cooperative/laboratory_shixuns/index.js
@@ -0,0 +1,60 @@
+$(document).on('turbolinks:load', function() {
+ if ($('body.cooperative-laboratory-shixuns-index-page').length > 0) {
+ var $searchForm = $('.laboratory-shixun-list-form .search-form');
+
+ $searchForm.find('select#tag_id').select2({
+ placeholder: "请选择",
+ allowClear: true
+ });
+
+ // 上传图片
+ $('.modal.cooperative-upload-file-modal').on('upload:success', function (e, data) {
+ var $imageElement = $('.shixun-image-' + data.source_id);
+ if($imageElement.length === 0) return;
+ $imageElement.attr('src', data.url);
+ $imageElement.show();
+ $imageElement.next().html('重新上传');
+ });
+
+ // 定义状态切换监听事件
+ 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: '/cooperative/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);
+ }
+})
\ No newline at end of file
diff --git a/app/assets/javascripts/cooperative/laboratory_subjects/index.js b/app/assets/javascripts/cooperative/laboratory_subjects/index.js
new file mode 100644
index 000000000..639c5d5df
--- /dev/null
+++ b/app/assets/javascripts/cooperative/laboratory_subjects/index.js
@@ -0,0 +1,83 @@
+$(document).on('turbolinks:load', function() {
+ if ($('body.cooperative-laboratory-subjects-index-page').length > 0) {
+ var $searchForm = $('.laboratory-subject-list-form .search-form');
+
+ // ************** 学校选择 *************
+ $searchForm.find('.school-select').select2({
+ theme: 'bootstrap4',
+ placeholder: '请选择创建者单位',
+ allowClear: true,
+ 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;
+ }
+ });
+
+ // 上传图片
+ $('.modal.cooperative-upload-file-modal').on('upload:success', function (e, data) {
+ var $imageElement = $('.subject-image-' + data.source_id);
+ if($imageElement.length === 0) return;
+ $imageElement.attr('src', data.url);
+ $imageElement.show();
+ $imageElement.next().html('重新上传');
+ });
+
+ // 定义状态切换监听事件
+ 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: '/cooperative/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);
+ }
+})
\ No newline at end of file
diff --git a/app/assets/javascripts/cooperative/modals/cooperative-edit-subject-modal.js b/app/assets/javascripts/cooperative/modals/cooperative-edit-subject-modal.js
new file mode 100644
index 000000000..414d04ed2
--- /dev/null
+++ b/app/assets/javascripts/cooperative/modals/cooperative-edit-subject-modal.js
@@ -0,0 +1,18 @@
+$(document).on('turbolinks:load', function () {
+ $('.cooperative-modal-container').on('show.bs.modal', '.modal.cooperative-edit-subject-modal', function () {
+ var $modal = $('.modal.cooperative-edit-subject-modal');
+ var $form = $modal.find('form.cooperative-edit-subject-form');
+
+ $modal.on('click', '.submit-btn', function () {
+ $form.find('.error').html('');
+ var url = $form.attr('action');
+
+ $.ajax({
+ method: 'PATCH',
+ dataType: 'script',
+ url: url,
+ data: $form.serialize()
+ });
+ });
+ })
+});
diff --git a/app/assets/javascripts/cooperative/modals/upload-file-modal.js b/app/assets/javascripts/cooperative/modals/upload-file-modal.js
index 835ccd383..302c534b6 100644
--- a/app/assets/javascripts/cooperative/modals/upload-file-modal.js
+++ b/app/assets/javascripts/cooperative/modals/upload-file-modal.js
@@ -42,7 +42,7 @@ $(document).on('turbolinks:load', function() {
$.ajax({
method: 'POST',
dataType: 'json',
- url: '/cooperatives/files?' + formDataString,
+ url: '/cooperative/files?' + formDataString,
data: new FormData($form[0]),
processData: false,
contentType: false,
diff --git a/app/assets/stylesheets/admins/common.scss b/app/assets/stylesheets/admins/common.scss
index aabe6085c..3437c3049 100644
--- a/app/assets/stylesheets/admins/common.scss
+++ b/app/assets/stylesheets/admins/common.scss
@@ -47,6 +47,12 @@
}
}
+ .image-preview-container {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ }
+
.action-container {
& > .action {
padding: 0 3px;
diff --git a/app/assets/stylesheets/cooperative/common.scss b/app/assets/stylesheets/cooperative/common.scss
index 488dd4caa..8e04e2328 100644
--- a/app/assets/stylesheets/cooperative/common.scss
+++ b/app/assets/stylesheets/cooperative/common.scss
@@ -47,6 +47,12 @@
}
}
+ .image-preview-container {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ }
+
.action-container {
& > .action {
padding: 0 3px;
diff --git a/app/controllers/concerns/base/render_helper.rb b/app/controllers/concerns/base/render_helper.rb
index e0aa49ac1..4d246c6cc 100644
--- a/app/controllers/concerns/base/render_helper.rb
+++ b/app/controllers/concerns/base/render_helper.rb
@@ -8,6 +8,7 @@ module Base::RenderHelper
def render_forbidden
render_by_format(html: -> { current_user&.business? ? render('shared/403') : redirect_to('/403') },
+ js: -> { render_js_error(I18n.t('error.forbidden'), type: :notify) },
json: -> { render status: 403, json: { messages: I18n.t('error.forbidden') } } )
end
diff --git a/app/controllers/cooperative/files_controller.rb b/app/controllers/cooperative/files_controller.rb
index 56710a968..20c0b0d5f 100644
--- a/app/controllers/cooperative/files_controller.rb
+++ b/app/controllers/cooperative/files_controller.rb
@@ -1,5 +1,5 @@
class Cooperative::FilesController < Cooperative::BaseController
- before_action :convert_file!, only: [:create]
+ before_action :convert_file!, :check_permission!, only: [:create]
def create
File.delete(file_path) if File.exist?(file_path) # 删除之前的文件
@@ -29,6 +29,22 @@ class Cooperative::FilesController < Cooperative::BaseController
render_error(ex.message)
end
+ def check_permission!
+ permission =
+ case params[:source_type].to_s
+ when '' then false
+ when 'Shixun' then
+ current_laboratory.laboratory_shixuns.exists?(ownership: true, shixun_id: params[:source_id])
+ when 'Subject' then
+ current_laboratory.laboratory_subjects.exists?(ownership: true, subject_id: params[:source_id])
+ else true
+ end
+
+ return if permission
+
+ render_forbidden
+ end
+
def file_path
@_file_path ||= begin
case params[:source_type].to_s
diff --git a/app/controllers/cooperative/laboratory_shixuns_controller.rb b/app/controllers/cooperative/laboratory_shixuns_controller.rb
new file mode 100644
index 000000000..e428416da
--- /dev/null
+++ b/app/controllers/cooperative/laboratory_shixuns_controller.rb
@@ -0,0 +1,39 @@
+class Cooperative::LaboratoryShixunsController < Cooperative::BaseController
+ before_action :check_shixun_ownership!, only: [:edit, :update]
+
+ helper_method :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 edit
+ end
+
+ def update
+
+ 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_shixun
+ @_current_laboratory_shixun ||= current_laboratory.laboratory_shixuns.find(params[:id])
+ end
+
+ def check_shixun_ownership!
+ return if current_laboratory_shixun.ownership?
+
+ render_forbidden
+ end
+end
\ No newline at end of file
diff --git a/app/controllers/cooperative/laboratory_subjects_controller.rb b/app/controllers/cooperative/laboratory_subjects_controller.rb
new file mode 100644
index 000000000..77088c223
--- /dev/null
+++ b/app/controllers/cooperative/laboratory_subjects_controller.rb
@@ -0,0 +1,46 @@
+class Cooperative::LaboratorySubjectsController < Cooperative::BaseController
+ before_action :check_subject_ownership!, only: [:edit, :update]
+
+ helper_method :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 edit
+ @laboratory_subject = current_laboratory_subject
+ end
+
+ def update
+ current_laboratory_subject.subject.update!(update_params)
+ 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_subject
+ @_current_laboratory_subject ||= current_laboratory.laboratory_subjects.find(params[:id])
+ end
+
+ def check_subject_ownership!
+ return if current_laboratory_subject.ownership?
+
+ render_forbidden
+ end
+
+ def update_params
+ params.require(:laboratory_subject).permit(:repertoire_id, :subject_level_system_id)
+ end
+end
\ No newline at end of file
diff --git a/app/controllers/student_works_controller.rb b/app/controllers/student_works_controller.rb
index 96307df8d..58406467d 100644
--- a/app/controllers/student_works_controller.rb
+++ b/app/controllers/student_works_controller.rb
@@ -526,11 +526,16 @@ class StudentWorksController < ApplicationController
@echart_data = student_efficiency(@homework, @work)
@myself_eff = @echart_data[:efficiency_list].find { |item| item.last == @user.id }
@myself_consume = @echart_data[:consume_list].find { |item| item.last == @user.id }
-
filename_ = "#{@use&.student_id}_#{@use&.real_name}_#{@shixun&.name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}"
filename = Base64.urlsafe_encode64(filename_.strip)
stylesheets = %w(shixun_work/shixun_work.css shared/codemirror.css)
- render pdf: 'shixun_work/shixun_work', filename: filename, stylesheets: stylesheets, disposition: 'inline', type:"pdf_attachment.content_type",stream:false
+ if params[:export].present? && params[:export]
+ normal_status(0,"正在下载中")
+ else
+ set_export_cookies
+ render pdf: 'shixun_work/shixun_work', filename: filename, stylesheets: stylesheets, disposition: 'inline', type:"pdf_attachment.content_type",stream:false
+ end
+ # render pdf: 'shixun_work/shixun_work', filename: filename, stylesheets: stylesheets, disposition: 'inline', type:"pdf_attachment.content_type",stream:false
end
# 作品调分
diff --git a/app/controllers/trustie_hacks_controller.rb b/app/controllers/trustie_hacks_controller.rb
index 803809124..22a7a2976 100644
--- a/app/controllers/trustie_hacks_controller.rb
+++ b/app/controllers/trustie_hacks_controller.rb
@@ -1,5 +1,5 @@
class TrustieHacksController < ApplicationController
- before_action :require_admin, :except => [:index]
+ before_action :require_admin, :except => [:index, :entry]
before_action :require_login, :except => [:index]
before_action :find_hackathon
before_action :find_hack, :except => [:create, :index, :edit_hackathon, :update_hackathon]
diff --git a/app/models/laboratory_subject.rb b/app/models/laboratory_subject.rb
index fa5862712..e56cd94bd 100644
--- a/app/models/laboratory_subject.rb
+++ b/app/models/laboratory_subject.rb
@@ -1,4 +1,6 @@
class LaboratorySubject < ApplicationRecord
belongs_to :laboratory
belongs_to :subject
+
+ delegate :repertoire_id, :subject_level_system_id, :student_count, to: :subject
end
\ No newline at end of file
diff --git a/app/models/trustie_hack.rb b/app/models/trustie_hack.rb
index b436007ca..7c2f3264b 100644
--- a/app/models/trustie_hack.rb
+++ b/app/models/trustie_hack.rb
@@ -1,4 +1,5 @@
class TrustieHack < ApplicationRecord
+ validates_length_of :description, maximum: 500
has_many :hack_users, :dependent => :destroy
belongs_to :trustie_hackathon, counter_cache: true
diff --git a/app/models/trustie_hackathon.rb b/app/models/trustie_hackathon.rb
index 7269e7856..65275099d 100644
--- a/app/models/trustie_hackathon.rb
+++ b/app/models/trustie_hackathon.rb
@@ -1,5 +1,5 @@
class TrustieHackathon < ApplicationRecord
-
+ validates_length_of :description, maximum: 500
has_many :trustie_hacks, :dependent => :destroy
end
diff --git a/app/views/admins/laboratory_shixuns/shared/_list.html.erb b/app/views/admins/laboratory_shixuns/shared/_list.html.erb
index 8463e2d49..e1244c472 100644
--- a/app/views/admins/laboratory_shixuns/shared/_list.html.erb
+++ b/app/views/admins/laboratory_shixuns/shared/_list.html.erb
@@ -7,8 +7,8 @@
封面
创建者
状态
- 执行时间
- 操作
+ 执行时间
+ 操作
diff --git a/app/views/cooperative/laboratory_shixuns/index.html.erb b/app/views/cooperative/laboratory_shixuns/index.html.erb
new file mode 100644
index 000000000..85781a85a
--- /dev/null
+++ b/app/views/cooperative/laboratory_shixuns/index.html.erb
@@ -0,0 +1,42 @@
+<% define_breadcrumbs do %>
+ <% add_breadcrumb('实训项目') %>
+<% end %>
+
+
+
+ <%= form_tag(cooperative_laboratory_shixuns_path, method: :get, class: 'form-inline search-form', remote: true) do %>
+
+ 状态:
+ <% status_options = [['全部', ''], ['编辑中', 0], ['审核中', 1], ['已发布', 2], ['已关闭', 3]] %>
+ <%= select_tag(:status, options_for_select(status_options), class: 'form-control') %>
+
+
+
+ 技术平台:
+ <%= select_tag(:tag_id, options_for_select(MirrorRepository.pluck(:type_name,:id).unshift(['']), params[:tag_id]), class: 'form-control') %>
+
+
+ <%= text_field_tag(:keyword, params[:keyword], class: 'form-control col-12 col-md-2 mr-3', placeholder: '创建者/实训名称检索') %>
+
+
+ <%= hidden_field_tag(:homepage, false, id:'') %>
+ <%= check_box_tag(:homepage, true, params[:homepage].to_s == 'true', class: 'form-check-input') %>
+ 只看首页展示
+
+
+
+ <%= hidden_field_tag(:ownership, false, id:'') %>
+ <%= check_box_tag(:ownership, true, params[:ownership].to_s == 'true', class: 'form-check-input') %>
+ 只看自建
+
+
+ <%= submit_tag('搜索', class: 'btn btn-primary ml-3', 'data-disable-with': '搜索中...') %>
+ <%= link_to '清空', cooperative_laboratory_shixuns_path, class: 'btn btn-default','data-disable-with': '清空中...' %>
+ <% end %>
+
+
+
+ <%= render partial: 'cooperative/laboratory_shixuns/shared/list', locals: { laboratory_shixuns: @laboratory_shixuns } %>
+
+
+<%= render(partial: 'cooperative/shared/modal/upload_file_modal', locals: { title: '上传封面', accept: 'image/*' }) %>
\ No newline at end of file
diff --git a/app/views/cooperative/laboratory_shixuns/index.js.erb b/app/views/cooperative/laboratory_shixuns/index.js.erb
new file mode 100644
index 000000000..927609f6c
--- /dev/null
+++ b/app/views/cooperative/laboratory_shixuns/index.js.erb
@@ -0,0 +1 @@
+$('.laboratory-shixun-list-container').html("<%= j(render partial: 'cooperative/laboratory_shixuns/shared/list', locals: { laboratory_shixuns: @laboratory_shixuns }) %>");
\ No newline at end of file
diff --git a/app/views/cooperative/laboratory_shixuns/shared/_list.html.erb b/app/views/cooperative/laboratory_shixuns/shared/_list.html.erb
new file mode 100644
index 000000000..1501e9f3b
--- /dev/null
+++ b/app/views/cooperative/laboratory_shixuns/shared/_list.html.erb
@@ -0,0 +1,27 @@
+
+
+
+ 实训名称
+ 技术平台
+ 技术体系
+ 封面
+ 创建者
+ 状态
+ 执行时间
+ 操作
+
+
+
+ <% if laboratory_shixuns.present? %>
+ <% laboratory_shixuns.each do |laboratory_shixun| %>
+
+ <%= render partial: 'cooperative/laboratory_shixuns/shared/td', locals: { laboratory_shixun: laboratory_shixun } %>
+
+ <% end %>
+ <% else %>
+ <%= render 'cooperative/shared/no_data_for_table' %>
+ <% end %>
+
+
+
+<%= render partial: 'cooperative/shared/paginate', locals: { objects: laboratory_shixuns } %>
\ No newline at end of file
diff --git a/app/views/cooperative/laboratory_shixuns/shared/_td.html.erb b/app/views/cooperative/laboratory_shixuns/shared/_td.html.erb
new file mode 100644
index 000000000..e7f87057d
--- /dev/null
+++ b/app/views/cooperative/laboratory_shixuns/shared/_td.html.erb
@@ -0,0 +1,32 @@
+<%- shixun = laboratory_shixun.shixun -%>
+
+
+ <%= link_to "/shixuns/#{shixun.identifier}", target: '_blank' do %>
+ <%= shixun.name %>
+ 首页
+ 自建
+ <% end %>
+
+<%= shixun.shixun_main_name %>
+
+ <% shixun.tag_repertoires.each do |tag| %>
+ <%= tag.name %>
+ <% end %>
+
+
+ <% imageExists = Util::FileManage.exists?(shixun) %>
+ <%= image_tag(imageExists ? Util::FileManage.source_disk_file_url(shixun) : '', height: 40, class: "preview-image shixun-image-#{shixun.id}", data: { toggle: 'tooltip', title: '点击预览' }, style: imageExists ? '' : 'display:none') %>
+ <% if laboratory_shixun.ownership? %>
+ <%= javascript_void_link imageExists ? '重新上传' : '上传图片', class: 'action upload-shixun-image-action', data: { source_id: shixun.id, source_type: 'Shixun', toggle: 'modal', target: '.cooperative-upload-file-modal' } %>
+ <% end %>
+
+<%= link_to shixun.user&.real_name, "/users/#{shixun.user&.login}", target:'_blank' %>
+<%= t("shixun.status.#{shixun.status}") %>
+<%= shixun.excute_time %>
+
+ <% if laboratory_shixun.ownership? %>
+ <%#= link_to('修改', cooperative_laboratory_subjects_path(laboratory_shixun)) %>
+ <% end %>
+ <%= 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') %>
+
\ No newline at end of file
diff --git a/app/views/cooperative/laboratory_subjects/edit.js.erb b/app/views/cooperative/laboratory_subjects/edit.js.erb
new file mode 100644
index 000000000..146879309
--- /dev/null
+++ b/app/views/cooperative/laboratory_subjects/edit.js.erb
@@ -0,0 +1,2 @@
+$('.cooperative-modal-container').html("<%= j( render partial: 'cooperative/laboratory_subjects/shared/edit_subject_modal', locals: { laboratory_subject: @laboratory_subject } ) %>");
+$('.modal.cooperative-edit-subject-modal').modal('show');
\ No newline at end of file
diff --git a/app/views/cooperative/laboratory_subjects/index.html.erb b/app/views/cooperative/laboratory_subjects/index.html.erb
new file mode 100644
index 000000000..3ed30b4f2
--- /dev/null
+++ b/app/views/cooperative/laboratory_subjects/index.html.erb
@@ -0,0 +1,42 @@
+<% define_breadcrumbs do %>
+ <% add_breadcrumb('实践课程') %>
+<% end %>
+
+
+
+ <%= form_tag(cooperative_laboratory_subjects_path, method: :get, class: 'form-inline search-form', remote: true) do %>
+
+ 状态:
+ <% status_options = [['全部', ''], ['编辑中', 0], ['审核中', 1], ['已发布', 2]] %>
+ <%= select_tag(:status, options_for_select(status_options), class: 'form-control') %>
+
+
+
+ 单位:
+ <%= select_tag :school_id, options_for_select([''], params[:school_id]), class: 'form-control school-select flex-1' %>
+
+
+ <%= text_field_tag(:keyword, params[:keyword], class: 'form-control col-12 col-md-2 mr-3', placeholder: '创建者/课程名称检索') %>
+
+
+ <%= hidden_field_tag(:homepage, false, id:'') %>
+ <%= check_box_tag(:homepage, true, params[:homepage].to_s == 'true', class: 'form-check-input') %>
+ 只看首页展示
+
+
+
+ <%= hidden_field_tag(:ownership, false, id:'') %>
+ <%= check_box_tag(:ownership, true, params[:ownership].to_s == 'true', class: 'form-check-input') %>
+ 只看自建
+
+
+ <%= submit_tag('搜索', class: 'btn btn-primary ml-3', 'data-disable-with': '搜索中...') %>
+ <%= link_to '清空', cooperative_laboratory_subjects_path(current_laboratory), class: 'btn btn-default','data-disable-with': '清空中...' %>
+ <% end %>
+
+
+
+ <%= render partial: 'cooperative/laboratory_subjects/shared/list', locals: { laboratory_subjects: @laboratory_subjects } %>
+
+
+<%= render(partial: 'cooperative/shared/modal/upload_file_modal', locals: { title: '上传封面', accept: 'image/*' }) %>
\ No newline at end of file
diff --git a/app/views/cooperative/laboratory_subjects/index.js.erb b/app/views/cooperative/laboratory_subjects/index.js.erb
new file mode 100644
index 000000000..557182485
--- /dev/null
+++ b/app/views/cooperative/laboratory_subjects/index.js.erb
@@ -0,0 +1 @@
+$('.laboratory-subject-list-container').html("<%= j(render partial: 'cooperative/laboratory_subjects/shared/list', locals: { laboratory_subjects: @laboratory_subjects }) %>");
\ No newline at end of file
diff --git a/app/views/cooperative/laboratory_subjects/shared/_edit_subject_modal.html.erb b/app/views/cooperative/laboratory_subjects/shared/_edit_subject_modal.html.erb
new file mode 100644
index 000000000..02ff4acbc
--- /dev/null
+++ b/app/views/cooperative/laboratory_subjects/shared/_edit_subject_modal.html.erb
@@ -0,0 +1,31 @@
+
+
+
+
+
+ <%= simple_form_for([:cooperative, laboratory_subject], html: { class: 'cooperative-edit-subject-form' }, defaults: { wrapper_html: { class: 'offset-md-1 col-md-10' } }) do |f| %>
+ <%= f.input :repertoire_id, label: '技术体系:' do %>
+ <% repertoire_options = Repertoire.order('CONVERT(name USING gbk) COLLATE gbk_chinese_ci ASC').map{|r| [r.name, r.id]} %>
+ <%= f.select :repertoire_id, [['请选择', '']] + repertoire_options, {}, class: 'form-control' %>
+ <% end %>
+
+ <%= f.input :subject_level_system_id, label: '等级体系:' do %>
+ <% level_options = SubjectLevelSystem.all.map{|r| [r.name, r.id]} %>
+ <%= f.select :subject_level_system_id, [['请选择', '']] + level_options, {}, class: 'form-control' %>
+ <% end %>
+
+
+ <% end %>
+
+
+
+
+
\ No newline at end of file
diff --git a/app/views/cooperative/laboratory_subjects/shared/_list.html.erb b/app/views/cooperative/laboratory_subjects/shared/_list.html.erb
new file mode 100644
index 000000000..2b972a959
--- /dev/null
+++ b/app/views/cooperative/laboratory_subjects/shared/_list.html.erb
@@ -0,0 +1,27 @@
+
+
+
+ 课程名称
+ 技术体系
+ 等级体系
+ 封面
+ 创建者
+ 单位
+ 状态
+ 操作
+
+
+
+ <% if laboratory_subjects.present? %>
+ <% laboratory_subjects.each do |laboratory_subject| %>
+
+ <%= render partial: 'cooperative/laboratory_subjects/shared/td', locals: { laboratory_subject: laboratory_subject } %>
+
+ <% end %>
+ <% else %>
+ <%= render 'cooperative/shared/no_data_for_table' %>
+ <% end %>
+
+
+
+<%= render partial: 'cooperative/shared/paginate', locals: { objects: laboratory_subjects } %>
\ No newline at end of file
diff --git a/app/views/cooperative/laboratory_subjects/shared/_td.html.erb b/app/views/cooperative/laboratory_subjects/shared/_td.html.erb
new file mode 100644
index 000000000..301bbd6a7
--- /dev/null
+++ b/app/views/cooperative/laboratory_subjects/shared/_td.html.erb
@@ -0,0 +1,28 @@
+<%- subject = laboratory_subject.subject -%>
+
+
+ <%= link_to(subject.name, "/paths/#{subject.id}", target: '_blank') %>
+ 首页
+ 自建
+
+<%= display_text subject.repertoire&.name %>
+<%= display_text subject.subject_level_system&.name %>
+
+ <% 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') %>
+ <% if laboratory_subject.ownership? %>
+ <%= javascript_void_link image_exists ? '重新上传' : '上传图片', class: 'action upload-subject-image-action', data: { source_id: subject.id, source_type: 'Subject', toggle: 'modal', target: '.cooperative-upload-file-modal' } %>
+ <% end %>
+
+<%= link_to subject.user&.real_name, "/users/#{subject.user&.login}", target:'_blank' %>
+<%= subject.user.school_name %>
+<%= display_subject_status(subject) %>
+
+
+ <% if laboratory_subject.ownership? %>
+ <%= link_to('修改', edit_cooperative_laboratory_subject_path(laboratory_subject), remote: true) %>
+ <% end %>
+
+ <%= 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') %>
+
\ No newline at end of file
diff --git a/app/views/cooperative/laboratory_subjects/update.js.erb b/app/views/cooperative/laboratory_subjects/update.js.erb
new file mode 100644
index 000000000..3b98e6e97
--- /dev/null
+++ b/app/views/cooperative/laboratory_subjects/update.js.erb
@@ -0,0 +1,3 @@
+$('.laboratory-subject-list-container .laboratory-subject-item-<%= current_laboratory_subject.id %>').html("<%= j(render partial: 'cooperative/laboratory_subjects/shared/td', locals: { laboratory_subject: current_laboratory_subject }) %>");
+$('.cooperative-modal-container .modal.cooperative-edit-subject-modal').modal('hide');
+show_success_flash();
diff --git a/app/views/cooperative/shared/_sidebar.html.erb b/app/views/cooperative/shared/_sidebar.html.erb
index 40a6b2de4..81ff12b0a 100644
--- a/app/views/cooperative/shared/_sidebar.html.erb
+++ b/app/views/cooperative/shared/_sidebar.html.erb
@@ -17,6 +17,8 @@
<%= sidebar_item(edit_cooperative_laboratory_setting_path, '网站设置', icon: 'cogs', controller: 'cooperative-laboratory_settings') %>
<%= sidebar_item(cooperative_carousels_path, '轮播图设置', icon: 'image', controller: 'cooperative-carousels') %>
<%= sidebar_item(cooperative_laboratory_users_path, '管理员列表', icon: 'user', controller: 'cooperative-laboratory_users') %>
+ <%= sidebar_item(cooperative_laboratory_shixuns_path, '实训项目', icon: 'window-restore', controller: 'cooperative-laboratory_shixuns') %>
+ <%= sidebar_item(cooperative_laboratory_subjects_path, '实践课程', icon: 'th-list', controller: 'cooperative-laboratory_subjects') %>
<%= sidebar_item('/', '返回主页', icon: 'sign-out', controller: 'root') %>
\ No newline at end of file
diff --git a/app/views/cooperative/shared/modal/_upload_file_modal.html.erb b/app/views/cooperative/shared/modal/_upload_file_modal.html.erb
index 8cd22a362..587002403 100644
--- a/app/views/cooperative/shared/modal/_upload_file_modal.html.erb
+++ b/app/views/cooperative/shared/modal/_upload_file_modal.html.erb
@@ -11,12 +11,13 @@