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
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
201 additions
and
60 deletions
+201
-60
department-list.component.html
...iness-unit/department-list/department-list.component.html
+90
-22
department-list.component.ts
...usiness-unit/department-list/department-list.component.ts
+53
-37
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
...
...
@@ -2,7 +2,9 @@
<div
class=
"px-1"
>
<div
class=
"relative shadow-md"
>
<input
type=
"text"
id=
"hs-leading-icon"
name=
"hs-leading-icon"
class=
"ti-form-input ltr:pl-11 rtl:pr-11 focus:z-10 "
placeholder=
"Search by No. or Name"
>
class=
"ti-form-input ltr:pl-11 rtl:pr-11 focus:z-10 "
placeholder=
"Search by No. or Name"
[(
ngModel
)]="
search
"
(
ngModelChange
)="
searchChange
()"
>
<div
class=
"absolute inset-y-0 ltr:left-0 rtl:right-0 flex items-center pointer-events-none z-20 ltr:pl-4 rtl:pr-4"
>
<i
class=
"ri-search-line text-gray"
></i>
...
...
@@ -60,25 +62,54 @@
</ng-container>
</tr>
</thead>
<tbody>
<tr
*
ngFor=
"let item of[
['ACC', 'งานบัญชีเเละการเงิน', 'Accounting and Finance'],
['ACC', 'งานบัญชีเเละการเงิน', 'Accounting and Finance'],
['ACC', 'งานบัญชีเเละการเงิน', 'Accounting and Finance'],
['ACC', 'งานบัญชีเเละการเงิน', 'Accounting and Finance'],
['ACC', 'งานบัญชีเเละการเงิน', 'Accounting and Finance']];let i = index"
>
<td
class=
"flex justify-center"
style=
"font-size: 12px;"
>
{{0+""+(i+1)}}
</td>
<td
style=
"font-size: 12px;"
>
{{item[0]}}
</td>
<td
style=
"font-size: 12px;"
>
{{item[1]}}
</td>
<td
style=
"font-size: 12px;"
>
{{item[2]}}
</td>
<tbody
*
ngIf=
"!bu2ListFilter().length"
>
<tr>
<td
class=
"text-center"
colspan=
"100%"
>
ไม่พบข้อมูล
</td>
</tr>
</tbody>
<tbody
*
ngIf=
"bu2ListFilter().length"
>
<tr
*
ngFor=
"let item of bu2ListFilter() | slice:((currentPage-1) * 10) : (((currentPage-1) * 10) + 10);let i = index"
>
<td
class=
"flex justify-center"
>
<i
class=
"ti ti-edit cursor-pointer i-gray fs-l px-1"
data-hs-overlay=
"#department-list-modal-edit"
></i>
<i
class=
"ti ti-trash cursor-pointer i-gray fs-l px-1"
></i>
{{((currentPage-1) * 10)+(i+1)}}
</td>
<td>
{{item.bu2id}}
</td>
<td>
{{item.tdesc}}
</td>
<td>
{{item.edesc}}
</td>
<td
class=
"flex justify-center"
>
<i
class=
"ti ti-edit cursor-pointer i-gray fs-l px-1"
(
click
)="
selectBu2
(
item
)"
data-hs-overlay=
"#department-list-modal-edit"
></i>
<i
class=
"ti ti-trash cursor-pointer i-gray fs-l px-1"
(
click
)="
deleteBu2
(
item
)"
></i>
</td>
</tr>
</tbody>
</table>
</div>
<nav
class=
"pagination-style-3 overflow-auto my-5"
*
ngIf=
"page.length"
>
<ul
class=
"ti-pagination"
>
<li>
<a
aria-label=
"anchor"
class=
"page-link"
href=
"javascript:void(0);"
(
click
)="
currentPage =
(currentPage-1
||
1
)"
>
<i
class=
"ri-arrow-left-s-line align-middle rtl:rotate-180"
></i>
</a>
</li>
<li
*
ngFor=
"let item of page"
>
<a
class=
"page-link"
href=
"javascript:void(0);"
[
class
.
active
]="
item=
=currentPage"
(
click
)="
currentPage=
item"
>
{{item}}
</a>
<!-- <a aria-label="anchor" class="page-link" href="javascript:void(0);"><i class="ri-more-line"></i>
</a> -->
</li>
<li>
<a
aria-label=
"anchor"
class=
"page-link"
href=
"javascript:void(0);"
(
click
)="
currentPage =
(currentPage
>
page.length-1 ? currentPage: currentPage+1 )">
<i
class=
"ri-arrow-right-s-line align-middle rtl:rotate-180"
></i>
</a>
</li>
</ul>
</nav>
</div>
</div>
...
...
@@ -163,7 +194,7 @@
</div>
</div>
<label
for=
"detail_th"
class=
"ti-form-label mt-2rem"
>
รายละเอียด (ไทย)
</label>
<input
type=
"text"
id=
"detail_th"
class=
"ti-form-input h-16"
placeholder=
""
>
<input
type=
"text"
id=
"detail_th"
class=
"ti-form-input h-16"
>
<label
for=
"detail_eng"
class=
"ti-form-label mt-2rem"
>
รายละเอียด (อังกฤษ)
</label>
<input
type=
"text"
id=
"detail_eng"
class=
"ti-form-input h-16"
placeholder=
""
>
<div
class=
"flex justify-end mt-2rem mb-1rem space-x-4"
>
...
...
@@ -172,7 +203,8 @@
data-hs-overlay=
"#department-list-modal-add"
>
ย้อนกลับ
</button>
<a
class=
"ti-btn ti-btn-success"
href=
"javascript:void(0);"
>
<a
class=
"ti-btn ti-btn-success"
href=
"javascript:void(0);"
data-hs-overlay=
"#department-list-alert-modal"
>
บันทึกข้อมูล
</a>
</div>
...
...
@@ -227,7 +259,7 @@
<div
class=
"relative w-full"
>
<div>
<div
class=
"relative flex rounded-md"
>
<input
type=
"text"
id=
"hs-leading-button-add-on-with-icon-and-button"
name=
"hs-leading-button-add-on-with-icon-and-button"
class=
"ti-form-input rounded-none ltr:rounded-r-md rtl:rounded-l-md focus:z-10"
style=
"padding-right: 3.5rem;"
>
<input
type=
"text"
id=
"hs-leading-button-add-on-with-icon-and-button"
name=
"hs-leading-button-add-on-with-icon-and-button"
class=
"ti-form-input rounded-none ltr:rounded-r-md rtl:rounded-l-md focus:z-10"
style=
"padding-right: 3.5rem;"
[(
ngModel
)]="
bu1
.
bu1id
"
readonly
>
<div
class=
"absolute inset-y-0 ltr:right-0 rtl:left-0 flex items-center pointer-events-none z-20 ltr:pr-4 rtl:pl-4 space-x-2"
>
<i
class=
"ti ti-circle-x text-red-500 cursor-pointer right-10"
></i>
<svg
class=
"h-3.5 w-3.5 text-gray-500 dark:text-white/70"
xmlns=
"http://www.w3.org/2000/svg"
width=
"16"
height=
"16"
fill=
"currentColor"
viewBox=
"0 0 16 16"
>
...
...
@@ -238,7 +270,7 @@
</div>
</div>
<div
class=
"flex flex-col-6"
>
<input
type=
"text"
id=
"input-label"
class=
"ti-form-input w-full"
style=
"background-color: #B3B3B3; margin-left:10px;"
disabled
value=
"ฝ่าย
1
"
>
<input
type=
"text"
id=
"input-label"
class=
"ti-form-input w-full"
style=
"background-color: #B3B3B3; margin-left:10px;"
disabled
value=
"ฝ่าย
"
[(
ngModel
)]="
bu1
.
tdesc
"
>
</div>
</div>
</div>
...
...
@@ -246,20 +278,56 @@
<label
for=
"input-label"
class=
"ti-form-label mt-2rem"
>
เเผนก
</label>
<div
class=
"sm:grid grid-cols-2 gap-1"
>
<div
class=
"relative w-full"
>
<input
type=
"text"
id=
"input-label"
class=
"ti-form-input w-full pr-10 "
style=
"background-color: #B3B3B3;"
value=
"01
"
>
<input
type=
"text"
id=
"input-label"
class=
"ti-form-input w-full pr-10 "
style=
"background-color: #B3B3B3;"
[
value
]="
bu2
.
bu2id
"
>
</div>
</div>
<label
for=
"detail_th"
class=
"ti-form-label mt-2rem"
>
รายละเอียด (ไทย)
</label>
<input
type=
"text"
id=
"detail_th"
class=
"ti-form-input h-16"
placeholder=
""
value=
"แผนก 1"
>
<input
type=
"text"
id=
"detail_th"
class=
"ti-form-input h-16"
[(
ngModel
)]="
bu2
.
tdesc
"
>
<label
for=
"detail_eng"
class=
"ti-form-label mt-2rem"
>
รายละเอียด (อังกฤษ)
</label>
<input
type=
"text"
id=
"detail_eng"
class=
"ti-form-input h-16"
placeholder=
"
"
>
<input
type=
"text"
id=
"detail_eng"
class=
"ti-form-input h-16"
[(
ngModel
)]="
bu2
.
edesc
"
>
<div
class=
"flex justify-end mt-2rem mb-1rem space-x-4 "
>
<button
type=
"button"
class=
"hs-dropdown-toggle ti-btn ti-border font-medium bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white focus:ring-primary dark:bg-bgdark dark:hover:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-white dark:focus:ring-offset-white/10"
data-hs-overlay=
"#department-list-modal-edit"
>
ย้อนกลับ
</button>
<a
class=
"ti-btn ti-btn-success"
href=
"javascript:void(0);"
>
<a
class=
"ti-btn ti-btn-success"
href=
"javascript:void(0);"
data-hs-overlay=
"#department-list-alert-modal"
>
บันทึกข้อมูล
</a>
</div>
</div>
</div>
</div>
</div>
<div
id=
"department-list-alert-modal"
class=
"hs-overlay hidden ti-modal"
>
<div
class=
"hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out h-[calc(100%-3.5rem)] flex items-center"
>
<div
class=
"max-h-full overflow-hidden ti-modal-content w-full"
>
<div
class=
"ti-modal-header"
>
<h3
class=
"text-xxl font-bold text-primary"
>
แจ้งเตือน
</h3>
<div
class=
"flex justify-end"
>
<button
type=
"button"
class=
"hs-dropdown-toggle ti-modal-clode-btn text-danger"
data-hs-overlay=
"#department-list-alert-modal"
>
<span
class=
"sr-only"
>
Close
</span>
<i
class=
"ti ti-circle-x fs-xxl"
></i>
</button>
</div>
</div>
<div
class=
"ti-modal-body "
>
<p
class=
"mt-1 text-gray-800 dark:text-white/70"
>
ยืนยันการบันทึกข้อมูลหรือไม่
</p>
<div
class=
"flex justify-end mt-2rem mb-1rem"
>
<button
type=
"button"
class=
"hs-dropdown-toggle ti-btn ti-border font-medium bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white focus:ring-primary dark:bg-bgdark dark:hover:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-white dark:focus:ring-offset-white/10"
data-hs-overlay=
"#department-list-alert-modal"
>
ย้อนกลับ
</button>
<a
class=
"ti-btn ti-btn-success"
href=
"javascript:void(0);"
data-hs-overlay=
"#department-list-alert-modal"
(
click
)="
addBu2
()"
>
บันทึกข้อมูล
</a>
</div>
...
...
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 ไม่ปิด )
}
}
=
{
"add"
:
{
isModalOpen
:
false
,
modalSize
:
'm'
,
backdropClose
:
true
,
},
"edit"
:
{
isModalOpen
:
false
,
modalSize
:
'm'
,
backdropClose
:
true
,
}
}
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
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
()
}
closeModal
(
name
:
string
)
{
this
.
modalOptions
[
name
].
isModalOpen
=
false
;
// ตรวจสอบว่ามี Modal อื่นเปิดอยู่หรือไม่
if
(
!
this
.
isAnyModalOpen
())
{
document
.
body
.
style
.
overflow
=
''
;
// คืนค่าการ Scroll เฉพาะเมื่อ Modal ทั้งหมดปิดแล้ว
}
getBu2List
()
{
this
.
bu2Service
.
getList
().
subscribe
(
response
=>
{
console
.
log
(
"31313 : "
,
response
)
this
.
bu2List
=
response
this
.
searchChange
()
})
}
isAnyModalOpen
():
boolean
{
// Logic ตรวจสอบว่า Modal อื่นยังเปิดอยู่หรือไม่
return
Object
.
values
(
this
.
modalOptions
).
some
(
modal
=>
modal
.
isModalOpen
);
// หากไม่มี Modal อื่นเปิด
searchChange
()
{
this
.
currentPage
=
1
this
.
page
=
Array
.
from
({
length
:
Math
.
ceil
(
this
.
bu2ListFilter
().
length
/
10
)
},
(
_
,
i
)
=>
i
+
1
);
}
bu2ListFilter
()
{
return
this
.
bu2List
.
filter
(
x
=>
x
.
bu2id
.
toLowerCase
().
includes
(
this
.
search
)
||
x
.
tdesc
.
toLowerCase
().
includes
(
this
.
search
)
||
x
.
edesc
.
toLowerCase
().
includes
(
this
.
search
))
}
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()
// }
// })
}
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