Browse Source

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

ryanemax 4 months ago
parent
commit
efc24ce7d0

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

@@ -118,7 +118,7 @@ export class ContentComponent implements OnInit {
 
   async submitForm(): Promise<boolean> {
     let coursesVrifly = !this.courses.some((item) =>
-      Object.values(item).some((val) => val != 0 && (val == '' || val == undefined))
+      Object.values(item).some((val) =>  val !== 0 && (val == undefined || val == ''))
     );
     this.eduTextbookVolume?.set('courses', this.courses);
     await this.eduTextbookVolume?.save();

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

@@ -32,13 +32,13 @@
       </nz-collapse-panel>
       }
     </nz-collapse>
-    }@else { @if(eduTextbookVolumeId){
+    }@else {
     <app-three
       #children
       [eduTextbook]="eduTextbook?.id"
       [eduTextbookVolume]="eduTextbook?.get('childrens')[0]"
     ></app-three>
-    } }
+    }
 
     <div class="author-content">
       <div class="nav">申报教材特色及创新</div>

+ 40 - 149
projects/textbook/src/modules/nav-author/components/textbook-content/textbook-content.component.ts

@@ -59,16 +59,7 @@ export class TextbookContentComponent implements OnInit {
     innovateExplain: ['', [Validators.required]],
     influence: ['', [Validators.required]],
   });
-  //申报教材建设历程
-  courses: Array<course> = [
-    {
-      date: '', //出版时间
-      wordage: '', //字数
-      num: '', //重印次数
-      sumNum: '', //本版总印数
-      accolade: '', //获奖励情况
-    },
-  ];
+
   constructor(
     public tbookSer: textbookServer,
     private fb: NonNullableFormBuilder,
@@ -79,56 +70,56 @@ export class TextbookContentComponent implements OnInit {
 
   loading = false;
   /**扩展表记录 */
-  eduTextbookVolumeList: Array<any> = [];
+  // eduTextbookVolumeList: Array<any> = [];
   /**获取扩展表记录 */
-  async getEduTextbookVolumeList() {
-    if (this.typeNumber && this.typeNumber > 12) {
-      this.typeNumber = 12;
-    }
-    console.log(this.type, this.typeNumber);
-    let query = new Parse.Query('EduTextbookVolume');
-    query.equalTo('eduTextbook', this.eduTextbook?.id);
-    query.select('objectId');
-    query.ascending('createdAt'); //小到大
-    query.notEqualTo('isDeleted', true);
-    if (this.type == '全册') {
-      query.limit(this.typeNumber);
-    } else {
-      query.limit(1);
-    }
-    let list = await query.find();
-    console.log(list);
-    if (this.type == '全册') {
-      this.eduTextbookVolumeList = new Array(this.typeNumber).fill({
-        objectId: '',
-      });
-      for (let i in list) {
-        this.eduTextbookVolumeList[i] = list[i];
-      }
-    } else {
-      this.eduTextbookVolumeList[0] = list[0];
-      console.log(this.eduTextbookVolumeList);
-      this.eduTextbookVolumeId = list[0]?.id;
-    }
-  }
+  // async getEduTextbookVolumeList() {
+  //   if (this.typeNumber && this.typeNumber > 12) {
+  //     this.typeNumber = 12;
+  //   }
+  //   console.log(this.type, this.typeNumber);
+  //   let query = new Parse.Query('EduTextbookVolume');
+  //   query.equalTo('eduTextbook', this.eduTextbook?.id);
+  //   query.select('objectId');
+  //   query.ascending('createdAt'); //小到大
+  //   query.notEqualTo('isDeleted', true);
+  //   if (this.type == '全册') {
+  //     query.limit(this.typeNumber);
+  //   } else {
+  //     query.limit(1);
+  //   }
+  //   let list = await query.find();
+  //   console.log(list);
+  //   if (this.type == '全册') {
+  //     this.eduTextbookVolumeList = new Array(this.typeNumber).fill({
+  //       objectId: '',
+  //     });
+  //     for (let i in list) {
+  //       this.eduTextbookVolumeList[i] = list[i];
+  //     }
+  //   } else {
+  //     this.eduTextbookVolumeList[0] = list[0];
+  //     console.log(this.eduTextbookVolumeList);
+  //     this.eduTextbookVolumeId = list[0]?.id;
+  //   }
+  // }
   /** 册数*/
-  typeNumber: any;
+  // typeNumber: any;
   /** 申报类型*/
   type: any;
   /** 单本时该册id*/
-  eduTextbookVolumeId: any;
+  // eduTextbookVolumeId: any;
 
   ngAfterViewInit(): void {
-    this.typeNumber = this.eduTextbook?.get('typeNumber');
+    // this.typeNumber = this.eduTextbook?.get('typeNumber');
     this.type = this.eduTextbook?.get('type');
-    this.getEduTextbookVolumeList();
-    this.creatSev.getEduTextbookVolumeList(this.eduTextbook.id);
+    // this.getEduTextbookVolumeList();
+    // this.creatSev.getEduTextbookVolumeList(this.eduTextbook.id);
   }
 
   ngOnInit() {
     if (this.eduTextbook.id) {
-      this.creatSev.type = this.eduTextbook.get('type');
-      this.creatSev.typeNumber = this.eduTextbook.get('typeNumber');
+      // this.creatSev.type = this.eduTextbook.get('type');
+      // this.creatSev.typeNumber = this.eduTextbook.get('typeNumber');
 
       this.validateForm = this.fb.group({
         innovateExplain: [
@@ -138,55 +129,16 @@ export class TextbookContentComponent implements OnInit {
         influence: [this.eduTextbook.get('influence'), [Validators.required]],
       });
       console.log(this.validateForm.value);
-      this.courses = this.eduTextbook.get('courses') || this.courses;
     }
   }
   async submitForm(event?: string): Promise<void> {
     let params: any = this.validateForm.value;
     console.log(params);
+    console.log(this.validateForm.valid);
     if (event == 'pre') {
       this.state.emit({ type: 'pre' });
       return
     }
-    console.log(this.validateForm.value);
-    // let coursesVrifly = !this.courses.some(item=>Object.values(item).some(val=> val == '' || val == undefined))
-    let coursesVrifly = true
-    if (this.validateForm.valid) {
-      let params: any = this.validateForm.value;
-      if (event == 'next') {
-        if(!coursesVrifly){
-          this.msg.warning('申报教材建设历程填写不完整')
-          return
-        }
-        await this.saveEduTextbook(params, true);
-        this.state.emit({ type: 'next', textBook: this.eduTextbook });
-      }
-    } else {
-      if (event == 'save') {
-        let params: any = this.validateForm.value;
-        await this.saveEduTextbook(params, (this.validateForm.valid && coursesVrifly));
-        this.modal.success({
-          nzTitle: '保存成功',
-          nzContent: '<p>已保存并且至空间</p>',
-          nzOnOk: () => console.log('Info OK'),
-        });
-        return;
-      }
-      if (event == 'next') {
-      let params: any = this.validateForm.value;
-      await this.saveEduTextbook(params, false);
-        this.state.emit({ type: 'next', textBook: this.eduTextbook });
-      }
-      // Object.values(this.validateForm.controls).forEach((control) => {
-      //   if (control.invalid) {
-      //     control.markAsDirty();
-      //     control.updateValueAndValidity({ onlySelf: true });
-      //   }
-      // });
-      // this.msg.warning('请填写完整信息');
-      return;
-    }
-    // let coursesVrifly = !this.courses.some(item=>Object.values(item).some(val=> val == '' || val == undefined))
     if (event == 'save') {
       await this.saveEduTextbook(params, this.validateForm.valid);
       this.modal.success({
@@ -201,66 +153,6 @@ export class TextbookContentComponent implements OnInit {
       this.state.emit({ type: 'next', textBook: this.eduTextbook });
       return;
     }
-    // if (this.validateForm.valid) {
-    //   let params: any = this.validateForm.value;
-    //   if (event == 'next') {
-    //     // if(!coursesVrifly){
-    //     //   this.msg.warning('申报教材建设历程填写不完整')
-    //     //   return
-    //     // }
-    //     await this.saveEduTextbook(params, true);
-    //     this.state.emit({ type: 'next', textBook: this.eduTextbook });
-    //   }
-    // } else {
-    //   if (event == 'save') {
-    //     let params: any = this.validateForm.value;
-    //     await this.saveEduTextbook(params, this.validateForm.valid);
-    //     this.modal.success({
-    //       nzTitle: '保存成功',
-    //       nzContent: '<p>已保存并且至空间</p>',
-    //       nzOnOk: () => console.log('Info OK'),
-    //     });
-    //     return;
-    //   }
-    //   if (event == 'next') {
-    //   let params: any = this.validateForm.value;
-    //   await this.saveEduTextbook(params, false);
-    //     this.state.emit({ type: 'next', textBook: this.eduTextbook });
-    //   }
-    //   // Object.values(this.validateForm.controls).forEach((control) => {
-    //   //   if (control.invalid) {
-    //   //     control.markAsDirty();
-    //   //     control.updateValueAndValidity({ onlySelf: true });
-    //   //   }
-    //   // });
-    //   // this.msg.warning('请填写完整信息');
-    // }
-    // if (event == 'save') {
-    //   let params = this.validateForm.value;
-    //   await this.saveEduTextbook(params, this.validateForm.valid);
-    //   this.modal.success({
-    //     nzTitle: '保存成功',
-    //     nzContent: '<p>已保存并且至空间</p>',
-    //     nzOnOk: () => console.log('Info OK'),
-    //   });
-    // }
-  }
-  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);
   }
 
   @ViewChildren(ContentComponent) children: QueryList<ContentComponent> | any;
@@ -313,7 +205,6 @@ export class TextbookContentComponent implements OnInit {
       params.innovateExplain &&
         this.eduTextbook?.set('innovateExplain', params.innovateExplain);
       params.influence && this.eduTextbook?.set('influence', params.influence);
-      // this.eduTextbook?.set('courses', this.courses);
       await this.eduTextbook?.save();
       this.saveLoading = false;
       if (!isComplete) {