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
c2ff51bc
Commit
c2ff51bc
authored
Aug 20, 2020
by
Deni Rinaldi
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'deni-dev(pc)' into 'master'
Deni dev(pc) See merge request
!136
parents
84f5d3ae
7c5516c4
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
402 additions
and
273 deletions
+402
-273
CreateParameter.js
src/container/MasterData/Parameter/CreateParameter.js
+9
-0
Parameter.js
src/container/MasterData/Parameter/Parameter.js
+24
-19
ReportItems.js
src/container/MasterData/ReportItems.js
+62
-25
CreateReportItems.js
...container/MasterData/formReportItems/CreateReportItems.js
+202
-151
EditReportItems.js
src/container/MasterData/formReportItems/EditReportItems.js
+105
-78
No files found.
src/container/MasterData/Parameter/CreateParameter.js
View file @
c2ff51bc
...
@@ -513,6 +513,7 @@ export default class CreateParameter extends Component {
...
@@ -513,6 +513,7 @@ export default class CreateParameter extends Component {
value
=
{
this
.
state
.
tempData
===
null
?
''
:
this
.
state
.
tempData
.
value
}
value
=
{
this
.
state
.
tempData
===
null
?
''
:
this
.
state
.
tempData
.
value
}
type
=
{
"number"
}
type
=
{
"number"
}
inputProps
=
{{
inputProps
=
{{
min
:
0
,
style
:
{
style
:
{
fontSize
:
11
fontSize
:
11
}
}
...
@@ -538,6 +539,7 @@ export default class CreateParameter extends Component {
...
@@ -538,6 +539,7 @@ export default class CreateParameter extends Component {
type
=
{
"number"
}
type
=
{
"number"
}
value
=
{
this
.
state
.
tempData
===
null
?
''
:
this
.
state
.
tempData
.
min_value
}
value
=
{
this
.
state
.
tempData
===
null
?
''
:
this
.
state
.
tempData
.
min_value
}
inputProps
=
{{
inputProps
=
{{
min
:
0
,
style
:
{
style
:
{
fontSize
:
11
fontSize
:
11
}
}
...
@@ -646,6 +648,7 @@ export default class CreateParameter extends Component {
...
@@ -646,6 +648,7 @@ export default class CreateParameter extends Component {
type
=
{
"number"
}
type
=
{
"number"
}
value
=
{
this
.
state
.
tempData
===
null
?
''
:
this
.
state
.
tempData
.
order
}
value
=
{
this
.
state
.
tempData
===
null
?
''
:
this
.
state
.
tempData
.
order
}
inputProps
=
{{
inputProps
=
{{
min
:
0
,
style
:
{
style
:
{
fontSize
:
11
fontSize
:
11
}
}
...
@@ -671,6 +674,7 @@ export default class CreateParameter extends Component {
...
@@ -671,6 +674,7 @@ export default class CreateParameter extends Component {
type
=
{
"number"
}
type
=
{
"number"
}
value
=
{
this
.
state
.
tempData
===
null
?
''
:
this
.
state
.
tempData
.
max_value
}
value
=
{
this
.
state
.
tempData
===
null
?
''
:
this
.
state
.
tempData
.
max_value
}
inputProps
=
{{
inputProps
=
{{
min
:
0
,
style
:
{
style
:
{
fontSize
:
11
fontSize
:
11
}
}
...
@@ -840,10 +844,12 @@ export default class CreateParameter extends Component {
...
@@ -840,10 +844,12 @@ export default class CreateParameter extends Component {
value
=
{
this
.
state
.
value
===
null
?
''
:
this
.
state
.
value
}
value
=
{
this
.
state
.
value
===
null
?
''
:
this
.
state
.
value
}
type
=
{
"number"
}
type
=
{
"number"
}
inputProps
=
{{
inputProps
=
{{
min
:
0
,
style
:
{
style
:
{
fontSize
:
11
fontSize
:
11
}
}
}}
}}
InputLabelProps
=
{{
InputLabelProps
=
{{
style
:
{
style
:
{
fontSize
:
11
,
fontSize
:
11
,
...
@@ -865,6 +871,7 @@ export default class CreateParameter extends Component {
...
@@ -865,6 +871,7 @@ export default class CreateParameter extends Component {
type
=
{
"number"
}
type
=
{
"number"
}
value
=
{
this
.
state
.
minValue
===
null
?
''
:
this
.
state
.
minValue
}
value
=
{
this
.
state
.
minValue
===
null
?
''
:
this
.
state
.
minValue
}
inputProps
=
{{
inputProps
=
{{
min
:
0
,
style
:
{
style
:
{
fontSize
:
11
fontSize
:
11
}
}
...
@@ -983,6 +990,7 @@ export default class CreateParameter extends Component {
...
@@ -983,6 +990,7 @@ export default class CreateParameter extends Component {
type
=
{
"number"
}
type
=
{
"number"
}
value
=
{
this
.
state
.
order
===
null
?
''
:
this
.
state
.
order
}
value
=
{
this
.
state
.
order
===
null
?
''
:
this
.
state
.
order
}
inputProps
=
{{
inputProps
=
{{
min
:
0
,
style
:
{
style
:
{
fontSize
:
11
fontSize
:
11
}
}
...
@@ -1008,6 +1016,7 @@ export default class CreateParameter extends Component {
...
@@ -1008,6 +1016,7 @@ export default class CreateParameter extends Component {
type
=
{
"number"
}
type
=
{
"number"
}
value
=
{
this
.
state
.
maxValue
===
null
?
''
:
this
.
state
.
maxValue
}
value
=
{
this
.
state
.
maxValue
===
null
?
''
:
this
.
state
.
maxValue
}
inputProps
=
{{
inputProps
=
{{
min
:
0
,
style
:
{
style
:
{
fontSize
:
11
fontSize
:
11
}
}
...
...
src/container/MasterData/Parameter/Parameter.js
View file @
c2ff51bc
...
@@ -42,26 +42,30 @@ export default class Parameter extends Component {
...
@@ -42,26 +42,30 @@ export default class Parameter extends Component {
getAllParameter
()
{
getAllParameter
()
{
api
.
create
().
getAllParameter
().
then
(
response
=>
{
api
.
create
().
getAllParameter
().
then
(
response
=>
{
if
(
response
.
data
.
status
===
"success"
)
{
if
(
response
.
data
)
{
console
.
log
(
response
);
if
(
response
.
data
.
status
===
"success"
)
{
let
data
=
response
.
data
.
data
console
.
log
(
response
);
let
listData
=
data
.
map
((
item
,
index
)
=>
{
let
data
=
response
.
data
.
data
return
[
let
listData
=
data
.
map
((
item
,
index
)
=>
{
item
.
setting_id
,
return
[
item
.
setting_group
,
item
.
setting_id
,
item
.
setting_type
,
item
.
setting_group
,
item
.
company_name
,
item
.
setting_type
,
item
.
description
,
item
.
company_name
,
item
.
order
,
item
.
description
,
item
.
value
,
item
.
order
,
item
.
min_value
,
item
.
value
,
item
.
max_value
,
item
.
min_value
,
item
.
status
item
.
max_value
,
]
item
.
status
})
]
this
.
setState
({
dataTable
:
listData
,
data
:
response
.
data
.
data
})
})
this
.
setState
({
dataTable
:
listData
,
data
:
response
.
data
.
data
})
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
data
.
message
,
tipeAlert
:
'warning'
})
}
}
else
{
}
else
{
alert
(
response
.
data
.
message
)
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
problem
,
tipeAlert
:
'error'
}
)
}
}
})
})
}
}
...
@@ -83,6 +87,7 @@ export default class Parameter extends Component {
...
@@ -83,6 +87,7 @@ export default class Parameter extends Component {
updateParameter
=
(
payload
)
=>
{
updateParameter
=
(
payload
)
=>
{
this
.
setState
({
visibleEdit
:
false
})
this
.
setState
({
visibleEdit
:
false
})
api
.
create
().
updateParameter
(
payload
).
then
(
response
=>
{
api
.
create
().
updateParameter
(
payload
).
then
(
response
=>
{
console
.
log
(
response
);
if
(
response
.
data
)
{
if
(
response
.
data
)
{
if
(
response
.
data
.
status
==
'success'
)
{
if
(
response
.
data
.
status
==
'success'
)
{
this
.
getAllParameter
()
this
.
getAllParameter
()
...
...
src/container/MasterData/ReportItems.js
View file @
c2ff51bc
import
React
,
{
Component
}
from
"react"
;
import
React
,
{
Component
}
from
"react"
;
import
{
createMuiTheme
,
MuiThemeProvider
}
from
'@material-ui/core/styles'
;
import
{
createMuiTheme
,
MuiThemeProvider
,
withStyles
}
from
'@material-ui/core/styles'
;
import
Images
from
"../../assets/Images"
;
import
Images
from
"../../assets/Images"
;
import
MUIDataTable
from
"mui-datatables"
;
import
MUIDataTable
from
"mui-datatables"
;
import
{
InputBase
}
from
"@material-ui/core"
;
import
{
InputBase
,
Snackbar
}
from
"@material-ui/core"
;
import
{
ExcelRenderer
}
from
'react-excel-renderer'
;
import
{
ExcelRenderer
}
from
'react-excel-renderer'
;
import
UploadFile
from
"../../library/Upload"
;
import
UploadFile
from
"../../library/Upload"
;
import
MuiAlert
from
'@material-ui/lab/Alert'
;
import
CreateReportItems
from
"./formReportItems/CreateReportItems"
;
import
CreateReportItems
from
"./formReportItems/CreateReportItems"
;
import
EditReportItems
from
"./formReportItems/EditReportItems"
;
import
EditReportItems
from
"./formReportItems/EditReportItems"
;
import
VisualReportItems
from
"./formReportItems/VisualReportItems"
;
import
VisualReportItems
from
"./formReportItems/VisualReportItems"
;
...
@@ -17,6 +18,9 @@ const getMuiTheme = () => createMuiTheme(ct.customTable());
...
@@ -17,6 +18,9 @@ const getMuiTheme = () => createMuiTheme(ct.customTable());
const
options
=
ct
.
customOptions
();
const
options
=
ct
.
customOptions
();
const
options2
=
ct
.
customOptions2
();
const
options2
=
ct
.
customOptions2
();
const
Alert
=
withStyles
({
})((
props
)
=>
<
MuiAlert
elevation
=
{
6
}
variant
=
"filled"
{...
props
}
/>
)
;
export
default
class
ReportItems
extends
Component
{
export
default
class
ReportItems
extends
Component
{
constructor
(
props
)
{
constructor
(
props
)
{
super
(
props
)
super
(
props
)
...
@@ -32,7 +36,10 @@ export default class ReportItems extends Component {
...
@@ -32,7 +36,10 @@ export default class ReportItems extends Component {
dataLoaded
:
false
,
dataLoaded
:
false
,
cols
:
null
,
cols
:
null
,
rows
:
null
,
rows
:
null
,
popupError
:
false
popupError
:
false
,
alert
:
false
,
tipeAlert
:
''
,
messageAlert
:
''
}
}
this
.
fileHandler
=
this
.
fileHandler
.
bind
(
this
);
this
.
fileHandler
=
this
.
fileHandler
.
bind
(
this
);
...
@@ -450,14 +457,18 @@ export default class ReportItems extends Component {
...
@@ -450,14 +457,18 @@ export default class ReportItems extends Component {
getData
()
{
getData
()
{
api
.
create
().
getReportItems
().
then
((
response
)
=>
{
api
.
create
().
getReportItems
().
then
((
response
)
=>
{
console
.
log
(
response
)
console
.
log
(
response
)
if
(
response
.
data
.
status
==
'success'
)
{
if
(
response
.
data
)
{
let
data
=
response
.
data
.
data
if
(
response
.
data
.
status
==
'success'
)
{
let
listData
=
data
.
sort
((
a
,
b
)
=>
a
.
item_report_id
-
b
.
item_report_id
).
map
((
item
,
index
)
=>
{
let
data
=
response
.
data
.
data
return
[
index
,
item
.
item_report_id
,
item
.
report_name
,
item
.
company_name
,
item
.
order
,
item
.
description
,
item
.
parent
,
item
.
uom
,
item
.
weight
,
item
.
type_report_name
,
item
.
status
]
let
listData
=
data
.
sort
((
a
,
b
)
=>
a
.
item_report_id
-
b
.
item_report_id
).
map
((
item
,
index
)
=>
{
})
return
[
index
,
item
.
item_report_id
,
item
.
report_name
,
item
.
company_name
,
item
.
order
,
item
.
description
,
item
.
parent
,
item
.
uom
,
item
.
weight
,
item
.
type_report_name
,
item
.
status
]
this
.
setState
({
dataTable
:
listData
,
listData
:
response
.
data
.
data
})
})
this
.
setState
({
dataTable
:
listData
,
listData
:
response
.
data
.
data
})
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
data
.
message
,
tipeAlert
:
'warning'
})
}
}
else
{
}
else
{
alert
(
response
.
data
.
message
)
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
problem
,
tipeAlert
:
'error'
}
)
}
}
})
})
}
}
...
@@ -482,14 +493,18 @@ export default class ReportItems extends Component {
...
@@ -482,14 +493,18 @@ export default class ReportItems extends Component {
}
}
api
.
create
().
searchReportItems
(
body
).
then
(
response
=>
{
api
.
create
().
searchReportItems
(
body
).
then
(
response
=>
{
// console.log(response.data);
// console.log(response.data);
if
(
response
.
data
.
status
==
'success'
)
{
if
(
response
.
data
)
{
let
data
=
response
.
data
.
data
if
(
response
.
data
.
status
==
'success'
)
{
let
listData
=
data
.
map
((
item
,
index
)
=>
{
let
data
=
response
.
data
.
data
return
[
index
,
item
.
item_report_id
,
item
.
report_name
,
item
.
company_name
,
item
.
order
,
item
.
description
,
item
.
parent
,
item
.
uom
,
item
.
weight
,
item
.
type_report_name
,
item
.
status
]
let
listData
=
data
.
map
((
item
,
index
)
=>
{
})
return
[
index
,
item
.
item_report_id
,
item
.
report_name
,
item
.
company_name
,
item
.
order
,
item
.
description
,
item
.
parent
,
item
.
uom
,
item
.
weight
,
item
.
type_report_name
,
item
.
status
]
this
.
setState
({
dataTable
:
listData
,
listData
:
response
.
data
.
data
})
})
this
.
setState
({
dataTable
:
listData
,
listData
:
response
.
data
.
data
})
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
data
.
message
,
tipeAlert
:
'warning'
})
}
}
else
{
}
else
{
alert
(
response
.
data
.
message
)
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
problem
,
tipeAlert
:
'error'
}
)
}
}
})
})
}
}
...
@@ -497,10 +512,15 @@ export default class ReportItems extends Component {
...
@@ -497,10 +512,15 @@ export default class ReportItems extends Component {
createReportItems
=
(
payload
)
=>
{
createReportItems
=
(
payload
)
=>
{
this
.
setState
({
add
:
false
})
this
.
setState
({
add
:
false
})
api
.
create
().
createReportItems
(
payload
).
then
(
response
=>
{
api
.
create
().
createReportItems
(
payload
).
then
(
response
=>
{
if
(
response
.
data
.
status
==
'success'
)
{
if
(
response
.
data
)
{
this
.
getData
()
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'
})
}
}
else
{
}
else
{
alert
(
response
.
data
.
message
)
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
problem
,
tipeAlert
:
'error'
}
)
}
}
})
})
}
}
...
@@ -538,10 +558,15 @@ export default class ReportItems extends Component {
...
@@ -538,10 +558,15 @@ export default class ReportItems extends Component {
updateReportItems
=
(
payload
)
=>
{
updateReportItems
=
(
payload
)
=>
{
this
.
setState
({
edit
:
false
})
this
.
setState
({
edit
:
false
})
api
.
create
().
updateReportItems
(
payload
).
then
(
response
=>
{
api
.
create
().
updateReportItems
(
payload
).
then
(
response
=>
{
if
(
response
.
data
.
status
==
'success'
)
{
if
(
response
.
data
)
{
this
.
getData
()
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'
})
}
}
else
{
}
else
{
alert
(
response
.
data
.
message
)
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
problem
,
tipeAlert
:
'error'
}
)
}
}
})
})
}
}
...
@@ -550,15 +575,22 @@ export default class ReportItems extends Component {
...
@@ -550,15 +575,22 @@ export default class ReportItems extends Component {
api
.
create
().
uploadReportItems
(
this
.
state
.
payload
).
then
(
response
=>
{
api
.
create
().
uploadReportItems
(
this
.
state
.
payload
).
then
(
response
=>
{
if
(
response
.
data
)
{
if
(
response
.
data
)
{
if
(
response
.
data
.
status
===
"success"
)
{
if
(
response
.
data
.
status
===
"success"
)
{
console
.
log
(
response
)
alert
(
response
.
data
.
message
)
alert
(
response
.
data
.
message
)
this
.
getData
()
this
.
getData
()
this
.
setState
({
itemReport
:
true
})
this
.
setState
({
itemReport
:
true
,
alert
:
true
,
messageAlert
:
response
.
data
.
message
,
tipeAlert
:
'success'
})
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
data
.
message
,
tipeAlert
:
'warning'
})
}
}
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
problem
,
tipeAlert
:
'error'
})
}
}
})
})
}
}
closeAlert
()
{
this
.
setState
({
alert
:
false
})
}
render
()
{
render
()
{
const
columns
=
[{
const
columns
=
[{
name
:
"Action"
,
name
:
"Action"
,
...
@@ -716,6 +748,11 @@ export default class ReportItems extends Component {
...
@@ -716,6 +748,11 @@ export default class ReportItems extends Component {
<
div
style
=
{{
height
:
this
.
props
.
height
}}
>
<
div
style
=
{{
height
:
this
.
props
.
height
}}
>
{
/* <Row> */
}
{
/* <Row> */
}
<
div
className
=
{
"main-color"
}
style
=
{{
height
:
199
,
width
:
'100%'
}}
/
>
<
div
className
=
{
"main-color"
}
style
=
{{
height
:
199
,
width
:
'100%'
}}
/
>
<
Snackbar
open
=
{
this
.
state
.
alert
}
autoHideDuration
=
{
6000
}
onClose
=
{()
=>
this
.
closeAlert
()}
>
<
Alert
onClose
=
{()
=>
this
.
closeAlert
()}
severity
=
{
this
.
state
.
tipeAlert
}
>
{
this
.
state
.
messageAlert
}
<
/Alert
>
<
/Snackbar
>
{
this
.
state
.
itemReport
===
true
?
{
this
.
state
.
itemReport
===
true
?
<
div
>
<
div
>
<
div
style
=
{{
display
:
'flex'
,
flexDirection
:
'row'
,
justifyContent
:
'space-between'
,
paddingRight
:
25
,
paddingLeft
:
25
,
marginTop
:
-
150
}}
>
<
div
style
=
{{
display
:
'flex'
,
flexDirection
:
'row'
,
justifyContent
:
'space-between'
,
paddingRight
:
25
,
paddingLeft
:
25
,
marginTop
:
-
150
}}
>
...
...
src/container/MasterData/formReportItems/CreateReportItems.js
View file @
c2ff51bc
...
@@ -21,7 +21,7 @@ export default class CreateReportItems extends Component {
...
@@ -21,7 +21,7 @@ export default class CreateReportItems extends Component {
order
:
''
,
order
:
''
,
description
:
''
,
description
:
''
,
uom
:
''
,
uom
:
''
,
weight
:
null
,
weight
:
''
,
formula
:
''
,
formula
:
''
,
realVal
:
''
,
realVal
:
''
,
condition
:
null
,
condition
:
null
,
...
@@ -36,6 +36,10 @@ export default class CreateReportItems extends Component {
...
@@ -36,6 +36,10 @@ export default class CreateReportItems extends Component {
errorRV
:
false
,
errorRV
:
false
,
errorStartDate
:
false
,
errorStartDate
:
false
,
errorEndDate
:
false
,
errorEndDate
:
false
,
errorTipeData
:
false
,
errorCondition
:
false
,
msgErrorTipeData
:
''
,
msgErrorCondition
:
''
,
msgErrorOrder
:
''
,
msgErrorOrder
:
''
,
msgErrorDesc
:
''
,
msgErrorDesc
:
''
,
msgErrorFormula
:
''
,
msgErrorFormula
:
''
,
...
@@ -45,7 +49,7 @@ export default class CreateReportItems extends Component {
...
@@ -45,7 +49,7 @@ export default class CreateReportItems extends Component {
disabledFormula
:
true
,
disabledFormula
:
true
,
disabledCondt
:
true
,
disabledCondt
:
true
,
disabledValue
:
true
,
disabledValue
:
true
,
options
:
[
'WARNING'
,
'STOPPER'
]
options
:
[
'WARNING'
,
'STOPPER'
]
}
}
}
}
...
@@ -56,25 +60,30 @@ export default class CreateReportItems extends Component {
...
@@ -56,25 +60,30 @@ export default class CreateReportItems extends Component {
this
.
getReportType
()
this
.
getReportType
()
// this.getParent()
// this.getParent()
let
date
=
format
(
new
Date
,
'yyyy-MM-dd'
)
let
date
=
format
(
new
Date
,
'yyyy-MM-dd'
)
console
.
log
(
date
);
console
.
log
(
date
);
this
.
setState
({
this
.
setState
({
startDate
:
date
,
startDate
:
date
,
endDate
:
date
endDate
:
date
})
})
}
}
handleChange
(
e
,
type
)
{
handleChange
(
e
,
type
)
{
let
data
=
this
.
state
let
data
=
this
.
state
let
isDate
=
type
!==
''
?
true
:
false
let
isDate
=
type
!==
''
?
true
:
false
if
(
isDate
&&
type
===
'start_date'
)
{
if
(
isDate
&&
type
===
'start_date'
)
{
this
.
setState
({...
data
,
startDate
:
format
(
e
,
'yyyy-MM-dd'
),
endDate
:
null
,
this
.
setState
({
...
data
,
startDate
:
format
(
e
,
'yyyy-MM-dd'
),
endDate
:
null
,
errorOrder
:
false
,
errorOrder
:
false
,
errorDesc
:
false
,
errorDesc
:
false
,
errorFormula
:
false
,
errorFormula
:
false
,
errorRV
:
false
,
errorRV
:
false
,
errorStartDate
:
false
,
errorStartDate
:
false
,
errorEndDate
:
false
,
errorEndDate
:
false
,
errorTipeData
:
false
,
errorCondition
:
false
,
msgErrorTipeData
:
''
,
msgErrorCondition
:
''
,
msgErrorOrder
:
''
,
msgErrorOrder
:
''
,
msgErrorDesc
:
''
,
msgErrorDesc
:
''
,
msgErrorFormula
:
''
,
msgErrorFormula
:
''
,
...
@@ -83,13 +92,18 @@ export default class CreateReportItems extends Component {
...
@@ -83,13 +92,18 @@ export default class CreateReportItems extends Component {
msgErrorED
:
''
,
msgErrorED
:
''
,
})
})
}
else
if
(
isDate
&&
type
===
'end_date'
)
{
}
else
if
(
isDate
&&
type
===
'end_date'
)
{
this
.
setState
({...
data
,
endDate
:
format
(
e
,
'yyyy-MM-dd'
),
this
.
setState
({
...
data
,
endDate
:
format
(
e
,
'yyyy-MM-dd'
),
errorOrder
:
false
,
errorOrder
:
false
,
errorDesc
:
false
,
errorDesc
:
false
,
errorFormula
:
false
,
errorFormula
:
false
,
errorRV
:
false
,
errorRV
:
false
,
errorStartDate
:
false
,
errorStartDate
:
false
,
errorEndDate
:
false
,
errorEndDate
:
false
,
errorTipeData
:
false
,
errorCondition
:
false
,
msgErrorTipeData
:
''
,
msgErrorCondition
:
''
,
msgErrorOrder
:
''
,
msgErrorOrder
:
''
,
msgErrorDesc
:
''
,
msgErrorDesc
:
''
,
msgErrorFormula
:
''
,
msgErrorFormula
:
''
,
...
@@ -98,13 +112,18 @@ export default class CreateReportItems extends Component {
...
@@ -98,13 +112,18 @@ export default class CreateReportItems extends Component {
msgErrorED
:
''
,
msgErrorED
:
''
,
})
})
}
else
{
}
else
{
this
.
setState
({...
data
,
[
e
.
target
.
name
]:
e
.
target
.
value
,
this
.
setState
({
...
data
,
[
e
.
target
.
name
]:
e
.
target
.
value
,
errorOrder
:
false
,
errorOrder
:
false
,
errorDesc
:
false
,
errorDesc
:
false
,
errorFormula
:
false
,
errorFormula
:
false
,
errorRV
:
false
,
errorRV
:
false
,
errorStartDate
:
false
,
errorStartDate
:
false
,
errorEndDate
:
false
,
errorEndDate
:
false
,
errorTipeData
:
false
,
errorCondition
:
false
,
msgErrorTipeData
:
''
,
msgErrorCondition
:
''
,
msgErrorOrder
:
''
,
msgErrorOrder
:
''
,
msgErrorDesc
:
''
,
msgErrorDesc
:
''
,
msgErrorFormula
:
''
,
msgErrorFormula
:
''
,
...
@@ -120,25 +139,29 @@ export default class CreateReportItems extends Component {
...
@@ -120,25 +139,29 @@ export default class CreateReportItems extends Component {
if
(
R
.
isNil
(
this
.
state
.
reportType
))
return
alert
(
"Jenis Laporan is Required."
);
if
(
R
.
isNil
(
this
.
state
.
reportType
))
return
alert
(
"Jenis Laporan is Required."
);
if
(
R
.
isNil
(
this
.
state
.
company
))
return
alert
(
"Perusahaan is Required."
);
if
(
R
.
isNil
(
this
.
state
.
company
))
return
alert
(
"Perusahaan is Required."
);
else
if
(
R
.
isEmpty
(
this
.
state
.
order
))
{
else
if
(
R
.
isEmpty
(
this
.
state
.
order
))
{
this
.
setState
({
errorOrder
:
true
,
msgErrorOrder
:
'Order Harus Diisi'
})
this
.
setState
({
errorOrder
:
true
,
msgErrorOrder
:
'Order Harus Diisi'
})
}
}
else
if
(
R
.
isEmpty
(
this
.
state
.
description
))
{
else
if
(
R
.
isEmpty
(
this
.
state
.
description
))
{
this
.
setState
({
errorDesc
:
true
,
msgErrorDesc
:
'Deskripsi Harus Diisi'
})
this
.
setState
({
errorDesc
:
true
,
msgErrorDesc
:
'Deskripsi Harus Diisi'
})
}
}
else
if
(
R
.
isNil
(
this
.
state
.
InputType
))
return
alert
(
"Tipe Data is Required."
)
else
if
(
R
.
isNil
(
this
.
state
.
InputType
))
{
this
.
setState
({
errorTipeData
:
true
,
msgErrorTipeData
:
'Tipe Data Harus Diisi'
})
}
else
if
(
this
.
state
.
disabledFormula
===
false
&&
R
.
isEmpty
(
this
.
state
.
formula
))
{
else
if
(
this
.
state
.
disabledFormula
===
false
&&
R
.
isEmpty
(
this
.
state
.
formula
))
{
this
.
setState
({
errorFormula
:
true
,
msgErrorFormula
:
'Formula Harus Diisi'
})
this
.
setState
({
errorFormula
:
true
,
msgErrorFormula
:
'Formula Harus Diisi'
})
}
}
else
if
(
this
.
state
.
disabledValue
===
false
&&
R
.
isEmpty
(
this
.
state
.
realVal
))
{
else
if
(
this
.
state
.
disabledValue
===
false
&&
R
.
isEmpty
(
this
.
state
.
realVal
))
{
this
.
setState
({
errorRV
:
true
,
msgErrorRV
:
'Nilai Seharusnya Harus Diisi'
})
this
.
setState
({
errorRV
:
true
,
msgErrorRV
:
'Nilai Seharusnya Harus Diisi'
})
}
else
if
(
this
.
state
.
disabledCondt
===
false
&&
R
.
isEmpty
(
this
.
state
.
condition
))
{
this
.
setState
({
errorCondition
:
true
,
msgErrorCondition
:
'Kondisi Jika Salah Harus Diisi'
})
}
}
else
if
(
this
.
state
.
disabledCondt
===
false
&&
R
.
isEmpty
(
this
.
state
.
condition
))
return
alert
(
"Kondisi Jika Salah is Required."
)
else
if
(
R
.
isNil
(
this
.
state
.
startDate
))
{
else
if
(
R
.
isNil
(
this
.
state
.
startDate
))
{
this
.
setState
({
errorStartDate
:
true
,
msgErrorSD
:
'Start Date tidak boleh kosong'
})
this
.
setState
({
errorStartDate
:
true
,
msgErrorSD
:
'Start Date tidak boleh kosong'
})
}
}
else
if
(
R
.
isNil
(
this
.
state
.
endDate
))
{
else
if
(
R
.
isNil
(
this
.
state
.
endDate
))
{
this
.
setState
({
errorEndDate
:
true
,
msgErrorED
:
'End Date tidak boleh kosong'
})
this
.
setState
({
errorEndDate
:
true
,
msgErrorED
:
'End Date tidak boleh kosong'
})
}
}
else
{
else
{
this
.
addReportItems
()
this
.
addReportItems
()
}
}
...
@@ -162,23 +185,13 @@ export default class CreateReportItems extends Component {
...
@@ -162,23 +185,13 @@ export default class CreateReportItems extends Component {
"end_date"
:
this
.
state
.
endDate
"end_date"
:
this
.
state
.
endDate
}
}
console
.
log
(
payload
)
console
.
log
(
payload
)
api
.
create
().
createReportItems
(
payload
).
then
((
response
)
=>
{
this
.
props
.
createReportItems
(
payload
)
console
.
log
(
response
)
if
(
response
.
data
)
{
if
(
response
.
data
.
status
===
'success'
)
{
this
.
props
.
onClickClose
()
this
.
props
.
refresh
()
}
else
{
alert
(
response
.
data
.
message
)
}
}
})
}
}
getInputType
()
{
getInputType
()
{
api
.
create
().
getInputType
().
then
((
response
)
=>
{
api
.
create
().
getInputType
().
then
((
response
)
=>
{
console
.
log
(
response
.
data
)
console
.
log
(
response
.
data
)
if
(
response
.
data
.
status
===
'success'
)
{
if
(
response
.
data
.
status
===
'success'
)
{
let
data
=
response
.
data
.
data
let
data
=
response
.
data
.
data
let
inputData
=
data
.
map
((
item
)
=>
{
let
inputData
=
data
.
map
((
item
)
=>
{
return
{
return
{
...
@@ -189,8 +202,8 @@ export default class CreateReportItems extends Component {
...
@@ -189,8 +202,8 @@ export default class CreateReportItems extends Component {
let
defaultProps
=
{
let
defaultProps
=
{
options
:
inputData
,
options
:
inputData
,
getOptionLabel
:
(
option
)
=>
titleCase
(
option
.
type_report_name
),
getOptionLabel
:
(
option
)
=>
titleCase
(
option
.
type_report_name
),
};
};
this
.
setState
({
listInputType
:
defaultProps
,
inputData
:
response
.
data
.
data
})
this
.
setState
({
listInputType
:
defaultProps
,
inputData
:
response
.
data
.
data
})
}
else
{
}
else
{
alert
(
response
.
data
.
message
)
alert
(
response
.
data
.
message
)
}
}
...
@@ -200,7 +213,7 @@ export default class CreateReportItems extends Component {
...
@@ -200,7 +213,7 @@ export default class CreateReportItems extends Component {
getPerusahaan
()
{
getPerusahaan
()
{
api
.
create
().
getPerusahaanActive
().
then
((
response
)
=>
{
api
.
create
().
getPerusahaanActive
().
then
((
response
)
=>
{
// console.log(response)
// console.log(response)
if
(
response
.
data
.
status
===
'success'
)
{
if
(
response
.
data
.
status
===
'success'
)
{
let
data
=
response
.
data
.
data
let
data
=
response
.
data
.
data
let
companyData
=
data
.
map
((
item
)
=>
{
let
companyData
=
data
.
map
((
item
)
=>
{
return
{
return
{
...
@@ -211,8 +224,8 @@ export default class CreateReportItems extends Component {
...
@@ -211,8 +224,8 @@ export default class CreateReportItems extends Component {
let
defaultProps
=
{
let
defaultProps
=
{
options
:
companyData
,
options
:
companyData
,
getOptionLabel
:
(
option
)
=>
titleCase
(
option
.
company_name
),
getOptionLabel
:
(
option
)
=>
titleCase
(
option
.
company_name
),
};
};
this
.
setState
({
listCompany
:
defaultProps
,
companyData
:
response
.
data
.
data
})
this
.
setState
({
listCompany
:
defaultProps
,
companyData
:
response
.
data
.
data
})
}
else
{
}
else
{
alert
(
response
.
data
.
message
)
alert
(
response
.
data
.
message
)
}
}
...
@@ -222,7 +235,7 @@ export default class CreateReportItems extends Component {
...
@@ -222,7 +235,7 @@ export default class CreateReportItems extends Component {
getReportType
()
{
getReportType
()
{
api
.
create
().
getReportType
().
then
((
response
)
=>
{
api
.
create
().
getReportType
().
then
((
response
)
=>
{
// console.log(response)
// console.log(response)
if
(
response
.
data
.
status
===
'success'
)
{
if
(
response
.
data
.
status
===
'success'
)
{
let
data
=
response
.
data
.
data
let
data
=
response
.
data
.
data
let
reportTypeData
=
data
.
map
((
item
)
=>
{
let
reportTypeData
=
data
.
map
((
item
)
=>
{
return
{
return
{
...
@@ -233,8 +246,8 @@ export default class CreateReportItems extends Component {
...
@@ -233,8 +246,8 @@ export default class CreateReportItems extends Component {
let
defaultProps
=
{
let
defaultProps
=
{
options
:
reportTypeData
,
options
:
reportTypeData
,
getOptionLabel
:
(
option
)
=>
titleCase
(
option
.
report_name
),
getOptionLabel
:
(
option
)
=>
titleCase
(
option
.
report_name
),
};
};
this
.
setState
({
listReportType
:
defaultProps
,
reportTypeData
:
response
.
data
.
data
})
this
.
setState
({
listReportType
:
defaultProps
,
reportTypeData
:
response
.
data
.
data
})
}
else
{
}
else
{
alert
(
response
.
data
.
message
)
alert
(
response
.
data
.
message
)
}
}
...
@@ -242,14 +255,14 @@ export default class CreateReportItems extends Component {
...
@@ -242,14 +255,14 @@ export default class CreateReportItems extends Component {
}
}
getParent
()
{
getParent
()
{
if
(
this
.
state
.
reportType
!==
null
&&
this
.
state
.
company
!==
null
)
{
if
(
this
.
state
.
reportType
!==
null
&&
this
.
state
.
company
!==
null
)
{
let
payload
=
{
let
payload
=
{
"report_id"
:
this
.
state
.
reportType
.
report_id
,
"report_id"
:
this
.
state
.
reportType
.
report_id
,
"company_id"
:
this
.
state
.
company
.
company_id
"company_id"
:
this
.
state
.
company
.
company_id
}
}
api
.
create
().
getReportParent
(
payload
).
then
((
response
)
=>
{
api
.
create
().
getReportParent
(
payload
).
then
((
response
)
=>
{
console
.
log
(
response
)
console
.
log
(
response
)
if
(
response
.
data
.
status
===
'success'
)
{
if
(
response
.
data
.
status
===
'success'
)
{
let
data
=
response
.
data
.
data
let
data
=
response
.
data
.
data
let
parentData
=
data
.
map
((
item
)
=>
{
let
parentData
=
data
.
map
((
item
)
=>
{
return
{
return
{
...
@@ -260,8 +273,8 @@ export default class CreateReportItems extends Component {
...
@@ -260,8 +273,8 @@ export default class CreateReportItems extends Component {
let
defaultProps
=
{
let
defaultProps
=
{
options
:
parentData
,
options
:
parentData
,
getOptionLabel
:
(
option
)
=>
titleCase
(
option
.
description
),
getOptionLabel
:
(
option
)
=>
titleCase
(
option
.
description
),
};
};
this
.
setState
({
listParent
:
defaultProps
,
parentData
:
response
.
data
.
data
})
this
.
setState
({
listParent
:
defaultProps
,
parentData
:
response
.
data
.
data
})
}
else
{
}
else
{
alert
(
response
.
data
.
message
)
alert
(
response
.
data
.
message
)
}
}
...
@@ -274,6 +287,15 @@ export default class CreateReportItems extends Component {
...
@@ -274,6 +287,15 @@ export default class CreateReportItems extends Component {
return
value
return
value
}
}
clearMessage
()
{
this
.
setState
({
errorTipeData
:
false
,
errorCondition
:
false
,
msgErrorTipeData
:
''
,
msgErrorCondition
:
''
,
})
}
render
()
{
render
()
{
return
(
return
(
...
@@ -291,7 +313,7 @@ export default class CreateReportItems extends Component {
...
@@ -291,7 +313,7 @@ export default class CreateReportItems extends Component {
className
=
"btn btn-circle btn-white"
className
=
"btn btn-circle btn-white"
onClick
=
{()
=>
this
.
props
.
onClickClose
()}
onClick
=
{()
=>
this
.
props
.
onClickClose
()}
>
>
<
img
src
=
{
Images
.
close
}
/
>
<
img
src
=
{
Images
.
close
}
/
>
<
/button
>
<
/button
>
<
/div
>
<
/div
>
<
/div
>
<
/div
>
...
@@ -322,15 +344,15 @@ export default class CreateReportItems extends Component {
...
@@ -322,15 +344,15 @@ export default class CreateReportItems extends Component {
<
/div
>
<
/div
>
<
/div
>
<
/div
>
<
div
className
=
"column-2"
>
<
div
className
=
"column-2"
>
<
div
className
=
"margin-top-10px"
style
=
{{
padding
:
10
,
borderRadius
:
5
}}
>
<
div
className
=
"margin-top-10px"
style
=
{{
padding
:
10
,
borderRadius
:
5
}}
>
<
Autocomplete
<
Autocomplete
{...
this
.
state
.
listReportType
}
{...
this
.
state
.
listReportType
}
id
=
"reportType"
id
=
"reportType"
onChange
=
{(
event
,
newInputValue
)
=>
this
.
setState
({
reportType
:
newInputValue
})}
onChange
=
{(
event
,
newInputValue
)
=>
this
.
setState
({
reportType
:
newInputValue
})}
debug
debug
renderInput
=
{(
params
)
=>
renderInput
=
{(
params
)
=>
<
TextField
{...
params
}
<
TextField
{...
params
}
label
=
"Jenis Laporan"
label
=
"Jenis Laporan"
InputLabelProps
=
{{
InputLabelProps
=
{{
style
:
{
style
:
{
fontSize
:
11
,
fontSize
:
11
,
...
@@ -348,15 +370,15 @@ export default class CreateReportItems extends Component {
...
@@ -348,15 +370,15 @@ export default class CreateReportItems extends Component {
<
div
className
=
"grid grid-2x grid-mobile-none gap-15px"
style
=
{{
paddingLeft
:
20
,
paddingRight
:
20
}}
>
<
div
className
=
"grid grid-2x grid-mobile-none gap-15px"
style
=
{{
paddingLeft
:
20
,
paddingRight
:
20
}}
>
<
div
className
=
"column-1"
>
<
div
className
=
"column-1"
>
<
div
className
=
"margin-top-10px"
style
=
{{
padding
:
10
,
borderRadius
:
5
}}
>
<
div
className
=
"margin-top-10px"
style
=
{{
padding
:
10
,
borderRadius
:
5
}}
>
<
Autocomplete
<
Autocomplete
{...
this
.
state
.
listCompany
}
{...
this
.
state
.
listCompany
}
id
=
"company"
id
=
"company"
onChange
=
{(
event
,
newInputValue
)
=>
this
.
setState
({
company
:
newInputValue
},
()
=>
this
.
getParent
())}
onChange
=
{(
event
,
newInputValue
)
=>
this
.
setState
({
company
:
newInputValue
},
()
=>
this
.
getParent
())}
debug
debug
renderInput
=
{(
params
)
=>
renderInput
=
{(
params
)
=>
<
TextField
{...
params
}
<
TextField
{...
params
}
label
=
"Perusahaan"
label
=
"Perusahaan"
InputLabelProps
=
{{
InputLabelProps
=
{{
style
:
{
style
:
{
fontSize
:
11
,
fontSize
:
11
,
...
@@ -371,17 +393,19 @@ export default class CreateReportItems extends Component {
...
@@ -371,17 +393,19 @@ export default class CreateReportItems extends Component {
<
/div
>
<
/div
>
<
/div
>
<
/div
>
<
div
className
=
"column-2"
>
<
div
className
=
"column-2"
>
<
div
className
=
"margin-top-10px"
style
=
{{
padding
:
10
,
borderRadius
:
5
}}
>
<
div
className
=
"margin-top-10px"
style
=
{{
padding
:
10
,
borderRadius
:
5
}}
>
<
TextField
<
TextField
style
=
{{
width
:
'100%'
}}
style
=
{{
width
:
'100%'
}}
id
=
"orders"
id
=
"orders"
name
=
"order"
name
=
"order"
label
=
"Order"
label
=
"Order"
type
=
"number"
onChange
=
{(
e
)
=>
this
.
handleChange
(
e
,
null
)}
onChange
=
{(
e
)
=>
this
.
handleChange
(
e
,
null
)}
value
=
{
this
.
state
.
order
}
value
=
{
this
.
state
.
order
}
error
=
{
this
.
state
.
errorOrder
}
error
=
{
this
.
state
.
errorOrder
}
helperText
=
{
this
.
state
.
msgErrorOrder
}
helperText
=
{
this
.
state
.
msgErrorOrder
}
inputProps
=
{{
inputProps
=
{{
min
:
0
,
style
:
{
style
:
{
fontSize
:
11
,
fontSize
:
11
,
fontFamily
:
'Nunito Sans, sans-serif'
,
fontFamily
:
'Nunito Sans, sans-serif'
,
...
@@ -402,7 +426,7 @@ export default class CreateReportItems extends Component {
...
@@ -402,7 +426,7 @@ export default class CreateReportItems extends Component {
<
div
className
=
"grid grid-2x grid-mobile-none gap-15px"
style
=
{{
paddingLeft
:
20
,
paddingRight
:
20
}}
>
<
div
className
=
"grid grid-2x grid-mobile-none gap-15px"
style
=
{{
paddingLeft
:
20
,
paddingRight
:
20
}}
>
<
div
className
=
"column-1"
>
<
div
className
=
"column-1"
>
<
div
className
=
"margin-top-10px"
style
=
{{
padding
:
10
,
borderRadius
:
5
}}
>
<
div
className
=
"margin-top-10px"
style
=
{{
padding
:
10
,
borderRadius
:
5
}}
>
<
TextField
<
TextField
style
=
{{
width
:
'100%'
}}
style
=
{{
width
:
'100%'
}}
id
=
"description"
id
=
"description"
...
@@ -431,16 +455,16 @@ export default class CreateReportItems extends Component {
...
@@ -431,16 +455,16 @@ export default class CreateReportItems extends Component {
<
/div
>
<
/div
>
<
/div
>
<
/div
>
<
div
className
=
"column-2"
>
<
div
className
=
"column-2"
>
<
div
className
=
"margin-top-10px"
style
=
{{
padding
:
10
,
borderRadius
:
5
}}
>
<
div
className
=
"margin-top-10px"
style
=
{{
padding
:
10
,
borderRadius
:
5
}}
>
<
Autocomplete
<
Autocomplete
{...
this
.
state
.
listParent
}
{...
this
.
state
.
listParent
}
id
=
"parentId"
id
=
"parentId"
onChange
=
{(
event
,
newInputValue
)
=>
this
.
setState
({
parent
:
newInputValue
})}
onChange
=
{(
event
,
newInputValue
)
=>
this
.
setState
({
parent
:
newInputValue
})}
debug
debug
disabled
=
{
this
.
state
.
reportType
==
null
||
this
.
state
.
company
==
null
}
disabled
=
{
this
.
state
.
reportType
==
null
||
this
.
state
.
company
==
null
}
renderInput
=
{(
params
)
=>
renderInput
=
{(
params
)
=>
<
TextField
{...
params
}
<
TextField
{...
params
}
label
=
"Parent ID"
label
=
"Parent ID"
InputLabelProps
=
{{
InputLabelProps
=
{{
style
:
{
style
:
{
fontSize
:
11
,
fontSize
:
11
,
...
@@ -458,7 +482,7 @@ export default class CreateReportItems extends Component {
...
@@ -458,7 +482,7 @@ export default class CreateReportItems extends Component {
<
div
className
=
"grid grid-2x grid-mobile-none gap-15px"
style
=
{{
paddingLeft
:
20
,
paddingRight
:
20
}}
>
<
div
className
=
"grid grid-2x grid-mobile-none gap-15px"
style
=
{{
paddingLeft
:
20
,
paddingRight
:
20
}}
>
<
div
className
=
"column-1"
>
<
div
className
=
"column-1"
>
<
div
className
=
"margin-top-10px"
style
=
{{
padding
:
10
,
borderRadius
:
5
}}
>
<
div
className
=
"margin-top-10px"
style
=
{{
padding
:
10
,
borderRadius
:
5
}}
>
<
TextField
<
TextField
style
=
{{
width
:
'100%'
}}
style
=
{{
width
:
'100%'
}}
id
=
"uom"
id
=
"uom"
...
@@ -484,7 +508,7 @@ export default class CreateReportItems extends Component {
...
@@ -484,7 +508,7 @@ export default class CreateReportItems extends Component {
<
/div
>
<
/div
>
<
/div
>
<
/div
>
<
div
className
=
"column-2"
>
<
div
className
=
"column-2"
>
<
div
className
=
"margin-top-10px"
style
=
{{
padding
:
10
,
borderRadius
:
5
}}
>
<
div
className
=
"margin-top-10px"
style
=
{{
padding
:
10
,
borderRadius
:
5
}}
>
<
TextField
<
TextField
style
=
{{
width
:
'100%'
}}
style
=
{{
width
:
'100%'
}}
id
=
"weight"
id
=
"weight"
...
@@ -513,20 +537,45 @@ export default class CreateReportItems extends Component {
...
@@ -513,20 +537,45 @@ export default class CreateReportItems extends Component {
<
div
className
=
"grid grid-2x grid-mobile-none gap-15px"
style
=
{{
paddingLeft
:
20
,
paddingRight
:
20
}}
>
<
div
className
=
"grid grid-2x grid-mobile-none gap-15px"
style
=
{{
paddingLeft
:
20
,
paddingRight
:
20
}}
>
<
div
className
=
"column-1"
>
<
div
className
=
"column-1"
>
<
div
className
=
"margin-top-10px"
style
=
{{
padding
:
10
,
borderRadius
:
5
}}
>
<
div
className
=
"margin-top-10px"
style
=
{{
padding
:
10
,
borderRadius
:
5
}}
>
<
Autocomplete
<
Autocomplete
{...
this
.
state
.
listInputType
}
{...
this
.
state
.
listInputType
}
id
=
"inputType"
id
=
"inputType"
onChange
=
{(
event
,
newInputValue
)
=>
this
.
setState
({
InputType
:
newInputValue
},
onChange
=
{(
event
,
newInputValue
)
=>
this
.
setState
({
InputType
:
newInputValue
},
()
=>
newInputValue
===
null
?
this
.
setState
({
disabledFormula
:
true
,
disabledCondt
:
true
,
disabledValue
:
true
,
formula
:
''
,
condition
:
''
,
realVal
:
''
})
()
=>
newInputValue
===
null
?
this
.
setState
({
disabledFormula
:
true
,
disabledCondt
:
true
,
disabledValue
:
true
,
formula
:
''
,
condition
:
''
,
realVal
:
''
})
:
newInputValue
.
type_report_name
===
'Formula'
?
this
.
setState
({
disabledFormula
:
false
,
disabledCondt
:
true
,
disabledValue
:
true
,
formula
:
''
,
condition
:
''
,
realVal
:
''
})
:
newInputValue
.
type_report_name
===
'Formula'
?
:
newInputValue
.
type_report_name
===
'Validation'
?
this
.
setState
({
disabledFormula
:
false
,
disabledCondt
:
false
,
disabledValue
:
false
,
formula
:
''
,
condition
:
''
,
realVal
:
''
})
this
.
setState
({
:
this
.
setState
({
disabledFormula
:
true
,
disabledCondt
:
true
,
disabledValue
:
true
,
formula
:
''
,
condition
:
''
,
realVal
:
''
})
disabledFormula
:
false
,
)}
disabledCondt
:
true
,
disabledValue
:
true
,
formula
:
''
,
condition
:
''
,
realVal
:
''
},
()
=>
this
.
clearMessage
())
:
newInputValue
.
type_report_name
===
'Validation'
?
this
.
setState
({
disabledFormula
:
false
,
disabledCondt
:
false
,
disabledValue
:
false
,
formula
:
''
,
condition
:
''
,
realVal
:
''
},
()
=>
this
.
clearMessage
())
:
this
.
setState
({
disabledFormula
:
true
,
disabledCondt
:
true
,
disabledValue
:
true
,
formula
:
''
,
condition
:
''
,
realVal
:
''
},
()
=>
this
.
clearMessage
())
)}
debug
debug
renderInput
=
{(
params
)
=>
renderInput
=
{(
params
)
=>
<
TextField
{...
params
}
<
TextField
{...
params
}
label
=
"Tipe Data"
label
=
"Tipe Data"
error
=
{
this
.
state
.
errorTipeData
}
helperText
=
{
this
.
state
.
msgErrorTipeData
}
InputLabelProps
=
{{
InputLabelProps
=
{{
style
:
{
style
:
{
fontSize
:
11
,
fontSize
:
11
,
...
@@ -541,7 +590,7 @@ export default class CreateReportItems extends Component {
...
@@ -541,7 +590,7 @@ export default class CreateReportItems extends Component {
<
/div
>
<
/div
>
<
/div
>
<
/div
>
<
div
className
=
"column-2"
>
<
div
className
=
"column-2"
>
<
div
className
=
"margin-top-10px"
style
=
{{
padding
:
10
,
borderRadius
:
5
}}
>
<
div
className
=
"margin-top-10px"
style
=
{{
padding
:
10
,
borderRadius
:
5
}}
>
<
TextField
<
TextField
style
=
{{
width
:
'100%'
}}
style
=
{{
width
:
'100%'
}}
id
=
"formula"
id
=
"formula"
...
@@ -573,7 +622,7 @@ export default class CreateReportItems extends Component {
...
@@ -573,7 +622,7 @@ export default class CreateReportItems extends Component {
<
div
className
=
"grid grid-2x grid-mobile-none gap-15px"
style
=
{{
paddingLeft
:
20
,
paddingRight
:
20
}}
>
<
div
className
=
"grid grid-2x grid-mobile-none gap-15px"
style
=
{{
paddingLeft
:
20
,
paddingRight
:
20
}}
>
<
div
className
=
"column-1"
>
<
div
className
=
"column-1"
>
<
div
className
=
"margin-top-10px"
style
=
{{
padding
:
10
,
borderRadius
:
5
}}
>
<
div
className
=
"margin-top-10px"
style
=
{{
padding
:
10
,
borderRadius
:
5
}}
>
<
TextField
<
TextField
style
=
{{
width
:
'100%'
}}
style
=
{{
width
:
'100%'
}}
id
=
"realVal"
id
=
"realVal"
...
@@ -601,18 +650,20 @@ export default class CreateReportItems extends Component {
...
@@ -601,18 +650,20 @@ export default class CreateReportItems extends Component {
<
/div
>
<
/div
>
<
/div
>
<
/div
>
<
div
className
=
"column-2"
>
<
div
className
=
"column-2"
>
<
div
className
=
"margin-top-10px"
style
=
{{
padding
:
10
,
borderRadius
:
5
}}
>
<
div
className
=
"margin-top-10px"
style
=
{{
padding
:
10
,
borderRadius
:
5
}}
>
<
Autocomplete
<
Autocomplete
value
=
{
this
.
state
.
condition
}
value
=
{
this
.
state
.
condition
}
id
=
"isWrongCondition"
id
=
"isWrongCondition"
disabled
=
{
this
.
state
.
disabledCondt
}
disabled
=
{
this
.
state
.
disabledCondt
}
onChange
=
{(
event
,
newValue
)
=>
{
onChange
=
{(
event
,
newValue
)
=>
{
this
.
setState
({
condition
:
newValue
}
);
this
.
setState
({
condition
:
newValue
},
()
=>
this
.
clearMessage
()
);
}}
}}
options
=
{
this
.
state
.
options
}
options
=
{
this
.
state
.
options
}
renderInput
=
{(
params
)
=>
renderInput
=
{(
params
)
=>
<
TextField
{...
params
}
<
TextField
{...
params
}
label
=
"Kondisi Jika Salah"
error
=
{
this
.
state
.
errorCondition
}
helperText
=
{
this
.
state
.
msgErrorCondition
}
label
=
"Kondisi Jika Salah"
InputLabelProps
=
{{
InputLabelProps
=
{{
style
:
{
style
:
{
fontSize
:
11
,
fontSize
:
11
,
...
@@ -620,7 +671,7 @@ export default class CreateReportItems extends Component {
...
@@ -620,7 +671,7 @@ export default class CreateReportItems extends Component {
color
:
'#7e8085'
color
:
'#7e8085'
}
}
}}
}}
InputProps
=
{{
...
params
.
InputProps
,
style
:
{
fontSize
:
11
,
fontFamily
:
'Nunito Sans, sans-serif'
}
}}
InputProps
=
{{
...
params
.
InputProps
,
style
:
{
fontSize
:
11
,
fontFamily
:
'Nunito Sans, sans-serif'
}
}}
/>
}
/>
}
/>
/>
<
/div
>
<
/div
>
...
@@ -629,67 +680,67 @@ export default class CreateReportItems extends Component {
...
@@ -629,67 +680,67 @@ export default class CreateReportItems extends Component {
<
div
className
=
"grid grid-2x grid-mobile-none gap-15px"
style
=
{{
paddingLeft
:
20
,
paddingRight
:
20
}}
>
<
div
className
=
"grid grid-2x grid-mobile-none gap-15px"
style
=
{{
paddingLeft
:
20
,
paddingRight
:
20
}}
>
<
div
className
=
"column-1"
>
<
div
className
=
"column-1"
>
<
div
className
=
"margin-top-10px"
style
=
{{
padding
:
10
,
borderRadius
:
5
}}
>
<
div
className
=
"margin-top-10px"
style
=
{{
padding
:
10
,
borderRadius
:
5
}}
>
<
DatePicker
<
DatePicker
margin
=
"normal"
margin
=
"normal"
id
=
"startDate"
id
=
"startDate"
label
=
"Berlaku Mulai"
label
=
"Berlaku Mulai"
format
=
"dd MMMM yyyy"
format
=
"dd MMMM yyyy"
value
=
{
this
.
state
.
startDate
==
""
?
null
:
this
.
state
.
startDate
}
value
=
{
this
.
state
.
startDate
==
""
?
null
:
this
.
state
.
startDate
}
error
=
{
this
.
state
.
errorStartDate
}
error
=
{
this
.
state
.
errorStartDate
}
helperText
=
{
this
.
state
.
msgErrorSD
}
helperText
=
{
this
.
state
.
msgErrorSD
}
onChange
=
{(
e
)
=>
this
.
handleChange
(
e
,
'start_date'
)}
onChange
=
{(
e
)
=>
this
.
handleChange
(
e
,
'start_date'
)}
KeyboardButtonProps
=
{{
KeyboardButtonProps
=
{{
'aria-label'
:
'change date'
,
'aria-label'
:
'change date'
,
}}
}}
inputProps
=
{{
inputProps
=
{{
style
:
{
style
:
{
fontSize
:
11
,
fontSize
:
11
,
fontFamily
:
'Nunito Sans, sans-serif'
,
fontFamily
:
'Nunito Sans, sans-serif'
,
}
}
}}
}}
InputLabelProps
=
{{
InputLabelProps
=
{{
style
:
{
style
:
{
fontSize
:
11
,
fontSize
:
11
,
color
:
'#7e8085'
,
color
:
'#7e8085'
,
fontFamily
:
'Nunito Sans, sans-serif'
,
fontFamily
:
'Nunito Sans, sans-serif'
,
}
}
}}
}}
style
=
{{
padding
:
0
,
margin
:
0
,
width
:
'100%'
}}
style
=
{{
padding
:
0
,
margin
:
0
,
width
:
'100%'
}}
/
>
/
>
<
/div
>
<
/div
>
<
/div
>
<
/div
>
<
div
className
=
"column-2"
>
<
div
className
=
"column-2"
>
<
div
className
=
"margin-top-10px"
style
=
{{
padding
:
10
,
borderRadius
:
5
}}
>
<
div
className
=
"margin-top-10px"
style
=
{{
padding
:
10
,
borderRadius
:
5
}}
>
<
DatePicker
<
DatePicker
margin
=
"normal"
margin
=
"normal"
id
=
"endDate"
id
=
"endDate"
label
=
"Berlaku Hingga"
label
=
"Berlaku Hingga"
format
=
"dd MMMM yyyy"
format
=
"dd MMMM yyyy"
value
=
{
this
.
state
.
endDate
==
""
?
null
:
this
.
state
.
endDate
}
value
=
{
this
.
state
.
endDate
==
""
?
null
:
this
.
state
.
endDate
}
error
=
{
this
.
state
.
errorEndDate
}
error
=
{
this
.
state
.
errorEndDate
}
helperText
=
{
this
.
state
.
msgErrorED
}
helperText
=
{
this
.
state
.
msgErrorED
}
onChange
=
{(
e
)
=>
this
.
handleChange
(
e
,
'end_date'
)}
onChange
=
{(
e
)
=>
this
.
handleChange
(
e
,
'end_date'
)}
minDate
=
{
this
.
state
.
startDate
}
minDate
=
{
this
.
state
.
startDate
}
KeyboardButtonProps
=
{{
KeyboardButtonProps
=
{{
'aria-label'
:
'change date'
,
'aria-label'
:
'change date'
,
}}
}}
inputProps
=
{{
inputProps
=
{{
style
:
{
style
:
{
fontSize
:
11
,
fontSize
:
11
,
fontFamily
:
'Nunito Sans, sans-serif'
,
fontFamily
:
'Nunito Sans, sans-serif'
,
}
}
}}
}}
InputLabelProps
=
{{
InputLabelProps
=
{{
style
:
{
style
:
{
fontSize
:
11
,
fontSize
:
11
,
color
:
'#7e8085'
,
color
:
'#7e8085'
,
fontFamily
:
'Nunito Sans, sans-serif'
,
fontFamily
:
'Nunito Sans, sans-serif'
,
}
}
}}
}}
style
=
{{
padding
:
0
,
margin
:
0
,
width
:
'100%'
}}
style
=
{{
padding
:
0
,
margin
:
0
,
width
:
'100%'
}}
/
>
/
>
<
/div
>
<
/div
>
<
/div
>
<
/div
>
...
@@ -697,7 +748,7 @@ export default class CreateReportItems extends Component {
...
@@ -697,7 +748,7 @@ export default class CreateReportItems extends Component {
<
div
className
=
"grid grid-2x grid-mobile-none gap-15px"
style
=
{{
paddingLeft
:
20
,
paddingRight
:
20
}}
>
<
div
className
=
"grid grid-2x grid-mobile-none gap-15px"
style
=
{{
paddingLeft
:
20
,
paddingRight
:
20
}}
>
<
div
className
=
"column-1"
>
<
div
className
=
"column-1"
>
<
div
className
=
"margin-top-10px"
style
=
{{
backgroundColor
:
'#e8e8e8'
,
padding
:
10
,
borderRadius
:
5
}}
>
<
div
className
=
"margin-top-10px"
style
=
{{
backgroundColor
:
'#e8e8e8'
,
padding
:
10
,
borderRadius
:
5
}}
>
<
TextField
<
TextField
style
=
{{
width
:
'100%'
}}
style
=
{{
width
:
'100%'
}}
value
=
{
'Aktif'
}
value
=
{
'Aktif'
}
...
@@ -721,15 +772,15 @@ export default class CreateReportItems extends Component {
...
@@ -721,15 +772,15 @@ export default class CreateReportItems extends Component {
<
/div
>
<
/div
>
<
/div
>
<
/div
>
<
/div
>
<
/div
>
<
div
className
=
"grid grid-2x grid-mobile-none gap-15px"
style
=
{{
paddingLeft
:
20
,
paddingRight
:
20
}}
>
<
div
className
=
"grid grid-2x grid-mobile-none gap-15px"
style
=
{{
paddingLeft
:
20
,
paddingRight
:
20
}}
>
<
div
className
=
"column-1"
>
<
div
className
=
"column-1"
>
<
div
className
=
"margin-top-10px"
style
=
{{
padding
:
10
,
borderRadius
:
5
}}
>
<
div
className
=
"margin-top-10px"
style
=
{{
padding
:
10
,
borderRadius
:
5
}}
>
<
div
style
=
{{
display
:
'flex'
}}
>
<
div
style
=
{{
display
:
'flex'
}}
>
<
Typography
style
=
{{
fontSize
:
11
,
width
:
'20%'
}}
>
Dibuat
<
/Typography
>
<
Typography
style
=
{{
fontSize
:
11
,
width
:
'20%'
}}
>
Dibuat
<
/Typography
>
<
Typography
style
=
{{
fontSize
:
11
}}
>
:
<
/Typography
>
<
Typography
style
=
{{
fontSize
:
11
}}
>
:
<
/Typography
>
<
/div
>
<
/div
>
<
div
style
=
{{
display
:
'flex'
}}
>
<
div
style
=
{{
display
:
'flex'
}}
>
<
Typography
style
=
{{
fontSize
:
11
,
width
:
'20%'
}}
>
Diubah
<
/Typography
>
<
Typography
style
=
{{
fontSize
:
11
,
width
:
'20%'
}}
>
Diubah
<
/Typography
>
<
Typography
style
=
{{
fontSize
:
11
}}
>
:
<
/Typography
>
<
Typography
style
=
{{
fontSize
:
11
}}
>
:
<
/Typography
>
<
/div
>
<
/div
>
...
@@ -748,8 +799,8 @@ export default class CreateReportItems extends Component {
...
@@ -748,8 +799,8 @@ export default class CreateReportItems extends Component {
<
/div
>
<
/div
>
<
/button
>
<
/button
>
<
/div
>
<
/div
>
<
div
className
=
"column-2"
style
=
{{
display
:
'flex'
,
justifyContent
:
'flex-end'
,
alignItems
:
'center'
}}
>
<
div
className
=
"column-2"
style
=
{{
display
:
'flex'
,
justifyContent
:
'flex-end'
,
alignItems
:
'center'
}}
>
<
button
<
button
type
=
"button"
type
=
"button"
onClick
=
{()
=>
this
.
validasi
()}
onClick
=
{()
=>
this
.
validasi
()}
>
>
...
...
src/container/MasterData/formReportItems/EditReportItems.js
View file @
c2ff51bc
import
React
,
{
Component
}
from
'react'
;
import
React
,
{
Component
}
from
'react'
;
import
{
TextField
,
Typography
}
from
'@material-ui/core'
;
import
{
TextField
,
Typography
,
withStyles
,
Snackbar
}
from
'@material-ui/core'
;
import
{
DatePicker
}
from
'@material-ui/pickers'
;
import
{
DatePicker
}
from
'@material-ui/pickers'
;
import
format
from
"date-fns/format"
;
import
format
from
"date-fns/format"
;
import
Autocomplete
from
'@material-ui/lab/Autocomplete'
;
import
Autocomplete
from
'@material-ui/lab/Autocomplete'
;
import
MuiAlert
from
'@material-ui/lab/Alert'
;
import
api
from
'../../../api'
;
import
api
from
'../../../api'
;
import
*
as
R
from
'ramda'
import
*
as
R
from
'ramda'
import
{
titleCase
}
from
'../../../library/Utils'
;
import
{
titleCase
}
from
'../../../library/Utils'
;
import
Images
from
'../../../assets/Images'
;
import
Images
from
'../../../assets/Images'
;
const
Alert
=
withStyles
({
})((
props
)
=>
<
MuiAlert
elevation
=
{
6
}
variant
=
"filled"
{...
props
}
/>
)
;
export
default
class
EditReportItems
extends
Component
{
export
default
class
EditReportItems
extends
Component
{
constructor
(
props
)
{
constructor
(
props
)
{
...
@@ -23,7 +26,7 @@ export default class EditReportItems extends Component {
...
@@ -23,7 +26,7 @@ export default class EditReportItems extends Component {
order
:
null
,
order
:
null
,
description
:
''
,
description
:
''
,
uom
:
''
,
uom
:
''
,
weight
:
null
,
weight
:
""
,
formula
:
''
,
formula
:
''
,
realVal
:
''
,
realVal
:
''
,
condition
:
null
,
condition
:
null
,
...
@@ -51,7 +54,10 @@ export default class EditReportItems extends Component {
...
@@ -51,7 +54,10 @@ export default class EditReportItems extends Component {
disabledFormula
:
true
,
disabledFormula
:
true
,
disabledCondt
:
true
,
disabledCondt
:
true
,
disabledValue
:
true
,
disabledValue
:
true
,
options
:
[
'WARNING'
,
'STOPPER'
]
options
:
[
'WARNING'
,
'STOPPER'
],
alert
:
false
,
tipeAlert
:
''
,
messageAlert
:
''
}
}
}
}
...
@@ -160,26 +166,20 @@ export default class EditReportItems extends Component {
...
@@ -160,26 +166,20 @@ export default class EditReportItems extends Component {
"end_date"
:
this
.
state
.
tempData
.
end_date
"end_date"
:
this
.
state
.
tempData
.
end_date
}
}
console
.
log
(
payload
)
console
.
log
(
payload
)
api
.
create
().
updateReportItems
(
payload
).
then
((
response
)
=>
{
this
.
props
.
updateReportItems
(
payload
)
console
.
log
(
response
);
if
(
response
.
data
)
{
if
(
response
.
data
.
status
===
'success'
)
{
this
.
props
.
onClickClose
()
this
.
props
.
refresh
()
}
else
{
alert
(
response
.
data
.
message
)
}
}
})
}
}
getDetailReportItems
()
{
getDetailReportItems
()
{
api
.
create
().
getDetailReportItems
(
this
.
props
.
data
[
1
]).
then
((
response
)
=>
{
api
.
create
().
getDetailReportItems
(
this
.
props
.
data
[
1
]).
then
((
response
)
=>
{
if
(
response
.
data
.
status
===
'success'
)
{
if
(
response
.
data
)
{
this
.
setState
({
tempData
:
response
.
data
.
data
},
()
=>
this
.
getInputType
(),
this
.
getPerusahaan
(),
this
.
getReportType
(),)
if
(
response
.
data
.
status
===
'success'
)
{
console
.
log
(
response
.
data
.
data
)
this
.
setState
({
tempData
:
response
.
data
.
data
},
()
=>
this
.
getInputType
(),
this
.
getPerusahaan
(),
this
.
getReportType
(),)
console
.
log
(
response
.
data
.
data
)
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
data
.
message
,
tipeAlert
:
'warning'
})
}
}
else
{
}
else
{
alert
(
response
.
data
.
message
)
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
problem
,
tipeAlert
:
'error'
}
)
}
}
})
})
}
}
...
@@ -187,23 +187,27 @@ export default class EditReportItems extends Component {
...
@@ -187,23 +187,27 @@ export default class EditReportItems extends Component {
getInputType
()
{
getInputType
()
{
api
.
create
().
getInputType
().
then
((
response
)
=>
{
api
.
create
().
getInputType
().
then
((
response
)
=>
{
// console.log(response)
// console.log(response)
if
(
response
.
data
.
status
===
'success'
)
{
if
(
response
.
data
)
{
let
data
=
response
.
data
.
data
if
(
response
.
data
.
status
===
'success'
)
{
let
inputData
=
data
.
map
((
item
)
=>
{
let
data
=
response
.
data
.
data
return
{
let
inputData
=
data
.
map
((
item
)
=>
{
type_report_id
:
item
.
type_report_id
,
return
{
type_report_name
:
item
.
type_report_name
type_report_id
:
item
.
type_report_id
,
}
type_report_name
:
item
.
type_report_name
})
}
let
defaultProps
=
{
})
options
:
inputData
,
let
defaultProps
=
{
getOptionLabel
:
(
option
)
=>
titleCase
(
option
.
type_report_name
),
options
:
inputData
,
};
getOptionLabel
:
(
option
)
=>
titleCase
(
option
.
type_report_name
),
};
let
index
=
inputData
.
findIndex
((
val
)
=>
val
.
type_report_id
===
this
.
state
.
tempData
.
type_report_id
)
let
index
=
inputData
.
findIndex
((
val
)
=>
val
.
type_report_id
===
this
.
state
.
tempData
.
type_report_id
)
this
.
setState
({
listInputType
:
defaultProps
,
InputType
:
index
===
-
1
?
null
:
inputData
[
index
]
})
this
.
setState
({
listInputType
:
defaultProps
,
InputType
:
index
===
-
1
?
null
:
inputData
[
index
]
})
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
data
.
message
,
tipeAlert
:
'warning'
})
}
}
else
{
}
else
{
alert
(
response
.
data
.
message
)
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
problem
,
tipeAlert
:
'error'
}
)
}
}
})
})
}
}
...
@@ -211,23 +215,27 @@ export default class EditReportItems extends Component {
...
@@ -211,23 +215,27 @@ export default class EditReportItems extends Component {
getPerusahaan
()
{
getPerusahaan
()
{
api
.
create
().
getPerusahaanActive
().
then
((
response
)
=>
{
api
.
create
().
getPerusahaanActive
().
then
((
response
)
=>
{
console
.
log
(
response
)
console
.
log
(
response
)
if
(
response
.
data
.
status
===
'success'
)
{
if
(
response
.
data
)
{
let
data
=
response
.
data
.
data
if
(
response
.
data
.
status
===
'success'
)
{
let
companyData
=
data
.
map
((
item
)
=>
{
let
data
=
response
.
data
.
data
return
{
let
companyData
=
data
.
map
((
item
)
=>
{
company_id
:
item
.
company_id
,
return
{
company_name
:
item
.
company_name
company_id
:
item
.
company_id
,
}
company_name
:
item
.
company_name
})
}
let
defaultProps
=
{
})
options
:
companyData
,
let
defaultProps
=
{
getOptionLabel
:
(
option
)
=>
titleCase
(
option
.
company_name
),
options
:
companyData
,
};
getOptionLabel
:
(
option
)
=>
titleCase
(
option
.
company_name
),
};
let
index
=
companyData
.
findIndex
((
val
)
=>
val
.
company_id
===
this
.
state
.
tempData
.
company_id
)
let
index
=
companyData
.
findIndex
((
val
)
=>
val
.
company_id
===
this
.
state
.
tempData
.
company_id
)
this
.
setState
({
listCompany
:
defaultProps
,
company
:
index
===
-
1
?
null
:
companyData
[
index
]
},
()
=>
this
.
getParent
())
this
.
setState
({
listCompany
:
defaultProps
,
company
:
index
===
-
1
?
null
:
companyData
[
index
]
},
()
=>
this
.
getParent
())
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
data
.
message
,
tipeAlert
:
'warning'
})
}
}
else
{
}
else
{
alert
(
response
.
data
.
message
)
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
problem
,
tipeAlert
:
'error'
}
)
}
}
})
})
}
}
...
@@ -235,23 +243,27 @@ export default class EditReportItems extends Component {
...
@@ -235,23 +243,27 @@ export default class EditReportItems extends Component {
getReportType
()
{
getReportType
()
{
api
.
create
().
getReportType
().
then
((
response
)
=>
{
api
.
create
().
getReportType
().
then
((
response
)
=>
{
console
.
log
(
response
)
console
.
log
(
response
)
if
(
response
.
data
.
status
===
'success'
)
{
if
(
response
.
data
)
{
let
data
=
response
.
data
.
data
if
(
response
.
data
.
status
===
'success'
)
{
let
reportTypeData
=
data
.
map
((
item
)
=>
{
let
data
=
response
.
data
.
data
return
{
let
reportTypeData
=
data
.
map
((
item
)
=>
{
report_id
:
item
.
report_id
,
return
{
report_name
:
item
.
report_name
,
report_id
:
item
.
report_id
,
}
report_name
:
item
.
report_name
,
})
}
let
defaultProps
=
{
})
options
:
reportTypeData
,
let
defaultProps
=
{
getOptionLabel
:
(
option
)
=>
titleCase
(
option
.
report_name
),
options
:
reportTypeData
,
};
getOptionLabel
:
(
option
)
=>
titleCase
(
option
.
report_name
),
};
let
index
=
reportTypeData
.
findIndex
((
val
)
=>
val
.
report_id
===
this
.
state
.
tempData
.
report_id
)
let
index
=
reportTypeData
.
findIndex
((
val
)
=>
val
.
report_id
===
this
.
state
.
tempData
.
report_id
)
this
.
setState
({
listReportType
:
defaultProps
,
reportType
:
index
===
-
1
?
null
:
reportTypeData
[
index
]
},
()
=>
this
.
getParent
())
this
.
setState
({
listReportType
:
defaultProps
,
reportType
:
index
===
-
1
?
null
:
reportTypeData
[
index
]
},
()
=>
this
.
getParent
())
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
data
.
message
,
tipeAlert
:
'warning'
})
}
}
else
{
}
else
{
alert
(
response
.
data
.
message
)
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
problem
,
tipeAlert
:
'error'
}
)
}
}
})
})
}
}
...
@@ -264,22 +276,26 @@ export default class EditReportItems extends Component {
...
@@ -264,22 +276,26 @@ export default class EditReportItems extends Component {
}
}
api
.
create
().
getReportParent
(
payload
).
then
((
response
)
=>
{
api
.
create
().
getReportParent
(
payload
).
then
((
response
)
=>
{
console
.
log
(
response
)
console
.
log
(
response
)
if
(
response
.
data
.
status
===
'success'
)
{
if
(
response
.
data
)
{
let
data
=
response
.
data
.
data
if
(
response
.
data
.
status
===
'success'
)
{
let
parentData
=
data
.
map
((
item
)
=>
{
let
data
=
response
.
data
.
data
return
{
let
parentData
=
data
.
map
((
item
)
=>
{
item_report_id
:
item
.
item_report_id
,
return
{
description
:
item
.
description
item_report_id
:
item
.
item_report_id
,
}
description
:
item
.
description
})
}
let
defaultProps
=
{
})
options
:
parentData
,
let
defaultProps
=
{
getOptionLabel
:
(
option
)
=>
titleCase
(
option
.
description
),
options
:
parentData
,
};
getOptionLabel
:
(
option
)
=>
titleCase
(
option
.
description
),
let
index
=
parentData
.
findIndex
((
val
)
=>
val
.
item_report_id
===
this
.
state
.
tempData
.
parent
)
};
this
.
setState
({
listParent
:
defaultProps
,
parent
:
index
==
-
1
?
null
:
parentData
[
index
]
})
let
index
=
parentData
.
findIndex
((
val
)
=>
val
.
item_report_id
===
this
.
state
.
tempData
.
parent
)
this
.
setState
({
listParent
:
defaultProps
,
parent
:
index
==
-
1
?
null
:
parentData
[
index
]
})
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
data
.
message
,
tipeAlert
:
'warning'
})
}
}
else
{
}
else
{
alert
(
response
.
data
.
message
)
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
problem
,
tipeAlert
:
'error'
}
)
}
}
})
})
}
}
...
@@ -294,6 +310,10 @@ export default class EditReportItems extends Component {
...
@@ -294,6 +310,10 @@ export default class EditReportItems extends Component {
})
})
}
}
closeAlert
()
{
this
.
setState
({
alert
:
false
})
}
render
()
{
render
()
{
return
(
return
(
...
@@ -315,6 +335,11 @@ export default class EditReportItems extends Component {
...
@@ -315,6 +335,11 @@ export default class EditReportItems extends Component {
<
/button
>
<
/button
>
<
/div
>
<
/div
>
<
/div
>
<
/div
>
<
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
=
"grid grid-2x grid-mobile-none gap-15px"
style
=
{{
paddingLeft
:
20
,
paddingRight
:
20
}}
>
<
div
className
=
"grid grid-2x grid-mobile-none gap-15px"
style
=
{{
paddingLeft
:
20
,
paddingRight
:
20
}}
>
<
div
className
=
"column-1"
>
<
div
className
=
"column-1"
>
...
@@ -398,11 +423,13 @@ export default class EditReportItems extends Component {
...
@@ -398,11 +423,13 @@ export default class EditReportItems extends Component {
id
=
"order"
id
=
"order"
label
=
"Order"
label
=
"Order"
name
=
"order"
name
=
"order"
type
=
"number"
value
=
{
this
.
state
.
tempData
===
null
?
''
:
this
.
state
.
tempData
.
order
}
value
=
{
this
.
state
.
tempData
===
null
?
''
:
this
.
state
.
tempData
.
order
}
error
=
{
this
.
state
.
errorOrder
}
error
=
{
this
.
state
.
errorOrder
}
helperText
=
{
this
.
state
.
msgErrorOrder
}
helperText
=
{
this
.
state
.
msgErrorOrder
}
onChange
=
{(
e
)
=>
this
.
handleChange
(
e
,
''
)}
onChange
=
{(
e
)
=>
this
.
handleChange
(
e
,
''
)}
inputProps
=
{{
inputProps
=
{{
min
:
0
,
style
:
{
style
:
{
fontSize
:
11
,
fontSize
:
11
,
fontFamily
:
'Nunito Sans, sans-serif'
fontFamily
:
'Nunito Sans, sans-serif'
...
...
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