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
466ca458
Commit
466ca458
authored
Apr 11, 2025
by
Nattana Chaiyamat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ส่วนย่อย4
parent
348909e5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
67 additions
and
75 deletions
+67
-75
sub-department-four.component.html
...it/sub-department-four/sub-department-four.component.html
+0
-0
sub-department-four.component.ts
...unit/sub-department-four/sub-department-four.component.ts
+67
-75
No files found.
src/app/components/company-components/company-registration/branch-business-unit/sub-department-four/sub-department-four.component.html
View file @
466ca458
This diff is collapsed.
Click to expand it.
src/app/components/company-components/company-registration/branch-business-unit/sub-department-four/sub-department-four.component.ts
View file @
466ca458
import
{
ChangeDetectorRef
,
Component
,
EventEmitter
,
Input
,
OnInit
}
from
'@angular/core'
;
import
{
ColumnModel
}
from
'@syncfusion/ej2-grids'
;
import
{
ToastrService
}
from
'ngx-toastr'
;
import
{
Bu6Model
,
MyBu6Model
}
from
'src/app/shared/model/bu6.model'
;
import
{
Bu7Model
,
MyBu7Model
}
from
'src/app/shared/model/bu7.model'
;
...
...
@@ -18,25 +19,11 @@ interface table {
styleUrls
:
[
'./sub-department-four.component.scss'
]
})
export
class
SubDepartmentFourComponent
implements
OnInit
{
bu7List
:
{
check
:
boolean
,
data
:
Bu7Model
}[]
=
[]
bu7ListLoading
=
false
bu7
:
Bu7Model
=
new
MyBu7Model
()
bu7Table
:
table
=
{
currentPage
:
1
,
page
:
Array
.
from
({
length
:
1
},
(
_
,
i
)
=>
i
+
1
),
search
:
""
,
pageSize
:
10
}
bu7
:
{
loading
:
boolean
,
select
:
Bu7Model
,
dataList
:
Bu7Model
[]
}
=
{
loading
:
false
,
select
:
new
MyBu7Model
(),
dataList
:
[]
}
selectedFile
:
File
|
null
=
null
;
selectedFileName
:
string
=
'กรุณาเลือกไฟล์'
;
bu7Modal
:
table
=
{
currentPage
:
1
,
page
:
Array
.
from
({
length
:
1
},
(
_
,
i
)
=>
i
+
1
),
search
:
""
,
pageSize
:
10
}
bu6List
:
Bu6Model
[]
=
[]
bu6
:
Bu6Model
=
new
MyBu6Model
()
bu6Modal
:
table
=
{
...
...
@@ -47,9 +34,29 @@ export class SubDepartmentFourComponent implements OnInit {
}
currentModal
:
'add'
|
'edit'
|
'delete'
=
"add"
numDataListChecked
=
0
isDataListChecked
=
false
isDataListCheckedAll
=
false
columns
:
ColumnModel
[]
=
[{
field
:
"bu7id"
,
headerText
:
"รหัสฝ่าย"
,
type
:
"string"
,
isPrimaryKey
:
true
,
},
{
field
:
"tdesc"
,
headerText
:
"รายละเอียดฝ่าย(ไทย)"
,
type
:
"string"
},
{
field
:
"edesc"
,
headerText
:
"รายละเอียดฝ่าย(อังกฤษ)"
,
type
:
"string"
}]
searchSettings
=
{
fields
:
[
'bu7id'
,
'tdesc'
,
'edesc'
],
operator
:
'contains'
,
ignoreCase
:
false
};
search
=
''
selectedItems
:
{
key
:
string
,
count
:
number
,
data
:
Map
<
string
,
boolean
>
}
=
{
key
:
''
,
count
:
0
,
data
:
new
Map
<
string
,
boolean
>
()
};
constructor
(
private
bu7Service
:
Bu7Service
,
private
bu6Service
:
Bu6Service
,
private
toastr
:
ToastrService
,
...
...
@@ -73,7 +80,7 @@ export class SubDepartmentFourComponent implements OnInit {
}
const
formData
=
new
FormData
();
formData
.
append
(
'file'
,
this
.
selectedFile
);
this
.
bu7
ListL
oading
=
true
this
.
bu7
.
l
oading
=
true
this
.
fileService
.
uploadExcel
(
formData
,
'mbu7'
).
subscribe
({
next
:
response
=>
{
if
(
response
.
success
)
{
...
...
@@ -81,11 +88,11 @@ export class SubDepartmentFourComponent implements OnInit {
this
.
getBu7List
()
}
else
{
this
.
showAlert
(
response
.
message
,
'error'
)
this
.
bu7
ListL
oading
=
false
this
.
bu7
.
l
oading
=
false
}
},
error
:
error
=>
{
this
.
showAlert
(
error
.
message
,
'error'
)
this
.
bu7
ListL
oading
=
false
this
.
bu7
.
l
oading
=
false
}
})
}
...
...
@@ -110,76 +117,62 @@ export class SubDepartmentFourComponent implements OnInit {
}
getBu7List
()
{
this
.
bu7
ListL
oading
=
true
this
.
bu7
.
l
oading
=
true
this
.
bu7Service
.
getList
().
subscribe
({
next
:
response
=>
{
this
.
bu7List
=
response
.
map
(
x
=>
({
check
:
false
,
data
:
new
MyBu7Model
(
x
)
}))
this
.
bu7ListLoading
=
false
this
.
onBu7TableSearchChange
()
this
.
isDataListCheckedAll
=
false
this
.
dataListCheckAll
()
this
.
bu7
.
dataList
=
response
.
map
(
x
=>
{
this
.
selectedItems
.
data
.
set
(
x
.
bu7id
,
false
)
return
new
MyBu7Model
(
x
)
})
this
.
selectedItems
.
key
=
'bu7id'
this
.
selectedItems
.
count
=
0
this
.
bu7
.
loading
=
false
this
.
cdr
.
detectChanges
()
},
error
:
error
=>
{
this
.
bu7
ListL
oading
=
false
this
.
bu7
.
l
oading
=
false
this
.
cdr
.
detectChanges
()
}
})
}
onBu7TableSearchChange
()
{
this
.
bu7Table
.
currentPage
=
1
this
.
bu7Table
.
page
=
Array
.
from
({
length
:
Math
.
ceil
(
this
.
filterBu7Table
().
length
/
10
)
},
(
_
,
i
)
=>
i
+
1
);
this
.
dataListCheck
()
}
filterBu7Table
()
{
return
this
.
bu7List
.
filter
(
x
=>
{
const
data
=
x
.
data
return
data
.
bu7id
.
toLowerCase
().
includes
(
this
.
bu7Table
.
search
.
toLowerCase
())
||
data
.
tdesc
.
toLowerCase
().
includes
(
this
.
bu7Table
.
search
.
toLowerCase
())
||
data
.
edesc
.
toLowerCase
().
includes
(
this
.
bu7Table
.
search
.
toLowerCase
())
})
}
selectBu7
(
bu7
?:
Bu7Model
)
{
this
.
bu7
=
new
MyBu7Model
(
bu7
||
{})
if
(
bu7
)
{
this
.
bu7
.
select
=
new
MyBu7Model
(
bu7
)
}
else
if
(
this
.
currentModal
==
'add'
)
{
this
.
bu7
.
select
=
new
MyBu7Model
()
}
else
if
(
this
.
currentModal
==
'edit'
)
{
this
.
bu7
.
select
=
new
MyBu7Model
({
bu7id
:
this
.
bu7
.
select
.
bu7id
})
}
this
.
selectBu6
()
if
(
this
.
bu7
.
parent
)
{
this
.
bu6Service
.
getById
(
this
.
bu7
.
parent
).
subscribe
(
response
=>
{
if
(
this
.
bu7
.
select
.
parent
)
{
this
.
bu6Service
.
getById
(
this
.
bu7
.
select
.
parent
).
subscribe
(
response
=>
{
this
.
bu6
=
new
MyBu6Model
(
response
)
this
.
cdr
.
detectChanges
()
})
}
}
onBu7ModalSearchChange
()
{
this
.
bu7Modal
.
currentPage
=
1
this
.
bu7Modal
.
page
=
Array
.
from
({
length
:
Math
.
ceil
(
this
.
filterBu7Modal
().
length
/
10
)
},
(
_
,
i
)
=>
i
+
1
);
}
filterBu7Modal
()
{
return
this
.
bu7List
.
filter
(
x
=>
{
const
data
=
x
.
data
return
data
.
bu7id
.
toLowerCase
().
includes
(
this
.
bu7Table
.
search
.
toLowerCase
())
||
data
.
tdesc
.
toLowerCase
().
includes
(
this
.
bu7Table
.
search
.
toLowerCase
())
||
data
.
edesc
.
toLowerCase
().
includes
(
this
.
bu7Table
.
search
.
toLowerCase
())
})
}
addBu7
()
{
this
.
bu7
ListL
oading
=
true
this
.
bu7Service
.
post
({
...
this
.
bu7
,
parent
:
this
.
bu6
.
bu6id
}).
subscribe
({
this
.
bu7
.
l
oading
=
true
this
.
bu7Service
.
post
({
...
this
.
bu7
.
select
,
parent
:
this
.
bu6
.
bu6id
}).
subscribe
({
next
:
response
=>
{
if
(
response
.
success
)
{
this
.
showAlert
(
response
.
message
,
'success'
)
this
.
getBu7List
()
}
else
{
this
.
showAlert
(
response
.
message
,
'error'
)
this
.
bu7
ListL
oading
=
false
this
.
bu7
.
l
oading
=
false
}
},
error
:
error
=>
{
this
.
showAlert
(
error
.
message
,
'error'
)
this
.
bu7
ListL
oading
=
false
this
.
bu7
.
l
oading
=
false
}
})
}
deleteBu7
()
{
this
.
bu7ListLoading
=
true
const
body
=
this
.
bu7List
.
filter
(
x
=>
x
.
check
).
map
(
x
=>
new
MyBu7Model
(
x
.
data
))
this
.
bu7
.
loading
=
true
const
selectedKeys
=
Array
.
from
(
this
.
selectedItems
.
data
.
keys
());
const
body
=
this
.
bu7
.
dataList
.
filter
(
x
=>
selectedKeys
.
includes
(
x
.
bu7id
)
&&
this
.
selectedItems
.
data
.
get
(
x
.
bu7id
)).
map
(
x
=>
new
MyBu7Model
(
x
))
this
.
bu7Service
.
delete
(
body
).
subscribe
({
next
:
response
=>
{
if
(
response
.
success
)
{
...
...
@@ -187,11 +180,11 @@ export class SubDepartmentFourComponent implements OnInit {
this
.
getBu7List
()
}
else
{
this
.
showAlert
(
response
.
message
,
'error'
)
this
.
bu7
ListL
oading
=
false
this
.
bu7
.
l
oading
=
false
}
},
error
:
error
=>
{
this
.
showAlert
(
error
.
message
,
'error'
)
this
.
bu7
ListL
oading
=
false
this
.
bu7
.
l
oading
=
false
}
})
}
...
...
@@ -226,21 +219,20 @@ export class SubDepartmentFourComponent implements OnInit {
})
}
dataListCheckAll
()
{
const
selectAll
=
this
.
isDataListCheckedAll
;
this
.
filterBu7Table
().
forEach
(
x
=>
x
.
check
=
selectAll
);
this
.
dataListCheck
();
checkPrimary
()
{
return
this
.
bu7
.
dataList
.
find
(
x
=>
x
.
bu7id
==
this
.
bu7
.
select
.
bu7id
)
}
dataListCheck
()
{
const
dataCheck
=
this
.
filterBu7Table
();
this
.
isDataListCheckedAll
=
dataCheck
.
length
?
dataCheck
.
every
(
x
=>
x
.
check
)
:
false
;
this
.
numDataListChecked
=
this
.
bu7List
.
filter
(
x
=>
x
.
check
).
length
this
.
isDataListChecked
=
Boolean
(
this
.
numDataListChecked
)
numSelectItem
()
{
const
selectedKeys
=
Array
.
from
(
this
.
selectedItems
.
data
.
keys
());
const
num
=
this
.
bu7
.
dataList
.
filter
(
x
=>
selectedKeys
.
includes
(
x
.
bu7id
)
&&
this
.
selectedItems
.
data
.
get
(
x
.
bu7id
)).
length
return
num
}
checkPrimary
(
)
{
return
this
.
bu7List
.
find
(
x
=>
x
.
data
.
bu7id
==
this
.
bu7
.
bu7id
)
onSelectItemChange
(
arg
:
any
)
{
this
.
selectedItems
=
arg
}
}
...
...
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