Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
myAppraisal
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
myAppraisal
Commits
34557a4c
Commit
34557a4c
authored
Nov 27, 2024
by
LAPTOP-CV4JFSHE\kantavee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
api bu2
parent
c24c76a6
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
107 additions
and
34 deletions
+107
-34
department-list.component.html
...iness-unit/department-list/department-list.component.html
+0
-0
department-list.component.ts
...usiness-unit/department-list/department-list.component.ts
+49
-33
dashboard.module.ts
src/app/components/dashboard/dashboard.module.ts
+2
-1
bu2.model.ts
src/app/shared/model/bu2.model.ts
+24
-0
bu1.service.ts
src/app/shared/services/bu1.service.ts
+3
-0
bu2.service.ts
src/app/shared/services/bu2.service.ts
+29
-0
No files found.
src/app/components/company-registration/branch-business-unit/department-list/department-list.component.html
View file @
34557a4c
This diff is collapsed.
Click to expand it.
src/app/components/company-registration/branch-business-unit/department-list/department-list.component.ts
View file @
34557a4c
import
{
Component
,
EventEmitter
,
Input
,
Output
}
from
'@angular/core'
;
import
{
Component
,
EventEmitter
,
Input
,
OnInit
,
}
from
'@angular/core'
;
import
{
Bu1Model
,
MyBu1Model
}
from
'src/app/shared/model/bu1.model'
;
import
{
Bu2Model
,
MyBu2Model
}
from
'src/app/shared/model/bu2.model'
;
import
{
Bu1Service
}
from
'src/app/shared/services/bu1.service'
;
import
{
Bu2Service
}
from
'src/app/shared/services/bu2.service'
;
@
Component
({
selector
:
'app-department-list'
,
templateUrl
:
'./department-list.component.html'
,
styleUrls
:
[
'./department-list.component.scss'
]
})
export
class
DepartmentListComponent
{
modalOptions
:
{
[
nameModal
:
string
]:
{
// ชื่อตรวจสอบการเปิดปิด
isModalOpen
:
boolean
;
// เปิด/ปิด
modalSize
:
string
;
// ขนาดของ Modal (s,m,l,vw10-vw100 )
backdropClose
:
boolean
;
// (คลิก Backdrop แล้ว true ปิด false ไม่ปิด )
export
class
DepartmentListComponent
implements
OnInit
{
currentPage
=
1
page
=
Array
.
from
({
length
:
1
},
(
_
,
i
)
=>
i
+
1
);
bu2List
:
Bu2Model
[]
=
[]
bu2
:
Bu2Model
=
new
MyBu2Model
({})
bu1
:
Bu1Model
=
new
MyBu1Model
({})
search
=
""
constructor
(
private
bu2Service
:
Bu2Service
,
private
bu1Service
:
Bu1Service
)
{
}
ngOnInit
():
void
{
this
.
getBu2List
()
}
}
=
{
"add"
:
{
isModalOpen
:
false
,
modalSize
:
'm'
,
backdropClose
:
true
,
},
"edit"
:
{
isModalOpen
:
false
,
modalSize
:
'm'
,
backdropClose
:
true
,
getBu2List
()
{
this
.
bu2Service
.
getList
().
subscribe
(
response
=>
{
console
.
log
(
"31313 : "
,
response
)
this
.
bu2List
=
response
this
.
searchChange
()
})
}
searchChange
()
{
this
.
currentPage
=
1
this
.
page
=
Array
.
from
({
length
:
Math
.
ceil
(
this
.
bu2ListFilter
().
length
/
10
)
},
(
_
,
i
)
=>
i
+
1
);
}
openModal
(
name
:
string
,
size
:
string
,
closeOnBackdrop
?:
boolean
)
{
this
.
modalOptions
[
name
].
modalSize
=
size
;
this
.
modalOptions
[
name
].
backdropClose
=
closeOnBackdrop
||
false
;
this
.
modalOptions
[
name
].
isModalOpen
=
true
;
document
.
body
.
style
.
overflow
=
'hidden'
;
// ล็อก Scroll
bu2ListFilter
()
{
return
this
.
bu2List
.
filter
(
x
=>
x
.
bu2id
.
toLowerCase
().
includes
(
this
.
search
)
||
x
.
tdesc
.
toLowerCase
().
includes
(
this
.
search
)
||
x
.
edesc
.
toLowerCase
().
includes
(
this
.
search
))
}
closeModal
(
name
:
string
)
{
this
.
modalOptions
[
name
].
isModalOpen
=
false
;
// ตรวจสอบว่ามี Modal อื่นเปิดอยู่หรือไม่
if
(
!
this
.
isAnyModalOpen
())
{
document
.
body
.
style
.
overflow
=
''
;
// คืนค่าการ Scroll เฉพาะเมื่อ Modal ทั้งหมดปิดแล้ว
selectBu2
(
bu2
:
Bu2Model
)
{
this
.
bu1Service
.
getById
(
bu2
.
parent
).
subscribe
(
response
=>
{
this
.
bu1
=
response
console
.
log
(
this
.
bu1
)
})
this
.
bu2
=
new
MyBu2Model
(
bu2
)
}
addBu2
()
{
// this.bu2Service.post(this.bu2).subscribe((response:any) => {
// if (response.success) {
// this.getBu2List()
// }
// })
}
isAnyModalOpen
():
boolean
{
// Logic ตรวจสอบว่า Modal อื่นยังเปิดอยู่หรือไม่
return
Object
.
values
(
this
.
modalOptions
).
some
(
modal
=>
modal
.
isModalOpen
);
// หากไม่มี Modal อื่นเปิด
deleteBu2
(
bu2
:
Bu2Model
)
{
// this.bu2Service.delete(new MyBu2Model(bu2)).subscribe((response:any) => {
// if (response.success) {
// this.getBu2List()
// }
// })
}
}
...
...
src/app/components/dashboard/dashboard.module.ts
View file @
34557a4c
...
...
@@ -41,6 +41,7 @@ import { HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http';
import
{
Bu1Service
}
from
'src/app/shared/services/bu1.service'
;
import
{
HttpRequestInterceptor
}
from
'src/app/shared/services/http-request.interceptor'
;
import
{
FormsModule
}
from
'@angular/forms'
;
import
{
Bu2Service
}
from
'src/app/shared/services/bu2.service'
;
@
NgModule
({
declarations
:
[
...
...
@@ -88,7 +89,7 @@ import { FormsModule } from '@angular/forms';
HttpClientModule
,
FormsModule
],
providers
:
[
Bu1Service
,
{
providers
:
[
Bu1Service
,
Bu2Service
,
{
provide
:
HTTP_INTERCEPTORS
,
useClass
:
HttpRequestInterceptor
,
multi
:
true
,
...
...
src/app/shared/model/bu2.model.ts
0 → 100644
View file @
34557a4c
export
interface
Bu2Model
{
bu2id
:
string
;
tdesc
:
string
;
edesc
:
string
;
parent
:
string
;
companyId
:
string
;
}
export
class
MyBu2Model
implements
Bu2Model
{
bu2id
:
string
;
tdesc
:
string
;
edesc
:
string
;
parent
:
string
;
companyId
:
string
;
constructor
(
data
:
Partial
<
Bu2Model
>
)
{
this
.
bu2id
=
data
.
bu2id
||
""
this
.
tdesc
=
data
.
tdesc
||
""
this
.
edesc
=
data
.
edesc
||
""
this
.
parent
=
data
.
parent
||
""
this
.
companyId
=
data
.
companyId
||
""
}
}
src/app/shared/services/bu1.service.ts
View file @
34557a4c
...
...
@@ -14,6 +14,9 @@ export class Bu1Service {
getList
():
Observable
<
Bu1Model
[]
>
{
return
this
.
http
.
get
<
Bu1Model
[]
>
(
this
.
urlApi
+
"/lists"
)
}
getById
(
bu1id
:
string
):
Observable
<
Bu1Model
>
{
return
this
.
http
.
get
<
Bu1Model
>
(
this
.
urlApi
+
"/"
+
bu1id
)
}
// post(body: Bu1Model) {
// return this.http.post(this.urlApi, body)
// }
...
...
src/app/shared/services/bu2.service.ts
0 → 100644
View file @
34557a4c
import
{
HttpClient
,
HttpHeaders
}
from
'@angular/common/http'
;
import
{
Injectable
}
from
'@angular/core'
;
import
{
Observable
}
from
'rxjs'
;
import
{
environment
}
from
'src/environments/environment'
;
import
{
Bu2Model
}
from
'../model/bu2.model'
;
@
Injectable
({
providedIn
:
'root'
})
export
class
Bu2Service
{
api
=
"/bu2"
urlApi
=
environment
.
baseUrl
+
this
.
api
constructor
(
private
http
:
HttpClient
)
{
}
getList
():
Observable
<
Bu2Model
[]
>
{
return
this
.
http
.
get
<
Bu2Model
[]
>
(
this
.
urlApi
+
"/lists"
)
}
// post(body: Bu1Model) {
// return this.http.post(this.urlApi, body)
// }
// delete(body: Bu1Model) {
// const options = {
// headers: new HttpHeaders({
// "Content-Type": "application/json",
// }),
// body: body
// };
// return this.http.delete(this.urlApi, options)
// }
}
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