删除方法判断还没上传成功时报错问题

dev_aliyun_beta
杨树明 6 years ago
parent a3c928a804
commit 0b43367fa9

@ -320,8 +320,11 @@ class CommonWorkPost extends Component{
// ModalSave: ()=>this.deleteAttachment(file),
// ModalCancel:this.cancelAttachment
// })
this.deleteAttachment(file)
return false;
if(file.response!=undefined){
this.deleteAttachment(file)
return false;
}
}
cancelAttachment=()=>{

@ -243,19 +243,22 @@ class NewWork extends Component{
}
onAttachmentRemove = (file, stateName) => {
this.props.confirm({
content: '是否确认删除?',
onOk: () => {
this.deleteAttachment(file, stateName)
},
onCancel() {
console.log('Cancel');
},
});
if(file.response!=undefined){
this.props.confirm({
content: '是否确认删除?',
onOk: () => {
this.deleteAttachment(file, stateName)
},
onCancel() {
console.log('Cancel');
},
});
return false;
}
return false;
}
deleteAttachment = (file, stateName) => {
// 初次上传不能直接取uid

@ -73,8 +73,9 @@ class AccessoryModal extends Component{
// ModalCancel:this.cancelAttachment
// })
// return false;
this.deleteAttachment(file);
if(file.response!=undefined){
this.deleteAttachment(file);
}
}

@ -64,8 +64,10 @@ class AccessoryModal2 extends Component{
// ModalCancel:this.cancelAttachment
// })
// return false;
if(file.response!=undefined){
this.deleteAttachment(file);
}
this.deleteAttachment(file);
}

@ -296,37 +296,39 @@ class Selectsetting extends Component{
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`
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) {
this.setState({
fileListtype:false,
fileList:[]
})
// this.setState((state) => {
// const index = state.fileList.indexOf(file);
// const newFileList = state.fileList.slice();
// newFileList.splice(index, 1);
// return {
// fileList: newFileList,
// };
// });
this.setState({
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) {
console.log(error);
});
this.setState({
fileListtype:false,
})
}
// const url = `/attachments/${file.response ? file.response.id : file.uid}.json`
}
onChangeTimepublishs= (date, dateString,key) => {

@ -132,28 +132,29 @@ class Sendresource extends Component{
onAttachmentRemove = (file) => {
debugger
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) {
this.setState({
fileListtype:false,
fileList:[]
})
}
}
})
.catch(function (error) {
console.log(error);
});
this.setState({
fileListtype:false,
})
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) {
this.setState({
fileListtype:false,
fileList:[]
})
}
}
})
.catch(function (error) {
console.log(error);
});
this.setState({
fileListtype:false,
})
}
}
ModalCancelModalCancel=()=>{

@ -157,49 +157,52 @@ class GraduationTasksSubmitedit extends Component{
}
onAttachmentRemove = (file) => {
let {attachments,fileList}=this.state;
const url = `/attachments/${file}.json`
axios.delete(url, {
})
.then((response) => {
if (response.data) {
// const { status } = response.data;
if (response.data.status === 0) {
console.log('--- success')
let newattachments=attachments;
if(file.uid===undefined){
for(var i=0; i<newattachments.length; i++){
if(newattachments[i].id===file.id){
newattachments.splice(i, 1);
}
}
if(file.response!=undefined){
let {attachments,fileList}=this.state;
const url = `/attachments/${file}.json`
axios.delete(url, {
})
.then((response) => {
if (response.data) {
// const { status } = response.data;
if (response.data.status === 0) {
console.log('--- success')
let newattachments=attachments;
if(file.uid===undefined){
for(var i=0; i<newattachments.length; i++){
if(newattachments[i].id===file.id){
newattachments.splice(i, 1);
}
}
}
}
this.setState({
Modalstype:true,
Modalstopval:response.data.message,
ModalSave:this.cancelAttachment,
Loadtype:true,
attachments:newattachments
})
this.setState({
Modalstype:true,
Modalstopval:response.data.message,
ModalSave:this.cancelAttachment,
Loadtype:true,
attachments:newattachments
})
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((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);
});
}
}
inputSearchValue=(e)=>{

@ -146,14 +146,16 @@ class GraduationTasksSubmitnew extends Component{
// },
// });
// 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=()=>{

@ -173,30 +173,33 @@ class GraduationTasksnew extends Component {
}
onAttachmentRemove = (file) => {
const url = `/attachments/${file.response ? file.response.id : file.uid}.json`
// const url = `/attachments/${file}.json`
axios.delete(url, {})
.then((response) => {
if (response.data) {
const {status} = response.data;
if (status == 0) {
console.log('--- success')
this.setState((state) => {
const index = state.fileList.indexOf(file);
const newFileList = state.fileList.slice();
newFileList.splice(index, 1);
return {
fileList: newFileList,
};
});
this.cancelAttachment()
if(file.response!=undefined){
const url = `/attachments/${file.response ? file.response.id : file.uid}.json`
// const url = `/attachments/${file}.json`
axios.delete(url, {})
.then((response) => {
if (response.data) {
const {status} = response.data;
if (status == 0) {
console.log('--- success')
this.setState((state) => {
const index = state.fileList.indexOf(file);
const newFileList = state.fileList.slice();
newFileList.splice(index, 1);
return {
fileList: newFileList,
};
});
this.cancelAttachment()
}
}
}
})
.catch(function (error) {
console.log(error);
});
})
.catch(function (error) {
console.log(error);
});
}
}
//滚动

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

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

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

Loading…
Cancel
Save