Commit ce3ce317 by kantavee

input add>search edit>search clear ทะเบียนส่วนกับส่วนย่อยที่2

parent c8c4c04c
......@@ -156,17 +156,16 @@
<div class="ti-modal-body">
<label class="ti-form-label mt-2rem">อยู่ภายใต้หน่วยงาน</label>
<div class="flex">
<div class="flex rounded-md w-1/2">
<input type="text"
class="ti-form-input rounded-none ltr:rounded-l-md br-transparent focus:z-10 br-transparent ti-form-input-no-border-left border-radius-0.25"
[(ngModel)]="bu1.bu1id" (ngModelChange)="bu1idChange()">
<div
class="w-auto inline-flex flex-shrink-0 justify-center items-center h-[2.875rem] w-[2.875rem] border focus:z-10 focus:outline-none focus:ring-0 focus:ring-primary transition-all text-sm bx-transparent">
<i class="ti ti-circle-x text-red-500 cursor-pointer right-10" (click)="selectBu1()"></i>
</div>
<div
class="inline-flex flex-shrink-0 justify-center items-center h-[2.875rem] w-[2.875rem] ltr:rounded-r-md rtl:rounded-l-md border focus:z-10 focus:outline-none focus:ring-0 focus:ring-primary transition-all text-sm bl-transparent border-radius-0.25">
<i class="ri-search-line cursor-pointer text-gray" data-hs-overlay="#department-list-bu1-table-modal"></i>
<div class="relative flex rounded-md">
<input type="text" id="hs-leading-button-add-on-with-icon-and-button" name="hs-leading-button-add-on-with-icon-and-button" class="ti-form-input rounded-none ltr:rounded-r-md rtl:rounded-l-md focus:z-10" style="padding-right: 3.5rem;"
[(ngModel)]="bu1.bu1id" (ngModelChange)="bu1idChange()">
<div class="absolute inset-y-0 ltr:right-0 rtl:left-0 flex items-center z-20 ltr:pr-4 rtl:pl-4 space-x-2">
<button type="button" class="flex items-center text-red-500" (click)="selectBu1()">
<i class="ti ti-circle-x cursor-pointer"></i>
</button>
<button type="button" class="flex items-center text-gray-500 dark:text-white/70" data-hs-overlay="#department-list-bu1-table-modal">
<i class="ri-search-line cursor-pointer text-gray"></i>
</button>
</div>
</div>
<div class="flex rounded-md w-1/2 pl-1rem">
......@@ -175,17 +174,16 @@
</div>
</div>
<label class="ti-form-label mt-2rem">เเผนก</label>
<div class="flex rounded-md w-1/2">
<input type="text"
class="ti-form-input rounded-none ltr:rounded-l-md br-transparent focus:z-10 br-transparent ti-form-input-no-border-left border-radius-0.25"
[(ngModel)]="bu2.bu2id" (ngModelChange)="bu2idChange()">
<div
class="w-auto inline-flex flex-shrink-0 justify-center items-center h-[2.875rem] w-[2.875rem] border focus:z-10 focus:outline-none focus:ring-0 focus:ring-primary transition-all text-sm bx-transparent">
<i class="ti ti-circle-x text-red-500 cursor-pointer right-10" (click)="selectBu2()"></i>
</div>
<div
class="inline-flex flex-shrink-0 justify-center items-center h-[2.875rem] w-[2.875rem] ltr:rounded-r-md rtl:rounded-l-md border focus:z-10 focus:outline-none focus:ring-0 focus:ring-primary transition-all text-sm bl-transparent border-radius-0.25">
<i class="ri-search-line cursor-pointer text-gray" data-hs-overlay="#department-list-bu2-table-modal"></i>
<div class="relative flex rounded-md w-1/2">
<input type="text" id="hs-leading-button-add-on-with-icon-and-button" name="hs-leading-button-add-on-with-icon-and-button" class="ti-form-input rounded-none ltr:rounded-r-md rtl:rounded-l-md focus:z-10" style="padding-right: 3.5rem;"
[(ngModel)]="bu2.bu2id" (ngModelChange)="bu2idChange()">
<div class="absolute inset-y-0 ltr:right-0 rtl:left-0 flex items-center z-20 ltr:pr-4 rtl:pl-4 space-x-2">
<button type="button" class="flex items-center text-red-500" (click)="selectBu2()">
<i class="ti ti-circle-x cursor-pointer"></i>
</button>
<button type="button" class="flex items-center text-gray-500 dark:text-white/70" data-hs-overlay="#department-list-bu2-table-modal">
<i class="ri-search-line cursor-pointer text-gray"></i>
</button>
</div>
</div>
<label for="detail_th" class="ti-form-label mt-2rem">รายละเอียด (ไทย)</label>
......@@ -251,18 +249,16 @@
<label for="hs-trailing-button-add-on-with-icon"
class="ti-form-label mt-2rem">อยู่ภายใต้หน่วยงาน</label>
<div class="flex">
<div class="flex rounded-md w-1/2">
<input type="text" id="hs-trailing-button-add-on-with-icon"
name="hs-trailing-button-add-on-with-icon"
class="ti-form-input rounded-none ltr:rounded-l-md br-transparent focus:z-10 br-transparent ti-form-input-no-border-left border-radius-0.25"
[(ngModel)]="bu1.bu1id" (ngModelChange)="bu1idChange()">
<div
class="w-auto inline-flex flex-shrink-0 justify-center items-center h-[2.875rem] w-[2.875rem] border focus:z-10 focus:outline-none focus:ring-0 focus:ring-primary transition-all text-sm bx-transparent">
<i class="ti ti-circle-x text-red-500 cursor-pointer right-10" (click)="selectBu1()"></i>
</div>
<div
class="inline-flex flex-shrink-0 justify-center items-center h-[2.875rem] w-[2.875rem] ltr:rounded-r-md rtl:rounded-l-md border focus:z-10 focus:outline-none focus:ring-0 focus:ring-primary transition-all text-sm bl-transparent border-radius-0.25">
<i class="ri-search-line cursor-pointer text-gray" data-hs-overlay="#department-list-bu1-table-modal"></i>
<div class="relative flex rounded-md">
<input type="text" id="hs-leading-button-add-on-with-icon-and-button" name="hs-leading-button-add-on-with-icon-and-button" class="ti-form-input rounded-none ltr:rounded-r-md rtl:rounded-l-md focus:z-10" style="padding-right: 3.5rem;"
[(ngModel)]="bu1.bu1id" (ngModelChange)="bu1idChange()">
<div class="absolute inset-y-0 ltr:right-0 rtl:left-0 flex items-center z-20 ltr:pr-4 rtl:pl-4 space-x-2">
<button type="button" class="flex items-center text-red-500" (click)="selectBu1()">
<i class="ti ti-circle-x cursor-pointer"></i>
</button>
<button type="button" class="flex items-center text-gray-500 dark:text-white/70" data-hs-overlay="#department-list-bu1-table-modal">
<i class="ri-search-line cursor-pointer text-gray"></i>
</button>
</div>
</div>
<div class="flex rounded-md w-1/2 pl-1rem">
......
......@@ -16,4 +16,21 @@ table.ti-custom-table thead {
table.ti-custom-table thead th span {
font-size: 12px;
font-weight: bold;
}
.ti-modal-content-search{
width: 90%; /* ความกว้างที่คุณต้องการ */
position: absolute; /* ทำให้สามารถจัดตำแหน่งได้ */
top: 50%; /* ให้อยู่กลางในแนวตั้ง */
left: 50%; /* ให้อยู่กลางในแนวนอน */
transform: translate(-50%, -50%); /* เคลื่อนที่ modal กลับมาให้ตรงกลาง */
background-color: #fff;
overflow-y: auto;
}
.ti-modal-body-search {
display: flex; /* ใช้ flexbox เพื่อจัดตำแหน่ง */
justify-content: center; /* จัดฟอร์มให้อยู่กลางในแนวนอน */
flex-direction: column; /* ทำให้ฟอร์มแสดงผลในรูปแบบคอลัมน์ */
height: calc(100% - 50px); /* ให้ความสูงเป็น 100% ลบด้วยระยะห่างข้างบน */
margin-left: 100px;
margin-right: 50px;
}
\ No newline at end of file
import { Component, EventEmitter, Input, OnInit, } from '@angular/core';
import { ToastrService } from 'ngx-toastr';
import { Bu2Model, MyBu2Model } from 'src/app/shared/model/bu2.model';
import { Bu3Model, MyBu3Model } from 'src/app/shared/model/bu3.model';
import { Bu2Service } from 'src/app/shared/services/bu2.service';
import { Bu3Service } from 'src/app/shared/services/bu3.service';
interface table {
currentPage: number,
page: number[],
search: string
}
@Component({
selector: 'app-section-registration',
templateUrl: './section-registration.component.html',
styleUrls: ['./section-registration.component.scss']
})
export class SectionRegistrationComponent implements OnInit {
currentPage = 1
page = Array.from({ length: 1 }, (_, i) => i + 1);
bu3List: Bu3Model[] = []
bu3: Bu3Model = new MyBu3Model({})
bu3Table: table = {
currentPage: 1,
page: Array.from({ length: 1 }, (_, i) => i + 1),
search: ""
}
bu3Modal: table = {
currentPage: 1,
page: Array.from({ length: 1 }, (_, i) => i + 1),
search: ""
}
bu2List: Bu2Model[] = []
bu2: Bu2Model = new MyBu2Model({})
search = ""
bu2Modal: table = {
currentPage: 1,
page: Array.from({ length: 1 }, (_, i) => i + 1),
search: ""
}
currentModal = ""
constructor(private bu3Service: Bu3Service,
private bu2Service: Bu2Service
private bu2Service: Bu2Service,
private toastr: ToastrService
) { }
ngOnInit(): void {
this.getBu3List()
this.getBu2List()
}
getBu3List() {
this.bu3Service.getList().subscribe(response => {
this.bu3List = response
this.searchChange()
this.onBu3TableSearchChange()
})
}
searchChange() {
this.currentPage = 1
this.page = Array.from({ length: Math.ceil(this.bu3ListFilter().length / 10) }, (_, i) => i + 1);
onBu3TableSearchChange() {
this.bu3Table.currentPage = 1
this.bu3Table.page = Array.from({ length: Math.ceil(this.filterBu3Table().length / 10) }, (_, i) => i + 1);
}
bu3ListFilter() {
return this.bu3List.filter(x => x.bu3id.toLowerCase().includes(this.search) ||
x.tdesc.toLowerCase().includes(this.search) ||
x.edesc.toLowerCase().includes(this.search))
filterBu3Table() {
return this.bu3List.filter(x => x.bu3id.toLowerCase().includes(this.bu3Table.search) ||
x.tdesc.toLowerCase().includes(this.bu3Table.search) ||
x.edesc.toLowerCase().includes(this.bu3Table.search))
}
selectBu3(bu3: Bu3Model) {
this.bu2Service.getById(bu3.parent).subscribe(response =>{
this.bu2 = response
})
this.bu3 = new MyBu3Model(bu3)
selectBu3(bu3?: Bu3Model) {
this.bu3 = new MyBu3Model(bu3 || {})
this.selectBu2()
if (this.bu3.parent) {
this.bu2Service.getById(this.bu3.parent).subscribe(response => {
this.bu2 = new MyBu2Model(response)
})
}
}
bu3idChange() {
const bu3 = this.bu3List.find(x => x.bu3id == this.bu3.bu3id)
this.selectBu3(bu3 || new MyBu3Model({ bu3id: this.bu3.bu3id }))
}
onBu3ModalSearchChange() {
this.bu3Modal.currentPage = 1
this.bu3Modal.page = Array.from({ length: Math.ceil(this.filterBu3Modal().length / 10) }, (_, i) => i + 1);
}
filterBu3Modal() {
return this.bu3List.filter(x => x.bu3id.toLowerCase().includes(this.bu3Modal.search) ||
x.tdesc.toLowerCase().includes(this.bu3Modal.search) ||
x.edesc.toLowerCase().includes(this.bu3Modal.search))
}
addBu3() {
// this.bu3Service.post(this.bu3).subscribe((response:any) => {
......@@ -52,11 +88,41 @@ export class SectionRegistrationComponent implements OnInit {
// })
}
deleteBu3(bu3: Bu3Model) {
// this.bu3Service.delete(new MyBu1Model(bu3)).subscribe((response:any) => {
// this.bu3Service.delete(new MyBu3Model(bu3)).subscribe((response:any) => {
// if (response.success) {
// this.getBu3List()
// }
// })
}
getBu2List() {
this.bu2Service.getList().subscribe(response => {
this.bu2List = response
this.onBu2ModalSearchChange()
})
}
onBu2ModalSearchChange() {
this.bu2Modal.currentPage = 1
this.bu2Modal.page = Array.from({ length: Math.ceil(this.filterBu2Modal().length / 10) }, (_, i) => i + 1);
}
bu2idChange() {
const bu2 = this.bu2List.find(x => x.bu2id == this.bu2.bu2id)
this.selectBu2(bu2 || new MyBu2Model({ bu2id: this.bu2.bu2id }))
}
filterBu2Modal() {
return this.bu2List.filter(x => x.bu2id.toLowerCase().includes(this.bu2Modal.search) ||
x.tdesc.toLowerCase().includes(this.bu2Modal.search) ||
x.edesc.toLowerCase().includes(this.bu2Modal.search))
}
selectBu2(bu2?: Bu2Model) {
this.bu2 = new MyBu2Model(bu2 || {})
}
showSuccess() {
this.toastr.success('This is an example of tip', 'TIP', {
timeOut: 3000,
positionClass: 'toast-top-right',
});
}
}
import { Component, EventEmitter, Input, OnInit } from '@angular/core';
import { Component, EventEmitter, Input, OnInit, } from '@angular/core';
import { ToastrService } from 'ngx-toastr';
import { Bu4Model, MyBu4Model } from 'src/app/shared/model/bu4.model';
import { Bu5Model, MyBu5Model } from 'src/app/shared/model/bu5.model';
import { Bu4Service } from 'src/app/shared/services/bu4.service';
import { Bu5Service } from 'src/app/shared/services/bu5.service';
interface table {
currentPage: number,
page: number[],
search: string
}
@Component({
selector: 'app-sub-department-two',
templateUrl: './sub-department-two.component.html',
styleUrls: ['./sub-department-two.component.scss']
})
export class SubDepartmentTwoComponent implements OnInit {
currentPage = 1
page = Array.from({ length: 1 }, (_, i) => i + 1);
bu5List: Bu5Model[] = []
bu5: Bu5Model = new MyBu5Model({})
bu5Table: table = {
currentPage: 1,
page: Array.from({ length: 1 }, (_, i) => i + 1),
search: ""
}
bu5Modal: table = {
currentPage: 1,
page: Array.from({ length: 1 }, (_, i) => i + 1),
search: ""
}
bu4List: Bu4Model[] = []
bu4: Bu4Model = new MyBu4Model({})
search = ""
bu4Modal: table = {
currentPage: 1,
page: Array.from({ length: 1 }, (_, i) => i + 1),
search: ""
}
currentModal = ""
constructor(private bu5Service: Bu5Service,
private bu4Service: Bu4Service
private bu4Service: Bu4Service,
private toastr: ToastrService
) { }
ngOnInit(): void {
this.getBu5List()
this.getBu4List()
}
getBu5List() {
this.bu5Service.getList().subscribe(response => {
this.bu5List = response
this.searchChange()
this.onBu5TableSearchChange()
})
}
searchChange() {
this.currentPage = 1
this.page = Array.from({ length: Math.ceil(this.bu5ListFilter().length / 10) }, (_, i) => i + 1);
onBu5TableSearchChange() {
this.bu5Table.currentPage = 1
this.bu5Table.page = Array.from({ length: Math.ceil(this.filterBu5Table().length / 10) }, (_, i) => i + 1);
}
bu5ListFilter() {
return this.bu5List.filter(x => x.bu5id.toLowerCase().includes(this.search) ||
x.tdesc.toLowerCase().includes(this.search) ||
x.edesc.toLowerCase().includes(this.search))
filterBu5Table() {
return this.bu5List.filter(x => x.bu5id.toLowerCase().includes(this.bu5Table.search) ||
x.tdesc.toLowerCase().includes(this.bu5Table.search) ||
x.edesc.toLowerCase().includes(this.bu5Table.search))
}
selectBu5(bu5: Bu5Model) {
this.bu4Service.getById(bu5.parent).subscribe(response => {
this.bu4 = response
})
this.bu5 = new MyBu5Model(bu5)
selectBu5(bu5?: Bu5Model) {
this.bu5 = new MyBu5Model(bu5 || {})
this.selectBu4()
if (this.bu5.parent) {
this.bu4Service.getById(this.bu5.parent).subscribe(response => {
this.bu4 = new MyBu4Model(response)
})
}
}
bu5idChange() {
const bu5 = this.bu5List.find(x => x.bu5id == this.bu5.bu5id)
this.selectBu5(bu5 || new MyBu5Model({ bu5id: this.bu5.bu5id }))
}
onBu5ModalSearchChange() {
this.bu5Modal.currentPage = 1
this.bu5Modal.page = Array.from({ length: Math.ceil(this.filterBu5Modal().length / 10) }, (_, i) => i + 1);
}
filterBu5Modal() {
return this.bu5List.filter(x => x.bu5id.toLowerCase().includes(this.bu5Modal.search) ||
x.tdesc.toLowerCase().includes(this.bu5Modal.search) ||
x.edesc.toLowerCase().includes(this.bu5Modal.search))
}
addBu5() {
// this.bu5Service.post(this.bu5).subscribe((response:any) => {
......@@ -59,4 +95,34 @@ export class SubDepartmentTwoComponent implements OnInit {
// })
}
getBu4List() {
this.bu4Service.getList().subscribe(response => {
this.bu4List = response
this.onBu4ModalSearchChange()
})
}
onBu4ModalSearchChange() {
this.bu4Modal.currentPage = 1
this.bu4Modal.page = Array.from({ length: Math.ceil(this.filterBu4Modal().length / 10) }, (_, i) => i + 1);
}
bu4idChange() {
const bu4 = this.bu4List.find(x => x.bu4id == this.bu4.bu4id)
this.selectBu4(bu4 || new MyBu4Model({ bu4id: this.bu4.bu4id }))
}
filterBu4Modal() {
return this.bu4List.filter(x => x.bu4id.toLowerCase().includes(this.bu4Modal.search) ||
x.tdesc.toLowerCase().includes(this.bu4Modal.search) ||
x.edesc.toLowerCase().includes(this.bu4Modal.search))
}
selectBu4(bu4?: Bu4Model) {
this.bu4 = new MyBu4Model(bu4 || {})
}
showSuccess() {
this.toastr.success('This is an example of tip', 'TIP', {
timeOut: 3000,
positionClass: 'toast-top-right',
});
}
}
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