Commit 86f746d2 by Nattana Chaiyamat

ข้อมูลทั่วไป

parent 7b2e3831
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<div class="relative shadow-md"> <div class="relative shadow-md">
<input type="text" id="hs-leading-icon" name="hs-leading-icon" <input type="text" id="hs-leading-icon" name="hs-leading-icon"
class="ti-form-input ltr:pl-11 rtl:pr-11 focus:z-10 " placeholder="Search by No. or Name" class="ti-form-input ltr:pl-11 rtl:pr-11 focus:z-10 " placeholder="Search by No. or Name"
[(ngModel)]="search" (ngModelChange)="searchChange()"> [(ngModel)]="search">
<div <div
class="absolute inset-y-0 ltr:left-0 rtl:right-0 flex items-center pointer-events-none z-20 ltr:pl-4 rtl:pr-4"> class="absolute inset-y-0 ltr:left-0 rtl:right-0 flex items-center pointer-events-none z-20 ltr:pl-4 rtl:pr-4">
...@@ -23,81 +23,19 @@ ...@@ -23,81 +23,19 @@
</div> </div>
<div class="px-1"> <div class="px-1">
<button type="button" class="ti-btn ti-btn-soft-secondary h-45px m-0 shadow-md" <button type="button" class="ti-btn ti-btn-soft-secondary h-45px m-0 shadow-md"
data-hs-overlay="#sub-job-competency-component-modal-edit" (click)="add();modalStatus='add';"> data-hs-overlay="#sub-job-competency-component-modal-edit" (click)="add();currentModal='add';">
<i class="ri-add-line"></i> <i class="ri-add-line"></i>
Add Add
</button> </button>
</div> </div>
<!-- <div class="px-1">
<button href="javascript:void(0);" class="ti-btn ti-btn-soft-danger h-45px m-0 shadow-md"
data-hs-overlay="#sub-command-structure-alert-delete-modal">
<i class="ri-delete-bin-6-line"></i>
Delete
</button>
</div> -->
<!-- <div class="px-1">
<button href="javascript:void(0);" class="ti-btn ti-btn-soft-warning h-45px m-0 shadow-md">
<i class="ti ti-book fs-l"></i>
Help
</button>
</div> -->
</div> </div>
</div> </div>
<div class="page px-rem"> <div class="page px-rem">
<div class="overflow-auto shadow-md rounded-t-md"> <app-datagrid-syncfution [searchSettings]="searchSettings" [searchText]="search" [dataSource]="jobCodeList"
<table class="ti-custom-table ti-custom-table-head ti-custom-table-hover table-bordered"> [columns]="columns" [selectedItems]="selectedItems" modalName="#sub-job-competency-component-modal-edit"
<thead> (sendSelectData)="currentModal='edit';edit($event)" (sendSelectedItems)="onSelectItemChange($event)">
<tr> </app-datagrid-syncfution>
<ng-container
*ngFor="let item of ['ลำดับ','รหัสงาน','ชื่อลักษณะงาน (ไทย)','ชื่อลักษณะงาน (อังกฤษ)','การจัดการ']; let f = first; let l = last; let i = index">
<th scope="col" class="relative px-10px py-10px bg-soft-secondary text-primary !text-center">
<span class="font-size-12px font-weight-700">{{ item }}</span>
<div class="absolute top-1/2 transform -translate-y-1/2 right-0" *ngIf="!l">
<i class="ti ti-dots-vertical fs-l"></i>
</div>
</th>
</ng-container>
</tr>
</thead>
<tbody *ngIf="loading">
<tr>
<td class="text-center" colspan="100%">
<div *ngFor="let item of [1,2,3]" class="ti-spinner w-8 h-8 text-secondary mx-1" role="status"
aria-label="loading">
<span class="sr-only">Loading...</span>
</div>
</td>
</tr>
</tbody>
<tbody *ngIf="!loading&&!jobcodeFilter().length">
<tr>
<td class="text-center" colspan="100%">
ไม่พบข้อมูล
</td>
</tr>
</tbody>
<tbody *ngIf="!loading&&jobcodeFilter().length">
<tr
*ngFor="let item of jobcodeFilter() |slice:((currentPage-1) * pageSize) : (((currentPage-1) * pageSize) + pageSize);let i = index">
<td class="text-center">
{{((currentPage-1) * pageSize)+(i+1)}}
</td>
<td class="text-center">{{item.jobcodeId}}</td>
<td>{{item.tdesc}}</td>
<td>{{item.edesc}}</td>
<td class="flex justify-center">
<i class="ti ti-edit cursor-pointer i-gray fs-l px-1" (click)="modalStatus='edit';edit(item)"
data-hs-overlay="#sub-job-competency-component-modal-edit"></i>
<i class="ti ti-trash cursor-pointer i-gray fs-l px-1" (click)="modalStatus='delete';edit(item)"
data-hs-overlay="#company-registration-page-alert-modal"></i>
</td>
</tr>
</tbody>
</table>
</div>
<app-pagination [totalItems]="jobcodeFilter().length" [pageSize]="pageSize" (pageChange)="currentPage = $event"
(pageSizeChange)="pageSize = $event;currentPage = 1"></app-pagination>
</div> </div>
...@@ -107,7 +45,7 @@ ...@@ -107,7 +45,7 @@
<div class="max-h-full overflow-hidden ti-modal-content"> <div class="max-h-full overflow-hidden ti-modal-content">
<div class="ti-modal-header"> <div class="ti-modal-header">
<h3 class="text-xxl font-bold text-primary"> <h3 class="text-xxl font-bold text-primary">
{{modalStatus== "add"?'เพิ่มข้อมูลทั่วไป':'เเก้ไขข้อมูลทั่วไป'}} {{currentModal== "add"?'เพิ่มข้อมูลทั่วไป':'เเก้ไขข้อมูลทั่วไป'}}
</h3> </h3>
<div class="flex justify-end"> <div class="flex justify-end">
<button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger" <button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger"
...@@ -147,13 +85,13 @@ ...@@ -147,13 +85,13 @@
</div> </div>
<div class="ti-modal-body" style="padding-top: 0px;"> <div class="ti-modal-body" style="padding-top: 0px;">
<label for="input-label" class="ti-form-label mt-1rem">รหัสงาน<span class="text-danger">* <label for="input-label" class="ti-form-label mt-1rem">รหัสงาน<span class="text-danger">*
<ng-container *ngIf="modalStatus=='add'&&checkPrimary()"> <ng-container *ngIf="currentModal=='add'&&checkPrimary()">
รหัสงานซ้ำ รหัสงานซ้ำ
</ng-container> </ng-container>
</span></label> </span></label>
<input type="text" id="input-label" <input type="text" id="input-label"
class="ti-form-input {{modalStatus == 'edit' ? 'bg-input-readonly' : ''}}" class="ti-form-input {{currentModal == 'edit' ? 'bg-input-readonly' : ''}}"
[attr.readonly]="modalStatus == 'edit' ? true : null" [(ngModel)]="selectJob.jobcodeId" [attr.readonly]="currentModal == 'edit' ? true : null" [(ngModel)]="selectJob.jobcodeId"
(ngModelChange)="checkJodid()"> (ngModelChange)="checkJodid()">
<label for="detail_th" class="ti-form-label mt-1rem">ชื่อลักษณะงาน (ไทย)<span <label for="detail_th" class="ti-form-label mt-1rem">ชื่อลักษณะงาน (ไทย)<span
class="text-danger">*</span></label> class="text-danger">*</span></label>
...@@ -226,8 +164,8 @@ ...@@ -226,8 +164,8 @@
ย้อนกลับ ย้อนกลับ
</button> </button>
<button <button
class="ti-btn ti-btn-success {{checkJobCodeId&&modalStatus=='add'||!selectJob.jobcodeId||!selectJob.tdesc||(modalStatus=='add'&&checkPrimary()) ? 'ti-btn-disabled' : ''}}" class="ti-btn ti-btn-success {{checkJobCodeId&&currentModal=='add'||!selectJob.jobcodeId||!selectJob.tdesc||(currentModal=='add'&&checkPrimary()) ? 'ti-btn-disabled' : ''}}"
[disabled]="checkJobCodeId&&modalStatus=='add'||!selectJob.jobcodeId||!selectJob.tdesc||(modalStatus=='add'&&checkPrimary())" [disabled]="checkJobCodeId&&currentModal=='add'||!selectJob.jobcodeId||!selectJob.tdesc||(currentModal=='add'&&checkPrimary())"
data-hs-overlay="#company-registration-page-alert-modal"> data-hs-overlay="#company-registration-page-alert-modal">
บันทึกข้อมูล บันทึกข้อมูล
</button> </button>
...@@ -254,16 +192,16 @@ ...@@ -254,16 +192,16 @@
</div> </div>
<div class="ti-modal-body "> <div class="ti-modal-body ">
<p class="mt-1 text-gray-800 dark:text-white/70"> <p class="mt-1 text-gray-800 dark:text-white/70">
<ng-container *ngIf="modalStatus=='add'||modalStatus=='edit'"> <ng-container *ngIf="currentModal=='add'||currentModal=='edit'">
ยืนยันการบันทึกข้อมูลหรือไม่ ยืนยันการบันทึกข้อมูลหรือไม่
</ng-container> </ng-container>
<ng-container *ngIf="modalStatus=='delete'||modalStatus=='deleteGroup'"> <ng-container *ngIf="currentModal=='delete'">
ยืนยันการลบข้อมูลหรือไม่ ยืนยันการลบข้อมูลหรือไม่
</ng-container> </ng-container>
</p> </p>
<div class="flex justify-end mt-2rem mb-1rem"> <div class="flex justify-end mt-2rem mb-1rem">
<ng-container *ngIf="modalStatus=='add'||modalStatus=='edit'"> <ng-container *ngIf="currentModal=='add'||currentModal=='edit'">
<button type="button" <button type="button"
class="hs-dropdown-toggle ti-btn ti-border font-medium bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white focus:ring-primary dark:bg-bgdark dark:hover:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-white dark:focus:ring-offset-white/10" class="hs-dropdown-toggle ti-btn ti-border font-medium bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white focus:ring-primary dark:bg-bgdark dark:hover:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-white dark:focus:ring-offset-white/10"
data-hs-overlay="#company-registration-page-alert-modal"> data-hs-overlay="#company-registration-page-alert-modal">
...@@ -274,7 +212,7 @@ ...@@ -274,7 +212,7 @@
บันทึกข้อมูล บันทึกข้อมูล
</a> </a>
</ng-container> </ng-container>
<ng-container *ngIf="modalStatus=='delete'||modalStatus=='deleteGroup'"> <ng-container *ngIf="currentModal=='delete'">
<button type="button" <button type="button"
class="hs-dropdown-toggle ti-btn ti-border font-medium bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white focus:ring-primary dark:bg-bgdark dark:hover:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-white dark:focus:ring-offset-white/10" class="hs-dropdown-toggle ti-btn ti-border font-medium bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white focus:ring-primary dark:bg-bgdark dark:hover:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-white dark:focus:ring-offset-white/10"
data-hs-overlay="#company-registration-page-alert-modal"> data-hs-overlay="#company-registration-page-alert-modal">
......
import { ChangeDetectorRef, Component } from '@angular/core'; import { ChangeDetectorRef, Component } from '@angular/core';
import { ColumnModel } from '@syncfusion/ej2-grids';
import { ToastrService } from 'ngx-toastr'; import { ToastrService } from 'ngx-toastr';
import { Bu1Model, MyBu1Model } from 'src/app/shared/model/bu1.model'; import { Bu1Model, MyBu1Model } from 'src/app/shared/model/bu1.model';
import { Bu2Model, MyBu2Model } from 'src/app/shared/model/bu2.model'; import { Bu2Model, MyBu2Model } from 'src/app/shared/model/bu2.model';
...@@ -28,9 +29,6 @@ import { PositionService } from 'src/app/shared/services/position.service'; ...@@ -28,9 +29,6 @@ import { PositionService } from 'src/app/shared/services/position.service';
styleUrls: ['./import-data.component.scss'] styleUrls: ['./import-data.component.scss']
}) })
export class ImportDataComponent { export class ImportDataComponent {
currentPage = 1
page = Array.from({ length: 1 }, (_, i) => i + 1);
pageSize = 10
search = "" search = ""
jobCodeList: JobCodeModel[] = [] jobCodeList: JobCodeModel[] = []
loading = false loading = false
...@@ -39,7 +37,6 @@ export class ImportDataComponent { ...@@ -39,7 +37,6 @@ export class ImportDataComponent {
selectedFileName: string = 'กรุณาเลือกไฟล์'; selectedFileName: string = 'กรุณาเลือกไฟล์';
selectJob: JobCodeModel = new MyJobCodeModel({}) selectJob: JobCodeModel = new MyJobCodeModel({})
modalStatus = ''
positionList: PositionModel[] = [] positionList: PositionModel[] = []
positionId = '' positionId = ''
...@@ -68,6 +65,30 @@ export class ImportDataComponent { ...@@ -68,6 +65,30 @@ export class ImportDataComponent {
supervisorPositionId = '' supervisorPositionId = ''
employeeList: EmployeeModel[] = [] employeeList: EmployeeModel[] = []
checkJobCodeId = false checkJobCodeId = false
currentModal: 'add' | 'edit' | 'delete' = "add"
columns: ColumnModel[] = [{
field: "jobcodeId",
headerText: "ชื่อล็อกอิน",
type: "string",
isPrimaryKey: true,
},
{
field: "tdesc",
headerText: "ชื่อลักษณะงาน (ไทย)",
type: "string"
},
{
field: "edesc",
headerText: "ชื่อลักษณะงาน (อังกฤษ)",
type: "string"
}]
searchSettings = {
fields: ['jobcodeId', 'tdesc', 'edesc'],
operator: 'contains',
ignoreCase: false
}
selectedItems: { key: string, count: number, data: Map<string, boolean> } = { key: '', count: 0, data: new Map<string, boolean>() };
constructor( constructor(
private toastr: ToastrService, private toastr: ToastrService,
private fileService: FileService, private fileService: FileService,
...@@ -112,10 +133,13 @@ export class ImportDataComponent { ...@@ -112,10 +133,13 @@ export class ImportDataComponent {
this.loading = false this.loading = false
this.jobcodeService.getList().subscribe({ this.jobcodeService.getList().subscribe({
next: response => { next: response => {
this.jobCodeList = response.map((x: any) => new MyJobCodeModel(x)) this.jobCodeList = response.map((x: any) => {
this.jobCodeList = this.jobCodeList.sort((a, b) => a.jobcodeId.localeCompare(b.jobcodeId)) this.selectedItems.data.set(x.jobcodeId, false)
return new MyJobCodeModel(x)
})
this.selectedItems.key = 'jobcodeId'
this.selectedItems.count = 0
this.loading = false this.loading = false
this.searchChange()
this.cdr.detectChanges() this.cdr.detectChanges()
}, error: error => { }, error: error => {
this.loading = false this.loading = false
...@@ -141,7 +165,6 @@ export class ImportDataComponent { ...@@ -141,7 +165,6 @@ export class ImportDataComponent {
this.bu5Id = item.bu5.bu5id this.bu5Id = item.bu5.bu5id
this.bu6Id = item.bu6.bu6id this.bu6Id = item.bu6.bu6id
this.bu7Id = item.bu7.bu7id this.bu7Id = item.bu7.bu7id
console.log("🚀 ~ ImportDataComponent ~ edit ~ this.selectJob:", this.selectJob)
} }
add() { add() {
this.selectJob = new MyJobCodeModel({}) this.selectJob = new MyJobCodeModel({})
...@@ -157,10 +180,6 @@ export class ImportDataComponent { ...@@ -157,10 +180,6 @@ export class ImportDataComponent {
this.bu7Id = '' this.bu7Id = ''
} }
searchChange() {
this.currentPage = 1
this.page = Array.from({ length: Math.ceil(this.jobcodeFilter().length / this.pageSize) }, (_, i) => i + 1);
}
clearValue() { clearValue() {
this.selectJob.jobObjective = '' this.selectJob.jobObjective = ''
...@@ -205,7 +224,9 @@ export class ImportDataComponent { ...@@ -205,7 +224,9 @@ export class ImportDataComponent {
}) })
} }
deleteJob() { deleteJob() {
this.jobcodeService.delete(this.selectJob).subscribe((response: any) => { const selectedKeys = Array.from(this.selectedItems.data.keys());
const body = this.jobCodeList.filter(x => selectedKeys.includes(x.jobcodeId) && this.selectedItems.data.get(x.jobcodeId)).map(x => new MyJobCodeModel(x))
this.jobcodeService.delete(body).subscribe((response: any) => {
if (response.success) { if (response.success) {
this.showAlert(response.message, 'success') this.showAlert(response.message, 'success')
this.selectJob = new MyJobCodeModel({}) this.selectJob = new MyJobCodeModel({})
...@@ -216,13 +237,7 @@ export class ImportDataComponent { ...@@ -216,13 +237,7 @@ export class ImportDataComponent {
this.cdr.detectChanges() this.cdr.detectChanges()
}) })
} }
jobcodeFilter() {
return this.jobCodeList.filter(x =>
x.tdesc.toLowerCase().includes(this.search.toLowerCase()) ||
x.edesc.toLowerCase().includes(this.search.toLowerCase()) ||
x.jobcodeId.toLowerCase().includes(this.search.toLowerCase())
)
}
onFileSelected(event: any) { onFileSelected(event: any) {
this.selectedFile = event.target.files.length > 0 ? event.target.files[0] : null; this.selectedFile = event.target.files.length > 0 ? event.target.files[0] : null;
this.selectedFileName = this.selectedFile?.name || "กรุณาเลือกไฟล์" this.selectedFileName = this.selectedFile?.name || "กรุณาเลือกไฟล์"
...@@ -444,4 +459,14 @@ export class ImportDataComponent { ...@@ -444,4 +459,14 @@ export class ImportDataComponent {
checkPrimary() { checkPrimary() {
return this.jobCodeList.find(x => x.jobcodeId == this.selectJob.jobcodeId) return this.jobCodeList.find(x => x.jobcodeId == this.selectJob.jobcodeId)
} }
numSelectItem() {
const selectedKeys = Array.from(this.selectedItems.data.keys());
const num = this.jobCodeList.filter(x => selectedKeys.includes(x.jobcodeId) && this.selectedItems.data.get(x.jobcodeId)).length
return num
}
onSelectItemChange(arg: any) {
this.selectedItems = arg
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment