Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
BookingMyHrManagement
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
Chanachai
BookingMyHrManagement
Commits
4ace00cf
Commit
4ace00cf
authored
Mar 17, 2025
by
DESKTOP-E0VCCBD\zedan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
b990c132
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
1151 additions
and
8 deletions
+1151
-8
admin-project-emp-manage.component.html
...roject-emp-manage/admin-project-emp-manage.component.html
+309
-1
admin-project-emp-manage.component.ts
...-project-emp-manage/admin-project-emp-manage.component.ts
+297
-3
admin-project-equirement.component.html
...roject-equirement/admin-project-equirement.component.html
+280
-1
admin-project-equirement.component.ts
...-project-equirement/admin-project-equirement.component.ts
+265
-3
No files found.
Web-Manage/src/app/DPU/company-management/admin-project-emp-manage/admin-project-emp-manage.component.html
View file @
4ace00cf
<p>
admin-project-emp-manage works!
</p>
<app-page-header
[
title
]="'จัดการสมาชิก'"
[
activeTitle
]="'ผู้ดูแลระบบ'"
[
title1
]="'จัดการสมาชิก'"
></app-page-header>
<div
class=
"grid grid-cols-12 gap-6"
>
<div
class=
"xl:col-span-12 col-span-12"
>
<div
class=
"box"
>
<div
class=
"box-header justify-between"
>
<div
class=
"box-title"
>
{{ 'All List' | translate}}
<span
class=
"badge bg-light text-default rounded-full ms-1 text-[0.75rem] align-middle"
>
{{itemsList.length}}
</span>
</div>
<div
class=
"flex flex-wrap gap-2"
>
<a
href=
"javascript:void(0);"
class=
"hs-dropdown-toggle ti-btn ti-btn-primary-full me-2"
(
click
)="
new
()"
data-hs-overlay=
"#modal-detail"
><i
class=
"ri-add-line font-semibold align-middle"
></i>
{{ 'Create' |
translate}}
</a>
<a
href=
"javascript:void(0);"
class=
"hs-dropdown-toggle ti-btn ti-btn-success-full me-2"
*
ngIf=
"someSelected"
(
click
)="
adjustSelect
(
1
)"
><i
class=
"ri-user-follow-line font-semibold align-middle"
></i>
{{ 'Active' |
translate}}
</a>
<a
href=
"javascript:void(0);"
class=
"hs-dropdown-toggle ti-btn ti-btn-secondary-full me-2"
*
ngIf=
"someSelected"
(
click
)="
adjustSelect
(
0
)"
><i
class=
"ri-user-unfollow-line font-semibold align-middle"
></i>
{{ 'Unactive' |
translate}}
</a>
<a
href=
"javascript:void(0);"
class=
"hs-dropdown-toggle ti-btn ti-btn-danger-full me-2"
*
ngIf=
"someSelected"
(
click
)="
deleteSelect
()"
><i
class=
"ri-delete-bin-line font-semibold align-middle"
></i>
{{ 'Delete' |
translate}}
</a>
<div>
<input
class=
"form-control form-control"
type=
"text"
placeholder=
"ค้นหาสมาชิก"
aria-label=
".form-control-sm example"
[(
ngModel
)]='
searchTerm
'
>
</div>
<!-- <div>
<input class="form-control form-control" type="text" placeholder="กรองตามบริษัท"
aria-label=".form-control-sm example" [(ngModel)]='searchTerm'>
</div> -->
<!-- <a href="javascript:void(0);" class="ti-btn ti-btn-primary-full !py-1 !px-2" aria-expanded="false">
เรียงตาม<i class="ri-arrow-down-s-line align-middle ms-1 inline-block"></i>
</a>
<ul class="hs-dropdown-menu ti-dropdown-menu hidden" role="menu">
<li><a class="ti-dropdown-item" href="javascript:void(0);">Newest</a></li>
<li><a class="ti-dropdown-item" href="javascript:void(0);">Oldest</a></li>
</ul> -->
</div>
</div>
<div
class=
"box-body"
>
<div
class=
"table-responsive"
>
<table
class=
"table whitespace-nowrap min-w-full ti-custom-table-hover"
>
<thead>
<tr
class=
"border-b border-defaultborder"
>
<th
scope=
"col"
class=
"!text-start"
>
<input
class=
"form-check-input check-all"
type=
"checkbox"
id=
"all-products"
(
change
)="
toggleAll
($
event
)"
[
checked
]="
allSelected
"
aria-label=
"..."
>
</th>
<th
scope=
"col"
class=
"text-start"
>
{{ 'Username' | translate}}
</th>
<th
scope=
"col"
class=
"text-start"
>
{{ 'Fullname' | translate}}
</th>
<th
scope=
"col"
class=
"text-start"
>
{{ 'Email' | translate}}
</th>
<th
scope=
"col"
class=
"text-start"
>
{{ 'Mobile' | translate}}
</th>
<th
scope=
"col"
class=
"text-start"
>
{{ 'User Group' | translate}}
</th>
<th
scope=
"col"
class=
"text-start"
>
{{ 'Status' | translate}}
</th>
<th
scope=
"col"
class=
"text-start"
>
{{ 'Update Date' | translate}}
</th>
<th
scope=
"col"
class=
"text-start"
></th>
</tr>
</thead>
<tbody>
@for(item of filterList;track filterList){
<tr
class=
"border border-defaultborder dark:border-defaultborder/10"
>
<td
class=
"product-checkbox"
><input
class=
"form-check-input"
type=
"checkbox"
[
checked
]="
selectedItems
.
get
(
item
.
memberId
)"
(
change
)="
onCheckboxChange
(
item
.
memberId
)"
aria-label=
"..."
value=
""
>
</td>
<td>
<div
class=
"flex items-center"
>
<span
class=
"avatar avatar-sm p-1 me-1 bg-light !rounded-full"
>
<img
[
src
]="
item
.
getPicture
()"
alt=
""
id=
"profile-img"
>
</span>
<div
class=
"ms-2"
>
<p
class=
"font-semibold mb-0 flex items-center text-primary"
><a
(
click
)="
view
(
item
)"
>
{{item.username}}
</a></p>
<p
class=
"text-[0.75rem] text-muted mb-0"
>
{{item.memberId}}
</p>
</div>
</div>
</td>
<!-- <td>
<div class="flex">
<div class="ms-2">
<p class="font-semibold mb-0 flex items-center text-primary"><a (click)="view(item)"
data-hs-overlay="#modal-detail">
{{item.username}}</a></p>
<p class="text-[0.75rem] text-muted mb-0">{{item.memberId}}</p>
</div>
</div>
</td> -->
<td>
{{item.firstName}} {{item.lastName}}
</td>
<td>
<div>
<span
class=
"block mb-1"
><i
class=
"ri-mail-line me-2 align-middle text-[.875rem] text-[#8c9097] dark:text-white/50 inline-flex"
></i>
{{item.email}}
</span>
</div>
</td>
<td>
<div>
<span
class=
"block"
><i
class=
"ri-phone-line me-2 align-middle text-[.875rem] text-[#8c9097] dark:text-white/50 inline-flex"
></i>
{{item.phoneNumber}}
</span>
</div>
</td>
<td>
<span
class=
"badge bg-{{ item.role == 1 ? 'primary' : 'info'}} text-white"
>
{{item.getRole()}}
</span>
</td>
<td>
<span
class=
"badge bg-{{ item.status == 1 ? 'primary' : 'danger'}} text-white"
>
{{item.getStatus()}}
</span>
</td>
<td><span
class=
"badge bg-info/10 text-primary"
><i
class=
"bi bi-clock me-1"
></i>
{{item.updatedAt | date : 'medium'}}
</span></td>
<td>
<td>
<div
class=
"flex flex-row items-center !gap-2 "
>
<a
aria-label=
"anchor"
(
click
)="
view
(
item
)"
data-hs-overlay=
"#modal-detail"
class=
"ti-btn ti-btn-wave !gap-0 !m-0 bg-info/10 text-info hover:bg-info hover:text-white hover:border-info"
><i
class=
"ri-pencil-line"
></i></a>
<a
aria-label=
"anchor"
href=
"javascript:void(0);"
(
click
)="
delete
(
item
)"
class=
"ti-btn ti-btn-wave product-btn !gap-0 !m-0 bg-danger/10 text-danger hover:bg-danger hover:text-white hover:border-danger"
><i
class=
"ri-delete-bin-line"
></i></a>
</div>
</td>
</tr>
}
</tbody>
</table>
</div>
</div>
<div
class=
"box-footer"
>
<div
class=
"flex items-center flex-wrap overflow-auto"
*
ngIf=
"filterList.length > 0"
>
<div
class=
"mb-2 sm:mb-0"
>
<div>
{{'Showing' | translate}} {{filterList.length}} {{'entries'
| translate}}
<i
class=
"bi bi-arrow-right ms-2 font-semibold"
></i>
</div>
</div>
<div
class=
"ms-auto"
>
<nav
aria-label=
"Page navigation"
>
<ul
class=
"ti-pagination mb-0"
>
<li
*
ngIf=
"pageIndex>0"
class=
"page-item {{pageIndex==0 ? 'disabled' : ''}}"
><a
class=
"page-link px-3 py-[0.375rem]"
(
click
)="
pageIndex =
pageIndex-1;updatePagedItems()"
>
{{'Previous' | translate}}
</a></li>
<li
class=
"page-item"
><a
class=
"page-link px-3 py-[0.375rem]"
href=
"javascript:void(0);"
*
ngIf=
"pageIndex-1>0"
(
click
)="
pageIndex =
pageIndex-2;updatePagedItems()"
>
{{pageIndex-1}}
</a></li>
<li
class=
"page-item"
><a
class=
"page-link px-3 py-[0.375rem]"
href=
"javascript:void(0);"
*
ngIf=
"pageIndex>0 && ((pageIndex-1)*10 < (searchTerm == '' ? itemsList.length : filterList.length))"
(
click
)="
pageIndex =
pageIndex-1;updatePagedItems()"
>
{{pageIndex}}
</a></li>
<li
class=
"page-item"
><a
class=
"page-link active px-3 py-[0.375rem]"
href=
"javascript:void(0);"
>
{{pageIndex +1}}
</a>
</li>
<li
class=
"page-item"
><a
class=
"page-link px-3 py-[0.375rem]"
href=
"javascript:void(0);"
*
ngIf=
"(pageIndex+1)*10 < (searchTerm == '' ? itemsList.length : filterList.length)"
(
click
)="
pageIndex =
pageIndex+1;updatePagedItems()"
>
{{pageIndex +2}}
</a></li>
<li
class=
"page-item"
><a
class=
"page-link px-3 py-[0.375rem]"
href=
"javascript:void(0);"
*
ngIf=
"(pageIndex+2)*10 < (searchTerm == '' ? itemsList.length : filterList.length)"
(
click
)="
pageIndex =
pageIndex+2;updatePagedItems()"
>
{{pageIndex +3}}
</a></li>
<li
*
ngIf=
"(pageIndex+1)*10 < (searchTerm == '' ? itemsList.length : filterList.length)"
class=
"page-item"
><a
class=
"page-link px-3 py-[0.375rem]"
(
click
)="
pageIndex =
pageIndex+1;updatePagedItems()"
>
{{'Next' |
translate}}
</a>
</li>
</ul>
</nav>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Start:: Create Contact -->
<div
id=
"modal-detail"
class=
"hs-overlay hidden ti-modal [--overlay-backdrop:static]"
>
<div
class=
"hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out"
>
<div
class=
"ti-modal-content"
>
<div
class=
"ti-modal-header"
>
<h6
class=
"modal-title text-[1rem] font-semibold text-defaulttextcolor"
id=
"mail-ComposeLabel"
>
{{ 'Create' |
translate }} {{ 'User' | translate }}
</h6>
<button
type=
"button"
class=
"hs-dropdown-toggle !text-[1rem] !font-semibold !text-defaulttextcolor"
data-hs-overlay=
"#modal-detail"
#
closeModal
>
<span
class=
"sr-only"
>
{{'Close' | translate}}
</span>
<i
class=
"ri-close-line"
></i>
</button>
</div>
<div
class=
"ti-modal-body px-4"
>
<div
class=
"grid grid-cols-12 gap-4"
>
<div
class=
"xl:col-span-12 col-span-12"
>
<div
class=
"mb-0 text-center"
>
<span
class=
"avatar avatar-xxl avatar-rounded"
>
<img
[
src
]="
selectModel
.
getPicture
()"
alt=
""
id=
"profile-img"
>
<span
class=
"badge rounded-full bg-primary avatar-badge"
>
<input
ng2FileSelect
[
uploader
]="
uploaderProfile
"
type=
"file"
name=
"photo"
class=
"absolute w-full h-full opacity-[0]"
id=
"profile-change"
>
<i
class=
"fe fe-camera text-[.625rem]"
></i>
</span>
</span>
</div>
</div>
<div
class=
"xl:col-span-12 col-span-12"
>
<label
for=
"deal-title"
class=
"form-label"
>
{{'Username' | translate}}
</label>
<input
type=
"text"
class=
"form-control"
id=
"deal-title"
placeholder=
""
[(
ngModel
)]="
selectModel
.
username
"
>
<div
class=
"text-danger"
*
ngIf=
"!selectModel.username"
>
{{'Please fill in information' | translate}}
</div>
</div>
<div
class=
"xl:col-span-12 col-span-12"
>
<label
for=
"deal-title"
class=
"form-label"
>
{{'Password' | translate}}
</label>
<input
type=
"password"
class=
"form-control"
id=
"deal-title"
placeholder=
""
[(
ngModel
)]="
selectModel
.
password
"
>
<div
class=
"text-danger"
*
ngIf=
"!selectModel.password"
>
{{'Please fill in information' | translate}}
</div>
</div>
<div
class=
"xl:col-span-12 col-span-12"
>
<label
for=
"deal-title"
class=
"form-label"
>
{{'Confirm Password' | translate}}
</label>
<input
type=
"password"
class=
"form-control"
id=
"deal-title"
placeholder=
""
[(
ngModel
)]="
confirmPassword
"
>
<div
class=
"text-danger"
*
ngIf=
"!confirmPassword"
>
{{'Please fill in information' | translate}}
</div>
<div
class=
"text-danger"
*
ngIf=
"confirmPassword && (confirmPassword != selectModel.password)"
>
{{'Password Not Match' | translate}}
</div>
</div>
<div
class=
"xl:col-span-6 col-span-12"
>
<label
for=
"deal-title"
class=
"form-label"
>
{{'ชื่อ' | translate}}
</label>
<input
type=
"text"
class=
"form-control"
id=
"deal-title"
placeholder=
""
[(
ngModel
)]="
selectModel
.
firstName
"
>
<div
class=
"text-danger"
*
ngIf=
"!selectModel.firstName"
>
{{'Please fill in information' | translate}}
</div>
</div>
<div
class=
"xl:col-span-6 col-span-12"
>
<label
for=
"deal-title"
class=
"form-label"
>
{{'นามสกุล' | translate}}
</label>
<input
type=
"text"
class=
"form-control"
id=
"deal-title"
placeholder=
""
[(
ngModel
)]="
selectModel
.
lastName
"
>
<div
class=
"text-danger"
*
ngIf=
"!selectModel.lastName"
>
{{'Please fill in information' | translate}}
</div>
</div>
<div
class=
"xl:col-span-6 col-span-12"
>
<label
for=
"deal-title"
class=
"form-label"
>
{{'อีเมล' | translate}}
</label>
<input
type=
"text"
class=
"form-control"
id=
"deal-title"
placeholder=
""
[(
ngModel
)]="
selectModel
.
email
"
>
<div
class=
"text-danger"
*
ngIf=
"!selectModel.email"
>
{{'Please fill in information' | translate}}
</div>
</div>
<div
class=
"xl:col-span-6 col-span-12"
>
<label
for=
"deal-title"
class=
"form-label"
>
{{'เบอร์ติดต่อ' | translate}}
</label>
<input
type=
"text"
class=
"form-control"
id=
"deal-title"
placeholder=
""
[(
ngModel
)]="
selectModel
.
phoneNumber
"
>
<div
class=
"text-danger"
*
ngIf=
"!selectModel.phoneNumber"
>
{{'Please fill in information' | translate}}
</div>
</div>
<div
class=
"xl:col-span-12 col-span-12"
>
<label
class=
"form-label"
>
{{'User Role' | translate}}
</label>
<ng-select
name=
"choices-multiple-remove-button1"
id=
"choices-multiple-remove-button1"
placeholder=
""
[(
ngModel
)]="
selectModel
.
role
"
>
<ng-option
[
value
]="
0
"
>
{{'ผู้ใช้งานทั่วไป' | translate}}
</ng-option>
<ng-option
[
value
]="
1
"
>
{{'ผู้ดูแลบริษัท' | translate}}
</ng-option>
</ng-select>
</div>
<div
class=
"xl:col-span-12 col-span-12"
>
<label
class=
"form-label"
>
{{'Status' | translate}}
</label>
<ng-select
name=
"choices-multiple-remove-button2"
id=
"choices-multiple-remove-button2"
placeholder=
""
[(
ngModel
)]="
selectModel
.
status
"
>
<ng-option
[
value
]="
0
"
>
{{'Unactive' | translate}}
</ng-option>
<ng-option
[
value
]="
1
"
>
{{'Active' | translate}}
</ng-option>
</ng-select>
</div>
</div>
</div>
<div
class=
"ti-modal-footer"
>
<button
type=
"button"
class=
"hs-dropdown-toggle ti-btn ti-btn-light align-middle"
data-hs-overlay=
"#modal-detail"
>
{{'Cancel' | translate}}
</button>
<button
type=
"button"
(
click
)="
save
()"
class=
"ti-btn bg-primary text-white !font-medium"
>
{{'Save' |
translate}}
</button>
</div>
</div>
</div>
</div>
<!-- End:: Create Contact -->
Web-Manage/src/app/DPU/company-management/admin-project-emp-manage/admin-project-emp-manage.component.ts
View file @
4ace00cf
import
{
Component
}
from
'@angular/core'
;
import
{
CommonModule
}
from
"@angular/common"
;
import
{
ChangeDetectionStrategy
,
Component
,
ElementRef
,
ViewChild
}
from
'@angular/core'
;
import
{
NgSelectModule
}
from
"@ng-select/ng-select"
;
import
{
TranslateModule
,
TranslateService
}
from
"@ngx-translate/core"
;
import
{
SharedModule
}
from
"../../../shared/shared.module"
;
import
{
UserService
}
from
"../../services/user.service"
;
import
{
UserProfileModel
}
from
"../../models/user.model"
;
import
{
FormsModule
}
from
"@angular/forms"
;
import
swal
from
'sweetalert'
;
import
{
MatPaginator
,
PageEvent
}
from
"@angular/material/paginator"
;
import
{
UserRoleModel
}
from
"../../models/user-role-model"
;
import
{
FileUploadModule
}
from
'ng2-file-upload'
;
import
{
FileItem
,
FileUploader
,
ParsedResponseHeaders
}
from
"ng2-file-upload"
;
import
{
environment
}
from
"../../../../environments/environment"
;
import
{
TokenService
}
from
"../../../shared/services/token.service"
;
import
{
ProjectMemberModel
}
from
"../../models/project-members"
;
@
Component
({
@
Component
({
selector
:
'app-admin-project-emp-manage'
,
selector
:
'app-admin-project-emp-manage'
,
standalone
:
true
,
standalone
:
true
,
imports
:
[],
imports
:
[
CommonModule
,
SharedModule
,
TranslateModule
,
NgSelectModule
,
FormsModule
,
MatPaginator
,
FileUploadModule
],
templateUrl
:
'./admin-project-emp-manage.component.html'
,
templateUrl
:
'./admin-project-emp-manage.component.html'
,
styleUrl
:
'./admin-project-emp-manage.component.scss'
styleUrl
:
'./admin-project-emp-manage.component.scss'
})
})
export
class
AdminProjectEmpManageComponent
{
export
class
AdminProjectEmpManageComponent
{
@
ViewChild
(
'closeModal'
)
public
childModal
?:
ElementRef
;
@
ViewChild
(
'modalDetail'
)
public
modalDetail
?:
ElementRef
;
action
=
"new"
;
allSelected
=
false
;
someSelected
=
false
;
confirmPassword
=
""
itemsList
:
ProjectMemberModel
[]
=
[]
filterList
:
ProjectMemberModel
[]
=
[]
selectModel
:
ProjectMemberModel
=
new
ProjectMemberModel
()
selectedItems
=
new
Map
<
string
,
boolean
>
();
roleList
:
UserRoleModel
[]
=
[]
empList
:
ProjectMemberModel
[]
=
[]
descName
=
'engName'
pageIndex
=
0
;
uploaderProfile
:
FileUploader
|
undefined
;
uploadErrorMsg
:
string
=
""
;
get
searchTerm
():
string
{
return
this
.
_searchTerm
;
}
set
searchTerm
(
val
:
string
)
{
this
.
pageIndex
=
0
;
this
.
allSelected
=
false
this
.
_searchTerm
=
val
;
if
(
val
!=
''
)
{
this
.
filterList
=
this
.
filter
(
val
);
}
else
{
this
.
updatePagedItems
()
}
}
_searchTerm
=
""
;
constructor
(
private
UserService
:
UserService
,
public
translate
:
TranslateService
,
private
tokenService
:
TokenService
)
{
this
.
uploadConfig
()
}
uploadConfig
()
{
this
.
uploaderProfile
=
new
FileUploader
({
url
:
environment
.
baseUrl
+
"/api/upload-image"
,
isHTML5
:
true
,
authToken
:
this
.
tokenService
.
getToken
()
!
,
});
this
.
uploaderProfile
.
onAfterAddingFile
=
(
fileItem
:
FileItem
)
=>
{
fileItem
.
withCredentials
=
false
;
this
.
uploadErrorMsg
=
""
;
while
(
this
.
uploaderProfile
!
.
queue
.
length
>
1
)
{
this
.
uploaderProfile
!
.
queue
[
0
].
remove
();
}
if
(
fileItem
.
file
.
size
>
5000000
)
{
this
.
uploadErrorMsg
=
"maximum file size 5mb."
;
swal
(
"Opp!!"
,
"ไม่สามารถอัพโหลดได้"
,
"info"
);
fileItem
.
isCancel
=
true
;
return
;
}
if
(
fileItem
.
file
.
type
!
.
indexOf
(
"image"
)
===
-
1
)
{
this
.
uploadErrorMsg
=
"please upload image only."
;
swal
(
"Opp!!"
,
"ไม่สามารถอัพโหลดได้"
,
"info"
);
fileItem
.
isCancel
=
true
;
return
;
}
fileItem
.
upload
();
};
this
.
uploaderProfile
.
onCompleteItem
=
(
item
:
FileItem
,
response
:
string
,
status
:
number
,
headers
:
ParsedResponseHeaders
)
=>
{
if
(
item
.
isSuccess
)
{
const
res
=
JSON
.
parse
(
response
);
console
.
log
(
"res"
,
res
);
this
.
selectModel
.
picture
=
res
.
filename
swal
(
res
.
message
,
"บันทึกสำเร็จ"
,
"success"
);
}
else
{
this
.
uploadErrorMsg
=
"cannot upload file."
;
swal
(
"Opp!!"
,
"ไม่สามารถอัพโหลดได้"
,
"info"
);
}
};
}
ngOnInit
():
void
{
this
.
userService
.
getLists
().
subscribe
(
result
=>
{
this
.
itemsList
=
result
this
.
updatePagedItems
()
})
}
filter
(
v
:
string
)
{
return
this
.
itemsList
?.
filter
(
(
x
)
=>
x
.
memberId
?.
toLowerCase
().
indexOf
(
v
.
toLowerCase
())
!==
-
1
||
x
.
username
?.
toLowerCase
().
indexOf
(
v
.
toLowerCase
())
!==
-
1
||
x
.
email
?.
toLowerCase
().
indexOf
(
v
.
toLowerCase
())
!==
-
1
||
x
.
phoneNumber
?.
toLowerCase
().
indexOf
(
v
.
toLowerCase
())
!==
-
1
||
x
.
getRole
()?.
toLowerCase
().
indexOf
(
v
.
toLowerCase
())
!==
-
1
||
x
.
getStatus
()?.
toLowerCase
().
indexOf
(
v
.
toLowerCase
())
!==
-
1
||
x
.
getFullname
()?.
toLowerCase
().
indexOf
(
v
.
toLowerCase
())
!==
-
1
);
}
delete
(
item
:
UserProfileModel
)
{
swal
({
title
:
"Are you sure?"
,
text
:
"You won't be able to revert this!"
,
icon
:
"warning"
,
dangerMode
:
true
,
buttons
:
[
"Cancel"
,
"Yes,Delete it!"
],
})
.
then
((
willDelete
:
any
)
=>
{
if
(
willDelete
)
{
this
.
userService
.
delete
(
item
).
subscribe
(
result
=>
{
swal
(
"Save Success!!"
,
"บันทึกข้อมูลสำเร็จ"
,
"success"
);
this
.
ngOnInit
()
})
}
});
}
new
()
{
this
.
action
=
'add'
this
.
selectModel
=
new
UserProfileModel
()
}
view
(
item
:
UserProfileModel
)
{
this
.
action
=
'edit'
this
.
confirmPassword
=
''
this
.
selectModel
=
new
UserProfileModel
(
item
)
console
.
log
(
this
.
selectModel
)
}
save
()
{
swal
({
title
:
"Are you sure?"
,
text
:
"คุณต้องการบันทึกหรือไม่"
,
icon
:
"warning"
,
dangerMode
:
false
,
buttons
:
[
"Cancel"
,
"Confirm"
],
})
.
then
((
willDelete
:
any
)
=>
{
if
(
willDelete
)
{
if
(
this
.
action
==
'add'
)
{
this
.
userService
.
save
(
this
.
selectModel
).
subscribe
(
result
=>
{
console
.
log
(
result
)
swal
(
"Save Success!!"
,
"บันทึกข้อมูลสมาชิก"
,
"success"
);
this
.
ngOnInit
()
this
.
childModal
?.
nativeElement
.
click
()
})
}
else
if
(
this
.
action
==
'edit'
)
{
this
.
userService
.
update
(
this
.
selectModel
).
subscribe
(
result
=>
{
console
.
log
(
result
)
swal
(
"Update Success!!"
,
"บันทึกข้อมูลสมาชิก"
,
"success"
);
this
.
ngOnInit
()
this
.
childModal
?.
nativeElement
.
click
()
})
}
}
});
}
updatePagedItems
()
{
const
startIndex
=
this
.
pageIndex
*
10
;
const
endIndex
=
startIndex
+
10
;
this
.
filterList
=
this
.
itemsList
.
slice
(
startIndex
,
endIndex
);
}
toggleAll
(
event
:
any
)
{
this
.
allSelected
=
event
.
target
.
checked
;
this
.
selectedItems
.
clear
();
this
.
itemsList
.
forEach
(
item
=>
{
this
.
selectedItems
.
set
(
item
.
memberId
,
this
.
allSelected
);
});
this
.
someSelected
=
this
.
itemsList
.
some
(
item
=>
this
.
selectedItems
.
get
(
item
.
memberId
));
}
onCheckboxChange
(
memberId
:
string
)
{
const
isSelected
=
this
.
selectedItems
.
get
(
memberId
)
||
false
;
this
.
selectedItems
.
set
(
memberId
,
!
isSelected
);
this
.
allSelected
=
this
.
itemsList
.
every
(
item
=>
this
.
selectedItems
.
get
(
item
.
memberId
));
this
.
someSelected
=
this
.
itemsList
.
some
(
item
=>
this
.
selectedItems
.
get
(
item
.
memberId
));
}
deleteSelect
()
{
let
employeeInfo
=
''
;
this
.
selectedItems
.
forEach
((
isSelected
,
memberId
)
=>
{
if
(
isSelected
)
{
const
user
=
this
.
itemsList
.
find
(
user
=>
user
.
memberId
===
memberId
);
if
(
user
)
{
employeeInfo
+=
`
${
this
.
translate
.
instant
(
'Fullname'
)}
:
${
user
.
getFullname
()}
\n`
;
}
}
});
swal
({
title
:
"Are you sure?"
,
text
:
employeeInfo
,
icon
:
"warning"
,
dangerMode
:
true
,
buttons
:
[
"Cancel"
,
"Yes, Delete it!"
],
})
.
then
((
willDelete
:
any
)
=>
{
if
(
willDelete
)
{
this
.
selectedItems
.
forEach
((
isSelected
,
memberId
)
=>
{
if
(
isSelected
)
{
const
user
=
this
.
itemsList
.
find
(
user
=>
user
.
memberId
===
memberId
);
if
(
user
)
{
this
.
userService
.
delete
(
user
).
subscribe
(
result
=>
{
swal
(
"Save Success!!"
,
"บันทึกข้อมูลสำเร็จ"
,
"success"
);
this
.
ngOnInit
();
});
}
}
});
}
});
}
adjustSelect
(
status
:
number
)
{
let
title
=
"Are you sure?"
let
employeeInfo
=
''
;
// ตัวแปรสำหรับเก็บข้อมูลพนักงาน
this
.
selectedItems
.
forEach
((
isSelected
,
memberId
)
=>
{
if
(
isSelected
)
{
const
user
=
this
.
itemsList
.
find
(
user
=>
user
.
memberId
===
memberId
);
if
(
user
)
{
employeeInfo
+=
`
${
this
.
translate
.
instant
(
'Fullname'
)}
:
${
user
.
getFullname
()}
\n`
;
}
}
});
swal
({
title
:
title
,
text
:
employeeInfo
,
icon
:
"warning"
,
dangerMode
:
false
,
buttons
:
[
"Cancel"
,
"Confirm"
],
})
.
then
((
willDelete
:
any
)
=>
{
if
(
willDelete
)
{
this
.
selectedItems
.
forEach
((
isSelected
,
memberId
)
=>
{
if
(
isSelected
)
{
const
user
=
this
.
itemsList
.
find
(
user
=>
user
.
memberId
===
memberId
);
if
(
user
)
{
user
.
status
=
status
this
.
userService
.
update
(
user
).
subscribe
(
result
=>
{
swal
(
"Save Success!!"
,
"บันทึกข้อมูลสำเร็จ"
,
"success"
);
this
.
ngOnInit
();
});
}
}
});
}
});
}
filterEmp
(
empId
:
string
)
{
this
.
selectModel
=
this
.
empList
.
filter
(
e
=>
e
.
memberId
==
empId
)[
0
]
}
}
}
}
Web-Manage/src/app/DPU/company-management/admin-project-equirement/admin-project-equirement.component.html
View file @
4ace00cf
<p>
admin-project-equirement works!
</p>
<app-page-header
[
title
]="'จัดการอุปกรณ์'"
[
activeTitle
]="'ผู้ดูแลระบบ'"
[
title1
]="'จัดการอุปกรณ์'"
></app-page-header>
<div
class=
"grid grid-cols-12 gap-x-6"
>
<div
class=
"xl:col-span-12 col-span-12"
>
<div
class=
"box mt-6"
>
<div
class=
"box-header justify-between"
>
<div
class=
"box-title"
>
{{ 'All List' | translate}}
<span
class=
"badge bg-light text-default rounded-full ms-1 text-[0.75rem] align-middle"
>
{{itemsList.length}}
</span>
</div>
<div
class=
"flex flex-wrap gap-2"
>
<a
href=
"javascript:void(0);"
class=
"hs-dropdown-toggle ti-btn ti-btn-primary-full me-2"
(
click
)="
new
()"
data-hs-overlay=
"#modal-detail"
><i
class=
"ri-add-line font-semibold align-middle"
></i>
{{ 'เพิ่ม' |
translate}}
</a>
<div>
<input
[(
ngModel
)]='
searchTerm
'
class=
"form-control form-control"
type=
"text"
placeholder=
"{{ 'ค้นหาอุปกรณ์' | translate}}"
aria-label=
".form-control-sm example"
>
</div>
<!-- <a href="javascript:void(0);" class="ti-btn ti-btn-primary-full !py-1 !px-2" aria-expanded="false">
เรียงตาม<i class="ri-arrow-down-s-line align-middle ms-1 inline-block"></i>
</a>
<ul class="hs-dropdown-menu ti-dropdown-menu hidden" role="menu">
<li><a class="ti-dropdown-item" href="javascript:void(0);">Posted Date</a></li>
<li><a class="ti-dropdown-item" href="javascript:void(0);">Status</a></li>
<li><a class="ti-dropdown-item" href="javascript:void(0);">Department</a></li>
<li><a class="ti-dropdown-item" href="javascript:void(0);">Job Type</a></li>
<li><a class="ti-dropdown-item" href="javascript:void(0);">Newest</a></li>
<li><a class="ti-dropdown-item" href="javascript:void(0);">Oldest</a></li>
</ul> -->
</div>
</div>
</div>
</div>
@for(item of filterList;track filterList){
<!-- <div class="xxl:col-span-4 xl:col-span-6 lg:col-span-6 md:col-span-6 sm:col-span-12 col-span-12">
<div class="box team-member-card">
<div class="teammember-cover-image mt-1">
<span class="avatar avatar-xl avatar-rounded">
<img [src]="item.getPicture()" alt="">
</span>
</div>
<div class="box-body !p-0">
<div
class="flex flex-wrap align-item-center sm:mt-0 mt-[3rem] justify-between border-b border-dashed dark:border-defaultborder/10 p-4">
<div class="team-member-details flex-grow">
<p class="mb-0 font-semibold text-[1rem] text-truncate">
<a href="javascript:void(0);">{{item.equipmentName}}</a>
</p>
<p class="mb-0 text-[0.75rem] text-[#8c9097] dark:text-white/50 text-truncate">
{{item.description}}</p>
</div>
</div>
</div>
<div class="box-footer border-block-start-dashed dark:border-defaultborder/10 text-center">
<div class="btn-list">
<div class="btn-list">
<button type="button" aria-label="button" data-hs-overlay="#modal-detail" (click)="view(item)"
class="ti-btn ti-btn-sm ti-btn-primary me-[0.375rem]"><i class="ri-edit-line"></i></button>
<button (click)="delete(item)" type="button" aria-label="button"
class="ti-btn ti-btn-sm ti-btn-danger me-0"><i class="ri-delete-bin-line"></i></button>
</div>
</div>
</div>
</div>
</div> -->
<div
class=
"xxl:col-span-2 xl:col-span-3 lg:col-span-4 md:col-span-4 sm:col-span-6 col-span-12"
>
<div
class=
"box custom-box"
>
<img
[
src
]="
item
.
getPicture
()"
class=
"!rounded-t-md"
alt=
"..."
style=
"width: 100%;height: 200px;object-fit: cover;"
>
<div
class=
"flex items-center justify-between nft-like-section w-full px-4"
>
<!-- <div class="flex-grow">
<button type="button" aria-label="button"
class="ti-btn ti-btn-sm ti-btn-success-full !rounded-full btn-wave waves-effect waves-light">
<i class="ri-heart-fill"></i>
</button>
</div>
<div>
<span class="badge nft-like-badge text-white"><i
class="ri-heart-fill me-1 text-danger align-middle inline-block"></i>0.47k</span>
</div> -->
</div>
<div
class=
"box-body"
>
<div
class=
"flex items-center mb-4"
>
<div>
<p
class=
"text-[.9375rem] font-semibold mb-2"
><a
href=
"javascript:void(0);"
>
{{item.equipmentName}}
</a></p>
<p
class=
"text-[0.75rem] text-[#8c9097] dark:text-white/50 mb-0"
>
S/N# {{item.serialNumber}}
</p>
</div>
</div>
<div
class=
"flex flex-wrap align-itesm-center justify-between"
>
<div
class=
"font-semibold mb-1"
>
รายละเอียด :
</div>
<p
class=
"text-[#8c9097] dark:text-white/50 mb-3"
>
{{item.description}}
</p>
<!-- <div class="flex flex-wrap items-center leading-none">
<span class="avatar avatar-xs me-1">
<img src="./assets/images/crypto-currencies/square-color/Ethereum.svg" alt="">
</span>0.24ETH
</div> -->
</div>
<div
class=
"flex flex-wrap align-itesm-center justify-between mb-2"
>
<div
class=
"font-semibold mb-1"
>
จำนวน :
</div>
<h3
class=
"text-[#8c9097] dark:text-white/50"
>
{{item.quantity}}
</h3>
</div>
<!-- <div class="grid">
<button type="button" class="ti-btn ti-btn-primary btn-wave waves-effect waves-light">Place Bid</button>
</div> -->
</div>
<div
class=
"box-footer border-block-start-dashed dark:border-defaultborder/10 text-center"
>
<div
class=
"btn-list"
>
<div
class=
"btn-list"
>
<button
type=
"button"
aria-label=
"button"
data-hs-overlay=
"#modal-detail"
(
click
)="
view
(
item
)"
class=
"ti-btn ti-btn-sm ti-btn-primary me-[0.375rem]"
><i
class=
"ri-edit-line"
></i></button>
<button
data-hs-overlay=
"#modal-stock"
type=
"button"
aria-label=
"button"
(
click
)="
viewStock
(
item
);"
class=
"ti-btn ti-btn-sm ti-btn-warning me-[0.375rem]"
>
<i
class=
"ri-store-line"
></i>
</button>
<button
(
click
)="
delete
(
item
)"
type=
"button"
aria-label=
"button"
class=
"ti-btn ti-btn-sm ti-btn-danger me-0"
><i
class=
"ri-delete-bin-line"
></i></button>
</div>
</div>
</div>
</div>
</div>
}
</div>
<!-- <nav aria-label="Page navigation" class="mb-4">
<ul class="ti-pagination !justify-end py-[0.375rem] px-3 text-[1rem] flex flex-row">
<li class="page-item disabled"><a class="page-link py-[0.375rem] px-3" href="javascript:void(0);">Previous</a></li>
<li class="page-item"><a class="page-link py-[0.375rem] px-3" href="javascript:void(0);">1</a></li>
<li class="page-item"><a class="page-link py-[0.375rem] px-3" href="javascript:void(0);">2</a></li>
<li class="page-item"><a class="page-link py-[0.375rem] px-3" href="javascript:void(0);">Next</a></li>
</ul>
</nav> -->
<!-- Start:: New Deal -->
<div
id=
"modal-detail"
class=
"hs-overlay hidden ti-modal"
>
<div
class=
"hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out"
>
<div
class=
"ti-modal-content"
>
<div
class=
"ti-modal-header"
>
<h6
class=
"modal-title text-[1rem] font-semibold text-defaulttextcolor"
id=
"mail-ComposeLabel"
>
ข้อมูลอุปกรณ์
</h6>
<button
type=
"button"
class=
"hs-dropdown-toggle !text-[1rem] !font-semibold !text-defaulttextcolor"
data-hs-overlay=
"#modal-detail"
>
<span
class=
"sr-only"
>
Close
</span>
<i
class=
"ri-close-line"
></i>
</button>
</div>
<div
class=
"ti-modal-body px-4"
>
<div
class=
"grid grid-cols-12 gap-4"
>
<div
class=
"xl:col-span-12 col-span-12"
>
<div
class=
"mb-0 text-center"
>
<span
class=
"avatar avatar-xxl avatar-rounded"
>
<img
[
src
]="
selectModel
.
getPicture
()"
alt=
""
id=
"profile-img"
>
<span
class=
"badge rounded-full bg-primary avatar-badge"
>
<input
ng2FileSelect
[
uploader
]="
uploaderProfile
"
type=
"file"
name=
"photo"
class=
"absolute w-full h-full opacity-[0]"
id=
"profile-change"
>
<i
class=
"fe fe-camera text-[.625rem]"
></i>
</span>
</span>
</div>
</div>
<div
class=
"xl:col-span-12 col-span-12"
>
<label
for=
"deal-name"
class=
"form-label"
>
ชื่ออุปกรณ์
</label>
<input
type=
"text"
class=
"form-control"
id=
"deal-name"
placeholder=
"ชื่ออุปกรณ์"
[(
ngModel
)]="
selectModel
.
equipmentName
"
>
</div>
<div
class=
"xl:col-span-12 col-span-12"
>
<label
for=
"deal-name"
class=
"form-label"
>
S/N
</label>
<input
type=
"text"
class=
"form-control"
id=
"deal-name"
placeholder=
"S/N"
[(
ngModel
)]="
selectModel
.
serialNumber
"
>
</div>
<!-- <div class="xl:col-span-6 col-span-12">
<label for="deal-name" class="form-label">จำนวน</label>
<input type="number" class="form-control" id="deal-name" placeholder="จำนวน"
[(ngModel)]="selectModel.quantity">
</div> -->
<div
class=
"xl:col-span-12 col-span-12"
>
<label
for=
"deal-lead-score"
class=
"form-label"
>
รายละเอียด
</label>
<!-- <input type="text" class="form-control" id="deal-lead-score" placeholder="รายละเอียด"
[(ngModel)]="selectModel.description"> -->
<textarea
class=
"form-control"
id=
"job-description"
[(
ngModel
)]="
selectModel
.
description
"
rows=
"4"
></textarea>
</div>
<div
class=
"xl:col-span-12 col-span-12"
>
<div
class=
"form-check form-check-lg flex items-center"
>
<input
class=
"form-check-input"
type=
"checkbox"
id=
"checkebox-lg"
[(
ngModel
)]="
selectModel
.
is_returnable
"
>
<label
class=
"form-check-label"
for=
"checkebox-lg"
>
ตรวจสอบการคืน
</label>
</div>
</div>
</div>
</div>
<div
class=
"ti-modal-footer"
>
<button
#
closeModal
type=
"button"
class=
"hs-dropdown-toggle ti-btn ti-btn-light align-middle"
data-hs-overlay=
"#modal-detail"
>
ยกเลิก
</button>
<button
type=
"button"
class=
"ti-btn bg-primary text-white !font-medium"
(
click
)="
save
()"
>
บันทึก
</button>
</div>
</div>
</div>
</div>
<!-- Start:: New Deal -->
<div
id=
"modal-stock"
class=
"hs-overlay hidden ti-modal"
*
ngIf=
"selectStock"
>
<div
class=
"hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out"
>
<div
class=
"ti-modal-content"
>
<div
class=
"ti-modal-header"
>
<h6
class=
"modal-title text-[1rem] font-semibold text-defaulttextcolor"
id=
"mail-ComposeLabel"
>
ข้อมูลอุปกรณ์
</h6>
<button
type=
"button"
class=
"hs-dropdown-toggle !text-[1rem] !font-semibold !text-defaulttextcolor"
data-hs-overlay=
"#modal-stock"
>
<span
class=
"sr-only"
>
Close
</span>
<i
class=
"ri-close-line"
></i>
</button>
</div>
<div
class=
"ti-modal-body px-4"
>
<div
class=
"grid grid-cols-12 gap-4"
>
<div
class=
"xl:col-span-12 col-span-12"
>
<img
[
src
]="
selectModel
.
getPicture
()"
class=
"!rounded-t-md"
alt=
"..."
style=
"width: 100%;height: auto;object-fit: cover;"
>
</div>
<div
class=
"xl:col-span-12 col-span-12"
>
<label
for=
"deal-name"
class=
"form-label"
>
ชื่ออุปกรณ์
</label>
<input
readonly
type=
"text"
class=
"form-control"
id=
"deal-name"
placeholder=
"ชื่ออุปกรณ์"
[(
ngModel
)]="
selectModel
.
equipmentName
"
>
</div>
<div
class=
"xl:col-span-12 col-span-12"
>
<label
for=
"deal-name"
class=
"form-label"
>
S/N
</label>
<input
readonly
type=
"text"
class=
"form-control"
id=
"deal-name"
placeholder=
"S/N"
[(
ngModel
)]="
selectModel
.
serialNumber
"
>
</div>
<div
class=
"xl:col-span-12 col-span-12"
>
<label
for=
"deal-name"
class=
"form-label"
>
จำนวน
</label>
<input
type=
"number"
class=
"form-control"
id=
"deal-name"
placeholder=
"จำนวน"
[(
ngModel
)]="
selectStock
.
quantity
"
>
</div>
<div
class=
"xl:col-span-12 col-span-12"
>
<div
class=
"form-check form-check-lg flex items-center"
>
<label
for=
"product-availability"
class=
"form-label"
>
ประเภท
</label>
<select
class=
"form-control"
data-trigger
name=
"product-availability"
id=
"product-availability"
[(
ngModel
)]="
selectStock
.
action
"
placeholder=
"Select"
>
<option
value=
"INBOUND"
selected
>
In Stock
</option>
<option
value=
"OUTBOUND"
>
Out Of Stock
</option>
<!-- <option value="OUTBOUND">Out Of Stock</option> -->
</select>
</div>
</div>
<div
class=
"xl:col-span-12 col-span-12"
>
<label
for=
"deal-lead-score"
class=
"form-label"
>
หมายเหตุ
</label>
<!-- <input type="text" class="form-control" id="deal-lead-score" placeholder="รายละเอียด"
[(ngModel)]="selectModel.description"> -->
<textarea
class=
"form-control"
id=
"job-description"
[(
ngModel
)]="
selectStock
.
remark
"
rows=
"4"
></textarea>
</div>
</div>
</div>
<div
class=
"ti-modal-footer"
>
<button
#
closeModalStock
type=
"button"
class=
"hs-dropdown-toggle ti-btn ti-btn-light align-middle"
data-hs-overlay=
"#modal-stock"
>
ยกเลิก
</button>
<button
type=
"button"
class=
"ti-btn bg-primary text-white !font-medium"
(
click
)="
saveStock
()"
>
บันทึก
</button>
</div>
</div>
</div>
</div>
Web-Manage/src/app/DPU/company-management/admin-project-equirement/admin-project-equirement.component.ts
View file @
4ace00cf
import
{
Component
}
from
'@angular/core'
;
import
{
CommonModule
}
from
"@angular/common"
;
import
{
ChangeDetectionStrategy
,
Component
,
ElementRef
,
ViewChild
}
from
'@angular/core'
;
import
{
NgSelectModule
}
from
"@ng-select/ng-select"
;
import
{
TranslateModule
,
TranslateService
}
from
"@ngx-translate/core"
;
import
{
FormsModule
}
from
"@angular/forms"
;
import
swal
from
'sweetalert'
;
import
{
MatPaginator
,
PageEvent
}
from
"@angular/material/paginator"
;
import
{
SharedModule
}
from
"../../../shared/shared.module"
;
import
{
UserProfileModel
}
from
"../../models/user.model"
;
import
{
UserService
}
from
"../../services/user.service"
;
import
{
TokenService
}
from
"../../../shared/services/token.service"
;
import
{
FileUploadModule
}
from
'ng2-file-upload'
;
import
{
FileItem
,
FileUploader
,
ParsedResponseHeaders
}
from
"ng2-file-upload"
;
import
{
environment
}
from
"../../../../environments/environment"
;
import
{
EquipmentModel
,
EquipmentStockModel
}
from
"../../models/equipments.model"
;
import
{
EquipmentService
}
from
"../../services/equirement.service"
;
import
{
HttpClient
}
from
"@angular/common/http"
;
@
Component
({
@
Component
({
selector
:
'app-admin-project-equirement'
,
selector
:
'app-admin-project-equirement'
,
standalone
:
true
,
standalone
:
true
,
imports
:
[],
imports
:
[
CommonModule
,
SharedModule
,
TranslateModule
,
NgSelectModule
,
FormsModule
,
MatPaginator
,
FileUploadModule
],
templateUrl
:
'./admin-project-equirement.component.html'
,
templateUrl
:
'./admin-project-equirement.component.html'
,
styleUrl
:
'./admin-project-equirement.component.scss'
styleUrl
:
'./admin-project-equirement.component.scss'
})
})
export
class
AdminProjectEquirementComponent
{
export
class
AdminProjectEquirementComponent
{
}
@
ViewChild
(
'closeModal'
)
public
childModal
?:
ElementRef
;
@
ViewChild
(
'closeModalStock'
)
public
closeModalStock
?:
ElementRef
;
@
ViewChild
(
'modalDetail'
)
public
modalDetail
?:
ElementRef
;
allSelected
=
false
;
someSelected
=
false
;
uploaderProfile
:
FileUploader
|
undefined
;
uploadErrorMsg
:
string
=
""
;
itemsList
:
EquipmentModel
[]
=
[]
filterList
:
EquipmentModel
[]
=
[]
selectModel
:
EquipmentModel
=
new
EquipmentModel
()
selectStock
?:
EquipmentStockModel
selectedItems
=
new
Map
<
string
,
boolean
>
();
pageIndex
=
0
;
get
searchTerm
():
string
{
return
this
.
_searchTerm
;
}
set
searchTerm
(
val
:
string
)
{
this
.
pageIndex
=
0
;
this
.
allSelected
=
false
this
.
_searchTerm
=
val
;
if
(
val
!=
''
)
{
this
.
filterList
=
this
.
filter
(
val
);
}
else
{
this
.
updatePagedItems
()
}
}
companyId
=
""
_searchTerm
=
""
;
isEdit
=
false
;
constructor
(
private
http
:
HttpClient
,
private
eqService
:
EquipmentService
,
public
translate
:
TranslateService
,
private
tokenService
:
TokenService
)
{
this
.
uploadConfig
()
this
.
companyId
=
this
.
tokenService
.
getSelectCompany
().
companyId
;
}
@
ViewChild
(
'video'
)
video
:
ElementRef
;
@
ViewChild
(
'canvas'
)
canvas
:
ElementRef
;
capturedImage
:
string
|
null
=
null
;
uploadStatus
:
string
=
''
;
checkMatch
=
false
;
memberId
=
""
isFaceDetected
=
false
;
// Flag to determine if a face is detected
uploadConfig
()
{
this
.
uploaderProfile
=
new
FileUploader
({
url
:
environment
.
baseUrl
+
"/api/upload-image"
,
isHTML5
:
true
,
authToken
:
this
.
tokenService
.
getToken
()
!
,
});
this
.
uploaderProfile
.
onAfterAddingFile
=
(
fileItem
:
FileItem
)
=>
{
fileItem
.
withCredentials
=
false
;
this
.
uploadErrorMsg
=
""
;
while
(
this
.
uploaderProfile
!
.
queue
.
length
>
1
)
{
this
.
uploaderProfile
!
.
queue
[
0
].
remove
();
}
if
(
fileItem
.
file
.
size
>
5000000
)
{
this
.
uploadErrorMsg
=
"maximum file size 5mb."
;
swal
(
"Opp!!"
,
"ไม่สามารถอัพโหลดได้"
,
"info"
);
fileItem
.
isCancel
=
true
;
return
;
}
if
(
fileItem
.
file
.
type
!
.
indexOf
(
"image"
)
===
-
1
)
{
this
.
uploadErrorMsg
=
"please upload image only."
;
swal
(
"Opp!!"
,
"ไม่สามารถอัพโหลดได้"
,
"info"
);
fileItem
.
isCancel
=
true
;
return
;
}
fileItem
.
upload
();
};
this
.
uploaderProfile
.
onCompleteItem
=
(
item
:
FileItem
,
response
:
string
,
status
:
number
,
headers
:
ParsedResponseHeaders
)
=>
{
if
(
item
.
isSuccess
)
{
const
res
=
JSON
.
parse
(
response
);
console
.
log
(
"res"
,
res
);
this
.
selectModel
.
picture
=
res
.
filename
swal
(
res
.
message
,
"บันทึกสำเร็จ"
,
"success"
);
}
else
{
this
.
uploadErrorMsg
=
"cannot upload file."
;
swal
(
"Opp!!"
,
"ไม่สามารถอัพโหลดได้"
,
"info"
);
}
};
}
ngOnInit
():
void
{
this
.
eqService
.
getLists
().
subscribe
(
result
=>
{
this
.
itemsList
=
result
this
.
updatePagedItems
()
})
}
filter
(
v
:
string
)
{
this
.
pageIndex
=
0
;
return
this
.
itemsList
?.
filter
(
(
x
)
=>
x
.
equipmentName
.
toLowerCase
().
indexOf
(
v
.
toLowerCase
())
!==
-
1
||
x
.
description
?.
toLowerCase
().
indexOf
(
v
.
toLowerCase
())
!==
-
1
);
}
delete
(
item
:
EquipmentModel
)
{
swal
({
title
:
"Are you sure?"
,
text
:
"You won't be able to revert this!"
,
icon
:
"warning"
,
dangerMode
:
true
,
buttons
:
[
"Cancel"
,
"Yes,Delete it!"
],
})
.
then
((
willDelete
:
any
)
=>
{
if
(
willDelete
)
{
this
.
eqService
.
delete
(
item
).
subscribe
(
result
=>
{
swal
(
"Save Success!!"
,
"บันทึกข้อมูลสำเร็จ"
,
"success"
);
this
.
ngOnInit
()
})
}
});
}
new
()
{
this
.
isEdit
=
false
this
.
selectModel
=
new
EquipmentModel
()
}
view
(
item
:
EquipmentModel
)
{
console
.
log
(
item
)
this
.
isEdit
=
true
;
this
.
selectModel
=
item
}
viewStock
(
item
:
EquipmentModel
)
{
this
.
selectModel
=
item
this
.
selectStock
=
new
EquipmentStockModel
()
this
.
selectStock
.
equipmentId
=
this
.
selectModel
.
equipmentId
this
.
selectStock
.
created_by
=
this
.
tokenService
.
getUser
().
member
.
memberId
this
.
selectStock
.
action
=
"INBOUND"
}
save
()
{
console
.
log
(
this
.
selectModel
)
swal
({
title
:
"Are you sure?"
,
text
:
"คุณต้องการบันทึกหรือไม่"
,
icon
:
"warning"
,
dangerMode
:
false
,
buttons
:
[
"Cancel"
,
"Confirm"
],
})
.
then
((
willDelete
:
any
)
=>
{
if
(
willDelete
)
{
if
(
!
this
.
isEdit
)
{
this
.
eqService
.
save
(
this
.
selectModel
).
subscribe
(
result
=>
{
swal
(
"Save Success!!"
,
"บันทึกข้อมูลสำเร็จ"
,
"success"
);
this
.
ngOnInit
()
this
.
childModal
?.
nativeElement
.
click
()
})
}
else
{
this
.
eqService
.
update
(
this
.
selectModel
).
subscribe
(
result
=>
{
swal
(
"Save Success!!"
,
"บันทึกข้อมูลสำเร็จ"
,
"success"
);
this
.
ngOnInit
()
this
.
childModal
?.
nativeElement
.
click
()
})
}
// this.selectModel.member.role = 0
}
});
}
updateEmp
()
{
swal
({
title
:
"Are you sure?"
,
text
:
"คุณต้องการบันทึกหรือไม่"
,
icon
:
"warning"
,
dangerMode
:
false
,
buttons
:
[
"Cancel"
,
"Confirm"
],
})
.
then
((
willDelete
:
any
)
=>
{
if
(
willDelete
)
{
this
.
eqService
.
save
(
this
.
selectModel
).
subscribe
(
result
=>
{
swal
(
"Save Success!!"
,
"บันทึกข้อมูลสำเร็จ"
,
"success"
);
this
.
ngOnInit
()
this
.
childModal
?.
nativeElement
.
click
()
})
}
});
}
// filterEmp(empId: string) {
// this.selectModel.supervisor = this.itemsList.filter(e => e.employeeId == empId)[0]
// }
updatePagedItems
()
{
const
startIndex
=
this
.
pageIndex
*
10
;
const
endIndex
=
startIndex
+
10
;
// this.filterList = this.itemsList.slice(startIndex, endIndex);
this
.
filterList
=
this
.
itemsList
}
saveStock
()
{
console
.
log
(
this
.
selectStock
)
swal
({
title
:
"Are you sure?"
,
text
:
"คุณต้องการบันทึกหรือไม่"
,
icon
:
"warning"
,
dangerMode
:
false
,
buttons
:
[
"Cancel"
,
"Confirm"
],
})
.
then
((
willDelete
:
any
)
=>
{
if
(
willDelete
)
{
this
.
eqService
.
stock
(
this
.
selectStock
!
).
subscribe
(
result
=>
{
swal
(
"Save Success!!"
,
"บันทึกข้อมูลสำเร็จ"
,
"success"
);
this
.
ngOnInit
()
this
.
closeModalStock
?.
nativeElement
.
click
()
})
}
});
}
}
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