linweizeng 2 лет назад
Родитель
Сommit
f76de542f8

+ 45 - 1
common/util/upload.js

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

+ 2 - 27
pages/communication/communication.vue

@@ -83,7 +83,7 @@
 			<uni-section title="上传附件" type="line">
 				<view style="padding: 10rpx;">
 					<view class="example-body" v-if="(typeValue == 3 || typeValue == 4)">
-						<uni-file-picker res="files" :listShow="false" limit="5" file-mediatype="all" @select="select" @progress="progress" @success="success" @fail="fail" @delete="deleteMe" :auto-upload="false" ref="uploadMe">
+						<uni-file-picker res="files" :listShow="false" limit="100" file-mediatype="all" @select="select" @progress="progress" @success="success" @fail="fail" @delete="deleteMe" :auto-upload="false" ref="uploadMe">
 						</uni-file-picker>
 					</view>
 					<view>
@@ -657,32 +657,7 @@
 				})
 			},
 			uploadClick(id, item) {
-				uni.showLoading({
-					title: '下载中',
-					mask: true
-				})
-				let requestData = {
-					attachmentId: id
-				}
-				this.$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()
-				})
+				this.$uploades.download(id, item, this)
 			},
 			getBianZhiRen(id, callback) {
 				let sql = `select * from ibps_party_employee where ID_ = '${id}'`

+ 3 - 28
pages/jiance/tousu.vue

@@ -67,7 +67,7 @@
 
 		<uni-section title="上传附件" type="line">
 			<view class="example-body" v-if="id == ''">
-				<uni-file-picker limit="5" file-mediatype="all" @select="select" @progress="progress" @success="success" @fail="fail" @delete="deleteMe" :auto-upload="false" ref="uploadMe"></uni-file-picker>
+				<uni-file-picker limit="100" file-mediatype="all" @select="select" @progress="progress" @success="success" @fail="fail" @delete="deleteMe" :auto-upload="false" ref="uploadMe"></uni-file-picker>
 			</view>
 			<view class="u-p-b-15">
 				<view v-for="(item,index) in fuJianShangChuanArray" :key="index" style="margin: 0 10rpx;">
@@ -619,33 +619,8 @@
 			close() {
 				this.popupShow = false
 			},
-			uploadClick(id, item, type) {
-				uni.showLoading({
-					title: '下载中',
-					mask: true
-				})
-				let requestData = {
-					attachmentId: id
-				}
-				this.$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 + '.' + type)
-					document.body.appendChild(link)
-					link.click()
-					window.URL.revokeObjectURL(link.href)
-					document.body.removeChild(link)
-					uni.hideLoading()
-				})
+			uploadClick(id, item) {
+				this.$uploades.download(id, item, this)
 			}
 		}
 	}

+ 3 - 3
uni_modules/uni-file-picker/components/uni-file-picker/uni-file-picker.vue

@@ -229,9 +229,9 @@
 				if (!this.limit) {
 					return 1
 				}
-				if (this.limit >= 9) {
-					return 9
-				}
+				// if (this.limit >= 9) {
+				// 	return 9
+				// }
 				return this.limit
 			}
 		},