删除调整

dev_hss
杨树明 5 years ago
parent f26aa7b19b
commit a449496d59

@ -159,7 +159,8 @@ class GraduationTasksSubmitedit extends Component{
onAttachmentRemove = (file) => { onAttachmentRemove = (file) => {
if(!file.percent || file.percent == 100){ if(!file.percent || file.percent == 100){
let {attachments,fileList}=this.state; let {attachments,fileList}=this.state;
const url = `/attachments/${file}.json` let id=file.response ==undefined ? file.id : file.response.id;
const url = `/attachments/${id}.json`
axios.delete(url, { axios.delete(url, {
}) })
.then((response) => { .then((response) => {

@ -168,36 +168,38 @@ class GraduationTasksSubmitnew extends Component{
} }
deleteAttachment = (file) => { deleteAttachment = (file) => {
const url = `/attachments/${file}.json` if(!file.percent || file.percent == 100){
axios.delete(url, { let id = file.response == undefined ? file.id : file.response.id;
}) const url = `/attachments/${id}.json`
.then((response) => { axios.delete(url, {})
if (response.data) { .then((response) => {
// const { status } = response.data; if (response.data) {
if (response.data.status === 0) { // const { status } = response.data;
if (response.data.status === 0) {
console.log('--- success')
this.setState({ console.log('--- success')
Modalstype:true, this.setState({
Modalstopval:response.data.message, Modalstype: true,
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 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)=>{

Loading…
Cancel
Save