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
96f9d10d
Commit
96f9d10d
authored
Jun 27, 2022
by
Arfin Syadziy
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev/arfin' into 'ENV-BOOTCAMP'
Dev/arfin See merge request
!1567
parents
25105f54
84e6bd54
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
42 additions
and
1388 deletions
+42
-1388
AuditTahunan.js
src/container/DocumentManagement/AuditTahunan.js
+0
-299
BOD.js
src/container/DocumentManagement/BOD.js
+0
-303
DocumentManagement.js
src/container/DocumentManagement/DocumentManagement.js
+42
-64
ManualBookETMS.js
src/container/DocumentManagement/ManualBookETMS.js
+0
-131
ManualBookTia.js
src/container/DocumentManagement/ManualBookTia.js
+0
-296
QReview.js
src/container/DocumentManagement/QReview.js
+0
-295
No files found.
src/container/DocumentManagement/AuditTahunan.js
deleted
100644 → 0
View file @
25105f54
import
React
,
{
Component
}
from
'react'
import
MUIDataTable
from
'mui-datatables'
import
{
withStyles
}
from
'@material-ui/core/styles'
;
import
{
createMuiTheme
,
MuiThemeProvider
,
Snackbar
}
from
'@material-ui/core'
;
import
MuiAlert
from
'@material-ui/lab/Alert'
;
import
Constant
from
'../../library/Constant'
;
import
Images
from
'../../assets/Images'
;
import
ReactTooltip
from
'react-tooltip'
;
import
PopUpDelete
from
"./PopUpDelete"
;
import
api
from
'../../api'
;
import
CreateManagementDoc
from
'./CreateManagementDoc'
;
import
EditManagementDoc
from
'./EditManagementDoc'
;
var
ct
=
require
(
"../../library/CustomTable"
);
const
getMuiTheme
=
()
=>
createMuiTheme
(
ct
.
customTable
());
const
options
=
ct
.
customOptionsManagementDocument
();
const
Alert
=
withStyles
({
})((
props
)
=>
<
MuiAlert
elevation
=
{
6
}
variant
=
"filled"
{...
props
}
/>
)
;
export
default
class
AuditTahunan
extends
Component
{
constructor
(
props
)
{
super
(
props
)
this
.
state
=
{
dataTable
:
[],
visibleCreate
:
false
,
visibleEdit
:
false
,
refresh
:
''
,
alert
:
false
,
popupDel
:
false
,
}
}
componentDidMount
()
{
// console.log(this.props.data)
this
.
getData
()
}
componentWillReceiveProps
(
props
)
{
// console.log(props);
const
{
refresh
,
id
}
=
this
.
props
;
if
(
props
.
refresh
!==
refresh
)
{
this
.
getData
()
}
}
getData
()
{
let
payload
=
{
"setting_id"
:
this
.
props
.
data
.
setting_id
}
api
.
create
().
getAllDocument
(
payload
).
then
(
response
=>
{
console
.
log
(
response
)
if
(
response
.
data
)
{
if
(
response
.
ok
)
{
if
(
response
.
data
.
status
==
'success'
)
{
let
dataTable
=
response
.
data
.
data
.
map
((
item
,
index
)
=>
{
return
[
index
,
item
.
document_name
,
item
.
description
,
item
.
company_name
,
item
.
document_periode
,
item
.
document_type
,
String
(
Number
(
item
.
document_size
)
/
1000
+
' KB'
),
item
.
created_by
,
item
.
created_at
,
]
})
this
.
setState
({
dataTable
})
let
docPath
=
response
.
data
.
data
.
map
((
item
)
=>
{
return
[
item
.
document_filepath
]
})
this
.
setState
({
docPath
})
let
docId
=
response
.
data
.
data
.
map
((
item
)
=>
{
return
[
item
.
document_id
]
})
this
.
setState
({
docId
})
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
data
.
message
,
tipeAlert
:
'warning'
,
loading
:
false
},
()
=>
{
if
(
response
.
data
.
message
.
includes
(
"Someone Logged In"
)
||
response
.
data
.
message
.
includes
(
"Token Expired"
))
{
setTimeout
(()
=>
{
localStorage
.
removeItem
(
Constant
.
TOKEN
)
window
.
location
.
reload
();
},
1000
);
}
})
}
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
data
.
message
,
tipeAlert
:
'error'
,
loading
:
false
})
}
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
problem
,
tipeAlert
:
'error'
,
loading
:
false
})
}
})
}
openPopUp
=
async
(
index
,
val
,
type
)
=>
{
if
(
type
===
'download'
)
{
console
.
log
(
this
.
state
.
docPath
[
val
])
let
res
=
await
fetch
(
`
${
process
.
env
.
REACT_APP_URL_MAIN_BE
}
/public/document/download_document?documentName=`
+
this
.
state
.
docPath
[
val
]
+
"&&fileType="
+
index
[
5
]
)
res
=
await
res
.
blob
()
// console.log(res)
if
(
res
.
size
>
0
)
{
let
url
=
window
.
URL
.
createObjectURL
(
res
);
let
a
=
document
.
createElement
(
'a'
);
a
.
href
=
url
;
a
.
download
=
index
[
1
];
a
.
click
();
}
}
if
(
type
===
'delete'
)
{
this
.
setState
({
id
:
this
.
state
.
docId
[
val
],
rowData
:
index
,
popupDel
:
true
})
}
if
(
type
===
'edit'
)
{
this
.
setState
({
id
:
this
.
state
.
docId
[
val
],
rowData
:
index
,
visibleEdit
:
true
})
}
}
deleteDoc
=
(
payload
)
=>
{
this
.
setState
({
popupDel
:
false
})
api
.
create
().
deleteDocument
(
payload
).
then
(
response
=>
{
console
.
log
(
response
.
data
)
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"
)
||
response
.
data
.
message
.
includes
(
"Token Expired"
))
{
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'
})
}
})
}
updateDocument
(
payload
)
{
api
.
create
().
updateDocument
(
payload
).
then
(
response
=>
{
console
.
log
(
response
)
if
(
response
.
data
)
{
if
(
response
.
ok
)
{
if
(
response
.
data
.
status
===
"success"
)
{
this
.
getData
()
this
.
setState
({
konfirmasi
:
false
,
alert
:
true
,
messageAlert
:
response
.
data
.
message
,
tipeAlert
:
'success'
,
visibleEdit
:
false
})
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
data
.
message
,
tipeAlert
:
'warning'
},
()
=>
{
if
(
response
.
data
.
message
.
includes
(
"Someone Logged In"
)
||
response
.
data
.
message
.
includes
(
"Token Expired"
))
{
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'
})
}
})
}
closeAlert
()
{
this
.
setState
({
alert
:
false
})
}
render
()
{
let
columns
=
[{
name
:
"Action"
,
options
:
{
filter
:
false
,
sort
:
false
,
customBodyRender
:
(
val
,
tableMeta
)
=>
{
console
.
log
(
tableMeta
)
return
(
<
div
style
=
{{
display
:
'flex'
}}
>
{
/* {this.state.btnedit && <span> */
}
<
a
data
-
tip
=
{
'Download'
}
data
-
for
=
"download"
>
<
button
style
=
{{
backgroundColor
:
'transparent'
,
cursor
:
'pointer'
,
borderColor
:
'transparent'
,
marginRight
:
15
}}
// onClick={() => console.log(tableMeta)}
onClick
=
{()
=>
this
.
openPopUp
(
tableMeta
.
rowData
,
val
,
'download'
)}
>
<
img
src
=
{
Images
.
download
}
/
>
<
/button
>
<
/a
>
<
ReactTooltip
border
=
{
true
}
id
=
"download"
place
=
"bottom"
type
=
"light"
effect
=
"solid"
/>
{
/* </span>} */
}
{
this
.
props
.
btnedit
&&
<
span
>
<
a
data
-
tip
=
{
'Edit'
}
data
-
for
=
"edit"
>
<
button
style
=
{{
backgroundColor
:
'transparent'
,
cursor
:
'pointer'
,
borderColor
:
'transparent'
,
marginRight
:
15
}}
// onClick={() => console.log(tableMeta)}
onClick
=
{()
=>
this
.
openPopUp
(
tableMeta
.
rowData
,
val
,
'edit'
)}
>
<
img
src
=
{
Images
.
editCopy
}
/
>
<
/button
>
<
/a
>
<
ReactTooltip
border
=
{
true
}
id
=
"edit"
place
=
"bottom"
type
=
"light"
effect
=
"solid"
/>
<
/span>
}
{
this
.
props
.
btndelete
&&
<
span
>
<
a
data
-
tip
=
{
'Delete'
}
data
-
for
=
"delete"
>
<
button
style
=
{{
backgroundColor
:
'transparent'
,
cursor
:
'pointer'
,
borderColor
:
'transparent'
,
}}
// onClick={() => console.log(tableMeta)}
onClick
=
{()
=>
this
.
openPopUp
(
tableMeta
.
rowData
,
val
,
'delete'
)}
>
<
img
src
=
{
Images
.
delete
}
/
>
<
/button
>
<
/a
>
<
ReactTooltip
border
=
{
true
}
id
=
"delete"
place
=
"bottom"
type
=
"light"
effect
=
"solid"
/>
<
/span>
}
<
/div
>
);
}
}
},
"File Name"
,
"Description"
,
"Company Name"
,
"Period"
,
"Type"
,
"File Size"
,
"Created By"
,
"Created Date"
]
return
(
<
div
style
=
{{
width
:
'100%'
}}
>
<
div
style
=
{{
padding
:
25
}}
>
<
Snackbar
open
=
{
this
.
state
.
alert
}
autoHideDuration
=
{
6000
}
onClose
=
{()
=>
this
.
closeAlert
()}
>
<
Alert
onClose
=
{()
=>
this
.
closeAlert
()}
severity
=
{
this
.
state
.
tipeAlert
}
>
{
this
.
state
.
messageAlert
}
<
/Alert
>
<
/Snackbar
>
<
MuiThemeProvider
theme
=
{
getMuiTheme
()}
>
<
MUIDataTable
theme
=
{
getMuiTheme
()}
data
=
{
this
.
state
.
dataTable
}
columns
=
{
columns
}
options
=
{
options
}
/
>
<
/MuiThemeProvider
>
<
/div
>
{
this
.
state
.
popupDel
&&
(
<
PopUpDelete
type
=
{
"delete"
}
onClickClose
=
{()
=>
this
.
setState
({
popupDel
:
false
})}
data
=
{
this
.
state
.
rowData
}
idoc
=
{
this
.
state
.
id
}
// getList={() => this.getData.bind(this)}
deleteDoc
=
{
this
.
deleteDoc
.
bind
(
this
)}
/
>
)}
{
this
.
state
.
visibleEdit
&&
(
<
EditManagementDoc
type
=
{
"edit"
}
onClickClose
=
{()
=>
this
.
setState
({
visibleEdit
:
false
})}
data
=
{
this
.
state
.
rowData
}
idoc
=
{
this
.
state
.
id
}
updateDocument
=
{
this
.
updateDocument
.
bind
(
this
)}
/
>
)}
<
/div
>
)
}
}
src/container/DocumentManagement/BOD.js
deleted
100644 → 0
View file @
25105f54
import
React
,
{
Component
}
from
'react'
import
MUIDataTable
from
'mui-datatables'
import
{
withStyles
}
from
'@material-ui/core/styles'
;
import
{
createMuiTheme
,
MuiThemeProvider
,
Snackbar
}
from
'@material-ui/core'
;
import
MuiAlert
from
'@material-ui/lab/Alert'
;
import
Constant
from
'../../library/Constant'
;
import
api
from
'../../api'
;
import
Images
from
'../../assets/Images'
;
import
ReactTooltip
from
'react-tooltip'
;
import
PopUpDelete
from
"./PopUpDelete"
;
import
CreateManagementDoc
from
'./CreateManagementDoc'
;
import
EditManagementDoc
from
'./EditManagementDoc'
;
var
ct
=
require
(
"../../library/CustomTable"
);
const
getMuiTheme
=
()
=>
createMuiTheme
(
ct
.
customTable
());
const
options
=
ct
.
customOptionsManagementDocument
();
const
Alert
=
withStyles
({
})((
props
)
=>
<
MuiAlert
elevation
=
{
6
}
variant
=
"filled"
{...
props
}
/>
)
;
export
default
class
BOD
extends
Component
{
constructor
(
props
)
{
super
(
props
)
this
.
state
=
{
dataTable
:
[],
visibleCreate
:
false
,
visibleEdit
:
false
,
refresh
:
''
,
alert
:
false
,
popupDel
:
false
,
}
}
componentDidMount
()
{
// console.log(this.props.data)
this
.
getData
()
}
componentWillReceiveProps
(
props
)
{
// console.log(props);
const
{
refresh
,
id
}
=
this
.
props
;
if
(
props
.
refresh
!==
refresh
)
{
this
.
getData
()
}
}
getData
()
{
let
payload
=
{
"setting_id"
:
this
.
props
.
data
.
setting_id
}
api
.
create
().
getAllDocument
(
payload
).
then
((
response
)
=>
{
console
.
log
(
response
)
if
(
response
.
problem
){
alert
(
response
.
problem
)
}
if
(
response
.
data
)
{
if
(
response
.
ok
)
{
if
(
response
.
data
.
status
==
'success'
)
{
let
dataTable
=
response
.
data
.
data
.
map
((
item
,
index
)
=>
{
return
[
index
,
item
.
document_name
,
item
.
description
,
item
.
company_name
,
item
.
document_periode
,
item
.
document_type
,
String
(
Number
(
item
.
document_size
)
/
1000
+
' KB'
),
item
.
created_by
,
item
.
created_at
,
]
})
this
.
setState
({
dataTable
})
let
docPath
=
response
.
data
.
data
.
map
((
item
)
=>
{
return
[
item
.
document_filepath
]
})
this
.
setState
({
docPath
})
let
docId
=
response
.
data
.
data
.
map
((
item
)
=>
{
return
[
item
.
document_id
]
})
this
.
setState
({
docId
})
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
data
.
message
,
tipeAlert
:
'warning'
,
loading
:
false
},
()
=>
{
if
(
response
.
data
.
message
.
includes
(
"Someone Logged In"
)
||
response
.
data
.
message
.
includes
(
"Token Expired"
))
{
setTimeout
(()
=>
{
localStorage
.
removeItem
(
Constant
.
TOKEN
)
window
.
location
.
reload
();
},
1000
);
}
})
}
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
data
.
message
,
tipeAlert
:
'error'
,
loading
:
false
})
}
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
problem
,
tipeAlert
:
'error'
,
loading
:
false
})
}
})
}
openPopUp
=
async
(
index
,
val
,
type
)
=>
{
if
(
type
===
'download'
)
{
console
.
log
(
this
.
state
.
docPath
[
val
])
let
res
=
await
fetch
(
`
${
process
.
env
.
REACT_APP_URL_MAIN_BE
}
/public/document/download_document?documentName=`
+
this
.
state
.
docPath
[
val
]
+
"&&fileType="
+
index
[
5
]
)
res
=
await
res
.
blob
()
// console.log(res)
if
(
res
.
size
>
0
)
{
let
url
=
window
.
URL
.
createObjectURL
(
res
);
let
a
=
document
.
createElement
(
'a'
);
a
.
href
=
url
;
a
.
download
=
index
[
1
];
a
.
click
();
}
}
if
(
type
===
'delete'
)
{
this
.
setState
({
id
:
this
.
state
.
docId
[
val
],
rowData
:
index
,
popupDel
:
true
})
}
if
(
type
===
'edit'
)
{
this
.
setState
({
id
:
this
.
state
.
docId
[
val
],
rowData
:
index
,
visibleEdit
:
true
})
}
}
updateDocument
(
payload
)
{
api
.
create
().
updateDocument
(
payload
).
then
(
response
=>
{
console
.
log
(
response
)
if
(
response
.
data
)
{
if
(
response
.
ok
)
{
if
(
response
.
data
.
status
===
"success"
)
{
this
.
getData
()
this
.
setState
({
konfirmasi
:
false
,
alert
:
true
,
messageAlert
:
response
.
data
.
message
,
tipeAlert
:
'success'
,
visibleEdit
:
false
})
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
data
.
message
,
tipeAlert
:
'warning'
},
()
=>
{
if
(
response
.
data
.
message
.
includes
(
"Someone Logged In"
)
||
response
.
data
.
message
.
includes
(
"Token Expired"
))
{
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'
})
}
})
}
closeAlert
()
{
this
.
setState
({
alert
:
false
})
}
deleteDoc
=
(
payload
)
=>
{
this
.
setState
({
popupDel
:
false
})
api
.
create
().
deleteDocument
(
payload
).
then
(
response
=>
{
console
.
log
(
response
.
data
)
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"
)
||
response
.
data
.
message
.
includes
(
"Token Expired"
))
{
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'
})
}
})
}
render
()
{
let
columns
=
[
{
name
:
"Action"
,
options
:
{
filter
:
false
,
sort
:
false
,
customBodyRender
:
(
val
,
tableMeta
)
=>
{
console
.
log
(
tableMeta
)
return
(
<
div
style
=
{{
display
:
'flex'
}}
>
{
/* {this.state.btnedit && <span> */
}
<
a
data
-
tip
=
{
'Download'
}
data
-
for
=
"download"
>
<
button
style
=
{{
backgroundColor
:
'transparent'
,
cursor
:
'pointer'
,
borderColor
:
'transparent'
,
marginRight
:
15
}}
// onClick={() => console.log(tableMeta)}
onClick
=
{()
=>
this
.
openPopUp
(
tableMeta
.
rowData
,
val
,
'download'
)}
>
<
img
src
=
{
Images
.
download
}
/
>
<
/button
>
<
/a
>
<
ReactTooltip
border
=
{
true
}
id
=
"download"
place
=
"bottom"
type
=
"light"
effect
=
"solid"
/>
{
/* </span>} */
}
{
this
.
props
.
btnedit
&&
<
span
>
<
a
data
-
tip
=
{
'Edit'
}
data
-
for
=
"edit"
>
<
button
style
=
{{
backgroundColor
:
'transparent'
,
cursor
:
'pointer'
,
borderColor
:
'transparent'
,
marginRight
:
15
}}
// onClick={() => console.log(tableMeta)}
onClick
=
{()
=>
this
.
openPopUp
(
tableMeta
.
rowData
,
val
,
'edit'
)}
>
<
img
src
=
{
Images
.
editCopy
}
/
>
<
/button
>
<
/a
>
<
ReactTooltip
border
=
{
true
}
id
=
"edit"
place
=
"bottom"
type
=
"light"
effect
=
"solid"
/>
<
/span>
}
{
this
.
props
.
btndelete
&&
<
span
>
<
a
data
-
tip
=
{
'Delete'
}
data
-
for
=
"delete"
>
<
button
style
=
{{
backgroundColor
:
'transparent'
,
cursor
:
'pointer'
,
borderColor
:
'transparent'
,
}}
// onClick={() => console.log(tableMeta)}
onClick
=
{()
=>
this
.
openPopUp
(
tableMeta
.
rowData
,
val
,
'delete'
)}
>
<
img
src
=
{
Images
.
delete
}
/
>
<
/button
>
<
/a
>
<
ReactTooltip
border
=
{
true
}
id
=
"delete"
place
=
"bottom"
type
=
"light"
effect
=
"solid"
/>
<
/span>
}
<
/div
>
);
}
}
},
"File Name"
,
"Description"
,
"Company Name"
,
"Period"
,
"Type"
,
"File Size"
,
"Created By"
,
"Created Date"
]
return
(
<
div
style
=
{{
width
:
'100%'
}}
>
<
div
style
=
{{
padding
:
25
}}
>
<
Snackbar
open
=
{
this
.
state
.
alert
}
autoHideDuration
=
{
6000
}
onClose
=
{()
=>
this
.
closeAlert
()}
>
<
Alert
onClose
=
{()
=>
this
.
closeAlert
()}
severity
=
{
this
.
state
.
tipeAlert
}
>
{
this
.
state
.
messageAlert
}
<
/Alert
>
<
/Snackbar
>
<
MuiThemeProvider
theme
=
{
getMuiTheme
()}
>
<
MUIDataTable
theme
=
{
getMuiTheme
()}
data
=
{
this
.
state
.
dataTable
}
columns
=
{
columns
}
options
=
{
options
}
/
>
<
/MuiThemeProvider
>
<
/div
>
{
this
.
state
.
popupDel
&&
(
<
PopUpDelete
type
=
{
"delete"
}
onClickClose
=
{()
=>
this
.
setState
({
popupDel
:
false
})}
data
=
{
this
.
state
.
rowData
}
idoc
=
{
this
.
state
.
id
}
// getList={() => this.getData.bind(this)}
deleteDoc
=
{
this
.
deleteDoc
.
bind
(
this
)}
/
>
)}
{
this
.
state
.
visibleEdit
&&
(
<
EditManagementDoc
type
=
{
"edit"
}
onClickClose
=
{()
=>
this
.
setState
({
visibleEdit
:
false
})}
data
=
{
this
.
state
.
rowData
}
idoc
=
{
this
.
state
.
id
}
updateDocument
=
{
this
.
updateDocument
.
bind
(
this
)}
/
>
)}
<
/div
>
)
}
}
src/container/DocumentManagement/DocumentManagement.js
View file @
96f9d10d
...
...
@@ -2,14 +2,14 @@ import React, { Component } from 'react'
import
{
Tabs
,
Tab
,
Typography
,
Paper
,
withStyles
,
Snackbar
}
from
'@material-ui/core'
import
ReactTooltip
from
'react-tooltip'
import
Images
from
'../../assets/Images'
import
ManualBookTia
from
'./ManualBookTia'
//
import ManualBookTia from './ManualBookTia'
import
api
from
'../../api'
import
AuditTahunan
from
'./AuditTahunan'
//
import AuditTahunan from './AuditTahunan'
import
CreateManagementDoc
from
'./CreateManagementDoc'
import
AllDocument
from
'./AllDocument'
import
QReview
from
'./QReview'
import
BOD
from
'./BOD'
import
ManualBookETMS
from
'./ManualBookETMS'
//
import QReview from './QReview'
//
import BOD from './BOD'
//
import ManualBookETMS from './ManualBookETMS'
import
PopUpKonfirmasi
from
"./PopUpKonfirmasi"
;
import
Constant
from
'../../library/Constant'
import
MuiAlert
from
'@material-ui/lab/Alert'
;
...
...
@@ -30,16 +30,17 @@ export default class DocumentManagement extends Component {
btndelete
:
false
,
load
:
false
,
name
:
''
,
userCompActive
:
[]
userCompActive
:
[],
isHasAccessDocument
:
false
,
}
}
getPermission
()
{
getPermission
(
subMenu
)
{
let
payload
=
{
menu
:
"document management"
menu
:
subMenu
}
api
.
create
().
getPermission
(
payload
).
then
(
response
=>
{
//
console.log(response)
console
.
log
(
response
)
if
(
response
.
data
)
{
if
(
response
.
data
.
status
===
"success"
)
{
this
.
setState
({
...
...
@@ -60,28 +61,44 @@ export default class DocumentManagement extends Component {
}
selectTab
=
(
event
,
newEvent
)
=>
{
this
.
setState
({
tab
:
newEvent
})
// console.log(this.state.tab)
this
.
setState
({
tab
:
newEvent
},
()
=>
{
console
.
log
(
this
.
state
.
tab
)
this
.
getPermission
(
this
.
state
.
listData
[
this
.
state
.
tab
].
value
.
toLocaleLowerCase
())
})
}
componentDidMount
()
{
this
.
getDataDocument
()
this
.
getPermission
()
//
this.getPermission()
this
.
getDetailUser
()
}
getDataDocument
(
id
,
name
)
{
api
.
create
().
getDocumentCategory
().
then
(
response
=>
{
//
console.log(response);
console
.
log
(
response
);
if
(
response
)
{
if
(
response
.
data
.
status
===
"success"
)
{
let
dataList
=
[]
response
.
data
.
data
.
map
((
item
,
index
)
=>
{
// if (item.value == "Manual Book TIA 4.0sss") {
dataList
.
push
(
item
)
// }
})
if
(
dataList
.
length
==
0
)
{
this
.
setState
({
isHasAccessDocument
:
dataList
.
length
==
0
?
false
:
true
})
}
else
{
this
.
setState
({
listData
:
response
.
data
.
data
,
id
:
id
===
undefined
?
response
.
data
.
data
[
0
].
setting_id
:
id
,
name
:
name
===
undefined
?
response
.
data
.
data
[
0
].
value
:
name
,
isHasAccessDocument
:
dataList
.
length
==
0
?
false
:
true
,
listData
:
dataList
,
id
:
id
===
undefined
?
dataList
[
0
].
setting_id
:
id
,
name
:
name
===
undefined
?
dataList
[
0
].
value
:
name
,
loadTable
:
true
,
refresh
:
id
===
undefined
?
''
:
'create'
},
()
=>
{
this
.
getPermission
(
dataList
[
0
].
value
)
})
}
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
data
.
message
,
tipeAlert
:
'warning'
,
loading
:
false
},
()
=>
{
if
(
response
.
data
.
message
.
includes
(
"Someone Logged In"
)
||
response
.
data
.
message
.
includes
(
"Token Expired"
))
{
...
...
@@ -255,7 +272,7 @@ export default class DocumentManagement extends Component {
<
Typography
style
=
{{
fontSize
:
'16px'
,
color
:
'white'
}}
>
Document
Management
<
/Typography
>
<
/div
>
<
div
style
=
{{
padding
:
20
}}
>
{
this
.
state
.
loading
&&
loadingComponent
}
{
this
.
state
.
loading
&&
loadingComponent
&&
this
.
state
.
isHasAccessDocument
}
<
Paper
style
=
{{
padding
:
20
}}
>
<
div
style
=
{{
display
:
'flex'
,
justifyContent
:
'flex-end'
}}
>
{(
this
.
state
.
btncreate
)
&&
<
span
>
...
...
@@ -304,54 +321,15 @@ export default class DocumentManagement extends Component {
handleLoading
=
{
this
.
handleLoading
.
bind
(
this
)}
name
=
{
this
.
state
.
name
}
/
>
// this.state.id === 68542 ?
// <AuditTahunan
// data={this.state.listData[this.state.tab]}
// refresh={this.state.refresh}
// btnedit={this.state.btnedit}
// btndelete={this.state.btndelete}
// load={this.state.load}
// />
// :
// this.state.id === 68541 ?
// <ManualBookTia
// data={this.state.listData[this.state.tab]}
// refresh={this.state.refresh}
// btnedit={this.state.btnedit}
// btndelete={this.state.btndelete}
// load={this.state.load}
// />
// :
// this.state.id === 68544 ?
// <QReview
// data={this.state.listData[this.state.tab]}
// refresh={this.state.refresh}
// btnedit={this.state.btnedit}
// btndelete={this.state.btndelete}
// load={this.state.load}
// />
// :
// this.state.id === 68543 ?
// <BOD
// data={this.state.listData[this.state.tab]}
// refresh={this.state.refresh}
// btnedit={this.state.btnedit}
// btndelete={this.state.btndelete}
// load={this.state.load}
// />
// // :
// // this.state.id === 68545 ?
// // <ManualBookETMS
// // data={this.state.listData[this.state.tab]}
// // refresh={this.state.refresh}
// // />
// :
// <span>Coming Soon</span>
)}
<
/div
>
<
/Paper
>
{
!
this
.
state
.
isHasAccessDocument
&&
(
<
Paper
style
=
{{
padding
:
20
}}
>
<
label
>
You
Don
't Have Any Access in Document Management</label>
</Paper>
)}
</div>
{this.state.konfirmasi && (
<PopUpKonfirmasi
...
...
src/container/DocumentManagement/ManualBookETMS.js
deleted
100644 → 0
View file @
25105f54
import
React
,
{
Component
}
from
'react'
import
MUIDataTable
from
'mui-datatables'
import
{
createMuiTheme
,
MuiThemeProvider
}
from
'@material-ui/core'
;
import
api
from
'../../api'
;
import
Images
from
'../../assets/Images'
;
import
ReactTooltip
from
'react-tooltip'
;
var
ct
=
require
(
"../../library/CustomTable"
);
const
getMuiTheme
=
()
=>
createMuiTheme
(
ct
.
customTable
());
const
options
=
ct
.
customOptions
();
export
default
class
ManualBookETMS
extends
Component
{
constructor
(
props
)
{
super
(
props
)
this
.
state
=
{
dataTable
:
[],
visibleCreate
:
false
,
refresh
:
''
}
}
componentDidMount
()
{
// console.log(this.props.data)
this
.
getData
()
}
componentWillReceiveProps
(
props
)
{
// console.log(props);
const
{
refresh
,
id
}
=
this
.
props
;
if
(
props
.
refresh
!==
refresh
)
{
this
.
getData
()
}
}
getData
()
{
let
payload
=
{
"setting_id"
:
this
.
props
.
data
.
setting_id
}
api
.
create
().
getAllDocument
(
payload
).
then
(
response
=>
{
console
.
log
(
response
)
let
dataTable
=
response
.
data
.
data
.
map
((
item
,
index
)
=>
{
return
[
index
,
item
.
document_name
,
item
.
description
,
item
.
company_name
,
item
.
document_type
,
String
(
Number
(
item
.
document_size
)
/
1000
+
' KB'
),
item
.
created_by
,
item
.
created_at
,
]
})
this
.
setState
({
dataTable
})
let
docPath
=
response
.
data
.
data
.
map
((
item
)
=>
{
return
[
item
.
document_filepath
]
})
this
.
setState
({
docPath
})
})
}
openPopUp
=
async
(
index
,
val
,
type
)
=>
{
if
(
type
===
'download'
)
{
console
.
log
(
this
.
state
.
docPath
[
val
])
let
res
=
await
fetch
(
`
${
process
.
env
.
REACT_APP_URL_MAIN_BE
}
/public/document/download_document?documentName=`
+
this
.
state
.
docPath
[
val
]
+
"&&fileType="
+
index
[
5
]
)
res
=
await
res
.
blob
()
// console.log(res)
if
(
res
.
size
>
0
)
{
let
url
=
window
.
URL
.
createObjectURL
(
res
);
let
a
=
document
.
createElement
(
'a'
);
a
.
href
=
url
;
a
.
download
=
index
[
1
];
a
.
click
();
}
}
}
render
()
{
let
columns
=
[{
name
:
"Action"
,
options
:
{
filter
:
false
,
sort
:
false
,
customBodyRender
:
(
val
,
tableMeta
)
=>
{
console
.
log
(
tableMeta
)
return
(
<
div
style
=
{{
display
:
'flex'
}}
>
{
/* {this.state.btnedit && <span> */
}
<
a
data
-
tip
=
{
'Download'
}
data
-
for
=
"download"
>
<
button
style
=
{{
backgroundColor
:
'transparent'
,
cursor
:
'pointer'
,
borderColor
:
'transparent'
,
marginRight
:
15
}}
// onClick={() => console.log(tableMeta)}
onClick
=
{()
=>
this
.
openPopUp
(
tableMeta
.
rowData
,
val
,
'download'
)}
>
<
img
src
=
{
Images
.
download
}
/
>
<
/button
>
<
/a
>
<
ReactTooltip
border
=
{
true
}
id
=
"download"
place
=
"bottom"
type
=
"light"
effect
=
"solid"
/>
{
/* </span>} */
}
<
/div
>
);
}
}
},
"Nama File"
,
"Keterangan"
,
"Perusahaan"
,
"Tipe"
,
"Ukuran"
,
"Ditambahkan Oleh"
,
"Ditambahkan Tanggal"
]
return
(
<
div
style
=
{{
width
:
'100%'
}}
>
<
div
style
=
{{
padding
:
25
}}
>
<
MuiThemeProvider
theme
=
{
getMuiTheme
()}
>
<
MUIDataTable
theme
=
{
getMuiTheme
()}
data
=
{
this
.
state
.
dataTable
}
columns
=
{
columns
}
options
=
{
options
}
/
>
<
/MuiThemeProvider
>
<
/div
>
<
/div
>
)
}
}
src/container/DocumentManagement/ManualBookTia.js
deleted
100644 → 0
View file @
25105f54
import
React
,
{
Component
}
from
'react'
import
ReactTooltip
from
'react-tooltip'
;
import
{
createMuiTheme
,
MuiThemeProvider
,
Snackbar
}
from
'@material-ui/core'
;
import
{
withStyles
}
from
'@material-ui/core/styles'
;
import
MuiAlert
from
'@material-ui/lab/Alert'
;
import
MUIDataTable
from
'mui-datatables'
import
Constant
from
'../../library/Constant'
;
import
Images
from
'../../assets/Images'
;
import
EditManagementDoc
from
"./EditManagementDoc"
;
import
PopUpDelete
from
"./PopUpDelete"
;
import
api
from
'../../api'
;
var
ct
=
require
(
"../../library/CustomTable"
);
const
getMuiTheme
=
()
=>
createMuiTheme
(
ct
.
customTable
());
const
options
=
ct
.
customOptions
();
const
Alert
=
withStyles
({
})((
props
)
=>
<
MuiAlert
elevation
=
{
6
}
variant
=
"filled"
{...
props
}
/>
)
;
export
default
class
ManualBookTia
extends
Component
{
constructor
(
props
)
{
super
(
props
)
this
.
state
=
{
dataTable
:
[],
visibleCreate
:
false
,
visibleEdit
:
false
,
refresh
:
''
,
alert
:
false
,
popupDel
:
false
,
}
}
componentDidMount
()
{
// console.log(this.props.data)
this
.
getData
()
}
componentWillReceiveProps
(
props
)
{
// console.log(props);
const
{
refresh
,
id
}
=
this
.
props
;
if
(
props
.
refresh
!==
refresh
)
{
this
.
getData
()
}
}
getData
()
{
let
payload
=
{
"setting_id"
:
this
.
props
.
data
.
setting_id
}
api
.
create
().
getAllDocument
(
payload
).
then
(
response
=>
{
console
.
log
(
response
)
if
(
response
.
data
)
{
if
(
response
.
ok
)
{
if
(
response
.
data
.
status
==
'success'
)
{
let
dataTable
=
response
.
data
.
data
.
map
((
item
,
index
)
=>
{
return
[
index
,
item
.
document_name
,
item
.
description
,
item
.
company_name
,
item
.
document_periode
,
item
.
document_type
,
String
(
Number
(
item
.
document_size
)
/
1000
+
' KB'
),
item
.
created_by
,
item
.
created_at
,
]
})
this
.
setState
({
dataTable
})
let
docPath
=
response
.
data
.
data
.
map
((
item
)
=>
{
return
[
item
.
document_filepath
]
})
this
.
setState
({
docPath
})
let
docId
=
response
.
data
.
data
.
map
((
item
)
=>
{
return
[
item
.
document_id
]
})
this
.
setState
({
docId
})
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
data
.
message
,
tipeAlert
:
'warning'
,
loading
:
false
},
()
=>
{
if
(
response
.
data
.
message
.
includes
(
"Someone Logged In"
)
||
response
.
data
.
message
.
includes
(
"Token Expired"
))
{
setTimeout
(()
=>
{
localStorage
.
removeItem
(
Constant
.
TOKEN
)
window
.
location
.
reload
();
},
1000
);
}
})
}
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
data
.
message
,
tipeAlert
:
'error'
,
loading
:
false
})
}
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
problem
,
tipeAlert
:
'error'
,
loading
:
false
})
}
})
}
closeAlert
()
{
this
.
setState
({
alert
:
false
})
}
openPopUp
=
async
(
index
,
val
,
type
)
=>
{
if
(
type
===
'download'
)
{
let
res
=
await
fetch
(
`
${
process
.
env
.
REACT_APP_URL_MAIN_BE
}
/public/document/download_document?documentName=`
+
this
.
state
.
docPath
[
val
]
+
"&&fileType="
+
index
[
5
]
)
res
=
await
res
.
blob
()
// console.log(res)
if
(
res
.
size
>
0
)
{
let
url
=
window
.
URL
.
createObjectURL
(
res
);
let
a
=
document
.
createElement
(
'a'
);
a
.
href
=
url
;
a
.
download
=
index
[
1
];
a
.
click
();
}
}
if
(
type
===
'delete'
)
{
this
.
setState
({
id
:
this
.
state
.
docId
[
val
],
rowData
:
index
,
popupDel
:
true
})
}
if
(
type
===
'edit'
)
{
this
.
setState
({
id
:
this
.
state
.
docId
[
val
],
rowData
:
index
,
visibleEdit
:
true
})
}
}
deleteDoc
=
(
payload
)
=>
{
this
.
setState
({
popupDel
:
false
})
api
.
create
().
deleteDocument
(
payload
).
then
(
response
=>
{
console
.
log
(
response
.
data
)
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"
)
||
response
.
data
.
message
.
includes
(
"Token Expired"
))
{
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'
})
}
})
}
updateDocument
(
payload
)
{
api
.
create
().
updateDocument
(
payload
).
then
(
response
=>
{
console
.
log
(
response
)
if
(
response
.
data
)
{
if
(
response
.
ok
)
{
if
(
response
.
data
.
status
===
"success"
)
{
this
.
getData
()
this
.
setState
({
konfirmasi
:
false
,
alert
:
true
,
messageAlert
:
response
.
data
.
message
,
tipeAlert
:
'success'
,
visibleEdit
:
false
})
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
data
.
message
,
tipeAlert
:
'warning'
},
()
=>
{
if
(
response
.
data
.
message
.
includes
(
"Someone Logged In"
)
||
response
.
data
.
message
.
includes
(
"Token Expired"
))
{
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'
})
}
})
}
render
()
{
let
columns
=
[{
name
:
"Action"
,
options
:
{
filter
:
false
,
sort
:
false
,
customBodyRender
:
(
val
,
tableMeta
)
=>
{
// console.log(tableMeta)
return
(
<
div
style
=
{{
display
:
'flex'
}}
>
{
/* {this.state.btnedit && <span> */
}
<
a
data
-
tip
=
{
'Download'
}
data
-
for
=
"download"
>
<
button
style
=
{{
backgroundColor
:
'transparent'
,
cursor
:
'pointer'
,
borderColor
:
'transparent'
,
marginRight
:
15
}}
// onClick={() => console.log(tableMeta)}
onClick
=
{()
=>
this
.
openPopUp
(
tableMeta
.
rowData
,
val
,
'download'
)}
>
<
img
src
=
{
Images
.
download
}
style
=
{{
width
:
33
}}
/
>
<
/button
>
<
/a
>
<
ReactTooltip
border
=
{
true
}
id
=
"download"
place
=
"bottom"
type
=
"light"
effect
=
"solid"
/>
{
/* </span>} */
}
{
this
.
props
.
btnedit
&&
<
span
>
<
a
data
-
tip
=
{
'Edit'
}
data
-
for
=
"edit"
>
<
button
style
=
{{
backgroundColor
:
'transparent'
,
cursor
:
'pointer'
,
borderColor
:
'transparent'
,
marginRight
:
15
}}
// onClick={() => console.log(tableMeta)}
onClick
=
{()
=>
this
.
openPopUp
(
tableMeta
.
rowData
,
val
,
'edit'
)}
>
<
img
src
=
{
Images
.
editCopy
}
/
>
<
/button
>
<
/a
>
<
ReactTooltip
border
=
{
true
}
id
=
"edit"
place
=
"bottom"
type
=
"light"
effect
=
"solid"
/>
<
/span>
}
{
this
.
props
.
btndelete
&&
<
span
>
<
a
data
-
tip
=
{
'Delete'
}
data
-
for
=
"delete"
>
<
button
style
=
{{
backgroundColor
:
'transparent'
,
cursor
:
'pointer'
,
borderColor
:
'transparent'
,
}}
// onClick={() => console.log(tableMeta)}
onClick
=
{()
=>
this
.
openPopUp
(
tableMeta
.
rowData
,
val
,
'delete'
)}
>
<
img
src
=
{
Images
.
delete
}
/
>
<
/button
>
<
/a
>
<
ReactTooltip
border
=
{
true
}
id
=
"delete"
place
=
"bottom"
type
=
"light"
effect
=
"solid"
/>
<
/span>
}
<
/div
>
);
}
}
},
"File Name"
,
"Description"
,
"Company Name"
,
"Type"
,
"File Size"
,
"Created By"
,
"Created Date"
]
return
(
<
div
style
=
{{
width
:
'100%'
}}
>
<
div
style
=
{{
padding
:
25
}}
>
<
Snackbar
open
=
{
this
.
state
.
alert
}
autoHideDuration
=
{
6000
}
onClose
=
{()
=>
this
.
closeAlert
()}
>
<
Alert
onClose
=
{()
=>
this
.
closeAlert
()}
severity
=
{
this
.
state
.
tipeAlert
}
>
{
this
.
state
.
messageAlert
}
<
/Alert
>
<
/Snackbar
>
<
MuiThemeProvider
theme
=
{
getMuiTheme
()}
>
<
MUIDataTable
theme
=
{
getMuiTheme
()}
data
=
{
this
.
state
.
dataTable
}
columns
=
{
columns
}
options
=
{
options
}
/
>
<
/MuiThemeProvider
>
<
/div
>
{
this
.
state
.
popupDel
&&
(
<
PopUpDelete
type
=
{
"delete"
}
onClickClose
=
{()
=>
this
.
setState
({
popupDel
:
false
})}
data
=
{
this
.
state
.
rowData
}
idoc
=
{
this
.
state
.
id
}
// getList={() => this.getData.bind(this)}
deleteDoc
=
{
this
.
deleteDoc
.
bind
(
this
)}
/
>
)}
{
this
.
state
.
visibleEdit
&&
(
<
EditManagementDoc
type
=
{
"edit"
}
onClickClose
=
{()
=>
this
.
setState
({
visibleEdit
:
false
})}
data
=
{
this
.
state
.
rowData
}
idoc
=
{
this
.
state
.
id
}
updateDocument
=
{
this
.
updateDocument
.
bind
(
this
)}
/
>
)}
<
/div
>
)
}
}
src/container/DocumentManagement/QReview.js
deleted
100644 → 0
View file @
25105f54
import
React
,
{
Component
}
from
'react'
import
MUIDataTable
from
'mui-datatables'
import
{
withStyles
}
from
'@material-ui/core/styles'
;
import
{
createMuiTheme
,
MuiThemeProvider
,
Snackbar
}
from
'@material-ui/core'
;
import
MuiAlert
from
'@material-ui/lab/Alert'
;
import
Constant
from
'../../library/Constant'
;
import
Images
from
'../../assets/Images'
;
import
ReactTooltip
from
'react-tooltip'
;
import
api
from
'../../api'
;
import
PopUpDelete
from
"./PopUpDelete"
;
import
CreateManagementDoc
from
'./CreateManagementDoc'
;
import
EditManagementDoc
from
'./EditManagementDoc'
;
var
ct
=
require
(
"../../library/CustomTable"
);
const
getMuiTheme
=
()
=>
createMuiTheme
(
ct
.
customTable
());
const
options
=
ct
.
customOptionsManagementDocument
();
const
Alert
=
withStyles
({
})((
props
)
=>
<
MuiAlert
elevation
=
{
6
}
variant
=
"filled"
{...
props
}
/>
)
;
export
default
class
QReview
extends
Component
{
constructor
(
props
)
{
super
(
props
)
this
.
state
=
{
dataTable
:
[],
visibleCreate
:
false
,
visibleEdit
:
false
,
refresh
:
''
,
alert
:
false
,
popupDel
:
false
,
}
}
componentDidMount
()
{
// console.log(this.props.data)
this
.
getData
()
}
componentWillReceiveProps
(
props
)
{
// console.log(props);
const
{
refresh
,
id
}
=
this
.
props
;
if
(
props
.
refresh
!==
refresh
)
{
this
.
getData
()
}
}
getData
()
{
let
payload
=
{
"setting_id"
:
this
.
props
.
data
.
setting_id
}
api
.
create
().
getAllDocument
(
payload
).
then
((
response
)
=>
{
console
.
log
(
response
)
if
(
response
.
data
)
{
if
(
response
.
ok
)
{
if
(
response
.
data
.
status
==
'success'
)
{
let
dataTable
=
response
.
data
.
data
.
map
((
item
,
index
)
=>
{
return
[
index
,
item
.
document_name
,
item
.
description
,
item
.
company_name
,
item
.
document_periode
,
item
.
document_type
,
String
(
Number
(
item
.
document_size
)
/
1000
+
' KB'
),
item
.
created_by
,
item
.
created_at
]
})
this
.
setState
({
dataTable
})
let
docPath
=
response
.
data
.
data
.
map
((
item
)
=>
{
return
[
item
.
document_filepath
]
})
this
.
setState
({
docPath
})
let
docId
=
response
.
data
.
data
.
map
((
item
)
=>
{
return
[
item
.
document_id
]
})
this
.
setState
({
docId
})
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
data
.
message
,
tipeAlert
:
'warning'
,
loading
:
false
},
()
=>
{
if
(
response
.
data
.
message
.
includes
(
"Someone Logged In"
)
||
response
.
data
.
message
.
includes
(
"Token Expired"
))
{
setTimeout
(()
=>
{
localStorage
.
removeItem
(
Constant
.
TOKEN
)
window
.
location
.
reload
();
},
1000
);
}
})
}
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
data
.
message
,
tipeAlert
:
'error'
,
loading
:
false
})
}
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
problem
,
tipeAlert
:
'error'
,
loading
:
false
})
}
})
}
openPopUp
=
async
(
index
,
val
,
type
)
=>
{
if
(
type
===
'download'
)
{
let
res
=
await
fetch
(
`
${
process
.
env
.
REACT_APP_URL_MAIN_BE
}
/public/document/download_document?documentName=`
+
this
.
state
.
docPath
[
val
]
+
"&&fileType="
+
index
[
5
]
)
res
=
await
res
.
blob
()
// console.log(res)
if
(
res
.
size
>
0
)
{
let
url
=
window
.
URL
.
createObjectURL
(
res
);
let
a
=
document
.
createElement
(
'a'
);
a
.
href
=
url
;
a
.
download
=
index
[
1
];
a
.
click
();
}
}
if
(
type
===
'delete'
)
{
this
.
setState
({
id
:
this
.
state
.
docId
[
val
],
rowData
:
index
,
popupDel
:
true
})
}
if
(
type
===
'edit'
)
{
this
.
setState
({
id
:
this
.
state
.
docId
[
val
],
rowData
:
index
,
visibleEdit
:
true
})
}
}
closeAlert
()
{
this
.
setState
({
alert
:
false
})
}
deleteDoc
=
(
payload
)
=>
{
this
.
setState
({
popupDel
:
false
})
api
.
create
().
deleteDocument
(
payload
).
then
(
response
=>
{
console
.
log
(
response
.
data
)
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"
)
||
response
.
data
.
message
.
includes
(
"Token Expired"
))
{
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'
})
}
})
}
updateDocument
(
payload
)
{
api
.
create
().
updateDocument
(
payload
).
then
(
response
=>
{
console
.
log
(
response
)
if
(
response
.
data
)
{
if
(
response
.
ok
)
{
if
(
response
.
data
.
status
===
"success"
)
{
this
.
getData
()
this
.
setState
({
konfirmasi
:
false
,
alert
:
true
,
messageAlert
:
response
.
data
.
message
,
tipeAlert
:
'success'
,
visibleEdit
:
false
})
}
else
{
this
.
setState
({
alert
:
true
,
messageAlert
:
response
.
data
.
message
,
tipeAlert
:
'warning'
},
()
=>
{
if
(
response
.
data
.
message
.
includes
(
"Someone Logged In"
)
||
response
.
data
.
message
.
includes
(
"Token Expired"
))
{
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'
})
}
})
}
render
()
{
let
columns
=
[{
name
:
"Action"
,
options
:
{
filter
:
false
,
sort
:
false
,
customBodyRender
:
(
val
,
tableMeta
)
=>
{
return
(
<
div
style
=
{{
display
:
'flex'
}}
>
<
a
data
-
tip
=
{
'Download'
}
data
-
for
=
"download"
>
<
button
style
=
{{
backgroundColor
:
'transparent'
,
cursor
:
'pointer'
,
borderColor
:
'transparent'
,
marginRight
:
15
}}
// onClick={() => console.log(tableMeta)}
onClick
=
{()
=>
this
.
openPopUp
(
tableMeta
.
rowData
,
val
,
'download'
)}
>
<
img
src
=
{
Images
.
download
}
/
>
<
/button
>
<
/a
>
<
ReactTooltip
border
=
{
true
}
id
=
"download"
place
=
"bottom"
type
=
"light"
effect
=
"solid"
/>
{
this
.
props
.
btnedit
&&
<
span
>
<
a
data
-
tip
=
{
'Edit'
}
data
-
for
=
"edit"
>
<
button
style
=
{{
backgroundColor
:
'transparent'
,
cursor
:
'pointer'
,
borderColor
:
'transparent'
,
marginRight
:
15
}}
// onClick={() => console.log(tableMeta)}
onClick
=
{()
=>
this
.
openPopUp
(
tableMeta
.
rowData
,
val
,
'edit'
)}
>
<
img
src
=
{
Images
.
editCopy
}
/
>
<
/button
>
<
/a
>
<
ReactTooltip
border
=
{
true
}
id
=
"edit"
place
=
"bottom"
type
=
"light"
effect
=
"solid"
/>
<
/span>
}
{
this
.
props
.
btndelete
&&
<
span
>
<
a
data
-
tip
=
{
'Delete'
}
data
-
for
=
"delete"
>
<
button
style
=
{{
backgroundColor
:
'transparent'
,
cursor
:
'pointer'
,
borderColor
:
'transparent'
,
}}
// onClick={() => console.log(tableMeta)}
onClick
=
{()
=>
this
.
openPopUp
(
tableMeta
.
rowData
,
val
,
'delete'
)}
>
<
img
src
=
{
Images
.
delete
}
/
>
<
/button
>
<
/a
>
<
ReactTooltip
border
=
{
true
}
id
=
"delete"
place
=
"bottom"
type
=
"light"
effect
=
"solid"
/>
<
/span>
}
<
/div
>
);
}
}
},
"File Name"
,
"Description"
,
"Company Name"
,
"Period"
,
"Type"
,
"File Size"
,
"Created By"
,
"Created Date"
]
return
(
<
div
style
=
{{
width
:
'100%'
}}
>
<
div
style
=
{{
padding
:
25
}}
>
<
Snackbar
open
=
{
this
.
state
.
alert
}
autoHideDuration
=
{
6000
}
onClose
=
{()
=>
this
.
closeAlert
()}
>
<
Alert
onClose
=
{()
=>
this
.
closeAlert
()}
severity
=
{
this
.
state
.
tipeAlert
}
>
{
this
.
state
.
messageAlert
}
<
/Alert
>
<
/Snackbar
>
<
MuiThemeProvider
theme
=
{
getMuiTheme
()}
>
<
MUIDataTable
theme
=
{
getMuiTheme
()}
data
=
{
this
.
state
.
dataTable
}
columns
=
{
columns
}
options
=
{
options
}
/
>
<
/MuiThemeProvider
>
<
/div
>
{
this
.
state
.
popupDel
&&
(
<
PopUpDelete
type
=
{
"delete"
}
onClickClose
=
{()
=>
this
.
setState
({
popupDel
:
false
})}
data
=
{
this
.
state
.
rowData
}
idoc
=
{
this
.
state
.
id
}
// getList={() => this.getData.bind(this)}
deleteDoc
=
{
this
.
deleteDoc
.
bind
(
this
)}
/
>
)}
{
this
.
state
.
visibleEdit
&&
(
<
EditManagementDoc
type
=
{
"edit"
}
onClickClose
=
{()
=>
this
.
setState
({
visibleEdit
:
false
})}
data
=
{
this
.
state
.
rowData
}
idoc
=
{
this
.
state
.
id
}
updateDocument
=
{
this
.
updateDocument
.
bind
(
this
)}
/
>
)}
<
/div
>
)
}
}
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