数据可视化大屏
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

50 linhas
1.8KB

  1. // parent.component.ts
  2. import { CommonModule } from '@angular/common';
  3. import { Component, Input, Output, EventEmitter } from '@angular/core';
  4. import { SHARED_IMPORTS } from '@shared';
  5. import { NzDropDownModule } from 'ng-zorro-antd/dropdown';
  6. import { NzIconModule } from 'ng-zorro-antd/icon';
  7. @Component({
  8. selector: 'data-v-card',
  9. standalone: true,
  10. template: `
  11. <div class="card-content">
  12. <!-- <img src="assets/dashboard/dashboard_card_bg.jpg" style="width: 100%;" /> -->
  13. <div class="card-content-title">
  14. <div class="card-content-l">{{ title }}</div>
  15. <div *ngIf="showSetting" class="card-content-r">
  16. <a nz-dropdown [nzDropdownMenu]="menu" nz-icon nzType="setting" nzTrigger="click" nzTheme="outline"></a>
  17. <nz-dropdown-menu #menu="nzDropdownMenu">
  18. <ul nz-menu nzSelectable>
  19. <li nz-menu-item *ngFor="let option of optionsList">
  20. <label nz-checkbox [(ngModel)]="option.checked" (ngModelChange)="onCheckChange()">{{ option.label }}</label>
  21. </li>
  22. </ul>
  23. </nz-dropdown-menu>
  24. </div>
  25. </div>
  26. <ng-content />
  27. </div>
  28. `,
  29. styleUrls: ['./card.component.less'],
  30. imports: [NzIconModule, CommonModule, NzDropDownModule, ...SHARED_IMPORTS]
  31. })
  32. export class DataVCardComponent {
  33. @Input() showSetting = false;
  34. @Input()
  35. optionsList: Array<{ label: string; checked: boolean }> = [];
  36. // 定义输出事件
  37. @Output() onCheckedItemsChange = new EventEmitter<Array<{ label: string; checked: boolean }>>();
  38. @Input() title: string = '';
  39. getCheckedItems() {
  40. return this.optionsList.filter(option => option.checked);
  41. }
  42. onCheckChange() {
  43. const checkedItems = this.getCheckedItems();
  44. this.onCheckedItemsChange.emit(checkedItems);
  45. }
  46. }