Parcourir la source

Merge branch 'master' of http://git.fmode.cn:3000/bin/edu-textbook

cehn il y a 7 mois
Parent
commit
61d7c79a4b

+ 57 - 0
projects/textbook/src/modules/nav-author/components/create/content/content.component.html

@@ -0,0 +1,57 @@
+  <div class="author-content">
+    <nz-table #basicTable [nzData]="courses" [nzScroll]="{ x: (maxWidth || '1200') + 'px' }">
+      <thead>
+        <tr>
+          <th nzWidth="80px" nzLeft nzAlign="right">版次</th>
+          <th nzWidth="120px">出版时间</th>
+          <th nzWidth="100px">字数</th>
+          <th nzWidth="100px">重印次数</th>
+          <th nzWidth="100px">本版总印数</th>
+          <th nzWidth="200px">获奖励情况</th>
+          <th nzWidth="80px" nzRight>操作</th>
+        </tr>
+      </thead>
+      <tbody>
+        @for (data of courses; track $index) {
+        <tr>
+          <td nzLeft nzAlign="right">{{ $index + 1 }}</td>
+          <td>
+            <nz-date-picker nzMode="month" [ngModelOptions]="{ standalone: true }"
+              [(ngModel)]="data.date"></nz-date-picker>
+          </td>
+          <td>
+            <nz-input-group style="width: 100%" [nzSuffix]="suffixTemplateInfo">
+              <input type="number" [(ngModel)]="data.wordage" nz-input placeholder="请输入字数"
+                [ngModelOptions]="{ standalone: true }" />
+            </nz-input-group>
+            <ng-template #suffixTemplateInfo>万</ng-template>
+          </td>
+          <td>
+            <nz-input-group style="width: 100%" [nzSuffix]="suffixTemplateInfo2">
+              <input type="number" [(ngModel)]="data.num" nz-input placeholder="请输入重印次数"
+                [ngModelOptions]="{ standalone: true }" />
+            </nz-input-group>
+            <ng-template #suffixTemplateInfo2>次</ng-template>
+          </td>
+          <td>
+            <nz-input-group style="width: 100%" [nzSuffix]="suffixTemplateInfo">
+              <input type="number" [(ngModel)]="data.sumNum" nz-input placeholder="请输入本版总印数"
+                [ngModelOptions]="{ standalone: true }" />
+            </nz-input-group>
+            <ng-template #suffixTemplateInfo>万</ng-template>
+          </td>
+          <td>
+            <input nz-input type="text" placeholder="请输入所获奖项" [ngModelOptions]="{ standalone: true }"
+              [(ngModel)]="data.accolade" nzStatus="" />
+          </td>
+          <td nzRight>
+            <a (click)="onPush($index)"><span nz-icon style="font-size: 20px; margin-right: 10px" nzType="plus-circle"
+                nzTheme="outline"></span></a>
+            <a (click)="onDel($index)"><span nz-icon style="font-size: 20px" nzType="delete"
+                nzTheme="outline"></span></a>
+          </td>
+        </tr>
+        }
+      </tbody>
+    </nz-table>
+  </div>

+ 21 - 0
projects/textbook/src/modules/nav-author/components/create/content/content.component.scss

@@ -0,0 +1,21 @@
+.author-content{
+    a{
+      color:#756B6D;
+    }
+    .nav{
+      font-family: PingFang SC;
+      font-size: 20px;
+      font-weight: 500;
+      line-height: 28px;
+      text-align: left;
+      margin-bottom: 20px;
+    }
+    .title{
+      font-family: PingFang SC;
+      font-size: 16px;
+      font-weight: 500;
+      line-height: 22px;
+      text-align: left;
+      margin: 10px 0;
+    }
+  }

+ 24 - 0
projects/textbook/src/modules/nav-author/components/create/content/content.component.spec.ts

@@ -0,0 +1,24 @@
+import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
+import { IonicModule } from '@ionic/angular';
+
+import { ContentComponent } from './content.component';
+
+describe('ContentComponent', () => {
+  let component: ContentComponent;
+  let fixture: ComponentFixture<ContentComponent>;
+
+  beforeEach(waitForAsync(() => {
+    TestBed.configureTestingModule({
+      declarations: [ ContentComponent ],
+      imports: [IonicModule.forRoot()]
+    }).compileComponents();
+
+    fixture = TestBed.createComponent(ContentComponent);
+    component = fixture.componentInstance;
+    fixture.detectChanges();
+  }));
+
+  it('should create', () => {
+    expect(component).toBeTruthy();
+  });
+});

+ 145 - 0
projects/textbook/src/modules/nav-author/components/create/content/content.component.ts

@@ -0,0 +1,145 @@
+import { Component, OnInit } from '@angular/core';
+
+
+import { Input, Output, EventEmitter } from '@angular/core';
+import { CommonCompModule } from '../../../../../services/common.modules';
+import { NzSelectModule } from 'ng-zorro-antd/select';
+import { ReactiveFormsModule } from '@angular/forms';
+import { NzRadioModule } from 'ng-zorro-antd/radio';
+import { NzMessageService } from 'ng-zorro-antd/message';
+import { NzGridModule } from 'ng-zorro-antd/grid';
+import { NzCheckboxModule } from 'ng-zorro-antd/checkbox';
+import { NzTableModule } from 'ng-zorro-antd/table';
+import { NzModalService } from 'ng-zorro-antd/modal';
+import Parse from 'parse';
+import {
+  FormControl,
+  FormGroup,
+  NonNullableFormBuilder,
+  Validators,
+} from '@angular/forms';
+import { textbookServer } from '../../../../../services/textbook';
+import { CreatedService } from '../../../../../services/created.service'
+
+
+interface course {
+  date: Date | any,
+  wordage: number | any,
+  num: number | any,
+  sumNum: number | any,
+  accolade: string
+}
+
+
+@Component({
+  selector: 'app-three',
+  templateUrl: './content.component.html',
+  styleUrls: ['./content.component.scss'],
+  standalone: true,
+  imports: [
+    CommonCompModule,
+    ReactiveFormsModule,
+    NzSelectModule,
+    NzRadioModule,
+    NzGridModule,
+    NzCheckboxModule,
+    NzTableModule,
+    ContentComponent
+  ],
+})
+export class ContentComponent implements OnInit {
+
+  @Input('eduTextbookVolumeId') eduTextbookVolumeId: any;
+
+
+  @Input('eduTextbook') eduTextbook: any;
+  @Input('maxWidth') maxWidth: number = 0;
+  @Output() state: EventEmitter<any> = new EventEmitter<any>();
+  @Output() save: EventEmitter<any> = new EventEmitter<any>();
+  validateForm: FormGroup<{
+  }> = this.fb.group({
+  });
+  //申报教材建设历程
+  courses: Array<course> = [
+    {
+      date: '',//出版时间
+      wordage: '',//字数
+      num: '',//重印次数
+      sumNum: '',//本版总印数
+      accolade: ''//获奖励情况
+    },
+  ];
+  constructor(
+    public tbookSer: textbookServer,
+    private fb: NonNullableFormBuilder,
+    private modal: NzModalService,
+    private msg: NzMessageService,
+    private creatSev: CreatedService
+  ) { }
+
+
+
+  /**分册记录Parse */
+  eduTextbookVolume: Parse.Object | any
+  /**获取扩展分册记录 */
+  async getEduTextbookVolume() {
+    console.log('传递的分册id' + this.eduTextbookVolumeId)
+    if (this.eduTextbookVolumeId) {
+      let query = new Parse.Query('EduTextbookVolume')
+      this.eduTextbookVolume = await query.get(this.eduTextbookVolumeId)
+      console.log(this.eduTextbookVolume);
+    } else {
+      console.log("分册id未传递")
+    }
+  }
+
+  ngAfterViewInit(): void {
+    //Called after ngAfterContentInit when the component's view has been initialized. Applies to components only.
+    //Add 'implements AfterViewInit' to the class.
+  }
+
+
+  async refersh() {
+    await this.getEduTextbookVolume()
+    if (this.eduTextbookVolume?.id) {
+
+      this.creatSev.type = this.eduTextbookVolume.get('type')
+      this.creatSev.typeNumber = this.eduTextbookVolume.get('typeNumber')
+
+      this.validateForm = this.fb.group({
+      });
+      console.log(this.validateForm.value);
+      this.courses = this.eduTextbookVolume.get('courses') || this.courses
+    }
+  }
+  ngOnInit() {
+    this.refersh()
+  }
+
+  changeCode() { }
+  getCode(e: any) { }
+  //添加作者信息
+  onPush(idx: number) {
+    this.courses.splice(idx + 1, 0, {
+      date: '',
+      wordage: '',
+      num: '',
+      sumNum: '',
+      accolade: ''
+    });
+  }
+  //删除作者信息
+  onDel(idx: number) {
+    if (this.courses?.length == 1) return
+    this.courses.splice(idx, 1);
+  }
+
+  async saveEduTextbook() {
+    console.log('执行子组件方法')
+    this.eduTextbookVolume?.set('courses', this.courses)
+    await this.eduTextbookVolume?.save()
+  }
+
+
+
+}

+ 20 - 106
projects/textbook/src/modules/nav-author/components/textbook-content/textbook-content.component.html

@@ -1,116 +1,30 @@
 <div class="entry">
+
+
   <form
     nz-form
     [formGroup]="validateForm"
     class="login-form"
     (ngSubmit)="submitForm()"
   >
-    <div class="author-content">
-      <nz-table
-        #basicTable
-        [nzData]="courses"
-        [nzScroll]="{ x: (maxWidth || '1200') + 'px' }"
-      >
-        <thead>
-          <tr>
-            <th nzWidth="80px" nzLeft nzAlign="right">版次</th>
-            <th nzWidth="120px">出版时间</th>
-            <th nzWidth="100px">字数</th>
-            <th nzWidth="100px">重印次数</th>
-            <th nzWidth="100px">本版总印数</th>
-            <th nzWidth="200px">获奖励情况</th>
-            <th nzWidth="80px" nzRight>操作</th>
-          </tr>
-        </thead>
-        <tbody>
-          @for (data of courses; track $index) {
-          <tr>
-            <td nzLeft nzAlign="right">{{ $index + 1 }}</td>
-            <td>
-              <nz-date-picker
-                nzMode="month"
-                [ngModelOptions]="{ standalone: true }"
-                [(ngModel)]="data.date"
-              ></nz-date-picker>
-            </td>
-            <td>
-              <nz-input-group
-                style="width: 100%"
-                [nzSuffix]="suffixTemplateInfo"
-              >
-                <input
-                  type="number"
-                  [(ngModel)]="data.wordage"
-                  nz-input
-                  placeholder="请输入字数"
-                  [ngModelOptions]="{ standalone: true }"
-                />
-              </nz-input-group>
-              <ng-template #suffixTemplateInfo>万</ng-template>
-            </td>
-            <td>
-              <nz-input-group
-                style="width: 100%"
-                [nzSuffix]="suffixTemplateInfo2"
-              >
-                <input
-                  type="number"
-                  [(ngModel)]="data.num"
-                  nz-input
-                  placeholder="请输入重印次数"
-                  [ngModelOptions]="{ standalone: true }"
-                />
-              </nz-input-group>
-              <ng-template #suffixTemplateInfo2>次</ng-template>
-            </td>
-            <td>
-              <nz-input-group
-                style="width: 100%"
-                [nzSuffix]="suffixTemplateInfo"
-              >
-                <input
-                  type="number"
-                  [(ngModel)]="data.sumNum"
-                  nz-input
-                  placeholder="请输入本版总印数"
-                  [ngModelOptions]="{ standalone: true }"
-                />
-              </nz-input-group>
-              <ng-template #suffixTemplateInfo>万</ng-template>
-            </td>
-            <td>
-              <input
-                nz-input
-                type="text"
-                placeholder="请输入所获奖项"
-                [ngModelOptions]="{ standalone: true }"
-                [(ngModel)]="data.accolade"
-                nzStatus=""
-              />
-            </td>
-            <td nzRight>
-              <a (click)="onPush($index)"
-                ><span
-                  nz-icon
-                  style="font-size: 20px; margin-right: 10px"
-                  nzType="plus-circle"
-                  nzTheme="outline"
-                ></span
-              ></a>
-              <a (click)="onDel($index)"
-                ><span
-                  nz-icon
-                  style="font-size: 20px"
-                  nzType="delete"
-                  nzTheme="outline"
-                ></span
-              ></a>
-            </td>
-          </tr>
-          }
-        </tbody>
-      </nz-table>
-    </div>
+
+  
+
+@if (type=='全册') {
+  <nz-collapse>
+    @for (panel of eduTextbookVolumeList; track $index; let pindex = $index) {
+    <nz-collapse-panel [nzHeader]="pindex+1+'册'" [nzActive]="'true'">
+      <app-three  #children [eduTextbookVolumeId]="panel?.id"></app-three>
+    </nz-collapse-panel>
+    }
+  </nz-collapse>
+}@else {
+  @if(eduTextbookVolumeId){
+    <app-three  #children [eduTextbookVolumeId]="eduTextbookVolumeId"></app-three>
+  }
+
+}
+
     <div class="author-content">
       <div class="nav">申报教材特色及创新</div>
       <nz-form-item class="row" style="margin-bottom: 16px">

+ 33 - 2
projects/textbook/src/modules/nav-author/components/textbook-content/textbook-content.component.ts

@@ -17,6 +17,11 @@ import {
 } from '@angular/forms';
 import { textbookServer } from '../../../../services/textbook';
 import { CreatedService } from '../../../../services/created.service'
+import{ContentComponent} from '../create/content/content.component'
+import { NzCollapseModule } from 'ng-zorro-antd/collapse';
+
+import {  ViewChildren, QueryList } from '@angular/core';
+
 
 
 interface course {
@@ -30,6 +35,7 @@ interface course {
 @Component({
   selector: 'app-textbook-content',
   imports: [
+    NzCollapseModule,
     CommonCompModule,
     ReactiveFormsModule,
     NzSelectModule,
@@ -37,6 +43,7 @@ interface course {
     NzGridModule,
     NzCheckboxModule,
     NzTableModule,
+    ContentComponent,
   ],
   standalone: true,
   templateUrl: './textbook-content.component.html',
@@ -72,7 +79,7 @@ export class TextbookContentComponent  implements OnInit {
     private creatSev:CreatedService
   ) { }
 
-
+loading=false
  /**扩展表记录 */
  eduTextbookVolumeList: Array<any> = []
  /**获取扩展表记录 */
@@ -101,6 +108,7 @@ export class TextbookContentComponent  implements OnInit {
    } else {
      this.eduTextbookVolumeList[0] = list[0]
      console.log(this.eduTextbookVolumeList)
+     this.eduTextbookVolumeId=list[0]?.id
    }
 
  }
@@ -108,7 +116,8 @@ export class TextbookContentComponent  implements OnInit {
  typeNumber:any
  /** 申报类型*/
  type:any
-
+/** 单册时该册id*/
+ eduTextbookVolumeId:any
 
 
   ngAfterViewInit(): void {
@@ -204,6 +213,27 @@ export class TextbookContentComponent  implements OnInit {
     this.courses.splice(idx, 1);
   }
 
+
+
+  @ViewChildren(ContentComponent) children: QueryList<ContentComponent> | any;
+
+    /**上传分册数据 */
+    async saveEduTextbookVolume(eduTextbookId?: any) {
+      console.log(eduTextbookId)
+      let arr = [] //存储返回的数组id
+      let isVrifly = true //默认都通过,若一项填写未完成,则不通过
+      return Promise.all(this.children.map(async (comp: any) => {
+        console.log(comp);
+        let req = await comp.saveEduTextbook(eduTextbookId||this.eduTextbook?.id)
+        console.log(req)
+        // arr.push(comp.saveEduTextbook())
+        //加上子组件返回是否填写完成的方法
+        // return arr
+      })).then(data => {
+        console.log(data);
+      })
+    }
+
   async saveEduTextbook(params: any, isComplete: boolean) {
     console.log(params);
     if (!this.eduTextbook) {
@@ -227,6 +257,7 @@ export class TextbookContentComponent  implements OnInit {
     params.influence && this.eduTextbook?.set('influence', params.influence);
     this.eduTextbook?.set('courses', this.courses);
     await this.eduTextbook?.save();
+    await this.saveEduTextbookVolume()
     return;
   }
 }

+ 1 - 0
projects/textbook/src/services/created.service.ts

@@ -1,4 +1,5 @@
 import { Injectable } from '@angular/core';
+import Parse from 'parse';
 
 @Injectable({
   providedIn: 'root'