Commit 63c6a8ac by DESKTOP-E3GSHH7\myhr

การประเมินจัดการประสิทธิภาพ>ทะเบียนกำหนดชื่อ

parent 64a5c116
......@@ -76,6 +76,7 @@ export class AssessmentTopicsComponent {
selectPmstype(data?: PmstypeModel) {
this.pmstopic.select.pmsType = new MyPmstypeModel(data)
}
getPmstopicList() {
this.pmstopic.loading = true
this.pmstopicService.getList().subscribe({
......
<div class="w-full min-height-50px mb-10px justify-between items-center">
<div class="flex justify-between">
<div class="flex">
<!-- <div class="flex items-center">
<input type="checkbox" class="ti-form-checkbox pointer-events-none" id="hs-default-checkbox"
[(ngModel)]="isDataListChecked">
<label for="hs-default-checkbox" class="text-sm text-gray-500 mx-2 pointer-events-none">
{{numDataListChecked}} Selected</label>
</div>
<div class="mx-1 flex items-center">
<button (click)="isDataListCheckedAll = !isDataListCheckedAll;dataListCheckAll()"
class="focus:ring-2 focus:ring-primary rounded-sm flex item-center">
<i class="fs-l transition-all duration-200"
[ngClass]="{'ri-checkbox-multiple-line text-gray-500': !isDataListCheckedAll, 'ri-checkbox-multiple-fill text-primary': isDataListCheckedAll}"></i>
</button>
<label class="text-sm text-gray-500 ml-2">Select All</label>
</div> -->
</div>
<div class="flex justify-end">
......@@ -22,138 +9,23 @@
<div class="relative shadow-md">
<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"
[(ngModel)]="search" (ngModelChange)="searchChange()" style="height: 40px;">
[(ngModel)]="search" style="height: 40px;">
<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">
<i class="ri-search-line text-gray"></i>
</div>
</div>
</div>
<!-- <div class="px-1">
<button type="button"
class="ti-btn ti-btn bg-pink-500/10 text-pink-500 hover:text-white hover:bg-pink-500 ring-offset-white focus:ring-pink-500 dark:focus:ring-offset-white/10 h-10 m-0 shadow-md"
data-hs-overlay="#assessment-typead-upload-modal"
(click)="fileInput.value = '';selectedFile=null;selectedFileName = 'กรุณาเลือกไฟล์'">
<i class="ti ti-file-plus"></i>
import
</button>
</div> -->
<!-- <div class="px-1">
<button type="button" class="ti-btn ti-btn-soft-secondary h-10 m-0 shadow-md"
data-hs-overlay="#assessment-types-modal" (click)="modalStatus='add';selectPmstype()">
<i class="ri-add-line"></i>
Add
</button>
</div>
<div class="px-1">
<button href="javascript:void(0);" class="ti-btn ti-btn-soft-danger h-10 m-0 shadow-md"
data-hs-overlay="#assessment-types-alert-modal" (click)="modalStatus='deleteGroup';selectPmstype()">
<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-10 m-0 shadow-md">
<i class="ti ti-book fs-l"></i>
Help
</button>
</div> -->
</div>
</div>
</div>
<div class="page px-rem">
<div class="overflow-auto shadow-md rounded-t-md">
<table class="ti-custom-table ti-custom-table-head ti-custom-table-hover table-bordered">
<thead>
<tr>
<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="pmstype.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="!pmstype.loading&&!pmstypeListFilter().length">
<tr>
<td class="text-center" colspan="100%">
ไม่พบข้อมูล
</td>
</tr>
</tbody>
<tbody *ngIf="!pmstype.loading&&pmstypeListFilter().length">
<tr
*ngFor="let item of pmstypeListFilter()| slice:((currentPage-1) * 10) : (((currentPage-1) * 10) + 10);let i = index">
<td class="text-center">
<!-- <input type="checkbox" class="ti-form-checkbox cursor-pointer"
id="checkbox-{{item.data.pmsTypeId}}" [(ngModel)]="item.check" (change)="dataListCheck()"> -->
<label for="checkbox-{{item.data.pmsTypeId}}">&nbsp;{{item.data.pmsTypeId}}</label>
</td>
<td>{{item.data.tdesc}}</td>
<td class="text-center">{{item.data.shortName}}</td>
<td class="flex justify-center">
<i class="ti ti-edit cursor-pointer i-gray fs-l px-1"
(click)="modalStatus='edit';selectPmstype(item.data)"
data-hs-overlay="#assessment-types-modal"></i>
<!-- <i class="ti ti-trash cursor-pointer i-gray fs-l px-1"
(click)="modalStatus='delete';selectPmstype(item.data)"
data-hs-overlay="#assessment-types-alert-modal"></i> -->
</td>
</tr>
</tbody>
</table>
</div>
<nav class="pagination-style-3 overflow-auto my-5" *ngIf="page.length">
<ul class="ti-pagination">
<li>
<a aria-label="anchor" class="page-link" href="javascript:void(0);"
(click)="currentPage = (currentPage-1 || 1)">
<i class="ri-arrow-left-s-line align-middle rtl:rotate-180"></i>
</a>
</li>
<li *ngFor="let item of page;let f = first;let l = last">
<ng-container *ngIf="item==3&&currentPage!=1&&currentPage!=2&&currentPage!=3">
<a aria-label="anchor" class="page-link" href="javascript:void(0);"><i class="ri-more-line"></i>
</a>
</ng-container>
<ng-container *ngIf="(f||l)||(item==currentPage-1||item==currentPage||item==currentPage+1)">
<a class="page-link" href="javascript:void(0);" [class.active]="item==currentPage"
(click)="currentPage=item">{{item}}
</a>
</ng-container>
<ng-container
*ngIf="item==page.length-2&&currentPage!=page.length&&currentPage!=page.length-1&&currentPage!=page.length-2">
<a aria-label="anchor" class="page-link" href="javascript:void(0);"><i class="ri-more-line"></i>
</a>
</ng-container>
</li>
<li>
<a aria-label="anchor" class="page-link" href="javascript:void(0);"
(click)="currentPage = (currentPage > page.length-1 ? currentPage: currentPage+1 )">
<i class="ri-arrow-right-s-line align-middle rtl:rotate-180"></i>
</a>
</li>
</ul>
<ul class="nav-tabs mt-3">
<span>Show {{((currentPage-1) * 10)+1}} to {{pmstypeListFilter().length<10 ?pmstypeListFilter().length:
(currentPage==page.length ? ((currentPage * 10) - ((currentPage * 10) - pmstypeListFilter().length)
) :(currentPage * 10) ) }} of {{pmstypeListFilter().length}} items</span>
</ul>
</nav>
<app-datagrid-syncfution [searchSettings]="searchSettings" [searchText]="search" [dataSource]="pmstype.dataList"
[columns]="columns" [selectedItems]="selectedItems" modalName="#assessment-types-modal"
(sendSelectData)="modalStatus='edit';selectPmstype($event)" (sendSelectedItems)="onSelectItemChange($event)">
</app-datagrid-syncfution>
</div>
......@@ -192,12 +64,6 @@
Clear
</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 class="ti-modal-body padding-16px pt-0 overflow-y-0">
......@@ -248,7 +114,7 @@
<i class="ti ti-circle-x fs-xxl"></i>
</button>
</ng-container>
<ng-container *ngIf="modalStatus=='delete'||modalStatus=='deleteGroup'">
<ng-container *ngIf="modalStatus=='delete'">
<button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger"
data-hs-overlay="#assessment-types-alert-modal">
<span class="sr-only">Close</span>
......@@ -262,11 +128,11 @@
<ng-container *ngIf="modalStatus=='add'||modalStatus=='edit'">
ยืนยันการบันทึกข้อมูลหรือไม่
</ng-container>
<ng-container *ngIf="modalStatus=='delete'||modalStatus=='deleteGroup'">
<ng-container *ngIf="numDataListChecked">
<ng-container *ngIf="modalStatus=='delete'">
<ng-container *ngIf="numSelectItem()">
ยืนยันการลบข้อมูลหรือไม่
</ng-container>
<ng-container *ngIf="!numDataListChecked">
<ng-container *ngIf="!numSelectItem()">
เลือกข้อมูลที่ต้องการลบ
</ng-container>
</ng-container>
......@@ -284,13 +150,13 @@
บันทึกข้อมูล
</a>
</ng-container>
<ng-container *ngIf="modalStatus=='delete'||modalStatus=='deleteGroup'">
<ng-container *ngIf="modalStatus=='delete'">
<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"
data-hs-overlay="#assessment-types-alert-modal">
ย้อนกลับ
</button>
<a class="ti-btn ti-btn-danger" href="javascript:void(0);" *ngIf="numDataListChecked"
<a class="ti-btn ti-btn-danger" href="javascript:void(0);" *ngIf="numSelectItem()"
data-hs-overlay="#assessment-types-alert-modal" (click)="updatePmstype('delete')">
ลบข้อมูล
</a>
......
......@@ -3,20 +3,39 @@ import { ToastrService } from 'ngx-toastr';
import { MyPmstypeModel, PmstypeModel } from 'src/app/shared/model/pmstype.model';
import { FileService } from 'src/app/shared/services/file.service';
import { PmstypeService } from 'src/app/shared/services/pmstype.service';
import { ColumnModel } from '@syncfusion/ej2-grids';
@Component({
selector: 'app-assessment-types',
templateUrl: './assessment-types.component.html',
styleUrls: ['./assessment-types.component.scss']
})
export class AssessmentTypesComponent {
currentPage = 1
page = Array.from({ length: 1 }, (_, i) => i + 1);
pmstype: { loading: boolean, select: PmstypeModel, dataList: PmstypeModel[] } = { loading: false, select: new MyPmstypeModel(), dataList: [] }
modalStatus: "add" | "edit" | 'delete' = "add"
columns: ColumnModel[] = [{
field: "pmsTypeId",
headerText: "รหัส",
type: "string",
isPrimaryKey: true,
},
{
field: "tdesc",
headerText: "ชื่อประเภท",
type: "string"
},
{
field: "shortName",
headerText: "ชื่อย่อ",
type: "string"
}]
searchSettings = {
fields: ['pmsTypeId', 'tdesc', 'shortName'],
operator: 'contains',
ignoreCase: false
};
search = ""
numDataListChecked = 0
isDataListChecked = false
isDataListCheckedAll = false
pmstype: { loading: boolean, select: PmstypeModel, dataList: { check: boolean, data: PmstypeModel }[] } = { loading: false, select: new MyPmstypeModel(), dataList: [] }
modalStatus: "add" | "edit" | 'delete' | 'deleteGroup' = "add"
selectedItems: { key: string, count: number, data: Map<string, boolean> } = { key: '', count: 0, data: new Map<string, boolean>() };
selectedFile: File | null = null;
selectedFileName: string = 'กรุณาเลือกไฟล์';
......@@ -33,13 +52,16 @@ export class AssessmentTypesComponent {
getPmstypeList() {
this.pmstype.loading = true
this.selectedItems.data.clear()
this.pmstypeService.getList().subscribe({
next: response => {
this.pmstype.dataList = response.map(x => ({ check: false, data: new MyPmstypeModel(x) }))
this.isDataListCheckedAll = false
this.dataListCheckAll()
this.pmstype.dataList = response.map(x => {
this.selectedItems.data.set(x.pmsTypeId, false)
return new MyPmstypeModel(x)
})
this.selectedItems.key = 'pmsTypeId'
this.selectedItems.count = 0
this.pmstype.loading = false
this.searchChange()
this.cdr.detectChanges()
}, error: error => {
this.pmstype.loading = false
......@@ -47,27 +69,24 @@ export class AssessmentTypesComponent {
}
})
}
pmstypeListFilter() {
return this.pmstype.dataList.filter(x => {
const data = x.data
const match = data.pmsTypeId.toLowerCase().includes(this.search.toLowerCase()) ||
data.tdesc.toLowerCase().includes(this.search.toLowerCase()) ||
data.shortName.toLowerCase().includes(this.search.toLowerCase())
return match
})
}
selectPmstype(data?: PmstypeModel) {
if (data) {
this.pmstype.select = new MyPmstypeModel(data)
} else if (this.modalStatus == 'add') {
this.pmstype.select = new MyPmstypeModel()
} else if (this.modalStatus == 'edit') {
this.pmstype.select = new MyPmstypeModel({ pmsTypeId: this.pmstype.select.pmsTypeId })
}
}
updatePmstype(typeApi: 'post' | 'delete') {
let body: PmstypeModel | PmstypeModel[]
switch (this.modalStatus) {
case ('delete'): {
body = [new MyPmstypeModel(this.pmstype.select)]
break;
}
case ('deleteGroup'): {
body = this.pmstype.dataList.filter(x => x.check).map(x => new MyPmstypeModel(x.data))
const selectedKeys = Array.from(this.selectedItems.data.keys());
body = this.pmstype.dataList.filter(x => selectedKeys.includes(x.pmsTypeId) && this.selectedItems.data.get(x.pmsTypeId)).map(x => new MyPmstypeModel(x))
break;
}
default: {
......@@ -80,7 +99,6 @@ export class AssessmentTypesComponent {
if (response.success) {
this.showAlert(response.message, 'success')
this.getPmstypeList()
this.searchChange()
} else {
this.showAlert(response.message, 'error')
this.pmstype.loading = false
......@@ -152,25 +170,6 @@ export class AssessmentTypesComponent {
}
dataListCheckAll() {
const selectAll = this.isDataListCheckedAll;
this.pmstype.dataList.filter(x => {
const data = x.data
const match = data.pmsTypeId.toLowerCase().includes(this.search.toLowerCase()) ||
data.tdesc.toLowerCase().includes(this.search.toLowerCase()) ||
data.shortName.toLowerCase().includes(this.search.toLowerCase())
return match
}).forEach(x => x.check = selectAll);
this.dataListCheck();
}
dataListCheck() {
const dataCheck = this.pmstypeListFilter();
this.isDataListCheckedAll = dataCheck.length ? dataCheck.every(x => x.check) : false;
this.numDataListChecked = this.pmstype.dataList.filter(x => x.check).length;
this.isDataListChecked = Boolean(this.numDataListChecked)
}
clearPmstype(modalStatus: string) {
if (modalStatus == 'add') {
this.selectPmstype()
......@@ -178,12 +177,20 @@ export class AssessmentTypesComponent {
this.selectPmstype(new MyPmstypeModel({ pmsTypeId: this.pmstype.select.pmsTypeId }))
}
}
searchChange() {
this.currentPage = 1
this.page = Array.from({ length: Math.ceil(this.pmstypeListFilter().length / 10) }, (_, i) => i + 1);
this.dataListCheck()
checkPrimary() {
return this.pmstype.dataList.find(x => x.pmsTypeId == this.pmstype.select.pmsTypeId)
}
numSelectItem() {
const selectedKeys = Array.from(this.selectedItems.data.keys());
const num = this.pmstype.dataList.filter(x => selectedKeys.includes(x.pmsTypeId) && this.selectedItems.data.get(x.pmsTypeId)).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