|
|
@@ -30,6 +30,9 @@ function uploaditem(item) {
|
|
|
uuid: data.data.id
|
|
|
}
|
|
|
resolve(obj)
|
|
|
+ },
|
|
|
+ fail: () => {
|
|
|
+ reject()
|
|
|
}
|
|
|
})
|
|
|
})
|
|
|
@@ -37,6 +40,11 @@ function uploaditem(item) {
|
|
|
|
|
|
function selectUpload(file) {
|
|
|
return new Promise((resolve, reject) => {
|
|
|
+ uni.showLoading({
|
|
|
+ title: '上传中',
|
|
|
+ mask: true
|
|
|
+ })
|
|
|
+ let that = this
|
|
|
let list = []
|
|
|
//读取文件大小
|
|
|
var fileSize = file.size;
|
|
|
@@ -49,13 +57,18 @@ function selectUpload(file) {
|
|
|
});
|
|
|
return
|
|
|
}
|
|
|
- let that = this
|
|
|
let eList = []
|
|
|
file.tempFilePaths.forEach(item => {
|
|
|
eList.push(uploaditem(item))
|
|
|
})
|
|
|
Promise.all(eList).then((res3) => {
|
|
|
+ uni.hideLoading()
|
|
|
resolve(res3)
|
|
|
+ }).catch(error => {
|
|
|
+ setTimeout(() => {
|
|
|
+ uni.hideLoading()
|
|
|
+ }, 1000)
|
|
|
+ reject()
|
|
|
})
|
|
|
|
|
|
})
|
|
|
@@ -85,7 +98,38 @@ function getFilesList(ids, that = this) {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+function download(id, item, that = this) {
|
|
|
+ uni.showLoading({
|
|
|
+ title: '下载中',
|
|
|
+ mask: true
|
|
|
+ })
|
|
|
+ let requestData = {
|
|
|
+ attachmentId: id
|
|
|
+ }
|
|
|
+ that.$http.get(`/ibps/platform/v3/file/download?attachmentId=${id}`, {
|
|
|
+ responseType: 'arraybuffer'
|
|
|
+ }).then(res => {
|
|
|
+ const blob = new Blob([
|
|
|
+ res.data
|
|
|
+ ], {
|
|
|
+ type: 'application/octet-stream'
|
|
|
+ })
|
|
|
+ const url = window.URL.createObjectURL(blob)
|
|
|
+ const link = document.createElement('a')
|
|
|
+ link.style.display = 'none'
|
|
|
+ link.href = url
|
|
|
+ link.setAttribute('download', item)
|
|
|
+ document.body.appendChild(link)
|
|
|
+ link.click()
|
|
|
+ window.URL.revokeObjectURL(link.href)
|
|
|
+ document.body.removeChild(link)
|
|
|
+ uni.hideLoading()
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
export default {
|
|
|
+ download,
|
|
|
getFilesList,
|
|
|
selectUpload
|
|
|
}
|