|
@@ -1,4 +1,4 @@
|
|
|
-import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
|
|
|
+import { Component, OnInit, Input, Output, EventEmitter,ViewChildren, QueryList } from '@angular/core';
|
|
|
import { CommonCompModule } from '../../../../services/common.modules';
|
|
|
import { NzSelectModule } from 'ng-zorro-antd/select';
|
|
|
import { ReactiveFormsModule } from '@angular/forms';
|
|
@@ -25,7 +25,8 @@ import { textbookServer } from '../../../../services/textbook';
|
|
|
import * as eduTextBook from '../../../../services/EduTextbook'
|
|
|
import { HttpClient } from '@angular/common/http';
|
|
|
import { Router } from '@angular/router'
|
|
|
-
|
|
|
+import { NzCollapseModule } from 'ng-zorro-antd/collapse';
|
|
|
+import{AuthorFileComponent} from '../create/author-file/author-file.component'
|
|
|
|
|
|
@Component({
|
|
|
selector: 'app-attachment',
|
|
@@ -36,9 +37,10 @@ import { Router } from '@angular/router'
|
|
|
NzRadioModule,
|
|
|
NzGridModule,
|
|
|
NzCheckboxModule,
|
|
|
- NzTableModule,
|
|
|
+ NzTableModule,NzCollapseModule,
|
|
|
NzUploadModule,
|
|
|
CompUploadComponent,DatePipe,
|
|
|
+ AuthorFileComponent
|
|
|
],
|
|
|
standalone: true,
|
|
|
templateUrl: './attachment.component.html',
|
|
@@ -50,6 +52,7 @@ export class AttachmentComponent implements OnInit {
|
|
|
@Input('maxWidth') maxWidth: number = 0;
|
|
|
@Output() state: EventEmitter<any> = new EventEmitter<any>();
|
|
|
@Output() save: EventEmitter<any> = new EventEmitter<any>();
|
|
|
+ @ViewChildren(AuthorFileComponent) children: QueryList<AuthorFileComponent> | any;
|
|
|
|
|
|
//填写诚信承诺是否正确
|
|
|
confirmationValidator: ValidatorFn = (
|
|
@@ -118,7 +121,7 @@ export class AttachmentComponent implements OnInit {
|
|
|
this.cipProveFile = this.eduTextbook?.get('cipProveFile') || this.cipProveFile
|
|
|
this.unitMaterial = this.eduTextbook?.get('unitMaterial') || this.unitMaterial
|
|
|
// this.examine = this.eduTextbook?.get('examine') || this.examine
|
|
|
- this.authorList = this.eduTextbook?.get('authorList')
|
|
|
+ // this.authorList = this.eduTextbook?.get('authorList')
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -235,11 +238,11 @@ export class AttachmentComponent implements OnInit {
|
|
|
})
|
|
|
/* 检验authorList字段是否留空 */
|
|
|
let authorListAuth
|
|
|
- console.log(this.authorList);
|
|
|
- authorListAuth = this.authorList.some((obj:any)=>{
|
|
|
- return Object.keys(obj).some((item: string) => item!= 'signature' && !obj[item])
|
|
|
- })
|
|
|
- console.log(authorListAuth);
|
|
|
+ // console.log(this.authorList);
|
|
|
+ // authorListAuth = this.authorList.some((obj:any)=>{
|
|
|
+ // return Object.keys(obj).some((item: string) => item!= 'signature' && !obj[item])
|
|
|
+ // })
|
|
|
+ // console.log(authorListAuth);
|
|
|
|
|
|
if (isVrifly || authorListAuth) {
|
|
|
this.msg.warning('已保存,存在未填项')
|
|
@@ -250,6 +253,8 @@ export class AttachmentComponent implements OnInit {
|
|
|
}
|
|
|
|
|
|
async submitForm(event?: string): Promise<void> {
|
|
|
+ if (this.saveLoading) return;
|
|
|
+ this.saveLoading = true;
|
|
|
let params = {
|
|
|
copyrightImgUrl: this.copyrightImgUrl,
|
|
|
CIPImgUrl: this.CIPImgUrl,
|
|
@@ -259,28 +264,20 @@ export class AttachmentComponent implements OnInit {
|
|
|
evidence: this.evidence,
|
|
|
moreMaterial: this.moreMaterial,
|
|
|
// examine: this.examine,
|
|
|
- authorList:this.authorList
|
|
|
+ // authorList:this.authorList
|
|
|
// unitMaterial: this.unitMaterial,
|
|
|
}
|
|
|
|
|
|
let isPageNull = this.examineNull()//检查本页空项
|
|
|
- let isIgnoreFiled = this.isIgnoreFiledNull()//检查数据空项
|
|
|
+ // let isIgnoreFiled = this.isIgnoreFiledNull()//检查数据空项
|
|
|
// console.log(isPageNull,isIgnoreFiled);
|
|
|
- await this.saveEduTextbook(params, (!isPageNull && !isIgnoreFiled));
|
|
|
-
|
|
|
+ let isComplete = await this.saveEduTextbook(params, (!isPageNull));
|
|
|
if (event == 'pre') {//上一步
|
|
|
this.state.emit({ type: 'pre' });
|
|
|
return;
|
|
|
- }else
|
|
|
- // await this.saveEduTextbook(params, (!isPageNull && !isIgnoreFiled));
|
|
|
- if (event == 'complete') {
|
|
|
+ }else if (event == 'complete') {
|
|
|
this.state.emit({ type: 'complete', textBook: this.eduTextbook });
|
|
|
- if (isPageNull || isIgnoreFiled) {
|
|
|
- console.log('教材填写不完整');
|
|
|
- } else {
|
|
|
- this.eduTextbook.set('complete', true)
|
|
|
- this.eduTextbook.set('status', '102')
|
|
|
- await this.eduTextbook.save()
|
|
|
+ if (isComplete) {
|
|
|
this.msg.success('已填写完成')
|
|
|
}
|
|
|
this.router.navigate(['/nav-author/manage/space'])
|
|
@@ -294,42 +291,78 @@ export class AttachmentComponent implements OnInit {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- async saveEduTextbook(params: any, isComplete: boolean) {
|
|
|
+
|
|
|
+ /**上传分册数据 */
|
|
|
+ async saveEduTextbookVolume() {
|
|
|
+ let isVrifly = true; //默认都通过,若一项填写未完成,则不通过
|
|
|
+ return Promise.all(
|
|
|
+ this.children.map(async (comp: any) => {
|
|
|
+ let req = await comp.submitForm();
|
|
|
+ // console.log(req)
|
|
|
+ if (!req) {
|
|
|
+ isVrifly = false;
|
|
|
+ }
|
|
|
+ return isVrifly;
|
|
|
+ })
|
|
|
+ ).then((data) => {
|
|
|
+ console.log(isVrifly);
|
|
|
+ return isVrifly;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ saveLoading: boolean = false;
|
|
|
+ async saveEduTextbook(params: any, isComplete: boolean):Promise<boolean|undefined> {
|
|
|
console.log(isComplete);
|
|
|
if (!this.eduTextbook) {
|
|
|
+ this.saveLoading = false;
|
|
|
this.msg.error('请先创建教材');
|
|
|
return;
|
|
|
}
|
|
|
- //如果填写未完整,仅保存,状态修改待完善101
|
|
|
- if (this.eduTextbook.get('status') == '102' && !isComplete) {
|
|
|
- this.eduTextbook?.set('status', '101');
|
|
|
- } else if (!this.eduTextbook.get('status')) {
|
|
|
- this.eduTextbook?.set('status', '101');
|
|
|
+ try {
|
|
|
+ //如果填写未完整,仅保存,状态修改待完善101
|
|
|
+ let complete = await this.saveEduTextbookVolume();
|
|
|
+ isComplete = isComplete && complete;
|
|
|
+ if (this.eduTextbook.get('status') == '102' && !isComplete) {
|
|
|
+ this.eduTextbook?.set('status', '101');
|
|
|
+ }
|
|
|
+ if(this.eduTextbook.get('complete') && isComplete){
|
|
|
+ this.eduTextbook.set('complete', true)
|
|
|
+ this.eduTextbook.set('status', '102')
|
|
|
+ }
|
|
|
+ this.eduTextbook?.set('user', Parse.User.current()?.toPointer());
|
|
|
+ this.eduTextbook?.set('company', {
|
|
|
+ __type: 'Pointer',
|
|
|
+ className: 'Company',
|
|
|
+ objectId: this.tbookSer.company,
|
|
|
+ });
|
|
|
+ params.selfResults &&
|
|
|
+ this.eduTextbook?.set('selfResults', params.selfResults);
|
|
|
+ // params.unitMaterial &&
|
|
|
+ // this.eduTextbook?.set('unitMaterial', params.unitMaterial);
|
|
|
+ params.expertOpinion &&
|
|
|
+ this.eduTextbook?.set('expertOpinion', params.expertOpinion);
|
|
|
+ params.evidence && this.eduTextbook?.set('evidence', params.evidence);
|
|
|
+ params.cipProveFile &&
|
|
|
+ this.eduTextbook?.set('cipProveFile', params.cipProveFile);
|
|
|
+ params.moreMaterial &&
|
|
|
+ this.eduTextbook?.set('moreMaterial', params.moreMaterial);
|
|
|
+ // params.examine &&
|
|
|
+ // this.eduTextbook?.set('examine', params.examine);
|
|
|
+ this.eduTextbook?.set('copyrightImgUrl', params.copyrightImgUrl);
|
|
|
+ this.eduTextbook?.set('CIPImgUrl', params.CIPImgUrl);
|
|
|
+ // this.eduTextbook?.set('authorList', params.authorList);
|
|
|
+ await this.eduTextbook?.save();
|
|
|
+ this.saveLoading = false;
|
|
|
+ if (!isComplete) {
|
|
|
+ this.msg.warning('保存成功,但存在未填写完成项');
|
|
|
+ }
|
|
|
+ return isComplete;
|
|
|
+ } catch (err) {
|
|
|
+ console.warn('保存错误:', err);
|
|
|
+ this.saveLoading = false;
|
|
|
+ this.msg.error('保存出错');
|
|
|
}
|
|
|
- this.eduTextbook?.set('user', Parse.User.current()?.toPointer());
|
|
|
- this.eduTextbook?.set('company', {
|
|
|
- __type: 'Pointer',
|
|
|
- className: 'Company',
|
|
|
- objectId: this.tbookSer.company,
|
|
|
- });
|
|
|
- params.selfResults &&
|
|
|
- this.eduTextbook?.set('selfResults', params.selfResults);
|
|
|
- // params.unitMaterial &&
|
|
|
- // this.eduTextbook?.set('unitMaterial', params.unitMaterial);
|
|
|
- params.expertOpinion &&
|
|
|
- this.eduTextbook?.set('expertOpinion', params.expertOpinion);
|
|
|
- params.evidence && this.eduTextbook?.set('evidence', params.evidence);
|
|
|
- params.cipProveFile &&
|
|
|
- this.eduTextbook?.set('cipProveFile', params.cipProveFile);
|
|
|
- params.moreMaterial &&
|
|
|
- this.eduTextbook?.set('moreMaterial', params.moreMaterial);
|
|
|
- // params.examine &&
|
|
|
- // this.eduTextbook?.set('examine', params.examine);
|
|
|
- this.eduTextbook?.set('copyrightImgUrl', params.copyrightImgUrl);
|
|
|
- this.eduTextbook?.set('CIPImgUrl', params.CIPImgUrl);
|
|
|
- this.eduTextbook?.set('authorList', params.authorList);
|
|
|
- await this.eduTextbook?.save();
|
|
|
- return;
|
|
|
+ this.saveLoading = false;
|
|
|
+ return isComplete;
|
|
|
}
|
|
|
upload(e: any, type: string, index?: any) {
|
|
|
let file = e[(e?.length - 1) || 0];
|
|
@@ -346,7 +379,7 @@ export class AttachmentComponent implements OnInit {
|
|
|
}else if(type == 'cipProveFile'){
|
|
|
this[type] = [ { name: file.name, url: file.url }]
|
|
|
}
|
|
|
- console.log(this.authorList)
|
|
|
+ // console.log(this.authorList)
|
|
|
}
|
|
|
|
|
|
|