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
45b7b38b
Commit
45b7b38b
authored
Feb 24, 2021
by
Faisal Hamdi
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'faisal' into 'master'
editMasterDataCat See merge request
!1215
parents
9e2b67f2
3df18b93
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
152 deletions
+34
-152
EditMasterDataCAT.js
src/container/MasterData/MasterDataCAT/EditMasterDataCAT.js
+33
-124
MasterDataCAT.js
src/container/MasterData/MasterDataCAT/MasterDataCAT.js
+1
-28
No files found.
src/container/MasterData/MasterDataCAT/EditMasterDataCAT.js
View file @
45b7b38b
...
...
@@ -16,6 +16,7 @@ export default class EditMasterDataCAT extends Component {
constructor
(
props
)
{
super
(
props
)
this
.
state
=
{
loading
:
true
,
company
:
null
,
parent
:
null
,
reportType
:
null
,
...
...
@@ -26,13 +27,15 @@ export default class EditMasterDataCAT extends Component {
listPeriode
:
null
,
errorWeight
:
false
,
msgErrorWeight
:
''
,
getParent
:
[]
getParent
:
[],
periode
:
null
,
created_by
:
''
,
updated_by
:
''
}
}
componentDidMount
()
{
this
.
getInputType
()
this
.
getPerusahaan
()
this
.
getReportType
()
let
date
=
format
(
new
Date
,
'yyyy-MM-dd'
)
this
.
setState
({
...
...
@@ -65,7 +68,7 @@ export default class EditMasterDataCAT extends Component {
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
comID
=
this
.
props
.
data
[
8
]
let
companyData
=
data
.
map
((
item
)
=>
{
return
{
company_id
:
item
.
company_id
,
...
...
@@ -137,8 +140,8 @@ export default class EditMasterDataCAT extends Component {
};
// let periode = (this.state.lastPeriod == "" ? String(Number(currentYear) + 1) : this.state.lastPeriod)
let
periode
=
String
(
Number
(
currentYear
))
let
index
=
data
.
sort
((
a
,
b
)
=>
a
-
b
).
findIndex
((
val
)
=>
val
==
=
periode
)
// console.log(data)
let
index
=
data
.
sort
((
a
,
b
)
=>
a
-
b
).
findIndex
((
val
)
=>
val
==
this
.
props
.
data
[
6
]
)
// console.log(
this.props.
data)
// console.log(this.state.latestPeriode)
// console.log(periodeData)
console
.
log
(
index
)
...
...
@@ -181,7 +184,7 @@ export default class EditMasterDataCAT extends Component {
handleReportName
(
item
)
{
let
indexString
=
String
(
item
).
indexOf
(
'-'
)
let
gantiNama
=
String
(
item
).
substr
(
0
,
indexString
)
let
gantiNama
=
indexString
===
-
1
?
item
:
String
(
item
).
substr
(
0
,
indexString
)
return
gantiNama
}
...
...
@@ -219,7 +222,7 @@ export default class EditMasterDataCAT extends Component {
"detail"
:
simpan
}
console
.
log
(
payload
)
this
.
props
.
cre
ateReportItems
(
payload
)
this
.
props
.
upd
ateReportItems
(
payload
)
}
...
...
@@ -261,48 +264,6 @@ export default class EditMasterDataCAT extends Component {
})
}
getPerusahaan
()
{
api
.
create
().
getPerusahaanActive
().
then
((
response
)
=>
{
// console.log(response)
if
(
response
.
data
)
{
if
(
response
.
ok
)
{
if
(
response
.
data
.
status
===
'success'
)
{
let
data
=
response
.
data
.
data
let
companyData
=
data
.
map
((
item
)
=>
{
return
{
company_id
:
item
.
company_id
,
company_name
:
item
.
company_name
}
})
companyData
.
push
({
company_id
:
0
,
company_name
:
'Default'
})
let
typeProps
=
{
options
:
companyData
.
sort
((
a
,
b
)
=>
a
.
company_id
-
b
.
company_id
),
getOptionLabel
:
(
option
)
=>
option
.
company_name
,
};
this
.
setState
({
listCompany
:
typeProps
,
companyData
:
response
.
data
.
data
})
}
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
);
}
})
// alert(response.data.message)
}
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
data
.
message
,
tipeAlert
:
'error'
})
}
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
problem
,
tipeAlert
:
'error'
})
}
})
}
getReportType
()
{
api
.
create
().
getReportType
().
then
((
response
)
=>
{
// console.log(response)
...
...
@@ -341,71 +302,23 @@ export default class EditMasterDataCAT extends Component {
})
}
getParent
()
{
if
(
this
.
state
.
reportType
!==
null
&&
this
.
state
.
company
!==
null
)
{
let
payload
=
{
"report_id"
:
this
.
state
.
reportType
.
report_id
,
"company_id"
:
this
.
state
.
company
.
company_id
}
api
.
create
().
getReportParent
(
payload
).
then
((
response
)
=>
{
// console.log(response)
if
(
response
.
data
)
{
if
(
response
.
ok
)
{
if
(
response
.
data
.
status
===
'success'
)
{
let
data
=
response
.
data
.
data
let
parentData
=
data
.
map
((
item
)
=>
{
return
{
item_report_id
:
item
.
item_report_id
,
description
:
item
.
description
}
})
let
defaultProps
=
{
options
:
parentData
,
getOptionLabel
:
(
option
)
=>
titleCase
(
option
.
description
),
};
this
.
setState
({
listParent
:
defaultProps
,
parentData
:
response
.
data
.
data
})
}
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
);
}
})
// alert(response.data.message)
}
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
data
.
message
,
tipeAlert
:
'error'
})
}
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
problem
,
tipeAlert
:
'error'
})
}
})
}
}
handleDate
(
item
)
{
let
value
=
format
(
item
,
'dd MMMM yyyy'
)
return
value
}
getDetailMasterDataCat
()
{
console
.
log
(
this
.
props
);
api
.
create
().
getDetailMasterDataCat
(
this
.
props
.
data
[
1
],
this
.
props
.
data
[
6
]).
then
((
response
)
=>
{
console
.
log
(
response
);
this
.
setState
({
loading
:
true
})
api
.
create
().
getDetailMasterDataCat
(
this
.
props
.
data
[
8
],
this
.
props
.
data
[
6
]).
then
((
response
)
=>
{
//
console.log(response);
if
(
response
.
data
)
{
if
(
response
.
ok
)
{
if
(
response
.
data
.
status
===
'success'
)
{
let
data
=
response
.
data
.
data
this
.
setState
({
tempData
:
response
.
data
.
data
,
getCompanyID
:
data
.
company_id
},
()
=>
this
.
getInputType
(),
this
.
getPerusahaan
(),
this
.
getReportType
())
// console.log(response.data.data)
if
(
response
.
data
.
status
===
"success"
)
{
this
.
setState
({
getParent
:
response
.
data
.
data
.
filter
((
val
)
=>
String
(
val
.
type_item_report_name
).
toLocaleLowerCase
()
!=
'break'
),
created_by
:
response
.
data
.
data
[
0
].
created
,
updated_by
:
response
.
data
.
data
[
0
].
created_at
},
()
=>
{
// console.log(this.state.getParent[0].created);
this
.
setState
({
loading
:
false
})
})
}
else
{
// alert(response.data.message)
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
data
.
message
,
tipeAlert
:
'warning'
},
()
=>
{
if
(
response
.
data
.
message
.
includes
(
"Someone Logged In"
))
{
setTimeout
(()
=>
{
...
...
@@ -415,9 +328,6 @@ export default class EditMasterDataCAT extends Component {
}
})
}
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
data
.
message
,
tipeAlert
:
'error'
})
}
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
problem
,
tipeAlert
:
'error'
})
}
...
...
@@ -437,7 +347,7 @@ export default class EditMasterDataCAT extends Component {
<
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'
}}
>
<
div
className
=
"popup-title"
>
<
span
style
=
{{
color
:
'#fff'
,
fontSize
:
16
,
fontWeight
:
'bold'
}}
>
Create
Data
<
/span
>
<
span
style
=
{{
color
:
'#fff'
,
fontSize
:
16
,
fontWeight
:
'bold'
}}
>
Edit
Data
<
/span
>
<
/div
>
<
/div
>
<
div
className
=
"col-2 content-right"
style
=
{{
maxWidth
:
"inherit"
,
alignSelf
:
'center'
}}
>
...
...
@@ -464,11 +374,8 @@ export default class EditMasterDataCAT extends Component {
<
Autocomplete
{...
this
.
state
.
listCompany
}
id
=
"company"
disabled
=
{
this
.
state
.
intent
===
'Home'
?
true
:
false
}
onChange
=
{(
event
,
newInputValue
)
=>
this
.
setState
({
company
:
newInputValue
,
loading
:
true
,
previewTable
:
false
},
()
=>
{
this
.
getReportType
()
})}
disableClearable
onChange
=
{(
event
,
newInputValue
)
=>
this
.
setState
({
company_name
:
newInputValue
},
()
=>
this
.
getParent
(),
this
.
clearMessage
())}
debug
style
=
{{
width
:
250
}}
renderInput
=
{(
params
)
=>
<
TextField
{...
params
}
...
...
@@ -589,7 +496,7 @@ export default class EditMasterDataCAT extends Component {
disabled
// onChange={(e) => this.handleChange(e, null)}
// value={this.state.order}
value
=
{
this
.
handleReportName
(
item
.
description
)}
value
=
{
this
.
handleReportName
(
item
.
item_report_name
)}
// error={this.state.errorOrder}
// helperText={this.state.msgErrorOrder}
inputProps
=
{{
...
...
@@ -673,9 +580,11 @@ export default class EditMasterDataCAT extends Component {
<
div
className
=
"margin-top-10px"
style
=
{{
paddingTop
:
10
,
paddingBottom
:
30
,
paddingRight
:
30
,
paddingLeft
:
30
}}
>
<
div
style
=
{{
display
:
'flex'
}}
>
<
Typography
style
=
{{
fontSize
:
11
,
width
:
'13%'
}}
>
Created
By
:
<
/Typography
>
{
!
this
.
state
.
loading
&&
<
Typography
style
=
{{
fontSize
:
11
}}
>
:
{
this
.
state
.
created_by
}
<
/Typography>
}
<
/div
>
<
div
style
=
{{
display
:
'flex'
}}
>
<
Typography
style
=
{{
fontSize
:
11
,
width
:
'13%'
}}
>
Updated
By
:
<
/Typography
>
{
!
this
.
state
.
loading
&&
<
Typography
style
=
{{
fontSize
:
11
}}
>
:
{
this
.
state
.
updated_by
}
<
/Typography>
}
<
/div
>
<
/div
>
<
/div
>
...
...
src/container/MasterData/MasterDataCAT/MasterDataCAT.js
View file @
45b7b38b
...
...
@@ -722,7 +722,7 @@ export default class MasterDataCAT extends Component {
}
createReportItems
=
(
payload
)
=>
{
this
.
setState
({
add
:
false
})
this
.
setState
({
add
:
false
,
edit
:
false
})
api
.
create
().
saveMasterDataCat
(
payload
).
then
(
response
=>
{
// console.log(response);
if
(
response
.
data
)
{
...
...
@@ -781,33 +781,6 @@ export default class MasterDataCAT extends Component {
}
}
// updateReportItems = (payload) => {
// this.setState({ edit: false })
// api.create().updateReportItems(payload).then(response => {
// if (response.data) {
// if (response.ok) {
// if (response.data.status == 'success') {
// this.getData()
// this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
// } 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' })
// }
// })
// }
uploadReportItems
()
{
api
.
create
().
uploadReportItems
(
this
.
state
.
payload
).
then
(
response
=>
{
if
(
response
.
data
)
{
...
...
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