user-edit.component.ts 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. import { Component, Input, OnInit } from '@angular/core';
  2. import { CommonModule } from '@angular/common';
  3. import { NzSpaceModule } from 'ng-zorro-antd/space';
  4. import { CommonCompModule } from '../../../services/common.modules';
  5. import { NzTabsModule } from 'ng-zorro-antd/tabs';
  6. import { ProcessComponent } from '../components/process/process.component';
  7. import { CreateCollectionComponent } from '../create-collection/create-collection.component';
  8. import { ActivatedRoute, Router } from '@angular/router';
  9. import Parse from 'parse';
  10. import { NzAvatarModule } from 'ng-zorro-antd/avatar';
  11. import { NzDropDownModule } from 'ng-zorro-antd/dropdown';
  12. import { NzPopoverModule } from 'ng-zorro-antd/popover';
  13. import { NzTagModule } from 'ng-zorro-antd/tag';
  14. import { NzModalModule } from 'ng-zorro-antd/modal';
  15. import { NzMessageService } from 'ng-zorro-antd/message';
  16. @Component({
  17. selector: 'app-user-edit',
  18. templateUrl: './user-edit.component.html',
  19. styleUrls: ['./user-edit.component.scss'],
  20. imports: [
  21. CommonModule,
  22. NzSpaceModule,
  23. CommonCompModule,
  24. NzTabsModule,
  25. ProcessComponent,
  26. CreateCollectionComponent,
  27. NzAvatarModule,
  28. NzDropDownModule,
  29. NzPopoverModule,
  30. NzTagModule,
  31. NzModalModule,
  32. ],
  33. standalone: true,
  34. })
  35. export class UserEditComponent implements OnInit {
  36. inputValue: string = `
  37. async function pipe(user, context, callback) {
  38. if (context.connection === "weibo") {
  39. return callback(new Error("当前系统禁止使用微博登录!"))
  40. }
  41. callback(null, user, context)
  42. }`;
  43. isVisible: boolean = false;
  44. user: Parse.Object | any;
  45. profile: Parse.Object | any;
  46. password: string = '';
  47. constructor(
  48. private activeRoute: ActivatedRoute,
  49. private router: Router,
  50. private message: NzMessageService
  51. ) {}
  52. ngOnInit() {
  53. this.activeRoute.paramMap.subscribe(async (params) => {
  54. let id = params.get('id');
  55. console.log(id);
  56. if (id) {
  57. let query = new Parse.Query('_User');
  58. this.user = await query.get(id);
  59. let queryProfile = new Parse.Query('Profile');
  60. queryProfile.equalTo('user', id);
  61. this.profile = await queryProfile.first();
  62. }
  63. });
  64. }
  65. async updateUser(type: string) {
  66. console.log(type);
  67. switch (type) {
  68. case '已认证':
  69. this.user.set('accountState', '已认证');
  70. break;
  71. case '已禁用':
  72. this.user.set('accountState', '已禁用');
  73. break;
  74. case '删除':
  75. this.user.set('isDeleted', true);
  76. break;
  77. }
  78. await this.user.save();
  79. this.ngOnInit();
  80. }
  81. async handleOk() {
  82. this.password = this.password.trim()
  83. if(!this.password){
  84. this.message.warning('密码格式错误');
  85. return
  86. }
  87. try {
  88. this.user.set('password', this.password);
  89. await this.user.save();
  90. this.ngOnInit();
  91. } catch (err) {
  92. this.message.warning('保存出错,请注意密码格式');
  93. }
  94. this.isVisible = false;
  95. }
  96. }