Commit 23aff7bd authored by Deni Rinaldi's avatar Deni Rinaldi

mandoc

parent b90c9b5c
...@@ -176,7 +176,7 @@ const create = (baseURL = 'https://tia.eksad.com/tia-reporting-dev/public/') => ...@@ -176,7 +176,7 @@ const create = (baseURL = 'https://tia.eksad.com/tia-reporting-dev/public/') =>
const uploadFoto = (body) => api.post('attachment/upload_foto', body) const uploadFoto = (body) => api.post('attachment/upload_foto', body)
// MANAGEMENT DOCUMENT // MANAGEMENT DOCUMENT
const getDocumentCategory = () => api.get('document_category/get_all_document_category') 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)
......
...@@ -14,23 +14,32 @@ export default class AuditTahunan extends Component { ...@@ -14,23 +14,32 @@ export default class AuditTahunan extends Component {
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": 1
} }
api.create().getAllDocument(payload).then(respone => { api.create().getAllDocument(payload).then(response => {
let dataTable = respone.data.data.map(item => { console.log(response)
let dataTable = response.data.data.map(item => {
return [ return [
item.document_name, item.document_name,
item.description, item.description,
......
...@@ -83,15 +83,21 @@ export default class CreateManagementDoc extends Component { ...@@ -83,15 +83,21 @@ export default class CreateManagementDoc extends Component {
} }
getDataDocument() { getDataDocument() {
api.create().getDocumentCategory().then(response => { let payload = {
"setting_group_id": 7,
"setting_type_id": 167,
"company_id": 0
}
api.create().getDocumentCategory(payload).then(response => {
console.log(response); console.log(response);
if (response.data) { if (response.data) {
if (response.data.status == 'success') { if (response.data.status == 'success') {
let data = response.data.data let data = response.data.data
let typeData = data.map((item) => { let typeData = data.map((item) => {
return { return {
document_category_id: item.document_category_id, document_category_id: item.setting_id,
document_category_name: item.document_category_name document_category_name: item.value
} }
}) })
let typeProps = { let typeProps = {
...@@ -173,7 +179,7 @@ export default class CreateManagementDoc extends Component { ...@@ -173,7 +179,7 @@ export default class CreateManagementDoc extends Component {
const formData = new FormData(); const formData = new FormData();
formData.append("file", this.state.file); formData.append("file", this.state.file);
formData.append("companyId", this.state.getPerusahaan.company_id); formData.append("companyId", this.state.getPerusahaan.company_id);
formData.append("documentCategoryId", this.state.getDocument.document_category_id); formData.append("settingId", this.state.getDocument.document_category_id);
formData.append("documentPeriode", this.state.periode.periode); formData.append("documentPeriode", this.state.periode.periode);
formData.append("description", this.state.description); formData.append("description", this.state.description);
formData.append("extension", this.state.fileType); formData.append("extension", this.state.fileType);
...@@ -186,6 +192,12 @@ export default class CreateManagementDoc extends Component { ...@@ -186,6 +192,12 @@ 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.status === "success") {
this.props.getDataDocument(this.props.setting_id)
this.props.onClickClose()
}
}
}) })
} }
......
...@@ -20,21 +20,37 @@ export default class DocumentManagement extends Component { ...@@ -20,21 +20,37 @@ 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() {
this.getDataDocument() this.getDataDocument()
} }
getDataDocument() { getDataDocument(id) {
api.create().getDocumentCategory().then(response => { let payload = {
"setting_group_id": 7,
"setting_type_id": 167,
"company_id": 0
}
api.create().getDocumentCategory(payload).then(response => {
console.log(response);
if (response) {
if (response.data.status === "success") {
this.setState({ this.setState({
listData: response.data.data, listData: response.data.data,
id: response.data.data[0].document_category_id, id: id === undefined ? response.data.data[0].setting_id : id,
loadTable: true loadTable: true,
refresh: id === undefined ? '' : 'create'
}) })
console.log(this.state.listData) // console.log(this.state.listData)
} else {
}
} else {
}
}) })
} }
...@@ -54,7 +70,7 @@ export default class DocumentManagement extends Component { ...@@ -54,7 +70,7 @@ export default class DocumentManagement extends Component {
<div style={{ display: 'grid', justifyContent: 'flex-end' }}> <div style={{ display: 'grid', justifyContent: 'flex-end' }}>
<button <button
type="button" type="button"
onClick={() => this.setState({ visibleCreate: true })} onClick={() => this.setState({ visibleCreate: true, refresh: '' })}
style={{ marginRight: 25 }} style={{ marginRight: 25 }}
> >
<div style={{ width: 150, height: 30, backgroundColor: '#354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}> <div style={{ width: 150, height: 30, backgroundColor: '#354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
...@@ -74,19 +90,20 @@ export default class DocumentManagement extends Component { ...@@ -74,19 +90,20 @@ export default class DocumentManagement extends Component {
{this.state.listData.map((item, index) => { {this.state.listData.map((item, index) => {
return ( return (
<Tab <Tab
onClick={() => this.setState({ id: item.document_category_id })} onClick={() => this.setState({ id: item.setting_id })}
label={item.document_category_name} label={item.value}
/> />
) )
})} })}
</Tabs> </Tabs>
{this.state.loadTable && ( {this.state.loadTable && (
this.state.id === 2 ? this.state.id === 68542 ?
<AuditTahunan <AuditTahunan
data={this.state.listData[this.state.tab]} data={this.state.listData[this.state.tab]}
refresh={this.state.refresh}
/> />
: :
this.state.id === 1 ? this.state.id === 68541 ?
<ManualBookTia /> <ManualBookTia />
: :
this.state.id === 3 ? this.state.id === 3 ?
...@@ -104,6 +121,8 @@ export default class DocumentManagement extends Component { ...@@ -104,6 +121,8 @@ export default class DocumentManagement extends Component {
{this.state.visibleCreate && ( {this.state.visibleCreate && (
<CreateManagementDoc <CreateManagementDoc
onClickClose={() => this.setState({ visibleCreate: false })} onClickClose={() => this.setState({ visibleCreate: false })}
getDataDocument={this.getDataDocument.bind(this)}
setting_id={this.state.id}
/> />
)} )}
</div> </div>
......
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