Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
portal-apps-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
portal-apps-manage
Commits
b9c354e1
Commit
b9c354e1
authored
Jul 21, 2025
by
Natthaphat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
จัดการบริษัท แก้ภาษา
parent
956ae068
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
182 additions
and
59 deletions
+182
-59
company-manage.component.html
...p/DPU/common/company-manage/company-manage.component.html
+53
-17
company-manage.component.ts
...app/DPU/common/company-manage/company-manage.component.ts
+110
-37
user-setting.component.html
.../user-management/user-setting/user-setting.component.html
+1
-1
auth.model.ts
src/app/DPU/models/auth.model.ts
+4
-0
companys.mode.ts
src/app/DPU/models/companys.mode.ts
+2
-2
companys.service.ts
src/app/DPU/services/companys.service.ts
+12
-2
No files found.
src/app/DPU/common/company-manage/company-manage.component.html
View file @
b9c354e1
...
...
@@ -82,7 +82,7 @@
</div>
</td>
<td>
<span
class=
"badge bg-{{ item.status == 1 ? 'primary' : '
danger
'}} text-white"
>
<span
class=
"badge bg-{{ item.status == 1 ? 'primary' : '
warning
'}} text-white"
>
{{item.getStatus()}}
</span>
</td>
...
...
@@ -187,13 +187,23 @@
<img
[
src
]="
selectModel
.
getPicture
()"
alt=
""
id=
"profile-img"
>
<span
class=
"badge rounded-full bg-primary avatar-badge"
>
<input
(
click
)="
triggerFileInput
()"
ng2FileSelect
[
uploader
]="
uploaderProfile
"
type=
"file"
name=
"photo"
class=
"absolute w-full h-full opacity-[0]"
id=
"profile-change"
[
disabled
]="
action =
==
'
edit
'"
>
name=
"photo"
class=
"absolute w-full h-full opacity-[0]"
id=
"profile-change"
[
disabled
]="
action =
==
'
edit
'"
>
<i
class=
"fe fe-camera text-[.625rem]"
></i>
</span>
</span>
</div>
</div>
<div
class=
"xl:col-span-12 col-span-12"
*
ngIf=
"action == 'edit'"
>
<label
for=
"companyId"
class=
"form-label"
>
{{'รหัสบริษัท' | translate}}
</label>
<input
type=
"text"
class=
"form-control !bg-input-readonly"
id=
"companyId"
placeholder=
""
[(
ngModel
)]="
selectModel
.
companyId
"
[
disabled
]="
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=
"thName"
class=
"form-label"
>
{{'ชื่อบริษัท ไทย' | translate}}
</label>
<input
type=
"text"
class=
"form-control"
id=
"thName"
placeholder=
""
[(
ngModel
)]="
selectModel
.
thName
"
>
...
...
@@ -209,32 +219,41 @@
</div>
</div>
<div
class=
"xl:col-span-12 col-span-12"
*
ngIf=
"action == 'edit'"
>
<label
for=
"companyId"
class=
"form-label"
>
{{'รหัสบริษัท' | translate}}
</label>
<input
type=
"text"
class=
"form-control !bg-input-readonly"
id=
"companyId"
placeholder=
""
[(
ngModel
)]="
selectModel
.
companyId
"
[
disabled
]="
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=
"email"
class=
"form-label"
>
{{'Email' | translate}}
</label>
<input
type=
"email"
class=
"form-control"
id=
"emailAddress"
placeholder=
"Email Addresss"
[(
ngModel
)]="
selectModel
.
email
"
(
input
)="
filterEngInput
($
event
)"
>
<input
type=
"email"
class=
"form-control"
id=
"emailAddress"
placeholder=
"Email Addresss"
[(
ngModel
)]="
selectModel
.
email
"
(
input
)="
filterEngInput
($
event
)"
>
<div
class=
"text-danger"
*
ngIf=
"!selectModel.email"
>
{{ 'Please fill in information' | translate }}
</div>
<div
class=
"text-danger"
*
ngIf=
"selectModel.email && (!selectModel.email.includes('@'))"
>
{{ 'Invalid email format @' | translate }}
</div>
<div
class=
"text-danger"
*
ngIf=
"selectModel.email && selectModel.email.includes('@') && !selectModel.email.split('@')[1]?.includes('.')"
>
<div
class=
"text-danger"
*
ngIf=
"selectModel.email && selectModel.email.includes('@') && !selectModel.email.split('@')[1]?.includes('.')"
>
{{ 'Invalid email format .' | translate }}
</div>
</div>
<!-- <div class="xl:col-span-
12 col-span-12
">
<!-- <div class="xl:col-span-
6 col-span-12" *ngIf="action !== 'edit'
">
<label for="password" class="form-label">{{'Password' | translate}}</label>
<input type="password" class="form-control" id="emailAddress" placeholder="Choose Password" [(ngModel)]="selectModel.password">
<input type="password" class="form-control" id="password" placeholder="" [(ngModel)]="password">
<div class="text-danger" *ngIf="!password">
{{ 'Please fill in information' | translate }}
</div>
</div>
<div class="xl:col-span-6 col-span-12" *ngIf="action !== 'edit'">
<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 != password)">
{{'Password Not Match' | translate}}
</div>
</div> -->
<!-- <div class="xl:col-span-12 col-span-12">
...
...
@@ -285,9 +304,26 @@
data-hs-overlay=
"#modal-detail"
>
{{'Cancel' | translate}}
</button>
<button
type=
"button"
(
click
)="
save
()"
class=
"ti-btn bg-primary text-white !font-medium"
[
class
.
ti-btn-disabled
]="!
selectModel
.
thName
||!
selectModel
.
engName
"
[
disabled
]="!
selectModel
.
thName
||!
selectModel
.
engName
"
>
<button
*
ngIf=
"action === 'add'"
type=
"button"
(
click
)="
save
()"
class=
"ti-btn bg-primary text-white !font-medium"
[
class
.
ti-btn-disabled
]="!
selectModel
.
thName
||
!
selectModel
.
engName
||
(!
selectModel
.
email
||
isEmailDuplicate
||
!
selectModel
.
email
.
includes
('@')
||
!
selectModel
.
email
.
includes
('.'))"
[
disabled
]="!
selectModel
.
thName
||
!
selectModel
.
engName
||
(!
selectModel
.
email
||
isEmailDuplicate
||
!
selectModel
.
email
.
includes
('@')
||
!
selectModel
.
email
.
includes
('.'))"
>
<!-- !password || !confirmPassword || (confirmPassword !== password)" -->
{{'Save' | translate}}
</button>
<button
*
ngIf=
"action === 'edit'"
type=
"button"
(
click
)="
save
()"
class=
"ti-btn bg-primary text-white !font-medium"
[
class
.
ti-btn-disabled
]="!
selectModel
.
thName
||
!
selectModel
.
engName
||
(!
selectModel
.
email
||
isEmailDuplicate
||
!
selectModel
.
email
.
includes
('@')
||
!
selectModel
.
email
.
includes
('.'))"
[
disabled
]="!
selectModel
.
thName
||
!
selectModel
.
engName
||
(!
selectModel
.
email
||
isEmailDuplicate
||
!
selectModel
.
email
.
includes
('@')
||
!
selectModel
.
email
.
includes
('.'))"
>
{{'Save' | translate}}
</button>
</div>
</div>
...
...
src/app/DPU/common/company-manage/company-manage.component.ts
View file @
b9c354e1
...
...
@@ -14,6 +14,8 @@ import { environment } from '../../../../environments/environment';
import
{
TokenService
}
from
'../../../shared/services/token.service'
;
import
{
CompanyModelS
}
from
'../../models/companys.mode'
;
import
{
CompanyServiceS
}
from
'../../services/companys.service'
;
import
{
AuthModel
}
from
'../../models/auth.model'
;
import
{
RoleModel
}
from
'../../models/role.model'
;
@
Component
({
selector
:
'app-company-manage'
,
...
...
@@ -24,7 +26,6 @@ import { CompanyServiceS } from '../../services/companys.service';
TranslateModule
,
NgSelectModule
,
FormsModule
,
MatPaginator
,
RouterModule
,
FileUploadModule
],
...
...
@@ -42,12 +43,18 @@ export class CompanyManageComponent {
filterList
:
CompanyModelS
[]
=
[];
selectModel
:
CompanyModelS
=
new
CompanyModelS
();
selectedItems
=
new
Map
<
string
,
boolean
>
();
existingEmails
:
CompanyModelS
[]
=
[]
// empList: CompanyModelS[] = [];
// descName = 'engName';
pageIndex
=
0
;
uploaderProfile
:
FileUploader
|
undefined
;
uploadErrorMsg
:
string
=
""
;
password
:
string
=
''
;
confirmPassword
=
""
isEmailDuplicate
=
false
;
get
searchTerm
():
string
{
return
this
.
_searchTerm
;
}
...
...
@@ -136,6 +143,13 @@ export class CompanyManageComponent {
this
.
getCompany
();
}
onEmailChange
(
email
:
string
)
{
const
lowerEmail
=
email
.
trim
().
toLowerCase
();
this
.
isEmailDuplicate
=
this
.
existingEmails
.
some
(
user
=>
user
.
email
&&
user
.
email
.
toLowerCase
()
===
lowerEmail
);
}
filter
(
v
:
string
)
{
return
this
.
itemsList
?.
filter
(
(
x
)
=>
...
...
@@ -158,7 +172,7 @@ export class CompanyManageComponent {
})
.
then
((
willDelete
:
any
)
=>
{
if
(
willDelete
)
{
this
.
comService
.
deleteCompany
(
item
.
companyId
).
subscribe
(
result
=>
{
this
.
comService
.
put
(
item
).
subscribe
(
result
=>
{
swal
(
"ลบสำเร็จ!!"
,
"ลบข้อมูลสำเร็จ"
,
"success"
);
this
.
ngOnInit
();
},
error
=>
{
...
...
@@ -200,6 +214,7 @@ export class CompanyManageComponent {
})
.
then
((
willSave
:
any
)
=>
{
if
(
willSave
)
{
if
(
this
.
action
===
'add'
)
{
this
.
comService
.
saveOrUpdateCompany
(
this
.
selectModel
).
subscribe
(
result
=>
{
console
.
log
(
result
);
swal
(
"บันทึกสำเร็จ!!"
,
"บันทึกข้อมูลสมาชิก"
,
"success"
);
...
...
@@ -209,9 +224,86 @@ export class CompanyManageComponent {
console
.
error
(
"เกิดข้อผิดพลาดในการบันทึก/อัปเดต:"
,
error
);
swal
(
"ข้อผิดพลาด!!"
,
"ไม่สามารถบันทึก/อัปเดตข้อมูลได้"
,
"error"
);
});
}
else
if
(
this
.
action
===
'edit'
)
{
this
.
comService
.
saveOrUpdateCompany
(
this
.
selectModel
).
subscribe
({
next
:
result
=>
{
swal
(
"Update Success!!"
,
"บันทึกข้อมูลบริษัท"
,
"success"
);
this
.
ngOnInit
();
this
.
childModal
?.
nativeElement
.
click
();
},
error
:
err
=>
{
swal
(
"Error"
,
"ไม่สามารถอัปเดตได้"
,
"error"
);
}
});
}
}
});
}
// save() {
// swal({
// title: "คุณแน่ใจหรือไม่?",
// text: "คุณต้องการบันทึกหรือไม่",
// icon: "warning",
// dangerMode: false,
// buttons: ["ยกเลิก", "ยืนยัน"],
// })
// .then((willSave: any) => {
// if (willSave) {
// if (this.action === 'add') {
// const body = new AuthModel();
// body.username = this.selectModel.email;
// body.password = this.password;
// body.role = new RoleModel({ roleId: 'employer' });
// const rawCompany = { ...body.company };
// rawCompany.thName = rawCompany.thName || this.selectModel.thName || "";
// rawCompany.engName = rawCompany.engName || this.selectModel.engName || "";
// rawCompany.email = rawCompany.email || this.selectModel.email || "";
// rawCompany.status = rawCompany.status ?? 1;
// body.company = new CompanyModelS(rawCompany);
// console.log(body);
// this.comService.register(body).subscribe({
// next: res => {
// if (this.selectModel.status === 1) {
// swal("Save Success!!", "บันทึกข้อมูลบริษัท", "success");
// this.ngOnInit();
// this.childModal?.nativeElement.click();
// } else {
// swal("Save Failed", res?.message || "ไม่สามารถลงทะเบียนได้", "warning");
// }
// },
// error: err => {
// console.error('Error response:', err);
// const errorMessage = err?.error?.message || err?.message || 'ไม่ทราบสาเหตุ';
// if (errorMessage.includes('email')) {
// swal("Save Failed", "อีเมลซ้ำหรือไม่ถูกต้อง", "warning");
// } else {
// swal("Error", errorMessage, "error");
// }
// }
// });
// } else if (this.action === 'edit') {
// this.comService.saveOrUpdateCompany(this.selectModel).subscribe({
// next: result => {
// swal("Update Success!!", "บันทึกข้อมูลบริษัท", "success");
// this.ngOnInit();
// this.childModal?.nativeElement.click();
// },
// error: err => {
// swal("Error", "ไม่สามารถอัปเดตได้", "error");
// }
// });
// }
// }
// });
// }
updatePagedItems
()
{
const
startIndex
=
this
.
pageIndex
*
10
;
...
...
@@ -236,54 +328,35 @@ export class CompanyManageComponent {
}
deleteSelect
()
{
let
companyInfo
=
''
;
const
selectedCompanyIdsToDelete
:
string
[]
=
[];
let
employerInfo
=
''
;
this
.
selectedItems
.
forEach
((
isSelected
,
companyId
)
=>
{
if
(
isSelected
)
{
const
item
=
this
.
itemsList
.
find
(
c
=>
c
.
companyId
===
companyId
);
if
(
item
)
{
companyInfo
+=
`
${
this
.
translate
.
instant
(
'บริษัท'
)}
:
${
item
.
thName
}
\n`
;
selectedCompanyIdsToDelete
.
push
(
item
.
companyId
);
const
com
=
this
.
itemsList
.
find
(
com
=>
com
.
companyId
===
companyId
);
if
(
com
)
{
employerInfo
+=
`
${
this
.
translate
.
instant
(
'Fullname'
)}
:
${
com
.
getName
()}
\n`
;
}
}
});
if
(
selectedCompanyIdsToDelete
.
length
===
0
)
{
swal
(
"ข้อผิดพลาด"
,
"กรุณาเลือกบริษัทที่ต้องการลบ"
,
"warning"
);
return
;
}
swal
({
title
:
"
คุณแน่ใจหรือไม่
?"
,
text
:
company
Info
,
title
:
"
Are you sure
?"
,
text
:
employer
Info
,
icon
:
"warning"
,
dangerMode
:
true
,
buttons
:
[
"
ยกเลิก"
,
"ใช่, ลบเลย
!"
],
buttons
:
[
"
Cancel"
,
"Yes, Delete it
!"
],
})
.
then
((
willDelete
:
any
)
=>
{
if
(
willDelete
)
{
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
.
selectedItems
.
forEach
((
isSelected
,
companyId
)
=>
{
if
(
isSelected
)
{
const
com
=
this
.
itemsList
.
find
(
com
=>
com
.
companyId
===
companyId
);
if
(
com
)
{
this
.
comService
.
put
(
com
).
subscribe
(
result
=>
{
swal
(
"Save Success!!"
,
"บันทึกข้อมูลสำเร็จ"
,
"success"
);
this
.
ngOnInit
();
this
.
selectedItems
.
clear
(
);
this
.
allSelected
=
false
;
this
.
someSelected
=
false
;
}
);
}
}
});
}
});
...
...
src/app/DPU/common/user-management/user-setting/user-setting.component.html
View file @
b9c354e1
...
...
@@ -330,7 +330,7 @@
</div>
</div>
<div
class=
"xl:col-span-6 col-span-12"
>
<div
class=
"xl:col-span-6 col-span-12"
*
ngIf=
"action !== 'edit'"
>
<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"
>
...
...
src/app/DPU/models/auth.model.ts
View file @
b9c354e1
...
...
@@ -2,12 +2,14 @@ import { TranslateService } from "@ngx-translate/core"
import
{
BaseModel
}
from
"./base.model"
import
{
RoleModel
}
from
"./role.model"
import
{
ProfileModel
}
from
"./profile.model"
import
{
CompanyModelS
}
from
"./companys.mode"
export
interface
AuthModel
{
username
:
string
password
:
string
role
:
RoleModel
profile
:
ProfileModel
company
:
CompanyModelS
}
export
class
AuthModel
extends
BaseModel
implements
AuthModel
{
...
...
@@ -15,6 +17,7 @@ export class AuthModel extends BaseModel implements AuthModel {
password
:
string
role
:
RoleModel
profile
:
ProfileModel
company
:
CompanyModelS
constructor
(
data
?:
Partial
<
AuthModel
>
,
translateService
?:
TranslateService
)
{
super
(
data
,
translateService
)
...
...
@@ -22,6 +25,7 @@ export class AuthModel extends BaseModel implements AuthModel {
this
.
password
=
data
?.
password
!
this
.
role
=
data
?.
role
?
new
RoleModel
(
data
.
role
,
translateService
)
:
data
?.
role
!
this
.
profile
=
data
?.
profile
?
new
ProfileModel
(
data
.
profile
,
translateService
)
:
data
?.
profile
!
this
.
company
=
data
?.
company
?
new
CompanyModelS
(
data
.
company
,
translateService
)
:
data
?.
company
!
}
}
...
...
src/app/DPU/models/companys.mode.ts
View file @
b9c354e1
...
...
@@ -149,9 +149,9 @@ export class CompanyModelS extends BaseModel implements CompanyModelS {
getStatus
():
string
{
if
(
this
.
status
==
1
)
{
return
this
.
translateService
.
instant
(
'P
UBLIC
'
);
return
this
.
translateService
.
instant
(
'P
ublic
'
);
}
else
{
return
this
.
translateService
.
instant
(
'P
ENDING
'
);
return
this
.
translateService
.
instant
(
'P
ending
'
);
}
}
...
...
src/app/DPU/services/companys.service.ts
View file @
b9c354e1
...
...
@@ -5,7 +5,8 @@ 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
import
{
PageResponseModel
,
ResponseModel
}
from
'../models/base.model'
;
// ตรวจสอบว่ามี BaseModel ใน base.model.ts
import
{
AuthModel
}
from
'../models/auth.model'
;
@
Injectable
({
providedIn
:
'root'
...
...
@@ -13,6 +14,7 @@ import { PageResponseModel } from '../models/base.model'; // ตรวจสอ
export
class
CompanyServiceS
{
api
=
"/admin/manage-company"
;
urlApi
=
environment
.
baseUrl
+
"/admin/manage-company"
;
apiAuthUrl
=
"/auth"
constructor
(
private
http
:
HttpClient
)
{
}
...
...
@@ -21,7 +23,7 @@ export class CompanyServiceS {
}
getList
():
Observable
<
CompanyModelS
[]
>
{
return
this
.
http
.
get
<
CompanyModelS
[]
>
(
this
.
urlApi
+
"/lists"
);
return
this
.
http
.
get
<
CompanyModelS
[]
>
(
this
.
urlApi
+
"/lists
?status=1
"
);
}
getListByPageSize
(
body
:
{
page
:
number
;
size
:
number
}):
Observable
<
PageResponseModel
<
CompanyModelS
>>
{
...
...
@@ -60,6 +62,14 @@ export class CompanyServiceS {
);
}
register
(
body
:
AuthModel
)
{
return
this
.
http
.
post
<
ResponseModel
>
(
this
.
apiAuthUrl
+
"/register"
,
body
);
}
put
(
body
:
CompanyModelS
)
{
return
this
.
http
.
put
<
ResponseModel
>
(
this
.
urlApi
,
new
CompanyModelS
(
body
));
}
saveOrUpdateCompany
(
body
:
CompanyModelS
):
Observable
<
any
>
{
return
this
.
http
.
post
(
this
.
urlApi
,
body
);
// ใช้ POST สำหรับทั้งคู่
}
...
...
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