Commit 41fcce8c authored by faisalhamdi's avatar faisalhamdi

Merge branch 'master' of http://103.44.149.204/d.arizona/tia-dev into faisal

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