Commit 9b6e46eb authored by Deni Rinaldi's avatar Deni Rinaldi

++

parent 40113c65
...@@ -209,7 +209,8 @@ const create = (type = "") => { ...@@ -209,7 +209,8 @@ const create = (type = "") => {
const createOpetaingInd = (body) => api.post('transaction/operating_indicator/create_submission_report', body) const createOpetaingInd = (body) => api.post('transaction/operating_indicator/create_submission_report', body)
const checkUploadOperatingInd = (body) => api.post('transaction/operating_indicator/check_import', body) const checkUploadOperatingInd = (body) => api.post('transaction/operating_indicator/check_import', body)
const uploadOperatingInd = (body) => api.post('transaction/operating_indicator/import_operating_indicator', body) const uploadOperatingInd = (body) => api.post('transaction/operating_indicator/import_operating_indicator', body)
const getDashboard = (body) => api.get('transaction/master_budget/get_dashboard') const getDashboard = (body) => api.get('transaction/get_dashboard')
const historyApproval = (body) => api.post('transaction/master_budget/history_approval', body)
//Template //Template
const downloadTemplate = (fileName, fileType) => api.get(`attachment/download_file?fileName=${fileName}&&fileType=${fileType}`) const downloadTemplate = (fileName, fileType) => api.get(`attachment/download_file?fileName=${fileName}&&fileType=${fileType}`)
...@@ -359,7 +360,8 @@ const create = (type = "") => { ...@@ -359,7 +360,8 @@ const create = (type = "") => {
submitMasterBudget, submitMasterBudget,
checkIsSubmit, checkIsSubmit,
getIdDeleteFromExcel, getIdDeleteFromExcel,
getDashboard getDashboard,
historyApproval
} }
} }
......
...@@ -49,7 +49,8 @@ export default class BudgetTahunan extends Component { ...@@ -49,7 +49,8 @@ export default class BudgetTahunan extends Component {
tipeAlert: '', tipeAlert: '',
messageAlert: '', messageAlert: '',
submissionID: null, submissionID: null,
isSubmit: false isSubmit: false,
visibleTableHistory: false
} }
this.fileHandler = this.fileHandler.bind(this); this.fileHandler = this.fileHandler.bind(this);
} }
...@@ -110,12 +111,12 @@ export default class BudgetTahunan extends Component { ...@@ -110,12 +111,12 @@ export default class BudgetTahunan extends Component {
if (response.data) { if (response.data) {
if (response.ok) { if (response.ok) {
if (response.data.status === 'success') { if (response.data.status === 'success') {
this.setState({ userCompany: response.data.data.company, isSubmit: false}, () => { this.setState({ userCompany: response.data.data.company }, () => {
this.getCompanyActive() this.getCompanyActive()
}) })
} }
} }
} }
}) })
} }
...@@ -130,20 +131,20 @@ export default class BudgetTahunan extends Component { ...@@ -130,20 +131,20 @@ export default class BudgetTahunan extends Component {
company_name: item.company_name, company_name: item.company_name,
} }
}) })
let arrayBaru = [] let arrayBaru = []
this.state.userCompany.map((item,index) => { this.state.userCompany.map((item, index) => {
let indexID = companyData.findIndex((val) => val.company_id == item) let indexID = companyData.findIndex((val) => val.company_id == item)
if (indexID !== -1) { if (indexID !== -1) {
arrayBaru.push(companyData[indexID]) arrayBaru.push(companyData[indexID])
} }
}) })
let defaultProps = { let defaultProps = {
options: arrayBaru, options: arrayBaru,
getOptionLabel: (option) => titleCase(option.company_name), getOptionLabel: (option) => titleCase(option.company_name),
}; };
this.setState({ listCompany: defaultProps, company: arrayBaru[0] }, () => { this.setState({ listCompany: defaultProps, company: arrayBaru[0] }, () => {
this.getPeriode() this.getPeriode()
}) })
...@@ -226,8 +227,9 @@ export default class BudgetTahunan extends Component { ...@@ -226,8 +227,9 @@ export default class BudgetTahunan extends Component {
console.log(response) console.log(response)
if (response) { if (response) {
if (response.data.data) { if (response.data.data) {
this.setState({ submissionID: response.data.data.submission_id }, () => { this.setState({ submissionID: response.data.data.submission_id, isSubmit: false }, () => {
this.checkIsSubmit() this.checkIsSubmit()
this.historyApproval()
}) })
} else { } else {
this.setState({ submissionID: null }) this.setState({ submissionID: null })
...@@ -236,14 +238,36 @@ export default class BudgetTahunan extends Component { ...@@ -236,14 +238,36 @@ export default class BudgetTahunan extends Component {
}) })
} }
historyApproval() {
let body = {
"submission_id": this.state.submissionID
}
api.create().historyApproval(body).then(response => {
console.log(response);
if (response.data.data.length > 0) {
let dataTableHistory = response.data.data.map(item => {
return [
item.pic,
item.status_approval,
item.remarks,
item.item_revision,
item.history_approval_date
]
})
this.setState({ dataTableHistory, visibleTableHistory: true })
}
})
}
checkIsSubmit() { checkIsSubmit() {
let body = { let body = {
"submission_id": this.state.submissionID "submission_id": this.state.submissionID
} }
api.create().checkIsSubmit(body).then(response => { api.create().checkIsSubmit(body).then(response => {
// console.log(response);
if (response.data) { if (response.data) {
if (response.data.status === "success") { if (response.data.status === "Success") {
this.setState({ isSubmit: true }) this.setState({ isSubmit: response.data.data.result })
} }
} }
}) })
...@@ -406,9 +430,15 @@ export default class BudgetTahunan extends Component { ...@@ -406,9 +430,15 @@ export default class BudgetTahunan extends Component {
let body = { let body = {
submission_id: this.state.submissionID submission_id: this.state.submissionID
} }
api.create().submitMasterBudget(body).then(response => { if (this.state.isSubmit === true) {
console.log(response); api.create().submitMasterBudget(body).then(response => {
}) if (response.data) {
if (response.data.status === "Success") {
this.getCompanyActive()
}
}
})
}
} }
render() { render() {
...@@ -500,6 +530,10 @@ export default class BudgetTahunan extends Component { ...@@ -500,6 +530,10 @@ export default class BudgetTahunan extends Component {
name: "", name: "",
options: { display: false } options: { display: false }
}] }]
const columnsHistory = [
"Name", "Status", "Remarks", "Revision Item", "Date"
]
const options = { const options = {
filter: false, filter: false,
sort: false, sort: false,
...@@ -546,6 +580,7 @@ export default class BudgetTahunan extends Component { ...@@ -546,6 +580,7 @@ export default class BudgetTahunan extends Component {
{...this.state.listPeriode} {...this.state.listPeriode}
id="periode" id="periode"
onChange={(event, newInputValue) => this.setState({ periode: newInputValue }, () => { onChange={(event, newInputValue) => this.setState({ periode: newInputValue }, () => {
this.getRevision()
this.getReport() this.getReport()
this.getReportAttachment() this.getReportAttachment()
this.getSubmission() this.getSubmission()
...@@ -563,6 +598,7 @@ export default class BudgetTahunan extends Component { ...@@ -563,6 +598,7 @@ export default class BudgetTahunan extends Component {
{...this.state.listCompany} {...this.state.listCompany}
id="company" id="company"
onChange={(event, newInputValue) => this.setState({ company: newInputValue }, () => { onChange={(event, newInputValue) => this.setState({ company: newInputValue }, () => {
this.getRevision()
this.getReport() this.getReport()
this.getReportAttachment() this.getReportAttachment()
this.getSubmission() this.getSubmission()
...@@ -648,16 +684,27 @@ export default class BudgetTahunan extends Component { ...@@ -648,16 +684,27 @@ export default class BudgetTahunan extends Component {
} }
</div> </div>
</div> </div>
{this.state.visibleTableHistory && (
<div style={{ marginTop: 20 }}>
<MuiThemeProvider theme={getMuiTheme()}>
<MUIDataTable
data={this.state.dataTableHistory}
columns={columnsHistory}
options={options}
/>
</MuiThemeProvider>
</div>
)}
</div> </div>
<div style={{ borderTop: 'solid 1px #c4c4c4', padding: 10, backgroundColor: '#f5f5f5', width: '100%', display: 'flex', justifyContent: 'flex-end' }} > <div style={{ borderTop: 'solid 1px #c4c4c4', padding: 10, backgroundColor: '#f5f5f5', width: '100%', display: 'flex', justifyContent: 'flex-end' }} >
<button <button
style={{ style={{
backgroundColor: 'transparent', backgroundColor: 'transparent',
cursor: this.state.isSubmit ? 'pointer' : 'cursor', cursor: this.state.isSubmit === true ? 'pointer' : 'cursor',
borderColor: 'transparent', borderColor: 'transparent',
outline: 'none', outline: 'none',
}} }}
onClick={() => this.state.isSubmit ? this.validate() : null} onClick={() => this.state.isSubmit === true ? this.validate() : null}
> >
<div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}> <div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Submit</Typography> <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Submit</Typography>
......
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