comp-manage.component.ts 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. import { Component, OnInit} from '@angular/core';
  2. import { CompNavComponent } from '../comp-nav/comp-nav.component';
  3. import {DomSanitizer} from '@angular/platform-browser';
  4. import { RouterOutlet, Router } from '@angular/router';
  5. import { CommonCompModule } from '../../services/common.modules';
  6. import { MatIconRegistry, MatIconModule } from '@angular/material/icon';
  7. import { textbookServer } from '../../services/textbook';
  8. import { HttpClient } from '@angular/common/http';
  9. @Component({
  10. selector: 'app-comp-manage',
  11. standalone: true,
  12. imports: [CompNavComponent, RouterOutlet, CommonCompModule,MatIconModule],
  13. templateUrl: './comp-manage.component.html',
  14. styleUrls: ['./comp-manage.component.scss'],
  15. })
  16. export class CompManageComponent implements OnInit {
  17. MENU_ICON:string = `<svg width="18" height="20" viewBox="0 0 18 20" fill="none" xmlns="http://www.w3.org/2000/svg">
  18. <path d="M18 2H4C3.46957 2 2.96086 2.21071 2.58579 2.58579C2.21071 2.96086 2 3.46957 2 4C2 4.53043 2.21071 5.03914 2.58579 5.41421C2.96086 5.78929 3.46957 6 4 6H18V19C18 19.2652 17.8946 19.5196 17.7071 19.7071C17.5196 19.8946 17.2652 20 17 20H4C2.93913 20 1.92172 19.5786 1.17157 18.8284C0.421427 18.0783 0 17.0609 0 16V4C0 2.93913 0.421427 1.92172 1.17157 1.17157C1.92172 0.421427 2.93913 0 4 0H17C17.2652 0 17.5196 0.105357 17.7071 0.292893C17.8946 0.48043 18 0.734783 18 1V2Z" fill="url(#paint0_linear_5_11023)"/>
  19. <defs>
  20. <linearGradient id="paint0_linear_5_11023" x1="9" y1="-2.21282e-07" x2="25.5" y2="40" gradientUnits="userSpaceOnUse">
  21. <stop stop-color="#E04860"/>
  22. <stop offset="1" stop-color="#E99306"/>
  23. </linearGradient>
  24. </defs>
  25. </svg>
  26. `
  27. optionsMap: any = {
  28. "国家级管理员":[
  29. {
  30. name:'教材管理',
  31. id:'1',
  32. child:[
  33. {
  34. name:'全部教材列表',
  35. path:'/nav-admin/manage/textbook',
  36. id:'1-1',
  37. },
  38. {
  39. name:'申报流程',
  40. path:"/nav-admin/manage/process",
  41. id:'1-2',
  42. },
  43. ]
  44. },
  45. {
  46. name:'用户管理',
  47. id:'2',
  48. child:[
  49. {
  50. name:'用户列表',
  51. path:"/nav-admin/manage/user",
  52. id:'2-1',
  53. },
  54. {
  55. name:'申报单位管理',
  56. path:"/nav-admin/manage/role",
  57. id:'2-3',
  58. },
  59. ]
  60. },
  61. // {
  62. // name:'品牌化',
  63. // id:'3',
  64. // child:[
  65. // {
  66. // name:'登录框',
  67. // id:'3-1',
  68. // },
  69. // {
  70. // name:'消息设置',
  71. // id:'3-2',
  72. // },
  73. // ]
  74. // },
  75. // {
  76. // name:'字段管理',
  77. // id:'4',
  78. // },
  79. ],
  80. "工作联系人":[
  81. {
  82. name:'教材申报',
  83. id:'1',
  84. child:[
  85. {
  86. name:'全部教材列表',
  87. path:'/nav-province-contact/manage/textbook',
  88. id:'1-1',
  89. },
  90. {
  91. name:'申报流程',
  92. path:"/nav-province-contact/manage/process",
  93. id:'1-2',
  94. },
  95. ]
  96. },
  97. {
  98. name:'用户管理',
  99. id:'2',
  100. child:[
  101. {
  102. name:'用户列表',
  103. path:"/nav-province-contact/manage/user",
  104. id:'2-1',
  105. },
  106. {
  107. name:'申报单位管理',
  108. path:"/nav-province-contact/manage/role",
  109. id:'2-3',
  110. },
  111. ]
  112. },
  113. ],
  114. "高校联系人":[
  115. {
  116. id:'1',
  117. name:'教材申报',
  118. child:[
  119. {
  120. id:'1-1',
  121. name:'全部教材',
  122. path:'/nav-province-school-contact/manage/textbook',
  123. }
  124. ]
  125. },
  126. {
  127. id:'2',
  128. name:'用户管理',
  129. child:[
  130. {
  131. id:'2-1',
  132. name:'用户列表',
  133. path:'/nav-province-school-contact/manage/user',
  134. },
  135. {
  136. name:'申报单位管理',
  137. path:"/nav-province-school-contact/manage/role",
  138. id:'2-2',
  139. },
  140. ]
  141. },
  142. {
  143. name:'个人空间',
  144. id:'3',
  145. path: '/nav-province-school-contact/manage/space',
  146. },
  147. {
  148. name:'回收站',
  149. id:'4',
  150. path: '/nav-province-school-contact/manage/recycle',
  151. },
  152. ],
  153. "评审专家":[
  154. {
  155. name:'报送流程',
  156. id:'1',
  157. path: '/nav-review/home/apply',
  158. },
  159. {
  160. name:'个人信息',
  161. id:'2',
  162. path: '/nav-review/profile',
  163. },
  164. ],
  165. "教师":[
  166. {
  167. name: '个人空间',
  168. id: '1',
  169. path: '/nav-author/manage/space',
  170. },
  171. {
  172. name: '回收站',
  173. id: '2',
  174. path: '/nav-author/manage/recycle',
  175. // params: {
  176. // isDeleted: true,
  177. // },
  178. },
  179. ],
  180. }
  181. active: string = localStorage.getItem('active') || '1';
  182. isCollapsed:boolean = false;
  183. constructor(
  184. public router: Router,
  185. public tbookSer: textbookServer,
  186. public textbook:textbookServer,
  187. iconRegistry: MatIconRegistry,
  188. sanitizer: DomSanitizer,
  189. private http: HttpClient,
  190. ) {
  191. iconRegistry.addSvgIconLiteral('menu', sanitizer.bypassSecurityTrustHtml(this.MENU_ICON));
  192. }
  193. ngOnInit() {
  194. console.log(this.tbookSer.profile.identity)
  195. if(localStorage.getItem('active')) return
  196. if(this.optionsMap[this.tbookSer.profile.identity][0]?.child){
  197. this.active = '1-1'
  198. }else{
  199. this.active = '1'
  200. }
  201. }
  202. toggleCollapsed(): void {
  203. this.isCollapsed = !this.isCollapsed;
  204. }
  205. toUrl(child: any) {
  206. let cateid = child.id;
  207. this.active = cateid;
  208. localStorage.setItem('active', cateid);
  209. console.log(child);
  210. if (child.params) {
  211. this.router.navigate([child.path, child?.params]);
  212. } else {
  213. this.router.navigate([child.path]);
  214. }
  215. }
  216. downloadFile(fileName: string) {
  217. const fileUrl = `/file/${fileName}`;
  218. this.http.get(fileUrl, { responseType: 'blob' }).subscribe((blob) => {
  219. const url = window.URL.createObjectURL(blob);
  220. const a = document.createElement('a');
  221. a.href = url;
  222. a.download = fileName;
  223. document.body.appendChild(a);
  224. a.click();
  225. document.body.removeChild(a);
  226. window.URL.revokeObjectURL(url);
  227. })
  228. }
  229. openFile(url:string){
  230. window.open(url)
  231. }
  232. }