实训的导出下载

dev_aliyun_beta
SylorHuang 6 years ago
commit d046d35b17

@ -19,6 +19,13 @@
//= require_tree ./i18n //= require_tree ./i18n
//= require_tree ./admins //= require_tree ./admins
$.ajaxSetup({
beforeSend: function(xhr) {
xhr.setRequestHeader('X-CSRF-Token', $('meta[name="csrf-token"]').attr('content'));
}
});
// ******** select2 global config ******** // ******** select2 global config ********
$.fn.select2.defaults.set('theme', 'bootstrap4'); $.fn.select2.defaults.set('theme', 'bootstrap4');
$.fn.select2.defaults.set('language', 'zh-CN'); $.fn.select2.defaults.set('language', 'zh-CN');
@ -53,7 +60,6 @@ $(document).on("turbolinks:before-cache", function () {
$('[data-toggle="tooltip"]').tooltip('hide'); $('[data-toggle="tooltip"]').tooltip('hide');
$('[data-toggle="popover"]').popover('hide'); $('[data-toggle="popover"]').popover('hide');
}); });
// var progressBar = new Turbolinks.ProgressBar(); // var progressBar = new Turbolinks.ProgressBar();
// $(document).on('ajax:send', function(event){ // $(document).on('ajax:send', function(event){

@ -27,10 +27,11 @@ $(document).on('turbolinks:load', function() {
}); });
// modal visited fire // modal visited fire
$refuseModal.on('shown.bs.modal', function(){ $refuseModal.on('shown.bs.modal', function(){
$refuseModal.find('.modal-body input[name="reason"]').focus(); $refuseModal.find('.modal-body textarea[name="reason"]').focus();
}); });
$refuseModal.on('hide.bs.modal', function () { $refuseModal.on('hide.bs.modal', function () {
$applyIdInput.val(''); $applyIdInput.val('');
$refuseModal.find('.modal-body textarea[name="reason"]').val('');
$form.data('url', ''); $form.data('url', '');
}) })

@ -127,7 +127,7 @@ class ExerciseBankQuestionsController < ApplicationController
normal_status("创建成功") normal_status("创建成功")
rescue Exception => e rescue Exception => e
uid_logger_error(e.message) uid_logger_error(e.message)
tip_exception("试卷问题创建失败!") tip_exception(e.message)
raise ActiveRecord::Rollback raise ActiveRecord::Rollback
end end
end end
@ -311,7 +311,7 @@ class ExerciseBankQuestionsController < ApplicationController
normal_status(0,"试卷更新成功") normal_status(0,"试卷更新成功")
rescue Exception => e rescue Exception => e
uid_logger_error(e.message) uid_logger_error(e.message)
tip_exception("页面调用失败!") tip_exception(e.message)
raise ActiveRecord::Rollback raise ActiveRecord::Rollback
end end
end end
@ -347,7 +347,7 @@ class ExerciseBankQuestionsController < ApplicationController
end end
rescue Exception => e rescue Exception => e
uid_logger_error(e.message) uid_logger_error(e.message)
tip_exception("问题移动失败!") tip_exception(e.message)
end end
end end
end end
@ -364,7 +364,7 @@ class ExerciseBankQuestionsController < ApplicationController
normal_status(0, "删除成功") normal_status(0, "删除成功")
rescue Exception => e rescue Exception => e
uid_logger_error(e.message) uid_logger_error(e.message)
tip_exception("删除失败") tip_exception(e.message)
end end
end end
end end
@ -372,7 +372,7 @@ class ExerciseBankQuestionsController < ApplicationController
private private
def bank_admin def bank_admin
tip_exception(403, "无权限") unless @bank.user_id == current_user.id || current_user.admin? tip_exception(403, "无权限") unless @exercise.user_id == current_user.id || current_user.admin?
end end
def get_exercise def get_exercise

@ -54,7 +54,7 @@ class PollBankQuestionsController < ApplicationController
normal_status("创建成功") normal_status("创建成功")
rescue Exception => e rescue Exception => e
uid_logger_error(e.message) uid_logger_error(e.message)
tip_exception("问卷的问题创建失败!") tip_exception(e.message)
raise ActiveRecord::Rollback raise ActiveRecord::Rollback
end end
end end
@ -67,6 +67,7 @@ class PollBankQuestionsController < ApplicationController
p_answer = params[:question_answers] p_answer = params[:question_answers]
p_other_answer = params[:question_other_answer] p_other_answer = params[:question_other_answer]
p_answer_count = p_answer.count p_answer_count = p_answer.count
@poll_current_answers = @poll_question.exercise_bank_choices.count
@poll_question.exercise_bank_choices.each do |an| @poll_question.exercise_bank_choices.each do |an|
if (p_answer_count < @poll_current_answers) && (p_answer_count..@poll_current_answers).to_a.include?(an.choice_position) if (p_answer_count < @poll_current_answers) && (p_answer_count..@poll_current_answers).to_a.include?(an.choice_position)
an.destroy an.destroy
@ -104,7 +105,7 @@ class PollBankQuestionsController < ApplicationController
normal_status("问卷更新成功") normal_status("问卷更新成功")
rescue Exception => e rescue Exception => e
uid_logger_error(e.message) uid_logger_error(e.message)
tip_exception("更新失败") tip_exception(e.message)
raise ActiveRecord::Rollback raise ActiveRecord::Rollback
end end
end end
@ -113,7 +114,7 @@ class PollBankQuestionsController < ApplicationController
private private
def bank_admin def bank_admin
tip_exception(403, "无权限") unless @bank.user_id == current_user.id || current_user.admin? tip_exception(403, "无权限") unless @poll.user_id == current_user.id || current_user.admin?
end end
def get_poll def get_poll

@ -8,14 +8,14 @@
</button> </button>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<form class="admin-common-refuse-form"> <%= form_tag(admins_path, method: :post, class: 'admin-common-refuse-form') do %>
<%= hidden_field_tag(:apply_id, nil) %> <%= hidden_field_tag(:apply_id, nil) %>
<div class="form-group"> <div class="form-group">
<label for="reason" class="col-form-label">原因:</label> <label for="reason" class="col-form-label">原因:</label>
<%= text_area_tag(:reason, nil, class: 'form-control', placeholder: '我得说点儿什么最多200字') %> <%= text_area_tag(:reason, nil, class: 'form-control', placeholder: '我得说点儿什么最多200字') %>
</div> </div>
<div class="error text-danger"></div> <div class="error text-danger"></div>
</form> <% end %>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button> <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>

@ -1,2 +1 @@
json.content @content json.url "/shixuns/#{@shixun.identifier}/repository/master/shixun_show/#{@path}"
json.path @path

@ -2,6 +2,7 @@ json.homework_common_id @homework.id
json.category @homework.category_info json.category @homework.category_info
json.course_name @course.name json.course_name @course.name
json.work_id @work.id json.work_id @work.id
json.work_efficiency @homework.work_efficiency
if @shixun if @shixun
json.shixun_name @shixun.name json.shixun_name @shixun.name
# 总体评价 # 总体评价

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -1,7 +1,7 @@
import React, { Component } from 'react'; import React, { Component } from 'react';
import {Link} from 'react-router-dom' import {Link} from 'react-router-dom'
const map={"blue":"blueFull","greyBack":"greyBack","grey":"greyWidthFixed","green":"greenBack",'greyLine':"greyLine", const map={"blue":"blueFull","greyBack":"greyBack","grey":"greyWidthFixed","green":"greenBack",'greyLine':"greyLine",'orangeLine':"orangeLine",
'colorBlue': 'colorBlue', // 蓝字白底 'colorBlue': 'colorBlue', // 蓝字白底
} }
class ActionBtn extends Component { class ActionBtn extends Component {

@ -822,9 +822,7 @@ class Fileslists extends Component{
max-height:350px; max-height:350px;
overflow-y: auto; overflow-y: auto;
} }
.drop_down_menu li {
overflow: visible;
}
.courseSecond{ .courseSecond{
margin-left: 10px; margin-left: 10px;
padding: 10px; padding: 10px;

@ -186,23 +186,26 @@ class BoardsNew extends Component{
}); });
} }
onAttachmentRemove = (file) => { onAttachmentRemove = (file) => {
confirm({ if(file.response!=undefined){
// title: '确定要删除这个附件吗?', confirm({
title: '是否确认删除?', // title: '确定要删除这个附件吗?',
title: '是否确认删除?',
okText: '确定',
cancelText: '取消', okText: '确定',
// content: 'Some descriptions', cancelText: '取消',
onOk: () => { // content: 'Some descriptions',
this.deleteAttachment(file) onOk: () => {
}, this.deleteAttachment(file)
onCancel() { },
console.log('Cancel'); onCancel() {
}, console.log('Cancel');
}); },
});
return false;
}
return false;
} }
deleteAttachment = (file) => { deleteAttachment = (file) => {
// 初次上传不能直接取uid // 初次上传不能直接取uid
@ -275,7 +278,7 @@ class BoardsNew extends Component{
console.log('beforeUpload', file.name); console.log('beforeUpload', file.name);
const isLt150M = file.size / 1024 / 1024 < 150; const isLt150M = file.size / 1024 / 1024 < 150;
if (!isLt150M) { if (!isLt150M) {
message.error('文件大小必须小于150MB!'); this.props.showNotification('文件大小必须小于150MB!');
} }
return isLt150M; return isLt150M;
}, },

@ -320,8 +320,11 @@ class CommonWorkPost extends Component{
// ModalSave: ()=>this.deleteAttachment(file), // ModalSave: ()=>this.deleteAttachment(file),
// ModalCancel:this.cancelAttachment // ModalCancel:this.cancelAttachment
// }) // })
this.deleteAttachment(file) if(file.response!=undefined){
return false; this.deleteAttachment(file)
return false;
}
} }
cancelAttachment=()=>{ cancelAttachment=()=>{
@ -594,7 +597,7 @@ render(){
console.log('beforeUpload', file.name); console.log('beforeUpload', file.name);
const isLt150M = file.size / 1024 / 1024 < 150; const isLt150M = file.size / 1024 / 1024 < 150;
if (!isLt150M) { if (!isLt150M) {
message.error('文件大小必须小于150MB!'); this.props.showNotification('文件大小必须小于150MB!');
} }
return isLt150M; return isLt150M;
}, },

@ -243,19 +243,22 @@ class NewWork extends Component{
} }
onAttachmentRemove = (file, stateName) => { onAttachmentRemove = (file, stateName) => {
this.props.confirm({ if(file.response!=undefined){
content: '是否确认删除?', this.props.confirm({
content: '是否确认删除?',
onOk: () => {
this.deleteAttachment(file, stateName) onOk: () => {
}, this.deleteAttachment(file, stateName)
onCancel() { },
console.log('Cancel'); onCancel() {
}, console.log('Cancel');
}); },
});
return false;
}
return false;
} }
deleteAttachment = (file, stateName) => { deleteAttachment = (file, stateName) => {
// 初次上传不能直接取uid // 初次上传不能直接取uid
@ -335,7 +338,7 @@ class NewWork extends Component{
console.log('beforeUpload', file.name); console.log('beforeUpload', file.name);
const isLt150M = file.size / 1024 / 1024 < 150; const isLt150M = file.size / 1024 / 1024 < 150;
if (!isLt150M) { if (!isLt150M) {
message.error('文件大小必须小于150MB!'); this.props.showNotification('文件大小必须小于150MB!');
} }
return isLt150M; return isLt150M;
}, },
@ -354,7 +357,7 @@ class NewWork extends Component{
console.log('beforeUpload', file.name); console.log('beforeUpload', file.name);
const isLt150M = file.size / 1024 / 1024 < 150; const isLt150M = file.size / 1024 / 1024 < 150;
if (!isLt150M) { if (!isLt150M) {
message.error('文件大小必须小于150MB!'); this.props.showNotification('文件大小必须小于150MB!');
} }
return isLt150M; return isLt150M;
}, },

@ -73,8 +73,9 @@ class AccessoryModal extends Component{
// ModalCancel:this.cancelAttachment // ModalCancel:this.cancelAttachment
// }) // })
// return false; // return false;
if(file.response!=undefined){
this.deleteAttachment(file); this.deleteAttachment(file);
}
} }
@ -256,7 +257,7 @@ class AccessoryModal extends Component{
console.log('beforeUpload', file.name); console.log('beforeUpload', file.name);
const isLt150M = file.size / 1024 / 1024 < 150; const isLt150M = file.size / 1024 / 1024 < 150;
if (!isLt150M) { if (!isLt150M) {
message.error('文件大小必须小于150MB!'); this.props.showNotification('文件大小必须小于150MB!');
} }
return isLt150M; return isLt150M;
}, },

@ -64,8 +64,10 @@ class AccessoryModal2 extends Component{
// ModalCancel:this.cancelAttachment // ModalCancel:this.cancelAttachment
// }) // })
// return false; // return false;
if(file.response!=undefined){
this.deleteAttachment(file);
}
this.deleteAttachment(file);
} }
@ -178,7 +180,7 @@ class AccessoryModal2 extends Component{
console.log('beforeUpload', file.name); console.log('beforeUpload', file.name);
const isLt150M = file.size / 1024 / 1024 < 150; const isLt150M = file.size / 1024 / 1024 < 150;
if (!isLt150M) { if (!isLt150M) {
message.error('文件大小必须小于150MB!'); this.props.showNotification('文件大小必须小于150MB!');
} }
return isLt150M; return isLt150M;
}, },

@ -296,37 +296,44 @@ class Selectsetting extends Component{
onAttachmentRemove = (file) => { onAttachmentRemove = (file) => {
if(file.response!=undefined){
const url = `/attachments/${file.response ? file.response.id : file.uid}.json`
axios.delete(url, {
})
.then((response) => {
if (response.data) {
const { status } = response.data;
if (status == 0) {
// const url = `/attachments/${file.response ? file.response.id : file.uid}.json` this.setState({
const url = `/attachments/${file.response ? file.response.id : file.uid}.json` fileListtype:false,
axios.delete(url, { fileList:[]
}) })
.then((response) => { // this.setState((state) => {
if (response.data) { // const index = state.fileList.indexOf(file);
const { status } = response.data; // const newFileList = state.fileList.slice();
if (status == 0) { // newFileList.splice(index, 1);
// return {
this.setState({ // fileList: newFileList,
fileListtype:false, // };
fileList:[] // });
}) }
// this.setState((state) => {
// const index = state.fileList.indexOf(file);
// const newFileList = state.fileList.slice();
// newFileList.splice(index, 1);
// return {
// fileList: newFileList,
// };
// });
} }
} })
.catch(function (error) {
console.log(error);
});
this.setState({
fileListtype:false,
}) })
.catch(function (error) { }else{
console.log(error); this.setState({
}); fileListtype:false,
this.setState({ fileList:[]
fileListtype:false, })
}) }
// const url = `/attachments/${file.response ? file.response.id : file.uid}.json`
} }
onChangeTimepublishs= (date, dateString,key) => { onChangeTimepublishs= (date, dateString,key) => {
@ -389,7 +396,7 @@ class Selectsetting extends Component{
console.log('beforeUpload', file.name); console.log('beforeUpload', file.name);
const isLt150M = file.size / 1024 / 1024 < 150; const isLt150M = file.size / 1024 / 1024 < 150;
if (!isLt150M) { if (!isLt150M) {
message.error('文件大小必须小于150MB!'); this.props.showNotification('文件大小必须小于150MB!');
} }
return isLt150M; return isLt150M;
}, },

@ -132,28 +132,34 @@ class Sendresource extends Component{
onAttachmentRemove = (file) => { onAttachmentRemove = (file) => {
debugger if(file.response!=undefined){
const url = `/attachments/${file.response ? file.response.id : file.uid}.json` const url = `/attachments/${file.response ? file.response.id : file.uid}.json`
axios.delete(url, { axios.delete(url, {
}) })
.then((response) => { .then((response) => {
if (response.data) { if (response.data) {
const { status } = response.data; const { status } = response.data;
if (status == 0) { if (status == 0) {
this.setState({ this.setState({
fileListtype:false, fileListtype:false,
fileList:[] fileList:[]
}) })
} }
} }
}) })
.catch(function (error) { .catch(function (error) {
console.log(error); console.log(error);
}); });
this.setState({ this.setState({
fileListtype:false, fileListtype:false,
}) })
}else{
this.setState({
fileListtype:false,
fileList:[]
})
}
} }
ModalCancelModalCancel=()=>{ ModalCancelModalCancel=()=>{
@ -338,7 +344,7 @@ debugger
// console.log('beforeUpload', file.name); // console.log('beforeUpload', file.name);
const isLt150M = file.size / 1024 / 1024 < 150; const isLt150M = file.size / 1024 / 1024 < 150;
if (!isLt150M) { if (!isLt150M) {
message.error('文件大小必须小于150MB!'); this.props.showNotification('文件大小必须小于150MB!');
} }
return isLt150M; return isLt150M;
}, },

@ -708,7 +708,14 @@ a.white-btn.use_scope-btn:hover{
color: #999!important; color: #999!important;
padding:0px 10px; padding:0px 10px;
} }
.orangeLine{
background: #fff;
border:1px solid #FE944B;
color: #FE944B!important;
padding:0px 10px;
line-height: 28px;
border-radius: 4px;
}
.colorFF6800{ .colorFF6800{
color:#FF6800; color:#FF6800;

@ -332,17 +332,17 @@ class Testpapersettinghomepage extends Component{
<div className="fl task_menu_ul"> <div className="fl task_menu_ul">
{this.props.isAdmin()===true? {this.props.isAdmin()===true?
<Menu mode="horizontal" selectedKeys={tab} onClick={this.changeTab}> <Menu mode="horizontal" selectedKeys={tab} onClick={this.changeTab}>
<Menu.Item key="0">答题列表</Menu.Item> <Menu.Item key="0" className={"exercisesafonts"}>答题列表</Menu.Item>
<Menu.Item key="1">统计结果</Menu.Item> <Menu.Item key="1" className={"exercisesafonts"}>统计结果</Menu.Item>
<Menu.Item key="2">试卷预览</Menu.Item> <Menu.Item key="2" className={"exercisesafonts"}>试卷预览</Menu.Item>
<Menu.Item key="3">设置</Menu.Item> <Menu.Item key="3" className={"exercisesafonts"}>设置</Menu.Item>
</Menu> </Menu>
: :
<Menu mode="horizontal" selectedKeys={tab} onClick={this.changeTab}> <Menu mode="horizontal" selectedKeys={tab} onClick={this.changeTab}>
<Menu.Item key="0">答题列表</Menu.Item> <Menu.Item key="0" className={"exercisesafonts"}>答题列表</Menu.Item>
{Commonheadofthetestpaper&&Commonheadofthetestpaper.show_statistic===true? {Commonheadofthetestpaper&&Commonheadofthetestpaper.show_statistic===true?
<Menu.Item key="1">统计结果</Menu.Item>:""} <Menu.Item key="1" className={"exercisesafonts"}>统计结果</Menu.Item>:""}
<Menu.Item key="3">设置</Menu.Item> <Menu.Item key="3" className={"exercisesafonts"}>设置</Menu.Item>
</Menu> </Menu>
} }
</div> </div>
@ -370,7 +370,7 @@ class Testpapersettinghomepage extends Component{
padding-top: 10px; padding-top: 10px;
padding-bottom: 8px; padding-bottom: 8px;
} }
a:hover { .exercisesafonts:hover {
color:#1A0B00 !important; color:#1A0B00 !important;
} }
`} `}

@ -157,49 +157,52 @@ class GraduationTasksSubmitedit extends Component{
} }
onAttachmentRemove = (file) => { onAttachmentRemove = (file) => {
let {attachments,fileList}=this.state; if(file.response!=undefined){
const url = `/attachments/${file}.json` let {attachments,fileList}=this.state;
axios.delete(url, { const url = `/attachments/${file}.json`
}) axios.delete(url, {
.then((response) => { })
if (response.data) { .then((response) => {
// const { status } = response.data; if (response.data) {
if (response.data.status === 0) { // const { status } = response.data;
console.log('--- success') if (response.data.status === 0) {
let newattachments=attachments; console.log('--- success')
if(file.uid===undefined){ let newattachments=attachments;
for(var i=0; i<newattachments.length; i++){ if(file.uid===undefined){
if(newattachments[i].id===file.id){ for(var i=0; i<newattachments.length; i++){
newattachments.splice(i, 1); if(newattachments[i].id===file.id){
} newattachments.splice(i, 1);
} }
}
} }
this.setState({ this.setState({
Modalstype:true, Modalstype:true,
Modalstopval:response.data.message, Modalstopval:response.data.message,
ModalSave:this.cancelAttachment, ModalSave:this.cancelAttachment,
Loadtype:true, Loadtype:true,
attachments:newattachments attachments:newattachments
}) })
this.setState((state) => { this.setState((state) => {
const index = state.fileList.indexOf(file); const index = state.fileList.indexOf(file);
const newFileList = state.fileList.slice(); const newFileList = state.fileList.slice();
newFileList.splice(index, 1); newFileList.splice(index, 1);
return { return {
fileList: newFileList, fileList: newFileList,
}; };
}); });
} }
} }
}) })
.catch(function (error) { .catch(function (error) {
console.log(error); console.log(error);
}); });
}
} }
inputSearchValue=(e)=>{ inputSearchValue=(e)=>{
@ -520,7 +523,7 @@ class GraduationTasksSubmitedit extends Component{
console.log('beforeUpload', file.name); console.log('beforeUpload', file.name);
const isLt150M = file.size / 1024 / 1024 < 150; const isLt150M = file.size / 1024 / 1024 < 150;
if (!isLt150M) { if (!isLt150M) {
message.error('文件大小必须小于150MB!'); this.props.showNotification('文件大小必须小于150MB!');
} }
return isLt150M; return isLt150M;
}, },

@ -146,14 +146,16 @@ class GraduationTasksSubmitnew extends Component{
// }, // },
// }); // });
// return false; // return false;
if(file.response!=undefined){
this.setState({
Modalstype:true,
Modalstopval:'确定要删除这个附件吗?',
ModalSave: ()=>this.deleteAttachment(file),
ModalCancel:this.cancelAttachment
})
return false;
}
this.setState({
Modalstype:true,
Modalstopval:'确定要删除这个附件吗?',
ModalSave: ()=>this.deleteAttachment(file),
ModalCancel:this.cancelAttachment
})
return false;
} }
cancelAttachment=()=>{ cancelAttachment=()=>{
@ -538,7 +540,7 @@ render(){
console.log('beforeUpload', file.name); console.log('beforeUpload', file.name);
const isLt150M = file.size / 1024 / 1024 < 150; const isLt150M = file.size / 1024 / 1024 < 150;
if (!isLt150M) { if (!isLt150M) {
message.error('文件大小必须小于150MB!'); this.props.showNotification('文件大小必须小于150MB!');
} }
return isLt150M; return isLt150M;
}, },

@ -88,21 +88,24 @@ class GraduationTasksappraiseMainEditor extends Component{
this.setState({ fileList }); this.setState({ fileList });
} }
onAttachmentRemove = (file, stateName) => { onAttachmentRemove = (file, stateName) => {
this.props.confirm({ if(file.response!=undefined){
content: '确定要删除这个附件吗?', this.props.confirm({
okText: '确定', content: '确定要删除这个附件吗?',
cancelText: '取消', okText: '确定',
// content: 'Some descriptions', cancelText: '取消',
onOk: () => { // content: 'Some descriptions',
this.deleteAttachment(file, stateName) onOk: () => {
}, this.deleteAttachment(file, stateName)
onCancel() { },
console.log('Cancel'); onCancel() {
}, console.log('Cancel');
}); },
});
return false;
}
return false;
} }
deleteAttachment = (file, stateName) => { deleteAttachment = (file, stateName) => {
// 初次上传不能直接取uid // 初次上传不能直接取uid
@ -169,7 +172,7 @@ class GraduationTasksappraiseMainEditor extends Component{
console.log('beforeUpload', file.name); console.log('beforeUpload', file.name);
const isLt150M = file.size / 1024 / 1024 < 150; const isLt150M = file.size / 1024 / 1024 < 150;
if (!isLt150M) { if (!isLt150M) {
message.error('文件大小必须小于150MB!'); this.props.showNotification('文件大小必须小于150MB!');
} }
return isLt150M; return isLt150M;
}, },

@ -103,14 +103,16 @@ class GraduationTasksedit extends Component{
} }
// 附件相关 START // 附件相关 START
handleChange = (info) => { handleChange = (info) => {
let fileList = info.fileList; if(info.file.status == "done" || info.file.status == "uploading"){
// console.log(fileList) let fileList = info.fileList;
// for(var list of fileList ){ // console.log(fileList)
// console.log(fileList) // for(var list of fileList ){
// } // console.log(fileList)
this.setState({ // }
fileList: appendFileSizeToUploadFileAll(fileList), this.setState({
}); fileList: appendFileSizeToUploadFileAll(fileList),
});
}
} }
// onAttachmentRemove = (file) => { // onAttachmentRemove = (file) => {
@ -148,39 +150,42 @@ class GraduationTasksedit extends Component{
} }
onAttachmentRemove = (file) => { onAttachmentRemove = (file) => {
// debugger if(file.response!=undefined){
this.cancelAttachment(); // debugger
const url = `/attachments/${file.response ? file.response.id : file.uid}.json` this.cancelAttachment();
// const url = `/attachments/${file}.json` const url = `/attachments/${file.response ? file.response.id : file.uid}.json`
axios.delete(url, { // const url = `/attachments/${file}.json`
}) axios.delete(url, {
.then((response) => { })
if (response.data) { .then((response) => {
if (response.data) {
if ( response.data.status === 0) {
if ( response.data.status === 0) {
this.setState({
Modalstype:false, this.setState({
Modalstopval:response.data.message, Modalstype:false,
ModalSave:this.cancelAttachment, Modalstopval:response.data.message,
Loadtype:true, ModalSave:this.cancelAttachment,
}) Loadtype:true,
})
this.setState((state) => {
this.setState((state) => {
const index = state.fileList.indexOf(file);
const newFileList = state.fileList.slice(); const index = state.fileList.indexOf(file);
newFileList.splice(index, 1); const newFileList = state.fileList.slice();
return { newFileList.splice(index, 1);
fileList: newFileList, return {
}; fileList: newFileList,
}); };
} });
} }
}) }
.catch(function (error) { })
console.log(error); .catch(function (error) {
}); console.log(error);
});
}
} }
Commoninterface=(fileList)=>{ Commoninterface=(fileList)=>{
@ -294,7 +299,7 @@ class GraduationTasksedit extends Component{
console.log('beforeUpload', file.name); console.log('beforeUpload', file.name);
const isLt150M = file.size / 1024 / 1024 < 150; const isLt150M = file.size / 1024 / 1024 < 150;
if (!isLt150M) { if (!isLt150M) {
message.error('文件大小必须小于150MB!'); this.props.showNotification('文件大小必须小于150MB!');
} }
return isLt150M; return isLt150M;
}, },

@ -57,24 +57,22 @@ class GraduationTasksnew extends Component {
} }
// if (GraduationTasksnewtype === true) { // if (GraduationTasksnewtype === true) {
this.props.form.validateFields((err, values) => { this.props.form.validateFields((err, values) => {
if (values.tasktype === undefined) {
this.ifHasAnchorJustScorll("tasktypes");
return
}
if (values.name === undefined) {
this.ifHasAnchorJustScorll("nametypes");
return
}
if (values.description === undefined) {
this.ifHasAnchorJustScorll("descriptiontypes");
return
}else if (values.description.length > 5000) {
this.ifHasAnchorJustScorll("descriptiontypes");
return
}
if (!err) { if (!err) {
if (values.tasktype === undefined) {
this.scrollToAnchors("tasktypes");
return
}
if (values.name === undefined) {
this.scrollToAnchors("nametypes");
return
}
if (values.description === undefined) {
this.scrollToAnchors("descriptiontypes");
return
} else if (values.description.length > 5000) {
this.scrollToAnchors("descriptiontypes");
return
}
// console.log('Received values of form: ', values); // console.log('Received values of form: ', values);
// console.log(fileList); // console.log(fileList);
const course_id = this.props.match.params.coursesId; const course_id = this.props.match.params.coursesId;
@ -129,14 +127,16 @@ class GraduationTasksnew extends Component {
} }
// 附件相关 START // 附件相关 START
handleChange = (info) => { handleChange = (info) => {
let fileList = info.fileList; if(info.file.status == "done" || info.file.status == "uploading"){
let fileList = info.fileList;
// for(var list of fileList ){
// console.log(list) // for(var list of fileList ){
// } // console.log(list)
this.setState({ // }
fileList: appendFileSizeToUploadFileAll(fileList), this.setState({
}); fileList: appendFileSizeToUploadFileAll(fileList),
});
}
} }
// onAttachmentRemove = (file) => { // onAttachmentRemove = (file) => {
@ -173,30 +173,33 @@ class GraduationTasksnew extends Component {
} }
onAttachmentRemove = (file) => { onAttachmentRemove = (file) => {
const url = `/attachments/${file.response ? file.response.id : file.uid}.json` if(file.response!=undefined){
// const url = `/attachments/${file}.json` const url = `/attachments/${file.response ? file.response.id : file.uid}.json`
axios.delete(url, {}) // const url = `/attachments/${file}.json`
.then((response) => { axios.delete(url, {})
if (response.data) { .then((response) => {
const {status} = response.data; if (response.data) {
if (status == 0) { const {status} = response.data;
console.log('--- success') if (status == 0) {
console.log('--- success')
this.setState((state) => {
const index = state.fileList.indexOf(file); this.setState((state) => {
const newFileList = state.fileList.slice(); const index = state.fileList.indexOf(file);
newFileList.splice(index, 1); const newFileList = state.fileList.slice();
return { newFileList.splice(index, 1);
fileList: newFileList, return {
}; fileList: newFileList,
}); };
this.cancelAttachment() });
this.cancelAttachment()
}
} }
} })
}) .catch(function (error) {
.catch(function (error) { console.log(error);
console.log(error); });
}); }
} }
//滚动 //滚动
@ -271,7 +274,7 @@ class GraduationTasksnew extends Component {
console.log('beforeUpload', file.name); console.log('beforeUpload', file.name);
const isLt150M = file.size / 1024 / 1024 < 150; const isLt150M = file.size / 1024 / 1024 < 150;
if (!isLt150M) { if (!isLt150M) {
message.error('文件大小必须小于150MB!'); this.props.showNotification('文件大小必须小于150MB!');
} }
return isLt150M; return isLt150M;
}, },

@ -215,19 +215,23 @@ class GraduateTopicNew extends Component{
this.setState({ fileList }); this.setState({ fileList });
} }
onAttachmentRemove = (file) => { onAttachmentRemove = (file) => {
confirm({
title: '确定要删除这个附件吗?', if(file.response!=undefined){
okText: '确定', confirm({
cancelText: '取消', title: '确定要删除这个附件吗?',
// content: 'Some descriptions', okText: '确定',
onOk: () => { cancelText: '取消',
this.deleteAttachment(file) // content: 'Some descriptions',
}, onOk: () => {
onCancel() { this.deleteAttachment(file)
console.log('Cancel'); },
}, onCancel() {
}); console.log('Cancel');
return false; },
});
return false;
}
} }
deleteAttachment = (file) => { deleteAttachment = (file) => {
console.log(file); console.log(file);
@ -310,7 +314,7 @@ class GraduateTopicNew extends Component{
console.log('beforeUpload', file.name); console.log('beforeUpload', file.name);
const isLt150M = file.size / 1024 / 1024 < 150; const isLt150M = file.size / 1024 / 1024 < 150;
if (!isLt150M) { if (!isLt150M) {
message.error('文件大小必须小于150MB!'); this.props.showNotification('文件大小必须小于150MB!');
} }
return isLt150M; return isLt150M;
}, },

@ -163,21 +163,25 @@ class GraduateTopicPostWorksNew extends Component{
this.setState({ fileList }); this.setState({ fileList });
} }
onAttachmentRemove = (file) => { onAttachmentRemove = (file) => {
confirm({ if(file.response!=undefined){
title: '确定要删除这个附件吗?', confirm({
okText: '确定', title: '确定要删除这个附件吗?',
cancelText: '取消', okText: '确定',
// content: 'Some descriptions', cancelText: '取消',
onOk: () => { // content: 'Some descriptions',
this.deleteAttachment(file) onOk: () => {
}, this.deleteAttachment(file)
onCancel() { },
console.log('Cancel'); onCancel() {
}, console.log('Cancel');
}); },
});
return false;
}
return false;
} }
deleteAttachment = (file) => { deleteAttachment = (file) => {
const url = `/attachments/${file.id}.json` const url = `/attachments/${file.id}.json`
@ -249,7 +253,7 @@ class GraduateTopicPostWorksNew extends Component{
console.log('beforeUpload', file.name); console.log('beforeUpload', file.name);
const isLt150M = file.size / 1024 / 1024 < 150; const isLt150M = file.size / 1024 / 1024 < 150;
if (!isLt150M) { if (!isLt150M) {
message.error('文件大小必须小于150MB!'); this.props.showNotification('文件大小必须小于150MB!');
} }
return isLt150M; return isLt150M;
}, },

@ -73,18 +73,21 @@ class CreateGroupByImportModal extends Component{
} }
onAttachmentRemove = (file) => { onAttachmentRemove = (file) => {
this.props.confirm({ if(file.response!=undefined){
content: '是否确认删除?', this.props.confirm({
content: '是否确认删除?',
onOk: () => {
this.deleteAttachment(file) onOk: () => {
}, this.deleteAttachment(file)
onCancel() { },
console.log('Cancel'); onCancel() {
}, console.log('Cancel');
}); },
});
return false;
return false;
}
} }
deleteAttachment = (file) => { deleteAttachment = (file) => {
const url = `/attachments/${file.response ? file.response.id : file.uid}.json` const url = `/attachments/${file.response ? file.response.id : file.uid}.json`

@ -280,9 +280,13 @@ class PollNew extends Component {
questionnair: true, questionnair: true,
left_banner_id:result.data.left_banner_id left_banner_id:result.data.left_banner_id
}) })
// console.log(this.state.polls_nametest) if( result.data.poll.polls_name){
// console.log(this.state.polls_descriptiontest) if( result.data.poll.polls_name.length>0){
// } this.setState({
addonAfter: result.data.poll.polls_name.length,
})
}
}
}).catch((error) => { }).catch((error) => {
console.log(error) console.log(error)
}) })
@ -326,8 +330,13 @@ class PollNew extends Component {
polls_descriptiontest: result.data.poll.polls_description, polls_descriptiontest: result.data.poll.polls_description,
questionnair: true, questionnair: true,
}) })
if( result.data.poll.polls_name){
// } if( result.data.poll.polls_name.length>0){
this.setState({
addonAfter: result.data.poll.polls_name.length,
})
}
}
}).catch((error) => { }).catch((error) => {
console.log(error) console.log(error)
}) })
@ -966,18 +975,23 @@ class PollNew extends Component {
if (this.state.problemtopicbool === true) { if (this.state.problemtopicbool === true) {
insindex = this.state.problemtopic; insindex = this.state.problemtopic;
} }
this.createquestionsandanswers(object, 1, arrc, null, 0, 0, insindex); this.createquestionsandanswers(object, 1, arrc, null, 0, 0, insindex,0);
// newarrpoll.push(question); // newarrpoll.push(question);
newarrpoll.splice(thiss.state.Insertposition, 0, question); newarrpoll.splice(thiss.state.Insertposition, 0, question);
} else if (object.question.question_type === 2) { } else if (object.question.question_type === 2) {
//插入多选题 //插入多选题
if (object.question.max_choices < object.question.min_choices) { if(object.question.max_choices){
this.props.showNotification(`可选的最大限制不能小于最小限制`); if(object.question.max_choices>0){
if (object.question.max_choices < object.question.min_choices) {
this.props.showNotification(`可选的最大限制不能小于最小限制`);
return; return;
}
}
} }
var questiontwo = {}; var questiontwo = {};
var other = []; var other = [];
var option = []; var option = [];
@ -1026,7 +1040,7 @@ class PollNew extends Component {
if (this.state.problemtopicbool === true) { if (this.state.problemtopicbool === true) {
insindex = this.state.problemtopic; insindex = this.state.problemtopic;
} }
this.createquestionsandanswers(object, 2, arrc, null, object.question.max_choices, object.question.min_choices, insindex); this.createquestionsandanswers(object, 2, arrc, null, object.question.max_choices, object.question.min_choices, insindex,object.question.answers.length);
//插入多选题 //插入多选题
// if (object.question.max_choices > arrc.length) { // if (object.question.max_choices > arrc.length) {
// // console.log("选择题的最大可选项不能大于选项数") // // console.log("选择题的最大可选项不能大于选项数")
@ -1096,7 +1110,7 @@ class PollNew extends Component {
if (this.state.problemtopicbool === true) { if (this.state.problemtopicbool === true) {
insindex = this.state.problemtopic; insindex = this.state.problemtopic;
} }
this.createquestionsandanswers(object, 3, null, null, 0, 0, insindex); this.createquestionsandanswers(object, 3, null, null, 0, 0, insindex,0);
// newarrpoll.push(question); // newarrpoll.push(question);
newarrpoll.splice(thiss.state.Insertposition, 0, question); newarrpoll.splice(thiss.state.Insertposition, 0, question);
} }
@ -1159,23 +1173,31 @@ class PollNew extends Component {
question = {"question": questiontwo}; question = {"question": questiontwo};
if (uuk !== -1) { if (uuk !== -1) {
// console.log("修改") // console.log("修改")
this.edittotheserver(object, 1, arrc, null, 0, 0); this.edittotheserver(object, 1, arrc, null, 0, 0,0);
newarrpoll.splice(uuk, 1, question); newarrpoll.splice(uuk, 1, question);
} else { } else {
// console.log("他原来的删除掉了") // console.log("他原来的删除掉了")
this.createquestionsandanswers(object, 1, arrc, null, 0, 0, object.question.id); this.createquestionsandanswers(object, 1, arrc, null, 0, 0, object.question.id,0);
newarrpoll.push(question); newarrpoll.push(question);
} }
newarr[indexo].question.new = "new" newarr[indexo].question.new = "new"
// console.log(newarrpoll) // console.log(newarrpoll)
} else if (object.question.question_type === 2) { } else if (object.question.question_type === 2) {
//插入多选题 //插入多选题
if(object.question.max_choices){
if(object.question.max_choices>0){
if (object.question.max_choices < object.question.min_choices) {
this.props.showNotification(`可选的最大限制不能小于最小限制`);
if (object.question.max_choices < object.question.min_choices) { return;
this.props.showNotification('可选的最大限制不能小于最小限制!'); }
}
return;
} }
// if (object.question.max_choices < object.question.min_choices) {
// this.props.showNotification('可选的最大限制不能小于最小限制!');
//
// return;
// }
var questiontwo = {}; var questiontwo = {};
var other = []; var other = [];
var option = []; var option = [];
@ -1230,11 +1252,11 @@ class PollNew extends Component {
// } // }
if (uuk !== -1) { if (uuk !== -1) {
// console.log("修改") // console.log("修改")
this.edittotheserver(object, 2, arrc, null, object.question.max_choices, object.question.min_choices); this.edittotheserver(object, 2, arrc, null, object.question.max_choices, object.question.min_choices,object.question.answers.length);
newarrpoll.splice(uuk, 1, question); newarrpoll.splice(uuk, 1, question);
} else { } else {
// console.log("删除") // console.log("删除")
this.createquestionsandanswers(object, 2, arrc, null, object.question.max_choices, object.question.min_choices, object.question.id); this.createquestionsandanswers(object, 2, arrc, null, object.question.max_choices, object.question.min_choices, object.question.id,object.question.answers.length);
newarrpoll.push(question); newarrpoll.push(question);
} }
// console.log(newarrpoll) // console.log(newarrpoll)
@ -1276,11 +1298,11 @@ class PollNew extends Component {
if (uuk !== -1) { if (uuk !== -1) {
// console.log("修改") // console.log("修改")
this.edittotheserver(object, 3, null, null, 0, 0); this.edittotheserver(object, 3, null, null, 0, 0,0);
newarrpoll.splice(uuk, 1, question); newarrpoll.splice(uuk, 1, question);
} else { } else {
// console.log("删除") // console.log("删除")
this.createquestionsandanswers(object, 3, null, null, 0, 0, object.question.id); this.createquestionsandanswers(object, 3, null, null, 0, 0, object.question.id,0);
newarrpoll.push(question); newarrpoll.push(question);
} }
// console.log(newarrpoll) // console.log(newarrpoll)
@ -1448,15 +1470,24 @@ class PollNew extends Component {
if (this.state.problemtopicbool === true) { if (this.state.problemtopicbool === true) {
insindex = this.state.problemtopic; insindex = this.state.problemtopic;
} }
this.createquestionsandanswers(object, 1, arrc, null, 0, 0, insindex); this.createquestionsandanswers(object, 1, arrc, null, 0, 0, insindex,0);
newarrpoll.splice(thiss.state.Insertposition, 0, question); newarrpoll.splice(thiss.state.Insertposition, 0, question);
} else if (object.question.question_type === 2) { } else if (object.question.question_type === 2) {
//插入多选题 //插入多选题
if (object.question.max_choices < object.question.min_choices) { if(object.question.max_choices){
this.props.showNotification(`可选的最大限制不能小于最小限制`); if(object.question.max_choices>0){
if (object.question.max_choices < object.question.min_choices) {
this.props.showNotification(`可选的最大限制不能小于最小限制`);
return; return;
}
}
} }
// if (object.question.max_choices < object.question.min_choices) {
// this.props.showNotification(`可选的最大限制不能小于最小限制`);
//
// return;
// }
var questiontwo = {}; var questiontwo = {};
var other = []; var other = [];
@ -1502,7 +1533,7 @@ class PollNew extends Component {
if (this.state.problemtopicbool === true) { if (this.state.problemtopicbool === true) {
insindex = this.state.problemtopic; insindex = this.state.problemtopic;
} }
this.createquestionsandanswers(object, 2, arrc, null, object.question.max_choices, object.question.min_choices, insindex); this.createquestionsandanswers(object, 2, arrc, null, object.question.max_choices, object.question.min_choices, insindex,object.question.answers.length);
//插入多选题 //插入多选题
// if (object.question.max_choices > arrc.length) { // if (object.question.max_choices > arrc.length) {
@ -1550,7 +1581,7 @@ class PollNew extends Component {
if (this.state.problemtopicbool === true) { if (this.state.problemtopicbool === true) {
insindex = this.state.problemtopic; insindex = this.state.problemtopic;
} }
this.createquestionsandanswers(object, 3, null, null, 0, 0, insindex); this.createquestionsandanswers(object, 3, null, null, 0, 0, insindex,0);
// newarrpoll.push(question); // newarrpoll.push(question);
newarrpoll.splice(thiss.state.Insertposition, 0, question); newarrpoll.splice(thiss.state.Insertposition, 0, question);
} }
@ -1611,21 +1642,30 @@ class PollNew extends Component {
question = {"question": questiontwo}; question = {"question": questiontwo};
if (uuk !== -1) { if (uuk !== -1) {
// console.log("修改") // console.log("修改")
this.edittotheserver(object, 1, arrc, null, 0, 0); this.edittotheserver(object, 1, arrc, null, 0, 0,0);
newarrpoll.splice(uuk, 1, question); newarrpoll.splice(uuk, 1, question);
} else { } else {
// console.log("删除") // console.log("删除")
this.createquestionsandanswers(object, 1, arrc, null, 0, 0, object.question.id); this.createquestionsandanswers(object, 1, arrc, null, 0, 0, object.question.id,0);
newarrpoll.push(question); newarrpoll.push(question);
} }
// console.log(newarrpoll) // console.log(newarrpoll)
} else if (object.question.question_type === 2) { } else if (object.question.question_type === 2) {
//插入多选题 //插入多选题
if (object.question.max_choices < object.question.min_choices) { if(object.question.max_choices){
this.props.showNotification(`可选的最大限制不能小于最小限制`); if(object.question.max_choices>0){
if (object.question.max_choices < object.question.min_choices) {
this.props.showNotification(`可选的最大限制不能小于最小限制`);
return; return;
}
}
} }
// if (object.question.max_choices < object.question.min_choices) {
// this.props.showNotification(`可选的最大限制不能小于最小限制`);
//
// return;
// }
var questiontwo = {}; var questiontwo = {};
var other = []; var other = [];
var option = []; var option = [];
@ -1667,11 +1707,11 @@ class PollNew extends Component {
//插入多选题 //插入多选题
if (uuk !== -1) { if (uuk !== -1) {
// console.log("修改") // console.log("修改")
this.edittotheserver(object, 2, arrc, null, object.question.max_choices, object.question.min_choices); this.edittotheserver(object, 2, arrc, null, object.question.max_choices, object.question.min_choices,object.question.answers.length);
newarrpoll.splice(uuk, 1, question); newarrpoll.splice(uuk, 1, question);
} else { } else {
// console.log("删除") // console.log("删除")
this.createquestionsandanswers(object, 2, arrc, null, object.question.max_choices, object.question.min_choices, object.question.id); this.createquestionsandanswers(object, 2, arrc, null, object.question.max_choices, object.question.min_choices, object.question.id,object.question.answers.length);
newarrpoll.push(question); newarrpoll.push(question);
} }
// console.log(newarrpoll) // console.log(newarrpoll)
@ -1712,11 +1752,11 @@ class PollNew extends Component {
question = {"question": questiontwo}; question = {"question": questiontwo};
if (uuk !== -1) { if (uuk !== -1) {
// console.log("修改") // console.log("修改")
this.edittotheserver(object, 3, null, null, 0, 0); this.edittotheserver(object, 3, null, null, 0, 0,0);
newarrpoll.splice(uuk, 1, question); newarrpoll.splice(uuk, 1, question);
} else { } else {
// console.log("删除") // console.log("删除")
this.createquestionsandanswers(object, 3, null, null, 0, 0, object.question.id); this.createquestionsandanswers(object, 3, null, null, 0, 0, object.question.id,0);
newarrpoll.push(question); newarrpoll.push(question);
} }
// console.log(newarrpoll) // console.log(newarrpoll)
@ -1752,7 +1792,8 @@ class PollNew extends Component {
////新增到服务器中 ////新增到服务器中
createquestionsandanswers = (object, number, option, other, max_choices, min_choices, insert_id) => { createquestionsandanswers = (object, number, option, other, max_choices, min_choices, insert_id,length) => {
var thiss = this; var thiss = this;
var poll_id = this.state.pollid; var poll_id = this.state.pollid;
var urlly = `/polls/${poll_id}/poll_questions.json` var urlly = `/polls/${poll_id}/poll_questions.json`
@ -1765,12 +1806,16 @@ class PollNew extends Component {
max_choicess = max_choices; max_choicess = max_choices;
min_choicess = min_choices; min_choicess = min_choices;
} }
console.log("createquestionsandanswers");
console.log(max_choicess);
console.log(min_choicess);
console.log(length);
axios.post(urlly, { axios.post(urlly, {
question_title: object.question.question_title, question_title: object.question.question_title,
question_type: number, question_type: number,
is_necessary: object.question.is_necessary, is_necessary: object.question.is_necessary,
max_choices: max_choicess, max_choices: max_choicess===undefined?length:max_choicess===null?length:max_choicess===0?length:max_choicess,
min_choices: min_choicess, min_choices: min_choicess===undefined?2:min_choicess===null?2:min_choicess===0?2:min_choicess,
question_answers: option, question_answers: option,
question_other_answer: null, question_other_answer: null,
insert_id: insert_id insert_id: insert_id
@ -1801,17 +1846,30 @@ class PollNew extends Component {
} }
///编辑修改到服务器当中 ///编辑修改到服务器当中
edittotheserver = (object, number, option, other, max_choices, min_choices) => { edittotheserver = (object, number, option, other, max_choices, min_choices,length) => {
// console.log("调用了edittotheserver") // console.log("调用了edittotheserver")
var url = `/poll_questions/${object.question.id}.json` var url = `/poll_questions/${object.question.id}.json`
var thiss = this; var thiss = this;
var max_choicess = null;
var min_choicess = null;
if (max_choices === 0 && min_choices === 0) {
max_choicess = null;
min_choicess = null;
} else {
max_choicess = max_choices;
min_choicess = min_choices;
}
console.log("createquestionsandanswers");
console.log(max_choicess);
console.log(min_choicess);
console.log(length);
axios.put(url, { axios.put(url, {
// debug: true, // debug: true,
question_title: object.question.question_title, question_title: object.question.question_title,
question_type: number, question_type: number,
is_necessary: object.question.is_necessary, is_necessary: object.question.is_necessary,
max_choices: max_choices, max_choices: max_choicess===undefined?length:max_choicess===null?length:max_choicess===0?length:max_choicess,
min_choices: min_choices, min_choices: min_choicess===undefined?2:min_choicess===null?2:min_choicess===0?2:min_choicess,
question_answers: option, question_answers: option,
question_other_answer: null, question_other_answer: null,
}).then((result) => { }).then((result) => {
@ -2123,6 +2181,12 @@ class PollNew extends Component {
//最小值 //最小值
HandleGradationGroupChangee = (value, index, max, length) => { HandleGradationGroupChangee = (value, index, max, length) => {
// console.log("最小值");
// console.log(value);
// console.log(index);
// console.log(max);
// console.log(length);
// debugger // debugger
var minbool = false; var minbool = false;
var maxbool = false; var maxbool = false;
@ -2137,7 +2201,7 @@ class PollNew extends Component {
if (minbool === true && maxbool === true) { if (minbool === true && maxbool === true) {
for (var i = 0; i < arr.length; i++) { for (var i = 0; i < arr.length; i++) {
if (index === i) { if (index === i) {
arr[i].question.min_choices = parseInt(value); arr[i].question.min_choices = parseInt(value);
} }
} }
this.setState({ this.setState({
@ -2146,18 +2210,8 @@ class PollNew extends Component {
} else { } else {
for (var i = 0; i < arr.length; i++) { for (var i = 0; i < arr.length; i++) {
if (index === i) { if (index === i) {
try {
if(parseInt(value)===0){
arr[i].question.min_choices = 2;
arr[i].question.max_choices = length;
}else{
arr[i].question.min_choices = parseInt(value); arr[i].question.min_choices = parseInt(value);
arr[i].question.max_choices = max; arr[i].question.max_choices = length;
}
}catch (e) {
arr[i].question.min_choices = 2;
arr[i].question.max_choices = length;
}
break; break;
} }
} }
@ -2169,19 +2223,32 @@ class PollNew extends Component {
} }
//最大值 //最大值
HandleGradationGroupChangeee = (value, index,minchoices) => { HandleGradationGroupChangeee = (value, index,minchoices,length) => {
// console.log("2112"); // console.log("2112");
// console.log(value); // console.log(value);
// console.log(minchoices); // console.log(minchoices);
// console.log("最大值");
// console.log(value);
// console.log(index);
// console.log(minchoices);
// console.log(length);
let arr = this.state.adddom; let arr = this.state.adddom;
for (var i = 0; i < arr.length; i++) { for (var i = 0; i < arr.length; i++) {
if (index === i) { if (index === i) {
if(parseInt(value)===0&&parseInt(minchoices)===0){ if(parseInt(value)===0&&parseInt(minchoices)===0){
arr[i].question.min_choices= parseInt(0);
arr[i].question.max_choices = parseInt(0);
}else if(parseInt(minchoices)===0){
arr[i].question.min_choices= parseInt(2);
arr[i].question.max_choices = parseInt(value);
}
else if(parseInt(value)===0&&parseInt(minchoices)>0){
arr[i].question.min_choices= parseInt(minchoices); arr[i].question.min_choices= parseInt(minchoices);
arr[i].question.max_choices = parseInt(value); arr[i].question.max_choices = parseInt(value);
}else { }
else {
arr[i].question.min_choices= minchoices===null?2:minchoices===undefined?2:minchoices===0?2:parseInt(minchoices); arr[i].question.min_choices= minchoices===null?2:minchoices===undefined?2:minchoices===0?2:parseInt(minchoices);
arr[i].question.max_choices = parseInt(value); arr[i].question.max_choices = parseInt(value);
} }
} }
} }
@ -2455,7 +2522,7 @@ class PollNew extends Component {
// console.log(this.state.projects===undefined?"":this.state.projects.poll_questions) // console.log(this.state.projects===undefined?"":this.state.projects.poll_questions)
var displaymysave = (mysave === true) ? "" : "display:none;"; var displaymysave = (mysave === true) ? "" : "display:none;";
return ( return (
<div> <div className="newMain">
{/*提示*/} {/*提示*/}
{Modalstype && Modalstype === true ? <Modals {Modalstype && Modalstype === true ? <Modals
modalsType={this.state.Modalstype} modalsType={this.state.Modalstype}
@ -2465,14 +2532,8 @@ class PollNew extends Component {
modalsBottomval={this.state.ModalsBottomval} modalsBottomval={this.state.ModalsBottomval}
loadtype={this.state.Loadtype} loadtype={this.state.Loadtype}
/> : ""} /> : ""}
<style>
{ <div className="educontent mb50">
`
.newMains{ margin: 0 auto; padding-bottom: 235px !important; min-width:1200px; min-height: 800px !important;}
`
}
</style>
<div className="educontent newMains">
<p className="clearfix mb20 mt10"> <p className="clearfix mb20 mt10">
<a className=" btn colorgrey fl hovercolorblue" onClick={()=>this.gotohome()}>{this.props.coursedata.name}</a> <a className=" btn colorgrey fl hovercolorblue" onClick={()=>this.gotohome()}>{this.props.coursedata.name}</a>
<span className="color-grey-9 fl ml3 mr3">&gt;</span> <span className="color-grey-9 fl ml3 mr3">&gt;</span>
@ -2874,7 +2935,7 @@ class PollNew extends Component {
value={itemo.question.min_choices === 0 || itemo.question.min_choices === "0" ? "--" : itemo.question.min_choices === null ? "--" : itemo.question.min_choices === undefined ? "--" : itemo.question.min_choices} value={itemo.question.min_choices === 0 || itemo.question.min_choices === "0" ? "--" : itemo.question.min_choices === null ? "--" : itemo.question.min_choices === undefined ? "--" : itemo.question.min_choices}
> >
<Option value={String("0")}>--</Option> <Option value={"0"}>--</Option>
{itemo.question.answers === undefined ? "" : itemo.question.answers.map((itemt, indext) => { {itemo.question.answers === undefined ? "" : itemo.question.answers.map((itemt, indext) => {
return ( return (
indext >= 1 ? <Option value={String(indext + 1)}>{indext + 1}</Option> : "" indext >= 1 ? <Option value={String(indext + 1)}>{indext + 1}</Option> : ""
@ -2885,10 +2946,10 @@ class PollNew extends Component {
className="ml10 mr10 color-grey-6 lineh-40 fl">~</span> className="ml10 mr10 color-grey-6 lineh-40 fl">~</span>
{/*可选最大*/} {/*可选最大*/}
<Select className="fl w100" <Select className="fl w100"
onChange={(value) => this.HandleGradationGroupChangeee(value, indexo,itemo.question.min_choices)} onChange={(value) => this.HandleGradationGroupChangeee(value, indexo,itemo.question.min_choices,itemo.question.answers.length)}
value={itemo.question.max_choices === 0 || itemo.question.max_choices === "0" ? "--" : itemo.question.min_choices === null ? "--" : itemo.question.min_choices === undefined ? "--" : itemo.question.max_choices} value={itemo.question.max_choices === 0 || itemo.question.max_choices === "0" ? "--" : itemo.question.min_choices === null ? "--" : itemo.question.min_choices === undefined ? "--" : itemo.question.max_choices}
> >
<Option value={String("0")}>--</Option> <Option value={"0"}>--</Option>
{itemo.question.answers === undefined ? "" : itemo.question.answers.map((itemt, indext) => { {itemo.question.answers === undefined ? "" : itemo.question.answers.map((itemt, indext) => {
return ( return (
indext >= 1 ? <Option value={String(indext + 1)}>{indext + 1}</Option> : "" indext >= 1 ? <Option value={String(indext + 1)}>{indext + 1}</Option> : ""
@ -3128,7 +3189,7 @@ class PollNew extends Component {
className="ml10 mr10 color-grey-6 lineh-40 fl">~</span> className="ml10 mr10 color-grey-6 lineh-40 fl">~</span>
{/*可选最大*/} {/*可选最大*/}
<Select className="fl w100" <Select className="fl w100"
onChange={(value) => this.HandleGradationGroupChangeee(value, indexo,itemo.question.min_choices)} onChange={(value) => this.HandleGradationGroupChangeee(value, indexo,itemo.question.min_choices,itemo.question.answers.length)}
value={itemo.question.max_choices === 0 || itemo.question.max_choices === "0" ? "--" : itemo.question.min_choices === null ? "--" : itemo.question.min_choices === undefined ? "--" : itemo.question.max_choices} value={itemo.question.max_choices === 0 || itemo.question.max_choices === "0" ? "--" : itemo.question.min_choices === null ? "--" : itemo.question.min_choices === undefined ? "--" : itemo.question.max_choices}
> >
<Option value={String("0")}>--</Option> <Option value={String("0")}>--</Option>
@ -3380,7 +3441,7 @@ class PollNew extends Component {
className="ml10 mr10 color-grey-6 lineh-40 fl">~</span> className="ml10 mr10 color-grey-6 lineh-40 fl">~</span>
{/*可选最大*/} {/*可选最大*/}
<Select className="fl w100" <Select className="fl w100"
onChange={(value) => this.HandleGradationGroupChangeee(value, indexo,itemo.question.min_choices)} onChange={(value) => this.HandleGradationGroupChangeee(value, indexo,itemo.question.min_choices,itemo.question.answers.length)}
value={itemo.question.max_choices === 0 || itemo.question.max_choices === "0" ? "--" : itemo.question.min_choices === null ? "--" : itemo.question.min_choices === undefined ? "--" : itemo.question.max_choices} value={itemo.question.max_choices === 0 || itemo.question.max_choices === "0" ? "--" : itemo.question.min_choices === null ? "--" : itemo.question.min_choices === undefined ? "--" : itemo.question.max_choices}
> >
<Option value={String("0")}>--</Option> <Option value={String("0")}>--</Option>

@ -1100,7 +1100,7 @@ class ShixunHomework extends Component{
{course_modules&&course_modules.main_category.map((item,key)=>{ {course_modules&&course_modules.main_category.map((item,key)=>{
return( return(
datas&&datas.category_id===null?"":<li key={key} id={item.main_category_id} onClick={() => this.moveTos(item.main_category_id)} title={item.main_category_name}>{item.main_category_name}</li> datas&&datas.category_id===null?"":<li key={key} id={item.main_category_id} onClick={() => this.moveTos(item.main_category_id)} title={item.main_category_name.length>18?item.main_category_name:""}>{item.main_category_name}</li>
) )
})} })}
@ -1109,10 +1109,10 @@ class ShixunHomework extends Component{
return (!this.state.dirSearchValue || item.category_name.indexOf(this.state.dirSearchValue) != -1) return (!this.state.dirSearchValue || item.category_name.indexOf(this.state.dirSearchValue) != -1)
}).map( (item,key) => { }).map( (item,key) => {
if(datas&&datas.category_id!=null&&datas&&datas.category_id===item.category_id===false){ if(datas&&datas.category_id!=null&&datas&&datas.category_id===item.category_id===false){
return <li key={key} id={item.category_id} onClick={() => this.moveTos(item.category_id )} title={item.category_name}>{item.category_name}</li> return <li key={key} id={item.category_id} onClick={() => this.moveTos(item.category_id )} title={item.category_name.length>18?item.category_name:""}>{item.category_name}</li>
} }
if(datas&&datas.category_id===null){ if(datas&&datas.category_id===null){
return <li key={key} id={item.category_id} onClick={() => this.moveTos(item.category_id )} title={item.category_name}>{item.category_name}</li> return <li key={key} id={item.category_id} onClick={() => this.moveTos(item.category_id )} title={item.category_name.length>18?item.category_name:""}>{item.category_name}</li>
} }
})} })}

@ -561,21 +561,24 @@ class MemoNew extends Component {
} }
} }
onAttachmentRemove = (file) => { onAttachmentRemove = (file) => {
this.props.confirm({ if(file.response!=undefined){
// title: '确定要删除这个附件吗?', this.props.confirm({
content: '是否确认删除?', // title: '确定要删除这个附件吗?',
content: '是否确认删除?',
okText: '确定',
cancelText: '取消', okText: '确定',
// content: 'Some descriptions', cancelText: '取消',
onOk: () => { // content: 'Some descriptions',
this.deleteAttachment(file) onOk: () => {
}, this.deleteAttachment(file)
onCancel() { },
console.log('Cancel'); onCancel() {
}, console.log('Cancel');
}); },
return false; });
return false;
}
} }
deleteAttachment = (file) => { deleteAttachment = (file) => {
// 初次上传不能直接取uid // 初次上传不能直接取uid

@ -82,10 +82,10 @@ class CaseDetail extends Component{
<a href="/moop_cases" className="color-grey-9">教学案例</a> &gt; <span className="color-grey-3">{ CaseDetail.title}</span> <a href="/moop_cases" className="color-grey-9">教学案例</a> &gt; <span className="color-grey-3">{ CaseDetail.title}</span>
</p> </p>
<p className="lineh-25 mb20 clearfix"> <p className="lineh-25 mb20 clearfix">
<span className="font-22 fl mr10 task-hide" style={{maxWidth:"800px"}}> <span className="font-22 fl mr10 task-hide lineh-30" style={{maxWidth:"800px"}}>
{ CaseDetail.title} { CaseDetail.title}
</span> </span>
<span className="mt5 fl"> <span className="mt10 fl">
<Tags tags={tags}></Tags> <Tags tags={tags}></Tags>
{ {
CaseDetail.status == "pending" && <span class="edu-filter-btn fl cdefault edu-activity-green ml10">草稿</span> CaseDetail.status == "pending" && <span class="edu-filter-btn fl cdefault edu-activity-green ml10">草稿</span>

@ -1,452 +1,455 @@
import React,{ Component } from "react"; import React,{ Component } from "react";
import './css/moopCases.css' import './css/moopCases.css'
import '../courses/css/Courses.css' import '../courses/css/Courses.css'
import { Form , Input , Upload , Button , Icon , message , Tooltip } from "antd"; import { Form , Input , Upload , Button , Icon , message , Tooltip } from "antd";
import { getImageUrl , setImagesUrl , MarkdownToHtml , ActionBtn , appendFileSizeToUploadFile , appendFileSizeToUploadFileAll , getUrl , getUploadActionUrl } from 'educoder'; import { getImageUrl , setImagesUrl , MarkdownToHtml , ActionBtn , appendFileSizeToUploadFile , appendFileSizeToUploadFileAll , getUrl , getUploadActionUrl } from 'educoder';
import Tags from './CaseTags' import Tags from './CaseTags'
import axios from 'axios'; import axios from 'axios';
import TPMMDEditor from '../tpm/challengesnew/TPMMDEditor'; import TPMMDEditor from '../tpm/challengesnew/TPMMDEditor';
import _ from 'lodash' import _ from 'lodash'
const { Dragger } = Upload; const { Dragger } = Upload;
function beforeUpload(file) { function beforeUpload(file) {
const isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png'; const isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png';
if (!isJpgOrPng) { if (!isJpgOrPng) {
message.error('You can only upload JPG/PNG file!'); message.error('You can only upload JPG/PNG file!');
} }
const isLt2M = file.size / 1024 / 1024 < 2; const isLt2M = file.size / 1024 / 1024 < 2;
if (!isLt2M) { if (!isLt2M) {
message.error('Image must smaller than 2MB!'); message.error('Image must smaller than 2MB!');
} }
return isJpgOrPng && isLt2M; return isJpgOrPng && isLt2M;
} }
function getBase64(img, callback) { function getBase64(img, callback) {
const reader = new FileReader(); const reader = new FileReader();
reader.addEventListener('load', () => callback(reader.result)); reader.addEventListener('load', () => callback(reader.result));
reader.readAsDataURL(img); reader.readAsDataURL(img);
} }
const $ = window.$; const $ = window.$;
class CaseNew extends Component{ class CaseNew extends Component{
constructor(props){ constructor(props){
super(props); super(props);
this.DescMdRef = React.createRef(); this.DescMdRef = React.createRef();
this.state={ this.state={
casesTags:[], casesTags:[],
contentFileList:[], contentFileList:[],
filesID:[], filesID:[],
imageUrl:undefined, imageUrl:undefined,
loading: false, loading: false,
checkTag:false, checkTag:false,
checkFile:false, checkFile:false,
coverID:undefined coverID:undefined
} }
} }
// 上传附件-删除确认框 // 上传附件-删除确认框
onAttachmentRemove = (file, stateName) => { onAttachmentRemove = (file, stateName) => {
this.props.confirm({ if(file.response!=undefined){
content: '是否确认删除?', this.props.confirm({
onOk: () => { content: '是否确认删除?',
this.deleteAttachment(file, stateName) onOk: () => {
}, this.deleteAttachment(file, stateName)
onCancel() { },
console.log('Cancel'); onCancel() {
}, console.log('Cancel');
}); },
return false; });
} return false;
}
// 上传附件-确认删除 }
deleteAttachment = (file, stateName) => {
// 初次上传不能直接取uid // 上传附件-确认删除
const url = `/attachments/${file.response ? file.response.id : file.uid}.json` deleteAttachment = (file, stateName) => {
axios.delete(url, { // 初次上传不能直接取uid
}).then((response) => { const url = `/attachments/${file.response ? file.response.id : file.uid}.json`
if (response.data) { axios.delete(url, {
const { status } = response.data; }).then((response) => {
if (status == 0) { if (response.data) {
console.log('--- success') const { status } = response.data;
if (status == 0) {
this.setState((state) => { console.log('--- success')
const index = state[stateName].indexOf(file);
const newFileList = state[stateName].slice(); this.setState((state) => {
newFileList.splice(index, 1); const index = state[stateName].indexOf(file);
console.log("newFileList"); const newFileList = state[stateName].slice();
console.log(newFileList.map(item =>{ return( item.id )})); newFileList.splice(index, 1);
return { console.log("newFileList");
[stateName]: newFileList, console.log(newFileList.map(item =>{ return( item.id )}));
filesID:newFileList.map(item =>{ return( item.id )}) return {
}; [stateName]: newFileList,
}); filesID:newFileList.map(item =>{ return( item.id )})
} };
} });
}) }
.catch(function (error) { }
console.log(error); })
}); .catch(function (error) {
} console.log(error);
// 上传附件-change });
handleContentUploadChange = (info) => { }
if (info.file.status === 'done' || info.file.status === 'uploading') { // 上传附件-change
let contentFileList = info.fileList; handleContentUploadChange = (info) => {
this.setState({ contentFileList: appendFileSizeToUploadFileAll(contentFileList)}); if (info.file.status === 'done' || info.file.status === 'uploading') {
let list = appendFileSizeToUploadFileAll(contentFileList); let contentFileList = info.fileList;
let arr = list.map(item=>{ this.setState({ contentFileList: appendFileSizeToUploadFileAll(contentFileList)});
return ( item.response && item.response.id ) let list = appendFileSizeToUploadFileAll(contentFileList);
}) let arr = list.map(item=>{
this.setState({ return ( item.response && item.response.id )
filesID:arr, })
checkFile:arr.length > 0 ? false : true this.setState({
}) filesID:arr,
} checkFile:arr.length > 0 ? false : true
} })
}
// 上传封面图-change }
handleChange = (info) => {
if (info.file.status === 'uploading') { // 上传封面图-change
this.setState({ loading: true }); handleChange = (info) => {
return; if (info.file.status === 'uploading') {
} this.setState({ loading: true });
if (info.file.status === 'done') { return;
// Get this url from response in real world. }
getBase64(info.file.originFileObj, imageUrl => if (info.file.status === 'done') {
this.setState({ // Get this url from response in real world.
imageUrl, getBase64(info.file.originFileObj, imageUrl =>
loading: false this.setState({
}), imageUrl,
); loading: false
console.log(info.file); }),
this.setState({ );
coverID:info.file.response && info.file.response.id console.log(info.file);
}) this.setState({
} coverID:info.file.response && info.file.response.id
}; })
}
// 编辑时加载数据 };
componentDidMount=()=>{
if(this.props.match.params.caseID){ // 编辑时加载数据
this.InitEditData(); componentDidMount=()=>{
} if(this.props.match.params.caseID){
} this.InitEditData();
}
componentDidUpdate=(prevState)=>{ }
if(this.props.CaseDetail && prevState.CaseDetail != this.props.CaseDetail){
this.props.form.setFieldsValue({ componentDidUpdate=(prevState)=>{
caseTitle:this.props.CaseDetail.title, if(this.props.CaseDetail && prevState.CaseDetail != this.props.CaseDetail){
userName:this.props.CaseDetail.author_name, this.props.form.setFieldsValue({
userUnit:this.props.CaseDetail.author_school_name, caseTitle:this.props.CaseDetail.title,
}) userName:this.props.CaseDetail.author_name,
this.setState({ userUnit:this.props.CaseDetail.author_school_name,
contentFileList:this.props.attachments.map(item => { })
return { this.setState({
id: item.id, contentFileList:this.props.attachments.map(item => {
uid: item.id, return {
name: appendFileSizeToUploadFile(item), id: item.id,
url: item.url, uid: item.id,
filesize: item.filesize, name: appendFileSizeToUploadFile(item),
status: 'done' url: item.url,
} filesize: item.filesize,
}), status: 'done'
filesID:this.props.attachments.map(item => { }
return ( item.id ) }),
}), filesID:this.props.attachments.map(item => {
coverID:this.props.cover && this.props.cover.id, return ( item.id )
imageUrl:this.props.CaseDetail.cover && setImagesUrl(this.props.CaseDetail.cover.url), }),
casesTags:this.props.tags.map(item=>{ coverID:this.props.cover && this.props.cover.id,
return (item.id); imageUrl:this.props.CaseDetail.cover && setImagesUrl(this.props.CaseDetail.cover.url),
}) casesTags:this.props.tags.map(item=>{
}) return (item.id);
console.log(this.props.attachments.map(item => { })
return ( item.id ) })
})) console.log(this.props.attachments.map(item => {
} return ( item.id )
} }))
}
InitEditData=()=>{ }
let caseID = this.props.match.params.caseID;
this.props.getDetail(caseID); InitEditData=()=>{
} let caseID = this.props.match.params.caseID;
this.props.getDetail(caseID);
// 申请提交和保存 }
handleSubmit = (type) => {
let caseID = this.props.match.params.caseID; // 申请提交和保存
console.log(type); handleSubmit = (type) => {
this.props.form.validateFieldsAndScroll((err, values) => { let caseID = this.props.match.params.caseID;
let { casesTags , filesID } = this.state; console.log(type);
if(casesTags.length == 0){ this.props.form.validateFieldsAndScroll((err, values) => {
$("html").animate({ scrollTop: $("#tagFormItem").offset().top - 100 }); let { casesTags , filesID } = this.state;
this.setState({ if(casesTags.length == 0){
checkTag:true $("html").animate({ scrollTop: $("#tagFormItem").offset().top - 100 });
}) this.setState({
return; checkTag:true
} })
if(filesID.length == 0){ return;
$("html").animate({ scrollTop: $("#fileFormItem").offset().top - 100 }); }
this.setState({ if(filesID.length == 0){
checkFile:true $("html").animate({ scrollTop: $("#fileFormItem").offset().top - 100 });
}) this.setState({
return; checkFile:true
} })
return;
const mdContnet = this.DescMdRef.current.getValue().trim(); }
console.log(mdContnet)
values.description = mdContnet; const mdContnet = this.DescMdRef.current.getValue().trim();
console.log(mdContnet)
console.log(values); values.description = mdContnet;
let url = caseID ? `/libraries/${caseID}.json`: `/libraries.json`;
if(caseID){ console.log(values);
axios.put((url),{ let url = caseID ? `/libraries/${caseID}.json`: `/libraries.json`;
title:values.caseTitle, if(caseID){
author_name:values.userName, axios.put((url),{
author_school_name:values.userUnit, title:values.caseTitle,
content:values.description, author_name:values.userName,
attachment_ids:this.state.contentFileList.map(item=>{ author_school_name:values.userUnit,
return (item.response ? item.response.id : item.id ) content:values.description,
}), attachment_ids:this.state.contentFileList.map(item=>{
tag_ids:this.state.casesTags, return (item.response ? item.response.id : item.id )
cover_id:this.state.coverID, }),
publish:type == 'save' ? false : true tag_ids:this.state.casesTags,
}).then((result)=>{ cover_id:this.state.coverID,
if(result){ publish:type == 'save' ? false : true
this.props.showNotification(type == 'save' ? `案例保存成功!`: `提交成功!`); }).then((result)=>{
this.props.history.push(type == 'save' ? `/moop_cases/${result.data.id}` : `/moop_cases/${result.data.id}/publish_success`); if(result){
} this.props.showNotification(type == 'save' ? `案例保存成功!`: `提交成功!`);
}).catch((error)=>{ this.props.history.push(type == 'save' ? `/moop_cases/${result.data.id}` : `/moop_cases/${result.data.id}/publish_success`);
console.log(error); }
}) }).catch((error)=>{
}else{ console.log(error);
axios.post((url),{ })
title:values.caseTitle, }else{
author_name:values.userName, axios.post((url),{
author_school_name:values.userUnit, title:values.caseTitle,
content:values.description, author_name:values.userName,
attachment_ids:this.state.filesID, author_school_name:values.userUnit,
tag_ids:this.state.casesTags, content:values.description,
cover_id:this.state.coverID, attachment_ids:this.state.filesID,
publish:type == 'save' ? false : true tag_ids:this.state.casesTags,
}).then((result)=>{ cover_id:this.state.coverID,
if(result){ publish:type == 'save' ? false : true
this.props.showNotification(type == 'save' ? `案例保存成功!`: `提交成功!`); }).then((result)=>{
this.props.history.push(type == 'save' ? `/moop_cases/${result.data.id}` : `/moop_cases/${result.data.id}/publish_success`); if(result){
} this.props.showNotification(type == 'save' ? `案例保存成功!`: `提交成功!`);
}).catch((error)=>{ this.props.history.push(type == 'save' ? `/moop_cases/${result.data.id}` : `/moop_cases/${result.data.id}/publish_success`);
console.log(error); }
}) }).catch((error)=>{
} console.log(error);
})
}) }
}
})
// 选择标签 }
changeType=(type)=>{
let tags = []; // 选择标签
if(this.state.casesTags.indexOf(type) > -1){ changeType=(type)=>{
tags = this.state.casesTags.filter(item => item != type); let tags = [];
}else{ if(this.state.casesTags.indexOf(type) > -1){
tags = this.state.casesTags.concat(type); tags = this.state.casesTags.filter(item => item != type);
} }else{
const tagUniqed = _.uniq(tags); tags = this.state.casesTags.concat(type);
this.setState({ }
casesTags: tagUniqed, const tagUniqed = _.uniq(tags);
checkTag:tags.length > 0 ? false : true this.setState({
}) casesTags: tagUniqed,
} checkTag:tags.length > 0 ? false : true
})
render(){ }
let { caseID } = this.props.match.params;
let { CaseDetail } = this.props; render(){
let { casesTags , contentFileList , imageUrl , checkTag , checkFile } = this.state; let { caseID } = this.props.match.params;
const {getFieldDecorator} = this.props.form; let { CaseDetail } = this.props;
let { casesTags , contentFileList , imageUrl , checkTag , checkFile } = this.state;
const {getFieldDecorator} = this.props.form;
// 上传附件点击事件
const uploadProps = {
width: 600, // 上传附件点击事件
multiple: true, const uploadProps = {
fileList:contentFileList, width: 600,
action: `${getUploadActionUrl()}`, multiple: true,
onChange: this.handleContentUploadChange, fileList:contentFileList,
onRemove: (file) => this.onAttachmentRemove(file, 'contentFileList'), action: `${getUploadActionUrl()}`,
beforeUpload: (file) => { onChange: this.handleContentUploadChange,
const isLt150M = file.size / 1024 / 1024 < 150; onRemove: (file) => this.onAttachmentRemove(file, 'contentFileList'),
if (!isLt150M) { beforeUpload: (file) => {
//message.error('文件大小必须小于150MB!'); const isLt150M = file.size / 1024 / 1024 < 150;
this.props.define({ if (!isLt150M) {
title:'提示', //this.props.showNotification('文件大小必须小于150MB!');
content:"该文件无法上传。超过文件大小限制(150MB),建议上传到百度云等其它共享工具里然后再txt文档里给出链接以及共享密码并上传" this.props.define({
}) title:'提示',
return isLt150M; content:"该文件无法上传。超过文件大小限制(150MB),建议上传到百度云等其它共享工具里然后再txt文档里给出链接以及共享密码并上传"
} })
} return isLt150M;
}; }
// 上传封面图-html }
const uploadButton = ( };
<div> // 上传封面图-html
<Icon className='font-36 color-grey-c' type={this.state.loading ? 'loading' : 'plus'} /> const uploadButton = (
</div> <div>
); <Icon className='font-36 color-grey-c' type={this.state.loading ? 'loading' : 'plus'} />
// 上传封面图点击事件 </div>
const uploadCover = { );
listType:"picture-card", // 上传封面图点击事件
className:"avatar-uploader", const uploadCover = {
showUploadList:false, listType:"picture-card",
action:`${getUploadActionUrl()}`, className:"avatar-uploader",
onChange:this.handleChange, showUploadList:false,
} action:`${getUploadActionUrl()}`,
console.log('111'); onChange:this.handleChange,
console.log(!caseID || (CaseDetail && CaseDetail.status == "pending")); }
return( console.log('111');
<div className="educontent mt10 mb50"> console.log(!caseID || (CaseDetail && CaseDetail.status == "pending"));
<style> return(
{ <div className="educontent mt10 mb50">
` <style>
.newCases .ant-col.ant-form-item-label{ {
float:left; `
margin-right:20px; .newCases .ant-col.ant-form-item-label{
height:35px; float:left;
line-height:35px; margin-right:20px;
} height:35px;
line-height:35px;
.newCaseUpload{ }
width: 100%;
background: #F2F9FF; .newCaseUpload{
justify-content: center; width: 100%;
align-items: center; background: #F2F9FF;
display: -webkit-flex; justify-content: center;
text-align: center; align-items: center;
height: 120px; display: -webkit-flex;
border-radius: 4px; text-align: center;
border: 1px dashed #4cacff; height: 120px;
} border-radius: 4px;
.newCases .ant-form-item{ border: 1px dashed #4cacff;
margin-bottom:20px!important ; }
} .newCases .ant-form-item{
.newCases .ant-col.ant-form-item-control-wrapper{ margin-bottom:20px!important ;
position:relative; }
} .newCases .ant-col.ant-form-item-control-wrapper{
.newCases .ant-form-explain{ position:relative;
position:absolute; }
bottom:-18px; .newCases .ant-form-explain{
left:76px; position:absolute;
padding-left: 7px; bottom:-18px;
} left:76px;
.newCases .resetLeft .ant-form-explain{ padding-left: 7px;
left:0px; }
} .newCases .resetLeft .ant-form-explain{
.newCases .resetBottom .ant-form-explain{ left:0px;
bottom:2px; }
} .newCases .resetBottom .ant-form-explain{
` bottom:2px;
} }
</style> `
<p className="mt10 mb20 clearfix lineh-20"> }
<a href="/moop_cases" className="color-grey-9">教学案例</a> &gt; <span className="color-grey-3">{ caseID ? "" : "" }</span> </style>
</p> <p className="mt10 mb20 clearfix lineh-20">
<p class="lineh-25 font-22 mb20">上传教学案例</p> <a href="/moop_cases" className="color-grey-9">教学案例</a> &gt; <span className="color-grey-3">{ caseID ? "" : "" }</span>
<Form onSubmit={this.handleSubmit} className={"newCases"}> </p>
<div className="padding30 edu-back-white"> <p class="lineh-25 font-22 mb20">上传教学案例</p>
<Form.Item label="标题"> <Form onSubmit={this.handleSubmit} className={"newCases"}>
{getFieldDecorator('caseTitle', { <div className="padding30 edu-back-white">
rules: [{required: true, message: "案例标题不能为空"}], <Form.Item label="标题">
})( {getFieldDecorator('caseTitle', {
<Input placeholder="例如:软件工程教学案例" className="greyInput winput-300-35 mr20 fl"/> rules: [{required: true, message: "案例标题不能为空"}],
)} })(
<span className="color-grey-c font-12 fl">简明扼要介绍文档/视频所包含的主要的内容</span> <Input placeholder="例如:软件工程教学案例" className="greyInput winput-300-35 mr20 fl"/>
</Form.Item> )}
<div className="clearfix"> <span className="color-grey-c font-12 fl">简明扼要介绍文档/视频所包含的主要的内容</span>
<Form.Item label="作者" className="fl with22"> </Form.Item>
{getFieldDecorator('userName', { <div className="clearfix">
rules: [{required: true, message: "请输入作者姓名"}], <Form.Item label="作者" className="fl with22">
})( {getFieldDecorator('userName', {
<Input placeholder="请输入姓名" className="greyInput winput-120-35 mr20 fl winput150"/> rules: [{required: true, message: "请输入作者姓名"}],
)} })(
</Form.Item> <Input placeholder="请输入姓名" className="greyInput winput-120-35 mr20 fl winput150"/>
<Form.Item className="fl resetLeft"> )}
{getFieldDecorator('userUnit', { </Form.Item>
rules: [{required: true, message: "请输入作者单位名称"}], <Form.Item className="fl resetLeft">
})( {getFieldDecorator('userUnit', {
<Input placeholder="请输入作者单位名称" className="greyInput winput-300-35 mr20 fl"/> rules: [{required: true, message: "请输入作者单位名称"}],
)} })(
</Form.Item> <Input placeholder="请输入作者单位名称" className="greyInput winput-300-35 mr20 fl"/>
</div> )}
<div className={checkTag==true ? "clearfix mb20 pr has-error" : "clearfix mb20"} id="tagFormItem"> </Form.Item>
<span className="upload_Title must">标签</span> </div>
<ul className="fl libraries_tab"> <div className={checkTag==true ? "clearfix mb20 pr has-error" : "clearfix mb20"} id="tagFormItem">
<li className={ casesTags.indexOf(1) > -1 ? "active" :"" } onClick={()=>this.changeType(1)}>获奖案例</li> <span className="upload_Title must">标签</span>
<li className={ casesTags.indexOf(2) > -1 ? "active" :"" } onClick={()=>this.changeType(2)}>入库案例</li> <ul className="fl libraries_tab">
</ul> <li className={ casesTags.indexOf(1) > -1 ? "active" :"" } onClick={()=>this.changeType(1)}>获奖案例</li>
{ <li className={ casesTags.indexOf(2) > -1 ? "active" :"" } onClick={()=>this.changeType(2)}>入库案例</li>
checkTag && <div class="ant-form-explain">请选择标签</div> <li className={ casesTags.indexOf(3) > -1 ? "active" :"" } onClick={()=>this.changeType(3)}>企业案例</li>
} </ul>
</div> {
<Form.Item label="描述" className="resetBottom" style={{marginBottom:"0px"}}> checkTag && <div class="ant-form-explain">请选择标签</div>
{getFieldDecorator('description', { }
rules: [{ </div>
required: true, message: '请输入描述内容' <Form.Item label="描述" className="resetBottom" style={{marginBottom:"0px"}}>
}], {getFieldDecorator('description', {
})( rules: [{
<TPMMDEditor ref={this.DescMdRef} placeholder="请添加描述" mdID={'caseContentMD'} refreshTimeout={1500} required: true, message: '请输入描述内容'
watch={true} className="caseMessageMD" initValue={CaseDetail && CaseDetail.content}></TPMMDEditor> }],
)} })(
</Form.Item> <TPMMDEditor ref={this.DescMdRef} placeholder="请添加描述" mdID={'caseContentMD'} refreshTimeout={1500}
<div className={checkFile == true ? "clearfix mb20 pr has-error" : "clearfix mb20"} id="fileFormItem" style={{marginLeft:"76px"}}> watch={true} className="caseMessageMD" initValue={CaseDetail && CaseDetail.content}></TPMMDEditor>
<Dragger {...uploadProps} className="librariesField upload_1"> )}
<p className="ant-upload-text color-blue font-18 mb20">上传附件</p> </Form.Item>
<p className="ant-upload-text color-grey-c">从我的电脑选择要上传的文档按住CTRL可以上传多份文档单个文件最大限制150MB</p> <div className={checkFile == true ? "clearfix mb20 pr has-error" : "clearfix mb20"} id="fileFormItem" style={{marginLeft:"76px"}}>
</Dragger> <Dragger {...uploadProps} className="librariesField upload_1">
{ <p className="ant-upload-text color-blue font-18 mb20">上传附件</p>
checkFile == true && <div style={{left:"0px",bottom:"-21px"}} class="ant-form-explain">请先上传附件</div> <p className="ant-upload-text color-grey-c">从我的电脑选择要上传的文档按住CTRL可以上传多份文档单个文件最大限制150MB</p>
} </Dragger>
</div> {
<p className="lineh-25 mt20 mb10 clearfix"> checkFile == true && <div style={{left:"0px",bottom:"-21px"}} class="ant-form-explain">请先上传附件</div>
<span className="upload_Title" style={{marginRight:"12px"}}>封面图</span><span class="color-grey-c fl lineh-35">120*90 px</span> }
</p> </div>
<div style={{marginLeft:"76px"}} className="uploadImage"> <p className="lineh-25 mt20 mb10 clearfix">
<Upload {...uploadCover}> <span className="upload_Title" style={{marginRight:"12px"}}>封面图</span><span class="color-grey-c fl lineh-35">120*90 px</span>
{ imageUrl ? </p>
<Tooltip title="重新上传"> <div style={{marginLeft:"76px"}} className="uploadImage">
<img src={imageUrl} alt="avatar" style={{ width: '100%' }} /> <Upload {...uploadCover}>
</Tooltip> { imageUrl ?
: <Tooltip title="重新上传">
<Tooltip title="上传图片"> <img src={imageUrl} alt="avatar" style={{ width: '100%' }} />
{uploadButton} </Tooltip>
</Tooltip> :
} <Tooltip title="上传图片">
</Upload> {uploadButton}
</div> </Tooltip>
</div> }
<div className="padding30 bor-top-greyE edu-back-white"> </Upload>
<li className="lineh-25 color-grey-6 font-18 mb20">审核说明</li> </div>
<ul className="font-16"> </div>
<li>平台管理员将对每天新上传的文档进行审核审核通过的文档将公开显示否则将私有化或移除</li> <div className="padding30 bor-top-greyE edu-back-white">
</ul> <li className="lineh-25 color-grey-6 font-18 mb20">审核说明</li>
</div> <ul className="font-16">
<div className="padding30 bor-top-greyE edu-back-white"> <li>平台管理员将对每天新上传的文档进行审核审核通过的文档将公开显示否则将私有化或移除</li>
<li className="lineh-25 color-grey-6 font-18 mb20">温馨提示</li> </ul>
<ul className="font-16 lineh-30"> </div>
<li>1.请勿上传已设置加密口令的文档资源</li> <div className="padding30 bor-top-greyE edu-back-white">
<li>2.可以上传符合教学案例标准的文档资料 <li className="lineh-25 color-grey-6 font-18 mb20">温馨提示</li>
<a className="color-blue" target="_blank" href="https://www.educoder.net/courses/1309/boards/5909/messages/34799">案例入库标准</a> <ul className="font-16 lineh-30">
<a target="_blank" className="color-blue" href="https://www.educoder.net/courses/1309/boards/5909/messages/34798">案例使用说明书</a>100MB</li> <li>1.请勿上传已设置加密口令的文档资源</li>
<li>3.请确保上传内容无侵权或违反国家关于互联网政策的不良行为</li> <li>2.可以上传符合教学案例标准的文档资料
<li>4.请使用ChromeFirefoxSafariIE11及以上版本浏览器</li> <a className="color-blue" target="_blank" href="https://www.educoder.net/courses/1309/boards/5909/messages/34799">案例入库标准</a>
</ul> <a target="_blank" className="color-blue" href="https://www.educoder.net/courses/1309/boards/5909/messages/34798">案例使用说明书</a>100MB</li>
</div> <li>3.请确保上传内容无侵权或违反国家关于互联网政策的不良行为</li>
<Form.Item> <li>4.请使用ChromeFirefoxSafariIE11及以上版本浏览器</li>
<div className="clearfix mt30 mb30"> </ul>
{ </div>
(!caseID || (CaseDetail && CaseDetail.status == "pending" || CaseDetail && CaseDetail.status == "refused")) ? <Button type="primary" onClick={()=>this.handleSubmit("submit")} className="defalutSubmitbtn fl mr20">申请发布</Button> : "" <Form.Item>
} <div className="clearfix mt30 mb30">
<a className="defalutCancelbtn fl" onClick={()=>this.handleSubmit("save")}>保存</ a> {
</div> (!caseID || (CaseDetail && CaseDetail.status == "pending" || CaseDetail && CaseDetail.status == "refused")) ? <Button type="primary" onClick={()=>this.handleSubmit("submit")} className="defalutSubmitbtn fl mr20">申请发布</Button> : ""
</Form.Item> }
</Form> <a className="defalutCancelbtn fl" onClick={()=>this.handleSubmit("save")}>保存</ a>
</div> </div>
) </Form.Item>
} </Form>
} </div>
const WrappedCoursesNewApp = Form.create({name: 'CaseNew'})(CaseNew); )
}
}
const WrappedCoursesNewApp = Form.create({name: 'CaseNew'})(CaseNew);
export default WrappedCoursesNewApp; export default WrappedCoursesNewApp;

@ -14,7 +14,17 @@ class CaseTags extends Component{
{ {
tags && tags.map((item,key)=>{ tags && tags.map((item,key)=>{
return( return(
<span key={key} className={item.name == "获奖案例" ? "edu-filter-btn fl cdefault edu-activity-red ml10" : "edu-filter-btn fl cdefault edu-activity-blue ml10"}>{item.name}</span> <React.Fragment>
{
item.name == "获奖案例" ?
<span key={key} className="edu-filter-btn fl cdefault edu-activity-red ml10">{item.name}</span>
:
item.name == "入库案例" ?
<span key={key} className="edu-filter-btn fl cdefault edu-activity-blue ml10">{item.name}</span>
:
<span key={key} className="edu-filter-btn fl cdefault edu-activity-orange-sub ml10">{item.name}</span>
}
</React.Fragment>
) )
}) })
} }

@ -62,6 +62,13 @@
border: 1px solid #4CACFF; border: 1px solid #4CACFF;
line-height: 17px; line-height: 17px;
} }
.edu-activity-orange-sub {
background-color: #FF781B;
color: #fff!important;
cursor: pointer;
border: 1px solid #ff6800;
line-height: 17px;
}
.pointsBtn { .pointsBtn {
width: 70px; width: 70px;

@ -481,12 +481,13 @@ export function TPMIndexHOC(WrappedComponent) {
} }
` `
}</style> }</style>
<NewHeader {...this.state} {...this.props}></NewHeader>
<Spin spinning={this.state.globalLoading} delay={0} className="globalSpin" <Spin spinning={this.state.globalLoading} delay={0} className="globalSpin"
size="large" size="large"
tip= {this._gLoadingTip || "加载中..."} tip= {this._gLoadingTip || "加载中..."}
> >
<NewHeader {...this.state} {...this.props}></NewHeader>
<div className="newContainer newContainers"> <div className="newContainer newContainers">
<WrappedComponent initCommonState={(user)=>this.initCommonState(user)} <WrappedComponent initCommonState={(user)=>this.initCommonState(user)}
{...this.props} {...this.state} {...this.props} {...this.state}
@ -497,11 +498,12 @@ export function TPMIndexHOC(WrappedComponent) {
</div> </div>
</Spin>
<NewFooter <NewFooter
Footerdown={Footerdown} Footerdown={Footerdown}
/> />
</Spin>
</div> </div>
); );
} }

@ -1384,20 +1384,23 @@ export default class TPMsettings extends Component {
} }
onAttachmentRemove = (file) => { onAttachmentRemove = (file) => {
confirm({ if(file.response!=undefined){
title: '确定要删除这个附件吗?', confirm({
okText: '确定', title: '确定要删除这个附件吗?',
cancelText: '取消', okText: '确定',
// content: 'Some descriptions', cancelText: '取消',
onOk: () => { // content: 'Some descriptions',
console.log("665") onOk: () => {
this.deleteAttachment(file) console.log("665")
}, this.deleteAttachment(file)
onCancel() { },
console.log('Cancel'); onCancel() {
}, console.log('Cancel');
}); },
return false; });
return false;
}
} }
deleteAttachment = (file) => { deleteAttachment = (file) => {

@ -772,20 +772,23 @@ class Newshixuns extends Component {
} }
onAttachmentRemove = (file) => { onAttachmentRemove = (file) => {
confirm({ if(file.response!=undefined){
title: '确定要删除这个附件吗?', confirm({
okText: '确定', title: '确定要删除这个附件吗?',
cancelText: '取消', okText: '确定',
// content: 'Some descriptions', cancelText: '取消',
onOk: () => { // content: 'Some descriptions',
console.log("665") onOk: () => {
this.deleteAttachment(file) console.log("665")
}, this.deleteAttachment(file)
onCancel() { },
console.log('Cancel'); onCancel() {
}, console.log('Cancel');
}); },
return false; });
return false;
}
} }
deleteAttachment = (file) => { deleteAttachment = (file) => {
console.log(file); console.log(file);
@ -913,7 +916,7 @@ class Newshixuns extends Component {
// // console.log('beforeUpload', file.name); // // console.log('beforeUpload', file.name);
// const isLt50M = file.size / 1024 / 1024 < 50; // const isLt50M = file.size / 1024 / 1024 < 50;
// if (!isLt50M) { // if (!isLt50M) {
// message.error('文件大小必须小于150MB!'); // this.props.showNotification('文件大小必须小于150MB!');
// } // }
// return isLt50M; // return isLt50M;
// }, // },

@ -13,6 +13,7 @@ import axios from 'axios';
import { trace, trace_collapse ,getImageUrl, toPath} from "educoder"; import { trace, trace_collapse ,getImageUrl, toPath} from "educoder";
import RepositoryDirectories from './RepositoryDirectories' import RepositoryDirectories from './RepositoryDirectories'
import RepositoryAddFile from './RepositoryAddFile'
const $ = window.$; const $ = window.$;
// 点击按钮复制功能 // 点击按钮复制功能
@ -82,10 +83,10 @@ class Repository extends Component {
<a href="/forums/2784" target="_blank" <a href="/forums/2784" target="_blank"
className=" guideBtn" >Git使用指南</a> className=" guideBtn" >Git使用指南</a>
{/* <RepositoryAddFile {...this.props} {...this.state}></RepositoryAddFile> */}
<div className="fr font-12 color-grey-9 pr"> <div className="fr font-12 color-grey-9 pr">
<label className="fl">网址克隆</label> <label className="fl mt2">网址克隆</label>
<input type="text" id="copy_rep_content" className="fl url-input" <input type="text" id="copy_rep_content" className="fl url-input mt2"
defaultValue={ git_url } style={{width: 313}}/> defaultValue={ git_url } style={{width: 313}}/>
<a onClick={() => { <a onClick={() => {
jsCopy() jsCopy()

@ -0,0 +1,52 @@
import React, { Component } from 'react';
import { ActionBtn } from 'educoder'
import { Form , Modal } from 'antd'
class RepositoryAddFile extends Component {
constructor(props) {
super(props);
this.state={
visible:false
}
}
addFile = () =>{
this.setState({
visible:true
})
}
cancelAdd = () =>{
this.setState({
visible:false
})
}
render(){
let { visible } = this.state
return(
<React.Fragment>
<ActionBtn style="orangeLine" className="ml20" onClick={this.addFile}>+添加文件</ActionBtn>
<Modal
className={"RepositioryModal"}
title={'添加文件'}
visible={visible}
closable={false}
footer={null}
destroyOnClose={true}
width="550px"
>
<div className="task-popup-content">
</div>
<div className="clearfix mt30 edu-txt-center mb10">
<a className="task-btn color-white mr30" onClick={this.cancelAdd}>取消</a>
<a className="task-btn task-btn-orange">提交</a>
</div>
</Modal>
</React.Fragment>
)
}
}
const WrappedRepositoryAddFile = Form.create({name: 'taskRepositoryAddFile'})(RepositoryAddFile);
// RouteHOC()
export default (WrappedRepositoryAddFile);
Loading…
Cancel
Save