Commit 4a3d4a9d authored by Rifka Kurnia's avatar Rifka Kurnia

Merge branch 'rifka' into 'master'

push hierarki revisi di ro n olpa

See merge request !1556
parents dcea738a bc121dd0
...@@ -232,15 +232,19 @@ export default class OutlookPA extends Component { ...@@ -232,15 +232,19 @@ export default class OutlookPA extends Component {
// dataTable.push([ // dataTable.push([
// 5, "Corporate Annual Target", 0, "not-yet", 39, false, 0 // 5, "Corporate Annual Target", 0, "not-yet", 39, false, 0
// ]) // ])
let dataTableRevision = response.data.data.map((item, index) => { let dataTableRevision = []
return [ response.data.data.map((item, index) => {
if (item.report_name !== 'Cash Flow') {
dataTableRevision.push([
item.report_id, item.report_id,
item.report_name, item.report_name === 'CAT' ? 'Corporate Annual Target' : item.report_name,
"" "",
] item.number
])
}
}) })
console.log(dataTable); // console.log(dataTable);
this.setState({ dataTable, loading: false, dataTableRevision, dataForRevision: response.data.data }) this.setState({ dataTable, loading: false, dataTableRevision: dataTableRevision.sort((a, b) => a.number - b.number), dataForRevision: response.data.data })
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => { this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) { if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
...@@ -1527,6 +1531,9 @@ export default class OutlookPA extends Component { ...@@ -1527,6 +1531,9 @@ export default class OutlookPA extends Component {
) )
} }
} }
}, {
name: "",
options: { display: false }
} }
] ]
...@@ -1543,20 +1550,69 @@ export default class OutlookPA extends Component { ...@@ -1543,20 +1550,69 @@ export default class OutlookPA extends Component {
this.setState({ dataTableRevision, detailRevisiCheck }) this.setState({ dataTableRevision, detailRevisiCheck })
} }
// const handleCheckRevision = (value) => {
// let detailRevisiCheck = this.state.detailRevisiCheck
// let payload = {
// report_id: value[0],
// remarks: value[2]
// }
// let indexId = detailRevisiCheck.findIndex((val) => val.report_id == value[0])
// if (indexId == -1) {
// detailRevisiCheck.push(payload)
// } else {
// detailRevisiCheck.splice(indexId, 1)
// }
// this.setState({ detailRevisiCheck })
// // console.log(detailRevisiCheck)
// }
const handleCheckRevision = (value) => { const handleCheckRevision = (value) => {
let detailRevisiCheck = this.state.detailRevisiCheck let detailRevisiCheck = this.state.detailRevisiCheck
let payload = { let payload = {
report_id: value[0], report_id: value[0],
remarks: value[2] remarks: value[2],
number: value[3]
} }
let indexDataRevisi = this.state.dataTableRevision.findIndex((val) => val[3] == value[3])
let indexId = detailRevisiCheck.findIndex((val) => val.report_id == value[0]) let indexId = detailRevisiCheck.sort((a, b) => a.number - b.number).findIndex((val) => val.number == value[3])
// // console.log(indexId)
if (indexId == -1) { if (indexId == -1) {
this.state.dataTableRevision.map((item, index) => {
if (index > indexDataRevisi) {
let indexIds = detailRevisiCheck.findIndex((val) => val.number == item[3])
if (indexIds == -1) {
let payload2 = {
report_id: item[0],
remarks: item[2],
number: item[3]
}
detailRevisiCheck.push(payload2)
}
}
})
detailRevisiCheck.push(payload) detailRevisiCheck.push(payload)
} else { } else {
let x = 0
detailRevisiCheck.sort((a, b) => a.number - b.number).map((item, index) => {
if (item.number < value[3]) {
x += 1
}
})
if (x < 1) {
this.state.dataTableRevision.map((item, index) => {
if (index > indexDataRevisi) {
let indexIdz = detailRevisiCheck.findIndex((val) => val.number == item[3])
if (indexIdz !== -1) {
detailRevisiCheck.splice(indexIdz, 1)
}
}
})
detailRevisiCheck.splice(indexId, 1) detailRevisiCheck.splice(indexId, 1)
} }
this.setState({ detailRevisiCheck }) }
this.setState({ detailRevisiCheck: detailRevisiCheck.sort((a, b) => a.number - b.number) })
// console.log(detailRevisiCheck) // console.log(detailRevisiCheck)
} }
......
...@@ -275,15 +275,19 @@ export default class RollingOutlook extends Component { ...@@ -275,15 +275,19 @@ export default class RollingOutlook extends Component {
item.revision item.revision
] ]
}) })
let dataTableRevision = response.data.data.map((item, index) => { let dataTableRevision = []
return [ response.data.data.map((item, index) => {
if (item.report_name !== 'Cash Flow') {
dataTableRevision.push([
item.report_id, item.report_id,
item.report_name, item.report_name === 'CAT' ? 'Corporate Annual Target' : item.report_name,
"" "",
] item.number
])
}
}) })
// console.log(dataTable); // console.log(dataTable);
this.setState({ dataTable, loading: false, dataTableRevision, dataForRevision: response.data.data }) this.setState({ dataTable, loading: false, dataTableRevision: dataTableRevision.sort((a, b) => a.number - b.number), dataForRevision: response.data.data })
} }
} else { } else {
this.setState({ loading: false }) this.setState({ loading: false })
...@@ -1590,6 +1594,9 @@ export default class RollingOutlook extends Component { ...@@ -1590,6 +1594,9 @@ export default class RollingOutlook extends Component {
) )
} }
} }
}, {
name: "",
options: { display: false }
} }
] ]
...@@ -1610,16 +1617,48 @@ export default class RollingOutlook extends Component { ...@@ -1610,16 +1617,48 @@ export default class RollingOutlook extends Component {
let detailRevisiCheck = this.state.detailRevisiCheck let detailRevisiCheck = this.state.detailRevisiCheck
let payload = { let payload = {
report_id: value[0], report_id: value[0],
remarks: value[2] remarks: value[2],
number: value[3]
} }
let indexDataRevisi = this.state.dataTableRevision.findIndex((val) => val[3] == value[3])
let indexId = detailRevisiCheck.findIndex((val) => val.report_id == value[0]) let indexId = detailRevisiCheck.sort((a, b) => a.number - b.number).findIndex((val) => val.number == value[3])
// // console.log(indexId)
if (indexId == -1) { if (indexId == -1) {
this.state.dataTableRevision.map((item, index) => {
if (index > indexDataRevisi) {
let indexIds = detailRevisiCheck.findIndex((val) => val.number == item[3])
if (indexIds == -1) {
let payload2 = {
report_id: item[0],
remarks: item[2],
number: item[3]
}
detailRevisiCheck.push(payload2)
}
}
})
detailRevisiCheck.push(payload) detailRevisiCheck.push(payload)
} else { } else {
let x = 0
detailRevisiCheck.sort((a, b) => a.number - b.number).map((item, index) => {
if (item.number < value[3]) {
x += 1
}
})
if (x < 1) {
this.state.dataTableRevision.map((item, index) => {
if (index > indexDataRevisi) {
let indexIdz = detailRevisiCheck.findIndex((val) => val.number == item[3])
if (indexIdz !== -1) {
detailRevisiCheck.splice(indexIdz, 1)
}
}
})
detailRevisiCheck.splice(indexId, 1) detailRevisiCheck.splice(indexId, 1)
} }
this.setState({ detailRevisiCheck }) }
this.setState({ detailRevisiCheck: detailRevisiCheck.sort((a, b) => a.number - b.number) })
console.log(detailRevisiCheck) console.log(detailRevisiCheck)
} }
......
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