truthhun 1 year ago
parent 25c5dabe99
commit ff8f42efc6

@ -56,7 +56,6 @@
:headers="{ authorization: `bearer ${token}` }"
:show-file-list="false"
:disabled="loading || !canIUploadDocument"
:on-success="onSuccess"
:auto-upload="false"
:on-change="onChange"
:file-list="fileList"
@ -398,13 +397,15 @@ export default {
return
}
//
this.loading = true
try {
// pending
window.uploadDocumentCancel.map((c) => c())
window.uploadDocumentCancel = []
} catch (error) {}
// TODO:
// TODO:
this.fileList.map((file) => {
console.log(file)
const formData = new FormData()
@ -412,9 +413,17 @@ export default {
const res = uploadDocument(formData)
console.log(res)
})
console.log('end')
}
})
},
cancleUpload() {
this.$refs.upload.abort()
},
onError(err) {
this.loading = false
console.log(err)
},
clearAllFiles() {
if (this.loading) {
return
@ -423,44 +432,6 @@ export default {
this.filesMap = {}
this.$refs.upload.clearFiles()
},
async uploadFile(option) {
const { file, filename } = option
console.log('upload', option, file, filename)
const res = await uploadDocument({
file,
filename,
})
console.log(res)
// if (res.status === 200) {
// this.$refs.upload.onSuccess(res.data, file, this.fileList)
// } else {
// this.$refs.upload.onError(res, file, this.fileList)
// }
this.loading = false
},
onError(err, file, fileList) {
console.log('onError', err, file, fileList)
this.loading = false
try {
const message = JSON.parse(err.message)
this.$message.error(message.error)
} catch (error) {
this.$message.error(err.message)
}
},
// TODO:
onSuccess(res, file, fileList) {
console.log('onSuccess', res, file, fileList)
const length = fileList.length
const successItems = fileList.filter(
(item) => item.response && item.response.code === 200
)
let percentAge = (successItems.length / length) * 100
this.percentAge = parseFloat(percentAge.toFixed(2))
if (percentAge === 100) {
this.createDocuments()
}
},
async createDocuments() {
const createDocumentRequest = {
overwrite: this.document.overwrite,

Loading…
Cancel
Save