diff --git a/public/react/src/modules/courses/coursesPublic/AccessoryModal.js b/public/react/src/modules/courses/coursesPublic/AccessoryModal.js index 750679111..aadfa770f 100644 --- a/public/react/src/modules/courses/coursesPublic/AccessoryModal.js +++ b/public/react/src/modules/courses/coursesPublic/AccessoryModal.js @@ -40,15 +40,17 @@ class AccessoryModal extends Component{ } // 附件相关 START handleChange = (info) => { - let fileList = info.fileList; - console.log(fileList) - // for(var list of fileList ){ - // console.log(fileList) - // } - this.setState({ - fileList:fileList, - Errormessage:false, - }); + if (info.file.status === 'uploading' || info.file.status === 'done' || info.file.status === 'removed') { + let fileList = info.fileList; + console.log(fileList) + // for(var list of fileList ){ + // console.log(fileList) + // } + this.setState({ + fileList:fileList, + Errormessage:false, + }); + } } onAttachmentRemove = (file) => { diff --git a/public/react/src/modules/courses/graduation/tasks/GraduationTasksnew.js b/public/react/src/modules/courses/graduation/tasks/GraduationTasksnew.js index da83e8d7e..2a658d0df 100644 --- a/public/react/src/modules/courses/graduation/tasks/GraduationTasksnew.js +++ b/public/react/src/modules/courses/graduation/tasks/GraduationTasksnew.js @@ -2,11 +2,12 @@ import React, {Component} from "React"; import {Form, Select, Input, Button, Checkbox, Upload, Icon, message, Modal} from "antd"; import {Link} from 'react-router-dom'; import TPMMDEditor from '../../../tpm/challengesnew/TPMMDEditor'; -import {WordsBtn, getUrl,bytesToSize,appendFileSizeToUploadFileAll} from 'educoder'; +import {WordsBtn, getUrl,bytesToSize,appendFileSizeToUploadFileAll , getUploadActionUrl} from 'educoder'; import axios from 'axios'; import Modals from '../../../modals/Modals'; import '../../css/Courses.css'; + const {Option} = Select; const CheckboxGroup = Checkbox.Group; const confirm = Modal.confirm; @@ -127,7 +128,7 @@ class GraduationTasksnew extends Component { } // 附件相关 START handleChange = (info) => { - if(info.file.status == "done" || info.file.status == "uploading"){ + if(info.file.status == "done" || info.file.status == "uploading" || info.file.status === 'removed'){ let fileList = info.fileList; // for(var list of fileList ){ @@ -174,7 +175,26 @@ class GraduationTasksnew extends Component { onAttachmentRemove = (file) => { if(!file.percent || file.percent == 100){ - const url = `/attachments/${file.response ? file.response.id : file.uid}.json` + this.props.confirm({ + content: '确定要删除这个附件吗?', + okText: '确定', + cancelText: '取消', + // content: 'Some descriptions', + onOk: () => { + this.deleteAttachment(file) + }, + onCancel() { + console.log('Cancel'); + }, + }); + return false; + + } + + } + + deleteAttachment = (file) =>{ + const url = `/attachments/${file.response ? file.response.id : file.uid}.json` // const url = `/attachments/${file}.json` axios.delete(url, {}) .then((response) => { @@ -198,8 +218,6 @@ class GraduationTasksnew extends Component { .catch(function (error) { console.log(error); }); - } - } //滚动 @@ -267,7 +285,7 @@ class GraduationTasksnew extends Component { // 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) => { diff --git a/public/react/src/modules/courses/graduation/topics/GraduateTopicNew.js b/public/react/src/modules/courses/graduation/topics/GraduateTopicNew.js index 28d6fcf77..20e03d069 100644 --- a/public/react/src/modules/courses/graduation/topics/GraduateTopicNew.js +++ b/public/react/src/modules/courses/graduation/topics/GraduateTopicNew.js @@ -11,7 +11,7 @@ import {getUrl} from 'educoder'; import "../../common/formCommon.css" import '../style.css' import '../../css/Courses.css' -import { WordsBtn, City } from 'educoder' +import { WordsBtn, City , getUploadActionUrl } from 'educoder' import {Link} from 'react-router-dom' // import City from './City' @@ -211,14 +211,16 @@ class GraduateTopicNew extends Component{ // 附件相关 START handleChange = (info) => { - let fileList = info.fileList; - this.setState({ fileList }); + if (info.file.status === 'uploading' || info.file.status === 'done' || info.file.status === 'removed') { + let fileList = info.fileList; + this.setState({ fileList }); + } } onAttachmentRemove = (file) => { if(!file.percent || file.percent == 100){ - confirm({ - title: '确定要删除这个附件吗?', + this.props.confirm({ + content: '确定要删除这个附件吗?', okText: '确定', cancelText: '取消', // content: 'Some descriptions', @@ -307,7 +309,7 @@ class GraduateTopicNew extends Component{ // 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) => {