Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
myjob-manage
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
myjob-manage
Commits
f02270be
Commit
f02270be
authored
Jun 30, 2025
by
DESKTOP-E3GSHH7\myhr
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
จัดการบริษัท
parent
c5f2b417
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
1100 additions
and
115 deletions
+1100
-115
company-manage.component.html
...p/DPU/common/company-manage/company-manage.component.html
+294
-10
company-manage.component.ts
...app/DPU/common/company-manage/company-manage.component.ts
+449
-103
base.model.ts
src/app/DPU/models/base.model.ts
+28
-0
companys.mode.ts
src/app/DPU/models/companys.mode.ts
+162
-0
province.model.ts
src/app/DPU/models/province.model.ts
+2
-1
company.service.ts
src/app/DPU/services/company.service.ts
+1
-1
companys.service.ts
src/app/DPU/services/companys.service.ts
+164
-0
No files found.
src/app/DPU/common/company-manage/company-manage.component.html
View file @
f02270be
<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"
>
...
...
@@ -25,6 +24,286 @@
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>
</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"
>
บริษัท
</th>
<th
scope=
"col"
class=
"text-start"
>
ชื่อเจ้าของ
</th>
<th
scope=
"col"
class=
"text-start"
>
ข้อมูลบริษัท
</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>
@if (filterList.length > 0) {
@for (item of filterList; track item.companyId) {
<tr
class=
"border border-defaultborder dark:border-defaultborder/10"
>
<td
class=
"product-checkbox"
>
<input
class=
"form-check-input"
type=
"checkbox"
[
checked
]="
selectedItems
.
get
(
item
.
companyId
)
||
false
"
(
change
)="
onCheckboxChange
(
item
.
companyId
)"
aria-label=
"..."
>
</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
routerLink=
"/company/home/{{item.companyId}}"
routerLinkActive=
"active"
>
{{item.thName}}
</a>
</p>
</div>
</div>
</td>
<td>
<div>
<span
class=
"block mb-1"
>
{{item.thFirstnameContact}} {{item.thLastnameContact}}
</span>
</div>
</td>
<td>
<div>
<span
class=
"block mb-1 whitespace-pre-wrap"
>
<i
class=
"ri-home-line me-2 align-middle text-[.875rem] text-[#8c9097] dark:text-white/50 inline-flex"
></i>
{{item.companyDetail}}
</span>
</div>
</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>
<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>
}
} @else {
<tr>
<td
[
attr
.
colspan
]="
6
"
class=
"text-center py-4"
>
<ng-container
*
ngIf=
"itemsList.length === 0 && !searchTerm"
>
<p>
กำลังโหลดข้อมูล หรือไม่มีข้อมูลเลย...
</p>
</ng-container>
<ng-container
*
ngIf=
"itemsList.length > 0 && filterList.length === 0 && searchTerm"
>
<p>
ไม่พบข้อมูลที่ค้นหา...
</p>
</ng-container>
</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>
<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 }} {{ 'Company' | 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-6 col-span-12"
>
<label
for=
"thName"
class=
"form-label"
>
{{'ชื่อบริษัท ไทย' | translate}}
</label>
<input
type=
"text"
class=
"form-control"
id=
"thName"
placeholder=
""
[(
ngModel
)]="
selectModel
.
thName
"
>
<div
class=
"text-danger"
*
ngIf=
"!selectModel.thName"
>
{{'Please fill in information' | translate}}
</div>
</div>
<div
class=
"xl:col-span-6 col-span-12"
>
<label
for=
"thName"
class=
"form-label"
>
{{'ชื่อบริษัท อังกฤษ' | translate}}
</label>
<input
type=
"text"
class=
"form-control"
id=
"thName"
placeholder=
""
[(
ngModel
)]="
selectModel
.
engName
"
>
<div
class=
"text-danger"
*
ngIf=
"!selectModel.thName"
>
{{'Please fill in information' | translate}}
</div>
</div>
<div
class=
"xl:col-span-12 col-span-12"
>
<label
for=
"companyId"
class=
"form-label"
>
{{'รหัสบริษัท' | translate}}
</label>
<input
type=
"text"
class=
"form-control"
id=
"companyId"
placeholder=
""
[(
ngModel
)]="
selectModel
.
companyId
"
[
readonly
]="
action =
==
'
edit
'"
[
ngClass
]="{
'!
bg-input-readonly
'
:
action =
==
'
edit
'
}"
>
<div
class=
"text-danger"
*
ngIf=
"!selectModel.companyId && action === 'add'"
>
{{'Please fill in information' | translate}}
</div>
</div>
<div
class=
"xl:col-span-12 col-span-12"
>
<label
for=
"companyDetail"
class=
"form-label"
>
{{'ข้อมูลบริษัท' | translate}}
</label>
<input
type=
"text"
class=
"form-control"
id=
"companyDetail"
placeholder=
""
[(
ngModel
)]="
selectModel
.
companyDetail
"
>
<div
class=
"text-danger"
*
ngIf=
"!selectModel.companyDetail"
>
{{'Please fill in information' | translate}}
</div>
</div>
<div
class=
"xl:col-span-12 col-span-12"
>
<label
for=
"locationDetail"
class=
"form-label"
>
{{'ที่อยู่' | translate}}
</label>
<textarea
class=
"form-control"
id=
"locationDetail"
placeholder=
""
[(
ngModel
)]="
selectModel
.
locationDetail
"
></textarea>
</div>
<div
class=
"xl:col-span-6 col-span-12"
>
<label
for=
"thFirstnameContact"
class=
"form-label"
>
{{'ชื่อเจ้าของ' | translate}}
</label>
<input
type=
"text"
class=
"form-control"
id=
"thFirstnameContact"
placeholder=
""
[(
ngModel
)]="
selectModel
.
thFirstnameContact
"
>
</div>
<div
class=
"xl:col-span-6 col-span-12"
>
<label
for=
"thLastnameContact"
class=
"form-label"
>
{{'นามสกุลเจ้าของ' | translate}}
</label>
<input
type=
"text"
class=
"form-control"
id=
"thLastnameContact"
placeholder=
""
[(
ngModel
)]="
selectModel
.
thLastnameContact
"
>
</div>
<div
class=
"xl:col-span-12 col-span-12"
>
<label
for=
"phoneContact"
class=
"form-label"
>
{{'เบอร์ติดต่อ' | translate}}
</label>
<input
type=
"text"
class=
"form-control"
id=
"phoneContact"
placeholder=
""
[(
ngModel
)]="
selectModel
.
phoneContact
"
>
</div>
<div
class=
"xl:col-span-12 col-span-12"
>
<label
class=
"form-label"
>
{{'Status' | translate}}
</label>
<ng-select
name=
"statusSelect"
id=
"statusSelect"
placeholder=
""
[(
ngModel
)]="
selectModel
.
status
"
>
<ng-option
[
value
]="
0
"
>
{{'Pending' | translate}}
</ng-option>
<ng-option
[
value
]="
1
"
>
{{'Public' | 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>
<!-- <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' |
...
...
@@ -34,17 +313,20 @@
<input class="form-control form-control" type="text" placeholder="ค้นหาบริษัท"
aria-label=".form-control-sm example" [(ngModel)]='searchTerm'>
</div>
<!-- <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">
</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> -->
</ul>
</div>
</div>
<div class="box-body">
...
...
@@ -85,7 +367,8 @@
</div>
</div>
</td>
<!-- <td>
<td>ไม่เอา
<div class="flex">
<div class="ms-2">
<p class="font-semibold mb-0 flex items-center text-primary"><a routerLink="/company/home/{{item.companyId}}" routerLinkActive="active">
...
...
@@ -93,7 +376,8 @@
<p class="text-[0.75rem] text-muted mb-0">{{item.companyId}}</p>
</div>
</div>
</td> -->
</td>
<td> {{item.companyCode}}</td>
<td>
<div>
...
...
@@ -171,7 +455,6 @@
<!-- 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">
...
...
@@ -267,5 +550,5 @@
</div>
</div>
</div>
</div>
<!-- End:: Create Contact -->
</div>
-->
<!-- End:: Create Contact -->
\ No newline at end of file
src/app/DPU/common/company-manage/company-manage.component.ts
View file @
f02270be
...
...
@@ -3,9 +3,7 @@ import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
import
{
RouterModule
}
from
'@angular/router'
;
import
{
SharedModule
}
from
'../../../shared/shared.module'
;
import
{
TranslateModule
,
TranslateService
}
from
'@ngx-translate/core'
;
import
{
CompanyModel
}
from
'../../models/company.model'
;
import
swal
from
'sweetalert'
;
import
{
CompanyService
}
from
'../../services/company.service'
;
import
{
MatPaginator
}
from
'@angular/material/paginator'
;
import
{
FormsModule
}
from
'@angular/forms'
;
import
{
NgSelectModule
}
from
'@ng-select/ng-select'
;
...
...
@@ -14,6 +12,8 @@ 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
{
CompanyModelS
}
from
'../../models/companys.mode'
;
import
{
CompanyServiceS
}
from
'../../services/companys.service'
;
@
Component
({
selector
:
'app-company-manage'
,
...
...
@@ -37,32 +37,34 @@ export class CompanyManageComponent {
action
=
"new"
;
allSelected
=
false
;
someSelected
=
false
;
itemsList
:
CompanyModel
[]
=
[]
filterList
:
CompanyModel
[]
=
[]
selectModel
:
CompanyModel
=
new
CompanyModel
()
itemsList
:
CompanyModel
S
[]
=
[];
filterList
:
CompanyModel
S
[]
=
[];
selectModel
:
CompanyModel
S
=
new
CompanyModelS
();
selectedItems
=
new
Map
<
string
,
boolean
>
();
empList
:
CompanyModel
[]
=
[]
descName
=
'engName'
// empList: CompanyModelS[] = [];
// 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
.
allSelected
=
false
;
this
.
_searchTerm
=
val
;
if
(
val
!=
''
)
{
this
.
filterList
=
this
.
filter
(
val
);
}
else
{
this
.
updatePagedItems
()
this
.
updatePagedItems
()
;
}
}
_searchTerm
=
""
;
constructor
(
private
comService
:
CompanyService
,
public
translate
:
TranslateService
,
private
tokenService
:
TokenService
)
{
this
.
uploadConfig
()
constructor
(
private
comService
:
CompanyServiceS
,
public
translate
:
TranslateService
,
private
tokenService
:
TokenService
)
{
this
.
uploadConfig
();
}
uploadConfig
()
{
...
...
@@ -106,9 +108,8 @@ export class CompanyManageComponent {
if
(
item
.
isSuccess
)
{
const
res
=
JSON
.
parse
(
response
);
console
.
log
(
"res"
,
res
);
this
.
selectModel
.
p
icture
=
res
.
filename
this
.
selectModel
.
p
hotoGraph
=
res
.
filename
;
swal
(
res
.
message
,
"บันทึกสำเร็จ"
,
"success"
);
}
else
{
this
.
uploadErrorMsg
=
"cannot upload file."
;
swal
(
"Opp!!"
,
"ไม่สามารถอัพโหลดได้"
,
"info"
);
...
...
@@ -116,93 +117,99 @@ export class CompanyManageComponent {
};
}
getCompany
()
{
this
.
comService
.
getList
().
subscribe
({
next
:
(
response
:
CompanyModelS
[])
=>
{
this
.
itemsList
=
response
.
map
((
x
:
any
)
=>
new
CompanyModelS
(
x
,
this
.
translate
));
console
.
log
(
'ข้อมูลบริษัท (itemsList)'
,
this
.
itemsList
);
this
.
updatePagedItems
();
},
error
:
(
error
)
=>
{
console
.
error
(
'error cant get company'
,
error
);
swal
(
"ข้อผิดพลาด"
,
"ไม่สามารถดึงข้อมูลบริษัทได้"
,
"error"
);
}
});
}
ngOnInit
():
void
{
this
.
comService
.
getLists
().
subscribe
(
result
=>
{
this
.
itemsList
=
result
this
.
updatePagedItems
()
})
this
.
getCompany
();
}
filter
(
v
:
string
)
{
return
this
.
itemsList
?.
filter
(
(
x
)
=>
x
.
companyId
?.
toLowerCase
().
indexOf
(
v
.
toLowerCase
())
!==
-
1
||
x
.
companyName
?.
toLowerCase
().
indexOf
(
v
.
toLowerCase
())
!==
-
1
||
x
.
companyCode
?.
toLowerCase
().
indexOf
(
v
.
toLowerCase
())
!==
-
1
||
x
.
companyInfo
?.
toLowerCase
().
indexOf
(
v
.
toLowerCase
())
!==
-
1
||
x
.
address
.
toLowerCase
().
indexOf
(
v
.
toLowerCase
())
!==
-
1
||
x
.
ownerName
.
toLowerCase
().
indexOf
(
v
.
toLowerCase
())
!==
-
1
||
x
.
thName
?.
toLowerCase
().
indexOf
(
v
.
toLowerCase
())
!==
-
1
||
x
.
companyDetail
?.
toLowerCase
().
indexOf
(
v
.
toLowerCase
())
!==
-
1
||
x
.
locationDetail
?.
toLowerCase
().
indexOf
(
v
.
toLowerCase
())
!==
-
1
||
x
.
thFirstnameContact
?.
toLowerCase
().
indexOf
(
v
.
toLowerCase
())
!==
-
1
||
x
.
getStatus
().
toLowerCase
().
indexOf
(
v
.
toLowerCase
())
!==
-
1
);
}
delete
(
item
:
CompanyModel
)
{
delete
(
item
:
CompanyModel
S
)
{
swal
({
title
:
"
Are you sure
?"
,
text
:
"
You won't be able to revert this
!"
,
title
:
"
คุณแน่ใจหรือไม่
?"
,
text
:
"
คุณจะไม่สามารถกู้คืนข้อมูลนี้ได้
!"
,
icon
:
"warning"
,
dangerMode
:
true
,
buttons
:
[
"
Cancel"
,
"Yes,Delete it
!"
],
buttons
:
[
"
ยกเลิก"
,
"ใช่, ลบเลย
!"
],
})
.
then
((
willDelete
:
any
)
=>
{
if
(
willDelete
)
{
this
.
comService
.
delete
(
item
).
subscribe
(
result
=>
{
swal
(
"Save Success!!"
,
"บันทึกข้อมูลสำเร็จ"
,
"success"
);
this
.
ngOnInit
()
})
this
.
comService
.
deleteCompany
(
item
.
companyId
).
subscribe
(
result
=>
{
swal
(
"ลบสำเร็จ!!"
,
"ลบข้อมูลสำเร็จ"
,
"success"
);
this
.
ngOnInit
();
},
error
=>
{
console
.
error
(
"เกิดข้อผิดพลาดในการลบ:"
,
error
);
swal
(
"ข้อผิดพลาด!!"
,
"ไม่สามารถลบข้อมูลได้"
,
"error"
);
});
}
});
}
new
()
{
this
.
action
=
'add'
this
.
selectModel
=
new
CompanyModel
()
this
.
action
=
'add'
;
this
.
selectModel
=
new
CompanyModel
S
();
this
.
selectModel
.
status
=
1
;
this
.
selectModel
.
address
=
""
;
this
.
selectModel
.
latitude
=
0.00
this
.
selectModel
.
longitude
=
0.00
this
.
selectModel
.
picture
=
""
this
.
selectModel
.
locationDetail
=
""
;
this
.
selectModel
.
latitude
=
""
;
this
.
selectModel
.
longitude
=
""
;
this
.
selectModel
.
photoGraph
=
""
;
this
.
selectModel
.
thName
=
""
;
this
.
selectModel
.
companyId
=
""
;
this
.
selectModel
.
companyDetail
=
""
;
this
.
selectModel
.
thFirstnameContact
=
""
;
this
.
selectModel
.
updatedAt
=
new
Date
().
toISOString
();
}
view
(
item
:
CompanyModel
)
{
this
.
action
=
'edit'
this
.
selectModel
=
new
CompanyModel
(
item
)
console
.
log
(
this
.
selectModel
)
view
(
item
:
CompanyModel
S
)
{
this
.
action
=
'edit'
;
this
.
selectModel
=
new
CompanyModel
S
(
item
);
console
.
log
(
this
.
selectModel
)
;
}
save
()
{
swal
({
title
:
"
Are you sure
?"
,
title
:
"
คุณแน่ใจหรือไม่
?"
,
text
:
"คุณต้องการบันทึกหรือไม่"
,
icon
:
"warning"
,
dangerMode
:
false
,
buttons
:
[
"
Cancel"
,
"Confirm
"
],
buttons
:
[
"
ยกเลิก"
,
"ยืนยัน
"
],
})
.
then
((
willDelete
:
any
)
=>
{
if
(
willDelete
)
{
if
(
this
.
action
==
'add'
)
{
this
.
comService
.
save
(
this
.
selectModel
).
subscribe
(
result
=>
{
console
.
log
(
result
)
swal
(
"Save Success!!"
,
"บันทึกข้อมูลสมาชิก"
,
"success"
);
this
.
ngOnInit
()
this
.
childModal
?.
nativeElement
.
click
()
})
}
else
if
(
this
.
action
==
'edit'
)
{
this
.
comService
.
update
(
this
.
selectModel
).
subscribe
(
result
=>
{
console
.
log
(
result
)
swal
(
"Update Success!!"
,
"บันทึกข้อมูลสมาชิก"
,
"success"
);
this
.
ngOnInit
()
this
.
childModal
?.
nativeElement
.
click
()
})
}
.
then
((
willSave
:
any
)
=>
{
if
(
willSave
)
{
this
.
comService
.
saveOrUpdateCompany
(
this
.
selectModel
).
subscribe
(
result
=>
{
console
.
log
(
result
);
swal
(
"บันทึกสำเร็จ!!"
,
"บันทึกข้อมูลสมาชิก"
,
"success"
);
this
.
ngOnInit
();
this
.
childModal
?.
nativeElement
.
click
();
},
error
=>
{
console
.
error
(
"เกิดข้อผิดพลาดในการบันทึก/อัปเดต:"
,
error
);
swal
(
"ข้อผิดพลาด!!"
,
"ไม่สามารถบันทึก/อัปเดตข้อมูลได้"
,
"error"
);
});
}
});
}
updatePagedItems
()
{
...
...
@@ -228,75 +235,414 @@ export class CompanyManageComponent {
}
deleteSelect
()
{
let
employeeInfo
=
''
;
let
companyInfo
=
''
;
const
selectedCompanyIdsToDelete
:
string
[]
=
[];
this
.
selectedItems
.
forEach
((
isSelected
,
companyId
)
=>
{
if
(
isSelected
)
{
const
item
=
this
.
itemsList
.
find
(
item
=>
item
.
companyId
===
companyId
);
const
item
=
this
.
itemsList
.
find
(
c
=>
c
.
companyId
===
companyId
);
if
(
item
)
{
employeeInfo
+=
`
${
this
.
translate
.
instant
(
'บริษัท'
)}
:
${
item
.
companyName
}
\n`
;
companyInfo
+=
`
${
this
.
translate
.
instant
(
'บริษัท'
)}
:
${
item
.
thName
}
\n`
;
selectedCompanyIdsToDelete
.
push
(
item
.
companyId
);
}
}
});
if
(
selectedCompanyIdsToDelete
.
length
===
0
)
{
swal
(
"ข้อผิดพลาด"
,
"กรุณาเลือกบริษัทที่ต้องการลบ"
,
"warning"
);
return
;
}
swal
({
title
:
"
Are you sure
?"
,
text
:
employee
Info
,
title
:
"
คุณแน่ใจหรือไม่
?"
,
text
:
company
Info
,
icon
:
"warning"
,
dangerMode
:
true
,
buttons
:
[
"
Cancel"
,
"Yes, Delete it
!"
],
buttons
:
[
"
ยกเลิก"
,
"ใช่, ลบเลย
!"
],
})
.
then
((
willDelete
:
any
)
=>
{
if
(
willDelete
)
{
this
.
selectedItems
.
forEach
((
isSelected
,
companyId
)
=>
{
if
(
isSelected
)
{
const
item
=
this
.
itemsList
.
find
(
item
=>
item
.
companyId
===
companyId
);
if
(
item
)
{
this
.
comService
.
delete
(
item
).
subscribe
(
result
=>
{
swal
(
"Save Success!!"
,
"บันทึกข้อมูลสำเร็จ"
,
"success"
);
this
.
ngOnInit
();
});
const
deletePromises
=
selectedCompanyIdsToDelete
.
map
(
companyId
=>
this
.
comService
.
deleteCompany
(
companyId
).
toPromise
()
.
then
(()
=>
true
)
.
catch
(
error
=>
{
console
.
error
(
`Error deleting company
${
companyId
}
:`
,
error
);
return
false
;
})
);
Promise
.
all
(
deletePromises
)
.
then
(
results
=>
{
const
allSuccessful
=
results
.
every
(
success
=>
success
);
if
(
allSuccessful
)
{
swal
(
"ลบสำเร็จ!!"
,
"บันทึกข้อมูลสำเร็จ"
,
"success"
);
}
else
{
swal
(
"สำเร็จบางส่วน/ข้อผิดพลาด!!"
,
"มีการลบข้อมูลบางส่วนไม่สำเร็จ หรือมีข้อผิดพลาด"
,
"warning"
);
}
}
});
this
.
ngOnInit
();
this
.
selectedItems
.
clear
();
this
.
allSelected
=
false
;
this
.
someSelected
=
false
;
});
}
});
}
adjustSelect
(
status
:
number
)
{
let
title
=
"Are you sure?"
let
employeeInfo
=
''
;
// ตัวแปรสำหรับเก็บข้อมูลพนักงาน
this
.
selectedItems
.
forEach
((
isSelected
,
memberId
)
=>
{
let
title
=
"คุณแน่ใจหรือไม่?"
;
let
companyInfo
=
''
;
const
selectedCompanies
:
CompanyModelS
[]
=
[];
this
.
selectedItems
.
forEach
((
isSelected
,
companyId
)
=>
{
if
(
isSelected
)
{
const
company
=
this
.
itemsList
.
find
(
c
ompany
=>
company
.
companyId
===
member
Id
);
const
company
=
this
.
itemsList
.
find
(
c
=>
c
.
companyId
===
company
Id
);
if
(
company
)
{
employeeInfo
+=
`
${
this
.
translate
.
instant
(
'Fullname'
)}
:
${
company
.
companyName
}
\n`
;
companyInfo
+=
`
${
this
.
translate
.
instant
(
'ชื่อบริษัท'
)}
:
${
company
.
thName
}
\n`
;
selectedCompanies
.
push
(
company
);
}
}
});
if
(
selectedCompanies
.
length
===
0
)
{
swal
(
"ข้อผิดพลาด"
,
"กรุณาเลือกบริษัทที่ต้องการปรับสถานะ"
,
"warning"
);
return
;
}
swal
({
title
:
title
,
text
:
employee
Info
,
text
:
company
Info
,
icon
:
"warning"
,
dangerMode
:
false
,
buttons
:
[
"
Cancel"
,
"Confirm
"
],
buttons
:
[
"
ยกเลิก"
,
"ยืนยัน
"
],
})
.
then
((
willDelete
:
any
)
=>
{
if
(
willDelete
)
{
this
.
selectedItems
.
forEach
((
isSelected
,
companyId
)
=>
{
if
(
isSelected
)
{
const
company
=
this
.
itemsList
.
find
(
company
=>
company
.
companyId
===
companyId
);
if
(
company
)
{
company
.
status
=
status
this
.
comService
.
update
(
company
).
subscribe
(
result
=>
{
swal
(
"Save Success!!"
,
"บันทึกข้อมูลสำเร็จ"
,
"success"
);
this
.
ngOnInit
();
});
}
}
.
then
((
willAdjust
:
any
)
=>
{
if
(
willAdjust
)
{
const
updatePromises
=
selectedCompanies
.
map
(
company
=>
{
company
.
status
=
status
;
return
this
.
comService
.
saveOrUpdateCompany
(
company
).
toPromise
()
.
then
(()
=>
true
)
.
catch
(
error
=>
{
console
.
error
(
`Error updating status for company
${
company
.
companyId
}
:`
,
error
);
return
false
;
});
});
}
Promise
.
all
(
updatePromises
)
.
then
(
results
=>
{
const
allSuccessful
=
results
.
every
(
success
=>
success
);
if
(
allSuccessful
)
{
swal
(
"บันทึกสำเร็จ!!"
,
"บันทึกข้อมูลสำเร็จ"
,
"success"
);
}
else
{
swal
(
"สำเร็จบางส่วน/ข้อผิดพลาด!!"
,
"มีการอัปเดตสถานะบางส่วนไม่สำเร็จ หรือมีข้อผิดพลาด"
,
"warning"
);
}
this
.
ngOnInit
();
this
.
selectedItems
.
clear
();
this
.
allSelected
=
false
;
this
.
someSelected
=
false
;
});
}
});
}
}
// import { Component, ElementRef, ViewChild } from '@angular/core';
// import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
// import { RouterModule } from '@angular/router';
// import { SharedModule } from '../../../shared/shared.module';
// import { TranslateModule, TranslateService } from '@ngx-translate/core';
// import { CompanyModel } from '../../models/company.model';
// import swal from 'sweetalert';
// import { CompanyService } from '../../services/company.service';
// import { MatPaginator } from '@angular/material/paginator';
// import { FormsModule } from '@angular/forms';
// import { NgSelectModule } from '@ng-select/ng-select';
// import { CommonModule } from '@angular/common';
// 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';
// @Component({
// selector: 'app-company-manage',
// standalone: true,
// imports: [
// CommonModule,
// SharedModule,
// TranslateModule,
// NgSelectModule,
// FormsModule,
// MatPaginator,
// RouterModule,
// FileUploadModule
// ],
// templateUrl: './company-manage.component.html',
// styleUrl: './company-manage.component.css',
// })
// export class CompanyManageComponent {
// @ViewChild('closeModal') public childModal?: ElementRef;
// @ViewChild('modalDetail') public modalDetail?: ElementRef;
// action = "new";
// allSelected = false;
// someSelected = false;
// itemsList: CompanyModel[] = []
// filterList: CompanyModel[] = []
// selectModel: CompanyModel = new CompanyModel()
// selectedItems = new Map<string, boolean>();
// empList: CompanyModel[] = []
// 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 comService: CompanyService, 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.comService.getLists().subscribe(result => {
// this.itemsList = result
// this.updatePagedItems()
// })
// }
// filter(v: string) {
// return this.itemsList?.filter(
// (x) =>
// x.companyId?.toLowerCase().indexOf(v.toLowerCase()) !== -1 ||
// x.companyName?.toLowerCase().indexOf(v.toLowerCase()) !== -1 ||
// x.companyCode?.toLowerCase().indexOf(v.toLowerCase()) !== -1 ||
// x.companyInfo?.toLowerCase().indexOf(v.toLowerCase()) !== -1 ||
// x.address.toLowerCase().indexOf(v.toLowerCase()) !== -1 ||
// x.ownerName.toLowerCase().indexOf(v.toLowerCase()) !== -1 ||
// x.getStatus().toLowerCase().indexOf(v.toLowerCase()) !== -1
// );
// }
// delete(item: CompanyModel) {
// 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.comService.delete(item).subscribe(result => {
// swal("Save Success!!", "บันทึกข้อมูลสำเร็จ", "success");
// this.ngOnInit()
// })
// }
// });
// }
// new() {
// this.action = 'add'
// this.selectModel = new CompanyModel()
// this.selectModel.status = 1;
// this.selectModel.address = "";
// this.selectModel.latitude = 0.00
// this.selectModel.longitude = 0.00
// this.selectModel.picture = ""
// }
// view(item: CompanyModel) {
// this.action = 'edit'
// this.selectModel = new CompanyModel(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.comService.save(this.selectModel).subscribe(result => {
// console.log(result)
// swal("Save Success!!", "บันทึกข้อมูลสมาชิก", "success");
// this.ngOnInit()
// this.childModal?.nativeElement.click()
// })
// } else if (this.action == 'edit') {
// this.comService.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.companyId, this.allSelected);
// });
// this.someSelected = this.itemsList.some(item => this.selectedItems.get(item.companyId));
// }
// onCheckboxChange(companyId: string) {
// const isSelected = this.selectedItems.get(companyId) || false;
// this.selectedItems.set(companyId, !isSelected);
// this.allSelected = this.itemsList.every(item => this.selectedItems.get(item.companyId));
// this.someSelected = this.itemsList.some(item => this.selectedItems.get(item.companyId));
// }
// deleteSelect() {
// let employeeInfo = '';
// this.selectedItems.forEach((isSelected, companyId) => {
// if (isSelected) {
// const item = this.itemsList.find(item => item.companyId === companyId);
// if (item) {
// employeeInfo += `${this.translate.instant('บริษัท')}: ${item.companyName}\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, companyId) => {
// if (isSelected) {
// const item = this.itemsList.find(item => item.companyId === companyId);
// if (item) {
// this.comService.delete(item).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 company = this.itemsList.find(company => company.companyId === memberId);
// if (company) {
// employeeInfo += `${this.translate.instant('Fullname')}: ${company.companyName}\n`;
// }
// }
// });
// swal({
// title: title,
// text: employeeInfo,
// icon: "warning",
// dangerMode: false,
// buttons: ["Cancel", "Confirm"],
// })
// .then((willDelete: any) => {
// if (willDelete) {
// this.selectedItems.forEach((isSelected, companyId) => {
// if (isSelected) {
// const company = this.itemsList.find(company => company.companyId === companyId);
// if (company) {
// company.status = status
// this.comService.update(company).subscribe(result => {
// swal("Save Success!!", "บันทึกข้อมูลสำเร็จ", "success");
// this.ngOnInit();
// });
// }
// }
// });
// }
// });
// }
// }
src/app/DPU/models/base.model.ts
View file @
f02270be
...
...
@@ -9,6 +9,34 @@ export class BaseModel{
}
}
export
function
dataToArray
(
data
?:
any
)
{
return
data
?
data
:
[]
}
export
function
checkData
(
data
?:
any
)
{
return
(
data
||
data
==
0
)
?
data
:
null
}
export
function
checkDataNumber
(
data
?:
any
)
{
return
(
data
||
data
==
0
)
?
Number
(
data
)
:
null
}
export
function
baseGetName
(
thName
?:
string
|
null
,
engName
?:
string
|
null
,
currentLang
?:
string
)
{
let
name
=
null
if
(
currentLang
==
"th"
)
{
if
(
thName
)
{
name
=
thName
}
else
if
(
engName
)
{
name
=
engName
}
}
else
{
if
(
engName
)
{
name
=
engName
}
else
if
(
thName
)
{
name
=
thName
}
}
return
name
}
export
interface
Sort
{
...
...
src/app/DPU/models/companys.mode.ts
0 → 100644
View file @
f02270be
// src/app/modules/company/models/companys.mode.ts
import
{
BaseModel
,
dataToArray
,
checkData
,
baseGetName
}
from
"./base.model"
;
import
{
CategoryModel
}
from
"./category.model"
;
import
{
WelfareModel
}
from
"./welfare.model"
;
import
{
CountryModel
}
from
"./country.model"
;
import
{
SubDistrictModel
}
from
"./subdistrict.model"
;
import
{
ProvinceModel
}
from
"./province.model"
;
import
{
TranslateService
}
from
"@ngx-translate/core"
;
import
{
environment
}
from
"../../../environments/environment"
;
export
interface
CompanyModelS
{
companyCategory
:
CategoryModel
|
null
;
companyId
:
string
;
employerId
:
string
;
companyWelfareList
:
WelfareModel
[];
country
:
CountryModel
|
null
;
locationDetail
:
string
;
companyDetail
:
string
;
email
:
string
;
emailContact
:
string
;
engFirstnameContact
:
string
;
engLastnameContact
:
string
;
engName
:
string
;
facebookSocial
:
string
;
fax
:
string
;
faxContact
:
string
;
industrialEstate
:
number
;
latitude
:
string
;
line
:
string
;
longitude
:
string
;
map
:
string
;
phone
:
string
;
phoneContact
:
string
;
photoGraph
:
string
;
province
:
ProvinceModel
|
null
;
provinceContact
:
ProvinceModel
|
null
;
subDistrict
:
SubDistrictModel
|
null
;
subDistrictContact
:
SubDistrictModel
|
null
;
taxPayer
:
string
;
telContact
:
string
;
thFirstnameContact
:
string
;
thLastnameContact
:
string
;
thName
:
string
;
twitterSocial
:
string
;
video
:
string
;
webSite
:
string
;
websiteContact
:
string
;
websiteSocial
:
string
;
status
:
number
;
// เพิ่มบรรทัดนี้:
updatedAt
:
string
;
// หรือ Date หาก backend ส่งมาเป็น timestamp หรือ Date object
}
export
class
CompanyModelS
extends
BaseModel
implements
CompanyModelS
{
companyCategory
:
CategoryModel
|
null
;
companyId
:
string
;
employerId
:
string
;
companyWelfareList
:
WelfareModel
[];
country
:
CountryModel
|
null
;
locationDetail
:
string
;
companyDetail
:
string
;
email
:
string
;
emailContact
:
string
;
engFirstnameContact
:
string
;
engLastnameContact
:
string
;
engName
:
string
;
facebookSocial
:
string
;
fax
:
string
;
faxContact
:
string
;
industrialEstate
:
number
;
latitude
:
string
;
line
:
string
;
longitude
:
string
;
map
:
string
;
phone
:
string
;
phoneContact
:
string
;
photoGraph
:
string
;
province
:
ProvinceModel
|
null
;
provinceContact
:
ProvinceModel
|
null
;
subDistrict
:
SubDistrictModel
|
null
;
subDistrictContact
:
SubDistrictModel
|
null
;
taxPayer
:
string
;
telContact
:
string
;
thFirstnameContact
:
string
;
thLastnameContact
:
string
;
thName
:
string
;
twitterSocial
:
string
;
video
:
string
;
webSite
:
string
;
websiteContact
:
string
;
websiteSocial
:
string
;
status
:
number
;
// เพิ่มบรรทัดนี้:
updatedAt
:
string
;
// หรือ Date
[
key
:
string
]:
any
;
constructor
(
data
?:
Partial
<
CompanyModelS
>
,
translateService
?:
TranslateService
)
{
super
(
data
,
translateService
);
this
.
companyCategory
=
data
?.
companyCategory
?
new
CategoryModel
(
data
?.
companyCategory
,
translateService
)
:
null
;
this
.
companyId
=
checkData
(
data
?.
companyId
);
this
.
companyWelfareList
=
dataToArray
(
data
?.
companyWelfareList
).
map
((
x
:
WelfareModel
)
=>
new
WelfareModel
(
x
,
translateService
));
this
.
country
=
data
?.
country
?
new
CountryModel
(
data
?.
country
,
translateService
)
:
null
;
this
.
locationDetail
=
checkData
(
data
?.
locationDetail
);
this
.
companyDetail
=
checkData
(
data
?.
companyDetail
);
this
.
email
=
checkData
(
data
?.
email
);
this
.
emailContact
=
checkData
(
data
?.
emailContact
);
this
.
engFirstnameContact
=
checkData
(
data
?.
engFirstnameContact
);
this
.
engLastnameContact
=
checkData
(
data
?.
engLastnameContact
);
this
.
engName
=
checkData
(
data
?.
engName
);
this
.
facebookSocial
=
checkData
(
data
?.
facebookSocial
);
this
.
fax
=
checkData
(
data
?.
fax
);
this
.
faxContact
=
checkData
(
data
?.
faxContact
);
this
.
industrialEstate
=
checkData
(
data
?.
industrialEstate
);
this
.
latitude
=
checkData
(
data
?.
latitude
);
this
.
line
=
checkData
(
data
?.
line
);
this
.
longitude
=
checkData
(
data
?.
longitude
);
this
.
map
=
checkData
(
data
?.
map
);
this
.
phone
=
checkData
(
data
?.
phone
);
this
.
phoneContact
=
checkData
(
data
?.
phoneContact
);
this
.
photoGraph
=
checkData
(
data
?.
photoGraph
);
this
.
province
=
data
?.
province
?
new
ProvinceModel
(
data
?.
province
,
translateService
)
:
null
;
this
.
provinceContact
=
data
?.
provinceContact
?
new
ProvinceModel
(
data
?.
provinceContact
,
translateService
)
:
null
;
this
.
subDistrict
=
data
?.
subDistrict
?
new
SubDistrictModel
(
data
?.
subDistrict
,
translateService
)
:
null
;
this
.
subDistrictContact
=
data
?.
subDistrictContact
?
new
SubDistrictModel
(
data
?.
subDistrictContact
,
translateService
)
:
null
;
this
.
taxPayer
=
checkData
(
data
?.
taxPayer
);
this
.
telContact
=
checkData
(
data
?.
telContact
);
this
.
thFirstnameContact
=
checkData
(
data
?.
thFirstnameContact
);
this
.
thLastnameContact
=
checkData
(
data
?.
thLastnameContact
);
this
.
thName
=
checkData
(
data
?.
thName
);
this
.
twitterSocial
=
checkData
(
data
?.
twitterSocial
);
this
.
video
=
checkData
(
data
?.
video
);
this
.
webSite
=
checkData
(
data
?.
webSite
);
this
.
websiteContact
=
checkData
(
data
?.
websiteContact
);
this
.
websiteSocial
=
checkData
(
data
?.
websiteSocial
);
this
.
status
=
checkData
(
data
?.
status
);
// เพิ่มบรรทัดนี้:
this
.
updatedAt
=
checkData
(
data
?.
updatedAt
);
// ดึงค่า updatedAt จากข้อมูลที่ได้รับ
}
getPicture
()
{
if
(
this
.
photoGraph
)
{
return
environment
.
baseUrl
+
"/files/image/"
+
this
.
photoGraph
;
}
else
{
return
"assets/img/icon/icon_employer.png"
;
}
}
getStatus
():
string
{
if
(
this
.
status
==
1
)
{
return
this
.
translateService
.
instant
(
'PUBLIC'
);
}
else
{
return
this
.
translateService
.
instant
(
'PENDING'
);
}
}
getName
()
{
return
baseGetName
(
this
.
thName
,
this
.
engName
,
this
.
translateService
?.
currentLang
);
}
}
\ No newline at end of file
src/app/DPU/models/province.model.ts
View file @
f02270be
import
{
TranslateService
}
from
"@ngx-translate/core"
;
import
{
BaseModel
,
baseGetName
,
checkData
}
from
"./base.model"
;
import
{
CountryModel
}
from
"./country.model"
;
import
{
RegionModel
}
from
"./region.model"
;
import
{
RegionModel
}
from
"./Region.model"
;
export
interface
ProvinceModel
{
provinceId
:
string
shortTname
:
string
...
...
src/app/DPU/services/company.service.ts
View file @
f02270be
...
...
@@ -12,7 +12,7 @@ import { CompanyModel } from '../models/company.model';
})
export
class
CompanyService
{
apiBaseUrl
=
"/company
s
"
;
apiBaseUrl
=
"/company"
;
constructor
(
private
http
:
HttpClient
,
private
translateService
:
TranslateService
...
...
src/app/DPU/services/companys.service.ts
0 → 100644
View file @
f02270be
// src/app/modules/company/services/companys.service.ts
import
{
HttpClient
,
HttpHeaders
}
from
'@angular/common/http'
;
import
{
Injectable
}
from
'@angular/core'
;
import
{
forkJoin
,
map
,
Observable
,
switchMap
}
from
'rxjs'
;
import
{
environment
}
from
"../../../environments/environment"
;
import
{
CompanyModelS
}
from
'../models/companys.mode'
;
import
{
PageResponseModel
}
from
'../models/base.model'
;
// ตรวจสอบว่ามี BaseModel ใน base.model.ts
@
Injectable
({
providedIn
:
'root'
})
export
class
CompanyServiceS
{
api
=
"/company"
;
urlApi
=
environment
.
baseUrl
+
"/company"
;
constructor
(
private
http
:
HttpClient
)
{
}
getById
(
companyId
:
string
):
Observable
<
CompanyModelS
>
{
return
this
.
http
.
get
<
CompanyModelS
>
(
this
.
urlApi
+
"/"
+
companyId
);
}
getList
():
Observable
<
CompanyModelS
[]
>
{
return
this
.
http
.
get
<
CompanyModelS
[]
>
(
this
.
urlApi
+
"/list"
);
}
getListByPageSize
(
body
:
{
page
:
number
;
size
:
number
}):
Observable
<
PageResponseModel
<
CompanyModelS
>>
{
return
this
.
http
.
get
<
PageResponseModel
<
CompanyModelS
>>
(
this
.
urlApi
,
{
params
:
body
}).
pipe
(
map
((
page
)
=>
{
return
{
...
page
,
content
:
page
.
content
.
map
((
e
)
=>
new
CompanyModelS
(
e
)),
};
})
);
}
getAllListByPageSize
():
Observable
<
CompanyModelS
[]
>
{
return
this
.
http
.
get
<
PageResponseModel
<
CompanyModelS
>>
(
this
.
urlApi
,
{
params
:
{
page
:
0
,
size
:
1
}
}).
pipe
(
switchMap
((
checkData
:
any
)
=>
{
const
size
=
500
;
const
totalElements
=
checkData
.
totalElements
;
const
numOfPages
=
Math
.
ceil
(
totalElements
/
size
);
const
parallelList
:
Observable
<
PageResponseModel
<
CompanyModelS
>>
[]
=
[];
for
(
let
page
=
0
;
page
<
numOfPages
;
page
++
)
{
parallelList
.
push
(
this
.
getListByPageSize
({
page
,
size
,
}));
}
return
forkJoin
(
parallelList
).
pipe
(
map
((
response
)
=>
{
let
data
:
CompanyModelS
[]
=
[];
for
(
let
i
=
0
;
i
<
response
.
length
;
i
++
)
{
data
=
data
.
concat
(
response
[
i
].
content
);
}
return
data
;
})
);
})
);
}
saveOrUpdateCompany
(
body
:
CompanyModelS
):
Observable
<
any
>
{
return
this
.
http
.
post
(
this
.
urlApi
,
body
);
// ใช้ POST สำหรับทั้งคู่
}
// deleteCompany(body: CompanyModelS): Observable<any> {
// const options = {
// headers: new HttpHeaders({
// "Content-Type": "application/json",
// }),
// body: body, // ส่ง body ไปด้วยใน request DELETE
// };
// return this.http.delete(this.urlApi, options);
// }
deleteCompany
(
companyId
:
string
):
Observable
<
any
>
{
// รับแค่ string companyId
const
options
=
{
headers
:
new
HttpHeaders
({
"Content-Type"
:
"application/json"
,
}),
// สร้าง Object ที่มีแค่ companyId
body
:
{
companyId
:
companyId
},
};
return
this
.
http
.
delete
(
this
.
urlApi
,
options
);
}
getComGroup
(
companyId
:
string
):
Observable
<
CompanyModelS
[]
>
{
return
this
.
http
.
get
<
CompanyModelS
[]
>
(
this
.
urlApi
+
"/group-checked?companyId="
+
companyId
);
}
}
// import { HttpClient, HttpHeaders } from '@angular/common/http';
// import { Injectable } from '@angular/core';
// import { forkJoin, map, Observable, switchMap } from 'rxjs';
// import { environment } from "../../../environments/environment";
// import { CompanyModelS } from '../models/companys.mode';
// import { PageResponseModel } from '../models/base.model';
// @Injectable({
// providedIn: 'root'
// })
// export class CompanyServiceS {
// api = "/company"
// urlApi = environment.baseUrl + "/company"
// constructor(private http: HttpClient) { }
// getById(companyId: string): Observable<CompanyModelS> {
// return this.http.get<CompanyModelS>(this.urlApi + "/" + companyId)
// }
// getList(): Observable<CompanyModelS[]> {
// return this.http.get<CompanyModelS[]>(this.urlApi + "/list")
// }
// getListByPageSize(body: { page: number; size: number }) {
// return this.http.get<PageResponseModel<CompanyModelS>>(this.urlApi, { params: body, }).pipe(
// map((page) => {
// return {
// ...page, content: page.content.map((e) => new CompanyModelS(e)),
// };
// })
// );
// }
// getAllListByPageSize(): Observable<CompanyModelS[]> {
// return this.http.get<PageResponseModel<CompanyModelS>>(this.urlApi, { params: { page: 0, size: 1 }, }).pipe(switchMap((checkData: any) => {
// const size = 500;
// const numOfPages = checkData.totalElements / size;
// const parallelList: Observable<PageResponseModel<CompanyModelS>>[] = [];
// for (let page = 0; page < numOfPages; page++) {
// parallelList.push(this.getListByPageSize({
// page,
// size,
// }));
// }
// return forkJoin(parallelList).pipe(
// map((response) => {
// let data: CompanyModelS[] = [];
// for (let i = 0; i < response.length; i++) {
// data = data.concat(response[i].content);
// }
// return data;
// })
// );
// }));
// }
// postCompany(body: CompanyModelS) {
// return this.http.post(this.urlApi, body)
// }
// deleteCompany(body: CompanyModelS) {
// const options = {
// headers: new HttpHeaders({
// "Content-Type": "application/json",
// }),
// body: body,
// };
// return this.http.delete(this.urlApi, options)
// }
// getComGroup(companyId: string): Observable<CompanyModelS[]> {
// return this.http.get<CompanyModelS[]>(this.urlApi + "/group-checked?companyId="+companyId)
// }
// }
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