textbook-content.component.ts 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
  2. import { CommonCompModule } from '../../../../services/common.modules';
  3. import { NzSelectModule } from 'ng-zorro-antd/select';
  4. import { ReactiveFormsModule } from '@angular/forms';
  5. import { NzRadioModule } from 'ng-zorro-antd/radio';
  6. import { NzMessageService } from 'ng-zorro-antd/message';
  7. import { NzGridModule } from 'ng-zorro-antd/grid';
  8. import { NzCheckboxModule } from 'ng-zorro-antd/checkbox';
  9. import { NzTableModule } from 'ng-zorro-antd/table';
  10. import {
  11. FormControl,
  12. FormGroup,
  13. NonNullableFormBuilder,
  14. Validators,
  15. } from '@angular/forms';
  16. interface course {
  17. date: Date|any,
  18. wordage: number|any,
  19. num: number|any,
  20. sumNum:number|any,
  21. accolade:string
  22. }
  23. @Component({
  24. selector: 'app-textbook-content',
  25. imports: [
  26. CommonCompModule,
  27. ReactiveFormsModule,
  28. NzSelectModule,
  29. NzRadioModule,
  30. NzGridModule,
  31. NzCheckboxModule,
  32. NzTableModule,
  33. ],
  34. standalone: true,
  35. templateUrl: './textbook-content.component.html',
  36. styleUrls: ['./textbook-content.component.scss'],
  37. })
  38. export class TextbookContentComponent implements OnInit {
  39. @Input('editFrom') editFrom: any;
  40. @Input('maxWidth') maxWidth: number = 0;
  41. @Output() next: EventEmitter<any> = new EventEmitter<any>();
  42. @Output() save: EventEmitter<any> = new EventEmitter<any>();
  43. validateForm: FormGroup<{
  44. innovateExplain: FormControl<string>; //申报教材特色及创新
  45. influence: FormControl<string>; //申报教材应用情况及社会影响力
  46. }> = this.fb.group({
  47. innovateExplain: ['', [Validators.required]],
  48. influence: ['', [Validators.required]],
  49. });
  50. //申报教材建设历程
  51. courses: Array<course> = [
  52. {
  53. date: '',//出版时间
  54. wordage: '',//字数
  55. num: '',//重印次数
  56. sumNum:'',//本版总印数
  57. accolade:''//获奖励情况
  58. },
  59. ];
  60. constructor(
  61. private fb: NonNullableFormBuilder,
  62. private msg: NzMessageService
  63. ) { }
  64. ngOnInit() {}
  65. submitForm(event?: string): void {
  66. console.log(this.validateForm.value);
  67. if (this.validateForm.valid) {
  68. console.log(this.validateForm.value);
  69. } else {
  70. Object.values(this.validateForm.controls).forEach((control) => {
  71. if (control.invalid) {
  72. control.markAsDirty();
  73. control.updateValueAndValidity({ onlySelf: true });
  74. }
  75. });
  76. this.msg.warning('请填写完整信息');
  77. }
  78. if (event == 'next') {
  79. this.next.emit();
  80. }
  81. }
  82. changeCode() {}
  83. getCode(e: any) {}
  84. //添加作者信息
  85. onPush(idx: number) {
  86. this.courses.splice(idx+1, 0, {
  87. date: '',
  88. wordage: '',
  89. num: '',
  90. sumNum:'',
  91. accolade:''
  92. });
  93. }
  94. //删除作者信息
  95. onDel(idx: number) {
  96. this.courses.splice(idx, 1);
  97. }
  98. }