Browse Source

完善文件下载问题

LuChongMei 1 year ago
parent
commit
436dafd193

+ 1 - 1
jp-mobile/pages/fileTransmit/examineFile.vue

@@ -179,7 +179,7 @@
 				this.$refs.uToast.show({
 					...params,
 					complete() {
-						params.url && uni.reLaunch({
+						params.url && uni.redirectTo({
 							url: params.url
 						})
 					}

+ 48 - 0
jp-mobile/pages/fileTransmit/fileCard.vue

@@ -243,8 +243,56 @@
 					uploadPath: result[0],
 					name: param.name
 				}
+				uni.downloadFile({
+					url:param.url,//调接口返回url
+					success:(res)=>{
+						// uni.hideLoading();
+						if(res.statusCode==200){
+							var tempFilePath = res.tempFilePath;
+							this.saveFile(tempFilePath,param.name);
+						}else{
+							uni.showToast({
+								icon:'none',
+								title:'报告下载失败'
+							})
+						}
+					},
+					fail:err=>{
+						uni.hideLoading();
+						uni.showToast({
+							icon:'none',
+							title:'报告下载失败'
+						})
+						reject(err);
+					}
+				})
 				fileService.download(item).then()
 			},
+			saveFile(url,name){//保存到本地
+				try{
+					const fileName = name;
+					//new Blob 实例化文件流
+					//let url = fileData
+					//const url = window.URL.createObjectURL(new Blob([fileData],{type:'application/pdf'}))
+					const link = document.createElement('a');
+					link.style.display = 'none';
+					link.href = url;
+					link.setAttribute('download',fileName);
+					document.body.appendChild(link);
+					link.click();
+					//下载完成移除元素
+					document.body.removeChild(link);
+					//释放掉blob对象
+					window.URL.revokeObjectURL(url)
+					uni.showToast({
+						title:'下载成功'
+					})
+				}catch(error){
+					uni.showToast({
+						title:'下载失败'
+					})
+				}
+			},
 		},
 		props: {
 			isoffice: {

+ 7 - 5
jp-mobile/pages/fileTransmit/statistics.vue

@@ -61,6 +61,7 @@
 					<view class="card_chart">
 						<view class="charts-box_1">
 							<qiun-data-charts type="ring" :opts="opts1" :chartData="chartDataOne" />
+							<!-- <qiun-data-charts type="arcbar" :opts="opts1" :chartData="chartDataOne" /> -->
 						</view>
 					</view>
 				</u-col>
@@ -129,11 +130,10 @@
 					enableScroll: false,
 					legend: {
 						show: true,
-						position: "bottom",
-						float:"left"
+						position: "right"
 					},
 					subtitle: {
-						name: "70%",
+						name: "1",
 						fontSize: 25,
 						color: "#7cb5ec"
 					},
@@ -144,7 +144,7 @@
 							activeRadius: 10,
 							offsetAngle: 0,
 							labelWidth: 15,
-							border: true,
+							border: false,
 							borderWidth: 3,
 							borderColor: "#FFFFFF"
 						}
@@ -202,8 +202,10 @@
 					let res = {
 						series: [{
 							data: [{
+								"name":"已办",
 								"value": 50,
 							}, {
+								"name":"待办",
 								"value": 50,
 							}]
 						}]
@@ -230,7 +232,7 @@
 
 	.charts-box_1 {
 		width: 100%;
-		height: 120px;
+		height: 200px;
 	}
 
 	.card_one {