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

++

parent 40113c65
......@@ -209,7 +209,8 @@ const create = (type = "") => {
const createOpetaingInd = (body) => api.post('transaction/operating_indicator/create_submission_report', 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 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
const downloadTemplate = (fileName, fileType) => api.get(`attachment/download_file?fileName=${fileName}&&fileType=${fileType}`)
......@@ -359,7 +360,8 @@ const create = (type = "") => {
submitMasterBudget,
checkIsSubmit,
getIdDeleteFromExcel,
getDashboard
getDashboard,
historyApproval
}
}
......
......@@ -49,7 +49,8 @@ export default class BudgetTahunan extends Component {
tipeAlert: '',
messageAlert: '',
submissionID: null,
isSubmit: false
isSubmit: false,
visibleTableHistory: false
}
this.fileHandler = this.fileHandler.bind(this);
}
......@@ -110,12 +111,12 @@ export default class BudgetTahunan extends Component {
if (response.data) {
if (response.ok) {
if (response.data.status === 'success') {
this.setState({ userCompany: response.data.data.company, isSubmit: false}, () => {
this.setState({ userCompany: response.data.data.company }, () => {
this.getCompanyActive()
})
})
}
}
}
}
})
}
......@@ -130,20 +131,20 @@ export default class BudgetTahunan extends Component {
company_name: item.company_name,
}
})
let arrayBaru = []
this.state.userCompany.map((item,index) => {
this.state.userCompany.map((item, index) => {
let indexID = companyData.findIndex((val) => val.company_id == item)
if (indexID !== -1) {
arrayBaru.push(companyData[indexID])
}
})
let defaultProps = {
options: arrayBaru,
getOptionLabel: (option) => titleCase(option.company_name),
};
this.setState({ listCompany: defaultProps, company: arrayBaru[0] }, () => {
this.getPeriode()
})
......@@ -226,8 +227,9 @@ export default class BudgetTahunan extends Component {
console.log(response)
if (response) {
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.historyApproval()
})
} else {
this.setState({ submissionID: null })
......@@ -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() {
let body = {
"submission_id": this.state.submissionID
}
api.create().checkIsSubmit(body).then(response => {
// console.log(response);
if (response.data) {
if (response.data.status === "success") {
this.setState({ isSubmit: true })
if (response.data.status === "Success") {
this.setState({ isSubmit: response.data.data.result })
}
}
})
......@@ -406,9 +430,15 @@ export default class BudgetTahunan extends Component {
let body = {
submission_id: this.state.submissionID
}
api.create().submitMasterBudget(body).then(response => {
console.log(response);
})
if (this.state.isSubmit === true) {
api.create().submitMasterBudget(body).then(response => {
if (response.data) {
if (response.data.status === "Success") {
this.getCompanyActive()
}
}
})
}
}
render() {
......@@ -500,6 +530,10 @@ export default class BudgetTahunan extends Component {
name: "",
options: { display: false }
}]
const columnsHistory = [
"Name", "Status", "Remarks", "Revision Item", "Date"
]
const options = {
filter: false,
sort: false,
......@@ -546,6 +580,7 @@ export default class BudgetTahunan extends Component {
{...this.state.listPeriode}
id="periode"
onChange={(event, newInputValue) => this.setState({ periode: newInputValue }, () => {
this.getRevision()
this.getReport()
this.getReportAttachment()
this.getSubmission()
......@@ -563,6 +598,7 @@ export default class BudgetTahunan extends Component {
{...this.state.listCompany}
id="company"
onChange={(event, newInputValue) => this.setState({ company: newInputValue }, () => {
this.getRevision()
this.getReport()
this.getReportAttachment()
this.getSubmission()
......@@ -648,16 +684,27 @@ export default class BudgetTahunan extends Component {
}
</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 style={{ borderTop: 'solid 1px #c4c4c4', padding: 10, backgroundColor: '#f5f5f5', width: '100%', display: 'flex', justifyContent: 'flex-end' }} >
<button
style={{
backgroundColor: 'transparent',
cursor: this.state.isSubmit ? 'pointer' : 'cursor',
cursor: this.state.isSubmit === true ? 'pointer' : 'cursor',
borderColor: 'transparent',
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' }}>
<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