|
|
|
@ -5,9 +5,7 @@ import {
|
|
|
|
|
} from 'antd';
|
|
|
|
|
import TPMMDEditor from '../../../tpm/challengesnew/TPMMDEditor';
|
|
|
|
|
import axios from 'axios'
|
|
|
|
|
import {getUrl} from 'educoder';
|
|
|
|
|
|
|
|
|
|
import { City } from 'educoder'
|
|
|
|
|
import { City , getUploadActionUrl , appendFileSizeToUploadFileAll } from 'educoder';
|
|
|
|
|
|
|
|
|
|
const NAME_COUNT=60;
|
|
|
|
|
class GraduateTopicNewForm extends Component{
|
|
|
|
@ -80,15 +78,21 @@ class GraduateTopicNewForm extends Component{
|
|
|
|
|
|
|
|
|
|
// 附件相关 START
|
|
|
|
|
handleChange = (info) => {
|
|
|
|
|
let fileList = info.fileList;
|
|
|
|
|
this.setState({ fileList });
|
|
|
|
|
if (info.file.status === 'done' || info.file.status === 'uploading') {
|
|
|
|
|
let contentFileList = info.fileList;
|
|
|
|
|
// this.setState({ fileList: appendFileSizeToUploadFileAll(contentFileList)});
|
|
|
|
|
// let list = appendFileSizeToUploadFileAll(contentFileList);
|
|
|
|
|
// let arr = list.map(item=>{
|
|
|
|
|
// return ( item.response && item.response.id )
|
|
|
|
|
// })
|
|
|
|
|
this.setState({
|
|
|
|
|
fileList:contentFileList
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
onAttachmentRemove = (file) => {
|
|
|
|
|
confirm({
|
|
|
|
|
title: '确定要删除这个附件吗?',
|
|
|
|
|
okText: '确定',
|
|
|
|
|
cancelText: '取消',
|
|
|
|
|
// content: 'Some descriptions',
|
|
|
|
|
this.props.confirm({
|
|
|
|
|
content: '确定要删除这个附件吗?',
|
|
|
|
|
onOk: () => {
|
|
|
|
|
this.deleteAttachment(file)
|
|
|
|
|
},
|
|
|
|
@ -102,9 +106,7 @@ class GraduateTopicNewForm extends Component{
|
|
|
|
|
console.log(file);
|
|
|
|
|
let id=file.response ==undefined ? file.id : file.response.id
|
|
|
|
|
const url = `/attachments/${id}.json`
|
|
|
|
|
axios.delete(url, {
|
|
|
|
|
})
|
|
|
|
|
.then((response) => {
|
|
|
|
|
axios.delete(url).then((response) => {
|
|
|
|
|
if (response.data) {
|
|
|
|
|
const { status } = response.data;
|
|
|
|
|
if (status == 0) {
|
|
|
|
@ -205,20 +207,20 @@ class GraduateTopicNewForm extends Component{
|
|
|
|
|
width: 600,
|
|
|
|
|
fileList,
|
|
|
|
|
multiple: true,
|
|
|
|
|
// https://github.com/ant-design/ant-design/issues/15505
|
|
|
|
|
// showUploadList={false},然后外部拿到 fileList 数组自行渲染列表。
|
|
|
|
|
// showUploadList: false,
|
|
|
|
|
action: `${getUrl()}/api/attachments.json`,
|
|
|
|
|
action: `${getUploadActionUrl()}`,
|
|
|
|
|
onChange: this.handleChange,
|
|
|
|
|
onRemove: this.onAttachmentRemove,
|
|
|
|
|
beforeUpload: (file) => {
|
|
|
|
|
console.log('beforeUpload', file.name);
|
|
|
|
|
const isLt150M = file.size / 1024 / 1024 < 150;
|
|
|
|
|
if (!isLt150M) {
|
|
|
|
|
message.error('文件大小必须小于150MB!');
|
|
|
|
|
}
|
|
|
|
|
//message.error('文件大小必须小于150MB!');
|
|
|
|
|
this.props.define({
|
|
|
|
|
title:'提示',
|
|
|
|
|
content:"该文件无法上传。超过文件大小限制(150MB),建议上传到百度云等其它共享工具里,然后再txt文档里给出链接以及共享密码并上传"
|
|
|
|
|
})
|
|
|
|
|
return isLt150M;
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
let { topicId , teacherName }=this.props;
|
|
|
|
|
return(
|
|
|
|
|