dw 2 週之前
父節點
當前提交
95a085afec
共有 5 個文件被更改,包括 196 次插入151 次删除
  1. 1
    0
      config/dev.env.js
  2. 1
    1
      config/prod.env.js
  3. 57
    44
      src/view/record/changerecord.vue
  4. 68
    55
      src/view/record/inrecord.vue
  5. 69
    51
      src/view/record/outrecord.vue

+ 1
- 0
config/dev.env.js 查看文件

@@ -6,5 +6,6 @@ module.exports = merge(prodEnv, {
6 6
   NODE_ENV: '"development"',
7 7
   // BASE_API: '"http://120.224.213.150/thware_mj/"'
8 8
 	 BASE_API: '"http://localhost:8080/thware/"'
9
+  // BASE_API: '"http://localhost:8080/thware_war/"'
9 10
 	// BASE_API: '"http://47.104.245.159:8081/thware/"'
10 11
 })

+ 1
- 1
config/prod.env.js 查看文件

@@ -2,6 +2,6 @@
2 2
 module.exports = {
3 3
   NODE_ENV: '"production"',
4 4
   BASE_API: '"http://120.224.213.150/thware_mj/"'
5
-	// BASE_API: '"http://60.205.9.174:8081/thware/"'
5
+	//  BASE_API: '"http://60.205.9.174:8080/thware_mj/"'
6 6
 	// BASE_API: '"http://39.105.120.43:8080/thware/"'
7 7
 }

+ 57
- 44
src/view/record/changerecord.vue 查看文件

@@ -265,55 +265,63 @@ childUrl:'WareChangeRecord/queryTotal.do',
265 265
 
266 266
 			},
267 267
 			// 导出Excel
268
-			handleExport() {
268
+			async handleExport() {
269 269
 				// 显示加载动画
270 270
 				this.exportLoading = true;
271
+				try {
272
+					var baseUrl = this.$store.state.app.serverName;
273
+					var url = baseUrl + 'WareChangeRecord/exportExcel.do';
274
+					let userId = localStorage.getItem("userId");
275
+					let belongId = localStorage.getItem("belongId");
276
+					let token = localStorage.getItem("token");
271 277
 
272
-				var baseUrl = this.$store.state.app.serverName;
273
-				var url = baseUrl + 'WareChangeRecord/exportExcel.do';
274
-				let userId = localStorage.getItem("userId");
275
-				let belongId = localStorage.getItem("belongId");
276
-				let token = localStorage.getItem("token");
278
+					var param = {
279
+						wareName: this.query.wareName,
280
+						stackName: this.query.stackName,
281
+						model: this.query.model,
282
+						materialName: this.query.materialName,
283
+						standard: this.query.standard,
284
+						customerName: this.query.customerName,
285
+						plateNo: this.query.plateNo,
286
+						pFromDate: (!this.query.RecordDate[0]) ? "1970-01-01 00:00:00" : this.query.RecordDate[0].Format("yyyy-MM-dd HH:mm:ss"),
287
+						pToDate: (!this.query.RecordDate[1]) ? new Date().Format("yyyy-MM-dd HH:mm:ss") : this.query.RecordDate[1].Format("yyyy-MM-dd HH:mm:ss"),
288
+						userId: userId,
289
+						belongId: belongId
290
+					};
277 291
 
278
-				var param = {
279
-					wareName: this.query.wareName,
280
-					stackName: this.query.stackName,
281
-					model: this.query.model,
282
-					materialName: this.query.materialName,
283
-					standard: this.query.standard,
284
-					customerName: this.query.customerName,
285
-					plateNo: this.query.plateNo,
286
-					pFromDate: (!this.query.RecordDate[0]) ? "1970-01-01 00:00:00" : this.query.RecordDate[0].Format("yyyy-MM-dd HH:mm:ss"),
287
-					pToDate: (!this.query.RecordDate[1]) ? new Date().Format("yyyy-MM-dd HH:mm:ss") : this.query.RecordDate[1].Format("yyyy-MM-dd HH:mm:ss"),
288
-					userId: userId,
289
-					belongId: belongId
290
-				};
292
+					// POST请求,携带token鉴权头,5分钟超时(大数据量导出需要更长时间)
293
+					const controller = new AbortController();
294
+					const timeoutId = setTimeout(() => controller.abort(), 300000); // 5分钟超时
291 295
 
292
-				var params = [];
293
-				for (var key in param) {
294
-					params.push(key + '=' + encodeURIComponent(param[key]));
295
-				}
296
-				var fullUrl = url + (params.length > 0 ? '?' + params.join('&') : '');
296
+					// 使用 fetch + blob 方式,POST方法下载完成后关闭 loading
297
+					const response = await fetch(url, {
298
+						method: 'POST',
299
+						headers: {
300
+							'Content-Type': 'application/x-www-form-urlencoded',
301
+							'token': token,
302
+							'userId': userId,
303
+							'belongId': belongId
304
+						},
305
+						body: new URLSearchParams(param),
306
+						signal: controller.signal
307
+					});
308
+					clearTimeout(timeoutId);
297 309
 
298
-				// 使用 fetch + blob 方式,下载完成后关闭 loading
299
-				fetch(fullUrl, {
300
-					headers: {
301
-						'token': token,
302
-						'userId': userId,
303
-						'belongId': belongId
304
-					}
305
-				})
306
-				.then(response => {
307 310
 					if (!response.ok) {
308
-						throw new Error('网络请求失败');
311
+						throw new Error('网络请求失败,状态码:' + response.status);
312
+					}
313
+					const blob = await response.blob();
314
+
315
+					// 判断后端是否返回错误提示(非Excel二进制)
316
+					if (blob.type.includes('text')) {
317
+						const text = await blob.text();
318
+						throw new Error(text || '导出数据查询失败,请缩小筛选时间范围');
309 319
 					}
310
-					return response.blob();
311
-				})
312
-				.then(blob => {
320
+
313 321
 					// 创建下载链接
314
-					const url = window.URL.createObjectURL(blob);
322
+					const blobUrl = window.URL.createObjectURL(blob);
315 323
 					const link = document.createElement('a');
316
-					link.href = url;
324
+					link.href = blobUrl;
317 325
 					link.download = '转移记录_' + new Date().toISOString().slice(0, 10) + '.xlsx';
318 326
 					document.body.appendChild(link);
319 327
 					link.click();
@@ -322,14 +330,19 @@ childUrl:'WareChangeRecord/queryTotal.do',
322 330
 					// 清理
323 331
 					setTimeout(() => {
324 332
 						document.body.removeChild(link);
325
-						window.URL.revokeObjectURL(url);
333
+						window.URL.revokeObjectURL(blobUrl);
326 334
 					}, 100);
327
-				})
328
-				.catch(error => {
335
+					this.$message.success('导出成功');
336
+				} catch (error) {
329 337
 					console.error('导出失败:', error);
330
-					this.$message.error('导出失败:' + error.message);
338
+					// 超时单独提示
339
+					if (error.name === 'AbortError') {
340
+						this.$message.error('导出超时(5分钟):数据量过大,请缩短查询时间区间或分批导出');
341
+					} else {
342
+						this.$message.error('导出失败:' + error.message);
343
+					}
331 344
 					this.exportLoading = false;
332
-				});
345
+				}
333 346
 			}
334 347
 		},
335 348
 	}

+ 68
- 55
src/view/record/inrecord.vue 查看文件

@@ -462,77 +462,90 @@
462 462
 				const replaceResult = this.query.ordNo.replace(/[;,,;\s\r\n]+/g, ",").split(",");
463 463
 				this.query.ordNo = replaceResult;
464 464
 			},
465
-			handleExport() {
466
-        // 显示加载动画
465
+      async handleExport() {
467 466
         this.exportLoading = true;
467
+        try {
468
+          const baseUrl = this.$store.state.app.serverName;
469
+          const url = baseUrl + 'WareStore/inExportStoreExcel.do';
470
+          const userId = localStorage.getItem("userId");
471
+          const belongId = localStorage.getItem("belongId");
472
+          const token = localStorage.getItem("token");
473
+          console.log(userId, belongId, token);
468 474
 
469
-        var baseUrl = this.$store.state.app.serverName;
470
-        var url = baseUrl + 'WareStore/inExportStoreExcel.do';
471
-        let userId = localStorage.getItem("userId");
472
-        let belongId = localStorage.getItem("belongId");
473
-        let token = localStorage.getItem("token");
474
-        console.log(userId, belongId, token);
475
-				var param = {
476
-					page: -1,
477
-					rows: -1,
478
-					wareName: this.query.wareName,
479
-					stackName: this.query.stackName,
480
-					model: this.query.model,
481
-					materialName: this.query.materialName,
482
-					standard: this.query.standard,
483
-					customerName: this.query.customerName,
484
-					plateNo: this.query.plateNo.length == 0 ? '' : this.query.plateNo.join(','),
485
-					fromDate:(!this.query.inRecordDate[0]) ? "1970-01-01 00:00:00" : this.query.inRecordDate[0].Format("yyyy-MM-dd HH:mm:ss"),		//date类型
486
-					toDate  :(!this.query.inRecordDate[1]) ? new Date().Format("yyyy-MM-dd HH:mm:ss") :this.query.inRecordDate[1].Format("yyyy-MM-dd HH:mm:ss"),
487
-					ordNo: this.query.ordNo == 0 ? '' : this.query.ordNo.join(','),
488
-					carNo : this.query.carNo,
489
-					tallyPeople:this.query.tallyPeople,
490
-					fkComponyName:this.query.fkComponyName,
491
-					remark1:this.query.remark1,
492
-          contractNo:this.query.contractNo.length == 0 ? '' : this.query.contractNo.join(','),
493
-          userId: userId,
494
-          belongId: belongId
495
-				}
475
+          // 组装导出参数(直接放body,不再拼接URL)
476
+          const param = {
477
+            page: -1,
478
+            rows: -1,
479
+            wareName: this.query.wareName,
480
+            stackName: this.query.stackName,
481
+            model: this.query.model,
482
+            materialName: this.query.materialName,
483
+            standard: this.query.standard,
484
+            customerName: this.query.customerName,
485
+            plateNo: this.query.plateNo.length == 0 ? '' : this.query.plateNo.join(','),
486
+            fromDate: (!this.query.inRecordDate[0]) ? "1970-01-01 00:00:00" : this.query.inRecordDate[0].Format("yyyy-MM-dd HH:mm:ss"),
487
+            toDate: (!this.query.inRecordDate[1]) ? new Date().Format("yyyy-MM-dd HH:mm:ss") : this.query.inRecordDate[1].Format("yyyy-MM-dd HH:mm:ss"),
488
+            ordNo: this.query.ordNo == 0 ? '' : this.query.ordNo.join(','),
489
+            carNo: this.query.carNo,
490
+            tallyPeople: this.query.tallyPeople,
491
+            fkComponyName: this.query.fkComponyName,
492
+            remark1: this.query.remark1,
493
+            contractNo: this.query.contractNo.length == 0 ? '' : this.query.contractNo.join(','),
494
+            userId: userId,
495
+            belongId: belongId
496
+          };
496 497
 
497
-        var params = [];
498
-        // 去掉 if(param\[key\]) 判断,空字符串也要传递给后端
499
-        for (var key in param) {
500
-          params.push(key + '=' + encodeURIComponent(param[key]));
501
-        }
502
-        var fullUrl = url + (params.length > 0 ? '?' + params.join('&') : '');
498
+          // POST请求,携带token鉴权头,60秒超时
499
+          const controller = new AbortController();
500
+          const timeoutId = setTimeout(() => controller.abort(), 600000); // 10分钟超时
501
+
502
+          const response = await fetch(url, {
503
+            method: 'POST',
504
+            headers: {
505
+              'Content-Type': 'application/x-www-form-urlencoded',
506
+              'token': token // 带上登录凭证,和列表查询接口保持一致
507
+            },
508
+            body: new URLSearchParams(param), // 参数放入请求体,不再拼URL
509
+            signal: controller.signal
510
+          });
511
+          clearTimeout(timeoutId);
503 512
 
504
-        // 使用 fetch + blob 方式,下载完成后关闭 loading
505
-        fetch(fullUrl)
506
-        .then(response => {
507 513
           if (!response.ok) {
508
-            throw new Error('网络请求失败');
514
+            throw new Error(`服务异常,状态码:${response.status}`);
515
+          }
516
+          const blob = await response.blob();
517
+          // 判断后端是否返回错误提示(非Excel二进制)
518
+          if (blob.type.includes('text')) {
519
+            const text = await blob.text();
520
+            throw new Error(text || '导出数据查询失败,请缩小筛选时间范围');
509 521
           }
510
-          return response.blob();
511
-        })
512
-        .then(blob => {
513
-          // 创建下载链接
514
-          const url = window.URL.createObjectURL(blob);
522
+
523
+          // 下载文件逻辑不变
524
+          const blobUrl = window.URL.createObjectURL(blob);
515 525
           const link = document.createElement('a');
516
-          link.href = url;
526
+          link.href = blobUrl;
517 527
           link.download = '入库记录_' + new Date().toISOString().slice(0, 10) + '.xlsx';
518 528
           document.body.appendChild(link);
519 529
           link.click();
520
-          // 浏览器开始下载后立即关闭 loading
521
-          this.exportLoading = false;
522
-          // 清理
523 530
           setTimeout(() => {
524 531
             document.body.removeChild(link);
525
-            window.URL.revokeObjectURL(url);
532
+            window.URL.revokeObjectURL(blobUrl);
526 533
           }, 100);
527
-        })
528
-        .catch(error => {
534
+          this.$message.success('导出成功');
535
+        } catch (error) {
529 536
           console.error('导出失败:', error);
530
-          this.$message.error('导出失败:' + error.message);
537
+          // 超时单独提示
538
+          if (error.name === 'AbortError') {
539
+            this.$message.error('导出超时:数据量过大,请缩短查询时间区间');
540
+          } else {
541
+            this.$message.error('导出失败:' + error.message);
542
+          }
543
+        } finally {
531 544
           this.exportLoading = false;
532
-        });
545
+        }
546
+      },
533 547
 
534
-			},
535
-			exportExcel(imptData) {
548
+      exportExcel(imptData) {
536 549
 				// alert(JSON.stringify(imptData))
537 550
 				const header = ["仓库名称"
538 551
 								,"垛位"

+ 69
- 51
src/view/record/outrecord.vue 查看文件

@@ -764,7 +764,7 @@
764 764
 					});
765 765
 					return;
766 766
 				}
767
-				window.open(this.serverName + 'ureport/preview?_u=file:out.ureport.xml&id=' + distId +
767
+				window.open(this.serverName + 'ureport/preview?_u=file:out_new.ureport.xml&id=' + distId +
768 768
 					'&time=' + this.time)
769 769
 
770 770
 			},
@@ -816,72 +816,90 @@
816 816
 				this.time = year + '-' + month + '-' + day + ' ' + hour + ':' + minute + ':' + second
817 817
 
818 818
 			},
819
-			handleExport() {
819
+    async handleExport() {
820 820
         // 显示Loading遮罩,禁止用户操作
821 821
         this.exportLoading = true;
822
+        try {
823
+          const baseUrl = this.$store.state.app.serverName;
824
+          const url = baseUrl + 'WareStore/outExportStoreExcel.do';
825
+          const userId = localStorage.getItem("userId");
826
+          const belongId = localStorage.getItem("belongId");
827
+          const token = localStorage.getItem("token");
828
+          console.log(userId, belongId, token);
822 829
 
823
-        var baseUrl = this.$store.state.app.serverName;
824
-				var url = baseUrl + 'WareStore/outExportStoreExcel.do';
825
-        let userId = localStorage.getItem("userId");
826
-        let belongId = localStorage.getItem("belongId");
827
-        let token = localStorage.getItem("token");
828
-				var param = {
829
-					page: -1,
830
-					rows: -1,
831
-					wareName: this.query.wareName,
832
-					stackName: this.query.stackName,
833
-					model: this.query.model,
834
-					materialName: this.query.materialName,
835
-					standard: this.query.standard,
836
-					customerName: this.query.customerName,
837
-					plateNo: this.query.plateNo.length == 0 ? '' : this.query.plateNo.join(','),
838
-					pFromDate:(!this.query.RecordDate[0]) ? "1970-01-01 00:00:00" : this.query.RecordDate[0].Format("yyyy-MM-dd HH:mm:ss"),		//date类型
839
-					pToDate  :(!this.query.RecordDate[1]) ? new Date().Format("yyyy-MM-dd HH:mm:ss") :this.query.RecordDate[1].Format("yyyy-MM-dd HH:mm:ss"),
840
-					carNo:this.query.carNo,
841
-					tallyPeople:this.query.tallyPeople,
842
-					ordNo: this.query.ordNo == 0 ? '' : this.query.ordNo.join(','),
843
-					fkComponyName:this.query.fkComponyName,
844
-					remark1:this.query.remark1,
845
-          contractNo:this.query.contractNo.length == 0 ? '' : this.query.contractNo.join(','),
846
-          userId: userId,
847
-          belongId: belongId
848
-				}
830
+          // 组装导出参数(直接放body,不再拼接URL)
831
+          const param = {
832
+            page: -1,
833
+            rows: -1,
834
+            wareName: this.query.wareName,
835
+            stackName: this.query.stackName,
836
+            model: this.query.model,
837
+            materialName: this.query.materialName,
838
+            standard: this.query.standard,
839
+            customerName: this.query.customerName,
840
+            plateNo: this.query.plateNo.length == 0 ? '' : this.query.plateNo.join(','),
841
+            pFromDate: (!this.query.RecordDate[0]) ? "1970-01-01 00:00:00" : this.query.RecordDate[0].Format("yyyy-MM-dd HH:mm:ss"),
842
+            pToDate: (!this.query.RecordDate[1]) ? new Date().Format("yyyy-MM-dd HH:mm:ss") : this.query.RecordDate[1].Format("yyyy-MM-dd HH:mm:ss"),
843
+            carNo: this.query.carNo,
844
+            tallyPeople: this.query.tallyPeople,
845
+            ordNo: this.query.ordNo == 0 ? '' : this.query.ordNo.join(','),
846
+            fkComponyName: this.query.fkComponyName,
847
+            remark1: this.query.remark1,
848
+            contractNo: this.query.contractNo.length == 0 ? '' : this.query.contractNo.join(','),
849
+            userId: userId,
850
+            belongId: belongId
851
+          };
849 852
 
850
-        var params = [];
851
-        for (var key in param) {
852
-          params.push(key + '=' + encodeURIComponent(param[key]));
853
-        }
854
-        var fullUrl = url + (params.length > 0 ? '?' + params.join('&') : '');
853
+          // POST请求,携带token鉴权头,5分钟超时(大数据量导出需要更长时间)
854
+          const controller = new AbortController();
855
+          const timeoutId = setTimeout(() => controller.abort(), 600000); // 5分钟超时
856
+
857
+          const response = await fetch(url, {
858
+            method: 'POST',
859
+            headers: {
860
+              'Content-Type': 'application/x-www-form-urlencoded',
861
+              'token': token // 带上登录凭证,和列表查询接口保持一致
862
+            },
863
+            body: new URLSearchParams(param), // 参数放入请求体,不再拼URL
864
+            signal: controller.signal
865
+          });
866
+          clearTimeout(timeoutId);
855 867
 
856
-        // 使用 fetch + blob 方式,下载完成后关闭 loading
857
-        fetch(fullUrl)
858
-        .then(response => {
859 868
           if (!response.ok) {
860
-            throw new Error('网络请求失败');
869
+            throw new Error(`服务异常,状态码:${response.status}`);
870
+          }
871
+          const blob = await response.blob();
872
+          // 判断后端是否返回错误提示(非Excel二进制)
873
+          if (blob.type.includes('text')) {
874
+            const text = await blob.text();
875
+            throw new Error(text || '导出数据查询失败,请缩小筛选时间范围');
861 876
           }
862
-          return response.blob();
863
-        })
864
-        .then(blob => {
865
-          // 创建下载链接
866
-          const url = window.URL.createObjectURL(blob);
877
+
878
+          // 下载文件逻辑不变
879
+          const blobUrl = window.URL.createObjectURL(blob);
867 880
           const link = document.createElement('a');
868
-          link.href = url;
881
+          link.href = blobUrl;
869 882
           link.download = '出库记录_' + new Date().toISOString().slice(0, 10) + '.xlsx';
870 883
           document.body.appendChild(link);
871 884
           link.click();
872
-          // 浏览器开始下载后立即关闭 loading
873
-          this.exportLoading = false;
874
-          // 清理
875 885
           setTimeout(() => {
876 886
             document.body.removeChild(link);
877
-            window.URL.revokeObjectURL(url);
887
+            window.URL.revokeObjectURL(blobUrl);
878 888
           }, 100);
879
-        })
880
-        .catch(error => {
889
+          this.$message.success('导出成功');
890
+        }
891
+        catch (error) {
881 892
           console.error('导出失败:', error);
882
-          this.$message.error('导出失败:' + error.message);
893
+          // 超时单独提示
894
+          if (error.name === 'AbortError') {
895
+            this.$message.error('导出超时(5分钟):数据量过大,请缩短查询时间区间或分批导出');
896
+          } else {
897
+            this.$message.error('导出失败:' + error.message);
898
+          }
899
+        }
900
+        finally {
883 901
           this.exportLoading = false;
884
-        });
902
+        }
885 903
 
886 904
 		},
887 905
 			exportExcel(imptData) {

Loading…
取消
儲存