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
45e1f86d
Commit
45e1f86d
authored
Nov 08, 2020
by
Dida Adams Arizona
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'didam' into 'master'
Didam See merge request
!626
parents
10f28123
06308efb
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
109 additions
and
42 deletions
+109
-42
BudgetTahunan.js
src/container/BudgetTahunan.js
+109
-42
No files found.
src/container/BudgetTahunan.js
View file @
45e1f86d
...
...
@@ -66,7 +66,8 @@ export default class BudgetTahunan extends Component {
latestPeriode
:
''
,
minDateRevision
:
new
Date
(),
maxDateRevision
:
new
Date
(),
btnApprove
:
false
btnApprove
:
false
,
isAdmin
:
false
}
this
.
myRef
=
React
.
createRef
()
this
.
fileHandler
=
this
.
fileHandler
.
bind
(
this
);
...
...
@@ -80,7 +81,7 @@ export default class BudgetTahunan extends Component {
})
this
.
props
.
selectIndex
(
'Master Budget & CAT'
)
if
(
this
.
props
.
location
.
state
!==
undefined
)
{
// console.log(this.props);
//
//
console.log(this.props);
this
.
setState
({
userType
:
this
.
props
.
location
.
state
.
userType
,
intent
:
'Home'
,
lastPeriod
:
this
.
props
.
location
.
state
.
rawData
.
periode
,
rawData
:
this
.
props
.
location
.
state
.
rawData
},
()
=>
{
this
.
checkApprover
()
})
...
...
@@ -89,15 +90,45 @@ export default class BudgetTahunan extends Component {
}
}
getRole
(
id
)
{
api
.
create
().
getDetailRole
(
id
).
then
((
response
)
=>
{
if
(
response
.
data
)
{
if
(
response
.
ok
)
{
if
(
response
.
data
.
status
===
'success'
)
{
// this.setState({ tempData: response.data.data, privileges: response.data.data.privileges })
// // console.log(response.data.data)
if
(
String
(
response
.
data
.
data
.
role_name
).
toLocaleLowerCase
()
==
'superadmin'
)
{
this
.
setState
({
isAdmin
:
true
})
}
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
data
.
message
,
tipeAlert
:
'warning'
},
()
=>
{
if
(
response
.
data
.
message
.
includes
(
"Someone Logged In"
))
{
setTimeout
(()
=>
{
localStorage
.
removeItem
(
Constant
.
TOKEN
)
window
.
location
.
reload
();
},
1000
);
}
})
}
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
data
.
message
,
tipeAlert
:
'error'
})
}
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
problem
,
tipeAlert
:
'error'
})
}
})
}
componentWillUnmount
()
{
document
.
body
.
style
.
overflow
=
'unset'
;
}
checkApprover
()
{
api
.
create
().
checkApprover
().
then
(
response
=>
{
// console.log(response.data.data)
if
(
response
.
data
)
{
if
(
response
.
data
.
status
===
"success"
)
{
// console.log(response);
//
//
console.log(response);
if
(
response
.
data
.
data
.
is_approver
===
true
)
{
this
.
setState
({
isApprover
:
true
,
checkApprover
:
true
},
()
=>
this
.
getPeriode
())
...
...
@@ -126,7 +157,7 @@ export default class BudgetTahunan extends Component {
"periode"
:
this
.
state
.
periode
.
periode
}
api
.
create
().
getCompanySubmitted
(
body
).
then
(
response
=>
{
// console.log(response);
//
//
console.log(response);
if
(
response
.
data
)
{
if
(
response
.
data
.
status
===
'success'
)
{
if
(
response
.
data
.
data
.
length
>
0
)
{
...
...
@@ -148,7 +179,7 @@ export default class BudgetTahunan extends Component {
}
this
.
setState
({
listCompany
:
defaultProps
,
company
:
indexID
==
null
?
companyData
[
0
]
:
companyData
[
indexID
]},
()
=>
{
// console.log(response.data.data);
//
//
console.log(response.data.data);
if
(
response
.
data
.
data
.
length
>
0
)
{
this
.
getRevision
()
}
else
{
...
...
@@ -184,13 +215,13 @@ export default class BudgetTahunan extends Component {
"revision"
:
this
.
state
.
revision
.
revision
,
}
api
.
create
().
getMasterBudgetAtt
(
payload
).
then
(
response
=>
{
// console.log(response)
//
//
console.log(response)
if
(
response
.
data
)
{
if
(
response
.
data
.
status
===
"success"
)
{
this
.
setState
({
listAttachment
:
response
.
data
.
data
})
}
}
// console.log(response);
//
//
console.log(response);
})
}
...
...
@@ -201,7 +232,7 @@ export default class BudgetTahunan extends Component {
"report_type"
:
"Master Budget"
,
}
api
.
create
().
getReportTypeBody
(
payload
).
then
(
response
=>
{
console
.
log
(
response
);
//
console.log(response);
if
(
response
.
data
)
{
if
(
response
.
data
.
status
===
"success"
)
{
let
dataTable
=
response
.
data
.
data
.
map
((
item
,
index
)
=>
{
...
...
@@ -225,7 +256,7 @@ export default class BudgetTahunan extends Component {
])
}
})
// console.log(dataTableRevision);
//
//
console.log(dataTableRevision);
this
.
setState
({
dataTable
,
loading
:
false
,
dataTableRevision
,
dataForRevision
:
response
.
data
.
data
},
()
=>
{
document
.
body
.
style
.
overflow
=
'unset'
;
})
...
...
@@ -244,7 +275,7 @@ export default class BudgetTahunan extends Component {
"periode"
:
this
.
state
.
periode
.
periode
}
api
.
create
().
getSubmitMasterBudget
(
body
).
then
(
response
=>
{
// console.log(response);
//
//
console.log(response);
if
(
response
.
data
)
{
if
(
response
.
data
.
status
===
"success"
)
{
this
.
setState
({
isSubmit
:
response
.
data
.
data
.
is_can_submit
},
()
=>
{
...
...
@@ -262,6 +293,7 @@ export default class BudgetTahunan extends Component {
if
(
response
.
data
)
{
if
(
response
.
ok
)
{
if
(
response
.
data
.
status
===
'success'
)
{
this
.
getRole
(
response
.
data
.
data
.
role_id
)
this
.
setState
({
userCompany
:
response
.
data
.
data
.
company
},
()
=>
{
this
.
getCompanyActive
()
})
...
...
@@ -273,7 +305,7 @@ export default class BudgetTahunan extends Component {
getCompanyActive
()
{
api
.
create
().
getPerusahaanActive
().
then
((
response
)
=>
{
// console.log(response);
//
//
console.log(response);
if
(
response
.
data
)
{
if
(
response
.
data
.
status
===
'success'
)
{
let
data
=
response
.
data
.
data
...
...
@@ -319,7 +351,7 @@ export default class BudgetTahunan extends Component {
getLastPeriod
()
{
api
.
create
().
getLastPeriod
(
this
.
state
.
company
.
company_id
).
then
(
response
=>
{
// console.log(response);
//
//
console.log(response);
if
(
response
.
data
.
status
===
"success"
)
{
this
.
setState
({
lastPeriod
:
response
.
data
.
data
.
last_periode
,
latestPeriode
:
response
.
data
.
data
.
latest_periode
},
()
=>
{
this
.
getPeriode
()
...
...
@@ -333,7 +365,7 @@ export default class BudgetTahunan extends Component {
// let dateNow = new Date
// let year = this.state.rawData ? this.state.rawData.periode : format(dateNow, 'yyyy')
let
currentYear
=
new
Date
().
getFullYear
()
// console.log(currentYear)
//
//
console.log(currentYear)
if
(
response
.
data
)
{
if
(
response
.
data
.
status
===
"success"
)
{
let
data
=
[]
...
...
@@ -359,10 +391,10 @@ export default class BudgetTahunan extends Component {
};
let
periode
=
(
this
.
state
.
lastPeriod
==
""
?
String
(
Number
(
currentYear
)
+
1
)
:
this
.
state
.
lastPeriod
)
let
index
=
data
.
sort
((
a
,
b
)
=>
a
-
b
).
findIndex
((
val
)
=>
val
===
periode
)
// console.log(data)
// console.log(this.state.latestPeriode)
// console.log(periodeData)
// console.log(index)
//
//
console.log(data)
//
//
console.log(this.state.latestPeriode)
//
//
console.log(periodeData)
//
//
console.log(index)
this
.
setState
({
listPeriode
:
defaultProps
,
periode
:
index
===
-
1
?
periodeData
[
0
]
:
periodeData
[
index
]
},
()
=>
{
if
(
this
.
state
.
isApprover
===
true
)
{
this
.
getCompanySubmitted
()
...
...
@@ -381,7 +413,7 @@ export default class BudgetTahunan extends Component {
"periode"
:
this
.
state
.
periode
.
periode
}
api
.
create
().
getRevision
(
payload
).
then
(
response
=>
{
// console.log(response);
//
//
console.log(response);
if
(
response
.
data
)
{
if
(
response
.
data
.
status
===
"success"
)
{
let
data
=
response
.
data
.
data
...
...
@@ -423,7 +455,7 @@ export default class BudgetTahunan extends Component {
"is_approver"
:
this
.
state
.
isApprover
}
api
.
create
().
getSubmission
(
payload
).
then
(
response
=>
{
// console.log(response)
// console.log(response
.data.data.last_status
)
if
(
response
.
data
)
{
if
(
response
.
data
.
status
===
"success"
)
{
this
.
setState
({
...
...
@@ -435,11 +467,11 @@ export default class BudgetTahunan extends Component {
btnApprove
:
response
.
data
.
data
.
is_submit
,
// loading: false
},
()
=>
{
// console.log(this.state.lastStatus);
//
//
console.log(this.state.lastStatus);
this
.
historyApproval
()
this
.
getLatestPeriodSubmit
()
api
.
create
().
checkApprover
().
then
(
response
=>
{
// console.log(response);
//
//
console.log(response);
if
(
response
.
data
.
data
.
is_approver
===
true
)
{
this
.
setState
({
isApprover
:
true
,
checkApprover
:
true
})
}
else
{
...
...
@@ -471,7 +503,7 @@ export default class BudgetTahunan extends Component {
"periode"
:
this
.
state
.
periode
.
periode
}
api
.
create
().
historyApproval
(
body
).
then
(
response
=>
{
// console.log(response);
//
//
console.log(response);
if
(
response
.
data
.
data
.
length
>
0
)
{
let
dataTableHistory
=
response
.
data
.
data
.
map
(
item
=>
{
return
[
...
...
@@ -502,15 +534,16 @@ export default class BudgetTahunan extends Component {
"min_periode"
:
moment
(
this
.
state
.
minDateRevision
).
format
(
'YYYY-MM-DD'
),
"max_periode"
:
moment
(
this
.
state
.
maxDateRevision
).
format
(
'YYYY-MM-DD'
)
}
// console.log(payload)
// // console.log(payload)
// // console.log(body)
api
.
create
().
approvalSubmission
(
body
).
then
((
res
)
=>
{
// console.log(res)
//
//
console.log(res)
// this.setState({ loading: false }, () => {
this
.
getSubmission
()
// })
if
(
type
==
'revision'
)
{
api
.
create
().
createPeriodeRevision
(
payload
).
then
((
res
))
}
this
.
getSubmission
()
})
}
...
...
@@ -521,7 +554,7 @@ export default class BudgetTahunan extends Component {
}
else
{
items
=
item
}
// console.log(this.state.dataForRevision);
//
//
console.log(this.state.dataForRevision);
this
.
state
.
dataForRevision
.
map
(
i
=>
{
if
(
i
.
report_name
===
items
)
{
if
(
i
.
revision
!==
revision
)
{
...
...
@@ -608,9 +641,9 @@ export default class BudgetTahunan extends Component {
fileHandler
=
(
event
)
=>
{
let
fileObj
=
event
ExcelRenderer
(
fileObj
,
(
err
,
resp
)
=>
{
// console.log(resp)
//
//
console.log(resp)
if
(
err
)
{
// console.log(err);
//
//
console.log(err);
}
else
{
const
formData
=
new
FormData
();
...
...
@@ -637,7 +670,7 @@ export default class BudgetTahunan extends Component {
deleteAttachment
(
item
)
{
api
.
create
().
deleteAttachment
(
item
.
attachment_id
).
then
(
response
=>
{
// console.log(response);
//
//
console.log(response);
if
(
response
.
data
)
{
if
(
response
.
data
.
status
===
"success"
)
{
this
.
getSubmission
()
...
...
@@ -654,9 +687,9 @@ export default class BudgetTahunan extends Component {
this
.
setState
({
loading
:
true
},
()
=>
{
document
.
body
.
style
.
overflow
=
'hidden'
;
})
// console.log(JSON.stringify(data));
//
//
console.log(JSON.stringify(data));
api
.
create
(
'UPLOAD'
).
createSubmitReport
(
data
).
then
(
response
=>
{
// console.log(response);
//
//
console.log(response);
if
(
response
.
data
)
{
if
(
response
.
data
.
status
===
"success"
)
{
this
.
getSubmission
()
...
...
@@ -678,9 +711,9 @@ export default class BudgetTahunan extends Component {
async
downloadAttachment
(
fileurl
,
name
)
{
let
length
=
name
.
split
(
"."
).
length
let
fileType
=
name
.
split
(
"."
)[
length
-
1
]
// console.log(fileType);
//
//
console.log(fileType);
let
url
=
`https://tia.eksad.com/tia-reporting-dev/public/transaction/master_budget/download_attachment?fileName=
${
fileurl
}
&&fileType=
${
fileType
}
`
// console.log(url);
//
//
console.log(url);
let
res
=
await
fetch
(
`https://tia.eksad.com/tia-reporting-dev/public/transaction/master_budget/download_attachment?fileName=
${
fileurl
}
&&fileType=
${
fileType
}
`
)
...
...
@@ -721,7 +754,7 @@ export default class BudgetTahunan extends Component {
submission_id
:
this
.
state
.
submissionID
}
api
.
create
().
submitMasterBudget
(
body
).
then
(
response
=>
{
// console.log(response);
//
//
console.log(response);
if
(
response
.
data
)
{
if
(
response
.
data
.
status
===
"success"
)
{
this
.
getSubmission
()
...
...
@@ -734,9 +767,9 @@ export default class BudgetTahunan extends Component {
})
}
// if (array.includes("not-yet" || "draft")) {
// console.log('gagal');
//
//
console.log('gagal');
// } else {
// console.log('masuk');
//
//
console.log('masuk');
// }
}
...
...
@@ -750,7 +783,7 @@ export default class BudgetTahunan extends Component {
remarksKosong
+=
1
}
})
console
.
log
(
arrayRevisi
)
//
console.log(arrayRevisi)
if
(
arrayRevisi
.
length
==
0
||
remarksKosong
>
0
)
{
this
.
setState
({
alert
:
true
,
messageAlert
:
'Remarks Cannot be Empty'
,
tipeAlert
:
'error'
})
}
else
{
...
...
@@ -781,7 +814,7 @@ export default class BudgetTahunan extends Component {
<
Select
value
=
{
val
}
onChange
=
{
event
=>
{
// console.log(event.target)
//
//
console.log(event.target)
updateValue
(
event
.
target
.
value
)
this
.
handleChange
(
event
.
target
.
value
,
tableMeta
)
}}
...
...
@@ -909,10 +942,10 @@ export default class BudgetTahunan extends Component {
defaultValue
=
{
value
}
color
=
{
"#5198ea"
}
onBlur
=
{(
event
)
=>
{
// console.log(event.target.value)
//
//
console.log(event.target.value)
// updateValue(event.target.value)
handleChangeText
(
event
.
target
.
value
,
tableMeta
)
// console.log(dataTable2)
//
//
console.log(dataTable2)
}}
/>
}
/>
...
...
@@ -950,7 +983,7 @@ export default class BudgetTahunan extends Component {
detailRevisiCheck
.
splice
(
indexId
,
1
)
}
this
.
setState
({
detailRevisiCheck
})
// console.log(detailRevisiCheck)
//
//
console.log(detailRevisiCheck)
}
const
options
=
{
...
...
@@ -1198,7 +1231,41 @@ export default class BudgetTahunan extends Component {
<
/div
>
)}
<
/div
>
{
this
.
state
.
checkApprover
===
true
?
{
this
.
state
.
isAdmin
&&
this
.
state
.
lastStatus
==
'APPROVED'
?
<
div
className
=
"grid grid-2x"
style
=
{{
borderTop
:
'solid 1px #c4c4c4'
,
padding
:
10
,
backgroundColor
:
'#f5f5f5'
,
width
:
'100%'
,
}}
>
<
div
className
=
"col-1"
/>
<
div
className
=
"col-2"
style
=
{{
display
:
'flex'
,
justifyContent
:
'flex-end'
,
maxWidth
:
'100%'
}}
>
<
button
style
=
{{
backgroundColor
:
'transparent'
,
cursor
:
'pointer'
,
borderColor
:
'transparent'
,
outline
:
'none'
,
marginRight
:
20
}}
onClick
=
{()
=>
this
.
setState
({
visibleRevision
:
true
})}
>
<
div
style
=
{{
backgroundColor
:
'#019ce5'
,
width
:
105
,
height
:
25
,
borderRadius
:
3
,
justifyContent
:
'center'
,
display
:
'flex'
,
alignItems
:
'center'
}}
>
<
Typography
style
=
{{
fontSize
:
'11px'
,
color
:
'#fff'
,
textAlign
:
'center'
}}
>
Revision
<
/Typography
>
<
/div
>
<
/button
>
{
/* <button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
outline: 'none',
}}
onClick={() => this.approvalSubmission('approve')}
>
<div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Approve</Typography>
</div>
</button> */
}
<
/div
>
<
/div
>
:
this
.
state
.
checkApprover
===
true
?
this
.
state
.
lastStatus
===
'WAITING FOR REVIEW'
?
<
div
style
=
{{
borderTop
:
'solid 1px #c4c4c4'
,
padding
:
10
,
backgroundColor
:
'#f5f5f5'
,
width
:
'100%'
,
display
:
'flex'
,
justifyContent
:
'flex-end'
}}
>
<
button
...
...
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