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
d52f604e
Commit
d52f604e
authored
Sep 22, 2020
by
d.arizona
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
markibo
parent
5340be35
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
174 additions
and
92 deletions
+174
-92
CorporateAnnualTarget.js
src/container/BudgetTahunan/CorporateAnnualTarget.js
+174
-92
No files found.
src/container/BudgetTahunan/CorporateAnnualTarget.js
View file @
d52f604e
import
React
,
{
Component
}
from
'react'
;
import
{
Typography
,
Paper
,
createMuiTheme
,
MuiThemeProvider
,
TableCell
,
FormControlLabel
,
TextField
,
Input
,
withStyles
,
makeStyles
,
Snackbar
}
from
'@material-ui/core'
;
import
{
Typography
,
Paper
,
createMuiTheme
,
ThemeProvider
,
MuiThemeProvider
,
TableCell
,
FormControlLabel
,
TextField
,
Input
,
withStyles
,
makeStyles
,
Snackbar
}
from
'@material-ui/core'
;
import
MUIDataTable
from
'mui-datatables'
;
import
NumberFormat
from
'react-number-format'
;
import
api
from
'../../api'
;
...
...
@@ -39,6 +39,17 @@ const style2 = {
zIndex
:
100
};
const
theme
=
createMuiTheme
({
overrides
:
{
// Style sheet name ⚛️
MuiInputBase
:
{
input
:
{
color
:
'#5198ea'
}
}
},
});
export
default
class
CorporateAnnualTarget
extends
Component
{
constructor
(
props
)
{
super
(
props
)
...
...
@@ -54,7 +65,7 @@ export default class CorporateAnnualTarget extends Component {
loading
:
false
,
uomList
:
[],
formulaYtdList
:
{
options
:
[{
value
:
'SUM'
},
{
value
:
'AVG'
},
{
value
:
'
MIN'
},
{
value
:
'MAX
'
}],
options
:
[{
value
:
'SUM'
},
{
value
:
'AVG'
},
{
value
:
'
LAST
'
}],
getOptionLabel
:
(
option
)
=>
titleCase
(
option
.
value
),
},
kpiTypeList
:
[],
...
...
@@ -62,7 +73,8 @@ export default class CorporateAnnualTarget extends Component {
visibleCAT
:
true
,
buttonError
:
true
,
// formulaYTDList: null,,
dataDelete
:
[]
dataDelete
:
[],
dataReal
:
[]
}
this
.
fileHandler
=
this
.
fileHandler
.
bind
(
this
);
...
...
@@ -101,7 +113,7 @@ export default class CorporateAnnualTarget extends Component {
item
.
level
,
""
,
item
.
description
,
item
.
cat
.
weight
,
item
.
type_report_id
==
1
?
`
${
Number
(
item
.
weight
)
*
100
}
%`
:
(
String
(
item
.
cat
.
weight
).
includes
(
'%'
)?
`
${
Number
(
String
(
item
.
cat
.
weight
).
replace
(
'%'
,
''
))
*
100
}
%`
:
`
${
Number
(
item
.
cat
.
weight
)
*
100
}
%`
)
,
item
.
cat
.
uom
,
item
.
cat
.
kpi_type
==
""
?
null
:
{
value
:
item
.
cat
.
kpi_type
},
item
.
cat
.
max_ach
==
""
?
null
:
{
value
:
item
.
cat
.
max_ach
},
...
...
@@ -143,7 +155,7 @@ export default class CorporateAnnualTarget extends Component {
item
.
level
,
""
,
item
.
description
,
item
.
cat
.
weight
,
item
.
type_report_id
==
1
?
`
${
Number
(
item
.
weight
)
*
100
}
%`
:
(
String
(
item
.
cat
.
weight
).
includes
(
'%'
)?
`
${
Number
(
String
(
item
.
cat
.
weight
).
replace
(
'%'
,
''
))
*
100
}
%`
:
`
${
Number
(
item
.
cat
.
weight
)
*
100
}
%`
)
,
item
.
cat
.
uom
,
item
.
cat
.
kpi_type
==
""
?
null
:
{
value
:
item
.
cat
.
kpi_type
},
item
.
cat
.
max_ach
==
""
?
null
:
{
value
:
item
.
cat
.
max_ach
},
...
...
@@ -175,7 +187,7 @@ export default class CorporateAnnualTarget extends Component {
}
}
})
this
.
setState
({
dataTable
,
loading
:
false
})
this
.
setState
({
dataTable
,
loading
:
false
,
dataReal
:
res
})
})
}
...
...
@@ -189,7 +201,7 @@ export default class CorporateAnnualTarget extends Component {
let
url
=
window
.
URL
.
createObjectURL
(
res
);
let
a
=
document
.
createElement
(
'a'
);
a
.
href
=
url
;
a
.
download
=
'Template
Balance Sheet
.xlsx'
;
a
.
download
=
'Template
Master Budget CAT
.xlsx'
;
a
.
click
();
}
}
...
...
@@ -427,6 +439,17 @@ export default class CorporateAnnualTarget extends Component {
"status"
:
"submitted"
,
"cat"
:
data
}
let
totalWeight
=
0
this
.
state
.
dataTable
.
map
((
items
,
indexs
)
=>
{
if
(
items
[
0
]
==
3
)
{
console
.
log
(
items
[
7
])
totalWeight
+=
Number
(
items
[
7
].
replace
(
'%'
,
''
))
}
})
console
.
log
(
totalWeight
)
if
(
totalWeight
<
100
)
{
this
.
setState
({
alert
:
true
,
messageAlert
:
'Total weight less than 100%'
,
tipeAlert
:
'warning'
,
loading
:
false
,
buttonError
:
true
,
editable
:
true
})
}
else
{
api
.
create
().
validateSubmitReport
(
payload
).
then
((
response
)
=>
{
console
.
log
(
response
)
if
(
response
.
data
.
data
.
result
)
{
...
...
@@ -436,6 +459,7 @@ export default class CorporateAnnualTarget extends Component {
}
})
}
}
closeAlert
()
{
this
.
setState
({
alert
:
false
})
...
...
@@ -608,23 +632,72 @@ export default class CorporateAnnualTarget extends Component {
const
handleChange
=
(
value
,
tableMeta
)
=>
{
let
val
=
String
(
value
).
split
(
","
).
join
(
""
)
let
total
=
0
let
lastValz
=
0
dataTable2
[
tableMeta
.
rowIndex
][
tableMeta
.
columnIndex
]
=
Number
(
val
)
dataTable2
[
tableMeta
.
rowIndex
].
map
((
item
,
index
)
=>
{
if
(
index
>=
13
&&
index
<=
24
)
{
let
valItem
=
item
==
undefined
||
item
==
""
?
0
:
item
total
+=
Number
(
valItem
)
if
(
index
==
24
)
{
lastValz
+=
Number
(
valItem
)
}
}
})
dataTable2
[
tableMeta
.
rowIndex
][
25
]
=
total
let
valz
=
dataTable2
[
tableMeta
.
rowIndex
][
11
]
==
null
?
'SUM'
:
dataTable2
[
tableMeta
.
rowIndex
][
11
].
value
dataTable2
[
tableMeta
.
rowIndex
][
25
]
=
(
valz
==
'SUM'
?
total
:
(
valz
==
'AVG'
?
(
total
/
12
)
:
lastValz
))
console
.
log
(
dataTable2
[
tableMeta
.
rowIndex
])
}
const
handleChangeDropdown
=
(
value
,
tableMeta
)
=>
{
dataTable2
[
tableMeta
.
rowIndex
][
tableMeta
.
columnIndex
]
=
value
let
valz
=
value
.
value
let
total
=
0
let
lastValz
=
0
if
(
valz
==
'SUM'
||
valz
==
'AVG'
||
valz
==
'LAST'
)
{
dataTable2
[
tableMeta
.
rowIndex
].
map
((
item
,
index
)
=>
{
if
(
index
>=
13
&&
index
<=
24
)
{
let
valItem
=
item
==
undefined
||
item
==
""
?
0
:
item
total
+=
Number
(
valItem
)
if
(
index
==
24
)
{
lastValz
+=
Number
(
valItem
)
}
}
})
dataTable2
[
tableMeta
.
rowIndex
][
25
]
=
(
valz
==
'SUM'
?
total
:
(
valz
==
'AVG'
?
(
total
/
12
)
:
lastValz
))
}
}
const
handleChangePercentage
=
(
value
,
tableMeta
)
=>
{
dataTable2
[
tableMeta
.
rowIndex
][
tableMeta
.
columnIndex
]
=
value
let
valueReal
=
value
.
replace
(
'%'
,
''
)
let
indexParentDatatable
=
dataTable2
.
findIndex
((
val
)
=>
val
[
1
]
==
tableMeta
.
rowData
[
2
])
let
indexParentReal
=
this
.
state
.
dataReal
.
findIndex
((
val
)
=>
val
.
id
==
tableMeta
.
rowData
[
2
])
// console.log(indexParentDatatable)
// console.log(indexParentReal)
let
valParent
=
dataTable2
[
indexParentDatatable
][
7
]
valParent
.
replace
(
'%'
,
''
)
let
valChild
=
0
dataTable2
.
map
((
item
,
index
)
=>
{
if
(
item
[
2
]
==
dataTable2
[
indexParentDatatable
][
1
]
&&
item
[
1
]
!==
tableMeta
.
rowData
[
1
])
{
let
weightItem
=
item
[
7
]
==
""
?
0
:
item
[
7
].
replace
(
'%'
,
''
)
console
.
log
(
weightItem
)
valChild
+=
Number
(
weightItem
)
}
})
let
endVal
=
''
// console.log(Number(valueReal) + Number(valChild))
// console.log(valueReal)
// console.log(Number(valParent.replace('%', '')))
if
((
Number
(
valueReal
)
+
Number
(
valChild
))
>
Number
(
valParent
.
replace
(
'%'
,
''
)))
{
endVal
=
`
${
Number
(
valParent
.
replace
(
'%'
,
''
))
-
(
Number
(
valChild
))}
%`
console
.
log
(
endVal
)
}
else
{
endVal
=
`
${
Number
(
valueReal
)}
%`
console
.
log
(
endVal
)
}
// console.log(endVal)
dataTable2
[
tableMeta
.
rowIndex
][
tableMeta
.
columnIndex
]
=
endVal
}
const
handleChangeText
=
(
value
,
tableMeta
)
=>
{
...
...
@@ -681,6 +754,7 @@ export default class CorporateAnnualTarget extends Component {
""
,
""
,
""
,
""
,
""
])
...
...
@@ -872,8 +946,11 @@ export default class CorporateAnnualTarget extends Component {
customBodyRender
:
(
value
,
tableMeta
,
updateValue
)
=>
{
return
(
<
div
style
=
{{
textAlign
:
'right'
}}
>
{
tableMeta
.
rowData
[
0
]
===
1
||
tableMeta
.
rowData
[
0
]
===
2
||
tableMeta
.
rowData
[
0
]
===
4
?
{
tableMeta
.
rowData
[
0
]
===
2
||
tableMeta
.
rowData
[
0
]
===
4
?
null
:
tableMeta
.
rowData
[
0
]
===
1
?
value
:
<
div
style
=
{{
flex
:
1
}}
>
<
FormControlLabel
style
=
{{
margin
:
0
}}
...
...
@@ -888,14 +965,6 @@ export default class CorporateAnnualTarget extends Component {
value
=
{
value
}
maxLength
=
{
4
}
onBlur
=
{(
event
)
=>
{
let
valueReal
=
event
.
target
.
value
.
replace
(
'%'
,
''
)
let
some
=
''
console
.
log
(
Number
(
valueReal
)
>
100
)
if
(
Number
(
valueReal
)
>
100
)
{
some
=
'100%'
}
else
{
some
=
event
.
target
.
value
}
// updateValue(some)
handleChangePercentage
(
event
.
target
.
value
,
tableMeta
)
}}
...
...
@@ -925,19 +994,31 @@ export default class CorporateAnnualTarget extends Component {
style
=
{{
margin
:
0
}}
// value={value}
control
=
{
!
handleAction
(
tableMeta
.
rowData
[
2
])?
<
Input
disableUnderline
=
{
true
}
style
=
{{
color
:
"#5198ea"
,
fontSize
:
12
,
textAlign
:
'right'
,
borderColor
:
'transparent'
,
margin
:
0
,
width
:
96
,
backgroundColor
:
'transparent'
}}
style
=
{{
fontSize
:
12
,
textAlign
:
'center'
,
borderColor
:
'transparent'
,
margin
:
0
,
width
:
96
,
backgroundColor
:
'transparent'
,
marginTop
:
-
10
}}
type
=
"text"
placeholder
=
""
defaultValue
=
{
value
}
color
=
{
"#5198ea"
}
disabled
=
{
!
handleAction
(
tableMeta
.
rowData
[
2
])}
on
Change
=
{(
event
)
=>
{
//
console.log(event.target.value)
//
//
updateValue(event.target.value)
//
handleChangeText(event.target.value, tableMeta)
//
console.log(dataTable2)
on
Blur
=
{(
event
)
=>
{
console
.
log
(
event
.
target
.
value
)
// updateValue(event.target.value)
handleChangeText
(
event
.
target
.
value
,
tableMeta
)
console
.
log
(
dataTable2
)
}}
/>
:
<
ThemeProvider
theme
=
{
theme
}
>
<
Input
disableUnderline
=
{
true
}
style
=
{{
fontSize
:
12
,
textAlign
:
'center'
,
borderColor
:
'transparent'
,
margin
:
0
,
width
:
96
,
backgroundColor
:
'transparent'
,
marginBottom
:
-
5
}}
type
=
"text"
placeholder
=
""
defaultValue
=
{
value
}
color
=
{
"#5198ea"
}
disabled
=
{
!
handleAction
(
tableMeta
.
rowData
[
2
])}
onBlur
=
{(
event
)
=>
{
console
.
log
(
event
.
target
.
value
)
// updateValue(event.target.value)
...
...
@@ -945,6 +1026,7 @@ export default class CorporateAnnualTarget extends Component {
console
.
log
(
dataTable2
)
}}
/
>
<
/ThemeProvider
>
}
/
>
}
...
...
@@ -953,7 +1035,7 @@ export default class CorporateAnnualTarget extends Component {
}
}
},
{
name
:
"
Jenis KPI
"
,
name
:
"
KPI Type
"
,
options
:
{
customHeadRender
:
(
columnMeta
)
=>
(
<
TableCell
style
=
{{
...
style2
,
top
:
0
,
zIndex
:
99
,
backgroundColor
:
'#1c71b8'
,
width
:
96
}}
>
...
...
@@ -1689,30 +1771,29 @@ export default class CorporateAnnualTarget extends Component {
),
customBodyRender
:
(
value
,
tableMeta
)
=>
{
return
(
<
div
style
=
{{
width
:
96
}}
>
<
div
style
=
{{
textAlign
:
'right'
}}
>
{
tableMeta
.
rowData
[
0
]
===
1
||
tableMeta
.
rowData
[
0
]
===
2
||
tableMeta
.
rowData
[
0
]
===
4
?
null
:
<
div
style
=
{{
flex
:
1
}}
>
null
:
<
FormControlLabel
style
=
{{
margin
:
0
}}
value
=
{
value
}
control
=
{
<
NumberFormat
thousandSeparator
=
{
true
}
style
=
{{
color
:
"#5198ea"
,
fontSize
:
12
,
textAlign
:
'right'
,
borderColor
:
'transparent'
,
margin
:
0
,
width
:
96
,
backgroundColor
:
'transparent'
}}
<
ThemeProvider
theme
=
{
theme
}
>
<
Input
disableUnderline
=
{
true
}
style
=
{{
fontSize
:
12
,
textAlign
:
'center'
,
borderColor
:
'transparent'
,
margin
:
0
,
width
:
96
,
backgroundColor
:
'transparent'
,
marginBottom
:
-
5
}}
type
=
"text"
placeholder
=
""
v
alue
=
{
value
}
defaultV
alue
=
{
value
}
onBlur
=
{(
event
)
=>
{
// updateValue
(event.target.value)
handleChange
(
event
.
target
.
value
,
tableMeta
)
console
.
log
(
event
.
target
.
value
)
handleChange
Text
(
event
.
target
.
value
,
tableMeta
)
console
.
log
(
dataTable2
)
}}
/
>
<
/ThemeProvider
>
}
/
>
<
/div>
}
<
/div
>
)
...
...
@@ -1728,30 +1809,31 @@ export default class CorporateAnnualTarget extends Component {
),
customBodyRender
:
(
value
,
tableMeta
)
=>
{
return
(
<
div
style
=
{{
width
:
96
}}
>
<
div
style
=
{{
textAlign
:
'right'
}}
>
{
tableMeta
.
rowData
[
0
]
===
1
||
tableMeta
.
rowData
[
0
]
===
2
||
tableMeta
.
rowData
[
0
]
===
4
?
null
:
<
div
style
=
{{
flex
:
1
}}
>
null
:
<
FormControlLabel
style
=
{{
margin
:
0
}}
value
=
{
value
}
//
value={value}
control
=
{
<
NumberFormat
thousandSeparator
=
{
true
}
style
=
{{
color
:
"#5198ea"
,
fontSize
:
12
,
textAlign
:
'right'
,
borderColor
:
'transparent'
,
margin
:
0
,
width
:
96
,
backgroundColor
:
'transparent'
}}
<
ThemeProvider
theme
=
{
theme
}
>
<
Input
disableUnderline
=
{
true
}
style
=
{{
color
:
"#5198ea"
,
fontSize
:
12
,
textAlign
:
'center'
,
borderColor
:
'transparent'
,
margin
:
0
,
width
:
96
,
backgroundColor
:
'transparent'
,
marginBottom
:
-
5
}}
type
=
"text"
placeholder
=
""
v
alue
=
{
value
}
defaultV
alue
=
{
value
}
onBlur
=
{(
event
)
=>
{
console
.
log
(
event
.
target
.
value
)
// updateValue(event.target.value)
handleChange
(
event
.
target
.
value
,
tableMeta
)
handleChange
Text
(
event
.
target
.
value
,
tableMeta
)
console
.
log
(
dataTable2
)
}}
/
>
<
/ThemeProvider
>
}
/
>
<
/div>
}
<
/div
>
)
...
...
@@ -1790,7 +1872,7 @@ export default class CorporateAnnualTarget extends Component {
<
div
style
=
{{
display
:
'flex'
,
justifyContent
:
'space-between'
}}
>
<
div
>
<
Typography
style
=
{{
fontSize
:
'11px'
,
color
:
'#4b4b4b'
}}
>
{
this
.
props
.
company
.
company_name
}
<
/Typography
>
<
Typography
style
=
{{
fontSize
:
'11px'
,
color
:
'#4b4b4b'
}}
>
Period
e
:
{
this
.
props
.
periode
}
(
rev
.{
this
.
props
.
revision
})
<
/Typography
>
<
Typography
style
=
{{
fontSize
:
'11px'
,
color
:
'#4b4b4b'
}}
>
Period
:
{
this
.
props
.
periode
}
(
rev
.{
this
.
props
.
revision
})
<
/Typography
>
<
Typography
style
=
{{
fontSize
:
'11px'
,
color
:
'#4b4b4b'
}}
>
in
IDR
mn
<
/Typography
>
<
/div
>
<
div
style
=
{{
width
:
'50%'
}}
>
...
...
@@ -1906,7 +1988,7 @@ export default class CorporateAnnualTarget extends Component {
marginRight
:
20
}}
onClick
=
{()
=>
{
this
.
setState
({
loading
:
true
},
()
=>
{
this
.
setState
({
loading
:
true
,
dataTable
:
dataTable2
},
()
=>
{
setTimeout
(()
=>
{
this
.
handleValidate
()
},
100
);
...
...
@@ -1947,7 +2029,7 @@ export default class CorporateAnnualTarget extends Component {
<
Typography
style
=
{{
fontSize
:
'11px'
,
color
:
'#4b4b4b'
}}
>
in
IDR
mn
<
/Typography
>
<
/div
>
{
this
.
state
.
dataLoaded
&&
(
<
div
style
=
{{
marginTop
:
20
,
width
:
this
.
props
.
width
-
(
this
.
props
.
open
===
true
?
400
:
150
)
,
height
:
this
.
props
.
height
-
400
}}
>
<
div
style
=
{{
marginTop
:
20
,
width
:
this
.
props
.
width
-
(
this
.
props
.
open
===
true
?
400
:
150
)
}}
>
{
!
this
.
state
.
loading
&&
<
MuiThemeProvider
theme
=
{
getMuiTheme
()}
>
<
MUIDataTable
data
=
{
dataTable2
}
...
...
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