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
6bfa93af
Commit
6bfa93af
authored
Feb 08, 2021
by
Riri Novita
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'riri' into 'master'
ilangin month See merge request
!1119
parents
616d4e34
3a1fad0d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
83 additions
and
136 deletions
+83
-136
SummaryOfTriputra.js
src/container/SummaryTriputra/SummaryOfTriputra.js
+83
-136
No files found.
src/container/SummaryTriputra/SummaryOfTriputra.js
View file @
6bfa93af
...
@@ -42,81 +42,12 @@ export default class SummaryOfTriputra extends Component {
...
@@ -42,81 +42,12 @@ export default class SummaryOfTriputra extends Component {
componentDidMount
()
{
componentDidMount
()
{
// this.getDetailUser()
// this.getDetailUser()
this
.
setState
({
report
:
this
.
state
.
reportType
[
0
],
loading
:
true
})
this
.
setState
({
report
:
this
.
state
.
reportType
[
0
],
loading
:
true
},
()
=>
{
this
.
getPeriode
()
console
.
log
(
this
.
state
.
report
);
// this.getMonth()
this
.
getPeriode
()
}
getDetailUser
()
{
let
userId
=
localStorage
.
getItem
(
Constant
.
USER
)
api
.
create
().
getDetailUser
(
userId
).
then
((
response
)
=>
{
if
(
response
.
data
)
{
if
(
response
.
ok
)
{
if
(
response
.
data
.
status
===
'success'
)
{
this
.
setState
({
userCompany
:
response
.
data
.
data
.
company
},
()
=>
{
this
.
getCompanyActive
()
})
}
}
}
})
}
getCompanyActive
()
{
api
.
create
().
getPerusahaanActive
().
then
((
response
)
=>
{
// console.log(response);
if
(
response
.
data
)
{
if
(
response
.
data
.
status
===
'success'
)
{
let
data
=
response
.
data
.
data
let
comID
=
this
.
state
.
rawData
?
this
.
state
.
rawData
.
company_id
:
0
let
companyData
=
data
.
map
((
item
)
=>
{
return
{
company_id
:
item
.
company_id
,
company_name
:
item
.
company_name
,
}
})
let
arrayBaru
=
[]
this
.
state
.
userCompany
.
map
((
item
,
index
)
=>
{
let
indexID
=
companyData
.
findIndex
((
val
)
=>
val
.
company_id
==
item
)
if
(
indexID
!==
-
1
)
{
arrayBaru
.
push
(
companyData
[
indexID
])
}
})
let
defaultProps
=
{
options
:
arrayBaru
,
getOptionLabel
:
(
option
)
=>
titleCase
(
option
.
company_name
),
};
let
index
=
arrayBaru
.
findIndex
((
val
)
=>
val
.
company_id
==
comID
)
this
.
setState
({
listCompany
:
defaultProps
,
company
:
arrayBaru
.
length
<
1
?
companyData
[
0
]
:
(
index
==
-
1
?
arrayBaru
[
0
]
:
arrayBaru
[
index
])
},
()
=>
{
this
.
getLastPeriod
()
})
}
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
.
problem
,
tipeAlert
:
'error'
,
listCompany
:
null
,
company
:
null
})
}
})
}
getLastPeriod
()
{
api
.
create
().
getLastPeriod
(
this
.
state
.
company
.
company_id
).
then
(
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
()
})
}
})
})
// this.getMonth()
}
}
getPeriode
()
{
getPeriode
()
{
...
@@ -129,7 +60,7 @@ export default class SummaryOfTriputra extends Component {
...
@@ -129,7 +60,7 @@ export default class SummaryOfTriputra extends Component {
let
data
=
[]
let
data
=
[]
response
.
data
.
data
.
map
((
item
)
=>
{
response
.
data
.
data
.
map
((
item
)
=>
{
// if (this.state.isApprover) {
// if (this.state.isApprover) {
if
(
item
>=
2000
&&
item
<=
(
Number
(
currentYear
)))
{
if
(
item
>=
2000
&&
item
<=
(
Number
(
currentYear
)
+
1
))
{
data
.
push
(
item
)
data
.
push
(
item
)
}
}
// } else {
// } else {
...
@@ -203,65 +134,65 @@ export default class SummaryOfTriputra extends Component {
...
@@ -203,65 +134,65 @@ export default class SummaryOfTriputra extends Component {
})
})
}
}
getReportType
()
{
//
getReportType() {
let
payload
=
{
//
let payload = {
"company_id"
:
this
.
state
.
company
.
company_id
,
//
"company_id": this.state.company.company_id,
"periode"
:
this
.
state
.
periode
.
periode
,
//
"periode": this.state.periode.periode,
"report_type"
:
"Master Budget"
,
//
"report_type": "Master Budget",
}
//
}
api
.
create
().
getReportTypeBody
(
payload
).
then
(
response
=>
{
//
api.create().getReportTypeBody(payload).then(response => {
console
.
log
(
response
);
//
console.log(response);
if
(
response
.
data
)
{
//
if (response.data) {
if
(
response
.
data
.
status
===
"success"
)
{
//
if (response.data.status === "success") {
if
(
this
.
state
.
report
.
value
===
1
)
{
//
if (this.state.report.value === 1) {
response
.
data
.
data
.
map
((
item
,
index
)
=>
{
//
response.data.data.map((item, index) => {
if
(
item
.
report_name
===
'MTD Report'
)
{
//
if (item.report_name === 'MTD Report') {
this
.
setState
({
revisionType
:
item
.
revision
},
()
=>
{
//
this.setState({ revisionType: item.revision }, ()=> {
this
.
getSubmission
()
//
this.getSubmission()
})
//
})
}
//
}
})
//
})
}
else
if
(
this
.
state
.
report
.
value
===
1
)
{
//
} else if (this.state.report.value === 1) {
response
.
data
.
data
.
map
((
item
,
index
)
=>
{
//
response.data.data.map((item, index) => {
if
(
item
.
report_name
===
'YTD Report'
)
{
//
if (item.report_name === 'YTD Report') {
this
.
setState
({
revisionType
:
item
.
revision
},
()
=>
{
//
this.setState({ revisionType: item.revision }, ()=> {
this
.
getSubmission
()
//
this.getSubmission()
})
//
})
}
//
}
})
//
})
}
else
{
//
} else {
this
.
setState
({
revisionType
:
0
},
()
=>
{
//
this.setState({ revisionType: 0 }, ()=> {
this
.
getSubmission
()
//
this.getSubmission()
})
//
})
}
//
}
}
//
}
}
//
}
})
//
})
}
//
}
getSubmission
()
{
//
getSubmission() {
this
.
setState
({
loading
:
true
})
//
this.setState({ loading: true })
let
payload
=
{
//
let payload = {
"company_id"
:
this
.
state
.
company
.
company_id
,
//
"company_id": this.state.company.company_id,
"periode"
:
this
.
state
.
periode
.
periode
,
//
"periode": this.state.periode.periode,
"is_approver"
:
true
//
"is_approver": true
}
//
}
api
.
create
().
getSubmission
(
payload
).
then
(
response
=>
{
//
api.create().getSubmission(payload).then(response => {
// console.log(response)
//
// console.log(response)
if
(
response
.
data
)
{
//
if (response.data) {
if
(
response
.
data
.
status
===
"success"
)
{
//
if (response.data.status === "success") {
this
.
setState
({
//
this.setState({
submissionID
:
response
.
data
.
data
.
submission_id
,
//
submissionID: response.data.data.submission_id,
lastRevision
:
response
.
data
.
data
.
last_revision
,
//
lastRevision: response.data.data.last_revision,
},
()
=>
{
//
}, () => {
this
.
getDataTable
()
//
this.getDataTable()
})
//
})
}
else
{
//
} else {
this
.
setState
({
submissionID
:
null
,
loading
:
false
})
//
this.setState({ submissionID: null, loading: false })
}
//
}
}
//
}
})
//
})
}
//
}
getDataTable
()
{
getDataTable
()
{
let
payload
=
{
let
payload
=
{
...
@@ -1470,8 +1401,23 @@ export default class SummaryOfTriputra extends Component {
...
@@ -1470,8 +1401,23 @@ export default class SummaryOfTriputra extends Component {
getOptionLabel
=
{(
option
)
=>
titleCase
(
option
.
label
)}
getOptionLabel
=
{(
option
)
=>
titleCase
(
option
.
label
)}
id
=
"typereport"
id
=
"typereport"
onChange
=
{(
event
,
newInputValue
)
=>
this
.
setState
({
report
:
newInputValue
,
loading
:
true
,
previewTable
:
false
},
()
=>
{
onChange
=
{(
event
,
newInputValue
)
=>
this
.
setState
({
report
:
newInputValue
,
loading
:
true
,
previewTable
:
false
},
()
=>
{
let
data
=
this
.
state
.
listPeriode
.
options
let
currentYear
=
new
Date
().
getFullYear
()
let
periode
=
(
this
.
state
.
lastPeriod
==
""
?
String
(
Number
(
currentYear
)
+
1
)
:
this
.
state
.
lastPeriod
)
let
dateNow
=
new
Date
()
dateNow
.
setMonth
(
dateNow
.
getMonth
()
-
1
);
let
yearNow
=
dateNow
.
getFullYear
()
// this.getSubmission()
// this.getSubmission()
this
.
getDataTable
()
if
(
!
String
(
this
.
state
.
report
.
label
).
toLocaleLowerCase
().
includes
(
'historical'
))
{
let
index
=
data
.
sort
((
a
,
b
)
=>
a
-
b
).
findIndex
((
val
)
=>
val
.
periode
==
yearNow
)
// console.log(index)
this
.
setState
({
periode
:
data
[
index
]},
()
=>
{
this
.
getDataTable
()
})
}
else
{
this
.
getDataTable
()
}
})}
})}
disableClearable
disableClearable
style
=
{{
width
:
250
}}
style
=
{{
width
:
250
}}
...
@@ -1496,7 +1442,8 @@ export default class SummaryOfTriputra extends Component {
...
@@ -1496,7 +1442,8 @@ export default class SummaryOfTriputra extends Component {
value
=
{
this
.
state
.
periode
}
value
=
{
this
.
state
.
periode
}
/
>
/
>
<
/div
>
<
/div
>
<
div
style
=
{{
marginTop
:
15
}}
>
{(
this
.
state
.
report
!=
null
&&
!
String
(
this
.
state
.
report
.
label
).
toLocaleLowerCase
().
includes
(
'historical'
))
&&
<
div
style
=
{{
marginTop
:
15
}}
>
<
Autocomplete
<
Autocomplete
{...
this
.
state
.
listMonths
}
{...
this
.
state
.
listMonths
}
// getOptionLabel={(option) => titleCase(option.label)}
// getOptionLabel={(option) => titleCase(option.label)}
...
@@ -1509,7 +1456,7 @@ export default class SummaryOfTriputra extends Component {
...
@@ -1509,7 +1456,7 @@ export default class SummaryOfTriputra extends Component {
renderInput
=
{(
params
)
=>
<
TextField
{...
params
}
label
=
"Months"
margin
=
"normal"
style
=
{{
marginTop
:
7
}}
/>
}
renderInput
=
{(
params
)
=>
<
TextField
{...
params
}
label
=
"Months"
margin
=
"normal"
style
=
{{
marginTop
:
7
}}
/>
}
value
=
{
this
.
state
.
month
}
value
=
{
this
.
state
.
month
}
/
>
/
>
<
/div
>
<
/div>
}
<
/div
>
<
/div
>
<
div
>
<
div
>
<
div
style
=
{{
display
:
'flex'
,
justifyContent
:
'space-between'
,
padding
:
'0px 20px 10px 20px'
}}
>
<
div
style
=
{{
display
:
'flex'
,
justifyContent
:
'space-between'
,
padding
:
'0px 20px 10px 20px'
}}
>
...
...
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