Commit 89cc2e37 authored by Riri Novita's avatar Riri Novita

lagi

parent d32c3bee
...@@ -107,86 +107,100 @@ export default class ProfitLoss extends Component { ...@@ -107,86 +107,100 @@ export default class ProfitLoss extends Component {
let dataTable = [] let dataTable = []
this.setState({ visibleProfitLoss: true }) this.setState({ visibleProfitLoss: true })
if (response.data) { if (response.data) {
let res = response.data.data if (response.ok) {
const handlePushChild = (item) => { if (response.data.status === 'success') {
let indexIDzz = dataTable.findIndex((val) => val[1] === item.id) let res = response.data.data
if (indexIDzz === -1) { const handlePushChild = (item) => {
dataTable.push([ let indexIDzz = dataTable.findIndex((val) => val[1] === item.id)
item.type_report_id, if (indexIDzz === -1) {
item.id, dataTable.push([
item.parent, item.type_report_id,
item.formula, item.id,
item.level, item.parent,
item.description, item.formula,
item.profit_loss.notes === "" ? null : item.profit_loss.notes, item.level,
item.profit_loss.total_actual_before === null ? "0" : item.profit_loss.total_actual_before === "" ? "0" : item.profit_loss.total_actual_before, item.description,
item.profit_loss.january, item.profit_loss.notes === "" ? null : item.profit_loss.notes,
item.profit_loss.february, item.profit_loss.total_actual_before === null ? "0" : item.profit_loss.total_actual_before === "" ? "0" : item.profit_loss.total_actual_before,
item.profit_loss.march, item.profit_loss.january,
item.profit_loss.april, item.profit_loss.february,
item.profit_loss.may, item.profit_loss.march,
item.profit_loss.june, item.profit_loss.april,
item.profit_loss.july, item.profit_loss.may,
item.profit_loss.august, item.profit_loss.june,
item.profit_loss.september, item.profit_loss.july,
item.profit_loss.october, item.profit_loss.august,
item.profit_loss.november, item.profit_loss.september,
item.profit_loss.december, item.profit_loss.october,
item.profit_loss.total_current_year, item.profit_loss.november,
item.profit_loss.total_next_year, item.profit_loss.december,
item.profit_loss.total_more_year, item.profit_loss.total_current_year,
item.order item.profit_loss.total_next_year,
]) item.profit_loss.total_more_year,
} item.order
if (item.children !== null) { ])
if (item.children.length > 0) { }
item.children.map((items, indexs) => { if (item.children !== null) {
handlePushChild(items) if (item.children.length > 0) {
}) item.children.map((items, indexs) => {
handlePushChild(items)
})
}
}
} }
res.map((item, index) => {
dataTable.push([
item.type_report_id,
item.id,
item.parent,
item.formula,
item.level,
item.description,
item.profit_loss.notes === "" ? null : item.profit_loss.notes,
item.profit_loss.total_actual_before === null ? "0" : item.profit_loss.total_actual_before === "" ? "0" : item.profit_loss.total_actual_before,
item.profit_loss.january,
item.profit_loss.february,
item.profit_loss.march,
item.profit_loss.april,
item.profit_loss.may,
item.profit_loss.june,
item.profit_loss.july,
item.profit_loss.august,
item.profit_loss.september,
item.profit_loss.october,
item.profit_loss.november,
item.profit_loss.december,
item.profit_loss.total_current_year,
item.profit_loss.total_next_year,
item.profit_loss.total_more_year,
item.order
])
if (item.children !== null) {
if (item.children.length > 0) {
item.children.map((items, indexs) => {
handlePushChild(items)
})
}
}
})
// console.log(dataTable)
this.setState({ dataTable, loading: false, buttonError: true, editable: true }, () => {
})
} 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', loading: false })
} }
res.map((item, index) => {
dataTable.push([
item.type_report_id,
item.id,
item.parent,
item.formula,
item.level,
item.description,
item.profit_loss.notes === "" ? null : item.profit_loss.notes,
item.profit_loss.total_actual_before === null ? "0" : item.profit_loss.total_actual_before === "" ? "0" : item.profit_loss.total_actual_before,
item.profit_loss.january,
item.profit_loss.february,
item.profit_loss.march,
item.profit_loss.april,
item.profit_loss.may,
item.profit_loss.june,
item.profit_loss.july,
item.profit_loss.august,
item.profit_loss.september,
item.profit_loss.october,
item.profit_loss.november,
item.profit_loss.december,
item.profit_loss.total_current_year,
item.profit_loss.total_next_year,
item.profit_loss.total_more_year,
item.order
])
if (item.children !== null) {
if (item.children.length > 0) {
item.children.map((items, indexs) => {
handlePushChild(items)
})
}
}
})
// console.log(dataTable)
this.setState({ dataTable, loading: false, buttonError: true, editable: true }, () => {
// console.log(dataTable)
})
} else { } else {
this.setState({ dataTable, loading: false, buttonError: true, editable: true }) this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
} }
}) })
...@@ -423,10 +437,10 @@ export default class ProfitLoss extends Component { ...@@ -423,10 +437,10 @@ export default class ProfitLoss extends Component {
// alert(response.data.status) // alert(response.data.status)
} }
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error', loading: false })
} }
} else { } else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' }) this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
} }
}) })
} }
......
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