Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mySkill-x
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
angular
mySkill-x
Commits
4f17325d
Commit
4f17325d
authored
Apr 02, 2025
by
Nattana Chaiyamat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
syncfution
parent
dcd55187
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
189 additions
and
353 deletions
+189
-353
department-register.component.html
...it/department-register/department-register.component.html
+45
-194
department-register.component.ts
...unit/department-register/department-register.component.ts
+76
-59
datagrid-syncfution.component.html
...ts/datagrid-syncfution/datagrid-syncfution.component.html
+22
-13
datagrid-syncfution.component.ts
...ents/datagrid-syncfution/datagrid-syncfution.component.ts
+46
-87
No files found.
src/app/components/company-components/company-registration/branch-business-unit/department-register/department-register.component.html
View file @
4f17325d
<div
class=
"w-full min-height-50px mb-10px justify-between items-center"
>
<div
class=
"w-full min-height-50px mb-10px justify-between items-center"
>
<div
class=
"flex justify-between"
>
<
!-- <
div class="flex justify-between">
<div class="flex">
<div class="flex">
<div class="flex items-center">
<div class="flex items-center">
<input type="checkbox" class="ti-form-checkbox pointer-events-none" id="hs-default-checkbox"
<input type="checkbox" class="ti-form-checkbox pointer-events-none" id="hs-default-checkbox"
[(ngModel)]="isDataListChecked">
[(ngModel)]="isDataListChecked">
<label for="hs-default-checkbox" class="text-sm text-gray-500 mx-2 pointer-events-none">
<label for="hs-default-checkbox" class="text-sm text-gray-500 mx-2 pointer-events-none">
{{
numDataListChecked
}} Selected
</label>
{{
selectedItems.count
}} Selected</label>
</div>
</div>
<div class="mx-1 flex items-center">
<div class="mx-1 flex items-center">
<button (click)="isDataListCheckedAll = !isDataListCheckedAll;dataListCheckAll()" id='check-boxall'
<button (click)="isDataListCheckedAll = !isDataListCheckedAll;dataListCheckAll()" id='check-boxall'
...
@@ -16,12 +16,12 @@
...
@@ -16,12 +16,12 @@
<label class="text-sm text-gray-500 ml-2" for="check-boxall">Select All</label>
<label class="text-sm text-gray-500 ml-2" for="check-boxall">Select All</label>
</div>
</div>
</div>
</div>
</div> -->
<div
class=
"flex justify-end"
>
<div
class=
"flex justify-end"
>
<div
class=
"px-1"
>
<div
class=
"px-1"
>
<div
class=
"relative shadow-md"
>
<div
class=
"relative shadow-md"
>
<input
type=
"text"
id=
"hs-leading-icon"
name=
"hs-leading-icon"
<input
type=
"text"
class=
"ti-form-input ltr:pl-11 rtl:pr-11 focus:z-10 "
class=
"ti-form-input ltr:pl-11 rtl:pr-11 focus:z-10 "
placeholder=
"Search by No. or Name"
placeholder=
"Search by No. or Name"
[(
ngModel
)]="
search
"
(
ngModelChange
)="
searchChange
()"
>
[(
ngModel
)]="
search
"
(
ngModelChange
)="
searchChange
()"
>
<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"
>
<i
class=
"ri-search-line text-gray"
></i>
<i
class=
"ri-search-line text-gray"
></i>
...
@@ -39,96 +39,30 @@
...
@@ -39,96 +39,30 @@
</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=
"#department-register-modal-add
"
(
click
)="
currentModel=
'add'
;
selectBu1
()"
>
data-hs-overlay=
"#department-register-modal
"
(
click
)="
currentModel=
'add'
;
selectBu1
()"
>
<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-info h-45px m-0 shadow-md">
<i class="ri-printer-line"></i>
Print
</button>
</div> -->
<div
class=
"px-1"
>
<div
class=
"px-1"
>
<button
href=
"javascript:void(0);"
class=
"ti-btn ti-btn-soft-danger h-45px m-0 shadow-md"
<button
href=
"javascript:void(0);"
class=
"ti-btn ti-btn-soft-danger h-45px m-0 shadow-md"
(
click
)="
currentModel=
'deleteGroup'
;
selectBu1
()"
(
click
)="
currentModel=
'delete'
;
selectBu1
()"
data-hs-overlay=
"#department-register-alert-modal"
>
data-hs-overlay=
"#department-register-delete-alert-modal"
>
<i
class=
"ri-delete-bin-6-line"
></i>
<i
class=
"ri-delete-bin-6-line"
></i>
Delete
Delete
</button>
</button>
</div>
</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>
<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
]="
bu1
.
dataList
"
<table
class=
"ti-custom-table ti-custom-table-head ti-custom-table-hover table-bordered"
>
[
columns
]="
columns
"
[
modalName
]="'#
department-register-modal
'"
[
selectedItems
]="
selectedItems
"
<thead>
(
sendSelectData
)="
currentModel=
'edit'
;
selectBu1
($
event
)"
(
sendSelectedItems
)="
onSelectItemChange
($
event
)"
>
<tr>
</app-datagrid-syncfution>
<ng-container
*
ngFor=
"let item of ['','รหัสฝ่าย','รายละเอียดฝ่าย (ไทย)','รายละเอียดฝ่าย (อังกฤษ)','การจัดการ']; let f = first; let l = last"
>
<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=
"!f&&!l"
>
<i
class=
"ti ti-dots-vertical fs-l"
></i>
</div>
</th>
</ng-container>
</tr>
</thead>
<tbody
*
ngIf=
"bu1ListLoading"
>
<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=
"!bu1ListLoading&&!bu1ListFilter().length"
>
<tr>
<td
class=
"text-center"
colspan=
"100%"
>
ไม่พบข้อมูล
</td>
</tr>
</tbody>
<tbody
*
ngIf=
"!bu1ListLoading&&bu1ListFilter().length"
>
<tr
*
ngFor=
"let item of bu1ListFilter() | slice:((currentPage-1) * pageSize) : (((currentPage-1) * pageSize) + pageSize);let i = index"
>
<td
class=
"text-center"
>
<input
type=
"checkbox"
class=
"ti-form-checkbox cursor-pointer"
id=
"checkbox-{{item.data.bu1id}}"
[(
ngModel
)]="
item
.
check
"
(
ngModelChange
)="
dataListCheck
()"
>
</td>
<td
class=
"text-center"
>
{{item.data.bu1id}}
</td>
<td>
{{item.data.tdesc}}
</td>
<td>
{{item.data.edesc}}
</td>
<td
class=
"flex justify-center"
>
<i
class=
"ti ti-edit cursor-pointer i-gray fs-l px-1"
(
click
)="
currentModel=
'edit'
;
selectBu1
(
item
.
data
)"
data-hs-overlay=
"#department-register-modal-edit"
></i>
<!-- <i class="ti ti-trash cursor-pointer i-gray fs-l px-1"
(click)="currentModel='delete';selectBu1(item)"
data-hs-overlay="#department-register-delete-alert-modal"></i> -->
</td>
</tr>
</tbody>
</table>
</div>
<app-pagination
[
totalItems
]="
bu1ListFilter
().
length
"
[
pageSize
]="
pageSize
"
(
pageChange
)="
currentPage =
$event"
(
pageSizeChange
)="
pageSize =
$event;currentPage
=
1
"
></app-pagination>
</div>
</div>
<div
id=
"department-register-modal
-add
"
class=
"hs-overlay hidden ti-modal"
>
<div
id=
"department-register-modal"
class=
"hs-overlay hidden ti-modal"
>
<div
class=
"hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out h-[calc(100%-3.5rem)]"
>
<div
class=
"hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out h-[calc(100%-3.5rem)]"
>
<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"
>
...
@@ -137,7 +71,7 @@
...
@@ -137,7 +71,7 @@
</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"
data-hs-overlay=
"#department-register-modal
-add
"
>
data-hs-overlay=
"#department-register-modal"
>
<span
class=
"sr-only"
>
Close
</span>
<span
class=
"sr-only"
>
Close
</span>
<i
class=
"ti ti-circle-x fs-xxl"
></i>
<i
class=
"ti ti-circle-x fs-xxl"
></i>
</button>
</button>
...
@@ -174,28 +108,29 @@
...
@@ -174,28 +108,29 @@
<div
class=
"ti-modal-body padding-16px pt-0 overflow-y-0"
>
<div
class=
"ti-modal-body padding-16px pt-0 overflow-y-0"
>
<label
for=
"input-label"
class=
"ti-form-label mt-2rem"
>
ฝ่าย
<label
for=
"input-label"
class=
"ti-form-label mt-2rem"
>
ฝ่าย
<span
class=
"text-danger"
>
*
<span
class=
"text-danger"
>
*
<ng-container
*
ngIf=
"checkPrimary()"
>
<ng-container
*
ngIf=
"checkPrimary()
&¤tModel=='add'
"
>
ฝ่ายซ้ำ
ฝ่ายซ้ำ
</ng-container>
</ng-container>
</span>
</span>
</label>
</label>
<input
type=
"text"
id=
"input-label"
class=
"ti-form-input w-1/2"
[
class
.!
border-red
]="
checkPrimary
()"
<input
type=
"text"
id=
"input-label"
class=
"ti-form-input w-1/2"
[(
ngModel
)]="
bu1
.
bu1id
"
>
[
class
.!
border-red
]="
checkPrimary
()&&
currentModel=
='add'"
[(
ngModel
)]="
bu1
.
select
.
bu1id
"
[
readonly
]="
currentModel=
='edit'"
[
class
.!
bg-input-readonly
]="
currentModel=
='edit'"
>
<label
for=
"detail_th"
class=
"ti-form-label mt-2rem"
>
รายละเอียดฝ่าย (ไทย)
<span
<label
for=
"detail_th"
class=
"ti-form-label mt-2rem"
>
รายละเอียดฝ่าย (ไทย)
<span
class=
"text-danger"
>
*
</span></label>
class=
"text-danger"
>
*
</span></label>
<input
type=
"text"
id=
"detail_th"
class=
"ti-form-input h-16"
[(
ngModel
)]="
bu1
.
tdesc
"
>
<input
type=
"text"
id=
"detail_th"
class=
"ti-form-input h-16"
[(
ngModel
)]="
bu1
.
select
.
tdesc
"
>
<label
for=
"detail_eng"
class=
"ti-form-label mt-2rem"
>
รายละเอียดฝ่าย (อังกฤษ)
</label>
<label
for=
"detail_eng"
class=
"ti-form-label mt-2rem"
>
รายละเอียดฝ่าย (อังกฤษ)
</label>
<input
type=
"text"
id=
"detail_eng"
class=
"ti-form-input h-16"
[(
ngModel
)]="
bu1
.
edesc
"
>
<input
type=
"text"
id=
"detail_eng"
class=
"ti-form-input h-16"
[(
ngModel
)]="
bu1
.
select
.
edesc
"
>
<div
class=
"flex justify-end mt-2rem mb-1rem"
>
<div
class=
"flex justify-end mt-2rem mb-1rem"
>
<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=
"#department-register-modal
-add
"
>
data-hs-overlay=
"#department-register-modal"
>
ย้อนกลับ
ย้อนกลับ
</button>
</button>
<button
type=
"button"
class=
"ti-btn ti-btn-success"
<button
type=
"button"
class=
"ti-btn ti-btn-success"
data-hs-overlay=
"#department-register-alert-modal"
data-hs-overlay=
"#department-register-alert-modal"
[
class
.
ti-btn-disabled
]="!
bu1
.
bu1id
||!
bu1
.
tdesc
||
checkPrimary
(
)"
[
class
.
ti-btn-disabled
]="!
bu1
.
select
.
bu1id
||!
bu1
.
select
.
tdesc
||(
checkPrimary
()&&
currentModel=
='add'
)"
[
disabled
]="!
bu1
.
bu1id
||!
bu1
.
tdesc
||
checkPrimary
(
)"
>
[
disabled
]="!
bu1
.
select
.
bu1id
||!
bu1
.
select
.
tdesc
||(
checkPrimary
()&&
currentModel=
='add'
)"
>
บันทึกข้อมูล
บันทึกข้อมูล
</button>
</button>
</div>
</div>
...
@@ -204,74 +139,6 @@
...
@@ -204,74 +139,6 @@
</div>
</div>
</div>
</div>
<div
id=
"department-register-modal-edit"
class=
"hs-overlay hidden ti-modal"
>
<div
class=
"hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out h-[calc(100%-3.5rem)]"
>
<div
class=
"max-h-full overflow-hidden ti-modal-content"
>
<div
class=
"ti-modal-header"
>
<h3
class=
"text-xxl font-bold text-primary"
>
แก้ไขข้อมูลทะเบียนฝ่าย
</h3>
<div
class=
"flex justify-end"
>
<button
type=
"button"
class=
"hs-dropdown-toggle ti-modal-clode-btn text-danger"
data-hs-overlay=
"#department-register-modal-edit"
>
<span
class=
"sr-only"
>
Close
</span>
<i
class=
"ti ti-circle-x fs-xxl"
></i>
</button>
</div>
</div>
<div
class=
"w-full flex justify-end"
>
<div
class=
"absolute flex"
>
<div
class=
"px-1"
>
<button
type=
"button"
class=
"ti-btn ti-btn-soft-indigo h-45px m-0 shadow-md"
(
click
)="
bu1
.
tdesc=
''
;
bu1
.
edesc=
''
"
>
<svg
class=
"svg-indigo"
width=
"16"
height=
"16"
viewBox=
"0 0 64.00 64.00"
xmlns=
"http://www.w3.org/2000/svg"
fill=
"none"
stroke=
"#595BEA"
stroke-width=
"3.84"
transform=
"rotate(45)matrix(-1, 0, 0, 1, 0, 0)"
>
<g
id=
"SVGRepo_bgCarrier"
stroke-width=
"0"
></g>
<g
id=
"SVGRepo_tracerCarrier"
stroke-linecap=
"round"
stroke-linejoin=
"round"
></g>
<g
id=
"SVGRepo_iconCarrier"
>
<path
d=
"M15 49A24 24 0 0 1 32 8"
></path>
<path
d=
"M49 15a24 24 0 0 1-17 41"
></path>
<polyline
points=
"15.03 40 15.03 48.97 8 48.97"
></polyline>
<polyline
points=
"48.97 24 48.97 15.03 56 15.03"
></polyline>
</g>
</svg>
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 "
>
<label
for=
"input-label"
class=
"ti-form-label mt-2rem"
>
ฝ่าย
<span
class=
"text-danger"
>
*
</span></label>
<input
type=
"text"
id=
"input-label"
class=
"ti-form-input w-1/2 bg-input-readonly"
[(
ngModel
)]="
bu1
.
bu1id
"
readonly
>
<label
for=
"detail_th"
class=
"ti-form-label mt-2rem"
>
รายละเอียดฝ่าย (ไทย)
<span
class=
"text-danger"
>
*
</span></label>
<input
type=
"text"
id=
"detail_th"
class=
"ti-form-input h-16"
[(
ngModel
)]="
bu1
.
tdesc
"
>
<label
for=
"detail_eng"
class=
"ti-form-label mt-2rem"
>
รายละเอียดฝ่าย (อังกฤษ)
</label>
<input
type=
"text"
id=
"detail_eng"
class=
"ti-form-input h-16"
[(
ngModel
)]="
bu1
.
edesc
"
>
<div
class=
"flex justify-end mt-2rem mb-1rem"
>
<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=
"#department-register-modal-edit"
>
ย้อนกลับ
</button>
<button
type=
"button"
class=
"ti-btn ti-btn-success"
data-hs-overlay=
"#department-register-alert-modal"
[
class
.
ti-btn-disabled
]="!
bu1
.
bu1id
||!
bu1
.
tdesc
"
[
disabled
]="!
bu1
.
bu1id
||!
bu1
.
tdesc
"
>
บันทึกข้อมูล
</button>
</div>
</div>
</div>
</div>
</div>
<div
id=
"department-register-alert-modal"
class=
"hs-overlay hidden ti-modal"
>
<div
id=
"department-register-alert-modal"
class=
"hs-overlay hidden ti-modal"
>
<div
class=
"hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out h-[calc(100%-3.5rem)] flex items-center"
>
<div
class=
"hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out h-[calc(100%-3.5rem)] flex items-center"
>
...
@@ -281,22 +148,36 @@
...
@@ -281,22 +148,36 @@
แจ้งเตือน
แจ้งเตือน
</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
*
ngIf=
"currentModel=='add'||currentModel=='edit'"
type=
"button"
[
attr
.
data-hs-overlay
]="
currentModel=
='add'?'#department-register-modal-add':'#department-register-modal-edit'"
>
class=
"hs-dropdown-toggle ti-modal-clode-btn text-danger"
data-hs-overlay=
"#department-register-modal"
>
<span
class=
"sr-only"
>
Close
</span>
<i
class=
"ti ti-circle-x fs-xxl"
></i>
</button>
<button
*
ngIf=
"currentModel=='delete'"
type=
"button"
class=
"hs-dropdown-toggle ti-modal-clode-btn text-danger"
data-hs-overlay=
"#department-register-alert-modal"
>
<span
class=
"sr-only"
>
Close
</span>
<span
class=
"sr-only"
>
Close
</span>
<i
class=
"ti ti-circle-x fs-xxl"
></i>
<i
class=
"ti ti-circle-x fs-xxl"
></i>
</button>
</button>
</div>
</div>
</div>
</div>
<div
class=
"ti-modal-body "
>
<div
class=
"ti-modal-body "
>
<p
class=
"mt-1 text-gray-800 dark:text-white/70"
>
<p
*
ngIf=
"currentModel=='add'||currentModel=='edit'"
class=
"mt-1 text-gray-800 dark:text-white/70"
>
ยืนยันการบันทึกข้อมูลหรือไม่
ยืนยันการบันทึกข้อมูลหรือไม่
</p>
</p>
<p
*
ngIf=
"currentModel=='delete'"
class=
"mt-1 text-gray-800 dark:text-white/70"
>
<div
class=
"flex justify-end mt-2rem mb-1rem"
>
<ng-container
*
ngIf=
"selectedItems.count"
>
ยืนยันการลบข้อมูลหรือไม่
</ng-container>
<ng-container
*
ngIf=
"!selectedItems.count"
>
เลือกข้อมูลที่ต้องการลบ
</ng-container>
</p>
<div
*
ngIf=
"currentModel=='add'||currentModel=='edit'"
class=
"flex justify-end mt-2rem mb-1rem"
>
<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"
[
attr
.
data-hs-overlay
]="
currentModel=
='add'?'#department-register-modal-add':'#department-register-modal-edit
'"
>
data-hs-overlay=
"#department-register-modal
'"
>
ย้อนกลับ
ย้อนกลับ
</button>
</button>
<button
type=
"button"
class=
"ti-btn ti-btn-success"
(
click
)="
addBu1
()"
<button
type=
"button"
class=
"ti-btn ti-btn-success"
(
click
)="
addBu1
()"
...
@@ -304,44 +185,14 @@
...
@@ -304,44 +185,14 @@
บันทึกข้อมูล
บันทึกข้อมูล
</button>
</button>
</div>
</div>
</div>
<div
*
ngIf=
"currentModel=='delete'"
class=
"flex justify-end mt-2rem mb-1rem"
>
</div>
</div>
</div>
<div
id=
"department-register-delete-alert-modal"
class=
"hs-overlay hidden ti-modal"
>
<div
class=
"hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out h-[calc(100%-3.5rem)] flex items-center"
>
<div
class=
"max-h-full overflow-hidden ti-modal-content w-full"
>
<div
class=
"ti-modal-header"
>
<h3
class=
"text-xxl font-bold text-primary"
>
แจ้งเตือน
</h3>
<div
class=
"flex justify-end"
>
<button
type=
"button"
class=
"hs-dropdown-toggle ti-modal-clode-btn text-danger"
data-hs-overlay=
"#department-register-delete-alert-modal"
>
<span
class=
"sr-only"
>
Close
</span>
<i
class=
"ti ti-circle-x fs-xxl"
></i>
</button>
</div>
</div>
<div
class=
"ti-modal-body "
>
<p
class=
"mt-1 text-gray-800 dark:text-white/70"
>
<ng-container
*
ngIf=
"numDataListChecked"
>
ยืนยันการลบข้อมูลหรือไม่
</ng-container>
<ng-container
*
ngIf=
"!numDataListChecked"
>
เลือกข้อมูลที่ต้องการลบ
</ng-container>
</p>
<div
class=
"flex justify-end mt-2rem mb-1rem"
>
<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=
"#department-register-
delete-
alert-modal"
>
data-hs-overlay=
"#department-register-alert-modal"
>
ย้อนกลับ
ย้อนกลับ
</button>
</button>
<button
type=
"button"
class=
"ti-btn ti-btn-danger"
(
click
)="
deleteBu1
()"
<button
type=
"button"
class=
"ti-btn ti-btn-danger"
(
click
)="
deleteBu1
()"
data-hs-overlay=
"#department-register-
delete-alert-modal"
*
ngIf=
"numDataListChecked
"
>
data-hs-overlay=
"#department-register-
alert-modal"
*
ngIf=
"selectedItems.count
"
>
ลบข้อมูล
ลบข้อมูล
</button>
</button>
</div>
</div>
...
...
src/app/components/company-components/company-registration/branch-business-unit/department-register/department-register.component.ts
View file @
4f17325d
import
{
ChangeDetectorRef
,
Component
,
EventEmitter
,
Input
,
OnInit
,
}
from
'@angular/core'
;
import
{
ChangeDetectorRef
,
Component
,
EventEmitter
,
Input
,
OnInit
,
}
from
'@angular/core'
;
import
{
ColumnModel
}
from
'@syncfusion/ej2-grids'
;
import
{
ar
}
from
'date-fns/locale'
;
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
{
Bu1Service
}
from
'src/app/shared/services/bu1.service'
;
import
{
Bu1Service
}
from
'src/app/shared/services/bu1.service'
;
...
@@ -13,19 +15,34 @@ export class DepartmentRegisterComponent implements OnInit {
...
@@ -13,19 +15,34 @@ export class DepartmentRegisterComponent implements OnInit {
currentPage
=
1
currentPage
=
1
pageSize
=
10
pageSize
=
10
page
=
Array
.
from
({
length
:
1
},
(
_
,
i
)
=>
i
+
1
);
page
=
Array
.
from
({
length
:
1
},
(
_
,
i
)
=>
i
+
1
);
bu1List
:
{
check
:
boolean
,
data
:
Bu1Model
}[]
=
[]
bu1ListLoading
=
false
bu1
:
Bu1Model
=
new
MyBu1Model
()
search
=
""
search
=
""
selectedFile
:
File
|
null
=
null
;
selectedFile
:
File
|
null
=
null
;
selectedFileName
:
string
=
'กรุณาเลือกไฟล์'
;
selectedFileName
:
string
=
'กรุณาเลือกไฟล์'
;
selectedItems
:
{
key
:
string
,
count
:
number
,
data
:
Map
<
string
,
boolean
>
}
=
{
key
:
''
,
count
:
0
,
data
:
new
Map
<
string
,
boolean
>
()
};
currentModel
:
'add'
|
'edit'
|
'delete'
=
"add"
bu1
:
{
loading
:
boolean
,
select
:
Bu1Model
,
dataList
:
Bu1Model
[]
}
=
{
loading
:
false
,
select
:
new
MyBu1Model
(),
dataList
:
[]
}
columns
:
ColumnModel
[]
=
[{
"field"
:
"bu1id"
,
"headerText"
:
"รหัสกลุ่มการอนุมัติ"
,
isPrimaryKey
:
true
,
},
{
"field"
:
"tdesc"
,
"headerText"
:
"รายละเอียดฝ่าย(ไทย)"
},
{
"field"
:
"edesc"
,
"headerText"
:
"รายละเอียดฝ่าย(อังกฤษ)"
}]
searchSettings
=
{
fields
:
[
'bu1id'
,
'tdesc'
,
'edesc'
],
operator
:
'contains'
,
ignoreCase
:
true
,
// customMatchCase: (cellValue: string, searchValue: string) => {
// return cellValue.toString().toLowerCase() === '00';
// }
currentModel
:
'add'
|
'edit'
|
'delete'
|
'deleteGroup'
=
"add"
};
numDataListChecked
=
0
isDataListChecked
=
false
isDataListCheckedAll
=
false
constructor
(
private
bu1Service
:
Bu1Service
,
constructor
(
private
bu1Service
:
Bu1Service
,
private
toastr
:
ToastrService
,
private
toastr
:
ToastrService
,
private
cdr
:
ChangeDetectorRef
,
private
cdr
:
ChangeDetectorRef
,
...
@@ -46,7 +63,7 @@ export class DepartmentRegisterComponent implements OnInit {
...
@@ -46,7 +63,7 @@ export class DepartmentRegisterComponent implements OnInit {
}
}
const
formData
=
new
FormData
();
const
formData
=
new
FormData
();
formData
.
append
(
'file'
,
this
.
selectedFile
);
formData
.
append
(
'file'
,
this
.
selectedFile
);
this
.
bu1
ListL
oading
=
true
this
.
bu1
.
l
oading
=
true
this
.
fileService
.
uploadExcel
(
formData
,
'mbu1'
).
subscribe
({
this
.
fileService
.
uploadExcel
(
formData
,
'mbu1'
).
subscribe
({
next
:
response
=>
{
next
:
response
=>
{
if
(
response
.
success
)
{
if
(
response
.
success
)
{
...
@@ -54,11 +71,11 @@ export class DepartmentRegisterComponent implements OnInit {
...
@@ -54,11 +71,11 @@ export class DepartmentRegisterComponent implements OnInit {
this
.
getBu1List
()
this
.
getBu1List
()
}
else
{
}
else
{
this
.
showAlert
(
response
.
message
,
'error'
)
this
.
showAlert
(
response
.
message
,
'error'
)
this
.
bu1
ListL
oading
=
false
this
.
bu1
.
l
oading
=
false
}
}
},
error
:
error
=>
{
},
error
:
error
=>
{
this
.
showAlert
(
error
.
message
,
'error'
)
this
.
showAlert
(
error
.
message
,
'error'
)
this
.
bu1
ListL
oading
=
false
this
.
bu1
.
l
oading
=
false
}
}
})
})
}
}
...
@@ -84,36 +101,37 @@ export class DepartmentRegisterComponent implements OnInit {
...
@@ -84,36 +101,37 @@ export class DepartmentRegisterComponent implements OnInit {
getBu1List
()
{
getBu1List
()
{
this
.
bu1
ListL
oading
=
true
this
.
bu1
.
l
oading
=
true
this
.
bu1Service
.
getList
().
subscribe
({
this
.
bu1Service
.
getList
().
subscribe
({
next
:
response
=>
{
next
:
response
=>
{
this
.
bu1List
=
response
.
map
(
x
=>
({
check
:
false
,
data
:
new
MyBu1Model
(
x
)
}))
this
.
bu1
.
dataList
=
response
.
map
(
x
=>
{
this
.
isDataListCheckedAll
=
false
this
.
selectedItems
.
data
.
set
(
x
.
bu1id
,
false
)
this
.
dataListCheckAll
()
return
new
MyBu1Model
(
x
)
this
.
bu1ListLoading
=
false
})
this
.
selectedItems
.
key
=
'bu1id'
console
.
log
(
" 🐒 this.selectedItems:"
,
this
.
selectedItems
)
this
.
bu1
.
loading
=
false
this
.
searchChange
()
this
.
searchChange
()
this
.
cdr
.
detectChanges
()
this
.
cdr
.
detectChanges
()
},
error
:
error
=>
{
},
error
:
error
=>
{
this
.
bu1
ListL
oading
=
false
this
.
bu1
.
l
oading
=
false
this
.
cdr
.
detectChanges
()
this
.
cdr
.
detectChanges
()
}
}
})
})
}
}
searchChange
()
{
searchChange
()
{
this
.
currentPage
=
1
this
.
currentPage
=
1
this
.
page
=
Array
.
from
({
length
:
Math
.
ceil
(
this
.
bu1ListFilter
().
length
/
10
)
},
(
_
,
i
)
=>
i
+
1
);
this
.
page
=
Array
.
from
({
length
:
Math
.
ceil
(
this
.
bu1ListFilter
().
length
/
10
)
},
(
_
,
i
)
=>
i
+
1
)
this
.
dataListCheck
()
}
}
bu1ListFilter
()
{
bu1ListFilter
()
{
return
this
.
bu1List
.
filter
(
x
=>
{
return
this
.
bu1
.
dataList
.
filter
(
x
=>
{
const
data
=
x
.
data
return
x
.
bu1id
.
toLowerCase
().
includes
(
this
.
search
.
toLowerCase
())
||
return
data
.
bu1id
.
toLowerCase
().
includes
(
this
.
search
.
toLowerCase
())
||
x
.
tdesc
.
toLowerCase
().
includes
(
this
.
search
.
toLowerCase
())
||
data
.
tdesc
.
toLowerCase
().
includes
(
this
.
search
.
toLowerCase
())
||
x
.
edesc
.
toLowerCase
().
includes
(
this
.
search
.
toLowerCase
())
data
.
edesc
.
toLowerCase
().
includes
(
this
.
search
.
toLowerCase
())
})
})
}
}
selectBu1
(
bu1
?:
Bu1Model
)
{
selectBu1
(
bu1
?:
Bu1Model
)
{
this
.
bu1
=
new
MyBu1Model
(
bu1
)
this
.
bu1
.
select
=
new
MyBu1Model
(
bu1
)
}
}
showAlert
(
text
:
string
,
type
:
'success'
|
'error'
)
{
showAlert
(
text
:
string
,
type
:
'success'
|
'error'
)
{
...
@@ -123,55 +141,53 @@ export class DepartmentRegisterComponent implements OnInit {
...
@@ -123,55 +141,53 @@ export class DepartmentRegisterComponent implements OnInit {
})
})
}
}
addBu1
()
{
addBu1
()
{
this
.
bu1
ListL
oading
=
true
this
.
bu1
.
l
oading
=
true
this
.
bu1Service
.
post
(
this
.
bu1
).
subscribe
({
this
.
bu1Service
.
post
(
this
.
bu1
.
select
).
subscribe
({
next
:
response
=>
{
next
:
response
=>
{
if
(
response
.
success
)
{
if
(
response
.
success
)
{
this
.
showAlert
(
response
.
message
,
'success'
)
this
.
showAlert
(
response
.
message
,
'success'
)
this
.
getBu1List
()
this
.
getBu1List
()
}
else
{
}
else
{
this
.
showAlert
(
response
.
message
,
'error'
)
this
.
showAlert
(
response
.
message
,
'error'
)
this
.
bu1
ListL
oading
=
false
this
.
bu1
.
l
oading
=
false
}
}
},
error
:
error
=>
{
},
error
:
error
=>
{
this
.
showAlert
(
error
.
message
,
'error'
)
this
.
showAlert
(
error
.
message
,
'error'
)
this
.
bu1
ListL
oading
=
false
this
.
bu1
.
l
oading
=
false
}
}
})
})
}
}
deleteBu1
()
{
deleteBu1
()
{
this
.
bu1ListLoading
=
true
this
.
bu1
.
loading
=
true
const
body
=
this
.
bu1List
.
filter
(
x
=>
x
.
check
).
map
(
x
=>
new
MyBu1Model
(
x
.
data
))
const
body
=
this
.
bu1
.
dataList
.
filter
(
x
=>
{
this
.
bu1Service
.
delete
(
body
).
subscribe
({
if
(
Array
.
from
(
this
.
selectedItems
.
data
.
keys
()).
find
((
y
:
any
)
=>
y
==
x
.
bu1id
)
&&
Array
.
from
(
this
.
selectedItems
.
data
.
values
()).
find
((
y
:
any
)
=>
y
))
{
next
:
response
=>
{
return
true
if
(
response
.
success
)
{
}
this
.
showAlert
(
response
.
message
,
'success'
)
return
false
this
.
getBu1List
()
}
}
else
{
).
map
(
x
=>
new
MyBu1Model
(
x
))
this
.
showAlert
(
response
.
message
,
'error'
)
console
.
log
(
" 🐒 body:"
,
body
)
this
.
bu1ListLoading
=
false
// this.bu1Service.delete(body).subscribe({
}
// next: response => {
},
error
:
error
=>
{
// if (response.success) {
this
.
showAlert
(
error
.
message
,
'error'
)
// this.showAlert(response.message, 'success')
this
.
bu1ListLoading
=
false
// this.getBu1List()
}
// } else {
})
// this.showAlert(response.message, 'error')
}
// this.bu1.loading = false
dataListCheckAll
()
{
// }
const
selectAll
=
this
.
isDataListCheckedAll
;
// }, error: error => {
this
.
bu1ListFilter
().
forEach
(
x
=>
x
.
check
=
selectAll
);
// this.showAlert(error.message, 'error')
this
.
dataListCheck
();
// this.bu1.loading = false
}
// }
// })
dataListCheck
()
{
const
dataCheck
=
this
.
bu1ListFilter
();
this
.
isDataListCheckedAll
=
dataCheck
.
length
?
dataCheck
.
every
(
x
=>
x
.
check
)
:
false
;
this
.
numDataListChecked
=
this
.
bu1List
.
filter
(
x
=>
x
.
check
).
length
this
.
isDataListChecked
=
Boolean
(
this
.
numDataListChecked
)
}
}
checkPrimary
()
{
checkPrimary
()
{
return
this
.
bu1
List
.
find
(
x
=>
x
.
data
.
bu1id
==
this
.
bu1
.
bu1id
)
return
this
.
bu1
.
dataList
.
find
(
x
=>
x
.
bu1id
==
this
.
bu1
.
select
.
bu1id
)
}
}
onSelectItemChange
(
arg
:
any
)
{
this
.
selectedItems
=
arg
}
}
}
\ No newline at end of file
src/app/components/datagrid-syncfution/datagrid-syncfution.component.html
View file @
4f17325d
<ejs-grid
#
grid
id=
'Grid'
[
dataSource
]="
dataSource
"
[
allowFiltering
]="
allowFiltering
"
[
filterSettings
]="
filterSettings
"
<ejs-grid
#
grid
id=
'Grid'
[
dataSource
]="
dataSource
"
[
allowFiltering
]="
allowFiltering
"
[
filterSettings
]="
filterSettings
"
[
groupSettings
]="
groupSettings
"
[
toolbar
]='
toolbarOptions
'
[
editSettings
]="
editSettings
"
[
searchSettings
]="
searchSettings
"
[
groupSettings
]="
groupSettings
"
[
toolbar
]='
toolbarOptions
'
(
actionBegin
)="
onActionBegin
($
event
)"
(
actionComplete
)="
onActionComplete
($
event
)"
[
editSettings
]="
editSettings
"
showColumnMenu=
'true'
allowPaging=
'true'
allowGrouping=
'true'
allowSorting=
'true'
(
rowSelected
)="
onRowSelectedCheckbox
($
event
.
data
)"
(
rowDeselected
)="
onRowDeselectedCheckbox
($
event
.
data
)"
showColumnMenu=
'true'
allowFiltering=
'true'
[
allowPdfExport
]='
true
'
(
toolbarClick
)='
toolbarClick
($
event
)'
showColumnMenu=
'true'
allowPaging=
'true'
allowGrouping=
'true'
allowSorting=
'true'
showColumnMenu=
'true'
[
allowExcelExport
]='
true
'
[
selectionSettings
]="
selectionOptions
"
(
detailDataBound
)='
detailDataBound
($
event
)'
allowFiltering=
'true'
[
allowPdfExport
]='
true
'
(
toolbarClick
)='
toolbarClick
($
event
)'
[
allowExcelExport
]='
true
'
width=
"auto"
allowReordering=
'true'
[
loadingIndicator
]='
loadingIndicator
'
[
query
]="
query
"
rowHeight=
'60'
[
selectionSettings
]="
selectionOptions
"
(
detailDataBound
)='
detailDataBound
($
event
)'
width=
"auto"
allowReordering=
'true'
allowEditing=
'false'
[
pageSettings
]='
initialPage
'
[
allowMultiSorting
]='
true
'
>
[
loadingIndicator
]='
loadingIndicator
'
[
query
]="
query
"
rowHeight=
'60'
allowEditing=
'false'
[
pageSettings
]='
initialPage
'
[
allowMultiSorting
]='
true
'
>
<e-columns>
<e-columns>
<e-column
type=
'checkbox'
width=
'50'
*
ngIf=
"checkBoxSetting"
></e-column>
<!-- <e-column type='checkbox' width='50' *ngIf="checkBoxSetting"></e-column> -->
<e-column
[
textAlign
]="'
center
'"
*
ngIf=
"checkBoxSetting"
[
allowEditing
]="
false
"
>
<ng-template
#
headerTemplate
let-data
>
<input
type=
"checkbox"
[
id
]="'
checkbox-all
'"
class=
"ti-form-checkbox cursor-pointer"
[
checked
]="
selectedItemsAll
"
(
click
)="
toggleSelectionAll
()"
>
<label
[
for
]="'
checkbox-all
'"
class=
"text-sm text-gray-500 mx-2"
>
{{selectedItems.count}} Selected
</label>
</ng-template>
<ng-template
#
template
let-data
>
<input
type=
"checkbox"
class=
"ti-form-checkbox cursor-pointer"
[
checked
]="
selectedItems
.
data
.
get
(
data
[
selectedItems
.
key
])
||
false
"
(
click
)="
toggleSelection
(
data
[
selectedItems
.
key
],
!
selectedItems
.
data
.
get
(
data
[
selectedItems
.
key
]))"
>
</ng-template>
</e-column>
<e-column
*
ngFor=
"let col of columns"
[
field
]="
col
.
field
"
[
headerText
]="
col
.
headerText
"
[
width
]="
col
.
width
"
<e-column
*
ngFor=
"let col of columns"
[
field
]="
col
.
field
"
[
headerText
]="
col
.
headerText
"
[
width
]="
col
.
width
"
[
format
]="
col
.
format
"
[
textAlign
]="'
center
'"
[
isPrimaryKey
]="
col
.
isPrimaryKey
"
[
editType
]="
col
.
editType
"
[
format
]="
col
.
format
"
[
textAlign
]="'
center
'"
[
isPrimaryKey
]="
col
.
isPrimaryKey
"
[
editType
]="
col
.
editType
"
[
validationRules
]="
col
.
validationRules
"
[
allowEditing
]="'
true
'"
[
allowSorting
]="'
true
'"
[
allowFiltering
]="
true
"
[
validationRules
]="
col
.
validationRules
"
[
allowEditing
]="'
true
'"
[
allowSorting
]="'
true
'"
[
allowFiltering
]="
true
"
...
@@ -24,10 +35,8 @@
...
@@ -24,10 +35,8 @@
</ng-template>
</ng-template>
<ng-template
#
template
let-data
>
<ng-template
#
template
let-data
>
<i
class=
"ti ti-eye cursor-pointer i-gray fs-l px-1"
(
click
)="
onNextPage
(
data
)"
*
ngIf=
"canChild"
></i>
<i
class=
"ti ti-eye cursor-pointer i-gray fs-l px-1"
(
click
)="
onNextPage
(
data
)"
*
ngIf=
"canChild"
></i>
<i
class=
"ti ti-edit cursor-pointer i-gray fs-l px-1"
data-hs-overlay=
"#modal-detail"
*
ngIf=
"canEdit"
<i
class=
"ti ti-edit cursor-pointer i-gray fs-l px-1"
[
attr
.
data-hs-overlay
]="
modalName
"
*
ngIf=
"canEdit"
(
click
)="
onViewSelected
(
data
)"
></i>
(
click
)="
onSelectData
(
data
)"
></i>
<i
class=
"ti ti-trash cursor-pointer i-gray fs-l px-1"
data-hs-overlay=
"#modal-delete"
*
ngIf=
"canDelete"
(
click
)="
onRemoveSelected
(
data
)"
></i>
</ng-template>
</ng-template>
</e-column>
</e-column>
</e-columns>
</e-columns>
...
...
src/app/components/datagrid-syncfution/datagrid-syncfution.component.ts
View file @
4f17325d
...
@@ -10,8 +10,9 @@ import {
...
@@ -10,8 +10,9 @@ import {
}
from
'@angular/core'
;
}
from
'@angular/core'
;
import
{
EditService
,
ReorderService
,
SortService
,
GroupService
,
ColumnMenuService
,
PageService
,
FilterService
,
SelectionSettingsModel
,
ToolbarItems
,
ToolbarService
,
GridComponent
,
PdfExportService
,
ExcelExportService
,
DetailRowService
,
DetailDataBoundEventArgs
,
Grid
,
AggregateService
,
PdfExportProperties
,
LoadingIndicatorModel
}
from
'@syncfusion/ej2-angular-grids'
;
import
{
EditService
,
ReorderService
,
SortService
,
GroupService
,
ColumnMenuService
,
PageService
,
FilterService
,
SelectionSettingsModel
,
ToolbarItems
,
ToolbarService
,
GridComponent
,
PdfExportService
,
ExcelExportService
,
DetailRowService
,
DetailDataBoundEventArgs
,
Grid
,
AggregateService
,
PdfExportProperties
,
LoadingIndicatorModel
}
from
'@syncfusion/ej2-angular-grids'
;
import
{
GroupSettingsModel
,
FilterSettingsModel
,
ColumnModel
}
from
'@syncfusion/ej2-angular-grids'
;
import
{
GroupSettingsModel
,
FilterSettingsModel
,
ColumnModel
}
from
'@syncfusion/ej2-angular-grids'
;
import
{
Query
}
from
'@syncfusion/ej2-data'
;
import
{
DataManager
,
Query
}
from
'@syncfusion/ej2-data'
;
import
{
L10n
,
setCulture
}
from
'@syncfusion/ej2-base'
;
import
{
L10n
,
setCulture
}
from
'@syncfusion/ej2-base'
;
setCulture
(
'th-TH'
);
setCulture
(
'th-TH'
);
L10n
.
load
({
L10n
.
load
({
...
@@ -51,28 +52,31 @@ L10n.load({
...
@@ -51,28 +52,31 @@ L10n.load({
encapsulation
:
ViewEncapsulation
.
None
encapsulation
:
ViewEncapsulation
.
None
})
})
export
class
DatagridSyncfutionComponent
implements
OnInit
{
export
class
DatagridSyncfutionComponent
implements
OnInit
{
/**
* ======================
* @Input() ส่วนรับค่า
* ======================
*/
@
ViewChild
(
'grid'
)
public
grid
?:
GridComponent
;
@
ViewChild
(
'grid'
)
public
grid
?:
GridComponent
;
@
Input
()
dataSource
:
any
[]
=
[];
@
Output
()
sendSelectData
=
new
EventEmitter
<
any
>
();
@
Input
()
columns
:
ColumnModel
[]
=
[];
// @Input() toolbarOptions?: ToolbarItems[]
@
Input
()
toolbarOptions
?:
ToolbarItems
[]
=
[
'Print'
,
'ExcelExport'
,
'CsvExport'
];
@
Input
()
searchSettings
=
{}
@
Input
()
selectedItems
:
{
key
:
string
,
count
:
number
,
data
:
Map
<
string
,
boolean
>
}
=
{
key
:
''
,
count
:
0
,
data
:
new
Map
<
string
,
boolean
>
()
};
selectedItemsAll
=
false
@
Output
()
sendSelectedItems
=
new
EventEmitter
<
any
>
();
@
Input
()
modalName
=
''
@
Input
()
checkBoxSetting
=
true
@
Input
()
checkBoxSetting
=
true
@
Input
()
actionSetting
=
true
@
Input
()
actionSetting
=
true
@
Input
()
detailSetting
=
false
@
Input
()
detailSetting
=
false
@
Input
()
childList
=
''
@
Input
()
childList
=
''
@
Input
()
searchText
=
''
@
Input
()
searchText
=
''
@
Input
()
dataSource
:
any
[]
=
[];
// ข้อมูลที่จะแสดงในตาราง
@
Input
()
columns
:
ColumnModel
[]
=
[];
// กำหนดโครงสร้างของคอลัมน์
@
Input
()
childColumns
:
ColumnModel
[]
=
[];
@
Input
()
childColumns
:
ColumnModel
[]
=
[];
@
Input
()
allowSorting
=
true
;
@
Input
()
allowSorting
=
true
;
@
Input
()
allowFiltering
=
true
;
@
Input
()
allowFiltering
=
true
;
@
Input
()
filterSettings
?:
FilterSettingsModel
=
{
type
:
'Excel'
};;
@
Input
()
filterSettings
?:
FilterSettingsModel
=
{
type
:
'Excel'
};;
@
Input
()
groupSettings
?:
GroupSettingsModel
=
{
allowReordering
:
true
,
showGroupedColumn
:
true
,
showDropArea
:
false
};
@
Input
()
groupSettings
?:
GroupSettingsModel
=
{
allowReordering
:
true
,
showGroupedColumn
:
true
,
showDropArea
:
false
};
public
selectionOptions
?:
SelectionSettingsModel
=
{
checkboxOnly
:
true
};
public
selectionOptions
?:
SelectionSettingsModel
=
{
checkboxOnly
:
true
};
// ตัวอย่างการตั้งค่าอื่น ๆ ตามต้องการ
@
Input
()
toolbarOptions
?:
ToolbarItems
[]
=
[
'Print'
,
'ExcelExport'
,
'CsvExport'
];
@
Input
()
editSettings
?
=
{
allowEditing
:
true
,
mode
:
'Batch'
};
@
Input
()
editSettings
?
=
{
allowEditing
:
true
,
mode
:
'Batch'
};
@
Input
()
initialPage
?
=
{
pageSizes
:
true
,
pageSize
:
10
};
@
Input
()
initialPage
?
=
{
pageSizes
:
true
,
pageSize
:
10
};
@
Input
()
canDelete
=
true
@
Input
()
canDelete
=
true
...
@@ -80,23 +84,13 @@ export class DatagridSyncfutionComponent implements OnInit {
...
@@ -80,23 +84,13 @@ export class DatagridSyncfutionComponent implements OnInit {
@
Input
()
canEdit
=
true
@
Input
()
canEdit
=
true
// ... เป็นต้น
// ... เป็นต้น
public
query
:
Query
=
new
Query
().
addParams
(
'dataCount'
,
'1000'
);
public
query
:
Query
=
new
Query
().
addParams
(
'dataCount'
,
'1000'
);
loadingIndicator
:
LoadingIndicatorModel
=
{
indicatorType
:
'Shimmer'
};
loadingIndicator
:
LoadingIndicatorModel
=
{
indicatorType
:
'Shimmer'
};
/**
* ======================
* @Output() ส่วนส่ง Event
* ======================
*/
// ตัวอย่าง event เมื่อเลือกแถว
@
Output
()
rowSelected
=
new
EventEmitter
<
any
>
();
@
Output
()
childSelected
=
new
EventEmitter
<
any
>
();
@
Output
()
rowRemoveSelected
=
new
EventEmitter
<
any
>
();
@
Output
()
rowSelectedCheckbox
=
new
EventEmitter
<
any
>
();
@
Output
()
rowDeselectedCheckbox
=
new
EventEmitter
<
any
>
();
// ตัวอย่าง event เมื่อมีการลบ / แก้ไข
// ตัวอย่าง event เมื่อมีการลบ / แก้ไข
@
Output
()
actionBegin
=
new
EventEmitter
<
any
>
();
@
Output
()
actionBegin
=
new
EventEmitter
<
any
>
();
@
Output
()
actionComplete
=
new
EventEmitter
<
any
>
();
@
Output
()
actionComplete
=
new
EventEmitter
<
any
>
();
public
selectedRecord
?:
any
;
// อาจมี event อื่น ๆ เช่น pageChange, filterChange, ฯลฯ
// อาจมี event อื่น ๆ เช่น pageChange, filterChange, ฯลฯ
// แล้วแต่ logic ที่ต้องการให้ parent รู้
// แล้วแต่ logic ที่ต้องการให้ parent รู้
// @Output() pageChanged = new EventEmitter<number>();
// @Output() pageChanged = new EventEmitter<number>();
...
@@ -111,93 +105,45 @@ export class DatagridSyncfutionComponent implements OnInit {
...
@@ -111,93 +105,45 @@ export class DatagridSyncfutionComponent implements OnInit {
}
}
ngOnChanges
(
changes
:
SimpleChanges
):
void
{
ngOnChanges
(
changes
:
SimpleChanges
):
void
{
console
.
log
(
changes
)
this
.
query
=
new
Query
().
addParams
(
'dataCount'
,
'1000'
);
this
.
query
=
new
Query
().
addParams
(
'dataCount'
,
'1000'
);
this
.
loadingIndicator
=
{
indicatorType
:
'Shimmer'
};
this
.
loadingIndicator
=
{
indicatorType
:
'Shimmer'
};
if
(
changes
)
{
if
(
changes
)
{
console
.
log
(
'this.dataSource'
,
this
.
dataSource
)
if
(
changes
[
'searchText'
])
{
if
(
changes
[
'searchText'
])
{
this
.
search
(
changes
[
'searchText'
].
currentValue
)
this
.
search
(
changes
[
'searchText'
].
currentValue
)
}
}
}
//Called before any other lifecycle hook. Use it to inject dependencies, but avoid any serious work here.
//Add '${implements OnChanges}' to the class.
}
/**
* =============================
* ฟังก์ชันที่ผูกกับ Event ของ <ejs-grid>
* =============================
*/
public
onViewSelected
(
args
:
any
)
{
// เมื่อมีการ select row
this
.
rowSelected
.
emit
(
args
);
}
public
onNextPage
(
args
:
any
)
{
// เมื่อมีการ select row
this
.
childSelected
.
emit
(
args
);
}
public
onRemoveSelected
(
args
:
any
)
{
// เมื่อมีการ select row
this
.
rowRemoveSelected
.
emit
(
args
);
}
public
onRowSelectedCheckbox
(
args
:
any
)
{
// เมื่อมีการ select row
this
.
rowSelectedCheckbox
.
emit
(
args
);
}
}
public
onRowDeselectedCheckbox
(
args
:
any
)
{
// เมื่อมีการ select row
this
.
rowDeselectedCheckbox
.
emit
(
args
);
}
}
onSelectData
(
args
:
any
)
{
public
onActionBegin
(
args
:
any
)
{
this
.
sendSelectData
.
emit
(
args
);
this
.
actionBegin
.
emit
(
args
);
}
}
public
onActionComplet
e
(
args
:
any
)
{
onNextPag
e
(
args
:
any
)
{
this
.
actionComplete
.
emit
(
args
);
console
.
log
(
args
)
}
}
toolbarClick
(
args
:
any
):
void
{
toolbarClick
(
args
:
any
):
void
{
// if (args.item.id === 'Grid_pdfexport') { // 'Grid_pdfexport' -> Grid component id + _ + toolbar item name
// const pdfExportProperties: PdfExportProperties = {
// exportType: 'CurrentPage'
// };
// this.grid/pdfExport(pdfExportProperties);
// }
if
(
args
.
item
.
id
===
'Grid_excelexport'
)
{
if
(
args
.
item
.
id
===
'Grid_excelexport'
)
{
// 'Grid_excelexport' -> Grid component id + _ + toolbar item name
this
.
grid
?.
excelExport
();
this
.
grid
?.
excelExport
();
}
}
else
if
(
args
.
item
.
id
===
'Grid_csvexport'
)
{
else
if
(
args
.
item
.
id
===
'Grid_csvexport'
)
{
// 'Grid_csvexport' -> Grid component id + _ + toolbar item name
this
.
grid
?.
csvExport
();
this
.
grid
?.
csvExport
();
}
}
// (this.grid as GridComponent).excelExport();
}
}
showDetails
(
data
:
any
)
{
console
.
log
(
data
)
this
.
selectedRecord
=
data
;
this
.
rowSelected
.
emit
(
this
.
selectedRecord
);
}
search
(
text
?:
string
)
{
search
(
text
:
string
)
{
if
(
text
){
if
(
this
.
grid
)
{
(
this
.
grid
as
GridComponent
).
search
(
text
);
(
this
.
grid
as
GridComponent
).
search
(
this
.
searchText
);
// let filteredData = (this.grid as GridComponent).getCurrentViewRecords();
// console.log(filteredData);
// const clonedData = JSON.parse(JSON.stringify(this.dataSource));
// new DataManager(clonedData).executeQuery(new Query().search(this.searchText, [], undefined, true)).then((e: any) => {
// console.log('Searched Records:', e.result)
// });
}
}
}
}
detailDataBound
(
e
:
DetailDataBoundEventArgs
)
{
detailDataBound
(
e
:
DetailDataBoundEventArgs
)
{
console
.
log
(
e
)
let
detail
=
new
Grid
({
let
detail
=
new
Grid
({
// ─────────────────────────────────────────────────────────────
// ─────────────────────────────────────────────────────────────
// เดิมเป็น data.filter(...) เทียบ EmployeeID
// เดิมเป็น data.filter(...) เทียบ EmployeeID
...
@@ -219,5 +165,18 @@ export class DatagridSyncfutionComponent implements OnInit {
...
@@ -219,5 +165,18 @@ export class DatagridSyncfutionComponent implements OnInit {
// detail.appendTo((e.detailElement as HTMLElement).querySelector('.custom-grid') as HTMLElement);
// detail.appendTo((e.detailElement as HTMLElement).querySelector('.custom-grid') as HTMLElement);
}
}
toggleSelection
(
key
:
string
,
value
:
boolean
)
{
this
.
selectedItems
.
data
.
set
(
key
,
value
);
this
.
selectedItems
.
count
=
Array
.
from
(
this
.
selectedItems
.
data
.
values
()).
filter
(
v
=>
v
).
length
;
this
.
sendSelectedItems
.
emit
(
this
.
selectedItems
);
}
toggleSelectionAll
()
{
this
.
selectedItemsAll
=
!
this
.
selectedItemsAll
;
this
.
selectedItems
.
data
.
forEach
((
_
,
key
)
=>
{
this
.
selectedItems
.
data
.
set
(
key
,
this
.
selectedItemsAll
);
});
this
.
selectedItems
.
count
=
this
.
selectedItemsAll
?
this
.
selectedItems
.
data
.
size
:
0
;
this
.
sendSelectedItems
.
emit
(
this
.
selectedItems
);
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment