|
@@ -10,6 +10,15 @@ import { MatButtonModule } from '@angular/material/button';
|
|
|
import { NzRadioModule } from 'ng-zorro-antd/radio';
|
|
|
import { DatePipe } from '@angular/common';
|
|
|
import { NzEmptyModule } from 'ng-zorro-antd/empty';
|
|
|
+import * as major from '../../services/majors.map';
|
|
|
+interface filter {
|
|
|
+ lang: any;
|
|
|
+ majorPoniter: any;
|
|
|
+ editionUnit: any;
|
|
|
+ approval: any;
|
|
|
+ carrierShape: any;
|
|
|
+ department: any;
|
|
|
+}
|
|
|
@Component({
|
|
|
selector: 'app-textbook',
|
|
|
templateUrl: './textbook.component.html',
|
|
@@ -28,7 +37,7 @@ import { NzEmptyModule } from 'ng-zorro-antd/empty';
|
|
|
export class TextbookComponent implements OnInit {
|
|
|
textbookList: Array<Parse.Object> = [];
|
|
|
count: number = 0;
|
|
|
- limit: number = 10;
|
|
|
+ @Input('limit') limit: number = 10;
|
|
|
pageSize: number = 1;
|
|
|
|
|
|
@Input('maxWidth') maxWidth: any; //最大宽度
|
|
@@ -37,8 +46,11 @@ export class TextbookComponent implements OnInit {
|
|
|
@Input('uid') uid: string = ''; //个人空间
|
|
|
@Input('path') path: string = '/nav-admin/manage/textbook/details';
|
|
|
@Input('discard') discard: Boolean = false; //是否删除
|
|
|
+ @Input('eduProcessId') eduProcessId: any = ''; //流程id,verify存在时需要
|
|
|
+
|
|
|
//相关权限配置
|
|
|
@Input('filterObj') filterObj: any = {
|
|
|
+ showMore: false, //显示更多字段
|
|
|
isCheck: true,
|
|
|
noStared: false, //非推荐
|
|
|
status: [],
|
|
@@ -50,16 +62,92 @@ export class TextbookComponent implements OnInit {
|
|
|
star: false, //加入推荐
|
|
|
remove: false, //移除推荐
|
|
|
submit: false, //提交
|
|
|
+ export:false,
|
|
|
verify: false, //提交推荐权限
|
|
|
},
|
|
|
};
|
|
|
-
|
|
|
+ listOfColumns: any = {
|
|
|
+ lang: {
|
|
|
+ listOfFilter: [
|
|
|
+ { value: '中文', text: '中文' },
|
|
|
+ { value: '英语', text: '英语' },
|
|
|
+ { value: '其他外国语', text: '其他外国语' },
|
|
|
+ { value: '中国少数名族语言', text: '中国少数名族语言' },
|
|
|
+ ],
|
|
|
+ onChange: (data: any) => {
|
|
|
+ console.log(data);
|
|
|
+ this.filters.lang.value = data;
|
|
|
+ this.onFilter()
|
|
|
+ },
|
|
|
+ },
|
|
|
+ majorPoniter: {
|
|
|
+ listOfFilter: [],
|
|
|
+ onChange: (data: any) => {
|
|
|
+ console.log(data);
|
|
|
+ this.filters.majorPoniter.value = data;
|
|
|
+ this.onFilter()
|
|
|
+ },
|
|
|
+ },
|
|
|
+ editionUnit: {
|
|
|
+ listOfFilter: [],
|
|
|
+ onChange: (data: any) => {
|
|
|
+ console.log(data);
|
|
|
+ this.filters.editionUnit.value = data;
|
|
|
+ this.onFilter()
|
|
|
+ },
|
|
|
+ },
|
|
|
+ approval: {
|
|
|
+ listOfFilter: [
|
|
|
+ {
|
|
|
+ value: '基础学科“101计划”核心教材',
|
|
|
+ text: '基础学科“101计划”核心教材',
|
|
|
+ },
|
|
|
+ { value: '战略性新兴领域教材', text: '战略性新兴领域教材' },
|
|
|
+ { value: '“四新”重点建设教材', text: '“四新”重点建设教材' },
|
|
|
+ { value: '否', text: '否' },
|
|
|
+ ],
|
|
|
+ onChange: (data: any) => {
|
|
|
+ console.log(data);
|
|
|
+ this.filters.approval.value = data;
|
|
|
+ this.onFilter()
|
|
|
+ },
|
|
|
+ },
|
|
|
+ carrierShape: {
|
|
|
+ listOfFilter: [
|
|
|
+ { value: '纸质教材', text: '纸质教材' },
|
|
|
+ { value: '电子教材', text: '电子教材' },
|
|
|
+ { value: '纸质教材附带电子资源', text: '纸质教材附带电子资源' },
|
|
|
+ ],
|
|
|
+ onChange: (data: any) => {
|
|
|
+ console.log(data);
|
|
|
+ this.filters.carrierShape.value = data;
|
|
|
+ this.onFilter()
|
|
|
+ },
|
|
|
+ },
|
|
|
+ department: {
|
|
|
+ listOfFilter: [],
|
|
|
+ onChange: (data: any) => {
|
|
|
+ console.log(data);
|
|
|
+ this.filters.department.value = data;
|
|
|
+ this.onFilter()
|
|
|
+ },
|
|
|
+ },
|
|
|
+ };
|
|
|
+ //筛选条件
|
|
|
+ filters: filter | any = {
|
|
|
+ lang: { type: 'string', value: [] },
|
|
|
+ majorPoniter: { type: 'string', value: [] },
|
|
|
+ editionUnit: { type: 'string', value: [] },
|
|
|
+ approval: { type: 'string', value: [] },
|
|
|
+ carrierShape: { type: 'string', value: [] },
|
|
|
+ department: { type: 'pointer', value: [] },
|
|
|
+ };
|
|
|
loading: boolean = false;
|
|
|
checkedAll: boolean = false; //全选
|
|
|
setOfCheckedId = new Set<string>();
|
|
|
searchValue: string = '';
|
|
|
manage: boolean = false;
|
|
|
- eduProcessId: any = ''; //流程id,verify存在时需要
|
|
|
+
|
|
|
constructor(
|
|
|
public tbookSer: textbookServer,
|
|
|
private route: Router,
|
|
@@ -70,11 +158,23 @@ export class TextbookComponent implements OnInit {
|
|
|
|
|
|
ngOnInit() {
|
|
|
this.activeRoute.paramMap.subscribe(async (params) => {
|
|
|
- this.eduProcessId = params.get('id');
|
|
|
+ // this.eduProcessId = params.get('id');
|
|
|
this.getTextbook();
|
|
|
if (Object.values(this.filterObj.btns).some((item) => item)) {
|
|
|
this.manage = true;
|
|
|
}
|
|
|
+ if (this.filterObj.showMore) {
|
|
|
+ this.listOfColumns.majorPoniter.listOfFilter = major.majors.options.map(
|
|
|
+ (item) => {
|
|
|
+ return { text: item.name, value: item.name };
|
|
|
+ }
|
|
|
+ );
|
|
|
+ this.listOfColumns.editionUnit.listOfFilter =
|
|
|
+ await this.getDepartment();
|
|
|
+ this.listOfColumns.department.listOfFilter = await this.getDepartment(
|
|
|
+ true
|
|
|
+ );
|
|
|
+ }
|
|
|
});
|
|
|
}
|
|
|
async getTextbook(val?: string, exported?: boolean): Promise<any[] | void> {
|
|
@@ -102,11 +202,18 @@ export class TextbookComponent implements OnInit {
|
|
|
query = Parse.Query.or(query1, query2);
|
|
|
}
|
|
|
// this.uid && query.equalTo('user',this.tbookSer.profile.user?.objectId);
|
|
|
+ for (const key in this.filters) {
|
|
|
+ const element = this.filters[key];
|
|
|
+ if (element.value?.length > 0) {
|
|
|
+ query.containedIn(key, element.value);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.eduProcessId && query.equalTo('eduProcess', this.eduProcessId);
|
|
|
this.depart && query.equalTo('department', this.depart);
|
|
|
this.recommend && query.equalTo('recommend', true);
|
|
|
this.filterObj?.noStared && query.notEqualTo('recommend', true);
|
|
|
this.uid && query.equalTo('user', this.uid);
|
|
|
- query.descending('createdAt')
|
|
|
+ query.descending('createdAt');
|
|
|
query.notEqualTo('isDeleted', true);
|
|
|
if (!this.uid) {
|
|
|
query.equalTo('render', true);
|
|
@@ -125,7 +232,7 @@ export class TextbookComponent implements OnInit {
|
|
|
this.loading = false;
|
|
|
return r;
|
|
|
}
|
|
|
- // query.include('department');
|
|
|
+ query.include('department');
|
|
|
this.count = await query.count();
|
|
|
query.limit(this.limit);
|
|
|
query.skip(this.limit * (this.pageSize - 1));
|
|
@@ -134,6 +241,41 @@ export class TextbookComponent implements OnInit {
|
|
|
console.log(this.textbookList);
|
|
|
this.loading = false;
|
|
|
}
|
|
|
+ async getDepartment(all?: boolean): Promise<any> {
|
|
|
+ let arr: { value: any; text: any }[] = [];
|
|
|
+ let filters = [
|
|
|
+ '66865e1c5d561921fb4d6764',
|
|
|
+ '66865deea3ac903090a7b30b',
|
|
|
+ '66865dac288c15c56afd80fa',
|
|
|
+ '66865d66ad23a23355b12aa7',
|
|
|
+ ];
|
|
|
+ if (this.tbookSer.profile.identity != '国家级管理员') {
|
|
|
+ filters = [this.tbookSer.profile.user?.department?.objectId];
|
|
|
+ }
|
|
|
+ let query = new Parse.Query('Department');
|
|
|
+ query.select('name');
|
|
|
+ query.notEqualTo('isDeleted', true);
|
|
|
+ if (all) {
|
|
|
+ query.containedIn('parent', filters);
|
|
|
+ } else {
|
|
|
+ query.equalTo('parent', '66865d66ad23a23355b12aa7');
|
|
|
+ }
|
|
|
+ query.limit(2000);
|
|
|
+ let r = await query.find();
|
|
|
+ r.forEach((item) => {
|
|
|
+ arr.push({
|
|
|
+ value: all ? item.id : item?.get('name'),
|
|
|
+ text: item?.get('name'),
|
|
|
+ });
|
|
|
+ });
|
|
|
+ return arr;
|
|
|
+ }
|
|
|
+ //筛选
|
|
|
+ onFilter(){
|
|
|
+ this.textbookList = []
|
|
|
+ this.pageSize = 1
|
|
|
+ this.getTextbook(this.searchValue)
|
|
|
+ }
|
|
|
onSearch(e: string) {
|
|
|
console.log(e);
|
|
|
this.getTextbook(e);
|
|
@@ -180,6 +322,7 @@ export class TextbookComponent implements OnInit {
|
|
|
nzOnOk: async () => {
|
|
|
if (data?.id) {
|
|
|
data.set('status', '300');
|
|
|
+ data.set('code', null);
|
|
|
await data.save();
|
|
|
} else {
|
|
|
let selectedList = this.textbookList.filter((item: any) =>
|
|
@@ -188,6 +331,7 @@ export class TextbookComponent implements OnInit {
|
|
|
let deletePromiseList = selectedList.map((item: any) => {
|
|
|
return new Promise((resolve) => {
|
|
|
item.set('status', '300');
|
|
|
+ item.set('code', null);
|
|
|
item.save().then(() => resolve(true));
|
|
|
});
|
|
|
});
|
|
@@ -196,6 +340,7 @@ export class TextbookComponent implements OnInit {
|
|
|
} catch (err) {}
|
|
|
}
|
|
|
this.getTextbook();
|
|
|
+ this.onAllChecked(false);
|
|
|
},
|
|
|
nzCancelText: '取消',
|
|
|
nzOnCancel: () => console.log('Cancel'),
|
|
@@ -229,6 +374,7 @@ export class TextbookComponent implements OnInit {
|
|
|
} catch (err) {}
|
|
|
}
|
|
|
this.getTextbook();
|
|
|
+ this.onAllChecked(false);
|
|
|
},
|
|
|
nzCancelText: '取消',
|
|
|
nzOnCancel: () => console.log('Cancel'),
|
|
@@ -270,12 +416,14 @@ export class TextbookComponent implements OnInit {
|
|
|
}
|
|
|
//提交教材
|
|
|
async submit(data?: Parse.Object) {
|
|
|
- let parentMap = await this.tbookSer.formatNode(this.tbookSer?.profile?.user?.department?.objectId);
|
|
|
+ let parentMap = await this.tbookSer.formatNode(
|
|
|
+ this.tbookSer?.profile?.user?.department?.objectId
|
|
|
+ );
|
|
|
console.log(parentMap);
|
|
|
- let processId = await this.getEduProcess(parentMap[1]?.key)
|
|
|
- if(!processId){
|
|
|
- this.message.warning('你的申报单位暂无进行的流程')
|
|
|
- return
|
|
|
+ let processId = await this.getEduProcess(parentMap[1]?.key);
|
|
|
+ if (!processId) {
|
|
|
+ this.message.warning('你的申报单位暂无进行的流程');
|
|
|
+ return;
|
|
|
}
|
|
|
this.modal.confirm({
|
|
|
nzTitle: '提交教材',
|
|
@@ -285,54 +433,69 @@ export class TextbookComponent implements OnInit {
|
|
|
nzOkDanger: false,
|
|
|
nzOnOk: async () => {
|
|
|
if (data?.id) {
|
|
|
+ if (data?.get('status') != '102' || data?.get('status') != '300') {
|
|
|
+ this.message.warning('教材信息填写不完整');
|
|
|
+ return;
|
|
|
+ }
|
|
|
let t =
|
|
|
this.tbookSer.formatTime('YYYYmmdd', new Date()) +
|
|
|
Math.random().toString().slice(-4);
|
|
|
data.set('render', true);
|
|
|
data.set('status', '200');
|
|
|
data.set('code', t);
|
|
|
- data.set('eduProcess',{
|
|
|
+ data.set('eduProcess', {
|
|
|
__type: 'Pointer',
|
|
|
className: 'EduProcess',
|
|
|
- objectId:processId
|
|
|
+ objectId: processId,
|
|
|
});
|
|
|
- if(parentMap[1]?.key){
|
|
|
+ if (parentMap[1]?.key) {
|
|
|
data.set('department', {
|
|
|
__type: 'Pointer',
|
|
|
className: 'Department',
|
|
|
- objectId:parentMap[1]?.key
|
|
|
+ objectId: parentMap[1]?.key,
|
|
|
});
|
|
|
}
|
|
|
await data.save();
|
|
|
} else {
|
|
|
+ let count = 0;
|
|
|
let selectedList = this.textbookList.filter((item: any) =>
|
|
|
this.setOfCheckedId.has(item?.id)
|
|
|
);
|
|
|
let deletePromiseList = selectedList.map((item: any) => {
|
|
|
return new Promise((resolve) => {
|
|
|
- let t =
|
|
|
- this.tbookSer.formatTime('YYYYmmdd', new Date()) +
|
|
|
- Math.random().toString().slice(-4);
|
|
|
- item.set('render', true);
|
|
|
- item.set('status', '200');
|
|
|
- item.set('code', t);
|
|
|
- item.set('eduProcess',{
|
|
|
- __type: 'Pointer',
|
|
|
- className: 'EduProcess',
|
|
|
- objectId:processId
|
|
|
- });
|
|
|
- if(parentMap[1]?.key){
|
|
|
- item.set('department', {
|
|
|
+ if (
|
|
|
+ data?.get('status') == '102' ||
|
|
|
+ data?.get('status') == '300'
|
|
|
+ ) {
|
|
|
+ count++;
|
|
|
+ let t =
|
|
|
+ this.tbookSer.formatTime('YYYYmmdd', new Date()) +
|
|
|
+ Math.random().toString().slice(-4);
|
|
|
+ item.set('render', true);
|
|
|
+ item.set('status', '200');
|
|
|
+ item.set('code', t);
|
|
|
+ item.set('eduProcess', {
|
|
|
__type: 'Pointer',
|
|
|
- className: 'Department',
|
|
|
- objectId:parentMap[1]?.key
|
|
|
+ className: 'EduProcess',
|
|
|
+ objectId: processId,
|
|
|
});
|
|
|
+ if (parentMap[1]?.key) {
|
|
|
+ item.set('department', {
|
|
|
+ __type: 'Pointer',
|
|
|
+ className: 'Department',
|
|
|
+ objectId: parentMap[1]?.key,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ item.save().then(() => resolve(true));
|
|
|
+ } else {
|
|
|
+ resolve(true);
|
|
|
}
|
|
|
- item.save().then(() => resolve(true));
|
|
|
});
|
|
|
});
|
|
|
try {
|
|
|
await Promise.all(deletePromiseList);
|
|
|
+ this.message.success('成功提交' + count + '条教材');
|
|
|
+ this.onAllChecked(false);
|
|
|
} catch (err) {}
|
|
|
}
|
|
|
this.getTextbook();
|
|
@@ -341,17 +504,33 @@ export class TextbookComponent implements OnInit {
|
|
|
nzOnCancel: () => console.log('Cancel'),
|
|
|
});
|
|
|
}
|
|
|
- async getEduProcess(id:string):Promise<string|undefined>{
|
|
|
- if(!id) return
|
|
|
- let query = new Parse.Query('EduProcess')
|
|
|
- query.equalTo('department',id)
|
|
|
- query.lessThanOrEqualTo('startDate',new Date())
|
|
|
- query.greaterThan('deadline',new Date())
|
|
|
- query.notEqualTo('isDeleted',true)
|
|
|
- query.notEqualTo('status','100')
|
|
|
- query.select('objectId')
|
|
|
- let res = await query.first()
|
|
|
- return res?.id
|
|
|
+ async getEduProcess(id: string): Promise<string | undefined> {
|
|
|
+ if (!id) return;
|
|
|
+ let query = new Parse.Query('EduProcess');
|
|
|
+ query.equalTo('department', id);
|
|
|
+ query.lessThanOrEqualTo('startDate', new Date());
|
|
|
+ query.greaterThan('deadline', new Date());
|
|
|
+ query.notEqualTo('isDeleted', true);
|
|
|
+ query.notEqualTo('status', '100');
|
|
|
+ query.select('objectId');
|
|
|
+ let res = await query.first();
|
|
|
+ return res?.id;
|
|
|
+ }
|
|
|
+ //导出
|
|
|
+ async exportProcess(data?:Parse.Object){
|
|
|
+ let processId = await this.getEduProcess(this.tbookSer.profile.user?.department?.objectId);
|
|
|
+ Parse.Cloud.run('tbookExportReport', { processId: processId }).then(
|
|
|
+ (data) => {
|
|
|
+ console.log(data);
|
|
|
+ let url = data.zipUrl;
|
|
|
+ const a = document.createElement('a'); // 创建一个<a>元素
|
|
|
+ a.href = url; // 设置链接的href属性为要下载的文件的URL
|
|
|
+ a.download = '报送流程'; // 设置下载文件的名称
|
|
|
+ document.body.appendChild(a); // 将<a>元素添加到文档中
|
|
|
+ a.click(); // 模拟点击<a>元素
|
|
|
+ document.body.removeChild(a); // 下载后移除<a>元素
|
|
|
+ }
|
|
|
+ );
|
|
|
}
|
|
|
toUrl(url: string, param?: Object) {
|
|
|
console.log(url);
|