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

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

@ -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,39 @@ 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) { }
console.log(error); // const url = `/attachments/${file.response ? file.response.id : file.uid}.json`
});
this.setState({
fileListtype:false,
})
} }
onChangeTimepublishs= (date, dateString,key) => { onChangeTimepublishs= (date, dateString,key) => {

@ -132,28 +132,29 @@ 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,
}) })
}
} }
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=()=>{

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

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

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