|
@@ -1,4 +1,10 @@
|
|
|
-import { Component, Input, OnInit } from '@angular/core';
|
|
|
+import {
|
|
|
+ Component,
|
|
|
+ Input,
|
|
|
+ OnInit,
|
|
|
+ QueryList,
|
|
|
+ ViewChildren,
|
|
|
+} from '@angular/core';
|
|
|
import { CommonModule } from '@angular/common';
|
|
|
import { NzSpaceModule } from 'ng-zorro-antd/space';
|
|
|
import { CommonCompModule } from '../../../services/common.modules';
|
|
@@ -12,6 +18,9 @@ import { MatDialog } from '@angular/material/dialog';
|
|
|
import { NzEmptyModule } from 'ng-zorro-antd/empty';
|
|
|
import { DatePipe } from '@angular/common';
|
|
|
import { NzPopoverModule } from 'ng-zorro-antd/popover';
|
|
|
+import { UploadCollectComponent } from '../components/upload-collect/upload-collect.component';
|
|
|
+import { NzCollapseModule } from 'ng-zorro-antd/collapse';
|
|
|
+
|
|
|
@Component({
|
|
|
selector: 'app-collect-file',
|
|
|
templateUrl: './collect-file.component.html',
|
|
@@ -23,6 +32,8 @@ import { NzPopoverModule } from 'ng-zorro-antd/popover';
|
|
|
NzMessageModule,
|
|
|
NzEmptyModule,
|
|
|
NzPopoverModule,
|
|
|
+ UploadCollectComponent,
|
|
|
+ NzCollapseModule,
|
|
|
],
|
|
|
providers: [DatePipe],
|
|
|
standalone: true,
|
|
@@ -32,10 +43,13 @@ export class CollectFileComponent implements OnInit {
|
|
|
eduProcess?: Parse.Object; //流程
|
|
|
count: number = 0;
|
|
|
|
|
|
- @Input('limit') limit: number = 10;
|
|
|
+ limit: number = 10;
|
|
|
pageIndex: number = 1;
|
|
|
loading: boolean = false;
|
|
|
@Input('maxWidth') maxWidth: any; //最大宽度
|
|
|
+ @ViewChildren(UploadCollectComponent) children:
|
|
|
+ | QueryList<UploadCollectComponent>
|
|
|
+ | any;
|
|
|
|
|
|
searchValue: string = '';
|
|
|
time: any;
|
|
@@ -65,6 +79,8 @@ export class CollectFileComponent implements OnInit {
|
|
|
isVisible: boolean = false;
|
|
|
currentTextbook?: Parse.Object; //当前编辑教材
|
|
|
|
|
|
+ statusMap: any = {}; //任务状态
|
|
|
+
|
|
|
constructor(
|
|
|
private msg: NzMessageService,
|
|
|
public tbookSer: textbookServer,
|
|
@@ -88,7 +104,7 @@ export class CollectFileComponent implements OnInit {
|
|
|
this.eduProcess = r;
|
|
|
}
|
|
|
|
|
|
- async getTextbook(val?: string, review?: boolean): Promise<any[] | void> {
|
|
|
+ async getTextbook(val?: string): Promise<any[] | void> {
|
|
|
if (this.loading) return;
|
|
|
this.loading = true;
|
|
|
try {
|
|
@@ -97,6 +113,8 @@ export class CollectFileComponent implements OnInit {
|
|
|
$or: [
|
|
|
{
|
|
|
title: { $regex: `.*${val || ''}.*` },
|
|
|
+ },
|
|
|
+ {
|
|
|
code: { $regex: `.*${val || ''}.*` },
|
|
|
},
|
|
|
{
|
|
@@ -107,9 +125,6 @@ export class CollectFileComponent implements OnInit {
|
|
|
{
|
|
|
ISBN: { $regex: `.*${val || ''}.*` },
|
|
|
},
|
|
|
- // {
|
|
|
- // author: { $regex: `.*${val || ''}.*` },
|
|
|
- // },
|
|
|
],
|
|
|
},
|
|
|
className: 'EduTextbookVolume',
|
|
@@ -135,8 +150,6 @@ export class CollectFileComponent implements OnInit {
|
|
|
query.equalTo('status', '400');
|
|
|
query.equalTo('recommend', true);
|
|
|
query.notEqualTo('discard', true);
|
|
|
- // query.exists('score');
|
|
|
- // query.equalTo('verify', true);
|
|
|
query.include(
|
|
|
'childrens',
|
|
|
'eduProcess.profileSubmitted.user',
|
|
@@ -145,30 +158,46 @@ export class CollectFileComponent implements OnInit {
|
|
|
this.count = await query.count();
|
|
|
query.limit(this.limit);
|
|
|
query.skip(this.limit * (this.pageIndex - 1));
|
|
|
- // if (exported) {
|
|
|
- // query.limit(1000);
|
|
|
- // let r = await query.find();
|
|
|
- // this.loading = false;
|
|
|
- // return r;
|
|
|
- // }
|
|
|
this.textbookList = await query.find();
|
|
|
//获取对应出版单位管理员
|
|
|
- // if(!review && this.textbookList.length > 0){
|
|
|
- // let contains:Array<string> = []
|
|
|
- // this.textbookList.forEach((childs:any)=>{
|
|
|
- // childs.get('childrens').forEach((item:Parse.Object)=> contains.push(item.get('editionUnit')))
|
|
|
- // })
|
|
|
- // let queryProcess = new Parse.Query('EduProcess')
|
|
|
- // queryProcess.notEqualTo('isDeleted',true)
|
|
|
- // queryProcess.containedIn('name',[...new Set(contains)])
|
|
|
- // queryProcess.include('profileSubmitted.user')
|
|
|
- // queryProcess.select('profileSubmitted.user.name','name')
|
|
|
- // let processList = await queryProcess.find()
|
|
|
- // console.log(processList);
|
|
|
- // processList.forEach(i=>{
|
|
|
- // this.manageProfiles[i?.get('name')] = i?.get('profileSubmitted')?.get('user')?.get('name')
|
|
|
- // })
|
|
|
- // }
|
|
|
+ this.textbookList.forEach((item) => {
|
|
|
+ this.statusMap[item.id] = {
|
|
|
+ status: '待上传',
|
|
|
+ color: '#1890ff',
|
|
|
+ btn: '上传',
|
|
|
+ };
|
|
|
+ //是否保存
|
|
|
+ let isSave = item?.get('childrens').some((child: Parse.Object) => {
|
|
|
+ return (
|
|
|
+ this.eduProcess?.get('name') == child?.get('editionUnit') &&
|
|
|
+ child?.get('collectStatus') == '100'
|
|
|
+ );
|
|
|
+ });
|
|
|
+ if (isSave) {
|
|
|
+ this.statusMap[item.id] = {
|
|
|
+ status: '已保存',
|
|
|
+ color: '#20c94e',
|
|
|
+ btn: '编辑',
|
|
|
+ };
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //是否提交
|
|
|
+ let isSbmit = item?.get('childrens').every((child: Parse.Object) => {
|
|
|
+ return (
|
|
|
+ this.eduProcess?.get('name') != child?.get('editionUnit') ||
|
|
|
+ (this.eduProcess?.get('name') == child?.get('editionUnit') &&
|
|
|
+ child?.get('collectStatus') == '200')
|
|
|
+ );
|
|
|
+ });
|
|
|
+ console.log(isSbmit);
|
|
|
+ if (isSbmit) {
|
|
|
+ this.statusMap[item.id] = {
|
|
|
+ status: '已提交',
|
|
|
+ color: '#7a7a7a',
|
|
|
+ btn: false,
|
|
|
+ };
|
|
|
+ }
|
|
|
+ });
|
|
|
console.log(this.textbookList);
|
|
|
this.loading = false;
|
|
|
} catch (err) {
|
|
@@ -192,11 +221,10 @@ export class CollectFileComponent implements OnInit {
|
|
|
this.getTextbook(this.searchValue);
|
|
|
}
|
|
|
//切换分页条数
|
|
|
- onPageSizeChange($event: any): void {
|
|
|
+ onPageSizeChange(): void {
|
|
|
console.log(this.limit);
|
|
|
- // this.onAllChecked(false)
|
|
|
this.pageIndex = 1;
|
|
|
- this.getTextbook();
|
|
|
+ this.getTextbook(this.searchValue);
|
|
|
}
|
|
|
|
|
|
toUrl(url: string, param?: Object) {
|
|
@@ -208,15 +236,37 @@ export class CollectFileComponent implements OnInit {
|
|
|
this.route.navigate([url]);
|
|
|
}
|
|
|
//打开上传弹窗
|
|
|
- onEditModal(data:Parse.Object){
|
|
|
- this.currentTextbook = data
|
|
|
- this.isVisible = true
|
|
|
+ onEditModal(data: Parse.Object) {
|
|
|
+ this.currentTextbook = data;
|
|
|
+ this.isVisible = true;
|
|
|
}
|
|
|
handleCancel(): void {
|
|
|
this.isVisible = false;
|
|
|
this.currentTextbook = undefined;
|
|
|
}
|
|
|
- saveCollect(type:string) {
|
|
|
+ async saveCollect(type: string): Promise<any> {
|
|
|
console.log(type);
|
|
|
+ let isVrifly = await this.saveEduTextbookVolume(type);
|
|
|
+ if (!isVrifly) return this.msg.warning('已保存,填写信息不完整');
|
|
|
+ this.msg.success(type == 'save' ? '保存成功' : '提交成功');
|
|
|
+ this.isVisible = false;
|
|
|
+ this.getTextbook();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**上传分册数据 */
|
|
|
+ async saveEduTextbookVolume(type: string): Promise<any> {
|
|
|
+ let isVrifly = true; //默认都通过,若一项填写未完成,则不通过
|
|
|
+ return Promise.all(
|
|
|
+ this.children.map(async (comp: any) => {
|
|
|
+ let complete = await comp.submitForm(type);
|
|
|
+ if (!complete) {
|
|
|
+ isVrifly = false;
|
|
|
+ }
|
|
|
+ return isVrifly;
|
|
|
+ })
|
|
|
+ ).then((data) => {
|
|
|
+ console.log(isVrifly);
|
|
|
+ return isVrifly;
|
|
|
+ });
|
|
|
}
|
|
|
}
|