Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mySkill-x
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
mySkill-x
Commits
3eeeb5e5
Commit
3eeeb5e5
authored
Feb 07, 2025
by
DESKTOP-HBB3MIJ\myHR
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ทะเบียนแผนก, ทะเบียนส่วน, ส่วนย่อย1, ส่วนย่อย2, ส่วนย่อย3, ส่วนย่อย4 import file
parent
b490b796
Show whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
795 additions
and
175 deletions
+795
-175
department-list.component.html
...iness-unit/department-list/department-list.component.html
+46
-4
department-list.component.ts
...usiness-unit/department-list/department-list.component.ts
+81
-21
section-registration.component.html
.../section-registration/section-registration.component.html
+46
-4
section-registration.component.ts
...it/section-registration/section-registration.component.ts
+82
-21
sub-department-four.component.html
...it/sub-department-four/sub-department-four.component.html
+46
-4
sub-department-four.component.ts
...unit/sub-department-four/sub-department-four.component.ts
+81
-21
sub-department-one.component.html
...unit/sub-department-one/sub-department-one.component.html
+46
-4
sub-department-one.component.ts
...s-unit/sub-department-one/sub-department-one.component.ts
+81
-21
sub-department-three.component.html
.../sub-department-three/sub-department-three.component.html
+46
-4
sub-department-three.component.ts
...it/sub-department-three/sub-department-three.component.ts
+81
-21
sub-department-two.component.html
...unit/sub-department-two/sub-department-two.component.html
+47
-5
sub-department-two.component.ts
...s-unit/sub-department-two/sub-department-two.component.ts
+81
-21
bu2.service.ts
src/app/shared/services/bu2.service.ts
+5
-4
bu3.service.ts
src/app/shared/services/bu3.service.ts
+6
-4
bu4.service.ts
src/app/shared/services/bu4.service.ts
+5
-4
bu5.service.ts
src/app/shared/services/bu5.service.ts
+5
-4
bu6.service.ts
src/app/shared/services/bu6.service.ts
+5
-4
bu7.service.ts
src/app/shared/services/bu7.service.ts
+5
-4
No files found.
src/app/components/company-components/company-registration/branch-business-unit/department-list/department-list.component.html
View file @
3eeeb5e5
...
...
@@ -3,12 +3,13 @@
<div
class=
"flex pr-2"
>
<!-- Content ของ div แรก -->
<div
class=
"px-1"
>
<button
type=
"button"
class=
"ti-btn ti-btn-soft-secondary h-20px m-0 shadow-md"
>
<button
type=
"button"
class=
"ti-btn ti-btn-soft-secondary h-20px m-0 shadow-md"
data-hs-overlay=
"#department-list-upload-modal"
>
<i
class=
"ri-add-line"
></i>
นำเข้าข้อมูล
</button>
<a
class=
"mx-2 justify-center -mb-px inline-flex items-center gap-2 font-weight-500 font-size-12px text-center text-secondary border-secondary border-b-2 align-items-end"
href=
"javascript:void(0);"
>
href=
"javascript:void(0);"
(
click
)="
downloadFile
()"
>
ดาวน์โหลดตัวอย่างไฟล์
</a>
</div>
...
...
@@ -65,14 +66,24 @@
</ng-container>
</tr>
</thead>
<tbody
*
ngIf=
"!filterBu2Table().length"
>
<tbody
*
ngIf=
"bu2ListLoading"
>
<tr>
<td
class=
"text-center"
colspan=
"100%"
>
<div
*
ngFor=
"let item of [1,2,3]"
class=
"ti-spinner w-8 h-8 text-secondary mx-1"
role=
"status"
aria-label=
"loading"
>
<span
class=
"sr-only"
>
Loading...
</span>
</div>
</td>
</tr>
</tbody>
<tbody
*
ngIf=
"!bu2ListLoading&&!filterBu2Table().length"
>
<tr>
<td
class=
"text-center"
colspan=
"100%"
>
ไม่พบข้อมูล
</td>
</tr>
</tbody>
<tbody
*
ngIf=
"filterBu2Table().length"
>
<tbody
*
ngIf=
"
!bu2ListLoading&&
filterBu2Table().length"
>
<tr
*
ngFor=
"let item of filterBu2Table() | slice:((bu2Table.currentPage-1) * 10) : (((bu2Table.currentPage-1) * 10) + 10);let i = index"
>
<td
class=
"text-center"
>
...
...
@@ -664,3 +675,33 @@
</div>
</div>
</div>
<div
id=
"department-list-upload-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)] rounded-md"
>
<div
class=
"ti-modal-header bg-primary !rounded-none !rounded-t-sm"
>
<h5
class=
"text-xxl font-bold text-white"
>
นำเข้าฝ่าย
</h5>
</div>
<div
class=
"ti-modal-body max-h-full overflow-hidden ti-modal-content !rounded-t-none !rounded-b-sm"
>
<h1
class=
"mt-2"
style=
"text-align: center;"
>
ไฟล์
</h1>
<div
class=
"mt-2 p-2"
>
<div
class=
"flex rounded-md"
>
<input
#
fileInput
type=
"file"
(
change
)="
onFileSelected
($
event
)"
hidden
>
<input
type=
"text"
[
value
]="
selectedFileName
"
readonly
(
click
)="
fileInput
.
click
()"
class=
"ti-form-input rounded-none ltr:rounded-l-md rtl:rounded-r-md focus:z-10 cursor-pointer"
>
<button
type=
"button"
(
click
)="
fileInput
.
click
()"
class=
"inline-flex flex-shrink-0 justify-center items-center h-[2.875rem] w-[2.875rem] ltr:rounded-r-md rtl:rounded-l-md border border-transparent font-semibold bg-secondary text-white hover:bg-secondary focus:z-10 focus:outline-none focus:ring-0 focus:ring-secondary transition-all text-sm"
>
<i
class=
"ti ti-upload"
></i>
</button>
</div>
<div
class=
"flex justify-center mt-2rem mb-1rem space-x-4"
>
<button
type=
"submit"
class=
"ti-btn ti-btn-secondary"
(
click
)="
uploadFile
()"
[
disabled
]="!
selectedFile
"
>
อัปโหลด
</button>
</div>
</div>
</div>
</div>
</div>
\ No newline at end of file
src/app/components/company-components/company-registration/branch-business-unit/department-list/department-list.component.ts
View file @
3eeeb5e5
...
...
@@ -4,6 +4,7 @@ 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'
;
import
{
FileService
}
from
'src/app/shared/services/file.service'
;
interface
table
{
currentPage
:
number
,
page
:
number
[],
...
...
@@ -16,12 +17,17 @@ interface table {
})
export
class
DepartmentListComponent
implements
OnInit
{
bu2List
:
Bu2Model
[]
=
[]
bu2ListLoading
=
false
bu2
:
Bu2Model
=
new
MyBu2Model
({})
bu2Table
:
table
=
{
currentPage
:
1
,
page
:
Array
.
from
({
length
:
1
},
(
_
,
i
)
=>
i
+
1
),
search
:
""
}
selectedFile
:
File
|
null
=
null
;
selectedFileName
:
string
=
'กรุณาเลือกไฟล์'
;
bu2Modal
:
table
=
{
currentPage
:
1
,
page
:
Array
.
from
({
length
:
1
},
(
_
,
i
)
=>
i
+
1
),
...
...
@@ -38,17 +44,71 @@ export class DepartmentListComponent implements OnInit {
constructor
(
private
bu2Service
:
Bu2Service
,
private
bu1Service
:
Bu1Service
,
private
toastr
:
ToastrService
,
private
cdr
:
ChangeDetectorRef
private
cdr
:
ChangeDetectorRef
,
private
fileService
:
FileService
)
{
}
ngOnInit
():
void
{
this
.
getBu2List
()
this
.
getBu1List
()
}
onFileSelected
(
event
:
any
)
{
this
.
selectedFile
=
event
.
target
.
files
.
length
>
0
?
event
.
target
.
files
[
0
]
:
null
;
this
.
selectedFileName
=
this
.
selectedFile
?.
name
||
"กรุณาเลือกไฟล์"
}
uploadFile
()
{
if
(
!
this
.
selectedFile
)
{
alert
(
'กรุณาเลือกไฟล์ก่อนอัปโหลด'
)
return
}
const
formData
=
new
FormData
();
formData
.
append
(
'file'
,
this
.
selectedFile
);
this
.
fileService
.
upload
(
formData
,
'mbu2'
).
subscribe
({
next
:
response
=>
{
if
(
response
.
success
)
{
this
.
showAlert
(
response
.
message
,
'success'
)
this
.
getBu2List
()
}
else
{
this
.
showAlert
(
response
.
message
,
'error'
)
}
},
error
:
error
=>
{
this
.
showAlert
(
error
.
message
,
'error'
)
}
})
}
downloadFile
()
{
const
fileName
=
'IMPORT_BU.xlsx'
this
.
fileService
.
download
(
fileName
).
subscribe
({
next
:
response
=>
{
const
url
=
window
.
URL
.
createObjectURL
(
response
);
const
a
=
document
.
createElement
(
"a"
);
a
.
href
=
url
;
a
.
download
=
fileName
;
document
.
body
.
appendChild
(
a
);
a
.
click
();
document
.
body
.
removeChild
(
a
);
window
.
URL
.
revokeObjectURL
(
url
);
},
error
:
error
=>
{
this
.
showAlert
(
error
.
message
,
'error'
)
}
})
}
getBu2List
()
{
this
.
bu2Service
.
getList
().
subscribe
(
response
=>
{
this
.
bu2ListLoading
=
true
this
.
bu2Service
.
getList
().
subscribe
({
next
:
response
=>
{
this
.
bu2List
=
response
this
.
bu2ListLoading
=
false
this
.
onBu2TableSearchChange
()
this
.
cdr
.
detectChanges
()
},
error
:
error
=>
{
this
.
bu2ListLoading
=
false
this
.
cdr
.
detectChanges
()
}
})
}
onBu2TableSearchChange
()
{
...
...
@@ -108,37 +168,37 @@ export class DepartmentListComponent implements OnInit {
this
.
bu1
=
new
MyBu1Model
(
bu1
||
{})
}
showSuccess
()
{
this
.
toastr
.
success
(
'บันทึกข้อมูลสำเร็จ'
,
'เเจ้งเตือน'
,
{
timeOut
:
3000
,
positionClass
:
'toast-top-right'
,
});
}
showSuccessDelete
()
{
this
.
toastr
.
success
(
'ลบข้อมูลสำเร็จ'
,
'เเจ้งเตือน'
,
{
timeOut
:
3000
,
positionClass
:
'toast-top-right'
,
});
}
showSuccessEdit
()
{
this
.
toastr
.
success
(
'เเก้ไขข้อมูลสำเร็จ'
,
'เเจ้งเตือน'
,
{
showAlert
(
text
:
string
,
type
:
'success'
|
'error'
)
{
this
.
toastr
[
type
](
text
,
'แจ้งเตือน'
,
{
timeOut
:
3000
,
positionClass
:
'toast-top-right'
,
})
;
})
}
addBu2
()
{
this
.
bu2Service
.
post
({
...
this
.
bu2
,
parent
:
this
.
bu1
.
bu1id
}).
subscribe
((
response
:
any
)
=>
{
this
.
bu2Service
.
post
({
...
this
.
bu2
,
parent
:
this
.
bu1
.
bu1id
}).
subscribe
({
next
:
response
=>
{
if
(
response
.
success
)
{
this
.
showSuccess
(
)
this
.
showAlert
(
response
.
message
,
'success'
)
this
.
getBu2List
()
}
else
{
this
.
showAlert
(
response
.
message
,
'error'
)
}
},
error
:
error
=>
{
this
.
showAlert
(
error
.
message
,
'error'
)
}
})
}
deleteBu2
()
{
this
.
bu2Service
.
delete
(
this
.
bu2
).
subscribe
((
response
:
any
)
=>
{
this
.
bu2Service
.
delete
(
this
.
bu2
).
subscribe
({
next
:
response
=>
{
if
(
response
.
success
)
{
this
.
showSuccessDelete
(
)
this
.
showAlert
(
response
.
message
,
'success'
)
this
.
getBu2List
()
}
else
{
this
.
showAlert
(
response
.
message
,
'error'
)
}
},
error
:
error
=>
{
this
.
showAlert
(
error
.
message
,
'error'
)
}
})
}
...
...
src/app/components/company-components/company-registration/branch-business-unit/section-registration/section-registration.component.html
View file @
3eeeb5e5
...
...
@@ -2,12 +2,13 @@
<div
class=
"flex justify-between"
>
<div
class=
"flex pr-2"
>
<div
class=
"px-1"
>
<button
type=
"button"
class=
"ti-btn ti-btn-soft-secondary h-20px m-0 shadow-md"
>
<button
type=
"button"
class=
"ti-btn ti-btn-soft-secondary h-20px m-0 shadow-md"
data-hs-overlay=
"#section-registration-upload-modal"
>
<i
class=
"ri-add-line"
></i>
นำเข้าข้อมูล
</button>
<a
class=
"mx-2 justify-center -mb-px inline-flex items-center gap-2 font-weight-500 font-size-12px text-center text-secondary border-secondary border-b-2 align-items-end"
href=
"javascript:void(0);"
>
href=
"javascript:void(0);"
(
click
)="
downloadFile
()"
>
ดาวน์โหลดตัวอย่างไฟล์
</a>
</div>
...
...
@@ -65,14 +66,24 @@
</ng-container>
</tr>
</thead>
<tbody
*
ngIf=
"!filterBu3Table().length"
>
<tbody
*
ngIf=
"bu3ListLoading"
>
<tr>
<td
class=
"text-center"
colspan=
"100%"
>
<div
*
ngFor=
"let item of [1,2,3]"
class=
"ti-spinner w-8 h-8 text-secondary mx-1"
role=
"status"
aria-label=
"loading"
>
<span
class=
"sr-only"
>
Loading...
</span>
</div>
</td>
</tr>
</tbody>
<tbody
*
ngIf=
"!bu3ListLoading&&!filterBu3Table().length"
>
<tr>
<td
class=
"text-center"
colspan=
"100%"
>
ไม่พบข้อมูล
</td>
</tr>
</tbody>
<tbody
*
ngIf=
"filterBu3Table().length"
>
<tbody
*
ngIf=
"
!bu3ListLoading&&
filterBu3Table().length"
>
<tr
*
ngFor=
"let item of filterBu3Table() | slice:((bu3Table.currentPage-1) * 10) : (((bu3Table.currentPage-1) * 10) + 10);let i = index"
>
<td
class=
"text-center"
>
...
...
@@ -665,3 +676,33 @@
</div>
</div>
</div>
<div
id=
"section-registration-upload-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)] rounded-md"
>
<div
class=
"ti-modal-header bg-primary !rounded-none !rounded-t-sm"
>
<h5
class=
"text-xxl font-bold text-white"
>
นำเข้าฝ่าย
</h5>
</div>
<div
class=
"ti-modal-body max-h-full overflow-hidden ti-modal-content !rounded-t-none !rounded-b-sm"
>
<h1
class=
"mt-2"
style=
"text-align: center;"
>
ไฟล์
</h1>
<div
class=
"mt-2 p-2"
>
<div
class=
"flex rounded-md"
>
<input
#
fileInput
type=
"file"
(
change
)="
onFileSelected
($
event
)"
hidden
>
<input
type=
"text"
[
value
]="
selectedFileName
"
readonly
(
click
)="
fileInput
.
click
()"
class=
"ti-form-input rounded-none ltr:rounded-l-md rtl:rounded-r-md focus:z-10 cursor-pointer"
>
<button
type=
"button"
(
click
)="
fileInput
.
click
()"
class=
"inline-flex flex-shrink-0 justify-center items-center h-[2.875rem] w-[2.875rem] ltr:rounded-r-md rtl:rounded-l-md border border-transparent font-semibold bg-secondary text-white hover:bg-secondary focus:z-10 focus:outline-none focus:ring-0 focus:ring-secondary transition-all text-sm"
>
<i
class=
"ti ti-upload"
></i>
</button>
</div>
<div
class=
"flex justify-center mt-2rem mb-1rem space-x-4"
>
<button
type=
"submit"
class=
"ti-btn ti-btn-secondary"
(
click
)="
uploadFile
()"
[
disabled
]="!
selectedFile
"
>
อัปโหลด
</button>
</div>
</div>
</div>
</div>
</div>
\ No newline at end of file
src/app/components/company-components/company-registration/branch-business-unit/section-registration/section-registration.component.ts
View file @
3eeeb5e5
...
...
@@ -4,6 +4,7 @@ import { Bu2Model, MyBu2Model } from 'src/app/shared/model/bu2.model';
import
{
Bu3Model
,
MyBu3Model
}
from
'src/app/shared/model/bu3.model'
;
import
{
Bu2Service
}
from
'src/app/shared/services/bu2.service'
;
import
{
Bu3Service
}
from
'src/app/shared/services/bu3.service'
;
import
{
FileService
}
from
'src/app/shared/services/file.service'
;
interface
table
{
currentPage
:
number
,
page
:
number
[],
...
...
@@ -16,12 +17,17 @@ interface table {
})
export
class
SectionRegistrationComponent
implements
OnInit
{
bu3List
:
Bu3Model
[]
=
[]
bu3ListLoading
=
false
bu3
:
Bu3Model
=
new
MyBu3Model
({})
bu3Table
:
table
=
{
currentPage
:
1
,
page
:
Array
.
from
({
length
:
1
},
(
_
,
i
)
=>
i
+
1
),
search
:
""
}
selectedFile
:
File
|
null
=
null
;
selectedFileName
:
string
=
'กรุณาเลือกไฟล์'
;
bu3Modal
:
table
=
{
currentPage
:
1
,
page
:
Array
.
from
({
length
:
1
},
(
_
,
i
)
=>
i
+
1
),
...
...
@@ -38,17 +44,72 @@ export class SectionRegistrationComponent implements OnInit {
constructor
(
private
bu3Service
:
Bu3Service
,
private
bu2Service
:
Bu2Service
,
private
toastr
:
ToastrService
,
private
cdr
:
ChangeDetectorRef
private
cdr
:
ChangeDetectorRef
,
private
fileService
:
FileService
)
{
}
ngOnInit
():
void
{
this
.
getBu3List
()
this
.
getBu2List
()
}
onFileSelected
(
event
:
any
)
{
this
.
selectedFile
=
event
.
target
.
files
.
length
>
0
?
event
.
target
.
files
[
0
]
:
null
;
this
.
selectedFileName
=
this
.
selectedFile
?.
name
||
"กรุณาเลือกไฟล์"
}
uploadFile
()
{
if
(
!
this
.
selectedFile
)
{
alert
(
'กรุณาเลือกไฟล์ก่อนอัปโหลด'
)
return
}
const
formData
=
new
FormData
();
formData
.
append
(
'file'
,
this
.
selectedFile
);
this
.
fileService
.
upload
(
formData
,
'mbu3'
).
subscribe
({
next
:
response
=>
{
if
(
response
.
success
)
{
this
.
showAlert
(
response
.
message
,
'success'
)
this
.
getBu3List
()
}
else
{
this
.
showAlert
(
response
.
message
,
'error'
)
}
},
error
:
error
=>
{
this
.
showAlert
(
error
.
message
,
'error'
)
}
})
}
downloadFile
()
{
const
fileName
=
'IMPORT_BU.xlsx'
this
.
fileService
.
download
(
fileName
).
subscribe
({
next
:
response
=>
{
const
url
=
window
.
URL
.
createObjectURL
(
response
);
const
a
=
document
.
createElement
(
"a"
);
a
.
href
=
url
;
a
.
download
=
fileName
;
document
.
body
.
appendChild
(
a
);
a
.
click
();
document
.
body
.
removeChild
(
a
);
window
.
URL
.
revokeObjectURL
(
url
);
},
error
:
error
=>
{
this
.
showAlert
(
error
.
message
,
'error'
)
}
})
}
getBu3List
()
{
this
.
bu3Service
.
getList
().
subscribe
(
response
=>
{
this
.
bu3ListLoading
=
true
this
.
bu3Service
.
getList
().
subscribe
({
next
:
response
=>
{
this
.
bu3List
=
response
this
.
bu3ListLoading
=
false
this
.
onBu3TableSearchChange
()
this
.
cdr
.
detectChanges
()
},
error
:
error
=>
{
this
.
bu3ListLoading
=
false
this
.
cdr
.
detectChanges
()
}
})
}
onBu3TableSearchChange
()
{
...
...
@@ -84,18 +145,30 @@ export class SectionRegistrationComponent implements OnInit {
x
.
edesc
.
includes
(
this
.
bu3Modal
.
search
))
}
addBu3
()
{
this
.
bu3Service
.
post
({
...
this
.
bu3
,
parent
:
this
.
bu2
.
bu2id
}).
subscribe
((
response
:
any
)
=>
{
this
.
bu3Service
.
post
({
...
this
.
bu3
,
parent
:
this
.
bu2
.
bu2id
}).
subscribe
({
next
:
response
=>
{
if
(
response
.
success
)
{
this
.
showAlert
(
response
.
message
,
'success'
)
this
.
getBu3List
()
this
.
showSuccess
()
}
else
{
this
.
showAlert
(
response
.
message
,
'error'
)
}
},
error
:
error
=>
{
this
.
showAlert
(
error
.
message
,
'error'
)
}
})
}
deleteBu3
()
{
this
.
bu3Service
.
delete
(
this
.
bu3
).
subscribe
((
response
:
any
)
=>
{
this
.
bu3Service
.
delete
(
this
.
bu3
).
subscribe
({
next
:
response
=>
{
if
(
response
.
success
)
{
this
.
showAlert
(
response
.
message
,
'success'
)
this
.
getBu3List
()
this
.
showSuccessDelete
()
}
else
{
this
.
showAlert
(
response
.
message
,
'error'
)
}
},
error
:
error
=>
{
this
.
showAlert
(
error
.
message
,
'error'
)
}
})
}
...
...
@@ -123,23 +196,11 @@ export class SectionRegistrationComponent implements OnInit {
this
.
bu2
=
new
MyBu2Model
(
bu2
||
{})
}
show
Success
(
)
{
this
.
toastr
.
success
(
'บันทึกข้อมูลสำเร็จ'
,
'เเ
จ้งเตือน'
,
{
show
Alert
(
text
:
string
,
type
:
'success'
|
'error'
)
{
this
.
toastr
[
type
](
text
,
'แ
จ้งเตือน'
,
{
timeOut
:
3000
,
positionClass
:
'toast-top-right'
,
});
}
showSuccessEdit
()
{
this
.
toastr
.
success
(
'เเก้ไขข้อมูลสำเร็จ'
,
'เเจ้งเตือน'
,
{
timeOut
:
3000
,
positionClass
:
'toast-top-right'
,
});
}
showSuccessDelete
()
{
this
.
toastr
.
success
(
'ลบข้อมูลสำเร็จ'
,
'เเจ้งเตือน'
,
{
timeOut
:
3000
,
positionClass
:
'toast-top-right'
,
});
})
}
}
src/app/components/company-components/company-registration/branch-business-unit/sub-department-four/sub-department-four.component.html
View file @
3eeeb5e5
...
...
@@ -2,12 +2,13 @@
<div
class=
"flex justify-between"
>
<div
class=
"flex pr-2"
>
<div
class=
"px-1"
>
<button
type=
"button"
class=
"ti-btn ti-btn-soft-secondary h-20px m-0 shadow-md"
>
<button
type=
"button"
class=
"ti-btn ti-btn-soft-secondary h-20px m-0 shadow-md"
data-hs-overlay=
"#sub-department-four-upload-modal"
>
<i
class=
"ri-add-line"
></i>
นำเข้าข้อมูล
</button>
<a
class=
"mx-2 justify-center -mb-px inline-flex items-center gap-2 font-weight-500 font-size-12px text-center text-secondary border-secondary border-b-2 align-items-end"
href=
"javascript:void(0);"
>
href=
"javascript:void(0);"
(
click
)="
downloadFile
()"
>
ดาวน์โหลดตัวอย่างไฟล์
</a>
</div>
...
...
@@ -64,14 +65,24 @@
</ng-container>
</tr>
</thead>
<tbody
*
ngIf=
"!filterBu7Table().length"
>
<tbody
*
ngIf=
"bu7ListLoading"
>
<tr>
<td
class=
"text-center"
colspan=
"100%"
>
<div
*
ngFor=
"let item of [1,2,3]"
class=
"ti-spinner w-8 h-8 text-secondary mx-1"
role=
"status"
aria-label=
"loading"
>
<span
class=
"sr-only"
>
Loading...
</span>
</div>
</td>
</tr>
</tbody>
<tbody
*
ngIf=
"!bu7ListLoading&&!filterBu7Table().length"
>
<tr>
<td
class=
"text-center"
colspan=
"100%"
>
ไม่พบข้อมูล
</td>
</tr>
</tbody>
<tbody
*
ngIf=
"filterBu7Table().length"
>
<tbody
*
ngIf=
"
!bu7ListLoading&&
filterBu7Table().length"
>
<tr
*
ngFor=
"let item of filterBu7Table() | slice:((bu7Table.currentPage-1) * 10) : (((bu7Table.currentPage-1) * 10) + 10);let i = index"
>
<td
class=
"text-center"
>
...
...
@@ -660,3 +671,33 @@
</div>
</div>
</div>
<div
id=
"sub-department-four-upload-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)] rounded-md"
>
<div
class=
"ti-modal-header bg-primary !rounded-none !rounded-t-sm"
>
<h5
class=
"text-xxl font-bold text-white"
>
นำเข้าฝ่าย
</h5>
</div>
<div
class=
"ti-modal-body max-h-full overflow-hidden ti-modal-content !rounded-t-none !rounded-b-sm"
>
<h1
class=
"mt-2"
style=
"text-align: center;"
>
ไฟล์
</h1>
<div
class=
"mt-2 p-2"
>
<div
class=
"flex rounded-md"
>
<input
#
fileInput
type=
"file"
(
change
)="
onFileSelected
($
event
)"
hidden
>
<input
type=
"text"
[
value
]="
selectedFileName
"
readonly
(
click
)="
fileInput
.
click
()"
class=
"ti-form-input rounded-none ltr:rounded-l-md rtl:rounded-r-md focus:z-10 cursor-pointer"
>
<button
type=
"button"
(
click
)="
fileInput
.
click
()"
class=
"inline-flex flex-shrink-0 justify-center items-center h-[2.875rem] w-[2.875rem] ltr:rounded-r-md rtl:rounded-l-md border border-transparent font-semibold bg-secondary text-white hover:bg-secondary focus:z-10 focus:outline-none focus:ring-0 focus:ring-secondary transition-all text-sm"
>
<i
class=
"ti ti-upload"
></i>
</button>
</div>
<div
class=
"flex justify-center mt-2rem mb-1rem space-x-4"
>
<button
type=
"submit"
class=
"ti-btn ti-btn-secondary"
(
click
)="
uploadFile
()"
[
disabled
]="!
selectedFile
"
>
อัปโหลด
</button>
</div>
</div>
</div>
</div>
</div>
\ No newline at end of file
src/app/components/company-components/company-registration/branch-business-unit/sub-department-four/sub-department-four.component.ts
View file @
3eeeb5e5
...
...
@@ -4,6 +4,7 @@ import { Bu6Model, MyBu6Model } from 'src/app/shared/model/bu6.model';
import
{
Bu7Model
,
MyBu7Model
}
from
'src/app/shared/model/bu7.model'
;
import
{
Bu6Service
}
from
'src/app/shared/services/bu6.service'
;
import
{
Bu7Service
}
from
'src/app/shared/services/bu7.service'
;
import
{
FileService
}
from
'src/app/shared/services/file.service'
;
interface
table
{
currentPage
:
number
,
...
...
@@ -17,12 +18,17 @@ interface table {
})
export
class
SubDepartmentFourComponent
implements
OnInit
{
bu7List
:
Bu7Model
[]
=
[]
bu7ListLoading
=
false
bu7
:
Bu7Model
=
new
MyBu7Model
({})
bu7Table
:
table
=
{
currentPage
:
1
,
page
:
Array
.
from
({
length
:
1
},
(
_
,
i
)
=>
i
+
1
),
search
:
""
}
selectedFile
:
File
|
null
=
null
;
selectedFileName
:
string
=
'กรุณาเลือกไฟล์'
;
bu7Modal
:
table
=
{
currentPage
:
1
,
page
:
Array
.
from
({
length
:
1
},
(
_
,
i
)
=>
i
+
1
),
...
...
@@ -39,17 +45,71 @@ export class SubDepartmentFourComponent implements OnInit {
constructor
(
private
bu7Service
:
Bu7Service
,
private
bu6Service
:
Bu6Service
,
private
toastr
:
ToastrService
,
private
cdr
:
ChangeDetectorRef
private
cdr
:
ChangeDetectorRef
,
private
fileService
:
FileService
)
{
}
ngOnInit
():
void
{
this
.
getBu7List
()
this
.
getBu6List
()
}
onFileSelected
(
event
:
any
)
{
this
.
selectedFile
=
event
.
target
.
files
.
length
>
0
?
event
.
target
.
files
[
0
]
:
null
;
this
.
selectedFileName
=
this
.
selectedFile
?.
name
||
"กรุณาเลือกไฟล์"
}
uploadFile
()
{
if
(
!
this
.
selectedFile
)
{
alert
(
'กรุณาเลือกไฟล์ก่อนอัปโหลด'
)
return
}
const
formData
=
new
FormData
();
formData
.
append
(
'file'
,
this
.
selectedFile
);
this
.
fileService
.
upload
(
formData
,
'mbu7'
).
subscribe
({
next
:
response
=>
{
if
(
response
.
success
)
{
this
.
showAlert
(
response
.
message
,
'success'
)
this
.
getBu7List
()
}
else
{
this
.
showAlert
(
response
.
message
,
'error'
)
}
},
error
:
error
=>
{
this
.
showAlert
(
error
.
message
,
'error'
)
}
})
}
downloadFile
()
{
const
fileName
=
'IMPORT_BU.xlsx'
this
.
fileService
.
download
(
fileName
).
subscribe
({
next
:
response
=>
{
const
url
=
window
.
URL
.
createObjectURL
(
response
);
const
a
=
document
.
createElement
(
"a"
);
a
.
href
=
url
;
a
.
download
=
fileName
;
document
.
body
.
appendChild
(
a
);
a
.
click
();
document
.
body
.
removeChild
(
a
);
window
.
URL
.
revokeObjectURL
(
url
);
},
error
:
error
=>
{
this
.
showAlert
(
error
.
message
,
'error'
)
}
})
}
getBu7List
()
{
this
.
bu7Service
.
getList
().
subscribe
(
response
=>
{
this
.
bu7ListLoading
=
true
this
.
bu7Service
.
getList
().
subscribe
({
next
:
response
=>
{
this
.
bu7List
=
response
this
.
bu7ListLoading
=
false
this
.
onBu7TableSearchChange
()
this
.
cdr
.
detectChanges
()
},
error
:
error
=>
{
this
.
bu7ListLoading
=
false
this
.
cdr
.
detectChanges
()
}
})
}
onBu7TableSearchChange
()
{
...
...
@@ -85,18 +145,30 @@ export class SubDepartmentFourComponent implements OnInit {
x
.
edesc
.
includes
(
this
.
bu7Modal
.
search
))
}
addBu7
()
{
this
.
bu7Service
.
post
({
...
this
.
bu7
,
parent
:
this
.
bu6
.
bu6id
}).
subscribe
((
response
:
any
)
=>
{
this
.
bu7Service
.
post
({
...
this
.
bu7
,
parent
:
this
.
bu6
.
bu6id
}).
subscribe
({
next
:
response
=>
{
if
(
response
.
success
)
{
this
.
showAlert
(
response
.
message
,
'success'
)
this
.
getBu7List
()
this
.
showSuccessAdd
()
}
else
{
this
.
showAlert
(
response
.
message
,
'error'
)
}
},
error
:
error
=>
{
this
.
showAlert
(
error
.
message
,
'error'
)
}
})
}
deleteBu7
()
{
this
.
bu7Service
.
delete
(
this
.
bu7
).
subscribe
((
response
:
any
)
=>
{
this
.
bu7Service
.
delete
(
this
.
bu7
).
subscribe
({
next
:
response
=>
{
if
(
response
.
success
)
{
this
.
showAlert
(
response
.
message
,
'success'
)
this
.
getBu7List
()
this
.
showSuccessDelete
()
}
else
{
this
.
showAlert
(
response
.
message
,
'error'
)
}
},
error
:
error
=>
{
this
.
showAlert
(
error
.
message
,
'error'
)
}
})
}
...
...
@@ -124,23 +196,11 @@ export class SubDepartmentFourComponent implements OnInit {
this
.
bu6
=
new
MyBu6Model
(
bu6
||
{})
}
show
SuccessAdd
(
)
{
this
.
toastr
.
success
(
'บันทึกข้อมูลสำเร็จ'
,
'แจ้งเตือน'
,
{
show
Alert
(
text
:
string
,
type
:
'success'
|
'error'
)
{
this
.
toastr
[
type
](
text
,
'แจ้งเตือน'
,
{
timeOut
:
3000
,
positionClass
:
'toast-top-right'
,
});
}
showSuccessEdit
()
{
this
.
toastr
.
success
(
'แก้ไขข้อมูลสำเร็จ'
,
'แจ้งเตือน'
,
{
timeOut
:
3000
,
positionClass
:
'toast-top-right'
,
});
}
showSuccessDelete
()
{
this
.
toastr
.
success
(
'ลบข้อมูลสำเร็จ'
,
'แจ้งเตือน'
,
{
timeOut
:
3000
,
positionClass
:
'toast-top-right'
,
});
})
}
}
...
...
src/app/components/company-components/company-registration/branch-business-unit/sub-department-one/sub-department-one.component.html
View file @
3eeeb5e5
...
...
@@ -2,12 +2,13 @@
<div
class=
"flex justify-between"
>
<div
class=
"flex pr-2"
>
<div
class=
"px-1"
>
<button
type=
"button"
class=
"ti-btn ti-btn-soft-secondary h-20px m-0 shadow-md"
>
<button
type=
"button"
class=
"ti-btn ti-btn-soft-secondary h-20px m-0 shadow-md"
data-hs-overlay=
"#sub-department-one-upload-modal"
>
<i
class=
"ri-add-line"
></i>
นำเข้าข้อมูล
</button>
<a
class=
"mx-2 justify-center -mb-px inline-flex items-center gap-2 font-weight-500 font-size-12px text-center text-secondary border-secondary border-b-2 align-items-end"
href=
"javascript:void(0);"
>
href=
"javascript:void(0);"
(
click
)="
downloadFile
()"
>
ดาวน์โหลดตัวอย่างไฟล์
</a>
</div>
...
...
@@ -65,14 +66,24 @@
</ng-container>
</tr>
</thead>
<tbody
*
ngIf=
"!filterBu4Table().length"
>
<tbody
*
ngIf=
"bu4ListLoading"
>
<tr>
<td
class=
"text-center"
colspan=
"100%"
>
<div
*
ngFor=
"let item of [1,2,3]"
class=
"ti-spinner w-8 h-8 text-secondary mx-1"
role=
"status"
aria-label=
"loading"
>
<span
class=
"sr-only"
>
Loading...
</span>
</div>
</td>
</tr>
</tbody>
<tbody
*
ngIf=
"!bu4ListLoading&&!filterBu4Table().length"
>
<tr>
<td
class=
"text-center"
colspan=
"100%"
>
ไม่พบข้อมูล
</td>
</tr>
</tbody>
<tbody
*
ngIf=
"filterBu4Table().length"
>
<tbody
*
ngIf=
"
!bu4ListLoading&&
filterBu4Table().length"
>
<tr
*
ngFor=
"let item of filterBu4Table() | slice:((bu4Table.currentPage-1) * 10) : (((bu4Table.currentPage-1) * 10) + 10);let i = index"
>
<td
class=
"text-center"
>
...
...
@@ -680,3 +691,33 @@
</div>
</div>
</div>
<div
id=
"sub-department-one-upload-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)] rounded-md"
>
<div
class=
"ti-modal-header bg-primary !rounded-none !rounded-t-sm"
>
<h5
class=
"text-xxl font-bold text-white"
>
นำเข้าฝ่าย
</h5>
</div>
<div
class=
"ti-modal-body max-h-full overflow-hidden ti-modal-content !rounded-t-none !rounded-b-sm"
>
<h1
class=
"mt-2"
style=
"text-align: center;"
>
ไฟล์
</h1>
<div
class=
"mt-2 p-2"
>
<div
class=
"flex rounded-md"
>
<input
#
fileInput
type=
"file"
(
change
)="
onFileSelected
($
event
)"
hidden
>
<input
type=
"text"
[
value
]="
selectedFileName
"
readonly
(
click
)="
fileInput
.
click
()"
class=
"ti-form-input rounded-none ltr:rounded-l-md rtl:rounded-r-md focus:z-10 cursor-pointer"
>
<button
type=
"button"
(
click
)="
fileInput
.
click
()"
class=
"inline-flex flex-shrink-0 justify-center items-center h-[2.875rem] w-[2.875rem] ltr:rounded-r-md rtl:rounded-l-md border border-transparent font-semibold bg-secondary text-white hover:bg-secondary focus:z-10 focus:outline-none focus:ring-0 focus:ring-secondary transition-all text-sm"
>
<i
class=
"ti ti-upload"
></i>
</button>
</div>
<div
class=
"flex justify-center mt-2rem mb-1rem space-x-4"
>
<button
type=
"submit"
class=
"ti-btn ti-btn-secondary"
(
click
)="
uploadFile
()"
[
disabled
]="!
selectedFile
"
>
อัปโหลด
</button>
</div>
</div>
</div>
</div>
</div>
\ No newline at end of file
src/app/components/company-components/company-registration/branch-business-unit/sub-department-one/sub-department-one.component.ts
View file @
3eeeb5e5
...
...
@@ -4,6 +4,7 @@ import { Bu3Model, MyBu3Model } from 'src/app/shared/model/bu3.model';
import
{
Bu4Model
,
MyBu4Model
}
from
'src/app/shared/model/bu4.model'
;
import
{
Bu3Service
}
from
'src/app/shared/services/bu3.service'
;
import
{
Bu4Service
}
from
'src/app/shared/services/bu4.service'
;
import
{
FileService
}
from
'src/app/shared/services/file.service'
;
interface
table
{
currentPage
:
number
,
page
:
number
[],
...
...
@@ -16,12 +17,17 @@ interface table {
})
export
class
SubDepartmentOneComponent
implements
OnInit
{
bu4List
:
Bu4Model
[]
=
[]
bu4ListLoading
=
false
bu4
:
Bu4Model
=
new
MyBu4Model
({})
bu4Table
:
table
=
{
currentPage
:
1
,
page
:
Array
.
from
({
length
:
1
},
(
_
,
i
)
=>
i
+
1
),
search
:
""
}
selectedFile
:
File
|
null
=
null
;
selectedFileName
:
string
=
'กรุณาเลือกไฟล์'
;
bu4Modal
:
table
=
{
currentPage
:
1
,
page
:
Array
.
from
({
length
:
1
},
(
_
,
i
)
=>
i
+
1
),
...
...
@@ -38,17 +44,71 @@ export class SubDepartmentOneComponent implements OnInit {
constructor
(
private
bu4Service
:
Bu4Service
,
private
bu3Service
:
Bu3Service
,
private
toastr
:
ToastrService
,
private
cdr
:
ChangeDetectorRef
private
cdr
:
ChangeDetectorRef
,
private
fileService
:
FileService
)
{
}
ngOnInit
():
void
{
this
.
getBu4List
()
this
.
getBu3List
()
}
onFileSelected
(
event
:
any
)
{
this
.
selectedFile
=
event
.
target
.
files
.
length
>
0
?
event
.
target
.
files
[
0
]
:
null
;
this
.
selectedFileName
=
this
.
selectedFile
?.
name
||
"กรุณาเลือกไฟล์"
}
uploadFile
()
{
if
(
!
this
.
selectedFile
)
{
alert
(
'กรุณาเลือกไฟล์ก่อนอัปโหลด'
)
return
}
const
formData
=
new
FormData
();
formData
.
append
(
'file'
,
this
.
selectedFile
);
this
.
fileService
.
upload
(
formData
,
'mbu4'
).
subscribe
({
next
:
response
=>
{
if
(
response
.
success
)
{
this
.
showAlert
(
response
.
message
,
'success'
)
this
.
getBu4List
()
}
else
{
this
.
showAlert
(
response
.
message
,
'error'
)
}
},
error
:
error
=>
{
this
.
showAlert
(
error
.
message
,
'error'
)
}
})
}
downloadFile
()
{
const
fileName
=
'IMPORT_BU.xlsx'
this
.
fileService
.
download
(
fileName
).
subscribe
({
next
:
response
=>
{
const
url
=
window
.
URL
.
createObjectURL
(
response
);
const
a
=
document
.
createElement
(
"a"
);
a
.
href
=
url
;
a
.
download
=
fileName
;
document
.
body
.
appendChild
(
a
);
a
.
click
();
document
.
body
.
removeChild
(
a
);
window
.
URL
.
revokeObjectURL
(
url
);
},
error
:
error
=>
{
this
.
showAlert
(
error
.
message
,
'error'
)
}
})
}
getBu4List
()
{
this
.
bu4Service
.
getList
().
subscribe
(
response
=>
{
this
.
bu4ListLoading
=
true
this
.
bu4Service
.
getList
().
subscribe
({
next
:
response
=>
{
this
.
bu4List
=
response
this
.
bu4ListLoading
=
false
this
.
onBu4TableSearchChange
()
this
.
cdr
.
detectChanges
()
},
error
:
error
=>
{
this
.
bu4ListLoading
=
false
this
.
cdr
.
detectChanges
()
}
})
}
onBu4TableSearchChange
()
{
...
...
@@ -84,18 +144,30 @@ export class SubDepartmentOneComponent implements OnInit {
x
.
edesc
.
includes
(
this
.
bu4Modal
.
search
))
}
addBu4
()
{
this
.
bu4Service
.
post
({
...
this
.
bu4
,
parent
:
this
.
bu3
.
bu3id
}).
subscribe
((
response
:
any
)
=>
{
this
.
bu4Service
.
post
({
...
this
.
bu4
,
parent
:
this
.
bu3
.
bu3id
}).
subscribe
({
next
:
response
=>
{
if
(
response
.
success
)
{
this
.
showAlert
(
response
.
message
,
'success'
)
this
.
getBu4List
()
this
.
showSuccess
()
}
else
{
this
.
showAlert
(
response
.
message
,
'error'
)
}
},
error
:
error
=>
{
this
.
showAlert
(
error
.
message
,
'error'
)
}
})
}
deleteBu4
()
{
this
.
bu4Service
.
delete
(
this
.
bu4
).
subscribe
((
response
:
any
)
=>
{
this
.
bu4Service
.
delete
(
this
.
bu4
).
subscribe
({
next
:
response
=>
{
if
(
response
.
success
)
{
this
.
showAlert
(
response
.
message
,
'success'
)
this
.
getBu4List
()
this
.
showSuccessDelete
()
}
else
{
this
.
showAlert
(
response
.
message
,
'error'
)
}
},
error
:
error
=>
{
this
.
showAlert
(
error
.
message
,
'error'
)
}
})
}
...
...
@@ -123,23 +195,11 @@ export class SubDepartmentOneComponent implements OnInit {
this
.
bu3
=
new
MyBu3Model
(
bu3
||
{})
}
show
Success
(
)
{
this
.
toastr
.
success
(
'บันทึกข้อมูลสำเร็จ'
,
'เเ
จ้งเตือน'
,
{
show
Alert
(
text
:
string
,
type
:
'success'
|
'error'
)
{
this
.
toastr
[
type
](
text
,
'แ
จ้งเตือน'
,
{
timeOut
:
3000
,
positionClass
:
'toast-top-right'
,
});
}
showSuccessEdit
()
{
this
.
toastr
.
success
(
'เเก้ไขข้อมูลสำเร็จ'
,
'เเจ้งเตือน'
,
{
timeOut
:
3000
,
positionClass
:
'toast-top-right'
,
});
}
showSuccessDelete
()
{
this
.
toastr
.
success
(
'ลบข้อมูลสำเร็จ'
,
'เเจ้งเตือน'
,
{
timeOut
:
3000
,
positionClass
:
'toast-top-right'
,
});
})
}
}
...
...
src/app/components/company-components/company-registration/branch-business-unit/sub-department-three/sub-department-three.component.html
View file @
3eeeb5e5
...
...
@@ -2,12 +2,13 @@
<div
class=
"flex justify-between"
>
<div
class=
"flex pr-2"
>
<div
class=
"px-1"
>
<button
type=
"button"
class=
"ti-btn ti-btn-soft-secondary h-20px m-0 shadow-md"
>
<button
type=
"button"
class=
"ti-btn ti-btn-soft-secondary h-20px m-0 shadow-md"
data-hs-overlay=
"#sub-department-three-upload-modal"
>
<i
class=
"ri-add-line"
></i>
นำเข้าข้อมูล
</button>
<a
class=
"mx-2 justify-center -mb-px inline-flex items-center gap-2 font-weight-500 font-size-12px text-center text-secondary border-secondary border-b-2 align-items-end"
href=
"javascript:void(0);"
>
href=
"javascript:void(0);"
(
click
)="
downloadFile
()"
>
ดาวน์โหลดตัวอย่างไฟล์
</a>
</div>
...
...
@@ -64,14 +65,24 @@
</ng-container>
</tr>
</thead>
<tbody
*
ngIf=
"!filterBu6Table().length"
>
<tbody
*
ngIf=
"bu6ListLoading"
>
<tr>
<td
class=
"text-center"
colspan=
"100%"
>
<div
*
ngFor=
"let item of [1,2,3]"
class=
"ti-spinner w-8 h-8 text-secondary mx-1"
role=
"status"
aria-label=
"loading"
>
<span
class=
"sr-only"
>
Loading...
</span>
</div>
</td>
</tr>
</tbody>
<tbody
*
ngIf=
"!bu6ListLoading&&!filterBu6Table().length"
>
<tr>
<td
class=
"text-center"
colspan=
"100%"
>
ไม่พบข้อมูล
</td>
</tr>
</tbody>
<tbody
*
ngIf=
"filterBu6Table().length"
>
<tbody
*
ngIf=
"
!bu6ListLoading&&
filterBu6Table().length"
>
<tr
*
ngFor=
"let item of filterBu6Table() | slice:((bu6Table.currentPage-1) * 10) : (((bu6Table.currentPage-1) * 10) + 10);let i = index"
>
<td
class=
"text-center"
>
...
...
@@ -660,3 +671,33 @@
</div>
</div>
</div>
<div
id=
"sub-department-three-upload-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)] rounded-md"
>
<div
class=
"ti-modal-header bg-primary !rounded-none !rounded-t-sm"
>
<h5
class=
"text-xxl font-bold text-white"
>
นำเข้าฝ่าย
</h5>
</div>
<div
class=
"ti-modal-body max-h-full overflow-hidden ti-modal-content !rounded-t-none !rounded-b-sm"
>
<h1
class=
"mt-2"
style=
"text-align: center;"
>
ไฟล์
</h1>
<div
class=
"mt-2 p-2"
>
<div
class=
"flex rounded-md"
>
<input
#
fileInput
type=
"file"
(
change
)="
onFileSelected
($
event
)"
hidden
>
<input
type=
"text"
[
value
]="
selectedFileName
"
readonly
(
click
)="
fileInput
.
click
()"
class=
"ti-form-input rounded-none ltr:rounded-l-md rtl:rounded-r-md focus:z-10 cursor-pointer"
>
<button
type=
"button"
(
click
)="
fileInput
.
click
()"
class=
"inline-flex flex-shrink-0 justify-center items-center h-[2.875rem] w-[2.875rem] ltr:rounded-r-md rtl:rounded-l-md border border-transparent font-semibold bg-secondary text-white hover:bg-secondary focus:z-10 focus:outline-none focus:ring-0 focus:ring-secondary transition-all text-sm"
>
<i
class=
"ti ti-upload"
></i>
</button>
</div>
<div
class=
"flex justify-center mt-2rem mb-1rem space-x-4"
>
<button
type=
"submit"
class=
"ti-btn ti-btn-secondary"
(
click
)="
uploadFile
()"
[
disabled
]="!
selectedFile
"
>
อัปโหลด
</button>
</div>
</div>
</div>
</div>
</div>
\ No newline at end of file
src/app/components/company-components/company-registration/branch-business-unit/sub-department-three/sub-department-three.component.ts
View file @
3eeeb5e5
...
...
@@ -4,6 +4,7 @@ import { Bu5Model, MyBu5Model } from 'src/app/shared/model/bu5.model';
import
{
Bu6Model
,
MyBu6Model
}
from
'src/app/shared/model/bu6.model'
;
import
{
Bu5Service
}
from
'src/app/shared/services/bu5.service'
;
import
{
Bu6Service
}
from
'src/app/shared/services/bu6.service'
;
import
{
FileService
}
from
'src/app/shared/services/file.service'
;
interface
table
{
currentPage
:
number
,
...
...
@@ -17,12 +18,17 @@ interface table {
})
export
class
SubDepartmentThreeComponent
implements
OnInit
{
bu6List
:
Bu6Model
[]
=
[]
bu6ListLoading
=
false
bu6
:
Bu6Model
=
new
MyBu6Model
({})
bu6Table
:
table
=
{
currentPage
:
1
,
page
:
Array
.
from
({
length
:
1
},
(
_
,
i
)
=>
i
+
1
),
search
:
""
}
selectedFile
:
File
|
null
=
null
;
selectedFileName
:
string
=
'กรุณาเลือกไฟล์'
;
bu6Modal
:
table
=
{
currentPage
:
1
,
page
:
Array
.
from
({
length
:
1
},
(
_
,
i
)
=>
i
+
1
),
...
...
@@ -39,17 +45,71 @@ export class SubDepartmentThreeComponent implements OnInit {
constructor
(
private
bu6Service
:
Bu6Service
,
private
bu5Service
:
Bu5Service
,
private
toastr
:
ToastrService
,
private
cdr
:
ChangeDetectorRef
private
cdr
:
ChangeDetectorRef
,
private
fileService
:
FileService
)
{
}
ngOnInit
():
void
{
this
.
getBu6List
()
this
.
getBu5List
()
}
onFileSelected
(
event
:
any
)
{
this
.
selectedFile
=
event
.
target
.
files
.
length
>
0
?
event
.
target
.
files
[
0
]
:
null
;
this
.
selectedFileName
=
this
.
selectedFile
?.
name
||
"กรุณาเลือกไฟล์"
}
uploadFile
()
{
if
(
!
this
.
selectedFile
)
{
alert
(
'กรุณาเลือกไฟล์ก่อนอัปโหลด'
)
return
}
const
formData
=
new
FormData
();
formData
.
append
(
'file'
,
this
.
selectedFile
);
this
.
fileService
.
upload
(
formData
,
'mbu6'
).
subscribe
({
next
:
response
=>
{
if
(
response
.
success
)
{
this
.
showAlert
(
response
.
message
,
'success'
)
this
.
getBu6List
()
}
else
{
this
.
showAlert
(
response
.
message
,
'error'
)
}
},
error
:
error
=>
{
this
.
showAlert
(
error
.
message
,
'error'
)
}
})
}
downloadFile
()
{
const
fileName
=
'IMPORT_BU.xlsx'
this
.
fileService
.
download
(
fileName
).
subscribe
({
next
:
response
=>
{
const
url
=
window
.
URL
.
createObjectURL
(
response
);
const
a
=
document
.
createElement
(
"a"
);
a
.
href
=
url
;
a
.
download
=
fileName
;
document
.
body
.
appendChild
(
a
);
a
.
click
();
document
.
body
.
removeChild
(
a
);
window
.
URL
.
revokeObjectURL
(
url
);
},
error
:
error
=>
{
this
.
showAlert
(
error
.
message
,
'error'
)
}
})
}
getBu6List
()
{
this
.
bu6Service
.
getList
().
subscribe
(
response
=>
{
this
.
bu6ListLoading
=
true
this
.
bu6Service
.
getList
().
subscribe
({
next
:
response
=>
{
this
.
bu6List
=
response
this
.
bu6ListLoading
=
false
this
.
onBu6TableSearchChange
()
this
.
cdr
.
detectChanges
()
},
error
:
error
=>
{
this
.
bu6ListLoading
=
false
this
.
cdr
.
detectChanges
()
}
})
}
onBu6TableSearchChange
()
{
...
...
@@ -85,18 +145,30 @@ export class SubDepartmentThreeComponent implements OnInit {
x
.
edesc
.
includes
(
this
.
bu6Modal
.
search
))
}
addBu6
()
{
this
.
bu6Service
.
post
({
...
this
.
bu6
,
parent
:
this
.
bu5
.
bu5id
}).
subscribe
((
response
:
any
)
=>
{
this
.
bu6Service
.
post
({
...
this
.
bu6
,
parent
:
this
.
bu5
.
bu5id
}).
subscribe
({
next
:
response
=>
{
if
(
response
.
success
)
{
this
.
showAlert
(
response
.
message
,
'success'
)
this
.
getBu6List
()
this
.
showSuccessAdd
()
}
else
{
this
.
showAlert
(
response
.
message
,
'error'
)
}
},
error
:
error
=>
{
this
.
showAlert
(
error
.
message
,
'error'
)
}
})
}
deleteBu6
()
{
this
.
bu6Service
.
delete
(
this
.
bu6
).
subscribe
((
response
:
any
)
=>
{
this
.
bu6Service
.
delete
(
this
.
bu6
).
subscribe
({
next
:
response
=>
{
if
(
response
.
success
)
{
this
.
showAlert
(
response
.
message
,
'success'
)
this
.
getBu6List
()
this
.
showSuccessDelete
()
}
else
{
this
.
showAlert
(
response
.
message
,
'error'
)
}
},
error
:
error
=>
{
this
.
showAlert
(
error
.
message
,
'error'
)
}
})
}
...
...
@@ -124,23 +196,11 @@ export class SubDepartmentThreeComponent implements OnInit {
this
.
bu5
=
new
MyBu5Model
(
bu5
||
{})
}
show
SuccessAdd
(
)
{
this
.
toastr
.
success
(
'บันทึกข้อมูลสำเร็จ'
,
'แจ้งเตือน'
,
{
show
Alert
(
text
:
string
,
type
:
'success'
|
'error'
)
{
this
.
toastr
[
type
](
text
,
'แจ้งเตือน'
,
{
timeOut
:
3000
,
positionClass
:
'toast-top-right'
,
});
}
showSuccessEdit
()
{
this
.
toastr
.
success
(
'แก้ไขข้อมูลสำเร็จ'
,
'แจ้งเตือน'
,
{
timeOut
:
3000
,
positionClass
:
'toast-top-right'
,
});
}
showSuccessDelete
()
{
this
.
toastr
.
success
(
'ลบข้อมูลสำเร็จ'
,
'แจ้งเตือน'
,
{
timeOut
:
3000
,
positionClass
:
'toast-top-right'
,
});
})
}
}
...
...
src/app/components/company-components/company-registration/branch-business-unit/sub-department-two/sub-department-two.component.html
View file @
3eeeb5e5
...
...
@@ -2,12 +2,13 @@
<div
class=
"flex justify-between"
>
<div
class=
"flex pr-2"
>
<div
class=
"px-1"
>
<button
type=
"button"
class=
"ti-btn ti-btn-soft-secondary h-20px m-0 shadow-md"
>
<button
type=
"button"
class=
"ti-btn ti-btn-soft-secondary h-20px m-0 shadow-md"
data-hs-overlay=
"#sub-department-two-upload-modal"
>
<i
class=
"ri-add-line"
></i>
นำเข้าข้อมูล
</button>
<a
class=
"mx-2 justify-center -mb-px inline-flex items-center gap-2 font-weight-500 font-size-12px text-center text-secondary border-secondary border-b-2 align-items-end"
href=
"javascript:void(0);"
>
href=
"javascript:void(0);"
(
click
)="
downloadFile
()"
>
ดาวน์โหลดตัวอย่างไฟล์
</a>
</div>
...
...
@@ -64,14 +65,24 @@
</ng-container>
</tr>
</thead>
<tbody
*
ngIf=
"!filterBu5Table().length"
>
<tbody
*
ngIf=
"bu5ListLoading"
>
<tr>
<td
class=
"text-center"
colspan=
"100%"
>
<div
*
ngFor=
"let item of [1,2,3]"
class=
"ti-spinner w-8 h-8 text-secondary mx-1"
role=
"status"
aria-label=
"loading"
>
<span
class=
"sr-only"
>
Loading...
</span>
</div>
</td>
</tr>
</tbody>
<tbody
*
ngIf=
"!bu5ListLoading&&!filterBu5Table().length"
>
<tr>
<td
class=
"text-center"
colspan=
"100%"
>
ไม่พบข้อมูล
</td>
</tr>
</tbody>
<tbody
*
ngIf=
"filterBu5Table().length"
>
<tbody
*
ngIf=
"
!bu5ListLoading&&
filterBu5Table().length"
>
<tr
*
ngFor=
"let item of filterBu5Table() | slice:((bu5Table.currentPage-1) * 10) : (((bu5Table.currentPage-1) * 10) + 10);let i = index"
>
<td
class=
"text-center"
>
...
...
@@ -586,7 +597,7 @@
ย้อนกลับ
</button>
<a
class=
"ti-btn ti-btn-success"
href=
"javascript:void(0);"
data-hs-overlay=
"#sub-department-two-alert-add-modal"
(
click
)="
addBu5
()
;
showSuccessAdd
()
"
>
data-hs-overlay=
"#sub-department-two-alert-add-modal"
(
click
)="
addBu5
()"
>
บันทึกข้อมูล
</a>
</div>
...
...
@@ -671,3 +682,33 @@
</div>
</div>
</div>
<div
id=
"sub-department-two-upload-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)] rounded-md"
>
<div
class=
"ti-modal-header bg-primary !rounded-none !rounded-t-sm"
>
<h5
class=
"text-xxl font-bold text-white"
>
นำเข้าฝ่าย
</h5>
</div>
<div
class=
"ti-modal-body max-h-full overflow-hidden ti-modal-content !rounded-t-none !rounded-b-sm"
>
<h1
class=
"mt-2"
style=
"text-align: center;"
>
ไฟล์
</h1>
<div
class=
"mt-2 p-2"
>
<div
class=
"flex rounded-md"
>
<input
#
fileInput
type=
"file"
(
change
)="
onFileSelected
($
event
)"
hidden
>
<input
type=
"text"
[
value
]="
selectedFileName
"
readonly
(
click
)="
fileInput
.
click
()"
class=
"ti-form-input rounded-none ltr:rounded-l-md rtl:rounded-r-md focus:z-10 cursor-pointer"
>
<button
type=
"button"
(
click
)="
fileInput
.
click
()"
class=
"inline-flex flex-shrink-0 justify-center items-center h-[2.875rem] w-[2.875rem] ltr:rounded-r-md rtl:rounded-l-md border border-transparent font-semibold bg-secondary text-white hover:bg-secondary focus:z-10 focus:outline-none focus:ring-0 focus:ring-secondary transition-all text-sm"
>
<i
class=
"ti ti-upload"
></i>
</button>
</div>
<div
class=
"flex justify-center mt-2rem mb-1rem space-x-4"
>
<button
type=
"submit"
class=
"ti-btn ti-btn-secondary"
(
click
)="
uploadFile
()"
[
disabled
]="!
selectedFile
"
>
อัปโหลด
</button>
</div>
</div>
</div>
</div>
</div>
\ No newline at end of file
src/app/components/company-components/company-registration/branch-business-unit/sub-department-two/sub-department-two.component.ts
View file @
3eeeb5e5
...
...
@@ -4,6 +4,7 @@ import { Bu4Model, MyBu4Model } from 'src/app/shared/model/bu4.model';
import
{
Bu5Model
,
MyBu5Model
}
from
'src/app/shared/model/bu5.model'
;
import
{
Bu4Service
}
from
'src/app/shared/services/bu4.service'
;
import
{
Bu5Service
}
from
'src/app/shared/services/bu5.service'
;
import
{
FileService
}
from
'src/app/shared/services/file.service'
;
interface
table
{
currentPage
:
number
,
page
:
number
[],
...
...
@@ -16,12 +17,17 @@ interface table {
})
export
class
SubDepartmentTwoComponent
implements
OnInit
{
bu5List
:
Bu5Model
[]
=
[]
bu5ListLoading
=
false
bu5
:
Bu5Model
=
new
MyBu5Model
({})
bu5Table
:
table
=
{
currentPage
:
1
,
page
:
Array
.
from
({
length
:
1
},
(
_
,
i
)
=>
i
+
1
),
search
:
""
}
selectedFile
:
File
|
null
=
null
;
selectedFileName
:
string
=
'กรุณาเลือกไฟล์'
;
bu5Modal
:
table
=
{
currentPage
:
1
,
page
:
Array
.
from
({
length
:
1
},
(
_
,
i
)
=>
i
+
1
),
...
...
@@ -38,17 +44,71 @@ export class SubDepartmentTwoComponent implements OnInit {
constructor
(
private
bu5Service
:
Bu5Service
,
private
bu4Service
:
Bu4Service
,
private
toastr
:
ToastrService
,
private
cdr
:
ChangeDetectorRef
private
cdr
:
ChangeDetectorRef
,
private
fileService
:
FileService
)
{
}
ngOnInit
():
void
{
this
.
getBu5List
()
this
.
getBu4List
()
}
onFileSelected
(
event
:
any
)
{
this
.
selectedFile
=
event
.
target
.
files
.
length
>
0
?
event
.
target
.
files
[
0
]
:
null
;
this
.
selectedFileName
=
this
.
selectedFile
?.
name
||
"กรุณาเลือกไฟล์"
}
uploadFile
()
{
if
(
!
this
.
selectedFile
)
{
alert
(
'กรุณาเลือกไฟล์ก่อนอัปโหลด'
)
return
}
const
formData
=
new
FormData
();
formData
.
append
(
'file'
,
this
.
selectedFile
);
this
.
fileService
.
upload
(
formData
,
'mbu5'
).
subscribe
({
next
:
response
=>
{
if
(
response
.
success
)
{
this
.
showAlert
(
response
.
message
,
'success'
)
this
.
getBu5List
()
}
else
{
this
.
showAlert
(
response
.
message
,
'error'
)
}
},
error
:
error
=>
{
this
.
showAlert
(
error
.
message
,
'error'
)
}
})
}
downloadFile
()
{
const
fileName
=
'IMPORT_BU.xlsx'
this
.
fileService
.
download
(
fileName
).
subscribe
({
next
:
response
=>
{
const
url
=
window
.
URL
.
createObjectURL
(
response
);
const
a
=
document
.
createElement
(
"a"
);
a
.
href
=
url
;
a
.
download
=
fileName
;
document
.
body
.
appendChild
(
a
);
a
.
click
();
document
.
body
.
removeChild
(
a
);
window
.
URL
.
revokeObjectURL
(
url
);
},
error
:
error
=>
{
this
.
showAlert
(
error
.
message
,
'error'
)
}
})
}
getBu5List
()
{
this
.
bu5Service
.
getList
().
subscribe
(
response
=>
{
this
.
bu5ListLoading
=
true
this
.
bu5Service
.
getList
().
subscribe
({
next
:
response
=>
{
this
.
bu5List
=
response
this
.
bu5ListLoading
=
false
this
.
onBu5TableSearchChange
()
this
.
cdr
.
detectChanges
()
},
error
:
error
=>
{
this
.
bu5ListLoading
=
false
this
.
cdr
.
detectChanges
()
}
})
}
onBu5TableSearchChange
()
{
...
...
@@ -84,18 +144,30 @@ export class SubDepartmentTwoComponent implements OnInit {
x
.
edesc
.
includes
(
this
.
bu5Modal
.
search
))
}
addBu5
()
{
this
.
bu5Service
.
post
({
...
this
.
bu5
,
parent
:
this
.
bu4
.
bu4id
}).
subscribe
((
response
:
any
)
=>
{
this
.
bu5Service
.
post
({
...
this
.
bu5
,
parent
:
this
.
bu4
.
bu4id
}).
subscribe
({
next
:
response
=>
{
if
(
response
.
success
)
{
this
.
showAlert
(
response
.
message
,
'success'
)
this
.
getBu5List
()
this
.
showSuccessAdd
()
}
else
{
this
.
showAlert
(
response
.
message
,
'error'
)
}
},
error
:
error
=>
{
this
.
showAlert
(
error
.
message
,
'error'
)
}
})
}
deleteBu5
()
{
this
.
bu5Service
.
delete
(
this
.
bu5
).
subscribe
((
response
:
any
)
=>
{
this
.
bu5Service
.
delete
(
this
.
bu5
).
subscribe
({
next
:
response
=>
{
if
(
response
.
success
)
{
this
.
showAlert
(
response
.
message
,
'success'
)
this
.
getBu5List
()
this
.
showSuccessDelete
()
}
else
{
this
.
showAlert
(
response
.
message
,
'error'
)
}
},
error
:
error
=>
{
this
.
showAlert
(
error
.
message
,
'error'
)
}
})
}
...
...
@@ -123,23 +195,11 @@ export class SubDepartmentTwoComponent implements OnInit {
this
.
bu4
=
new
MyBu4Model
(
bu4
||
{})
}
show
SuccessAdd
(
)
{
this
.
toastr
.
success
(
'บันทึกข้อมูลสำเร็จ'
,
'แจ้งเตือน'
,
{
show
Alert
(
text
:
string
,
type
:
'success'
|
'error'
)
{
this
.
toastr
[
type
](
text
,
'แจ้งเตือน'
,
{
timeOut
:
3000
,
positionClass
:
'toast-top-right'
,
});
}
showSuccessEdit
()
{
this
.
toastr
.
success
(
'แก้ไขข้อมูลสำเร็จ'
,
'แจ้งเตือน'
,
{
timeOut
:
3000
,
positionClass
:
'toast-top-right'
,
});
}
showSuccessDelete
()
{
this
.
toastr
.
success
(
'ลบข้อมูลสำเร็จ'
,
'แจ้งเตือน'
,
{
timeOut
:
3000
,
positionClass
:
'toast-top-right'
,
});
})
}
}
src/app/shared/services/bu2.service.ts
View file @
3eeeb5e5
...
...
@@ -3,6 +3,7 @@ import { Injectable } from '@angular/core';
import
{
Observable
}
from
'rxjs'
;
import
{
environment
}
from
'src/environments/environment'
;
import
{
Bu2Model
}
from
'../model/bu2.model'
;
import
{
AlertModel
}
from
'../model/alert.model'
;
@
Injectable
({
providedIn
:
'root'
})
...
...
@@ -17,16 +18,16 @@ export class Bu2Service {
getById
(
bu2id
:
string
):
Observable
<
Bu2Model
>
{
return
this
.
http
.
get
<
Bu2Model
>
(
this
.
urlApi
+
"/"
+
bu2id
)
}
post
(
body
:
Bu2Model
)
{
return
this
.
http
.
post
(
this
.
urlApi
,
body
)
post
(
body
:
Bu2Model
)
:
Observable
<
AlertModel
>
{
return
this
.
http
.
post
<
AlertModel
>
(
this
.
urlApi
,
body
)
}
delete
(
body
:
Bu2Model
)
{
delete
(
body
:
Bu2Model
)
:
Observable
<
AlertModel
>
{
const
options
=
{
headers
:
new
HttpHeaders
({
"Content-Type"
:
"application/json"
,
}),
body
:
body
};
return
this
.
http
.
delete
(
this
.
urlApi
,
options
)
return
this
.
http
.
delete
<
AlertModel
>
(
this
.
urlApi
,
options
)
}
}
src/app/shared/services/bu3.service.ts
View file @
3eeeb5e5
...
...
@@ -3,6 +3,7 @@ import { Injectable } from '@angular/core';
import
{
Observable
}
from
'rxjs'
;
import
{
environment
}
from
'src/environments/environment'
;
import
{
Bu3Model
}
from
'../model/bu3.model'
;
import
{
AlertModel
}
from
'../model/alert.model'
;
@
Injectable
({
providedIn
:
'root'
})
...
...
@@ -17,16 +18,16 @@ import { Bu3Model } from '../model/bu3.model';
getList
():
Observable
<
Bu3Model
[]
>
{
return
this
.
http
.
get
<
Bu3Model
[]
>
(
this
.
urlApi
+
"/lists"
)
}
post
(
body
:
Bu3Model
)
{
return
this
.
http
.
post
(
this
.
urlApi
,
body
)
post
(
body
:
Bu3Model
)
:
Observable
<
AlertModel
>
{
return
this
.
http
.
post
<
AlertModel
>
(
this
.
urlApi
,
body
)
}
delete
(
body
:
Bu3Model
)
{
delete
(
body
:
Bu3Model
)
:
Observable
<
AlertModel
>
{
const
options
=
{
headers
:
new
HttpHeaders
({
"Content-Type"
:
"application/json"
,
}),
body
:
body
};
return
this
.
http
.
delete
(
this
.
urlApi
,
options
)
return
this
.
http
.
delete
<
AlertModel
>
(
this
.
urlApi
,
options
)
}
}
\ No newline at end of file
src/app/shared/services/bu4.service.ts
View file @
3eeeb5e5
...
...
@@ -3,6 +3,7 @@ import { Injectable } from '@angular/core';
import
{
Observable
}
from
'rxjs'
;
import
{
environment
}
from
'src/environments/environment'
;
import
{
Bu4Model
}
from
'../model/bu4.model'
;
import
{
AlertModel
}
from
'../model/alert.model'
;
@
Injectable
({
providedIn
:
'root'
})
...
...
@@ -17,16 +18,16 @@ export class Bu4Service {
getById
(
bu4id
:
string
):
Observable
<
Bu4Model
>
{
return
this
.
http
.
get
<
Bu4Model
>
(
this
.
urlApi
+
"/"
+
bu4id
)
}
post
(
body
:
Bu4Model
)
{
return
this
.
http
.
post
(
this
.
urlApi
,
body
)
post
(
body
:
Bu4Model
)
:
Observable
<
AlertModel
>
{
return
this
.
http
.
post
<
AlertModel
>
(
this
.
urlApi
,
body
)
}
delete
(
body
:
Bu4Model
)
{
delete
(
body
:
Bu4Model
)
:
Observable
<
AlertModel
>
{
const
options
=
{
headers
:
new
HttpHeaders
({
"Content-Type"
:
"application/json"
,
}),
body
:
body
};
return
this
.
http
.
delete
(
this
.
urlApi
,
options
)
return
this
.
http
.
delete
<
AlertModel
>
(
this
.
urlApi
,
options
)
}
}
src/app/shared/services/bu5.service.ts
View file @
3eeeb5e5
...
...
@@ -3,6 +3,7 @@ import { Injectable } from '@angular/core';
import
{
Observable
}
from
'rxjs'
;
import
{
environment
}
from
'src/environments/environment'
;
import
{
Bu5Model
}
from
'../model/bu5.model'
;
import
{
AlertModel
}
from
'../model/alert.model'
;
@
Injectable
({
providedIn
:
'root'
})
...
...
@@ -17,16 +18,16 @@ export class Bu5Service {
getById
(
bu5id
:
string
):
Observable
<
Bu5Model
>
{
return
this
.
http
.
get
<
Bu5Model
>
(
this
.
urlApi
+
"/"
+
bu5id
)
}
post
(
body
:
Bu5Model
)
{
return
this
.
http
.
post
(
this
.
urlApi
,
body
)
post
(
body
:
Bu5Model
)
:
Observable
<
AlertModel
>
{
return
this
.
http
.
post
<
AlertModel
>
(
this
.
urlApi
,
body
)
}
delete
(
body
:
Bu5Model
)
{
delete
(
body
:
Bu5Model
)
:
Observable
<
AlertModel
>
{
const
options
=
{
headers
:
new
HttpHeaders
({
"Content-Type"
:
"application/json"
,
}),
body
:
body
};
return
this
.
http
.
delete
(
this
.
urlApi
,
options
)
return
this
.
http
.
delete
<
AlertModel
>
(
this
.
urlApi
,
options
)
}
}
src/app/shared/services/bu6.service.ts
View file @
3eeeb5e5
...
...
@@ -3,6 +3,7 @@ import { Injectable } from '@angular/core';
import
{
Observable
}
from
'rxjs'
;
import
{
environment
}
from
'src/environments/environment'
;
import
{
Bu6Model
}
from
'../model/bu6.model'
;
import
{
AlertModel
}
from
'../model/alert.model'
;
@
Injectable
({
providedIn
:
'root'
})
...
...
@@ -17,16 +18,16 @@ export class Bu6Service {
getById
(
bu6id
:
string
):
Observable
<
Bu6Model
>
{
return
this
.
http
.
get
<
Bu6Model
>
(
this
.
urlApi
+
"/"
+
bu6id
)
}
post
(
body
:
Bu6Model
)
{
return
this
.
http
.
post
(
this
.
urlApi
,
body
)
post
(
body
:
Bu6Model
)
:
Observable
<
AlertModel
>
{
return
this
.
http
.
post
<
AlertModel
>
(
this
.
urlApi
,
body
)
}
delete
(
body
:
Bu6Model
)
{
delete
(
body
:
Bu6Model
)
:
Observable
<
AlertModel
>
{
const
options
=
{
headers
:
new
HttpHeaders
({
"Content-Type"
:
"application/json"
,
}),
body
:
body
};
return
this
.
http
.
delete
(
this
.
urlApi
,
options
)
return
this
.
http
.
delete
<
AlertModel
>
(
this
.
urlApi
,
options
)
}
}
src/app/shared/services/bu7.service.ts
View file @
3eeeb5e5
...
...
@@ -3,6 +3,7 @@ import { Injectable } from '@angular/core';
import
{
Observable
}
from
'rxjs'
;
import
{
environment
}
from
'src/environments/environment'
;
import
{
Bu7Model
}
from
'../model/bu7.model'
;
import
{
AlertModel
}
from
'../model/alert.model'
;
@
Injectable
({
providedIn
:
'root'
})
...
...
@@ -17,16 +18,16 @@ export class Bu7Service {
getById
(
bu7id
:
string
):
Observable
<
Bu7Model
>
{
return
this
.
http
.
get
<
Bu7Model
>
(
this
.
urlApi
+
"/"
+
bu7id
)
}
post
(
body
:
Bu7Model
)
{
return
this
.
http
.
post
(
this
.
urlApi
,
body
)
post
(
body
:
Bu7Model
)
:
Observable
<
AlertModel
>
{
return
this
.
http
.
post
<
AlertModel
>
(
this
.
urlApi
,
body
)
}
delete
(
body
:
Bu7Model
)
{
delete
(
body
:
Bu7Model
)
:
Observable
<
AlertModel
>
{
const
options
=
{
headers
:
new
HttpHeaders
({
"Content-Type"
:
"application/json"
,
}),
body
:
body
};
return
this
.
http
.
delete
(
this
.
urlApi
,
options
)
return
this
.
http
.
delete
<
AlertModel
>
(
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