|
@@ -1,14 +1,297 @@
|
|
|
-import { Component, OnInit } from '@angular/core';
|
|
|
+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';
|
|
|
|
|
|
@Component({
|
|
|
selector: 'app-review-details',
|
|
|
templateUrl: './review-details.component.html',
|
|
|
styleUrls: ['./review-details.component.scss'],
|
|
|
+ imports: [
|
|
|
+ CommonModule,
|
|
|
+ NzSpaceModule,
|
|
|
+ CommonCompModule,
|
|
|
+ NzMessageModule,
|
|
|
+ NzEmptyModule,
|
|
|
+ NzPopoverModule,
|
|
|
+ ],
|
|
|
+ providers: [DatePipe],
|
|
|
+ standalone: true,
|
|
|
})
|
|
|
-export class ReviewDetailsComponent implements OnInit {
|
|
|
+export class ReviewDetailsComponent implements OnInit {
|
|
|
+ reviewList: Array<Parse.Object> = [];
|
|
|
+ count: number = 0;
|
|
|
+ @Input('limit') limit: number = 10;
|
|
|
+ pageIndex: number = 1;
|
|
|
+ loading: boolean = false;
|
|
|
+ @Input('maxWidth') maxWidth: any; //最大宽度
|
|
|
+ @Input('eduProcess') eduProcess?: Parse.Object; //流程id,verify存在时需要
|
|
|
|
|
|
- constructor() { }
|
|
|
+ @Input('listOfFilter') listOfFilter: Array<any> = []; //评审组
|
|
|
+ @Input('filterObj') filterObj: any = {
|
|
|
+ showGroup: false,
|
|
|
+ contained: [],
|
|
|
+ bookMap: {}, //教材对应评审组结构{booid:评审组名称}
|
|
|
+ };
|
|
|
+ searchValue: string = '';
|
|
|
+ listOfColumns: any = {
|
|
|
+ lang: {
|
|
|
+ // listOfFilter: [{ value: '中文', text: '中文' }],
|
|
|
+ onChange: (data: Array<string>) => {
|
|
|
+ console.log(data);
|
|
|
+ if (data?.length < 1) {
|
|
|
+ this.filterObj.contained = Object.keys(this.filterObj.bookMap);
|
|
|
+ } else {
|
|
|
+ this.filterObj.contained = [];
|
|
|
+ for (const key in this.filterObj.bookMap) {
|
|
|
+ const item = this.filterObj.bookMap[key];
|
|
|
+ if (data.includes(item.id)) {
|
|
|
+ this.filterObj.contained.push(key);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.getTextbook(this.searchValue);
|
|
|
+ },
|
|
|
+ },
|
|
|
+ };
|
|
|
|
|
|
- ngOnInit() {}
|
|
|
+ showLoading: boolean = false; //全局
|
|
|
+ time: any;
|
|
|
|
|
|
+ constructor(
|
|
|
+ private activeRoute: ActivatedRoute,
|
|
|
+ public tbookSer: textbookServer,
|
|
|
+ private router: Router,
|
|
|
+ private msg: NzMessageService,
|
|
|
+ public dialog: MatDialog,
|
|
|
+ private route: Router,
|
|
|
+ private datePipe: DatePipe,
|
|
|
+ private modal: NzModalService
|
|
|
+ ) {}
|
|
|
+
|
|
|
+ ngOnInit() {
|
|
|
+ this.getTextbook();
|
|
|
+ }
|
|
|
+ async getTextbook(val?: string, exported?: boolean): Promise<any[] | void> {
|
|
|
+ if (this.loading) return;
|
|
|
+ if(!exported) this.loading = true;
|
|
|
+ try {
|
|
|
+ let queryParams: any = {
|
|
|
+ where: {
|
|
|
+ $or: [
|
|
|
+ {
|
|
|
+ eduTextbook: {
|
|
|
+ $inQuery: {
|
|
|
+ where: {
|
|
|
+ $or: [
|
|
|
+ {
|
|
|
+ title: { $regex: `.*${val || ''}.*` },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ childrens: {
|
|
|
+ $inQuery: {
|
|
|
+ where: {
|
|
|
+ $or: [
|
|
|
+ {
|
|
|
+ ISBN: { $regex: `.*${val || ''}.*` },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ author: { $regex: `.*${val || ''}.*` },
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ className: 'EduTextbookVolume',
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ className: 'EduTextbook',
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ profile: {
|
|
|
+ $inQuery: {
|
|
|
+ where: {
|
|
|
+ $or: [
|
|
|
+ {
|
|
|
+ user: {
|
|
|
+ $inQuery: {
|
|
|
+ where: {
|
|
|
+ $or: [
|
|
|
+ {
|
|
|
+ name: { $regex: `.*${val || ''}.*` },
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ className: '_User',
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ className: 'Profile',
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ eduTextbook: { $in: this.filterObj.contained },
|
|
|
+ },
|
|
|
+ };
|
|
|
+ let query = Parse.Query.fromJSON('EduReview', queryParams);
|
|
|
+ this.eduProcess?.id && query.equalTo('eduProcess', this.eduProcess.id);
|
|
|
+ query.descending('updatedAt');
|
|
|
+ query.notEqualTo('isDeleted', true);
|
|
|
+ query.include('eduTextbook', 'profile', 'profile.user');
|
|
|
+ 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.reviewList = await query.find();
|
|
|
+ console.log(this.reviewList);
|
|
|
+ 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 export() {
|
|
|
+ if (this.showLoading) return;
|
|
|
+ this.showLoading = true;
|
|
|
+ try {
|
|
|
+ let data: any = await this.getTextbook('', true);
|
|
|
+ let table = `<table border="1px" cellspacing="0" cellpadding="0">
|
|
|
+ <thead>
|
|
|
+ <tr>
|
|
|
+ <th>序号</th>
|
|
|
+ <th>申报教材名称</th>
|
|
|
+ <th>所属评审组</th>
|
|
|
+ ${this.filterObj.showGroup ? '<th>评审专家</th>' : ''}
|
|
|
+ <th>提交时间</th>
|
|
|
+ <th>分值</th>
|
|
|
+ </tr>
|
|
|
+ </thead>
|
|
|
+ <tbody>
|
|
|
+ `;
|
|
|
+ let _body = '';
|
|
|
+ for (var row = 0; row < data.length; row++) {
|
|
|
+ _body += '<tr>';
|
|
|
+ _body += '<td>';
|
|
|
+ _body += `${row + 1}`;
|
|
|
+ _body += '</td>';
|
|
|
+
|
|
|
+ _body += '<td>';
|
|
|
+ _body += ` ${data[row]?.get('eduTextbook')?.get('title') || ''}`;
|
|
|
+ _body += '</td>';
|
|
|
+
|
|
|
+ if(this.filterObj.showGroup){
|
|
|
+ _body += '<td>';
|
|
|
+ _body += ` ${
|
|
|
+ this.filterObj.bookMap[data[row]?.get('eduTextbook')?.id].name || '-'
|
|
|
+ }`;
|
|
|
+ _body += '</td>';
|
|
|
+ }
|
|
|
+
|
|
|
+ _body += '<td>';
|
|
|
+ _body += `${
|
|
|
+ data[row]?.get('profile')?.get('user')?.get('name') || '-'
|
|
|
+ }`;
|
|
|
+ _body += '</td>';
|
|
|
+
|
|
|
+ _body += '<td>';
|
|
|
+ _body += ` ${this.datePipe.transform(
|
|
|
+ data[row]?.updatedAt,
|
|
|
+ 'yyyy-MM-dd HH:mm:ss'
|
|
|
+ )}`;
|
|
|
+ _body += '</td>';
|
|
|
+
|
|
|
+ _body += '<td>';
|
|
|
+ _body += `${data[row]?.get('score') ?? '-'}`;
|
|
|
+ _body += '</td>';
|
|
|
+
|
|
|
+ _body += '</tr>';
|
|
|
+ }
|
|
|
+ table += _body;
|
|
|
+ table += '</tbody>';
|
|
|
+ table += '</table>';
|
|
|
+ let title = '评审详情表';
|
|
|
+ this.excel(table, `${title}.xls`);
|
|
|
+ this.showLoading = false;
|
|
|
+ } catch (err) {
|
|
|
+ console.log(err);
|
|
|
+ this.showLoading = false;
|
|
|
+ this.msg.error('导出超时');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ excel(data: any, filename: string) {
|
|
|
+ let html =
|
|
|
+ "<html xmlns:o='urn:schemas-microsoft-com:office:office' xmlns:x='urn:schemas-microsoft-com:office:excel' xmlns='http://www.w3.org/TR/REC-html40'>";
|
|
|
+ html +=
|
|
|
+ '<meta http-equiv="content-type" content="application/vnd.ms-excel; charset=UTF-8">';
|
|
|
+ html += '<meta http-equiv="content-type" content="application/vnd.ms-excel';
|
|
|
+ html += '; charset=UTF-8">';
|
|
|
+ html += '<head>';
|
|
|
+ html += '</head>';
|
|
|
+ html += '<body>';
|
|
|
+ html += data;
|
|
|
+ html += '</body>';
|
|
|
+ html += '</html>';
|
|
|
+ let uri =
|
|
|
+ 'data:application/vnd.ms-excel;charset=utf-8,' + encodeURIComponent(html);
|
|
|
+ let link = document.createElement('a');
|
|
|
+ link.href = uri;
|
|
|
+ link.download = `${filename}`;
|
|
|
+ document.body.appendChild(link);
|
|
|
+ link.click();
|
|
|
+ document.body.removeChild(link);
|
|
|
+ }
|
|
|
}
|