|
@@ -22,7 +22,9 @@ import {
|
|
|
AbstractControl,
|
|
|
} from '@angular/forms';
|
|
|
import { textbookServer } from '../../../../services/textbook';
|
|
|
-// import * as eduTextBook from '../../../../../../../server/db/schemas/'
|
|
|
+import * as eduTextBook from '../../../../services/EduTextbook'
|
|
|
+import { HttpClient } from '@angular/common/http';
|
|
|
+
|
|
|
@Component({
|
|
|
selector: 'app-attachment',
|
|
|
imports: [
|
|
@@ -91,7 +93,8 @@ export class AttachmentComponent implements OnInit {
|
|
|
constructor(
|
|
|
public tbookSer: textbookServer,
|
|
|
private msg: NzMessageService,
|
|
|
- private modal: NzModalService
|
|
|
+ private modal: NzModalService,
|
|
|
+ private http: HttpClient
|
|
|
) { }
|
|
|
ngOnInit() {
|
|
|
if (this.eduTextbook.id) {
|
|
@@ -156,21 +159,37 @@ export class AttachmentComponent implements OnInit {
|
|
|
|
|
|
/**判断是否存在未填字段 */
|
|
|
isIgnoreFiledNull() {
|
|
|
+ let selectList = this.eduTextbook?.get('characteristic')
|
|
|
+ let check = false
|
|
|
+ for(let i in selectList){
|
|
|
+ if(selectList[i].label=='通识课'||selectList[i].label=='公共基础课'||selectList[i].label=='专业课'){
|
|
|
+ if(selectList[i].checked) {
|
|
|
+ check=true
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!check){
|
|
|
+ this.msg.create('warning','请返回选择适用课程性质')
|
|
|
+ return true
|
|
|
+ }
|
|
|
|
|
|
- // eduColumn =
|
|
|
+ let eduColumn = eduTextBook.EduTextbook.fields
|
|
|
let ignoreFiled = [
|
|
|
- 'typeNumber', 'editionNumber', 'importantProjectOther',
|
|
|
+ 'typeNumber', 'code','editionNumber', 'importantProjectOther',
|
|
|
'textbookFiles', 'createdAt', 'updatedAt', 'copyright', 'authorSign',
|
|
|
'CIP', 'isDeleted', 'opinions', 'printNumber', 'printSum', 'render',
|
|
|
'importantProject', 'importantProjectOther', 'complete', 'links', 'recommend',
|
|
|
'printSun', 'discard', 'edition', 'eduProcess', 'authors', 'editor',
|
|
|
- 'copyrightImgUrl', 'CIPImgUrl', 'selfResults', 'expertOpinion', 'evidence',
|
|
|
- 'moreMaterial', 'unitMaterial','approvedImgUrl'
|
|
|
+ 'copyrightImgUrl', 'CIPImgurl', 'selfResults', 'expertOpinion', 'evidence',
|
|
|
+ 'moreMaterial', 'unitMaterial','approvedImgUrl','department'
|
|
|
] //非必填字段
|
|
|
let textBookJson = this.eduTextbook.toJSON()
|
|
|
- let isVrifly = Object.keys(textBookJson).some((item: string) => {
|
|
|
+
|
|
|
+
|
|
|
+ let isVrifly = Object.keys(eduColumn).some((item: string) => {
|
|
|
if (!ignoreFiled.includes(item) && (textBookJson[item] === '' || textBookJson[item] === undefined || textBookJson[item] === null)) {
|
|
|
- console.warn('字段未填写:' + item);
|
|
|
+ console.warn('字段未填写:' + item)
|
|
|
return true
|
|
|
}
|
|
|
return
|
|
@@ -281,4 +300,19 @@ export class AttachmentComponent implements OnInit {
|
|
|
let result = decodeURIComponent(str?.substring(index + 1))
|
|
|
return result || '未知文件名'
|
|
|
}
|
|
|
+
|
|
|
+ downloadFile(fileName:string){
|
|
|
+ // let fileName = '十四五”普通高等教育本科国家级规划教材第一次遴选推荐申报表.docx'
|
|
|
+ const fileUrl = `../../../../../public/file/${fileName}`;
|
|
|
+ this.http.get(fileUrl, { responseType: 'blob' }).subscribe((blob) => {
|
|
|
+ const url = window.URL.createObjectURL(blob);
|
|
|
+ const a = document.createElement('a');
|
|
|
+ a.href = url;
|
|
|
+ a.download = fileName;
|
|
|
+ document.body.appendChild(a);
|
|
|
+ a.click();
|
|
|
+ document.body.removeChild(a);
|
|
|
+ window.URL.revokeObjectURL(url);
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|