Commit 550e0882 authored by d.arizona's avatar d.arizona

lebih baik kita usai disini

parent 574b28ed
......@@ -78,7 +78,9 @@ export default class CorporateAnnualTarget extends Component {
buttonDraft: true,
updateBy: '',
handleTekTekTek: 0,
editable: false
editable: false,
dataCustomerPrs: [],
dataInternalBsn: []
}
this.fileHandler = this.fileHandler.bind(this);
......@@ -104,12 +106,35 @@ export default class CorporateAnnualTarget extends Component {
// console.log(JSON.stringify(payload))
api.create().getDetailReportMB(payload).then(response => {
let dataTable = []
let dataCustomerPrs = []
let dataInternalBsn = []
// console.log(response)
let res = response.data.data
const handlePushChild = (item) => {
let indexIDzz = dataTable.findIndex((val) => val[1] === item.id)
if (indexIDzz === -1) {
let parentTrue = item.parent_name == 'INTERNAL BUSINESS PROCESS PERSPECTIVE' || item.parent_name == 'CUSTOMER PERSPECTIVE'
if (item.parent_name == 'INTERNAL BUSINESS PROCESS PERSPECTIVE') {
if (item.type_report_id !== 4) {
dataInternalBsn.push({
id: item.id,
name: item.description,
check: false
})
}
}
if (item.parent_name == 'CUSTOMER PERSPECTIVE') {
if (item.type_report_id !== 4) {
dataCustomerPrs.push({
id: item.id,
name: item.description,
check: false
})
}
}
dataTable.push([
item.type_report_id,
item.id,
......@@ -192,7 +217,9 @@ export default class CorporateAnnualTarget extends Component {
}
}
})
this.setState({ dataTable, loading: false, dataReal: res, editable: true })
this.setState({ dataTable, loading: false, dataReal: res, editable: true, dataCustomerPrs, dataInternalBsn }, () => {
console.log(dataCustomerPrs)
})
})
}
......@@ -325,13 +352,37 @@ export default class CorporateAnnualTarget extends Component {
console.log(JSON.stringify(this.state.payload))
api.create().checkUploadMB(this.state.payload).then(response => {
// // console.log(JSON.stringify(this.state.payload));
// console.log(response)
console.log(response)
if (response.data) {
if (response.data.status === 'success') {
// this.setState({ visibleUpload: false, visibleCAT: false })
this.setState({ visibleUpload: false, visibleCAT: false })
let dataTable = response.data.data.map((item, index) => {
return [
let dataTable = []
let custoId = 0
let bisnsId = 0
let dataDelete = this.state.dataDelete
response.data.data.map((item, index) => {
if (item.item_report == 'CUSTOMER PERSPECTIVE') {
custoId = item.item_report_id
}
if (item.item_report == 'INTERNAL BUSINESS PROCESS PERSPECTIVE') {
bisnsId = item.item_report_id
}
if (item.type_report_id !== 4 && item.parent !== null && (item.parent == custoId || item.parent == bisnsId)) {
let indexCust = this.state.dataCustomerPrs.findIndex((val) => val.name == item.item_report)
let indexBisn = this.state.dataInternalBsn.findIndex((val) => val.name == item.item_report)
if (indexCust !== -1 && item.item_report_id == 0) {
dataDelete.push(this.state.dataCustomerPrs[indexCust].id)
}
if (indexBisn !== -1 && item.item_report_id == 0) {
dataDelete.push(this.state.dataInternalBsn[indexBisn].id)
}
}
dataTable.push([
item.type_report_id,
item.item_report_id,
item.parent,
......@@ -363,11 +414,11 @@ export default class CorporateAnnualTarget extends Component {
item.strategic,
item.pic,
item.error
]
])
})
// console.log(dataTable)
console.log(dataTable)
// console.log(this.state.buttonError)
this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: false, editable: true }, () => {
this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: false, editable: true, dataDelete }, () => {
this.state.dataTable.map(item => {
if (item[30].length > 0) {
// console.log('masuk')
......@@ -382,8 +433,9 @@ export default class CorporateAnnualTarget extends Component {
}
uploadCAT(type) {
// let dataDelete = this.state.dataDelete
// console.log(dataDelete)
let payload = { "item_report_id": this.state.dataDelete }
if (this.state.dataDelete.length > 0) {
api.create().deleteAllItemReport(payload).then((response) => {
this.functionUpload(type)
......@@ -436,7 +488,7 @@ export default class CorporateAnnualTarget extends Component {
"cat": data
}
// console.log(data);
// console.log(JSON.stringify(body))
console.log(JSON.stringify(body))
api.create('UPLOAD').uploadMasterBudget(body).then(response => {
// console.log(response);
if (response.data) {
......@@ -888,7 +940,7 @@ export default class CorporateAnnualTarget extends Component {
}
const handleTambah = (data, rowIndex) => {
// console.log(dataTable2)
console.log(dataTable2)
let newData = []
dataTable2.map((item, index) => {
newData.push(item)
......@@ -932,6 +984,7 @@ export default class CorporateAnnualTarget extends Component {
this.setState({ dataTable: dataTable2 }, () => {
setTimeout(() => {
this.setState({ loading: false })
console.log(dataTable2)
}, 500)
})
}
......
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