|
@@ -0,0 +1,236 @@
|
|
|
+import { Component, Input, OnInit } from '@angular/core';
|
|
|
+import { CommonModule } from '@angular/common';
|
|
|
+import { NzSpaceModule } from 'ng-zorro-antd/space';
|
|
|
+import { CommonCompModule } from '../../../../services/common.modules';
|
|
|
+import { ActivatedRoute, Router } from '@angular/router';
|
|
|
+import { NzMessageModule } from 'ng-zorro-antd/message';
|
|
|
+import { NzMessageService } from 'ng-zorro-antd/message';
|
|
|
+import Parse from 'parse';
|
|
|
+// import { textbookServer } from '../../../../services/textbook';
|
|
|
+import { NzModalService } from 'ng-zorro-antd/modal';
|
|
|
+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 { setHours } from 'date-fns';
|
|
|
+import { NzDatePickerModule } from 'ng-zorro-antd/date-picker';
|
|
|
+@Component({
|
|
|
+ selector: 'app-collect-textbook',
|
|
|
+ templateUrl: './collect-textbook.component.html',
|
|
|
+ styleUrls: ['./collect-textbook.component.scss'],
|
|
|
+ imports: [
|
|
|
+ CommonModule,
|
|
|
+ NzSpaceModule,
|
|
|
+ CommonCompModule,
|
|
|
+ NzMessageModule,
|
|
|
+ NzEmptyModule,
|
|
|
+ NzPopoverModule,
|
|
|
+ NzDatePickerModule
|
|
|
+ ],
|
|
|
+ providers: [DatePipe],
|
|
|
+ standalone: true,
|
|
|
+})
|
|
|
+export class CollectTextbookComponent implements OnInit {
|
|
|
+ textbookList: Array<Parse.Object> = [];
|
|
|
+ count: number = 0;
|
|
|
+ timeDefaultValue = setHours(new Date(), 0);
|
|
|
+
|
|
|
+ @Input('limit') limit: number = 10;
|
|
|
+ pageIndex: number = 1;
|
|
|
+ loading: boolean = false;
|
|
|
+ @Input('maxWidth') maxWidth: any; //最大宽度
|
|
|
+ @Input('eduProcess') eduProcess?: Parse.Object; //流程id
|
|
|
+
|
|
|
+ // @Input('filterObj') filterObj: any = {
|
|
|
+ // contained: [],
|
|
|
+ // };
|
|
|
+
|
|
|
+ showModal: boolean = false;
|
|
|
+ textBookList: Array<Parse.Object> = []; //流程教材列表(推荐)
|
|
|
+ collectStartData: any;
|
|
|
+ collectEndData: any;
|
|
|
+
|
|
|
+ searchValue: string = '';
|
|
|
+ time: any;
|
|
|
+ showLoading: boolean = false; //全局
|
|
|
+ /* 格式化拓展表字段 */
|
|
|
+ fromatFiled(list: Array<Parse.Object>, filed: string): string {
|
|
|
+ let arr: Array<string | null> = [];
|
|
|
+ let isDate = false;
|
|
|
+ list.forEach((item: Parse.Object) => {
|
|
|
+ if (
|
|
|
+ isDate ||
|
|
|
+ Object.prototype.toString.call(item.get(filed)).indexOf('Date') != -1
|
|
|
+ ) {
|
|
|
+ arr.push(this.datePipe.transform(item.get(filed), 'yyyy-MM'));
|
|
|
+ isDate = true;
|
|
|
+ } else {
|
|
|
+ arr.push(item.get(filed));
|
|
|
+ }
|
|
|
+ });
|
|
|
+ let j = Array.from(arr).join(',');
|
|
|
+ if (!isDate) {
|
|
|
+ j = Array.from(new Set(arr)).join(' ');
|
|
|
+ }
|
|
|
+ return j || '-';
|
|
|
+ }
|
|
|
+ manageProfiles:any = {}
|
|
|
+
|
|
|
+ formatMapProfile(list:Array<Parse.Object>):Array<string>{
|
|
|
+ let arr:Array<string> = []
|
|
|
+ list.forEach(item=>{
|
|
|
+ arr.push(this.manageProfiles[item?.get('editionUnit')])
|
|
|
+ })
|
|
|
+ return [...new Set(arr)]
|
|
|
+ }
|
|
|
+
|
|
|
+ constructor(
|
|
|
+ // private activeRoute: ActivatedRoute,
|
|
|
+ // public tbookSer: textbookServer,
|
|
|
+ private msg: NzMessageService,
|
|
|
+ public dialog: MatDialog,
|
|
|
+ private route: Router,
|
|
|
+ private datePipe: DatePipe,
|
|
|
+ private modal: NzModalService
|
|
|
+ ) {}
|
|
|
+
|
|
|
+ ngOnInit() {
|
|
|
+ this.getTextbook();
|
|
|
+ }
|
|
|
+ async getTextbook(val?: string, review?: boolean): Promise<any[] | void> {
|
|
|
+ if (this.loading) return;
|
|
|
+ this.loading = true;
|
|
|
+ try {
|
|
|
+ let queryParams: any = {
|
|
|
+ where: {
|
|
|
+ $or: [
|
|
|
+ {
|
|
|
+ title: { $regex: `.*${val || ''}.*` },
|
|
|
+ code: { $regex: `.*${val || ''}.*` },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ childrens: {
|
|
|
+ $inQuery: {
|
|
|
+ where: {
|
|
|
+ $or: [
|
|
|
+ {
|
|
|
+ ISBN: { $regex: `.*${val || ''}.*` },
|
|
|
+ },
|
|
|
+ // {
|
|
|
+ // author: { $regex: `.*${val || ''}.*` },
|
|
|
+ // },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ className: 'EduTextbookVolume',
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ };
|
|
|
+ let query = Parse.Query.fromJSON('EduTextbook', queryParams);
|
|
|
+ query.equalTo('eduProcess', this.eduProcess?.id);
|
|
|
+ query.descending('updatedAt');
|
|
|
+ query.notEqualTo('isDeleted', true);
|
|
|
+ query.equalTo('status', '400');
|
|
|
+ query.equalTo('recommend', true);
|
|
|
+ query.notEqualTo('discard', true);
|
|
|
+ // query.exists('score');
|
|
|
+ // query.equalTo('verify', true);
|
|
|
+ query.include('childrens');
|
|
|
+ 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')
|
|
|
+ })
|
|
|
+ }
|
|
|
+ console.log(this.textbookList);
|
|
|
+ this.loading = false;
|
|
|
+ } catch (err) {
|
|
|
+ console.warn(err);
|
|
|
+ this.msg.error('获取超时');
|
|
|
+ }
|
|
|
+ this.loading = false;
|
|
|
+ }
|
|
|
+ onSearch(e: string) {
|
|
|
+ this.pageIndex = 1;
|
|
|
+ console.log(e);
|
|
|
+ if (this.time) clearTimeout(this.time);
|
|
|
+ this.time = setTimeout(() => {
|
|
|
+ this.getTextbook(e);
|
|
|
+ }, 500);
|
|
|
+ }
|
|
|
+ //分页切换
|
|
|
+ pageIndexChange(e: any) {
|
|
|
+ console.log(e);
|
|
|
+ this.pageIndex = e;
|
|
|
+ this.getTextbook(this.searchValue);
|
|
|
+ }
|
|
|
+ //切换分页条数
|
|
|
+ onPageSizeChange($event: any): void {
|
|
|
+ console.log(this.limit);
|
|
|
+ // this.onAllChecked(false)
|
|
|
+ this.pageIndex = 1;
|
|
|
+ this.getTextbook();
|
|
|
+ }
|
|
|
+
|
|
|
+ toUrl(url: string, param?: Object) {
|
|
|
+ console.log(url);
|
|
|
+ if (param) {
|
|
|
+ this.route.navigate([url, param]);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.route.navigate([url]);
|
|
|
+ }
|
|
|
+
|
|
|
+ //打开编辑收集文件弹窗
|
|
|
+ async openEditCollect() {
|
|
|
+ this.collectStartData = this.eduProcess?.get('collectStartData');
|
|
|
+ this.collectEndData = this.eduProcess?.get('collectEndData');
|
|
|
+ this.pageIndex = 1;
|
|
|
+ this.searchValue = ''
|
|
|
+ this.getTextbook();
|
|
|
+
|
|
|
+ this.showModal = true;
|
|
|
+ }
|
|
|
+ handleCancel(): void {
|
|
|
+ this.showModal = false
|
|
|
+ }
|
|
|
+ //保存收集文件设置
|
|
|
+ async editCollect() {
|
|
|
+ if (
|
|
|
+ !this.collectStartData ||
|
|
|
+ !this.collectEndData ||
|
|
|
+ this.collectStartData > this.collectEndData
|
|
|
+ ) {
|
|
|
+ this.msg.warning('请设置正确的开始和截止时间');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.eduProcess?.set('collectStartData', this.collectStartData);
|
|
|
+ this.eduProcess?.set('collectEndData', this.collectEndData);
|
|
|
+ await this.eduProcess?.save();
|
|
|
+ this.msg.success('设置成功');
|
|
|
+ this.showModal = false;
|
|
|
+ }
|
|
|
+}
|