src/app/modules/search/staff/staff.ts
Поиск сотрудников организации
| selector | search-staff | 
| styleUrls | staff.scss | 
| templateUrl | ./staff.html | 
| Properties | 
| Methods | 
| constructor(profileService: ProfileService, commonService: CommonService) | |||||||||
| Defined in src/app/modules/search/staff/staff.ts:44 | |||||||||
| Конструктор 
                                        Parameters :
                                         
 | 
| ngOnInit | 
| ngOnInit() | 
| Defined in src/app/modules/search/staff/staff.ts:58 | 
| Инициализация 
                                    Returns :      void | 
| onFilter | ||||||
| onFilter(event: ) | ||||||
| Defined in src/app/modules/search/staff/staff.ts:102 | ||||||
| Получение новых данных для фильтрации 
                                        Parameters :
                                         
 
                                    Returns :      void | 
| onViewProfile | ||||||
| onViewProfile(event: ) | ||||||
| Defined in src/app/modules/search/staff/staff.ts:120 | ||||||
| Получение профиля при просмотре 
                                        Parameters :
                                         
 
                                    Returns :      void | 
| setCatalog | 
| setCatalog() | 
| Defined in src/app/modules/search/staff/staff.ts:70 | 
| Получение справочников 
                                    Returns :      void | 
| catalog | 
| catalog:      | 
| Type : any | 
| Defined in src/app/modules/search/staff/staff.ts:34 | 
| Справочники для фильтров | 
| data | 
| data:      | 
| Type : any | 
| Defined in src/app/modules/search/staff/staff.ts:29 | 
| Данные | 
| defaultImage | 
| defaultImage:      | 
| Type : string | 
| Default value : assets/images/default_image.svg | 
| Defined in src/app/modules/search/staff/staff.ts:24 | 
| Изображение по-умолчанию | 
| header | 
| header:      | 
| Type : string | 
| Default value : Поиск сотрудника | 
| Defined in src/app/modules/search/staff/staff.ts:19 | 
| Заголовок | 
| loading | 
| loading:      | 
| Type : boolean | 
| Default value : true | 
| Defined in src/app/modules/search/staff/staff.ts:44 | 
| Индикатор загрузки основных данных | 
| profile | 
| profile:      | 
| Type : any | 
| Defined in src/app/modules/search/staff/staff.ts:39 | 
| Профиль | 
import { Component, OnInit } from '@angular/core';
import { ProfileService } from 'glx.ui/components/kernel/services/profile.service';
import { CommonService } from 'glx.ui/components/kernel/services/common.service';
/**
 * Поиск сотрудников организации
 */
@Component({
  selector: 'search-staff',
  templateUrl: './staff.html',
  styleUrls: ['./staff.scss']
})
export class SearchStaffComponent implements OnInit {
  /**
   * Заголовок
   * @type {string}
   */
  header: string = 'Поиск сотрудника';
  /**
   * Изображение по-умолчанию
   * @type {string}
   */
  defaultImage: string = 'assets/images/default_image.svg';
  /**
   * Данные
   * @type {{}}
   */
  data: any = {};
  /**
   * Справочники для фильтров
   * @type {{}}
   */
  catalog: any = {};
  /**
   * Профиль
   * @type {{}}
   */
  profile: any = {};
  /**
   * Индикатор загрузки основных данных
   * @type {boolean}
   */
  loading: boolean = true;
  /**
   * Конструктор
   * @param {ProfileService} profileService
   * @param {CommonService} commonService
   */
  constructor(private profileService: ProfileService,
              private commonService: CommonService,) {
  }
  /**
   * Инициализация
   */
  ngOnInit() {
    this.loading = true;
    this.catalog = {
      departments: [],
      job_titles: []
    };
    this.setCatalog();
  }
  /**
   * Получение справочников
   */
  setCatalog() {
    this.commonService.get('depslist')
      .subscribe(
        data => {
          this.catalog.departments = [];
          this.catalog.departments.push({'value': '', 'label': '(любое)'});
          for (let i = 0; i < data.length; i++) {
            this.catalog.departments.push(data[i]);
          }
        },
        error => {
          console.error(error);
        });
    this.commonService.get('jobtitles')
      .subscribe(
        data => {
          this.catalog.job_titles = [];
          this.catalog.job_titles.push({'value': '', 'label': '(любая)'});
          for (let i = 0; i < data.length; i++) {
            this.catalog.job_titles.push(data[i]);
          }
        },
        error => {
          console.error(error);
        });
  }
  /**
   * Получение новых данных для фильтрации
   * @param event
   */
  onFilter(event) {
    this.profileService.searchEmployees(event)
      .subscribe(
        data => {
          this.data = data;
        },
        error => {
          console.error(error);
        },
        () => {
          this.loading = false;
        });
  }
  /**
   * Получение профиля при просмотре
   * @param event
   */
  onViewProfile(event) {
    this.profile = {};
    this.profileService.get(event)
      .subscribe(
        data => {
          this.profile = data;
        },
        error => {
          console.error(error);
        });
  }
}
<glx-page-title-bx [header]="header"></glx-page-title-bx>
<div class="staff-search-wrapper">
  <glx-staff-search
    [filterShow]="false"
    [data]="data"
    [catalog]="catalog"
    [profile]="profile"
    (onFilter)="onFilter($event)"
    (onViewProfile)="onViewProfile($event)"
    [defaultImage]="defaultImage"
    [loading]="loading"
    imagePrefix="/bitrix/galaktika/galaktika.vuzapi/public/"
    globalFilterPlaceholder="Поиск по ФИО, подразделению, должности..."
  ></glx-staff-search>
</div>