Commit 010a45cb by Mon

เอาโค้ดส่วนที่ไม่ใช้งานออกหน้า การจัดการประสิทธิภาพ

parent 27565d13
...@@ -22,9 +22,9 @@ ...@@ -22,9 +22,9 @@
<div class="page px-rem"> <div class="page px-rem">
<app-datagrid-syncfution [searchSettings]="searchSettings" [searchText]="search" [dataSource]="pmstype.dataList" <app-datagrid-syncfution [searchSettings]="searchSettings" [searchText]="search" [dataSource]="pmstype.dataList" [checkBoxSetting]="false"
[columns]="columns" [selectedItems]="selectedItems" [columns]="columns"
(sendSelectData)="modalStatus='edit';selectPmstype($event);openDialog()" (sendSelectedItems)="onSelectItemChange($event)"> (sendSelectData)="modalStatus='edit';selectPmstype($event);openDialog()">
</app-datagrid-syncfution> </app-datagrid-syncfution>
</div> </div>
......
...@@ -62,11 +62,8 @@ export class AssessmentTypesComponent { ...@@ -62,11 +62,8 @@ export class AssessmentTypesComponent {
this.pmstypeService.getList().subscribe({ this.pmstypeService.getList().subscribe({
next: response => { next: response => {
this.pmstype.dataList = response.map(x => { this.pmstype.dataList = response.map(x => {
this.selectedItems.data.set(x.pmsTypeId, false)
return new MyPmstypeModel(x) return new MyPmstypeModel(x)
}) })
this.selectedItems.key = 'pmsTypeId'
this.selectedItems.count = 0
this.pmstype.loading = false this.pmstype.loading = false
this.cdr.detectChanges() this.cdr.detectChanges()
}, error: error => { }, error: error => {
...@@ -117,73 +114,7 @@ export class AssessmentTypesComponent { ...@@ -117,73 +114,7 @@ export class AssessmentTypesComponent {
} }
}) })
} }
deletePmstype() {
if (!this.numSelectItem()) {
this.showAlert('กรุณาเลือกข้อมูลที่ต้องการลบ', 'error')
return
}
Swal.fire({
icon: 'question',
title: 'แจ้งเตือน',
text: 'ยืนยันการลบข้อมูลหรือไม่',
showCancelButton: true,
confirmButtonText: 'ลบข้อมูล',
cancelButtonText: 'ย้อนกลับ',
reverseButtons: true,
}).then((result) => {
if (result.isConfirmed) {
this.pmstype.loading = true
const selectedKeys = Array.from(this.selectedItems.data.keys());
const body = this.pmstype.dataList.filter(x => selectedKeys.includes(x.pmsTypeId) && this.selectedItems.data.get(x.pmsTypeId)).map(x => new MyPmstypeModel(x))
this.pmstypeService.delete(body).subscribe({
next: response => {
if (response.success) {
this.showAlert(response.message, 'success')
this.getPmstypeList()
this.closeDialog()
} else {
this.showAlert(response.message, 'error')
this.pmstype.loading = false
}
}, error: error => {
this.showAlert(error.message, 'error')
this.pmstype.loading = false
}
})
}
});
}
updatePmstype(typeApi: 'post' | 'delete') {
let body: PmstypeModel | PmstypeModel[]
switch (this.modalStatus) {
case ('delete'): {
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: {
body = new MyPmstypeModel(this.pmstype.select)
}
}
this.pmstype.loading = true
this.pmstypeService[typeApi]((body as any)).subscribe({
next: response => {
if (response.success) {
this.showAlert(response.message, 'success')
this.getPmstypeList()
} else {
this.showAlert(response.message, 'error')
this.pmstype.loading = false
}
this.cdr.detectChanges()
}, error: error => {
this.showAlert(error.message, 'error')
this.pmstype.loading = false
this.cdr.detectChanges()
}
})
}
showAlert(text: string, type: 'success' | 'error') { showAlert(text: string, type: 'success' | 'error') {
this.toastr[type](text, 'แจ้งเตือน', { this.toastr[type](text, 'แจ้งเตือน', {
...@@ -253,15 +184,7 @@ export class AssessmentTypesComponent { ...@@ -253,15 +184,7 @@ export class AssessmentTypesComponent {
checkPrimary() { checkPrimary() {
return this.pmstype.dataList.find(x => x.pmsTypeId == this.pmstype.select.pmsTypeId) 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
}
openDialog() { openDialog() {
this.dialogRef = this.dialog.open(this.assessmentTypesModal, { this.dialogRef = this.dialog.open(this.assessmentTypesModal, {
......
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