|
@@ -36,6 +36,7 @@ import { MatIconModule } from '@angular/material/icon';
|
|
|
import { MatButtonModule } from '@angular/material/button';
|
|
|
import { provideNativeDateAdapter } from '@angular/material/core';
|
|
|
import { ViewChildren, QueryList } from '@angular/core';
|
|
|
+import { CreatedService } from '../../../../services/created.service'
|
|
|
|
|
|
@Component({
|
|
|
selector: 'app-basic',
|
|
@@ -77,14 +78,36 @@ export class BasicInComponent implements OnInit {
|
|
|
|
|
|
@ViewChildren(BasicComponent) children: QueryList<BasicComponent> | any;
|
|
|
|
|
|
+
|
|
|
+ async deleteVolume(index: any) {
|
|
|
+ console.log('hhhhhh', index)
|
|
|
+ if (this.eduTextbookVolumeList.length <= 2) {
|
|
|
+ this.msg.create('warning', '全册最少两册')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ console.log(this.eduTextbookVolumeList)
|
|
|
+ console.log(this.eduTextbookVolumeList[index])
|
|
|
+ if (this.eduTextbookVolumeList[index]?.id) {
|
|
|
+ this.eduTextbookVolumeList[index]?.set('isDeleted', true)
|
|
|
+ await this.eduTextbookVolumeList[index]?.save()
|
|
|
+ delete this.eduTextbookVolumeList[index]
|
|
|
+ this.typeNumber = this.typeNumber - 1
|
|
|
+ } else {
|
|
|
+ delete this.eduTextbookVolumeList[index]
|
|
|
+ this.typeNumber = this.typeNumber - 1
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
|
|
|
- async saveEduTextbookVolume() {
|
|
|
+ async saveEduTextbookVolume(eduTextbookId?: any) {
|
|
|
+ console.log(eduTextbookId)
|
|
|
let arr = []
|
|
|
let isVrifly = true
|
|
|
return Promise.all(this.children.map(async (comp: any) => {
|
|
|
console.log(comp);
|
|
|
- let req = await comp.saveEduTextbook()
|
|
|
+ let req = await comp.saveEduTextbook(eduTextbookId)
|
|
|
console.log(req)
|
|
|
|
|
|
|
|
@@ -141,18 +164,20 @@ export class BasicInComponent implements OnInit {
|
|
|
|
|
|
this.eduTextbook?.set('approvedImgUrl', params.approvedImgUrl)
|
|
|
this.eduTextbook?.set('unitType', params.unitType)
|
|
|
- if(!this.eduTextbook?.get('code')){
|
|
|
+ if (!this.eduTextbook?.get('code')) {
|
|
|
let t =
|
|
|
- this.tbookSer.formatTime('YYYYmmdd', new Date()) +
|
|
|
- Math.random().toString().slice(-4);
|
|
|
+ this.tbookSer.formatTime('YYYYmmdd', new Date()) +
|
|
|
+ Math.random().toString().slice(-4);
|
|
|
this.eduTextbook.set('code', t);
|
|
|
}
|
|
|
- await this.eduTextbook?.save();
|
|
|
- this.saveEduTextbookVolume()
|
|
|
+ let res = await this.eduTextbook?.save();
|
|
|
+ this.eduTextbookId = await res?.id
|
|
|
+ console.log(res?.id)
|
|
|
+ await this.saveEduTextbookVolume(this.eduTextbookId)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ eduTextbookId: string = ''
|
|
|
|
|
|
|
|
|
|
|
@@ -162,6 +187,7 @@ export class BasicInComponent implements OnInit {
|
|
|
|
|
|
|
|
|
ngAfterViewInit() {
|
|
|
+ this.eduTextbookId = this.eduTextbook?.id
|
|
|
this.accordion?.openAll()
|
|
|
this.cdr.detectChanges()
|
|
|
this.getEduTextbookVolumeList()
|
|
@@ -171,10 +197,13 @@ export class BasicInComponent implements OnInit {
|
|
|
eduTextbookVolumeList: Array<any> = []
|
|
|
|
|
|
async getEduTextbookVolumeList() {
|
|
|
- console.log(this.validateForm?.value?.type)
|
|
|
-
|
|
|
+ if (this.typeNumber && this.typeNumber > 12) {
|
|
|
+ this.typeNumber = 12
|
|
|
+ }
|
|
|
+ console.log(this.validateForm?.value?.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)
|
|
@@ -185,20 +214,36 @@ export class BasicInComponent implements OnInit {
|
|
|
}
|
|
|
let list = await query.find()
|
|
|
console.log(list)
|
|
|
- this.eduTextbookVolumeList = new Array(this.typeNumber).fill({ objectId: '' })
|
|
|
- for (let i in list) {
|
|
|
- this.eduTextbookVolumeList[i] = { objectId: list[i]?.id }
|
|
|
+ if (this.validateForm?.value?.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.singleId = list[0]?.id
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ }
|
|
|
+ singleId: string = ''
|
|
|
+ loading = false
|
|
|
+ async checkSingle() {
|
|
|
+ this.loading = true
|
|
|
+ this.validateForm.get("type")?.setValue('单册')
|
|
|
+ await this.getEduTextbookVolumeList()
|
|
|
+ this.loading = false
|
|
|
+
|
|
|
}
|
|
|
|
|
|
- checkAll() {
|
|
|
+ async checkAll() {
|
|
|
this.validateForm.get("type")?.setValue('全册')
|
|
|
|
|
|
this.accordion?.openAll()
|
|
|
this.getEduTextbookVolumeList()
|
|
|
}
|
|
|
ngOnInit() {
|
|
|
+
|
|
|
if (this.eduTextbook?.get('editionUnit')) {
|
|
|
this.isShowChooseEU = false
|
|
|
}
|
|
@@ -213,7 +258,7 @@ export class BasicInComponent implements OnInit {
|
|
|
|
|
|
this.approvedImgList[0].url = this.eduTextbook?.get('approvedImgUrl')
|
|
|
this.typeNumber = this.eduTextbook?.get('typeNumber') || 2
|
|
|
-
|
|
|
+ if (this.typeNumber > 12) this.typeNumber = 12
|
|
|
|
|
|
console.log(this.eduTextbook);
|
|
|
this.validateForm = this.fb.group({
|
|
@@ -221,7 +266,7 @@ export class BasicInComponent implements OnInit {
|
|
|
ISBN: [parseInt(this.eduTextbook?.get('ISBN') || '') || null, [Validators.required]],
|
|
|
author: [this.eduTextbook?.get('author') || '', [Validators.required]],
|
|
|
unit: [this.eduTextbook?.get('unit') || '', [Validators.required]],
|
|
|
- type: [this.eduTextbook?.get('type') || '全册', [Validators.required]],
|
|
|
+ type: [this.eduTextbook?.get('type') || '单册', [Validators.required]],
|
|
|
|
|
|
|
|
|
majorPoniter: [this.eduTextbook?.get('majorPoniter')?.code || '', [Validators.required]],
|
|
@@ -473,7 +518,8 @@ export class BasicInComponent implements OnInit {
|
|
|
private fb: NonNullableFormBuilder,
|
|
|
private modal: NzModalService,
|
|
|
private msg: NzMessageService,
|
|
|
- private cdr: ChangeDetectorRef
|
|
|
+ private cdr: ChangeDetectorRef,
|
|
|
+ private creatSev:CreatedService
|
|
|
) {
|
|
|
}
|
|
|
|
|
@@ -502,6 +548,7 @@ export class BasicInComponent implements OnInit {
|
|
|
if (event == 'save') {
|
|
|
let params = this.validateForm.value
|
|
|
await this.saveEduTextbook(params, this.validateForm.valid)
|
|
|
+ await this.getEduTextbookVolumeList()
|
|
|
this.modal.success({
|
|
|
nzTitle: '保存成功',
|
|
|
nzContent: '<p>已保存并且至空间</p>',
|
|
@@ -518,6 +565,7 @@ export class BasicInComponent implements OnInit {
|
|
|
if (event == 'save') {
|
|
|
let params = this.validateForm.value
|
|
|
await this.saveEduTextbook(params, this.validateForm.valid)
|
|
|
+ await this.getEduTextbookVolumeList()
|
|
|
this.modal.success({
|
|
|
nzTitle: '保存成功',
|
|
|
nzContent: '<p>已保存并且至空间</p>',
|
|
@@ -527,9 +575,6 @@ export class BasicInComponent implements OnInit {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
selectedValue = null;
|
|
|
listOfOption: Array<{ value: string; text: string }> = [];
|
|
|
nzFilterOption = (): boolean => true;
|