Merge branch 'dev_aliyun' of https://bdgit.educoder.net/Hjqreturn/educoder into dev_aliyun

dev_aliyun_beta
杨树林 6 years ago
commit 41994149db

@ -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

@ -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=()=>{

@ -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

@ -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);
}
} }

@ -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);
} }

@ -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) => {

@ -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=()=>{

@ -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)=>{

@ -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=()=>{

@ -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

@ -148,39 +148,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)=>{

@ -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); });
}); }
} }
//滚动 //滚动

@ -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);

@ -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`

@ -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`

@ -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

@ -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` // 上传附件-确认删除
axios.delete(url, { deleteAttachment = (file, stateName) => {
}).then((response) => { // 初次上传不能直接取uid
if (response.data) { const url = `/attachments/${file.response ? file.response.id : file.uid}.json`
const { status } = response.data; axios.delete(url, {
if (status == 0) { }).then((response) => {
console.log('--- success') if (response.data) {
const { status } = response.data;
this.setState((state) => { if (status == 0) {
const index = state[stateName].indexOf(file); console.log('--- success')
const newFileList = state[stateName].slice();
newFileList.splice(index, 1); this.setState((state) => {
console.log("newFileList"); const index = state[stateName].indexOf(file);
console.log(newFileList.map(item =>{ return( item.id )})); const newFileList = state[stateName].slice();
return { newFileList.splice(index, 1);
[stateName]: newFileList, console.log("newFileList");
filesID:newFileList.map(item =>{ return( item.id )}) console.log(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) {
// 上传附件-change console.log(error);
handleContentUploadChange = (info) => { });
if (info.file.status === 'done' || info.file.status === 'uploading') { }
let contentFileList = info.fileList; // 上传附件-change
this.setState({ contentFileList: appendFileSizeToUploadFileAll(contentFileList)}); handleContentUploadChange = (info) => {
let list = appendFileSizeToUploadFileAll(contentFileList); if (info.file.status === 'done' || info.file.status === 'uploading') {
let arr = list.map(item=>{ let contentFileList = info.fileList;
return ( item.response && item.response.id ) this.setState({ contentFileList: appendFileSizeToUploadFileAll(contentFileList)});
}) let list = appendFileSizeToUploadFileAll(contentFileList);
this.setState({ let arr = list.map(item=>{
filesID:arr, return ( item.response && item.response.id )
checkFile:arr.length > 0 ? false : true })
}) this.setState({
} filesID:arr,
} checkFile:arr.length > 0 ? false : true
})
// 上传封面图-change }
handleChange = (info) => { }
if (info.file.status === 'uploading') {
this.setState({ loading: true }); // 上传封面图-change
return; handleChange = (info) => {
} if (info.file.status === 'uploading') {
if (info.file.status === 'done') { this.setState({ loading: true });
// Get this url from response in real world. return;
getBase64(info.file.originFileObj, imageUrl => }
this.setState({ if (info.file.status === 'done') {
imageUrl, // Get this url from response in real world.
loading: false getBase64(info.file.originFileObj, imageUrl =>
}), this.setState({
); imageUrl,
console.log(info.file); loading: false
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({
caseTitle:this.props.CaseDetail.title, componentDidUpdate=(prevState)=>{
userName:this.props.CaseDetail.author_name, if(this.props.CaseDetail && prevState.CaseDetail != this.props.CaseDetail){
userUnit:this.props.CaseDetail.author_school_name, this.props.form.setFieldsValue({
}) caseTitle:this.props.CaseDetail.title,
this.setState({ userName:this.props.CaseDetail.author_name,
contentFileList:this.props.attachments.map(item => { userUnit:this.props.CaseDetail.author_school_name,
return { })
id: item.id, this.setState({
uid: item.id, contentFileList:this.props.attachments.map(item => {
name: appendFileSizeToUploadFile(item), return {
url: item.url, id: item.id,
filesize: item.filesize, uid: item.id,
status: 'done' name: appendFileSizeToUploadFile(item),
} url: item.url,
}), filesize: item.filesize,
filesID:this.props.attachments.map(item => { status: 'done'
return ( item.id ) }
}), }),
coverID:this.props.cover && this.props.cover.id, filesID:this.props.attachments.map(item => {
imageUrl:this.props.CaseDetail.cover && setImagesUrl(this.props.CaseDetail.cover.url), return ( item.id )
casesTags:this.props.tags.map(item=>{ }),
return (item.id); coverID:this.props.cover && this.props.cover.id,
}) imageUrl:this.props.CaseDetail.cover && setImagesUrl(this.props.CaseDetail.cover.url),
}) casesTags:this.props.tags.map(item=>{
console.log(this.props.attachments.map(item => { return (item.id);
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); // 申请提交和保存
this.props.form.validateFieldsAndScroll((err, values) => { handleSubmit = (type) => {
let { casesTags , filesID } = this.state; let caseID = this.props.match.params.caseID;
if(casesTags.length == 0){ console.log(type);
$("html").animate({ scrollTop: $("#tagFormItem").offset().top - 100 }); this.props.form.validateFieldsAndScroll((err, values) => {
this.setState({ let { casesTags , filesID } = this.state;
checkTag:true if(casesTags.length == 0){
}) $("html").animate({ scrollTop: $("#tagFormItem").offset().top - 100 });
return; this.setState({
} checkTag:true
if(filesID.length == 0){ })
$("html").animate({ scrollTop: $("#fileFormItem").offset().top - 100 }); return;
this.setState({ }
checkFile:true if(filesID.length == 0){
}) $("html").animate({ scrollTop: $("#fileFormItem").offset().top - 100 });
return; this.setState({
} checkFile:true
})
const mdContnet = this.DescMdRef.current.getValue().trim(); return;
console.log(mdContnet) }
values.description = mdContnet;
const mdContnet = this.DescMdRef.current.getValue().trim();
console.log(values); console.log(mdContnet)
let url = caseID ? `/libraries/${caseID}.json`: `/libraries.json`; values.description = mdContnet;
if(caseID){
axios.put((url),{ console.log(values);
title:values.caseTitle, let url = caseID ? `/libraries/${caseID}.json`: `/libraries.json`;
author_name:values.userName, if(caseID){
author_school_name:values.userUnit, axios.put((url),{
content:values.description, title:values.caseTitle,
attachment_ids:this.state.contentFileList.map(item=>{ author_name:values.userName,
return (item.response ? item.response.id : item.id ) author_school_name:values.userUnit,
}), content:values.description,
tag_ids:this.state.casesTags, attachment_ids:this.state.contentFileList.map(item=>{
cover_id:this.state.coverID, return (item.response ? item.response.id : item.id )
publish:type == 'save' ? false : true }),
}).then((result)=>{ tag_ids:this.state.casesTags,
if(result){ cover_id:this.state.coverID,
this.props.showNotification(type == 'save' ? `案例保存成功!`: `提交成功!`); publish:type == 'save' ? false : true
this.props.history.push(type == 'save' ? `/moop_cases/${result.data.id}` : `/moop_cases/${result.data.id}/publish_success`); }).then((result)=>{
} if(result){
}).catch((error)=>{ this.props.showNotification(type == 'save' ? `案例保存成功!`: `提交成功!`);
console.log(error); this.props.history.push(type == 'save' ? `/moop_cases/${result.data.id}` : `/moop_cases/${result.data.id}/publish_success`);
}) }
}else{ }).catch((error)=>{
axios.post((url),{ console.log(error);
title:values.caseTitle, })
author_name:values.userName, }else{
author_school_name:values.userUnit, axios.post((url),{
content:values.description, title:values.caseTitle,
attachment_ids:this.state.filesID, author_name:values.userName,
tag_ids:this.state.casesTags, author_school_name:values.userUnit,
cover_id:this.state.coverID, content:values.description,
publish:type == 'save' ? false : true attachment_ids:this.state.filesID,
}).then((result)=>{ tag_ids:this.state.casesTags,
if(result){ cover_id:this.state.coverID,
this.props.showNotification(type == 'save' ? `案例保存成功!`: `提交成功!`); publish:type == 'save' ? false : true
this.props.history.push(type == 'save' ? `/moop_cases/${result.data.id}` : `/moop_cases/${result.data.id}/publish_success`); }).then((result)=>{
} if(result){
}).catch((error)=>{ this.props.showNotification(type == 'save' ? `案例保存成功!`: `提交成功!`);
console.log(error); this.props.history.push(type == 'save' ? `/moop_cases/${result.data.id}` : `/moop_cases/${result.data.id}/publish_success`);
}) }
} }).catch((error)=>{
console.log(error);
}) })
} }
// 选择标签 })
changeType=(type)=>{ }
let tags = [];
if(this.state.casesTags.indexOf(type) > -1){ // 选择标签
tags = this.state.casesTags.filter(item => item != type); changeType=(type)=>{
}else{ let tags = [];
tags = this.state.casesTags.concat(type); if(this.state.casesTags.indexOf(type) > -1){
} tags = this.state.casesTags.filter(item => item != type);
const tagUniqed = _.uniq(tags); }else{
this.setState({ tags = this.state.casesTags.concat(type);
casesTags: tagUniqed, }
checkTag:tags.length > 0 ? false : true const tagUniqed = _.uniq(tags);
}) this.setState({
} casesTags: tagUniqed,
checkTag:tags.length > 0 ? false : true
render(){ })
let { caseID } = this.props.match.params; }
let { CaseDetail } = this.props;
let { casesTags , contentFileList , imageUrl , checkTag , checkFile } = this.state; render(){
const {getFieldDecorator} = this.props.form; let { caseID } = this.props.match.params;
let { CaseDetail } = this.props;
let { casesTags , contentFileList , imageUrl , checkTag , checkFile } = this.state;
// 上传附件点击事件 const {getFieldDecorator} = this.props.form;
const uploadProps = {
width: 600,
multiple: true, // 上传附件点击事件
fileList:contentFileList, const uploadProps = {
action: `${getUploadActionUrl()}`, width: 600,
onChange: this.handleContentUploadChange, multiple: true,
onRemove: (file) => this.onAttachmentRemove(file, 'contentFileList'), fileList:contentFileList,
beforeUpload: (file) => { action: `${getUploadActionUrl()}`,
const isLt150M = file.size / 1024 / 1024 < 150; onChange: this.handleContentUploadChange,
if (!isLt150M) { onRemove: (file) => this.onAttachmentRemove(file, 'contentFileList'),
//message.error('文件大小必须小于150MB!'); beforeUpload: (file) => {
this.props.define({ const isLt150M = file.size / 1024 / 1024 < 150;
title:'提示', if (!isLt150M) {
content:"该文件无法上传。超过文件大小限制(150MB),建议上传到百度云等其它共享工具里然后再txt文档里给出链接以及共享密码并上传" //message.error('文件大小必须小于150MB!');
}) this.props.define({
return isLt150M; title:'提示',
} content:"该文件无法上传。超过文件大小限制(150MB),建议上传到百度云等其它共享工具里然后再txt文档里给出链接以及共享密码并上传"
} })
}; return isLt150M;
// 上传封面图-html }
const uploadButton = ( }
<div> };
<Icon className='font-36 color-grey-c' type={this.state.loading ? 'loading' : 'plus'} /> // 上传封面图-html
</div> const uploadButton = (
); <div>
// 上传封面图点击事件 <Icon className='font-36 color-grey-c' type={this.state.loading ? 'loading' : 'plus'} />
const uploadCover = { </div>
listType:"picture-card", );
className:"avatar-uploader", // 上传封面图点击事件
showUploadList:false, const uploadCover = {
action:`${getUploadActionUrl()}`, listType:"picture-card",
onChange:this.handleChange, className:"avatar-uploader",
} showUploadList:false,
console.log('111'); action:`${getUploadActionUrl()}`,
console.log(!caseID || (CaseDetail && CaseDetail.status == "pending")); onChange:this.handleChange,
return( }
<div className="educontent mt10 mb50"> console.log('111');
<style> console.log(!caseID || (CaseDetail && CaseDetail.status == "pending"));
{ return(
` <div className="educontent mt10 mb50">
.newCases .ant-col.ant-form-item-label{ <style>
float:left; {
margin-right:20px; `
height:35px; .newCases .ant-col.ant-form-item-label{
line-height:35px; float:left;
} margin-right:20px;
height:35px;
.newCaseUpload{ line-height:35px;
width: 100%; }
background: #F2F9FF;
justify-content: center; .newCaseUpload{
align-items: center; width: 100%;
display: -webkit-flex; background: #F2F9FF;
text-align: center; justify-content: center;
height: 120px; align-items: center;
border-radius: 4px; display: -webkit-flex;
border: 1px dashed #4cacff; text-align: center;
} height: 120px;
.newCases .ant-form-item{ border-radius: 4px;
margin-bottom:20px!important ; border: 1px dashed #4cacff;
} }
.newCases .ant-col.ant-form-item-control-wrapper{ .newCases .ant-form-item{
position:relative; margin-bottom:20px!important ;
} }
.newCases .ant-form-explain{ .newCases .ant-col.ant-form-item-control-wrapper{
position:absolute; position:relative;
bottom:-18px; }
left:76px; .newCases .ant-form-explain{
padding-left: 7px; position:absolute;
} bottom:-18px;
.newCases .resetLeft .ant-form-explain{ left:76px;
left:0px; padding-left: 7px;
} }
.newCases .resetBottom .ant-form-explain{ .newCases .resetLeft .ant-form-explain{
bottom:2px; left:0px;
} }
` .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> }
</p> </style>
<p class="lineh-25 font-22 mb20">上传教学案例</p> <p className="mt10 mb20 clearfix lineh-20">
<Form onSubmit={this.handleSubmit} className={"newCases"}> <a href="/moop_cases" className="color-grey-9">教学案例</a> &gt; <span className="color-grey-3">{ caseID ? "" : "" }</span>
<div className="padding30 edu-back-white"> </p>
<Form.Item label="标题"> <p class="lineh-25 font-22 mb20">上传教学案例</p>
{getFieldDecorator('caseTitle', { <Form onSubmit={this.handleSubmit} className={"newCases"}>
rules: [{required: true, message: "案例标题不能为空"}], <div className="padding30 edu-back-white">
})( <Form.Item label="标题">
<Input placeholder="例如:软件工程教学案例" className="greyInput winput-300-35 mr20 fl"/> {getFieldDecorator('caseTitle', {
)} rules: [{required: true, message: "案例标题不能为空"}],
<span className="color-grey-c font-12 fl">简明扼要介绍文档/视频所包含的主要的内容</span> })(
</Form.Item> <Input placeholder="例如:软件工程教学案例" className="greyInput winput-300-35 mr20 fl"/>
<div className="clearfix"> )}
<Form.Item label="作者" className="fl with22"> <span className="color-grey-c font-12 fl">简明扼要介绍文档/视频所包含的主要的内容</span>
{getFieldDecorator('userName', { </Form.Item>
rules: [{required: true, message: "请输入作者姓名"}], <div className="clearfix">
})( <Form.Item label="作者" className="fl with22">
<Input placeholder="请输入姓名" className="greyInput winput-120-35 mr20 fl winput150"/> {getFieldDecorator('userName', {
)} rules: [{required: true, message: "请输入作者姓名"}],
</Form.Item> })(
<Form.Item className="fl resetLeft"> <Input placeholder="请输入姓名" className="greyInput winput-120-35 mr20 fl winput150"/>
{getFieldDecorator('userUnit', { )}
rules: [{required: true, message: "请输入作者单位名称"}], </Form.Item>
})( <Form.Item className="fl resetLeft">
<Input placeholder="请输入作者单位名称" className="greyInput winput-300-35 mr20 fl"/> {getFieldDecorator('userUnit', {
)} rules: [{required: true, message: "请输入作者单位名称"}],
</Form.Item> })(
</div> <Input placeholder="请输入作者单位名称" className="greyInput winput-300-35 mr20 fl"/>
<div className={checkTag==true ? "clearfix mb20 pr has-error" : "clearfix mb20"} id="tagFormItem"> )}
<span className="upload_Title must">标签</span> </Form.Item>
<ul className="fl libraries_tab"> </div>
<li className={ casesTags.indexOf(1) > -1 ? "active" :"" } onClick={()=>this.changeType(1)}>获奖案例</li> <div className={checkTag==true ? "clearfix mb20 pr has-error" : "clearfix mb20"} id="tagFormItem">
<li className={ casesTags.indexOf(2) > -1 ? "active" :"" } onClick={()=>this.changeType(2)}>入库案例</li> <span className="upload_Title must">标签</span>
</ul> <ul className="fl libraries_tab">
{ <li className={ casesTags.indexOf(1) > -1 ? "active" :"" } onClick={()=>this.changeType(1)}>获奖案例</li>
checkTag && <div class="ant-form-explain">请选择标签</div> <li className={ casesTags.indexOf(2) > -1 ? "active" :"" } onClick={()=>this.changeType(2)}>入库案例</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;

@ -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);

Loading…
Cancel
Save