examtest.component.ts 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. import {Component, OnInit} from '@angular/core';
  2. import {ActivatedRoute, Router} from "@angular/router";
  3. import {ConfigService, RequsetData} from "../../../service/config.service";
  4. import {AlertController, MenuController, ModalController} from "@ionic/angular";
  5. @Component({
  6. selector: 'app-examtest',
  7. templateUrl: './examtest.component.html',
  8. styleUrls: ['./examtest.component.scss'],
  9. })
  10. export class ExamtestComponent implements OnInit {
  11. getDataUrl = '/api/exammanage/questiontypeSetting/getList';
  12. getLibaryUrl = '/api/exampaper/getLibaryTree';
  13. questionTypeList: any = [];
  14. fileTypeData: any = {
  15. title: '所有题库',
  16. pSelectedName: '所有题库',
  17. rootKids: [],
  18. selectedNode: null,
  19. selectedParent: null,
  20. fileTypeName: ''
  21. };
  22. libaryTree = [];
  23. typeList: any[] = [];
  24. selectLibaryList = [];
  25. bakLibaryList=[];
  26. constructor(private menu: MenuController, private router: Router, private configService: ConfigService, private routeInfo: ActivatedRoute) {
  27. }
  28. ngOnInit() {
  29. this.routeInfo.queryParams.subscribe(params => {
  30. this.getQuestionTypeList();
  31. this.getLibaryTree();
  32. });
  33. }
  34. getQuestionTypeList() {
  35. this.configService.HttpGetRomote(this.getDataUrl, {}).subscribe((data: RequsetData) => {
  36. if (data.success) {
  37. this.questionTypeList = data.item;
  38. }
  39. });
  40. }
  41. getLibaryTree() {
  42. this.configService.HttpGetRomote(this.getLibaryUrl, {}).subscribe((data: RequsetData) => {
  43. if (data.success) {
  44. this.libaryTree = data.item;
  45. this.typeList = data.item;
  46. }
  47. });
  48. }
  49. selectFileType() {
  50. this.menu.enable(true, 'typeRoot').then(a => {
  51. });
  52. this.menu.open('typeRoot').then(a => {
  53. });
  54. }
  55. BackMenu() {
  56. if (this.fileTypeData.selectedNode.parentList != null) {
  57. this.typeList = this.fileTypeData.selectedNode.parentList;
  58. this.fileTypeData.selectedNode = this.fileTypeData.selectedNode.parentNode;
  59. }
  60. if (this.fileTypeData.selectedNode == null) {
  61. this.fileTypeData.pSelectedName = '所有题库';
  62. }
  63. }
  64. selectedTitle() {
  65. let result = false;
  66. if (this.fileTypeData.selectedNode == null) {
  67. result = true;
  68. } else {
  69. if (this.fileTypeData.selectedParent != null) {
  70. result = this.fileTypeData.selectedNode.filetypeid == this.fileTypeData.selectedParent.filetypeid;
  71. }
  72. }
  73. return result;
  74. }
  75. SelectTitleFileType() {
  76. this.fileTypeData.selectedNode = this.fileTypeData.selectedParent;
  77. }
  78. selectedItem(it: any) {
  79. let result = false;
  80. if (this.fileTypeData.selectedNode != null) {
  81. result = this.fileTypeData.selectedNode.id == it.id;
  82. }
  83. return result;
  84. }
  85. ShowKidsFileType(it: any) {
  86. if (it.childList == 0) {
  87. return true;
  88. }
  89. it.parentNode = this.fileTypeData.selectedNode;
  90. this.fileTypeData.selectedNode = it;
  91. this.fileTypeData.pSelectedName = it.name;
  92. it.parentList = this.typeList;
  93. this.typeList = it.childList;
  94. }
  95. chooseFileType() {
  96. this.selectLibaryList = this.bakLibaryList;//Object.assign({}, this.bakLibaryList);
  97. this.CloseMenu();
  98. }
  99. CloseMenu() {
  100. this.menu.close('typeRoot').then(a => {
  101. });
  102. }
  103. checkedChange(it, checked) {
  104. it.checked = checked;
  105. this.bakLibaryList = this.bakLibaryList.filter(x => x.id != it.id);
  106. if (checked) {
  107. this.bakLibaryList.push({id: it.id, name: it.name});
  108. }
  109. }
  110. eachLibaryTree(treeList: any[]) {
  111. treeList.forEach((item: any) => {
  112. if (item.checked) {
  113. this.selectLibaryList.push({id: item.id, name: item.name});
  114. }
  115. if (item.childList.length > 0) {
  116. this.eachLibaryTree(item.childList);
  117. }
  118. })
  119. }
  120. entryTest() {
  121. }
  122. }