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
9b7d69c1
Commit
9b7d69c1
authored
Apr 16, 2025
by
Nakarin Luankla
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
แก้ model bu1-4
parent
b4ff8dbf
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
290 additions
and
577 deletions
+290
-577
department-list.component.html
...iness-unit/department-list/department-list.component.html
+31
-225
department-list.component.ts
...usiness-unit/department-list/department-list.component.ts
+79
-22
section-registration.component.html
.../section-registration/section-registration.component.html
+32
-159
section-registration.component.ts
...it/section-registration/section-registration.component.ts
+58
-6
sub-department-one.component.html
...unit/sub-department-one/sub-department-one.component.html
+30
-159
sub-department-one.component.ts
...s-unit/sub-department-one/sub-department-one.component.ts
+60
-6
No files found.
src/app/components/company-components/company-registration/branch-business-unit/department-list/department-list.component.html
View file @
9b7d69c1
...
...
@@ -23,7 +23,7 @@
</div>
<div
class=
"px-1"
>
<button
type=
"button"
class=
"ti-btn ti-btn-soft-secondary h-45px m-0 shadow-md"
(
click
)="
currentModal=
'add'
;
selectBu1
();
selectBu2
()
"
data-hs-overlay=
"#department-list-modal
"
>
(
click
)="
currentModal=
'add'
;
selectBu1
();
selectBu2
()
;
openDialog
();
"
>
<i
class=
"ri-add-line"
></i>
Add
</button>
...
...
@@ -36,7 +36,7 @@
</div> -->
<div
class=
"px-1"
>
<button
href=
"javascript:void(0);"
class=
"ti-btn ti-btn-soft-danger h-45px m-0 shadow-md"
(
click
)="
currentModal=
'delete'
;
selectBu1
()"
data-hs-overlay=
"#department-list-alert-delete-modal"
>
(
click
)="
currentModal=
'delete'
;
deleteBu2
()"
>
<i
class=
"ri-delete-bin-6-line"
></i>
Delete
</button>
...
...
@@ -52,63 +52,27 @@
<div
class=
"page px-rem"
>
<app-datagrid-syncfution
[
searchSettings
]="
searchSettings
"
[
searchText
]="
search
"
[
dataSource
]="
bu2List
"
[
columns
]="
columns
"
[
modalName
]="'#
department-list-modal
'"
[
selectedItems
]="
selectedItems
"
(
sendSelectData
)="
currentModal=
'edit'
;
selectBu2
($
event
)"
(
sendSelectedItems
)="
onSelectItemChange
($
event
)"
>
[
columns
]="
columns
"
[
selectedItems
]="
selectedItems
"
(
sendSelectData
)="
currentModal=
'edit'
;
selectBu2
($
event
)
;
openDialog
()
"
(
sendSelectedItems
)="
onSelectItemChange
($
event
)"
>
</app-datagrid-syncfution>
</div>
<div
id=
"department-list-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=
"max-h-full overflow-hidden ti-modal-content"
>
<div
class=
"ti-modal-header"
>
<h3
class=
"text-xxl font-bold text-primary"
>
เพิ่มข้อมูลทะเบียนเเผนก
</h3>
<h3
class=
"text-xxl font-bold text-primary"
*
ngIf=
"currentModal=='add'"
>
เพิ่มข้อมูลทะเบียนเเผนก
</h3>
<h3
class=
"text-xxl font-bold text-primary"
*
ngIf=
"currentModal=='edit'"
>
แก้ไขข้อมูลทะเบียนเเผนก
<ng-template
#
departmentListModal
let-modal
>
<h3
mat-dialog-title
>
{{currentModal=='add'?'เพิ่มข้อมูลทะเบียนเเผนก':'แก้ไขข้อมูลทะเบียนเเผนก'}}
</h3>
<div
class=
"flex justify-end"
>
<button
type=
"button"
class=
"hs-dropdown-toggle ti-modal-clode-btn text-danger"
data-hs-overlay=
"#department-list-modal"
>
<span
class=
"sr-only"
>
Close
</span>
<i
class=
"ti ti-circle-x fs-xxl"
></i>
</button>
</div>
</div>
<div
class=
"ti-modal-center"
>
<div
class=
"flex justify-end"
style=
"padding-right: 1rem;"
>
<div
class=
"w-full flex justify-end mb-1rem"
>
<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
)="
selectBu1
();
selectBu2
()"
>
<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>
<button
type=
"button"
class=
"ti-btn ti-btn-soft-indigo h-45px m-0 shadow-md"
(
click
)="
selectBu1
();
selectBu2
()"
>
<i
class=
"ti ti-eraser text-base"
></i>
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
class=
"ti-form-label
"
>
อยู่ภายใต้หน่วยงาน
<span
class=
"text-danger"
>
*
</span></label>
<mat-dialog-content
>
<label
class=
"ti-form-label
"
>
อยู่ภายใต้หน่วยงาน
<span
class=
"text-danger"
>
*
</span></label>
<div
class=
"flex"
>
<div
class=
"relative flex rounded-md"
>
<input
type=
"text"
id=
"hs-leading-button-add-on-with-icon-and-button"
...
...
@@ -120,8 +84,7 @@
<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"
>
<button
type=
"button"
class=
"flex items-center text-gray-500 dark:text-white/70"
(
click
)="
openBu1Dialog
()"
>
<i
class=
"ri-search-line cursor-pointer text-gray"
></i>
</button>
</div>
...
...
@@ -146,46 +109,24 @@
<input
type=
"text"
id=
"detail_th"
class=
"ti-form-input h-16"
[(
ngModel
)]="
bu2
.
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
)]="
bu2
.
edesc
"
>
<div
class=
"flex justify-end mt-2rem mb-1rem space-x-4"
>
<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-list-modal
"
>
</mat-dialog-content
>
<mat-dialog-actions
align=
"end"
>
<button
type=
"button"
mat-button
[
mat-dialog-close
]
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
"
>
ย้อนกลับ
</button>
<button
class=
"ti-btn ti-btn-success"
type=
"button"
data-hs-overlay=
"#department-list-alert-modal"
[
class
.
ti-btn-disabled
]="!
bu1
.
bu1id
||!
bu2
.
bu2id
||!
bu2
.
tdesc
||(
currentModal=
='add'&&checkPrimary())"
<button
type=
"button"
class=
"ti-btn ti-btn-success"
mat-button
[
class
.
ti-btn-disabled
]="!
bu1
.
bu1id
||!
bu2
.
bu2id
||!
bu2
.
tdesc
||(
currentModal=
='add'&&checkPrimary())"
(
click
)="
addBu2
()"
[
disabled
]="!
bu1
.
bu1id
||!
bu2
.
bu2id
||!
bu2
.
tdesc
||(
currentModal=
='add'&&checkPrimary())"
>
บันทึกข้อมูล
</button>
</div>
</div>
</div>
</div>
</div>
</mat-dialog-actions>
</ng-template>
<div
id=
"department-list-bu1-table-modal"
class=
"hs-overlay hidden ti-modal"
>
<div
class=
"hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out lg:!max-w-4xl lg:w-full m-3 lg:!mx-auto"
>
<div
class=
"max-h-full overflow-hidden ti-modal-content"
>
<div
class=
"ti-modal-header"
>
<h3
class=
"text-xxl font-bold text-primary"
>
<ng-template
#
departmentListBu1Modal
let-modal
>
<h3
mat-dialog-title
>
ข้อมูลทะเบียนฝ่าย
</h3>
<div
class=
"flex justify-end"
>
<button
*
ngIf=
"currentModal=='add'"
type=
"button"
class=
"hs-dropdown-toggle ti-modal-clode-btn text-danger"
data-hs-overlay=
"#department-list-modal"
>
<span
class=
"sr-only"
>
Close
</span>
<i
class=
"ti ti-circle-x fs-xxl"
></i>
</button>
<button
*
ngIf=
"currentModal=='edit'"
type=
"button"
class=
"hs-dropdown-toggle ti-modal-clode-btn text-danger"
data-hs-overlay=
"#department-list-modal-edit"
>
<span
class=
"sr-only"
>
Close
</span>
<i
class=
"ti ti-circle-x fs-xxl"
></i>
</button>
</div>
</div>
<div
class=
"ti-modal-body"
>
<mat-dialog-content>
<div
class=
"flex justify-end pb-1rem"
>
<div
class=
"px-1"
>
<div
class=
"relative shadow-md"
>
...
...
@@ -224,22 +165,8 @@
</tr>
</tbody>
<tbody
*
ngIf=
"filterBu1Modal().length"
>
<ng-container
*
ngIf=
"currentModal=='add'"
>
<tr
*
ngFor=
"let item of filterBu1Modal() | slice:((bu1Modal.currentPage-1) * bu1Modal.pageSize) : (((bu1Modal.currentPage-1) * bu1Modal.pageSize) + bu1Modal.pageSize);let i = index"
class=
"cursor-pointer"
(
click
)="
selectBu1
(
item
)"
data-hs-overlay=
"#department-list-modal"
>
<td
class=
"flex justify-center"
>
{{((bu1Modal.currentPage-1) * bu1Modal.pageSize)+(i+1)}}
</td>
<td>
{{item.bu1id}}
</td>
<td>
{{item.tdesc}}
</td>
<td>
{{item.edesc}}
</td>
</tr>
</ng-container>
<ng-container
*
ngIf=
"currentModal=='edit'"
>
<tr
*
ngFor=
"let item of filterBu1Modal() | slice:((bu1Modal.currentPage-1) * bu1Modal.pageSize) : (((bu1Modal.currentPage-1) * bu1Modal.pageSize) + bu1Modal.pageSize);let i = index"
class=
"cursor-pointer"
(
click
)="
selectBu1
(
item
)"
data-hs-overlay=
"#department-list-modal-edit"
>
class=
"cursor-pointer"
(
click
)="
selectBu1
(
item
);
closeBu1Dialog
()"
>
<td
class=
"flex justify-center"
>
{{((bu1Modal.currentPage-1) * bu1Modal.pageSize)+(i+1)}}
</td>
...
...
@@ -247,142 +174,21 @@
<td>
{{item.tdesc}}
</td>
<td>
{{item.edesc}}
</td>
</tr>
</ng-container>
</tbody>
</table>
</div>
<app-pagination
[
totalItems
]="
filterBu1Modal
().
length
"
[
pageSize
]="
bu1Modal
.
pageSize
"
(
pageChange
)="
bu1Modal
.
currentPage =
$event"
(
pageSizeChange
)="
bu1Modal
.
pageSize =
$event;bu1Modal.currentPage
=
1
"
></app-pagination>
<div
class=
"flex justify-end mt-2rem mb-1rem space-x-4"
>
<button
type=
"button"
*
ngIf=
"currentModal=='add'"
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-list-modal"
>
ย้อนกลับ
</button>
<button
type=
"button"
*
ngIf=
"currentModal=='edit'"
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-list-modal-edit"
>
ย้อนกลับ
</button>
</div>
</div>
</div>
</div>
</div>
<div
id=
"department-list-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-list-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"
>
ยืนยันการบันทึกข้อมูลหรือไม่
</p>
<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-list-modal"
>
</mat-dialog-content>
<mat-dialog-actions
align=
"end"
>
<button
type=
"button"
mat-button
[
mat-dialog-close
]
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"
>
ย้อนกลับ
</button>
<a
class=
"ti-btn ti-btn-success"
href=
"javascript:void(0);"
data-hs-overlay=
"#department-list-alert-modal"
(
click
)="
addBu2
()"
>
บันทึกข้อมูล
</a>
</div>
</div>
</div>
</div>
</div>
<div
id=
"department-list-alert-edit-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-list-modal-edit"
>
<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"
>
ยืนยันการเเก้ไขข้อมูลหรือไม่
</p>
</mat-dialog-actions>
</ng-template>
<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-list-modal-edit"
>
ย้อนกลับ
</button>
<a
class=
"ti-btn ti-btn-success"
href=
"javascript:void(0);"
data-hs-overlay=
"#department-list-alert-edit-modal"
(
click
)="
addBu2
()"
>
บันทึกข้อมูล
</a>
</div>
</div>
</div>
</div>
</div>
<div
id=
"department-list-alert-delete-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-list-alert-delete-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=
"numSelectItem()"
>
ยืนยันการลบข้อมูลหรือไม่
</ng-container>
<ng-container
*
ngIf=
"!numSelectItem()"
>
เลือกข้อมูลที่ต้องการลบ
</ng-container>
!
</p>
<div
class=
"flex justify-end mt-2rem mb-1rem"
>
<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-list-alert-delete-modal"
>
ย้อนกลับ
</button>
<a
class=
"ti-btn ti-btn-danger"
href=
"javascript:void(0);"
data-hs-overlay=
"#department-list-alert-delete-modal"
(
click
)="
deleteBu2
()"
*
ngIf=
"numSelectItem()"
>
ลบข้อมูล
</a>
</div>
</div>
</div>
</div>
</div>
<div
id=
"department-list-upload-modal"
class=
"hs-overlay hidden ti-modal"
>
<div
class=
"hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out rounded-md"
>
...
...
src/app/components/company-components/company-registration/branch-business-unit/department-list/department-list.component.ts
View file @
9b7d69c1
import
{
ChangeDetectorRef
,
Component
,
EventEmitter
,
Input
,
OnInit
,
}
from
'@angular/core'
;
import
{
ChangeDetectorRef
,
Component
,
EventEmitter
,
Input
,
OnInit
,
ViewChild
,
}
from
'@angular/core'
;
import
{
MatDialog
}
from
'@angular/material/dialog'
;
import
{
ColumnModel
}
from
'@syncfusion/ej2-grids'
;
import
{
ToastrService
}
from
'ngx-toastr'
;
import
{
Bu1Model
,
MyBu1Model
}
from
'src/app/shared/model/bu1.model'
;
...
...
@@ -6,6 +7,7 @@ import { Bu2Model, MyBu2Model } from 'src/app/shared/model/bu2.model';
import
{
Bu1Service
}
from
'src/app/shared/services/bu1.service'
;
import
{
Bu2Service
}
from
'src/app/shared/services/bu2.service'
;
import
{
FileService
}
from
'src/app/shared/services/file.service'
;
import
Swal
from
'sweetalert2'
;
interface
table
{
currentPage
:
number
,
page
:
number
[],
...
...
@@ -70,18 +72,38 @@ export class DepartmentListComponent implements OnInit {
pageSize
:
10
}
currentModal
:
'add'
|
'edit'
|
'delete'
=
"add"
@
ViewChild
(
"departmentListModal"
)
departmentListModal
:
any
;
@
ViewChild
(
"departmentListBu1Modal"
)
departmentListBu1Modal
:
any
;
dialogRef
:
any
dialogRefBu1
:
any
constructor
(
private
bu2Service
:
Bu2Service
,
private
bu1Service
:
Bu1Service
,
private
toastr
:
ToastrService
,
private
cdr
:
ChangeDetectorRef
,
private
fileService
:
FileService
private
fileService
:
FileService
,
private
dialog
:
MatDialog
)
{
}
ngOnInit
():
void
{
this
.
getBu2List
()
this
.
getBu1List
()
}
openDialog
()
{
this
.
dialogRef
=
this
.
dialog
.
open
(
this
.
departmentListModal
,
{
width
:
'500px'
,
})
}
openBu1Dialog
()
{
this
.
dialogRefBu1
=
this
.
dialog
.
open
(
this
.
departmentListBu1Modal
,
{
width
:
'800px'
,
})
}
closeDialog
()
{
this
.
dialogRef
.
close
()
}
closeBu1Dialog
()
{
this
.
dialogRefBu1
.
close
()
}
onFileSelected
(
event
:
any
)
{
this
.
selectedFile
=
event
.
target
.
files
.
length
>
0
?
event
.
target
.
files
[
0
]
:
null
;
this
.
selectedFileName
=
this
.
selectedFile
?.
name
||
"กรุณาเลือกไฟล์"
...
...
@@ -185,45 +207,80 @@ export class DepartmentListComponent implements OnInit {
}
showAlert
(
text
:
string
,
type
:
'success'
|
'error'
)
{
this
.
toastr
[
type
](
text
,
'แจ้งเตือน'
,
{
timeOut
:
3000
,
positionClass
:
'toast-top-right'
,
})
Swal
.
fire
({
title
:
'แจ้งเตือน'
,
text
:
text
,
icon
:
type
,
confirmButtonText
:
'ตกลง'
,
});
}
addBu2
()
{
Swal
.
fire
({
icon
:
'question'
,
title
:
'แจ้งเตือน'
,
text
:
'ยืนยันการบันทึกข้อมูลหรือไม่'
,
showCancelButton
:
true
,
confirmButtonText
:
'บันทึกข้อมูล'
,
cancelButtonText
:
'ย้อนกลับ'
,
reverseButtons
:
true
,
}).
then
((
result
)
=>
{
if
(
result
.
isConfirmed
)
{
this
.
bu2ListLoading
=
true
this
.
bu2Service
.
post
({
...
this
.
bu2
,
parent
:
this
.
bu1
.
bu1id
}).
subscribe
({
next
:
response
=>
{
if
(
response
.
success
)
{
this
.
showAlert
(
response
.
message
,
'success'
)
this
.
getBu2List
()
this
.
closeDialog
();
}
else
{
this
.
showAlert
(
response
.
message
,
'error'
)
this
.
bu2ListLoading
=
false
this
.
closeDialog
();
}
},
error
:
error
=>
{
this
.
showAlert
(
error
.
message
,
'error'
)
this
.
bu2ListLoading
=
false
this
.
closeDialog
();
}
})
}
});
}
deleteBu2
()
{
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
.
bu2ListLoading
=
true
// const body = this.bu2List.filter(x => x.check).map(x => new MyBu2Model(x.data))
// this.bu2Service.delete(body).subscribe({
// next: response => {
// if (response.success) {
// this.showAlert(response.message, 'success')
// this.getBu2List()
// } else {
// this.showAlert(response.message, 'error')
// this.bu2ListLoading = false
// }
// }, error: error => {
// this.showAlert(error.message, 'error')
// this.bu2ListLoading = false
// }
// })
const
selectedKeys
=
Array
.
from
(
this
.
selectedItems
.
data
.
keys
());
const
body
=
this
.
bu2List
.
filter
(
x
=>
selectedKeys
.
includes
(
x
.
bu2id
)
&&
this
.
selectedItems
.
data
.
get
(
x
.
bu2id
)).
map
(
x
=>
new
MyBu2Model
(
x
))
this
.
bu2Service
.
delete
(
body
).
subscribe
({
next
:
response
=>
{
if
(
response
.
success
)
{
this
.
showAlert
(
response
.
message
,
'success'
)
this
.
getBu2List
()
}
else
{
this
.
showAlert
(
response
.
message
,
'error'
)
this
.
bu2ListLoading
=
false
}
},
error
:
error
=>
{
this
.
showAlert
(
error
.
message
,
'error'
)
this
.
bu2ListLoading
=
false
}
})
}
});
}
...
...
src/app/components/company-components/company-registration/branch-business-unit/section-registration/section-registration.component.html
View file @
9b7d69c1
...
...
@@ -23,14 +23,14 @@
</div>
<div
class=
"px-1"
>
<button
type=
"button"
class=
"ti-btn ti-btn-soft-secondary h-45px m-0 shadow-md"
(
click
)="
currentModal=
'add'
;
selectBu2
();
selectBu3
()
"
data-hs-overlay=
"#section-registration-modal
"
>
(
click
)="
currentModal=
'add'
;
selectBu2
();
selectBu3
()
;
openDialog
()
"
>
<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-45px m-0 shadow-md"
(
click
)="
currentModal=
'delete'
"
data-hs-overlay=
"#section-registration-alert-delete-modal"
>
(
click
)="
currentModal=
'delete'
;
deleteBu3
()"
>
<i
class=
"ri-delete-bin-6-line"
></i>
Delete
</button>
...
...
@@ -41,55 +41,27 @@
<div
class=
"page px-rem"
>
<app-datagrid-syncfution
[
searchSettings
]="
searchSettings
"
[
searchText
]="
search
"
[
dataSource
]="
bu3
.
dataList
"
[
columns
]="
columns
"
[
selectedItems
]="
selectedItems
"
modalName=
"#section-registration-modal"
(
sendSelectData
)="
currentModal=
'edit'
;
selectBu3
($
event
)"
(
sendSelectedItems
)="
onSelectItemChange
($
event
)"
>
[
columns
]="
columns
"
[
selectedItems
]="
selectedItems
"
(
sendSelectData
)="
currentModal=
'edit'
;
selectBu3
($
event
)
;
openDialog
()
"
(
sendSelectedItems
)="
onSelectItemChange
($
event
)"
>
</app-datagrid-syncfution>
</div>
<div
id=
"section-registration-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=
"max-h-full overflow-hidden ti-modal-content"
>
<div
class=
"ti-modal-header"
>
<h3
class=
"text-xxl font-bold text-primary"
>
<ng-container
*
ngIf=
"currentModal=='add'"
>
เพิ่มข้อมูลทะเบียนส่วน
</ng-container>
<ng-container
*
ngIf=
"currentModal=='edit'"
>
แก้ไขข้อมูลทะเบียนส่วน
</ng-container>
<ng-template
#
sectionRegistrationModal
let-modal
>
<h3
mat-dialog-title
>
{{currentModal=='add'?'เพิ่มข้อมูลทะเบียนส่วน':'แก้ไขข้อมูลทะเบียนส่วน'}}
</h3>
<div
class=
"flex justify-end"
>
<button
type=
"button"
class=
"hs-dropdown-toggle ti-modal-clode-btn text-danger"
data-hs-overlay=
"#section-registration-modal"
>
<span
class=
"sr-only"
>
Close
</span>
<i
class=
"ti ti-circle-x fs-xxl"
></i>
</button>
</div>
</div>
<div
class=
"ti-modal-center"
>
<div
class=
"flex justify-end"
style=
"padding-right: 1rem;"
>
<div
class=
"w-full flex justify-end mb-1rem"
>
<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
)="
selectBu2
();
selectBu3
()"
>
<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>
<i
class=
"ti ti-eraser text-base"
></i>
Clear
</button>
</div>
</div>
</div>
<div
class=
"ti-modal-body"
>
<mat-dialog-content
>
<label
class=
"ti-form-label"
>
อยู่ภายใต้หน่วยงาน
<span
class=
"text-danger"
>
*
</span></label>
<div
class=
"flex"
>
<div
class=
"relative flex rounded-md"
>
...
...
@@ -102,15 +74,14 @@
<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=
"#section-registration-bu2-table-modal"
>
<button
type=
"button"
class=
"flex items-center text-gray-500 dark:text-white/70"
(
click
)="
openDialogBu2
()"
>
<i
class=
"ri-search-line cursor-pointer text-gray"
></i>
</button>
</div>
</div>
<div
class=
"flex rounded-md w-1/2 pl-1rem"
>
<input
type=
"text"
id=
"input-label"
class=
"ti-form-input w-full pr-10 bg-input-readonly"
readonly
[
value
]="
bu2
.
tdesc
"
>
<input
type=
"text"
id=
"input-label"
class=
"ti-form-input w-full pr-10 bg-input-readonly"
readonly
[
value
]="
bu2
.
tdesc
"
>
</div>
</div>
<label
class=
"ti-form-label mt-2rem"
>
ส่วน
...
...
@@ -130,40 +101,24 @@
<input
type=
"text"
id=
"detail_th"
class=
"ti-form-input h-16"
[(
ngModel
)]="
bu3
.
select
.
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
)]="
bu3
.
select
.
edesc
"
>
<div
class=
"flex justify-end mt-2rem mb-1rem space-x-4"
>
<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=
"#section-registration-modal
"
>
</mat-dialog-content
>
<mat-dialog-actions
align=
"end"
>
<button
type=
"button"
mat-button
[
mat-dialog-close
]
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
"
>
ย้อนกลับ
</button>
<button
type=
"button"
class=
"ti-btn ti-btn-success"
data-hs-overlay=
"#section-registration-alert-modal"
<button
type=
"button"
class=
"ti-btn ti-btn-success"
mat-button
(
click
)="
addBu3
()"
[
class
.
ti-btn-disabled
]="!
bu2
.
bu2id
||!
bu3
.
select
.
bu3id
||!
bu3
.
select
.
tdesc
||(
currentModal=
='add'&&checkPrimary())"
[
disabled
]="!
bu2
.
bu2id
||!
bu3
.
select
.
bu3id
||!
bu3
.
select
.
tdesc
||(
currentModal=
='add'&&checkPrimary())"
>
บันทึกข้อมูล
</button>
</div>
</div>
</div>
</div>
</div>
</mat-dialog-actions>
</ng-template>
<div
id=
"section-registration-bu2-table-modal"
class=
"hs-overlay hidden ti-modal"
>
<div
class=
"hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out lg:!max-w-4xl lg:w-full m-3 lg:!mx-auto"
>
<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=
"#section-registration-modal"
>
<span
class=
"sr-only"
>
Close
</span>
<i
class=
"ti ti-circle-x fs-xxl"
></i>
</button>
</div>
</div>
<div
class=
"ti-modal-body"
>
<ng-template
#
sectionRegistrationModalBu2
let-modal
>
<h3
mat-dialog-title
>
ข้อมูลทะเบียนเเผนก
</h3>
<mat-dialog-content>
<div
class=
"flex justify-end pb-1rem"
>
<div
class=
"px-1"
>
<div
class=
"relative shadow-md"
>
...
...
@@ -203,8 +158,7 @@
</tbody>
<tbody
*
ngIf=
"filterBu2Modal().length"
>
<tr
*
ngFor=
"let item of filterBu2Modal() | slice:((bu2Modal.currentPage-1) * bu2Modal.pageSize) : (((bu2Modal.currentPage-1) * bu2Modal.pageSize) + bu2Modal.pageSize);let i = index"
class=
"cursor-pointer"
(
click
)="
selectBu2
(
item
)"
data-hs-overlay=
"#section-registration-modal"
>
class=
"cursor-pointer"
(
click
)="
selectBu2
(
item
);
closeDialogBu2
()"
>
<td
class=
"flex justify-center"
>
{{((bu2Modal.currentPage-1) * bu2Modal.pageSize)+(i+1)}}
</td>
...
...
@@ -218,97 +172,16 @@
<app-pagination
[
totalItems
]="
filterBu2Modal
().
length
"
[
pageSize
]="
bu2Modal
.
pageSize
"
(
pageChange
)="
bu2Modal
.
currentPage =
$event"
(
pageSizeChange
)="
bu2Modal
.
pageSize =
$event;bu2Modal.currentPage
=
1
"
></app-pagination>
<div
class=
"flex justify-end mt-2rem mb-1rem space-x-4"
>
<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=
"#section-registration-modal
"
>
</mat-dialog-content
>
<mat-dialog-actions
align=
"end"
>
<button
type=
"button"
mat-button
[
mat-dialog-close
]
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
"
>
ย้อนกลับ
</button>
</div>
</div>
</div>
</div>
</div>
</mat-dialog-actions>
</ng-template>
<div
id=
"section-registration-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=
"#section-registration-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"
>
ยืนยันการบันทึกข้อมูลหรือไม่
</p>
<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=
"#section-registration-modal"
>
ย้อนกลับ
</button>
<a
class=
"ti-btn ti-btn-success"
href=
"javascript:void(0);"
data-hs-overlay=
"#section-registration-alert-modal"
(
click
)="
addBu3
()"
>
บันทึกข้อมูล
</a>
</div>
</div>
</div>
</div>
</div>
<div
id=
"section-registration-alert-delete-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=
"#section-registration-alert-delete-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=
"numSelectItem()"
>
ยืนยันการลบข้อมูลหรือไม่
</ng-container>
<ng-container
*
ngIf=
"!numSelectItem()"
>
เลือกข้อมูลที่ต้องการลบ
</ng-container>
!
</p>
<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=
"#section-registration-alert-delete-modal"
>
ย้อนกลับ
</button>
<a
class=
"ti-btn ti-btn-danger"
href=
"javascript:void(0);"
data-hs-overlay=
"#section-registration-alert-delete-modal"
(
click
)="
deleteBu3
()"
*
ngIf=
"numSelectItem()"
>
ลบข้อมูล
</a>
</div>
</div>
</div>
</div>
</div>
<div
id=
"section-registration-upload-modal"
class=
"hs-overlay hidden ti-modal"
>
<div
class=
"hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out rounded-md"
>
...
...
src/app/components/company-components/company-registration/branch-business-unit/section-registration/section-registration.component.ts
View file @
9b7d69c1
import
{
ChangeDetectorRef
,
Component
,
EventEmitter
,
Input
,
OnInit
,
}
from
'@angular/core'
;
import
{
ChangeDetectorRef
,
Component
,
EventEmitter
,
Input
,
OnInit
,
ViewChild
,
}
from
'@angular/core'
;
import
{
MatDialog
}
from
'@angular/material/dialog'
;
import
{
ColumnModel
}
from
'@syncfusion/ej2-grids'
;
import
{
ToastrService
}
from
'ngx-toastr'
;
import
{
Bu2Model
,
MyBu2Model
}
from
'src/app/shared/model/bu2.model'
;
...
...
@@ -6,6 +7,7 @@ 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'
;
import
{
FileService
}
from
'src/app/shared/services/file.service'
;
import
Swal
from
'sweetalert2'
;
interface
table
{
currentPage
:
number
,
page
:
number
[],
...
...
@@ -56,17 +58,38 @@ export class SectionRegistrationComponent implements OnInit {
};
search
=
''
selectedItems
:
{
key
:
string
,
count
:
number
,
data
:
Map
<
string
,
boolean
>
}
=
{
key
:
''
,
count
:
0
,
data
:
new
Map
<
string
,
boolean
>
()
};
@
ViewChild
(
"sectionRegistrationModal"
)
sectionRegistrationModal
:
any
;
@
ViewChild
(
"sectionRegistrationModalBu2"
)
sectionRegistrationModalBu2
:
any
;
dialogRef
:
any
dialogRefBu2
:
any
constructor
(
private
bu3Service
:
Bu3Service
,
private
bu2Service
:
Bu2Service
,
private
toastr
:
ToastrService
,
private
cdr
:
ChangeDetectorRef
,
private
fileService
:
FileService
private
fileService
:
FileService
,
private
dialog
:
MatDialog
)
{
}
ngOnInit
():
void
{
this
.
getBu3List
()
this
.
getBu2List
()
}
openDialog
()
{
this
.
dialogRef
=
this
.
dialog
.
open
(
this
.
sectionRegistrationModal
,
{
width
:
'500px'
,
})
}
openDialogBu2
()
{
this
.
dialogRefBu2
=
this
.
dialog
.
open
(
this
.
sectionRegistrationModalBu2
,
{
width
:
'800px'
,
})
}
closeDialog
()
{
this
.
dialogRef
.
close
()
}
closeDialogBu2
()
{
this
.
dialogRefBu2
.
close
()
}
onFileSelected
(
event
:
any
)
{
this
.
selectedFile
=
event
.
target
.
files
.
length
>
0
?
event
.
target
.
files
[
0
]
:
null
;
...
...
@@ -154,23 +177,48 @@ export class SectionRegistrationComponent implements OnInit {
}
addBu3
()
{
Swal
.
fire
({
icon
:
'question'
,
title
:
'แจ้งเตือน'
,
text
:
'ยืนยันการบันทึกข้อมูลหรือไม่'
,
showCancelButton
:
true
,
confirmButtonText
:
'บันทึกข้อมูล'
,
}).
then
((
result
)
=>
{
if
(
result
.
isConfirmed
)
{
this
.
bu3
.
loading
=
true
this
.
bu3Service
.
post
({
...
this
.
bu3
.
select
,
parent
:
this
.
bu2
.
bu2id
}).
subscribe
({
next
:
response
=>
{
if
(
response
.
success
)
{
this
.
showAlert
(
response
.
message
,
'success'
)
this
.
getBu3List
()
this
.
closeDialog
()
}
else
{
this
.
showAlert
(
response
.
message
,
'error'
)
this
.
bu3
.
loading
=
false
this
.
closeDialog
()
}
},
error
:
error
=>
{
this
.
showAlert
(
error
.
message
,
'error'
)
this
.
bu3
.
loading
=
false
this
.
closeDialog
()
}
})
}
})
}
deleteBu3
()
{
if
(
this
.
numSelectItem
()
==
0
)
{
this
.
showAlert
(
'กรุณาเลือกข้อมูลที่จะลบ'
,
'error'
)
return
}
Swal
.
fire
({
icon
:
'question'
,
title
:
'แจ้งเตือน'
,
text
:
'ยืนยันการลบข้อมูลหรือไม่'
,
showCancelButton
:
true
,
confirmButtonText
:
'ลบข้อมูล'
,
}).
then
((
result
)
=>
{
if
(
result
.
isConfirmed
)
{
this
.
bu3
.
loading
=
true
const
selectedKeys
=
Array
.
from
(
this
.
selectedItems
.
data
.
keys
());
const
body
=
this
.
bu3
.
dataList
.
filter
(
x
=>
selectedKeys
.
includes
(
x
.
bu3id
)
&&
this
.
selectedItems
.
data
.
get
(
x
.
bu3id
)).
map
(
x
=>
new
MyBu3Model
(
x
))
...
...
@@ -189,6 +237,8 @@ export class SectionRegistrationComponent implements OnInit {
}
})
}
})
}
getBu2List
()
{
this
.
bu2Service
.
getList
().
subscribe
(
response
=>
{
...
...
@@ -214,10 +264,12 @@ export class SectionRegistrationComponent implements OnInit {
}
showAlert
(
text
:
string
,
type
:
'success'
|
'error'
)
{
this
.
toastr
[
type
](
text
,
'แจ้งเตือน'
,
{
timeOut
:
3000
,
positionClass
:
'toast-top-right'
,
})
Swal
.
fire
({
title
:
'แจ้งเตือน'
,
text
:
text
,
icon
:
type
,
confirmButtonText
:
'ตกลง'
,
});
}
checkPrimary
()
{
...
...
src/app/components/company-components/company-registration/branch-business-unit/sub-department-one/sub-department-one.component.html
View file @
9b7d69c1
...
...
@@ -22,14 +22,13 @@
</div>
<div
class=
"px-1"
>
<button
type=
"button"
class=
"ti-btn ti-btn-soft-secondary h-45px m-0 shadow-md"
(
click
)="
currentModal=
'add'
;
selectBu3
();
selectBu4
()
"
data-hs-overlay=
"#sub-department-one-modal"
>
(
click
)="
currentModal=
'add'
;
selectBu3
();
selectBu4
()
;
openDialog
()"
>
<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-45px m-0 shadow-md"
data-hs-overlay=
"#sub-department-one-alert-delete-modal"
>
<button
href=
"javascript:void(0);"
class=
"ti-btn ti-btn-soft-danger h-45px m-0 shadow-md"
(
click
)="
deleteBu4
()"
>
<i
class=
"ri-delete-bin-6-line"
></i>
Delete
</button>
...
...
@@ -39,56 +38,26 @@
<div
class=
"page px-rem"
>
<app-datagrid-syncfution
[
searchSettings
]="
searchSettings
"
[
searchText
]="
search
"
[
dataSource
]="
bu4
.
dataList
"
[
columns
]="
columns
"
[
selectedItems
]="
selectedItems
"
modalName=
"#sub-department-one-modal"
(
sendSelectData
)="
currentModal=
'edit'
;
selectBu4
($
event
)"
(
sendSelectedItems
)="
onSelectItemChange
($
event
)"
>
[
columns
]="
columns
"
[
selectedItems
]="
selectedItems
"
(
sendSelectData
)="
currentModal=
'edit'
;
selectBu4
($
event
)
;
openDialog
()
"
(
sendSelectedItems
)="
onSelectItemChange
($
event
)"
>
</app-datagrid-syncfution>
</div>
<div
id=
"sub-department-one-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=
"max-h-full overflow-hidden ti-modal-content"
>
<div
class=
"ti-modal-header"
>
<h3
class=
"text-xxl font-bold text-primary"
>
<ng-container
*
ngIf=
"currentModal=='add'"
>
เพิ่มข้อมูลทะเบียนส่วนย่อย 1
</ng-container>
<ng-container
*
ngIf=
"currentModal=='edit'"
>
แก้ไขข้อมูลทะเบียนส่วนย่อย 1
</ng-container>
<ng-template
#
subDepartmentOneModal
let-modal
>
<h3
mat-dialog-title
>
{{currentModal=='add'?'เพิ่มข้อมูลทะเบียนส่วนย่อย 1':'แก้ไขข้อมูลทะเบียนส่วนย่อย 1'}}
</h3>
<div
class=
"flex justify-end"
>
<button
type=
"button"
class=
"hs-dropdown-toggle ti-modal-clode-btn text-danger"
data-hs-overlay=
"#sub-department-one-modal"
>
<span
class=
"sr-only"
>
Close
</span>
<i
class=
"ti ti-circle-x fs-xxl"
></i>
</button>
</div>
</div>
<div
class=
"ti-modal-center"
>
<div
class=
"flex justify-end"
style=
"padding-right: 1rem;"
>
<div
class=
"w-full flex justify-end mb-1rem"
>
<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
)="
selectBu3
();
selectBu4
()"
>
<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>
<button
type=
"button"
class=
"ti-btn ti-btn-soft-indigo h-45px m-0 shadow-md"
(
click
)="
selectBu3
();
selectBu4
()"
>
<i
class=
"ti ti-eraser text-base"
></i>
Clear
</button>
</div>
</div>
</div>
<div
class=
"ti-modal-body"
>
<mat-dialog-content
>
<label
class=
"ti-form-label"
>
อยู่ภายใต้หน่วยงาน
<span
class=
"text-danger"
>
*
</span></label>
<div
class=
"flex"
>
<div
class=
"relative flex rounded-md"
>
...
...
@@ -101,8 +70,7 @@
<button
type=
"button"
class=
"flex items-center text-red-500"
(
click
)="
selectBu3
()"
>
<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=
"#sub-department-one-bu3-table-modal"
>
<button
type=
"button"
class=
"flex items-center text-gray-500 dark:text-white/70"
(
click
)="
openDialogBu3
()"
>
<i
class=
"ri-search-line cursor-pointer text-gray"
></i>
</button>
</div>
...
...
@@ -129,41 +97,25 @@
<input
type=
"text"
id=
"detail_th"
class=
"ti-form-input h-16"
[(
ngModel
)]="
bu4
.
select
.
tdesc
"
>
<label
for=
"detail_eng"
class=
"ti-form-label mt-2rem"
>
รายละเอียดส่วนย่อย1 (อังกฤษ)
</label>
<input
type=
"text"
id=
"detail_eng"
class=
"ti-form-input h-16"
[(
ngModel
)]="
bu4
.
select
.
edesc
"
>
<div
class=
"flex justify-end mt-2rem mb-1rem space-x-4"
>
<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=
"#sub-department-one-modal
"
>
</mat-dialog-content
>
<mat-dialog-actions
align=
"end"
>
<button
type=
"button"
mat-button
[
mat-dialog-close
]
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
"
>
ย้อนกลับ
</button>
<button
class=
"ti-btn ti-btn-success"
type=
"button"
data-hs-overlay=
"#sub-department-one-alert-modal"
<button
type=
"button"
class=
"ti-btn ti-btn-success"
mat-button
(
click
)="
addBu4
()"
[
class
.
ti-btn-disabled
]="!
bu3
.
bu3id
||!
bu4
.
select
.
bu4id
||!
bu4
.
select
.
tdesc
||(
currentModal=
='add'&&checkPrimary())"
[
disabled
]="!
bu3
.
bu3id
||!
bu4
.
select
.
bu4id
||!
bu4
.
select
.
tdesc
||(
currentModal=
='add'&&checkPrimary())"
>
บันทึกข้อมูล
</button>
</div>
</div>
</div>
</div>
</div>
</mat-dialog-actions>
</ng-template>
<div
id=
"sub-department-one-bu3-table-modal"
class=
"hs-overlay hidden ti-modal"
>
<div
class=
"hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out lg:!max-w-4xl lg:w-full m-3 lg:!mx-auto"
>
<div
class=
"max-h-full overflow-hidden ti-modal-content"
>
<div
class=
"ti-modal-header"
>
<h3
class=
"text-xxl font-bold text-primary"
>
<ng-template
#
subDepartmentOneBu3TableModal
let-modal
>
<h3
mat-dialog-title
>
ข้อมูลทะเบียนส่วน
</h3>
<div
class=
"flex justify-end"
>
<button
type=
"button"
class=
"hs-dropdown-toggle ti-modal-clode-btn text-danger"
data-hs-overlay=
"#sub-department-one-modal"
>
<span
class=
"sr-only"
>
Close
</span>
<i
class=
"ti ti-circle-x fs-xxl"
></i>
</button>
</div>
</div>
<div
class=
"ti-modal-body"
>
<mat-dialog-content>
<div
class=
"flex justify-end pb-1rem"
>
<div
class=
"px-1"
>
<div
class=
"relative shadow-md"
>
...
...
@@ -203,8 +155,7 @@
</tbody>
<tbody
*
ngIf=
"filterBu3Modal().length"
>
<tr
*
ngFor=
"let item of filterBu3Modal() | slice:((bu3Modal.currentPage-1) * bu3Modal.pageSize) : (((bu3Modal.currentPage-1) * bu3Modal.pageSize) + bu3Modal.pageSize);let i = index"
class=
"cursor-pointer"
(
click
)="
selectBu3
(
item
)"
data-hs-overlay=
"#sub-department-one-modal"
>
class=
"cursor-pointer"
(
click
)="
selectBu3
(
item
);
closeDialogBu3
()"
>
<td
class=
"flex justify-center"
>
{{((bu3Modal.currentPage-1) * bu3Modal.pageSize)+(i+1)}}
</td>
...
...
@@ -218,97 +169,17 @@
<app-pagination
[
totalItems
]="
filterBu3Modal
().
length
"
[
pageSize
]="
bu3Modal
.
pageSize
"
(
pageChange
)="
bu3Modal
.
currentPage =
$event"
(
pageSizeChange
)="
bu3Modal
.
pageSize =
$event;bu3Modal.currentPage
=
1
"
></app-pagination>
<div
class=
"flex justify-end mt-2rem mb-1rem space-x-4"
>
<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=
"#sub-department-one-modal
"
>
</mat-dialog-content
>
<mat-dialog-actions
align=
"end"
>
<button
type=
"button"
mat-button
[
mat-dialog-close
]
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
"
>
ย้อนกลับ
</button>
</div>
</div>
</div>
</div>
</div>
</mat-dialog-actions>
</ng-template>
<div
id=
"sub-department-one-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=
"#sub-department-one-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"
>
ยืนยันการบันทึกข้อมูลหรือไม่
</p>
<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=
"#sub-department-one-modal"
>
ย้อนกลับ
</button>
<a
class=
"ti-btn ti-btn-success"
href=
"javascript:void(0);"
data-hs-overlay=
"#sub-department-one-alert-modal"
(
click
)="
addBu4
()"
>
บันทึกข้อมูล
</a>
</div>
</div>
</div>
</div>
</div>
<div
id=
"sub-department-one-alert-delete-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=
"#sub-department-one-alert-delete-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=
"numSelectItem()"
>
ยืนยันการลบข้อมูลหรือไม่
</ng-container>
<ng-container
*
ngIf=
"!numSelectItem()"
>
เลือกข้อมูลที่ต้องการลบ
</ng-container>
</p>
<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=
"#sub-department-one-alert-delete-modal"
>
ย้อนกลับ
</button>
<a
class=
"ti-btn ti-btn-danger"
href=
"javascript:void(0);"
data-hs-overlay=
"#sub-department-one-alert-delete-modal"
(
click
)="
deleteBu4
();"
*
ngIf=
"numSelectItem()"
>
ลบข้อมูล
</a>
</div>
</div>
</div>
</div>
</div>
<div
id=
"sub-department-one-upload-modal"
class=
"hs-overlay hidden ti-modal"
>
<div
class=
"hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out rounded-md"
>
...
...
src/app/components/company-components/company-registration/branch-business-unit/sub-department-one/sub-department-one.component.ts
View file @
9b7d69c1
import
{
ChangeDetectorRef
,
Component
,
EventEmitter
,
Input
,
OnInit
}
from
'@angular/core'
;
import
{
ChangeDetectorRef
,
Component
,
EventEmitter
,
Input
,
OnInit
,
ViewChild
}
from
'@angular/core'
;
import
{
ColumnModel
}
from
'@syncfusion/ej2-grids'
;
import
{
MatDialog
}
from
'@angular/material/dialog'
;
import
{
ToastrService
}
from
'ngx-toastr'
;
import
{
Bu3Model
,
MyBu3Model
}
from
'src/app/shared/model/bu3.model'
;
import
{
Bu4Model
,
MyBu4Model
}
from
'src/app/shared/model/bu4.model'
;
import
{
Bu3Service
}
from
'src/app/shared/services/bu3.service'
;
import
{
Bu4Service
}
from
'src/app/shared/services/bu4.service'
;
import
{
FileService
}
from
'src/app/shared/services/file.service'
;
import
Swal
from
'sweetalert2'
;
interface
table
{
currentPage
:
number
,
page
:
number
[],
...
...
@@ -63,11 +65,17 @@ export class SubDepartmentOneComponent implements OnInit {
};
search
=
''
selectedItems
:
{
key
:
string
,
count
:
number
,
data
:
Map
<
string
,
boolean
>
}
=
{
key
:
''
,
count
:
0
,
data
:
new
Map
<
string
,
boolean
>
()
};
@
ViewChild
(
"subDepartmentOneModal"
)
subDepartmentOneModal
:
any
;
@
ViewChild
(
"subDepartmentOneBu3TableModal"
)
subDepartmentOneBu3TableModal
:
any
;
dialogRef
:
any
dialogRefBu3
:
any
constructor
(
private
bu4Service
:
Bu4Service
,
private
bu3Service
:
Bu3Service
,
private
toastr
:
ToastrService
,
private
cdr
:
ChangeDetectorRef
,
private
fileService
:
FileService
private
fileService
:
FileService
,
private
dialog
:
MatDialog
)
{
}
ngOnInit
():
void
{
...
...
@@ -75,6 +83,23 @@ export class SubDepartmentOneComponent implements OnInit {
this
.
getBu3List
()
}
openDialog
()
{
this
.
dialogRef
=
this
.
dialog
.
open
(
this
.
subDepartmentOneModal
,
{
width
:
'500px'
,
})
}
openDialogBu3
()
{
this
.
dialogRefBu3
=
this
.
dialog
.
open
(
this
.
subDepartmentOneBu3TableModal
,
{
width
:
'800px'
,
})
}
closeDialog
()
{
this
.
dialogRef
.
close
()
}
closeDialogBu3
()
{
this
.
dialogRefBu3
.
close
()
}
onFileSelected
(
event
:
any
)
{
this
.
selectedFile
=
event
.
target
.
files
.
length
>
0
?
event
.
target
.
files
[
0
]
:
null
;
this
.
selectedFileName
=
this
.
selectedFile
?.
name
||
"กรุณาเลือกไฟล์"
...
...
@@ -160,23 +185,48 @@ export class SubDepartmentOneComponent implements OnInit {
}
addBu4
()
{
Swal
.
fire
({
icon
:
'question'
,
title
:
'แจ้งเตือน'
,
text
:
'ยืนยันการบันทึกข้อมูลหรือไม่'
,
showCancelButton
:
true
,
confirmButtonText
:
'บันทึกข้อมูล'
,
}).
then
((
result
)
=>
{
if
(
result
.
isConfirmed
)
{
this
.
bu4
.
loading
=
true
this
.
bu4Service
.
post
({
...
this
.
bu4
.
select
,
parent
:
this
.
bu3
.
bu3id
}).
subscribe
({
next
:
response
=>
{
if
(
response
.
success
)
{
this
.
showAlert
(
response
.
message
,
'success'
)
this
.
getBu4List
()
this
.
closeDialog
()
}
else
{
this
.
showAlert
(
response
.
message
,
'error'
)
this
.
bu4
.
loading
=
false
this
.
closeDialog
()
}
},
error
:
error
=>
{
this
.
showAlert
(
error
.
message
,
'error'
)
this
.
bu4
.
loading
=
false
this
.
closeDialog
()
}
})
}
})
}
deleteBu4
()
{
if
(
this
.
numSelectItem
()
==
0
)
{
this
.
showAlert
(
'กรุณาเลือกข้อมูลที่จะลบ'
,
'error'
)
return
}
Swal
.
fire
({
icon
:
'question'
,
title
:
'แจ้งเตือน'
,
text
:
'ยืนยันการลบข้อมูลหรือไม่'
,
showCancelButton
:
true
,
confirmButtonText
:
'ลบข้อมูล'
,
}).
then
((
result
)
=>
{
if
(
result
.
isConfirmed
)
{
this
.
bu4
.
loading
=
true
const
selectedKeys
=
Array
.
from
(
this
.
selectedItems
.
data
.
keys
());
const
body
=
this
.
bu4
.
dataList
.
filter
(
x
=>
selectedKeys
.
includes
(
x
.
bu4id
)
&&
this
.
selectedItems
.
data
.
get
(
x
.
bu4id
)).
map
(
x
=>
new
MyBu4Model
(
x
))
...
...
@@ -195,6 +245,8 @@ export class SubDepartmentOneComponent implements OnInit {
}
})
}
})
}
getBu3List
()
{
this
.
bu3Service
.
getList
().
subscribe
(
response
=>
{
...
...
@@ -220,10 +272,12 @@ export class SubDepartmentOneComponent implements OnInit {
}
showAlert
(
text
:
string
,
type
:
'success'
|
'error'
)
{
this
.
toastr
[
type
](
text
,
'แจ้งเตือน'
,
{
timeOut
:
3000
,
positionClass
:
'toast-top-right'
,
})
Swal
.
fire
({
title
:
'แจ้งเตือน'
,
text
:
text
,
icon
:
type
,
confirmButtonText
:
'ตกลง'
,
});
}
...
...
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