indicators-and-curriculum.component.ts 3.31 KB
Newer Older
1 2
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { ToastrService } from 'ngx-toastr';
3 4 5 6 7
export interface DataModel {
  code: string,
  name: string,
  type: string
}
8
@Component({
9 10 11
  selector: 'app-indicators-and-curriculum',
  templateUrl: './indicators-and-curriculum.component.html',
  styleUrls: ['./indicators-and-curriculum.component.scss']
12 13 14
})
export class IndicatorsAndCurriculumComponent {
  @Output() sendPathTitle: EventEmitter<string[]> = new EventEmitter<string[]>();
15 16 17
  editTab = false
  currentPage = 1
  search = ""
18
  page = Array.from({ length: 1 }, (_, i) => i + 1);
19

20 21 22 23 24 25
  dataList: DataModel[] = [
    { code: "CC-01", name: "จิตสำนึกด้านความปลอดภัยและคุณภาพ (Safety & Quality)", type: "CC" },
    { code: "CC-02", name: "การทำงานเป็นทีมแบบ TAT (TAT Teamwork)", type: "CC" },
    { code: "CC-03", name: "ความรับผิดชอบในหน้าที่และโปร่งใส (Accountability & Ethics)", type: "CC" },
    { code: "MC-01", name: "การคิดเชิงกลยุทธ์ (Strategic Thinking)", type: "MC" },
    { code: "MC-02", name: "การมีทัศนคติที่เติบโต (Mindset-Growth)", type: "MC" },
26
    { code: "PC-01", name: "ความรู้ด้านกฎหมายแรงงาน, กฎหมายแพ่งพาณิชย์, กฎหมายอาญา", type: "PC" },
27 28 29
  ]
  constructor(private toastr: ToastrService) {
    this.pathTitleChange()
30
    this.searchChange()
31 32
  }

33 34
  pathTitleChange() {
    this.sendPathTitle.emit(this.editTab ? ['การประเมินสมรรถนะ', 'การจัดการสมรรถนะ', 'ตัวชี้วัดเเละหลักสูตร', 'การจัดการตัวชี้วัดเเละหลักสูตร'] : ['การประเมินสมรรถนะ', 'การจัดการสมรรถนะ', 'ตัวชี้วัดเเละหลักสูตร'])
35 36
  }

37 38 39 40
  searchChange() {
    this.currentPage = 1;
    const filteredData = this.dataListFilter();
    this.page = Array.from({ length: Math.ceil(filteredData.length / 10) }, (_, i) => i + 1);
41 42
  }

43 44 45 46 47
  dataListFilter() {
    return this.dataList.filter(x => {
      const match = x.code.includes(this.search) || x.name.includes(this.search);
      return match;
    });
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
  }


  showSuccess() {
    this.toastr.success('บันทึกข้อมูลสำเร็จ', 'เเจ้งเตือน', {
      timeOut: 3000,
      positionClass: 'toast-top-right',
    });
  }
  showSuccessEdit() {
    this.toastr.success('เเก้ไขข้อมูลสำเร็จ', 'เเจ้งเตือน', {
      timeOut: 3000,
      positionClass: 'toast-top-right',
    });
  }
  showSuccessDelete() {
    this.toastr.success('ลบข้อมูลสำเร็จ', 'เเจ้งเตือน', {
      timeOut: 3000,
      positionClass: 'toast-top-right',
    });
  }
69 70 71 72 73 74 75 76 77 78 79
  addUser() {
    console.log('เพิ่มผู้ใช้งาน');
  }

  deleteUser() {
    console.log('ลบผู้ใช้งาน');
  }

  editUser() {
    console.log('แก้ไขผู้ใช้งาน');
  }
80 81

  
82 83
}