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
6161cddf
Commit
6161cddf
authored
Apr 16, 2025
by
Nattana Chaiyamat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
สร้างชื่อผู้ใช้งาน
parent
2b0c2692
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
114 additions
and
228 deletions
+114
-228
user-settings.component.html
...count-settings/user-settings/user-settings.component.html
+46
-171
user-settings.component.ts
...account-settings/user-settings/user-settings.component.ts
+68
-57
No files found.
src/app/components/company-components/account-settings/user-settings/user-settings.component.html
View file @
6161cddf
<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 pr-2 pb-2rem"
>
<div
class=
"flex justify-end"
>
<div
class=
"flex"
>
<div
class=
"px-1"
>
<div
class=
"flex items-center"
>
<div
class=
"relative shadow-md"
>
<input
type=
"checkbox"
class=
"ti-form-checkbox pointer-events-none"
id=
"hs-default-checkbox"
<input
type=
"text"
class=
"ti-form-input ltr:pl-11 rtl:pr-11 focus:z-10 "
[(
ngModel
)]="
isDataListChecked
"
>
placeholder=
"Search by No. or Name"
[(
ngModel
)]="
search
"
>
<label
for=
"hs-default-checkbox"
class=
"text-sm text-gray-500 mx-2 pointer-events-none"
>
<div
{{numDataListChecked}} Selected
</label>
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"
>
</div>
<i
class=
"ri-search-line text-gray"
></i>
<div
class=
"mx-1 flex items-center"
>
</div>
<button
(
click
)="
isDataListCheckedAll =
!isDataListCheckedAll;dataListCheckAll()"
id=
'check-boxall'
class=
"focus:ring-2 focus:ring-primary rounded-sm flex item-center"
>
<i
class=
"fs-l transition-all duration-200"
[
ngClass
]="{'
ri-checkbox-multiple-line
text-gray-500
'
:
!
isDataListCheckedAll
,
'
ri-checkbox-multiple-fill
text-primary
'
:
isDataListCheckedAll
}"
></i>
</button>
<label
class=
"text-sm text-gray-500 ml-2 cursor-pointer"
for=
"check-boxall"
>
Select All
</label>
</div>
</div>
</div>
</div>
</div>
<div
class=
"px-1"
>
<div
class=
"flex justify-between"
>
<button
type=
"button"
<div
class=
"flex pr-2"
>
class=
" h-45px ti-btn ti-btn bg-pink-500/10 text-pink-500 hover:text-white hover:bg-pink-500 ring-offset-white focus:ring-pink-500 dark:focus:ring-offset-white/10 h-10 m-0 shadow-md"
<div
class=
"px-1"
>
data-hs-overlay=
"#user-setting-upload-modal"
<button
type=
"button"
class=
"ti-btn ti-btn-soft-secondary h-20px m-0 shadow-md"
(
click
)="
fileInput
.
value =
''
;
selectedFile=
null;selectedFileName
=
'กรุณาเลือกไฟล์'"
>
data-hs-overlay=
"#user-setting-upload-modal"
<i
class=
"ti ti-file-plus"
></i>
(
click
)="
fileInput
.
value =
''
;
selectedFile=
null;selectedFileName
=
'กรุณาเลือกไฟล์'"
>
import
<i
class=
"ri-add-line"
></i>
</button>
นำเข้าข้อมูล
</button>
<a
class=
"mx-2 justify-center -mb-px inline-flex items-center gap-2 font-weight-500 font-size-12px text-center text-secondary border-secondary border-b-2 align-items-end"
href=
"javascript:void(0);"
(
click
)="
downloadFile
()"
>
ดาวน์โหลดตัวอย่างไฟล์
</a>
</div>
</div>
</div>
<div
class=
"flex justify-end"
>
<div
class=
"px-1"
>
<div
class=
"px-1"
>
<button
type=
"button"
class=
"ti-btn ti-btn-soft-secondary h-45px m-0 shadow-md"
<div
class=
"relative shadow-md"
>
data-hs-overlay=
"#user-setting-modal"
(
click
)="
currentModal=
'add'
;
selectUser
()"
>
<input
type=
"text"
class=
"ti-form-input ltr:pl-11 rtl:pr-11 focus:z-10 "
<i
class=
"ri-add-line"
></i>
placeholder=
"Search by No. or Name"
style=
"height: 40px;"
[(
ngModel
)]="
search
"
Add
(
ngModelChange
)="
searchChange
()"
>
</button>
<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"
>
<div
class=
"px-1"
>
<i
class=
"ri-search-line text-gray"
></i>
<button
type=
"button"
class=
"ti-btn ti-btn-soft-danger h-45px m-0 shadow-md"
</div>
data-hs-overlay=
"#user-setting-alert-modal"
(
click
)="
currentModal=
'delete'
"
>
</div>
<i
class=
"ri-delete-bin-6-line"
></i>
</div>
Delete
<div
class=
"px-1"
>
</button>
<button
type=
"button"
class=
"ti-btn ti-btn-soft-secondary h-20px m-0 shadow-md"
data-hs-overlay=
"#user-setting-modal"
(
click
)="
currentModal=
'add'
;
selectUser
()"
>
<i
class=
"ri-add-line"
></i>
Add
</button>
</div>
<div
class=
"px-1"
>
<button
type=
"button"
class=
"ti-btn ti-btn-soft-danger h-20px m-0 shadow-md"
data-hs-overlay=
"#user-setting-alert-modal"
(
click
)="
currentModal=
'deleteGroup'
"
>
<i
class=
"ri-delete-bin-6-line"
></i>
Delete
</button>
</div>
<!-- <div class="px-1">
<button type="button" class="ti-btn ti-btn-soft-warning h-20px m-0 shadow-md">
<i class="ti ti-book fs-l"></i>
Help
</button>
</div> -->
</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
]="
user
.
dataList
"
<table
class=
"ti-custom-table ti-custom-table-head ti-custom-table-hover table-bordered"
>
[
columns
]="
columns
"
[
selectedItems
]="
selectedItems
"
modalName=
"#user-setting-modal"
<thead>
(
sendSelectData
)="
currentModal=
'edit'
;
selectUser
($
event
)"
(
sendSelectedItems
)="
onSelectItemChange
($
event
)"
>
<tr>
</app-datagrid-syncfution>
<ng-container
*
ngFor=
"let item of ['','ชื่อล็อกอิน','รหัสพนักงาน','ชื่อ','นามสกุล','สถานะ','การจัดการ']; let f = first; let l = last; let i = index"
>
<th
scope=
"col"
class=
"relative px-10px py-10px bg-soft-secondary text-primary !text-center"
>
<span
class=
"font-size-12px font-weight-700"
>
{{ item }}
</span>
<div
class=
"absolute top-1/2 transform -translate-y-1/2 right-0"
*
ngIf=
"!l&&!f"
>
<i
class=
"ti ti-dots-vertical fs-l"
></i>
</div>
</th>
</ng-container>
</tr>
</thead>
<tbody
*
ngIf=
"user.loading"
>
<tr>
<td
class=
"text-center"
colspan=
"100%"
>
<div
*
ngFor=
"let item of [1,2,3]"
class=
"ti-spinner w-8 h-8 text-secondary mx-1"
role=
"status"
aria-label=
"loading"
>
<span
class=
"sr-only"
>
Loading...
</span>
</div>
</td>
</tr>
</tbody>
<tbody
*
ngIf=
"!user.loading&&!userListFilter().length"
>
<tr>
<td
class=
"text-center"
colspan=
"100%"
>
ไม่พบข้อมูล
</td>
</tr>
</tbody>
<tbody
*
ngIf=
"!user.loading&&userListFilter().length"
>
<tr
*
ngFor=
"let item of userListFilter() | slice:((currentPage-1) * 10) : (((currentPage-1) * 10) + 10);let i = index"
>
<td
class=
"text-center"
>
<input
type=
"checkbox"
class=
"ti-form-checkbox cursor-pointer"
id=
"checkbox-{{item.data.usernameId}}"
[(
ngModel
)]="
item
.
check
"
(
ngModelChange
)="
dataListCheck
()"
>
</td>
<td
class=
"text-center"
>
<label
for=
"checkbox-{{item.data.usernameId}}"
>
{{item.data.usernameId}}
</label>
</td>
<td
class=
"text-center"
>
{{item.data.empId}}
</td>
<td>
{{item.data.employee.fname}}
</td>
<td>
{{item.data.employee.lname}}
</td>
<td
class=
"text-center"
>
{{item.data.status=='0'?'ไม่ใช้งาน':'ใช้งาน'}}
</td>
<td
class=
"flex justify-center"
>
<i
class=
"ti ti-edit cursor-pointer i-gray fs-l px-1"
(
click
)="
currentModal=
'edit'
;
selectUser
(
item
.
data
)"
data-hs-overlay=
"#user-setting-modal"
></i>
<!-- <i class="ti ti-trash cursor-pointer i-gray fs-l px-1"
data-hs-overlay="#user-setting-alert-modal"
(click)="currentModal='delete';selectUser(item.data)"></i> -->
</td>
</tr>
</tbody>
</table>
</div>
<nav
class=
"pagination-style-3 overflow-auto my-5"
*
ngIf=
"page.length"
>
<ul
class=
"ti-pagination"
>
<li>
<a
aria-label=
"anchor"
class=
"page-link"
href=
"javascript:void(0);"
(
click
)="
currentPage =
(currentPage-1
||
1
)"
>
<i
class=
"ri-arrow-left-s-line align-middle rtl:rotate-180"
></i>
</a>
</li>
<li
*
ngFor=
"let item of page;let f = first;let l = last"
>
<ng-container
*
ngIf=
"item==3&¤tPage!=1&¤tPage!=2&¤tPage!=3"
>
<a
aria-label=
"anchor"
class=
"page-link"
href=
"javascript:void(0);"
><i
class=
"ri-more-line"
></i>
</a>
</ng-container>
<ng-container
*
ngIf=
"(f||l)||(item==currentPage-1||item==currentPage||item==currentPage+1)"
>
<a
class=
"page-link"
href=
"javascript:void(0);"
[
class
.
active
]="
item=
=currentPage"
(
click
)="
currentPage=
item"
>
{{item}}
</a>
</ng-container>
<ng-container
*
ngIf=
"item==page.length-2&¤tPage!=page.length&¤tPage!=page.length-1&¤tPage!=page.length-2"
>
<a
aria-label=
"anchor"
class=
"page-link"
href=
"javascript:void(0);"
><i
class=
"ri-more-line"
></i>
</a>
</ng-container>
</li>
<li>
<a
aria-label=
"anchor"
class=
"page-link"
href=
"javascript:void(0);"
(
click
)="
currentPage =
(currentPage
>
page.length-1 ? currentPage: currentPage+1 )">
<i
class=
"ri-arrow-right-s-line align-middle rtl:rotate-180"
></i>
</a>
</li>
</ul>
<ul
class=
"nav-tabs mt-3"
>
<span>
Show {{((currentPage-1) * 10)+1}} to {{userListFilter().length
<10
?
userListFilter
().
length:
(
currentPage=
=page.length
?
((
currentPage
*
10
)
-
((
currentPage
*
10
)
-
userListFilter
().
length
)
)
:
(
currentPage
*
10
)
)
}}
of
{{
userListFilter
().
length
}}
items
</
span
>
</ul>
</nav>
</div>
</div>
...
@@ -203,17 +79,11 @@
...
@@ -203,17 +79,11 @@
Clear
Clear
</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
class=
"ti-modal-body padding-16px pt-0 overflow-y-0"
>
<div
class=
"ti-modal-body padding-16px pt-0 overflow-y-0"
>
<label
class=
"ti-form-label mt-2rem"
>
ชื่อล็อกอิน
<label
class=
"ti-form-label mt-2rem"
>
ชื่อล็อกอิน
<span
class=
"text-danger"
>
*
<span
class=
"text-danger"
>
*
<ng-container
*
ngIf=
"currentModal=='add'&&checkPrimary()"
>
<ng-container
*
ngIf=
"currentModal=='add'&&checkPrimary()"
>
ชื่อล็อกอินซ้ำ
ชื่อล็อกอินซ้ำ
</ng-container>
</ng-container>
...
@@ -725,6 +595,11 @@
...
@@ -725,6 +595,11 @@
<i
class=
"ti ti-upload"
></i>
<i
class=
"ti ti-upload"
></i>
</button>
</button>
</div>
</div>
<div
class=
"flex justify-center mt-2rem "
>
<h1
class=
"cursor-pointer justify-center -mb-px inline-flex items-center gap-2 font-weight-500 font-size-12px
text-center text-secondary border-secondary border-b-2 align-items-end"
(
click
)="
downloadFile
()"
>
ดาวน์โหลดตัวอย่างไฟล์
</h1>
</div>
<div
class=
"flex justify-center mt-2rem mb-1rem space-x-4"
>
<div
class=
"flex justify-center mt-2rem mb-1rem space-x-4"
>
<button
type=
"submit"
data-hs-overlay=
"#user-setting-upload-modal"
class=
"ti-btn ti-btn-secondary"
<button
type=
"submit"
data-hs-overlay=
"#user-setting-upload-modal"
class=
"ti-btn ti-btn-secondary"
[
class
.
ti-btn-disabled
]="!
selectedFile
"
(
click
)="
uploadFile
()"
[
disabled
]="!
selectedFile
"
>
[
class
.
ti-btn-disabled
]="!
selectedFile
"
(
click
)="
uploadFile
()"
[
disabled
]="!
selectedFile
"
>
...
@@ -752,7 +627,7 @@
...
@@ -752,7 +627,7 @@
<i
class=
"ti ti-circle-x fs-xxl"
></i>
<i
class=
"ti ti-circle-x fs-xxl"
></i>
</button>
</button>
</ng-container>
</ng-container>
<ng-container
*
ngIf=
"currentModal == 'delete'
||currentModal == 'deleteGroup'
"
>
<ng-container
*
ngIf=
"currentModal == 'delete'"
>
<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=
"#user-setting-alert-modal"
>
data-hs-overlay=
"#user-setting-alert-modal"
>
<span
class=
"sr-only"
>
Close
</span>
<span
class=
"sr-only"
>
Close
</span>
...
@@ -766,11 +641,11 @@
...
@@ -766,11 +641,11 @@
<ng-container
*
ngIf=
"currentModal == 'add'||currentModal == 'edit'"
>
<ng-container
*
ngIf=
"currentModal == 'add'||currentModal == 'edit'"
>
ยืนยันการบันทึกข้อมูลหรือไม่!
ยืนยันการบันทึกข้อมูลหรือไม่!
</ng-container>
</ng-container>
<ng-container
*
ngIf=
"currentModal == 'delete'
||currentModal == 'deleteGroup'
"
>
<ng-container
*
ngIf=
"currentModal == 'delete'"
>
<ng-container
*
ngIf=
"num
DataListChecked
"
>
<ng-container
*
ngIf=
"num
SelectItem()
"
>
ยืนยันการลบข้อมูลหรือไม่
ยืนยันการลบข้อมูลหรือไม่
</ng-container>
</ng-container>
<ng-container
*
ngIf=
"!num
DataListChecked
"
>
<ng-container
*
ngIf=
"!num
SelectItem()
"
>
เลือกข้อมูลที่ต้องการลบ
เลือกข้อมูลที่ต้องการลบ
</ng-container>
!
</ng-container>
!
</ng-container>
</ng-container>
...
@@ -787,7 +662,7 @@
...
@@ -787,7 +662,7 @@
บันทึกข้อมูล
บันทึกข้อมูล
</a>
</a>
</ng-container>
</ng-container>
<ng-container
*
ngIf=
"currentModal == 'delete'
||currentModal == 'deleteGroup'
"
>
<ng-container
*
ngIf=
"currentModal == 'delete'"
>
<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=
"#user-setting-alert-modal"
>
data-hs-overlay=
"#user-setting-alert-modal"
>
...
@@ -795,7 +670,7 @@
...
@@ -795,7 +670,7 @@
</button>
</button>
<a
class=
"ti-btn ti-btn-danger"
href=
"javascript:void(0);"
<a
class=
"ti-btn ti-btn-danger"
href=
"javascript:void(0);"
data-hs-overlay=
"#user-setting-alert-modal"
(
click
)="
updateUser
('
delete
')"
data-hs-overlay=
"#user-setting-alert-modal"
(
click
)="
updateUser
('
delete
')"
*
ngIf=
"num
DataListChecked
"
>
*
ngIf=
"num
SelectItem()
"
>
ลบข้อมูล
ลบข้อมูล
</a>
</a>
</ng-container>
</ng-container>
...
...
src/app/components/company-components/account-settings/user-settings/user-settings.component.ts
View file @
6161cddf
import
{
ChangeDetectorRef
,
Component
,
EventEmitter
,
Input
,
Output
}
from
'@angular/core'
;
import
{
ChangeDetectorRef
,
Component
,
EventEmitter
,
Input
,
Output
}
from
'@angular/core'
;
import
{
ColumnModel
}
from
'@syncfusion/ej2-grids'
;
import
{
ToastrService
}
from
'ngx-toastr'
;
import
{
ToastrService
}
from
'ngx-toastr'
;
import
{
EmployeeModel
,
MyEmployeeModel
}
from
'src/app/shared/model/employee.model'
;
import
{
EmployeeModel
,
MyEmployeeModel
}
from
'src/app/shared/model/employee.model'
;
import
{
LevelModel
,
MyLevelModel
}
from
'src/app/shared/model/level.model'
;
import
{
LevelModel
,
MyLevelModel
}
from
'src/app/shared/model/level.model'
;
...
@@ -20,24 +21,52 @@ export interface DataModal {
...
@@ -20,24 +21,52 @@ export interface DataModal {
export
class
UserSettingsComponent
{
export
class
UserSettingsComponent
{
selectedFile
:
File
|
null
=
null
;
selectedFile
:
File
|
null
=
null
;
selectedFileName
:
string
=
'กรุณาเลือกไฟล์'
;
selectedFileName
:
string
=
'กรุณาเลือกไฟล์'
;
currentModal
:
'add'
|
'edit'
|
'delete'
|
'deleteGroup'
=
"add"
currentModal
:
'add'
|
'edit'
|
'delete'
=
"add"
currentPage
=
1
search
=
""
page
=
Array
.
from
({
length
:
1
},
(
_
,
i
)
=>
i
+
1
);
modal
:
DataModal
=
{
modal
:
DataModal
=
{
search
:
""
,
search
:
""
,
currentPage
:
1
,
currentPage
:
1
,
page
:
Array
.
from
({
length
:
1
},
(
_
,
i
)
=>
i
+
1
)
page
:
Array
.
from
({
length
:
1
},
(
_
,
i
)
=>
i
+
1
)
}
}
numDataListChecked
=
0
isDataListChecked
=
false
isDataListCheckedAll
=
false
companyId
=
""
companyId
=
""
user
:
{
loading
:
boolean
,
select
:
UserModel
,
dataList
:
{
check
:
boolean
,
data
:
UserModel
}
[]
}
=
{
loading
:
false
,
select
:
new
MyUserModel
(),
dataList
:
[]
}
user
:
{
loading
:
boolean
,
select
:
UserModel
,
dataList
:
UserModel
[]
}
=
{
loading
:
false
,
select
:
new
MyUserModel
(),
dataList
:
[]
}
employee
:
{
loading
:
boolean
,
select
:
EmployeeModel
,
dataList
:
{
check
:
boolean
,
data
:
EmployeeModel
}[]
}
=
{
loading
:
false
,
select
:
new
MyEmployeeModel
(),
dataList
:
[]
}
employee
:
{
loading
:
boolean
,
select
:
EmployeeModel
,
dataList
:
{
check
:
boolean
,
data
:
EmployeeModel
}[]
}
=
{
loading
:
false
,
select
:
new
MyEmployeeModel
(),
dataList
:
[]
}
role
:
{
loading
:
boolean
,
select
:
RoleModel
,
dataList
:
{
check
:
boolean
,
data
:
RoleModel
}[]
}
=
{
loading
:
false
,
select
:
new
MyRoleModel
(),
dataList
:
[]
}
role
:
{
loading
:
boolean
,
select
:
RoleModel
,
dataList
:
{
check
:
boolean
,
data
:
RoleModel
}[]
}
=
{
loading
:
false
,
select
:
new
MyRoleModel
(),
dataList
:
[]
}
level
:
{
loading
:
boolean
,
select
:
LevelModel
,
dataList
:
{
check
:
boolean
,
data
:
LevelModel
}[]
}
=
{
loading
:
false
,
select
:
new
MyLevelModel
(),
dataList
:
[]
}
level
:
{
loading
:
boolean
,
select
:
LevelModel
,
dataList
:
{
check
:
boolean
,
data
:
LevelModel
}[]
}
=
{
loading
:
false
,
select
:
new
MyLevelModel
(),
dataList
:
[]
}
search
=
""
columns
:
ColumnModel
[]
=
[{
field
:
"usernameId"
,
headerText
:
"ชื่อล็อกอิน"
,
type
:
"string"
,
isPrimaryKey
:
true
,
},
{
field
:
"empId"
,
headerText
:
"รหัสพนักงาน"
,
type
:
"string"
},
{
field
:
"employee.fname"
,
headerText
:
"ชื่อ"
,
type
:
"string"
},
{
field
:
"employee.lname"
,
headerText
:
"นามสกุล"
,
type
:
"string"
},
{
field
:
"status"
,
headerText
:
"สถานะ"
,
type
:
"string"
}]
searchSettings
=
{
fields
:
[
'usernameId'
,
'empId'
,
'fname'
,
'lname'
,
'status'
],
operator
:
'contains'
,
ignoreCase
:
false
}
selectedItems
:
{
key
:
string
,
count
:
number
,
data
:
Map
<
string
,
boolean
>
}
=
{
key
:
''
,
count
:
0
,
data
:
new
Map
<
string
,
boolean
>
()
};
constructor
(
private
toastr
:
ToastrService
,
constructor
(
private
toastr
:
ToastrService
,
private
cdr
:
ChangeDetectorRef
,
private
cdr
:
ChangeDetectorRef
,
private
userService
:
UserService
,
private
userService
:
UserService
,
...
@@ -66,7 +95,6 @@ export class UserSettingsComponent {
...
@@ -66,7 +95,6 @@ export class UserSettingsComponent {
next
:
response
=>
{
next
:
response
=>
{
this
.
level
.
dataList
=
response
.
map
(
x
=>
({
check
:
false
,
data
:
new
MyLevelModel
(
x
)
}))
this
.
level
.
dataList
=
response
.
map
(
x
=>
({
check
:
false
,
data
:
new
MyLevelModel
(
x
)
}))
this
.
level
.
loading
=
false
this
.
level
.
loading
=
false
this
.
searchChange
()
this
.
cdr
.
detectChanges
()
this
.
cdr
.
detectChanges
()
},
error
:
error
=>
{
},
error
:
error
=>
{
this
.
level
.
loading
=
false
this
.
level
.
loading
=
false
...
@@ -92,7 +120,6 @@ export class UserSettingsComponent {
...
@@ -92,7 +120,6 @@ export class UserSettingsComponent {
next
:
response
=>
{
next
:
response
=>
{
this
.
role
.
dataList
=
response
.
map
(
x
=>
({
check
:
false
,
data
:
new
MyRoleModel
(
x
)
}))
this
.
role
.
dataList
=
response
.
map
(
x
=>
({
check
:
false
,
data
:
new
MyRoleModel
(
x
)
}))
this
.
role
.
loading
=
false
this
.
role
.
loading
=
false
this
.
searchChange
()
this
.
cdr
.
detectChanges
()
this
.
cdr
.
detectChanges
()
},
error
:
error
=>
{
},
error
:
error
=>
{
this
.
role
.
loading
=
false
this
.
role
.
loading
=
false
...
@@ -118,7 +145,6 @@ export class UserSettingsComponent {
...
@@ -118,7 +145,6 @@ export class UserSettingsComponent {
next
:
response
=>
{
next
:
response
=>
{
this
.
employee
.
dataList
=
response
.
map
(
x
=>
({
check
:
false
,
data
:
new
MyEmployeeModel
(
x
)
}))
this
.
employee
.
dataList
=
response
.
map
(
x
=>
({
check
:
false
,
data
:
new
MyEmployeeModel
(
x
)
}))
this
.
employee
.
loading
=
false
this
.
employee
.
loading
=
false
this
.
searchChange
()
this
.
cdr
.
detectChanges
()
this
.
cdr
.
detectChanges
()
},
error
:
error
=>
{
},
error
:
error
=>
{
this
.
employee
.
loading
=
false
this
.
employee
.
loading
=
false
...
@@ -142,11 +168,13 @@ export class UserSettingsComponent {
...
@@ -142,11 +168,13 @@ export class UserSettingsComponent {
this
.
user
.
loading
=
true
this
.
user
.
loading
=
true
this
.
userService
.
getList
().
subscribe
({
this
.
userService
.
getList
().
subscribe
({
next
:
response
=>
{
next
:
response
=>
{
this
.
user
.
dataList
=
response
.
map
(
x
=>
({
check
:
false
,
data
:
new
MyUserModel
(
x
)
}))
this
.
user
.
dataList
=
response
.
map
(
x
=>
{
this
.
isDataListCheckedAll
=
false
this
.
selectedItems
.
data
.
set
(
x
.
usernameId
,
false
)
this
.
dataListCheckAll
()
return
new
MyUserModel
({
...
x
,
status
:
x
.
status
==
'1'
?
'ใช้งาน'
:
'ไม่ใช้งาน'
})
})
this
.
selectedItems
.
key
=
'usernameId'
this
.
selectedItems
.
count
=
0
this
.
user
.
loading
=
false
this
.
user
.
loading
=
false
this
.
searchChange
()
this
.
cdr
.
detectChanges
()
this
.
cdr
.
detectChanges
()
},
error
:
error
=>
{
},
error
:
error
=>
{
this
.
user
.
loading
=
false
this
.
user
.
loading
=
false
...
@@ -154,17 +182,21 @@ export class UserSettingsComponent {
...
@@ -154,17 +182,21 @@ export class UserSettingsComponent {
}
}
})
})
}
}
userListFilter
()
{
return
this
.
user
.
dataList
.
filter
(
x
=>
{
searchModalChange
(
dataList
:
any
[])
{
const
data
=
x
.
data
this
.
modal
.
currentPage
=
1
const
match
=
data
.
usernameId
.
toLowerCase
().
includes
(
this
.
search
.
toLowerCase
())
||
this
.
modal
.
page
=
Array
.
from
({
length
:
Math
.
ceil
(
dataList
.
length
/
10
)
},
(
_
,
i
)
=>
i
+
1
);
data
.
empId
.
toLowerCase
().
includes
(
this
.
search
.
toLowerCase
())
||
this
.
cdr
.
markForCheck
()
data
.
employee
.
thFullName
.
toLowerCase
().
includes
(
this
.
search
.
toLowerCase
())
return
match
})
}
}
selectUser
(
data
?:
UserModel
)
{
selectUser
(
data
?:
UserModel
)
{
this
.
user
.
select
=
new
MyUserModel
({
...
data
,
companyId
:
data
?.
companyId
||
this
.
companyId
,
status
:
data
?.
status
||
'0'
})
if
(
data
)
{
this
.
user
.
select
=
new
MyUserModel
({
...
data
,
companyId
:
data
?.
companyId
||
this
.
companyId
,
status
:
data
.
status
==
'ใช้งาน'
?
'1'
:
'0'
})
}
else
if
(
this
.
currentModal
==
'add'
)
{
this
.
user
.
select
=
new
MyUserModel
({
companyId
:
this
.
companyId
,
status
:
'0'
})
}
else
if
(
this
.
currentModal
==
'edit'
)
{
this
.
user
.
select
=
new
MyUserModel
({
usernameId
:
this
.
user
.
select
.
usernameId
,
companyId
:
this
.
companyId
,
status
:
'0'
})
}
}
}
onFileSelected
(
event
:
any
)
{
onFileSelected
(
event
:
any
)
{
this
.
selectedFile
=
event
.
target
.
files
.
length
>
0
?
event
.
target
.
files
[
0
]
:
null
;
this
.
selectedFile
=
event
.
target
.
files
.
length
>
0
?
event
.
target
.
files
[
0
]
:
null
;
...
@@ -239,11 +271,8 @@ export class UserSettingsComponent {
...
@@ -239,11 +271,8 @@ export class UserSettingsComponent {
let
body
:
UserModel
|
UserModel
[]
let
body
:
UserModel
|
UserModel
[]
switch
(
this
.
currentModal
)
{
switch
(
this
.
currentModal
)
{
case
(
'delete'
):
{
case
(
'delete'
):
{
body
=
[
new
MyUserModel
(
this
.
user
.
select
)]
const
selectedKeys
=
Array
.
from
(
this
.
selectedItems
.
data
.
keys
());
break
;
body
=
this
.
user
.
dataList
.
filter
(
x
=>
selectedKeys
.
includes
(
x
.
usernameId
)
&&
this
.
selectedItems
.
data
.
get
(
x
.
usernameId
)).
map
(
x
=>
new
MyUserModel
({
...
x
,
status
:
x
.
status
==
'ใช้งาน'
?
'1'
:
'0'
}))
}
case
(
'deleteGroup'
):
{
body
=
this
.
user
.
dataList
.
filter
(
x
=>
x
.
check
).
map
(
x
=>
new
MyUserModel
(
x
.
data
))
break
;
break
;
}
}
default
:
{
default
:
{
...
@@ -255,7 +284,6 @@ export class UserSettingsComponent {
...
@@ -255,7 +284,6 @@ export class UserSettingsComponent {
if
(
response
.
success
)
{
if
(
response
.
success
)
{
this
.
showAlert
(
response
.
message
,
'success'
)
this
.
showAlert
(
response
.
message
,
'success'
)
this
.
getUserList
()
this
.
getUserList
()
this
.
searchChange
()
}
else
{
}
else
{
this
.
showAlert
(
response
.
message
,
'error'
)
this
.
showAlert
(
response
.
message
,
'error'
)
this
.
user
.
loading
=
false
this
.
user
.
loading
=
false
...
@@ -268,16 +296,7 @@ export class UserSettingsComponent {
...
@@ -268,16 +296,7 @@ export class UserSettingsComponent {
}
}
})
})
}
}
searchChange
()
{
this
.
currentPage
=
1
this
.
page
=
Array
.
from
({
length
:
Math
.
ceil
(
this
.
userListFilter
().
length
/
10
)
},
(
_
,
i
)
=>
i
+
1
);
this
.
dataListCheck
()
}
searchModalChange
(
dataList
:
any
[])
{
this
.
modal
.
currentPage
=
1
this
.
modal
.
page
=
Array
.
from
({
length
:
Math
.
ceil
(
dataList
.
length
/
10
)
},
(
_
,
i
)
=>
i
+
1
);
this
.
cdr
.
markForCheck
()
}
selectDataModal
(
target
:
{
[
key
:
string
]:
any
},
field
:
string
,
data
:
any
)
{
selectDataModal
(
target
:
{
[
key
:
string
]:
any
},
field
:
string
,
data
:
any
)
{
target
[
field
]
=
JSON
.
parse
(
JSON
.
stringify
(
data
))
target
[
field
]
=
JSON
.
parse
(
JSON
.
stringify
(
data
))
}
}
...
@@ -298,26 +317,18 @@ export class UserSettingsComponent {
...
@@ -298,26 +317,18 @@ export class UserSettingsComponent {
})
})
}
}
dataListCheckAll
()
{
const
selectAll
=
this
.
isDataListCheckedAll
;
checkPrimary
()
{
this
.
user
.
dataList
.
filter
(
x
=>
{
return
this
.
user
.
dataList
.
find
(
x
=>
x
.
usernameId
==
this
.
user
.
select
.
usernameId
)
const
data
=
x
.
data
const
match
=
data
.
usernameId
.
toLowerCase
().
includes
(
this
.
search
.
toLowerCase
())
||
data
.
empId
.
toLowerCase
().
includes
(
this
.
search
.
toLowerCase
())
||
data
.
employee
.
thFullName
.
toLowerCase
().
includes
(
this
.
search
.
toLowerCase
())
return
match
}).
forEach
(
x
=>
x
.
check
=
selectAll
);
this
.
dataListCheck
();
}
}
dataListCheck
()
{
numSelectItem
()
{
const
dataCheck
=
this
.
userListFilter
();
const
selectedKeys
=
Array
.
from
(
this
.
selectedItems
.
data
.
keys
());
this
.
isDataListCheckedAll
=
dataCheck
.
length
?
dataCheck
.
every
(
x
=>
x
.
check
)
:
false
;
const
num
=
this
.
user
.
dataList
.
filter
(
x
=>
selectedKeys
.
includes
(
x
.
usernameId
)
&&
this
.
selectedItems
.
data
.
get
(
x
.
usernameId
)).
length
this
.
numDataListChecked
=
this
.
user
.
dataList
.
filter
(
x
=>
x
.
check
).
length
;
return
num
this
.
isDataListChecked
=
Boolean
(
this
.
numDataListChecked
)
}
}
checkPrimary
(
)
{
onSelectItemChange
(
arg
:
any
)
{
return
this
.
user
.
dataList
.
find
(
x
=>
x
.
data
.
usernameId
==
this
.
user
.
select
.
usernameId
)
this
.
selectedItems
=
arg
}
}
}
}
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