Commit 259d8c8a authored by Deni Rinaldi's avatar Deni Rinaldi

Merge branch 'rifka' into 'master'

update all menu managdoc

See merge request !287
parents f639c475 85241424
...@@ -179,6 +179,7 @@ const create = (baseURL = 'https://tia.eksad.com/tia-reporting-dev/public/') => ...@@ -179,6 +179,7 @@ const create = (baseURL = 'https://tia.eksad.com/tia-reporting-dev/public/') =>
const getDocumentCategory = (body) => api.post('setting/get_all_setting_document_category', body) const getDocumentCategory = (body) => api.post('setting/get_all_setting_document_category', body)
const getAllDocument = (body) => api.post('document/get_all_document', body) const getAllDocument = (body) => api.post('document/get_all_document', body)
const uploadDocument = (body) => api.post('document/upload_document', body) const uploadDocument = (body) => api.post('document/upload_document', body)
const updateDocument = (body) => api.post('document/update_document', body)
// ------ // ------
// STEP 3 // STEP 3
...@@ -286,6 +287,7 @@ const create = (baseURL = 'https://tia.eksad.com/tia-reporting-dev/public/') => ...@@ -286,6 +287,7 @@ const create = (baseURL = 'https://tia.eksad.com/tia-reporting-dev/public/') =>
getDocumentCategory, getDocumentCategory,
getAllDocument, getAllDocument,
uploadDocument, uploadDocument,
updateDocument,
createSubmitReport, createSubmitReport,
getSubmission getSubmission
} }
......
...@@ -44,7 +44,7 @@ export default class AuditTahunan extends Component { ...@@ -44,7 +44,7 @@ export default class AuditTahunan extends Component {
item.document_name, item.document_name,
item.description, item.description,
item.company_name, item.company_name,
"", item.document_periode,
item.document_type, item.document_type,
String(Number(item.document_size) / 1000 + ' MB'), String(Number(item.document_size) / 1000 + ' MB'),
item.created_by, item.created_by,
......
...@@ -9,40 +9,58 @@ var ct = require("../../library/CustomTable"); ...@@ -9,40 +9,58 @@ var ct = require("../../library/CustomTable");
const getMuiTheme = () => createMuiTheme(ct.customTable()); const getMuiTheme = () => createMuiTheme(ct.customTable());
const options = ct.customOptionsManagementDocument(); const options = ct.customOptionsManagementDocument();
export default class AuditTahunan extends Component { export default class BOD extends Component {
constructor(props) { constructor(props) {
super(props) super(props)
this.state = { this.state = {
dataTable: [], dataTable: [],
visibleCreate: false visibleCreate: false,
refresh: ''
} }
} }
componentDidMount() { componentDidMount() {
console.log(this.props.data) // console.log(this.props.data)
this.getData() this.getData()
} }
componentWillReceiveProps(props) {
// console.log(props);
const { refresh, id } = this.props;
if (props.refresh !== refresh) {
this.getData()
}
}
getData() { getData() {
let payload = { let payload = {
"company_id": 1, "setting_id": this.props.data.setting_id
"document_category_id": 4
} }
api.create().getAllDocument(payload).then(respone => { api.create().getAllDocument(payload).then((response) => {
let dataTable = respone.data.data.map(item => { console.log(response)
return [ if (response.problem){
item.document_name, alert(response.problem)
item.description, }
item.company_name, if (response.data) {
"", if (response.ok) {
item.document_type, if (response.data.status == 'success') {
String(Number(item.document_size) / 1000 + ' MB'), let dataTable = response.data.data.map(item => {
item.created_by, return [
item.created_at, item.document_name,
] item.description,
}) item.company_name,
this.setState({ dataTable }) item.document_periode,
item.document_type,
String(Number(item.document_size) / 1000 + ' MB'),
item.created_by,
item.created_at,
]
})
this.setState({ dataTable })
}
}
}
}) })
} }
......
...@@ -9,6 +9,7 @@ import UploadFile from "../../library/Upload"; ...@@ -9,6 +9,7 @@ import UploadFile from "../../library/Upload";
import { ExcelRenderer } from 'react-excel-renderer'; import { ExcelRenderer } from 'react-excel-renderer';
import * as R from 'ramda' import * as R from 'ramda'
import MuiAlert from '@material-ui/lab/Alert'; import MuiAlert from '@material-ui/lab/Alert';
import PopUpKonfirmasi from "./PopUpKonfirmasi";
const Alert = withStyles({ const Alert = withStyles({
})((props) => <MuiAlert elevation={6} variant="filled" {...props} />); })((props) => <MuiAlert elevation={6} variant="filled" {...props} />);
...@@ -36,7 +37,9 @@ export default class CreateManagementDoc extends Component { ...@@ -36,7 +37,9 @@ export default class CreateManagementDoc extends Component {
alert: false, alert: false,
tipeAlert: '', tipeAlert: '',
messageAlert: '', messageAlert: '',
fileType: '' fileType: '',
konfirmasi: false,
docId:''
} }
} }
...@@ -192,11 +195,72 @@ export default class CreateManagementDoc extends Component { ...@@ -192,11 +195,72 @@ export default class CreateManagementDoc extends Component {
createDocument(){ createDocument(){
api.create().uploadDocument(this.state.formData).then(response => { api.create().uploadDocument(this.state.formData).then(response => {
console.log(response) console.log(response)
if (response) { if (response.data) {
if (response.data.status === "success") { if (response.ok) {
this.props.getDataDocument(this.props.setting_id) if (response.data.message === "The Document Already Exists in The System, Do You Want to Overwrite It?") {
this.props.onClickClose() let docId = response.data.data
this.setState({ docId })
this.setState({ konfirmasi: true })
// console.log(this.state.docId)
}
else if (response.data.message === "Upload Document Success") {
this.props.getDataDocument(this.props.setting_id)
this.props.onClickClose()
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
}
else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Someone Logged In")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
})
}
createUploadDocument = (payload) => {
const docuID = Object.values(payload)
const formDatas = new FormData();
formDatas.append("file", this.state.file);
formDatas.append("companyId", this.state.getPerusahaan.company_id);
formDatas.append("settingId", this.state.getDocument.document_category_id);
formDatas.append("documentPeriode", this.state.periode.periode);
formDatas.append("description", this.state.description);
formDatas.append("extension", this.state.fileType);
formDatas.append("documentId", docuID[0]);
api.create().updateDocument(formDatas).then(response => {
console.log(response)
if (response.data) {
if (response.ok) {
if (response.data.status === "success") {
this.props.getDataDocument(this.props.setting_id)
this.props.onClickClose()
this.setState({ konfirmasi: false })
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Someone Logged In")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
} }
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
}) })
} }
...@@ -211,6 +275,7 @@ export default class CreateManagementDoc extends Component { ...@@ -211,6 +275,7 @@ export default class CreateManagementDoc extends Component {
render() { render() {
return ( return (
<div>
<div className="test app-popup-show"> <div className="test app-popup-show">
<Snackbar open={this.state.alert} autoHideDuration={6000} onClose={() => this.closeAlert()}> <Snackbar open={this.state.alert} autoHideDuration={6000} onClose={() => this.closeAlert()}>
<Alert onClose={() => this.closeAlert()} severity={this.state.tipeAlert}> <Alert onClose={() => this.closeAlert()} severity={this.state.tipeAlert}>
...@@ -364,6 +429,16 @@ export default class CreateManagementDoc extends Component { ...@@ -364,6 +429,16 @@ export default class CreateManagementDoc extends Component {
</div> </div>
</div> </div>
</div> </div>
{this.state.konfirmasi && (
<PopUpKonfirmasi
onClickClosePopUp={() => this.setState({ konfirmasi: false })}
data={this.state.docId}
// getList={() => this.getData.bind(this)}
// deleteAM={this.deleteAM.bind(this)}
uploadDocId={this.createUploadDocument.bind(this)}
/>
)}
</div>
) )
} }
} }
...@@ -7,6 +7,8 @@ import api from '../../api' ...@@ -7,6 +7,8 @@ import api from '../../api'
import AuditTahunan from './AuditTahunan' import AuditTahunan from './AuditTahunan'
import CreateManagementDoc from './CreateManagementDoc' import CreateManagementDoc from './CreateManagementDoc'
import QReview from './QReview' import QReview from './QReview'
import BOD from './BOD'
import ManualBookETMS from './ManualBookETMS'
export default class DocumentManagement extends Component { export default class DocumentManagement extends Component {
constructor(props) { constructor(props) {
...@@ -20,7 +22,7 @@ export default class DocumentManagement extends Component { ...@@ -20,7 +22,7 @@ export default class DocumentManagement extends Component {
selectTab = (event, newEvent) => { selectTab = (event, newEvent) => {
this.setState({ tab: newEvent }) this.setState({ tab: newEvent })
// console.log(this.state.tab) console.log(this.state.tab)
} }
componentDidMount() { componentDidMount() {
...@@ -44,7 +46,7 @@ export default class DocumentManagement extends Component { ...@@ -44,7 +46,7 @@ export default class DocumentManagement extends Component {
loadTable: true, loadTable: true,
refresh: id === undefined ? '' : 'create' refresh: id === undefined ? '' : 'create'
}) })
// console.log(this.state.listData) console.log(this.state.listData)
} else { } else {
} }
...@@ -102,16 +104,32 @@ export default class DocumentManagement extends Component { ...@@ -102,16 +104,32 @@ export default class DocumentManagement extends Component {
data={this.state.listData[this.state.tab]} data={this.state.listData[this.state.tab]}
refresh={this.state.refresh} refresh={this.state.refresh}
/> />
: :
this.state.id === 68541 ? this.state.id === 68541 ?
<ManualBookTia /> <ManualBookTia
: data={this.state.listData[this.state.tab]}
this.state.id === 68544 ? refresh={this.state.refresh}
<QReview />
data={this.state.listData[this.state.tab]} :
/> this.state.id === 68544 ?
: <QReview
<span>Test2</span> data={this.state.listData[this.state.tab]}
refresh={this.state.refresh}
/>
:
this.state.id === 68543 ?
<BOD
data={this.state.listData[this.state.tab]}
refresh={this.state.refresh}
/>
:
this.state.id === 68545 ?
<ManualBookETMS
data={this.state.listData[this.state.tab]}
refresh={this.state.refresh}
/>
:
<span>Test2</span>
)} )}
</div> </div>
......
import React, { Component } from 'react'
import MUIDataTable from 'mui-datatables'
import { createMuiTheme, MuiThemeProvider } from '@material-ui/core';
import api from '../../api';
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 => {
return [
item.document_name,
item.description,
item.company_name,
item.document_type,
String(Number(item.document_size) / 1000 + ' MB'),
item.created_by,
item.created_at,
]
})
this.setState({ dataTable })
})
}
render() {
let columns = [
"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>
)
}
}
import React, { Component } from 'react' import React, { Component } from 'react'
import MUIDataTable from 'mui-datatables' import MUIDataTable from 'mui-datatables'
import { createMuiTheme, MuiThemeProvider } from '@material-ui/core'; import { createMuiTheme, MuiThemeProvider } from '@material-ui/core';
import api from '../../api';
var ct = require("../../library/CustomTable"); var ct = require("../../library/CustomTable");
...@@ -11,10 +12,48 @@ export default class ManualBookTia extends Component { ...@@ -11,10 +12,48 @@ export default class ManualBookTia extends Component {
constructor(props) { constructor(props) {
super(props) super(props)
this.state = { this.state = {
dataTable: [] 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 => {
return [
item.document_name,
item.description,
item.company_name,
item.document_periode,
item.document_type,
String(Number(item.document_size) / 1000 + ' MB'),
item.created_by,
item.created_at,
]
})
this.setState({ dataTable })
})
}
render() { render() {
let columns = [ let columns = [
"Nama File", "Keterangan", "Perusahaan", "Tipe", "Ukuran", "Ditambahkan Oleh", "Ditambahkan Tanggal" "Nama File", "Keterangan", "Perusahaan", "Tipe", "Ukuran", "Ditambahkan Oleh", "Ditambahkan Tanggal"
......
import React, { Component } from 'react';
import Images from '../../assets/Images';
import { Typography } from '@material-ui/core';
import api from "../../api";
import Constant from '../../library/Constant';
export default class PopUpDeleteAM extends Component {
constructor(props) {
super(props)
this.state = {
id: '',
getApprovedBy: null,
getTypes: null,
}
}
componentDidMount() {
// if (this.props.type === 'delete') {
// this.getDetailAM()
// }
console.log(this.props.data)
}
// getDetailAM() {
// api.create().getDetailAM(this.props.data[1]).then(response => {
// console.log(response.data)
// if (response.data) {
// if (response.ok) {
// if (response.data.status === "success") {
// let data = response.data.data
// this.setState({
// id: data.approval_matrix_id,
// getTypes: data.approval_type_name,
// getApprovedBy: data.fullname
// })
// } else {
// this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
// if (response.data.message.includes("Someone Logged In")) {
// setTimeout(() => {
// localStorage.removeItem(Constant.TOKEN)
// window.location.reload();
// }, 1000);
// }
// })
// }
// } else {
// this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
// }
// } else {
// this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
// }
// })
// }
onClickUpload() {
let payload = this.props.data
this.props.uploadDocId(payload)
}
render() {
return (
<div className="test app-popup-show">
<div className="popup-content background-white border-radius" style={{ borderRadius: 8 }}>
<div style={{ display: 'flex', justifyContent: 'center', paddingTop: 20 }}>
<img src={Images.failed} />
</div>
<div style={{ display: 'grid', justifyContent: 'center', marginTop: 20, paddingBottom: 20 }}>
<span style={{ textAlign: 'center', fontSize: 14, fontWeight: 'bold', fontFamily: 'Nunito Sans, sans-serif' }}>
The Document Already Exists in The System, <br />
Do You Want to Overwrite It?
</span>
</div>
<div className="border-top grid grid-2x" style={{ height: 56, backgroundColor: '#f5f5f5', paddingLeft: 20, paddingRight: 20 }}>
<div className="column-1" style={{ alignSelf: 'center' }}>
<button
type="button"
onClick={() => this.props.onClickClosePopUp()}
>
<div style={{ width: 102, height: 30, border: 'solid 1px #354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
<span style={{ color: '#354960', fontSize: 11 }}>Cancel</span>
</div>
</button>
</div>
<div className="column-2" style={{ display: 'flex', justifyContent: 'flex-end', alignItems: 'center' }}>
<button
type="button"
onClick={()=> this.onClickUpload()}
>
<div style={{ width: 102, height: 30, backgroundColor: '#354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
<span style={{ color: '#fff', fontSize: 11 }}>Rewrite</span>
</div>
</button>
</div>
</div>
</div>
</div>
);
}
}
import React, { Component } from 'react' import React, { Component } from 'react'
import MUIDataTable from 'mui-datatables' import MUIDataTable from 'mui-datatables'
import { createMuiTheme, MuiThemeProvider } from '@material-ui/core'; import { withStyles } from '@material-ui/core/styles';
import { createMuiTheme, MuiThemeProvider, Snackbar } from '@material-ui/core';
import api from '../../api'; import api from '../../api';
import MuiAlert from '@material-ui/lab/Alert';
import Constant from '../../library/Constant';
import CreateManagementDoc from './CreateManagementDoc'; import CreateManagementDoc from './CreateManagementDoc';
...@@ -9,7 +12,10 @@ var ct = require("../../library/CustomTable"); ...@@ -9,7 +12,10 @@ var ct = require("../../library/CustomTable");
const getMuiTheme = () => createMuiTheme(ct.customTable()); const getMuiTheme = () => createMuiTheme(ct.customTable());
const options = ct.customOptionsManagementDocument(); const options = ct.customOptionsManagementDocument();
export default class AuditTahunan extends Component { const Alert = withStyles({
})((props) => <MuiAlert elevation={6} variant="filled" {...props} />);
export default class QReview extends Component {
constructor(props) { constructor(props) {
super(props) super(props)
this.state = { this.state = {
...@@ -37,24 +43,42 @@ export default class AuditTahunan extends Component { ...@@ -37,24 +43,42 @@ export default class AuditTahunan extends Component {
"setting_id": this.props.data.setting_id "setting_id": this.props.data.setting_id
} }
api.create().getAllDocument(payload).then(response => { api.create().getAllDocument(payload).then((response) => {
console.log(response) console.log(response)
if (response.problem){ if (response.problem){
alert(response.problem) alert(response.problem)
}
if (response.data) {
if (response.ok) {
if (response.data.status == 'success') {
let dataTable = response.data.data.map(item => {
return [
item.document_name,
item.description,
item.company_name,
item.document_periode,
item.document_type,
String(Number(item.document_size) / 1000 + ' MB'),
item.created_by,
item.created_at,
]
})
this.setState({ dataTable })
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
if (response.data.message.includes("Someone Logged In")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error', loading: false })
}
} else { } else {
let dataTable = response.data.data.map(item => { this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
return [
item.document_name,
item.description,
item.company_name,
"",
item.document_type,
String(Number(item.document_size) / 1000 + ' MB'),
item.created_by,
item.created_at,
]
})
this.setState({ dataTable })
} }
}) })
} }
...@@ -66,6 +90,11 @@ export default class AuditTahunan extends Component { ...@@ -66,6 +90,11 @@ export default class AuditTahunan extends Component {
return ( return (
<div style={{ width: '100%' }}> <div style={{ width: '100%' }}>
<div style={{ padding: 25 }}> <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()}> <MuiThemeProvider theme={getMuiTheme()}>
<MUIDataTable <MUIDataTable
theme={getMuiTheme()} theme={getMuiTheme()}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment