content.component.ts 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. import { Component, OnInit } from '@angular/core';
  2. import { Input, Output, EventEmitter } from '@angular/core';
  3. import { CommonCompModule } from '../../../../../services/common.modules';
  4. import { NzSelectModule } from 'ng-zorro-antd/select';
  5. import { ReactiveFormsModule } from '@angular/forms';
  6. import { NzRadioModule } from 'ng-zorro-antd/radio';
  7. import { NzMessageService } from 'ng-zorro-antd/message';
  8. import { NzGridModule } from 'ng-zorro-antd/grid';
  9. import { NzCheckboxModule } from 'ng-zorro-antd/checkbox';
  10. import { NzTableModule } from 'ng-zorro-antd/table';
  11. import { NzModalService } from 'ng-zorro-antd/modal';
  12. import Parse from 'parse';
  13. // import {
  14. // FormControl,
  15. // FormGroup,
  16. // NonNullableFormBuilder,
  17. // Validators,
  18. // } from '@angular/forms';
  19. import { textbookServer } from '../../../../../services/textbook';
  20. import { CreatedService } from '../../../../../services/created.service'
  21. interface course {
  22. date: Date | any,
  23. wordage: number | any,
  24. num: number | any,
  25. sumNum: number | any,
  26. accolade: string
  27. }
  28. @Component({
  29. selector: 'app-three',
  30. templateUrl: './content.component.html',
  31. styleUrls: ['./content.component.scss'],
  32. standalone: true,
  33. imports: [
  34. CommonCompModule,
  35. ReactiveFormsModule,
  36. NzSelectModule,
  37. NzRadioModule,
  38. NzGridModule,
  39. NzCheckboxModule,
  40. NzTableModule,
  41. ContentComponent
  42. ],
  43. })
  44. export class ContentComponent implements OnInit {
  45. @Input('eduTextbook') eduTextbook: any;
  46. @Input('eduTextbookVolume') eduTextbookVolume: Parse.Object | any;
  47. @Input('maxWidth') maxWidth: number = 0;
  48. @Output() state: EventEmitter<any> = new EventEmitter<any>();
  49. @Output() save: EventEmitter<any> = new EventEmitter<any>();
  50. //申报教材建设历程
  51. courses: Array<course> = [
  52. {
  53. date: '',//出版时间
  54. wordage: '',//字数
  55. num: '',//重印次数
  56. sumNum: '',//本版总印数
  57. accolade: ''//获奖励情况
  58. },
  59. ];
  60. constructor(
  61. public tbookSer: textbookServer,
  62. private modal: NzModalService,
  63. private msg: NzMessageService,
  64. private creatSev: CreatedService
  65. ) { }
  66. ngOnInit() {
  67. this.refersh()
  68. }
  69. ngAfterViewInit(): void {
  70. }
  71. async refersh() {
  72. await this.getEduTextbookVolume()
  73. if (this.eduTextbookVolume?.id) {
  74. this.creatSev.type = this.eduTextbookVolume.get('type')
  75. this.creatSev.typeNumber = this.eduTextbookVolume.get('typeNumber')
  76. this.courses = this.eduTextbookVolume.get('courses') || this.courses
  77. }
  78. }
  79. /**获取扩展分册记录 */
  80. async getEduTextbookVolume() {
  81. let id = this?.eduTextbookVolume?.id || this?.eduTextbookVolume?.objectId;
  82. console.log('传递的分册id' + id)
  83. if (id) {
  84. let query = new Parse.Query('EduTextbookVolume')
  85. this.eduTextbookVolume = await query.get(id)
  86. console.log(this.eduTextbookVolume);
  87. }
  88. }
  89. //添加作者信息
  90. onPush(idx: number) {
  91. this.courses.splice(idx + 1, 0, {
  92. date: '',
  93. wordage: '',
  94. num: '',
  95. sumNum: '',
  96. accolade: ''
  97. });
  98. }
  99. //删除作者信息
  100. onDel(idx: number) {
  101. if (this.courses?.length == 1) return
  102. this.courses.splice(idx, 1);
  103. }
  104. async submitForm(): Promise<boolean> {
  105. let coursesVrifly = !this.courses.some((item) =>
  106. Object.values(item).some((val) => val == '' || val == undefined)
  107. );
  108. this.eduTextbookVolume?.set('courses', this.courses);
  109. await this.eduTextbookVolume?.save();
  110. return coursesVrifly;
  111. }
  112. }