Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
Tia-dev
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
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
Dida Adams Arizona
Tia-dev
Commits
d742784c
Commit
d742784c
authored
Aug 28, 2020
by
faisalhamdi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed issue company
parent
535cc7f6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
135 additions
and
87 deletions
+135
-87
CreatePerusahaan.js
src/container/MasterData/Perusahaan/CreatePerusahaan.js
+113
-76
VisualPerusahaan.js
src/container/MasterData/Perusahaan/VisualPerusahaan.js
+22
-11
No files found.
src/container/MasterData/Perusahaan/CreatePerusahaan.js
View file @
d742784c
import
React
,
{
Component
}
from
'react'
;
import
{
TextField
,
Typography
}
from
'@material-ui/core'
;
import
{
TextField
,
Typography
,
withStyles
,
Snackbar
}
from
'@material-ui/core'
;
import
*
as
R
from
'ramda'
;
import
{
Date
TimePicker
,
KeyboardDatePicker
,
Date
Picker
}
from
"@material-ui/pickers"
;
import
{
DatePicker
}
from
"@material-ui/pickers"
;
import
format
from
"date-fns/format"
;
import
Autocomplete
from
'@material-ui/lab/Autocomplete'
;
import
MuiAlert
from
'@material-ui/lab/Alert'
;
import
api
from
'../../../api'
;
import
Images
from
'../../../assets/Images'
;
const
Alert
=
withStyles
({
})((
props
)
=>
<
MuiAlert
elevation
=
{
6
}
variant
=
"filled"
{...
props
}
/>
)
;
export
default
class
CreatePerusahaan
extends
Component
{
constructor
(
props
)
{
super
(
props
)
...
...
@@ -35,7 +39,10 @@ export default class CreatePerusahaan extends Component {
msgErrorSD
:
''
,
msgErrorED
:
''
,
msgErrorJL
:
''
,
msgErrorUB
:
''
msgErrorUB
:
''
,
alert
:
false
,
tipeAlert
:
''
,
messageAlert
:
''
,
}
}
...
...
@@ -45,7 +52,7 @@ export default class CreatePerusahaan extends Component {
}
componentDidMount
()
{
this
.
get
ParentCompany
()
this
.
get
CompanyActive
()
this
.
getAllUnitBisnis
()
if
(
this
.
props
.
type
===
'edit'
)
{
this
.
getDetailPerusahaan
()
...
...
@@ -62,91 +69,112 @@ export default class CreatePerusahaan extends Component {
getDetailPerusahaan
()
{
api
.
create
().
getDetailPerusahaan
(
this
.
props
.
data
[
1
]).
then
(
response
=>
{
if
(
response
.
data
.
status
===
"success"
)
{
console
.
log
(
response
);
this
.
setState
({
businessID
:
response
.
data
.
data
.
business_unit_id
,
companyID
:
response
.
data
.
data
.
company_id
,
status
:
response
.
data
.
data
.
status
,
company
:
response
.
data
.
data
.
company_name
,
parentID
:
response
.
data
.
data
.
parent
,
parent
:
response
.
data
.
data
.
parent_name
,
startDate
:
response
.
data
.
data
.
start_date
,
endDate
:
response
.
data
.
data
.
end_date
,
totalReport
:
response
.
data
.
data
.
total_report
,
created
:
response
.
data
.
data
.
created
,
updated
:
response
.
data
.
data
.
updated
===
null
?
""
:
response
.
data
.
data
.
updated
},
()
=>
this
.
getAllUnitBisnis
(),
this
.
getCompanyActive
())
}
console
.
log
(
response
)
if
(
response
.
data
)
{
if
(
response
.
data
.
status
===
"success"
)
{
this
.
setState
({
businessID
:
response
.
data
.
data
.
business_unit_id
,
companyID
:
response
.
data
.
data
.
company_id
,
status
:
response
.
data
.
data
.
status
,
company
:
response
.
data
.
data
.
company_name
,
parentID
:
response
.
data
.
data
.
parent
,
parent
:
response
.
data
.
data
.
parent_name
,
startDate
:
response
.
data
.
data
.
start_date
,
endDate
:
response
.
data
.
data
.
end_date
,
totalReport
:
response
.
data
.
data
.
total_report
,
created
:
response
.
data
.
data
.
created
,
updated
:
response
.
data
.
data
.
updated
===
null
?
""
:
response
.
data
.
data
.
updated
},
()
=>
this
.
getAllUnitBisnis
(),
this
.
getCompanyActive
())
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
data
.
message
,
tipeAlert
:
'warning'
})
}
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
problem
,
tipeAlert
:
'error'
})
}
})
}
getCompanyActive
()
{
api
.
create
().
getPerusahaanActive
().
then
(
response
=>
{
if
(
response
.
data
.
status
==
'success'
)
{
let
data
=
response
.
data
.
data
let
perusahaanData
=
data
.
map
((
item
)
=>
{
return
{
company_id
:
item
.
company_id
,
company_name
:
item
.
company_name
}
})
let
index
=
perusahaanData
.
sort
((
a
,
b
)
=>
a
.
company_id
-
b
.
company_id
).
findIndex
((
val
)
=>
val
.
company_id
==
this
.
state
.
parentID
)
let
typeProps
=
{
options
:
perusahaanData
,
getOptionLabel
:
(
option
)
=>
option
.
company_name
,
};
this
.
setState
({
perusahaan
:
typeProps
,
perusahaanData
:
response
.
data
.
data
,
getPerusahaan
:
index
==
-
1
?
null
:
perusahaanData
[
index
]
})
}
else
{
alert
(
response
.
data
.
message
)
if
(
this
.
state
.
company
!==
null
)
{
console
.
log
(
this
.
state
.
company
)
let
payload
=
{
"company_id"
:
this
.
state
.
company
.
company_id
}
})
api
.
create
().
getPerusahaanActive
(
payload
).
then
(
response
=>
{
console
.
log
(
response
)
if
(
response
.
data
)
{
if
(
response
.
data
.
status
==
'success'
)
{
let
data
=
response
.
data
.
data
let
perusahaanData
=
data
.
map
((
item
)
=>
{
return
{
company_id
:
item
.
company_id
,
company_name
:
item
.
company_name
}
})
let
index
=
perusahaanData
.
sort
((
a
,
b
)
=>
a
.
company_id
-
b
.
company_id
).
findIndex
((
val
)
=>
val
.
company_id
==
this
.
state
.
parentID
)
let
typeProps
=
{
options
:
perusahaanData
,
getOptionLabel
:
(
option
)
=>
option
.
company_name
,
};
this
.
setState
({
perusahaan
:
typeProps
,
perusahaanData
:
response
.
data
.
data
,
getPerusahaan
:
index
==
-
1
?
null
:
perusahaanData
[
index
]
})
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
data
.
message
,
tipeAlert
:
'warning'
})
}
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
problem
,
tipeAlert
:
'error'
})
}
})
}
}
getAllUnitBisnis
()
{
api
.
create
().
getUnitBisnisActive
().
then
(
response
=>
{
if
(
response
.
data
.
status
===
'success'
)
{
let
data
=
response
.
data
.
data
let
typeData
=
data
.
map
((
item
)
=>
{
return
{
business_unit_id
:
item
.
business_unit_id
,
business_unit_name
:
item
.
business_unit_name
}
})
// console.log(typeData)
let
index
=
typeData
.
findIndex
((
val
)
=>
val
.
business_unit_id
==
this
.
state
.
businessID
)
console
.
log
(
index
)
let
typeProps
=
{
options
:
typeData
,
getOptionLabel
:
(
option
)
=>
option
.
business_unit_name
,
};
this
.
setState
({
types
:
typeProps
,
typeData
:
response
.
data
.
data
,
getTypes
:
index
==
-
1
?
null
:
typeData
[
index
]
})
if
(
response
.
data
)
{
if
(
response
.
data
.
status
===
'success'
)
{
let
data
=
response
.
data
.
data
let
typeData
=
data
.
map
((
item
)
=>
{
return
{
business_unit_id
:
item
.
business_unit_id
,
business_unit_name
:
item
.
business_unit_name
}
})
// console.log(typeData)
let
index
=
typeData
.
findIndex
((
val
)
=>
val
.
business_unit_id
==
this
.
state
.
businessID
)
console
.
log
(
index
)
let
typeProps
=
{
options
:
typeData
,
getOptionLabel
:
(
option
)
=>
option
.
business_unit_name
,
};
this
.
setState
({
types
:
typeProps
,
typeData
:
response
.
data
.
data
,
getTypes
:
index
==
-
1
?
null
:
typeData
[
index
]
})
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
data
.
message
,
tipeAlert
:
'warning'
})
}
}
else
{
alert
(
response
.
data
.
message
)
}
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
problem
,
tipeAlert
:
'error'
}
)
}
})
}
getParentCompany
()
{
api
.
create
().
getPerusahaanActive
().
then
((
response
)
=>
{
if
(
response
.
data
.
status
===
'success'
)
{
let
data
=
response
.
data
.
data
let
typeData
=
data
.
map
((
item
)
=>
{
return
{
company_id
:
item
.
company_id
,
company_name
:
item
.
company_name
}
})
let
typeProps
=
{
options
:
typeData
.
sort
((
a
,
b
)
=>
a
.
company_id
-
b
.
company_id
),
getOptionLabel
:
(
option
)
=>
option
.
company_name
,
};
this
.
setState
({
perusahaan
:
typeProps
,
perusahaanData
:
response
.
data
.
data
})
}
else
{
alert
(
response
.
data
.
message
)
}
})
}
//
getParentCompany() {
//
api.create().getPerusahaanActive().then((response) => {
//
if (response.data.status === 'success') {
//
let data = response.data.data
//
let typeData = data.map((item) => {
//
return {
//
company_id: item.company_id,
//
company_name: item.company_name
//
}
//
})
//
let typeProps = {
//
options: typeData.sort((a, b) => a.company_id - b.company_id),
//
getOptionLabel: (option) => option.company_name,
//
};
//
this.setState({ perusahaan: typeProps, perusahaanData: response.data.data })
//
} else {
//
alert(response.data.message)
//
}
//
})
//
}
handleChange
(
e
,
type
)
{
let
data
=
this
.
state
...
...
@@ -229,9 +257,18 @@ export default class CreatePerusahaan extends Component {
}
}
closeAlert
()
{
this
.
setState
({
alert
:
false
})
}
renderEdit
()
{
return
(
<
div
className
=
"test app-popup-show"
>
<
Snackbar
open
=
{
this
.
state
.
alert
}
autoHideDuration
=
{
6000
}
onClose
=
{()
=>
this
.
closeAlert
()}
>
<
Alert
onClose
=
{()
=>
this
.
closeAlert
()}
severity
=
{
this
.
state
.
tipeAlert
}
>
{
this
.
state
.
messageAlert
}
<
/Alert
>
<
/Snackbar
>
<
div
className
=
"popup-content background-white border-radius"
style
=
{{
borderRadius
:
8
}}
>
<
div
className
=
"popup-panel grid grid-2x main-color"
style
=
{{
height
:
64
,
borderTopRightRadius
:
8
,
borderTopLeftRadius
:
8
}}
>
<
div
className
=
"col-1"
style
=
{{
maxWidth
:
"inherit"
,
display
:
'flex'
,
alignItems
:
'center'
}}
>
...
...
src/container/MasterData/Perusahaan/VisualPerusahaan.js
View file @
d742784c
import
React
,
{
Component
}
from
'react'
;
import
{
Container
,
Row
,
Col
}
from
"react-bootstrap"
;
import
{
makeStyles
,
createMuiTheme
,
MuiThemeProvider
}
from
'@material-ui/core/styles'
;
import
{
TextField
}
from
'@material-ui/core'
;
import
MenuItem
from
'@material-ui/core/MenuItem'
;
import
{
Typography
,
withStyles
,
Snackbar
}
from
'@material-ui/core'
;
import
Perusahaan
from
"./Perusahaan"
;
import
TreeView
from
'@material-ui/lab/TreeView'
;
import
ExpandMoreIcon
from
'@material-ui/icons/ExpandMore'
;
import
ChevronRightIcon
from
'@material-ui/icons/ChevronRight'
;
import
TreeItem
from
'@material-ui/lab/TreeItem'
;
import
MuiAlert
from
'@material-ui/lab/Alert'
;
import
Nestable
from
'react-nestable/dist/Nestable'
;
import
AddIcon
from
'@material-ui/icons/Add'
;
import
RemoveIcon
from
'@material-ui/icons/Remove'
;
import
api
from
'../../../api'
;
const
Alert
=
withStyles
({
})((
props
)
=>
<
MuiAlert
elevation
=
{
6
}
variant
=
"filled"
{...
props
}
/>
)
;
export
default
class
VisualPerusahaan
extends
Component
{
constructor
(
props
)
{
super
(
props
)
...
...
@@ -40,7 +38,10 @@ export default class VisualPerusahaan extends Component {
},
],
arrayCollapse
:
[],
defaultCollapsed
:
false
defaultCollapsed
:
false
,
alert
:
false
,
tipeAlert
:
''
,
messageAlert
:
''
,
}
}
...
...
@@ -50,9 +51,16 @@ export default class VisualPerusahaan extends Component {
getPerusahaan
()
{
api
.
create
().
getPerusahaanHierarki
().
then
((
response
)
=>
{
if
(
response
.
data
.
status
==
'success'
)
{
this
.
setState
({
items
:
response
.
data
.
data
})
console
.
log
(
response
.
data
.
data
)
console
.
log
(
response
)
if
(
response
.
data
)
{
if
(
response
.
data
.
status
==
'success'
)
{
this
.
setState
({
items
:
response
.
data
.
data
})
console
.
log
(
response
.
data
.
data
)
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
data
.
message
,
tipeAlert
:
'warning'
})
}
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
problem
,
tipeAlert
:
'error'
})
}
})
}
...
...
@@ -98,6 +106,9 @@ export default class VisualPerusahaan extends Component {
)
};
closeAlert
()
{
this
.
setState
({
alert
:
false
})
}
render
()
{
...
...
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