export-file.component.ts 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import { Component, EventEmitter, OnInit, Output } from '@angular/core';
  2. import { Router, ActivatedRoute } from '@angular/router';
  3. import { CommonCompModule } from '../../../../services/common.modules';
  4. import Parse from 'parse';
  5. @Component({
  6. selector: 'app-export-file',
  7. templateUrl: './export-file.component.html',
  8. styleUrls: ['./export-file.component.scss'],
  9. imports: [CommonCompModule],
  10. standalone: true,
  11. })
  12. export class ExportFileComponent implements OnInit {
  13. @Output() change: EventEmitter<any> = new EventEmitter<any>();
  14. starCount: number = 0;
  15. otherCount: number = 0;
  16. allCount: number = 0;
  17. tbookId: any;
  18. constructor(private router: Router, private activeRoute: ActivatedRoute) {}
  19. ngOnInit() {
  20. this.activeRoute.paramMap.subscribe(async (params) => {
  21. let id = params.get('id');
  22. this.tbookId = id;
  23. // let query = new Parse.Query('EduProcess');
  24. // query.include('branch', 'department');
  25. // query.equalTo('objectId', id);
  26. // this.eduProcess = await query.first();
  27. console.log(id);
  28. let query = new Parse.Query('EduTextbook');
  29. query.notEqualTo('isDeleted', true);
  30. query.equalTo('recommend', true);
  31. query.equalTo('eduProcess', id);
  32. this.allCount = await query.count();
  33. query.containedIn('approval', [
  34. '首届全国教材建设奖优秀教材(高等教育类)教材',
  35. '否',
  36. ]);
  37. this.otherCount = await query.count();
  38. });
  39. }
  40. close() {
  41. history.back();
  42. }
  43. next() {
  44. this.change.emit('next');
  45. }
  46. onDownload() {
  47. Parse.Cloud.run('tbookExportReport', { processId: this.tbookId }).then(
  48. (data) => {
  49. console.log(data);
  50. let url = data.zipUrl;
  51. const a = document.createElement('a'); // 创建一个&lt;a&gt;元素
  52. a.href = url; // 设置链接的href属性为要下载的文件的URL
  53. a.download = '报送流程'; // 设置下载文件的名称
  54. document.body.appendChild(a); // 将&lt;a&gt;元素添加到文档中
  55. a.click(); // 模拟点击&lt;a&gt;元素
  56. document.body.removeChild(a); // 下载后移除&lt;a&gt;元素
  57. }
  58. );
  59. }
  60. }