basic-in.component.ts 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623
  1. import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
  2. import { languages } from '../../../../services/languages.map';
  3. import { CommonCompModule } from '../../../../services/common.modules';
  4. import { NzSelectModule } from 'ng-zorro-antd/select';
  5. import { ReactiveFormsModule } from '@angular/forms';
  6. import { NzRadioModule } from 'ng-zorro-antd/radio';
  7. import { NzUploadModule } from 'ng-zorro-antd/upload';
  8. import { NzTagModule } from 'ng-zorro-antd/tag';
  9. import { NzMessageService } from 'ng-zorro-antd/message';
  10. import { NzModalService } from 'ng-zorro-antd/modal';
  11. import { textbookServer } from '../../../../services/textbook';
  12. import Parse from 'parse';
  13. import {
  14. FormControl,
  15. FormGroup,
  16. NonNullableFormBuilder,
  17. Validators,
  18. } from '@angular/forms';
  19. import { CompUploadComponent } from '../../../../app/comp-upload/comp-upload.component';
  20. import { NzInputModule } from 'ng-zorro-antd/input';
  21. import * as major from '../../../../services/majors4.map';
  22. import { NzCheckboxModule } from 'ng-zorro-antd/checkbox';
  23. import { BasicComponent } from '../create/basic/basic.component';
  24. import { ChangeDetectorRef } from '@angular/core';
  25. import { ViewChild } from '@angular/core';
  26. import { MatAccordion, MatExpansionModule } from '@angular/material/expansion';
  27. import { MatDatepickerModule } from '@angular/material/datepicker';
  28. import { MatInputModule } from '@angular/material/input';
  29. import { MatFormFieldModule } from '@angular/material/form-field';
  30. import { MatIconModule } from '@angular/material/icon';
  31. import { MatButtonModule } from '@angular/material/button';
  32. import { provideNativeDateAdapter } from '@angular/material/core';
  33. import { ViewChildren, QueryList } from '@angular/core';
  34. import { CreatedService } from '../../../../services/created.service';
  35. import { NzCollapseModule } from 'ng-zorro-antd/collapse';
  36. @Component({
  37. selector: 'app-basic',
  38. imports: [
  39. CommonCompModule,
  40. ReactiveFormsModule,
  41. NzSelectModule,
  42. NzRadioModule,
  43. NzUploadModule,
  44. NzInputModule,
  45. NzTagModule,
  46. CompUploadComponent,
  47. NzCheckboxModule,
  48. BasicComponent,
  49. MatButtonModule,
  50. MatExpansionModule,
  51. MatIconModule,
  52. MatFormFieldModule,
  53. MatInputModule,
  54. MatDatepickerModule,
  55. NzCollapseModule,
  56. ],
  57. standalone: true,
  58. templateUrl: './basic-in.component.html',
  59. styleUrls: ['./basic-in.component.scss'],
  60. providers: [provideNativeDateAdapter()],
  61. })
  62. export class BasicInComponent implements OnInit {
  63. @Input('eduTextbook') eduTextbook: Parse.Object | any;
  64. @Input('editFrom') editFrom: any;
  65. @Output() state: EventEmitter<any> = new EventEmitter<any>();
  66. @Output() save: EventEmitter<any> = new EventEmitter<any>();
  67. @ViewChild(MatAccordion) accordion: MatAccordion | any;
  68. @ViewChildren(BasicComponent) children: QueryList<BasicComponent> | any;
  69. /**删除分册 */
  70. async deleteVolume(index: number, comp: BasicComponent) {
  71. console.log(comp);
  72. if (this.eduTextbookVolumeList.length <= 2) {
  73. this.msg.create('warning', '全册最少两册');
  74. return;
  75. }
  76. this.eduTextbookVolumeList.splice(index, 1);
  77. this.typeNumber = this.typeNumber - 1;
  78. return;
  79. // console.log(this.eduTextbookVolumeList)
  80. // console.log(this.eduTextbookVolumeList[index])
  81. // if (this.eduTextbookVolumeList[index]?.id) {
  82. // this.eduTextbookVolumeList[index]?.set('isDeleted', true)
  83. // await this.eduTextbookVolumeList[index]?.save()
  84. // delete this.eduTextbookVolumeList[index]
  85. // this.typeNumber = this.typeNumber - 1
  86. // } else {
  87. // delete this.eduTextbookVolumeList[index]
  88. // this.typeNumber = this.typeNumber - 1
  89. // }
  90. // console.log(this.eduTextbookVolumeList);
  91. }
  92. /**上传分册数据 */
  93. async saveEduTextbookVolume(eduTextbookId?: string): Promise<any> {
  94. // console.log(eduTextbookId);
  95. let arr: Array<any> = []; //存储返回的数组id
  96. let isVrifly = true; //默认都通过,若一项填写未完成,则不通过
  97. return Promise.all(
  98. this.children.map(async (comp: any) => {
  99. // console.log(comp);
  100. let etvId = await comp.submitForm(eduTextbookId);
  101. console.log('返回eduTextbookVolume:'+etvId);
  102. arr.push({
  103. __type: 'Pointer',
  104. className: 'EduTextbookVolume',
  105. objectId: etvId,
  106. });
  107. if (!comp.isComlpete) {
  108. isVrifly = false;
  109. }
  110. //加上子组件返回是否填写完成的方法
  111. return arr;
  112. })
  113. ).then((data) => {
  114. // console.log(data);
  115. return {
  116. list: arr,
  117. isVrifly,
  118. };
  119. });
  120. }
  121. eduTextbookId: string = '';
  122. saveLoading: boolean = false; //保存等待
  123. async saveEduTextbook(params: any, isComplete: boolean) {
  124. if (this.saveLoading) return;
  125. this.saveLoading = true;
  126. try {
  127. // this.changeImportantProject()
  128. // console.log(params);
  129. if (!this.eduTextbook) {
  130. let obj = Parse.Object.extend('EduTextbook');
  131. this.eduTextbook = new obj();
  132. }
  133. this.eduTextbook?.set('user', Parse.User.current()?.toPointer());
  134. this.eduTextbook?.set('company', {
  135. __type: 'Pointer',
  136. className: 'Company',
  137. objectId: this.tbookSer.company,
  138. });
  139. let majorPoniter = this.selectList.find(
  140. (item) => item.code == params.majorPoniter
  141. );
  142. this.eduTextbook?.set('title', params.title);
  143. this.eduTextbook?.set('majorPoniter', majorPoniter);
  144. this.eduTextbook?.set('approval', params.approval);
  145. this.eduTextbook?.set('type', params.type);
  146. this.eduTextbook?.set('approvedImgUrl', params.approvedImgUrl);
  147. // this.eduTextbook?.set('typeNumber', this.typeNumber);
  148. if (!this.eduTextbook?.get('code')) {
  149. let t =
  150. this.tbookSer.formatTime('YYYYmmdd', new Date()) +
  151. Math.random().toString().slice(-4);
  152. this.eduTextbook.set('code', t);
  153. }
  154. // this.eduTextbook?.set('ISBN', (params.ISBN || 0).toString());
  155. // this.eduTextbook?.set('author', params.author);
  156. // this.eduTextbook?.set('unit', params.unit);
  157. // this.eduTextbook?.set('lang', params.lang);
  158. // this.eduTextbook?.set('authors', params.authors);
  159. // this.eduTextbook?.set('editor', params.editor);
  160. // this.eduTextbook?.set('editionUnit', params.editionUnit);
  161. // this.eduTextbook?.set('editionFirst', params.editionFirst);
  162. // this.eduTextbook?.set('carrierShape', params.carrierShape);
  163. // this.eduTextbook?.set('editionDate', params.editionDate);
  164. // this.eduTextbook?.set('editionNumber', params.editionNumber);
  165. // this.eduTextbook?.set('printDate', params.printDate);
  166. // this.eduTextbook?.set('printNumber', params.printNumber);
  167. // this.eduTextbook?.set('printSum', params.printSum);
  168. // this.eduTextbook?.set('importantProject', this.importantProject);
  169. // this.eduTextbook?.set('importantProjectOther', params.importantProjectOther);
  170. // this.eduTextbook?.set('unitType', params.unitType)
  171. let res = await this.eduTextbook?.save();
  172. this.eduTextbookId = await res?.id;
  173. // console.log(res?.id);
  174. let eduTextbookVolumes = await this.saveEduTextbookVolume(
  175. this.eduTextbookId
  176. );
  177. console.log(eduTextbookVolumes?.isVrifly);
  178. console.log(eduTextbookVolumes.list);
  179. this.eduTextbook?.set('childrens', eduTextbookVolumes.list);
  180. this.eduTextbook?.set('typeNumber', eduTextbookVolumes.list.length);
  181. isComplete = isComplete && eduTextbookVolumes?.isVrifly;
  182. //如果填写未完整,仅保存,状态修改待完善101
  183. if (this.eduTextbook.get('status') == '102' && !isComplete) {
  184. this.eduTextbook?.set('status', '101');
  185. this.eduTextbook.set('complete', false);
  186. } else if (!this.eduTextbook.get('status')) {
  187. this.eduTextbook?.set('status', '101');
  188. }
  189. if(isComplete){
  190. this.eduTextbook.set('complete', true)
  191. }
  192. await this.eduTextbook?.save();
  193. this.saveLoading = false;
  194. if (!isComplete) {
  195. this.msg.warning('保存成功,但存在未填写完成项');
  196. }
  197. return;
  198. } catch (err) {
  199. console.warn('保存错误:', err);
  200. this.saveLoading = false;
  201. this.msg.error('保存出错');
  202. }
  203. }
  204. /**扩展表记录 */
  205. eduTextbookVolumeList: Array<any> = [];
  206. /**获取扩展表记录 */
  207. async getEduTextbookVolumeList() {
  208. if (this.typeNumber && this.typeNumber > 12) {
  209. this.typeNumber = 12;
  210. }
  211. console.log(this.validateForm?.value?.type, this.typeNumber);
  212. // let query = new Parse.Query('EduTextbookVolume')
  213. // query.equalTo('eduTextbook', this.eduTextbook?.id)
  214. // // query.equalTo()
  215. // query.select('objectId')
  216. // query.ascending('createdAt')//小到大
  217. // query.notEqualTo('isDeleted', true)
  218. // if (this.validateForm?.value?.type == '全册') {
  219. // query.limit(this.typeNumber)
  220. // } else {
  221. // query.limit(1)
  222. // }
  223. let query = new Parse.Query('EduTextbook');
  224. query.equalTo('objectId', this.eduTextbook?.id);
  225. query.select('childrens');
  226. let r = await query.first();
  227. let list: any = r?.get('childrens') || [];
  228. console.log(list);
  229. this.eduTextbookVolumeList = new Array(this.typeNumber).fill({
  230. objectId: '',
  231. });
  232. if (this.validateForm?.value?.type == '全册') {
  233. if(this.eduTextbookVolumeList.length < 2){
  234. for (let index = 0; index < 2 - this.eduTextbookVolumeList.length; index++) {
  235. this.eduTextbookVolumeList.push({objectId:''})
  236. }
  237. }
  238. list.forEach((item: any, index: number) => {
  239. this.eduTextbookVolumeList[index] = item;
  240. });
  241. } else {
  242. this.singleId = list[0]?.id;
  243. }
  244. }
  245. singleId: string = '';
  246. loading = false;
  247. async checkSingle() {
  248. this.loading = true;
  249. this.validateForm.get('type')?.setValue('单本');
  250. await this.getEduTextbookVolumeList();
  251. this.loading = false;
  252. }
  253. /**申报类型选择全册 */
  254. async checkAll() {
  255. this.validateForm.get('type')?.setValue('全册');
  256. this.accordion?.openAll();
  257. this.getEduTextbookVolumeList();
  258. }
  259. changeCode() {}
  260. getCode(e: any) {}
  261. /***教材获批截图 */
  262. approvedImgList: Array<any> = [
  263. {
  264. name: '获批截图',
  265. status: 'done',
  266. url: '',
  267. },
  268. ];
  269. /**
  270. * 书号自动补全函数
  271. * @param isbn 书号
  272. */
  273. // async autoCompleteByISBN() {
  274. // let isbn = this.validateForm.value?.ISBN;
  275. // let result = await Parse.Cloud.run("tbookISBN", {
  276. // isbn: isbn
  277. // })
  278. // if (!result?.isbn) {
  279. // this.msg.warning('未找到该书号的图书信息,请手动填写')
  280. // }
  281. // // 其他字段,需补充接口与数据库对应关系
  282. // this.validateForm.get("title")?.setValue(result?.book_name)
  283. // this.validateForm.get("author")?.setValue(result?.author_name)
  284. // this.validateForm.get("authors")?.setValue(result?.author)
  285. // this.validateForm.get("majorPoniter")?.setValue(result?.major)
  286. // this.validateForm.get("lang")?.setValue(languages.options?.[result?.languages]?.name)
  287. // this.validateForm.get("editionUnit")?.setValue(result?.publisher)
  288. // this.validateForm.get("editionDate")?.setValue(new Date(result?.publish_time))
  289. // this.validateForm.get("carrierShape")?.setValue(result?.publication_class)
  290. // console.log(result)
  291. // }
  292. /**出版时间及版次不可选择时间 */
  293. disabledEditionDate = (current: Date): boolean => {
  294. return current < new Date(2022, 11, 1);
  295. };
  296. /** 全册次数*/
  297. typeNumber: number = 2;
  298. // typeNumberChange() {
  299. // if (this.typeNumber < 2) {
  300. // this.msg.create('warning', '不得小于两册')
  301. // this.typeNumber = 2
  302. // } else {
  303. // }
  304. // this.getEduTextbookVolumeList()
  305. // // this.eduTextbookVolumeList = []
  306. // // // for (let i = 1; i++; i <= this.typeNumber) {
  307. // // // this.eduTextbookVolumeList.push(false)
  308. // // // }
  309. // // this.eduTextbookVolumeList=new Array(this.typeNumber-1).fill(false)
  310. // // console.log(this.eduTextbookVolumeList)
  311. // }
  312. validateForm: FormGroup<{
  313. title: FormControl<string>; //申报教材名称
  314. majorPoniter: FormControl<string>; //教材应用对象及所诉学科专业类
  315. approval: FormControl<string>; //是否为重点立项教材
  316. type: FormControl<string>; //申报类型
  317. approvedImgUrl: FormControl<string>; //重点立项教材获批截图
  318. // ISBN: FormControl<any>; //国际标准书号
  319. // author: FormControl<string>; //第一主编(作者)
  320. // unit: FormControl<string>; //第一主编(作者)单位
  321. // unitType: FormControl<string>//第一主编(作者)单位类型
  322. // lang: FormControl<string>; //教材主要语种类型
  323. // authors: FormControl<string>; //其他主编姓名
  324. // editor: FormControl<string>; //其他编者姓名
  325. // editionUnit: FormControl<string>; //出版单位
  326. // editionFirst: FormControl<Date>; //初版时间
  327. // carrierShape: FormControl<string>; //载体形式
  328. // editionDate: FormControl<Date>; //出版时间
  329. // editionNumber: FormControl<number>; //出版版次
  330. // printDate: FormControl<Date>; //最新印次时间
  331. // printNumber: FormControl<number>; //最新印次
  332. // printSum: FormControl<number>; //初版以来合计印数
  333. // importantProjectOther: FormControl<string>; //其他省部级及以上项目
  334. }> = this.fb.group({
  335. title: ['', [Validators.required]],
  336. majorPoniter: ['', [Validators.required]],
  337. approval: ['', [Validators.required]],
  338. type: ['', [Validators.required]],
  339. approvedImgUrl: [''],
  340. // ISBN: [null, [Validators.required]],
  341. // author: ['', [Validators.required]],
  342. // unit: ['', [Validators.required]],
  343. // lang: ['', [Validators.required]],
  344. // authors: [''],
  345. // editor: [''],
  346. // editionUnit: ['', [Validators.required]],
  347. // editionFirst: [new Date(), [Validators.required]],
  348. // carrierShape: ['', [Validators.required]],
  349. // editionDate: [new Date(), [Validators.required]],
  350. // editionNumber: [0, [Validators.required]],
  351. // printDate: [new Date(), [Validators.required]],
  352. // printNumber: [0, [Validators.required]],
  353. // printSum: [0, [Validators.required]],
  354. // importantProjectOther: [''],
  355. // unitType: ['', [Validators.required]],
  356. });
  357. /** 所属学科专业类显示数量*/
  358. nzOptionOverflowSize = 5;
  359. //教材应用对象及所诉学科专业类
  360. selectList = major.majors.options;
  361. //语言选择
  362. selectLang: Array<any> = languages.options;
  363. //可选单位类型
  364. unitSelects: Array<any> = [
  365. {
  366. name: '部属高校',
  367. code: '部属高校',
  368. },
  369. {
  370. name: '部省合建高校',
  371. code: '部省合建高校',
  372. },
  373. {
  374. name: '省部共建高校',
  375. code: '省部共建高校',
  376. },
  377. {
  378. name: '其他',
  379. code: '其他',
  380. },
  381. ];
  382. //载体形式
  383. carrierOptions: Array<any> = [
  384. {
  385. name: '纸质教材',
  386. code: 'Z001',
  387. },
  388. {
  389. name: '电子教材',
  390. code: 'Z002',
  391. },
  392. {
  393. name: '纸质教材附带电子资源',
  394. code: 'Z003',
  395. },
  396. ];
  397. /**可选的重点项目 */
  398. importantProjectList: Array<any> = [
  399. {
  400. label: '首届全国教材建设奖全国优秀教材(高等教育类)',
  401. value: '首届全国教材建设奖全国优秀教材(高等教育类)',
  402. checked: false,
  403. },
  404. {
  405. label: '“十二五”普通高等教育本科国家级规划教材',
  406. value: '“十二五”普通高等教育本科国家级规划教材',
  407. checked: false,
  408. },
  409. {
  410. label: '“十二五”以来省级优秀教材',
  411. value: '“十二五”以来省级优秀教材',
  412. checked: false,
  413. },
  414. {
  415. label: '“十二五”以来省级规划教材',
  416. value: '“十二五”以来省级规划教材',
  417. checked: false,
  418. },
  419. {
  420. label: '其他省部级及以上项目',
  421. value: '其他省部级及以上项目',
  422. checked: false,
  423. },
  424. ];
  425. /**选中的重点项目 */
  426. importantProject: Array<any> = [];
  427. /**多选框改变 */
  428. changeImportantProject() {
  429. let checkedList =
  430. this.importantProjectList.filter((item) => item.checked) || [];
  431. this.importantProject = checkedList.map((item) => item.value);
  432. console.log(this.importantProject);
  433. }
  434. /* 是否重点立项教材可选列表 */
  435. options: Array<any> = [
  436. {
  437. name: '经中央有关部门审定的教材',
  438. code: '经中央有关部门审定的教材',
  439. },
  440. {
  441. name: '首届全国教材建设奖优秀教材(高等教育类)教材',
  442. code: '首届全国教材建设奖优秀教材(高等教育类)教材',
  443. },
  444. {
  445. name: '“101计划”核心教材',
  446. code: '“101计划”核心教材',
  447. },
  448. {
  449. name: '“四新”重点建设教材(含战略性新兴领域教材)',
  450. code: '“四新”重点建设教材(含战略性新兴领域教材)',
  451. },
  452. {
  453. name: '否',
  454. code: '否',
  455. },
  456. ];
  457. constructor(
  458. public tbookSer: textbookServer,
  459. private fb: NonNullableFormBuilder,
  460. private modal: NzModalService,
  461. private msg: NzMessageService,
  462. private cdr: ChangeDetectorRef,
  463. private creatSev: CreatedService
  464. ) {}
  465. isShowChooseEU: boolean = true;
  466. ngOnInit() {
  467. // if (this.eduTextbook?.get('editionUnit')) {
  468. // this.isShowChooseEU = false
  469. // }
  470. // this.importantProject = this.eduTextbook?.get('importantProject') || []
  471. // if (this.importantProject?.length > 0) {
  472. // for (let i in this.importantProjectList) {
  473. // if (this.importantProject.indexOf(this.importantProjectList[i].value) != -1) {
  474. // this.importantProjectList[i].checked = true
  475. // }
  476. // }
  477. // }
  478. this.approvedImgList[0].url = this.eduTextbook?.get('approvedImgUrl');
  479. this.typeNumber = this.eduTextbook?.get('childrens').length || 2;
  480. if (this.typeNumber > 12) this.typeNumber = 12;
  481. // console.log(this.approvedImgList)
  482. // console.log(this.eduTextbook);
  483. this.validateForm = this.fb.group({
  484. title: [this.eduTextbook?.get('title') || '', [Validators.required]],
  485. majorPoniter: [
  486. this.eduTextbook?.get('majorPoniter')?.code || '',
  487. [Validators.required],
  488. ],
  489. approval: [
  490. this.eduTextbook?.get('approval') || '',
  491. [Validators.required],
  492. ],
  493. type: [this.eduTextbook?.get('type') || '单本', [Validators.required]],
  494. approvedImgUrl: [this.eduTextbook?.get('approvedImgUrl') || ''],
  495. // ISBN: [parseInt(this.eduTextbook?.get('ISBN') || '') || null, [Validators.required]],
  496. // author: [this.eduTextbook?.get('author') || '', [Validators.required]],
  497. // unit: [this.eduTextbook?.get('unit') || '', [Validators.required]],
  498. // lang: [this.eduTextbook?.get('lang') || '', [Validators.required]],
  499. // authors: [this.eduTextbook?.get('authors') || ''],
  500. // editor: [this.eduTextbook?.get('editor') || '',],
  501. // editionUnit: [this.eduTextbook?.get('editionUnit') || '', [Validators.required]],
  502. // editionFirst: [this.eduTextbook?.get('editionFirst') || new Date(), [Validators.required]],
  503. // carrierShape: [this.eduTextbook?.get('carrierShape') || '', [Validators.required]],
  504. // editionDate: [this.eduTextbook?.get('editionDate') || new Date(), [Validators.required]],
  505. // editionNumber: [this.eduTextbook?.get('editionNumber') || 0, [Validators.required]],
  506. // printDate: [this.eduTextbook?.get('printDate') || new Date(), [Validators.required]],
  507. // printNumber: [this.eduTextbook?.get('printNumber') || 0, [Validators.required]],
  508. // printSum: [this.eduTextbook?.get('printSum') || 0, [Validators.required]],
  509. // importantProjectOther: [this.eduTextbook?.get('importantProjectOther') || ''],
  510. // unitType: [this.eduTextbook?.get('unitType') || '', [Validators.required]],
  511. });
  512. }
  513. ngAfterViewInit() {
  514. this.eduTextbookId = this.eduTextbook?.id;
  515. this.accordion?.openAll();
  516. this.cdr.detectChanges();
  517. this.getEduTextbookVolumeList();
  518. }
  519. addVolume() {
  520. if (this.eduTextbookVolumeList.length >= 12) {
  521. this.msg.error('已超过最多册数');
  522. return;
  523. }
  524. this.eduTextbookVolumeList.push({ objectId: '' });
  525. this.typeNumber++;
  526. }
  527. upload(e: any, type: string) {
  528. console.log(e);
  529. let file = e[0];
  530. // if(type == 'copyrightImgUrl' || type == 'CIPImgUrl' ||type=='approvedImgUrl'){
  531. if (type == 'approvedImgUrl') {
  532. this.validateForm.value[type] = file?.url;
  533. }
  534. console.log(this.validateForm.value);
  535. }
  536. async submitForm(event?: string): Promise<void> {
  537. console.log(this.validateForm.value);
  538. console.log(this.validateForm.valid);
  539. if (event == 'next') {
  540. let params = this.validateForm.value;
  541. await this.saveEduTextbook(params, this.validateForm.valid);
  542. this.state.emit({ type: 'next', textBook: this.eduTextbook });
  543. }
  544. // if (this.validateForm.valid) {
  545. // let params = this.validateForm.value
  546. // if (event == 'next') {
  547. // await this.saveEduTextbook(params, this.validateForm.valid)
  548. // this.state.emit({ type: 'next', textBook: this.eduTextbook });
  549. // }
  550. // } else {
  551. // if (event == 'save') {
  552. // let params = this.validateForm.value
  553. // await this.saveEduTextbook(params, this.validateForm.valid)
  554. // // await this.getEduTextbookVolumeList()
  555. // this.modal.success({
  556. // nzTitle: '保存成功',
  557. // nzContent: '<p>已保存并且至空间</p>',
  558. // nzOnOk: () => console.log('Info OK')
  559. // });
  560. // return
  561. // }
  562. // if (event == 'next') {
  563. // let params = this.validateForm.value
  564. // await this.saveEduTextbook(params, this.validateForm.valid)
  565. // this.state.emit({ type: 'next', textBook: this.eduTextbook });
  566. // }
  567. // }
  568. if (event == 'save') {
  569. let params = this.validateForm.value;
  570. await this.saveEduTextbook(params, this.validateForm.valid);
  571. // await this.getEduTextbookVolumeList()
  572. this.modal.success({
  573. nzTitle: '保存成功',
  574. nzContent: '<p>已保存并且至空间</p>',
  575. nzOnOk: () => console.log('Info OK'),
  576. });
  577. }
  578. }
  579. selectedValue = null;
  580. listOfOption: Array<{ value: string; text: string }> = [];
  581. nzFilterOption = (): boolean => true;
  582. eduTimeout: any;
  583. /**出版单位列表 */
  584. eduList: Array<Parse.Object> = [];
  585. /**搜索出版单位 */
  586. async search(value: string) {
  587. clearTimeout(this.eduTimeout);
  588. this.eduTimeout = setTimeout(async () => {
  589. let query = new Parse.Query('Department');
  590. query.notEqualTo('isDeleted', true);
  591. query.equalTo('parent', '66865d66ad23a23355b12aa7');
  592. query.contains('name', value);
  593. query.limit(10);
  594. this.eduList = await query.find();
  595. }, 500);
  596. }
  597. openFile(url: any) {
  598. window.open(url);
  599. }
  600. }