Commit 3531f4d8 authored by d.arizona's avatar d.arizona

apdet

parent 5d67852a
......@@ -47,7 +47,8 @@ class HomePage extends Component {
company: [],
dataDashboardCAT: [],
loading2: false,
loading3: false
loading3: false,
parameterPerfom: []
}
}
......@@ -114,9 +115,7 @@ class HomePage extends Component {
let indexMonthMR = MR.findIndex((val) => val.value == yearNow)
this.setState({ listPeriodeMB: defaultPropsMB, periodeMB: MB[MB.length - 1], listPeriodeMR: defaultPropsMR, periodeMR: MR[indexMonthMR], listPeriodeCAT: defaultPropsMB, periodeCAT: MB[indexMonthMR] }, () => {
this.getListUserSubcoMB()
this.getListUserSubcoMR()
this.getDetailUser()
this.getParameterGroupPerfom()
})
}
......@@ -130,7 +129,28 @@ class HomePage extends Component {
let arrayChild = []
item.category.map((items, indexs) => {
if (this.state.company.includes(items.company_id)) {
arrayChild.push({ ...items, current_value: Number(items.current_value).toFixed(2), performanceColor: this.handleBackgroundPerform(Number(items.current_value)) })
let indexPerform = this.state.parameterPerfom.findIndex((val) => val.company_id == items.company_id)
let listPerfomanceDefault = []
if (indexPerform == -1) {
listPerfomanceDefault = this.state.parameterPerfom.filter((val) => String(val.company_name).toLocaleLowerCase() == "default")
} else {
listPerfomanceDefault = this.state.parameterPerfom.filter((val) => val.company_id == items.company_id)
}
let performanceScore = ''
let perfomanceScoreColor = '#fff'
if (listPerfomanceDefault.length > 0) {
listPerfomanceDefault.map((item, index) => {
// console.log(Number(lastTotal))
// console.log(Number(item.min_value))
// console.log(Number(item.max_value))
if (Number(items.current_value).toFixed(2) >= Number(item.min_value) && Number(items.current_value).toFixed(2) <= Number(item.max_value)) {
// console.log('masuk')
performanceScore = item.description
perfomanceScoreColor = item.value
}
})
}
arrayChild.push({ ...items, current_value: Number(items.current_value).toFixed(2), performanceColor: perfomanceScoreColor })
}
})
if (arrayChild.length > 0 && String(item.item_business).toLocaleLowerCase() != 'holding') {
......@@ -484,6 +504,27 @@ class HomePage extends Component {
return color
}
getParameterGroupPerfom() {
api.create().getParameterByGroupName({
"group_name": "PERFORMANCE_KPI"
}).then((response) => {
console.log(response.data)
if (response.data) {
this.setState({ parameterPerfom: response.data.data } , () => {
this.getListUserSubcoMB()
this.getListUserSubcoMR()
this.getDetailUser()
})
} else {
this.setState({ parameterPerfom: [] } , () => {
this.getListUserSubcoMB()
this.getListUserSubcoMR()
this.getDetailUser()
})
}
})
}
render() {
const getDataMonth = (item) => {
let months = item.months
......
......@@ -822,8 +822,13 @@ export default class CorporateAnnualTargetMR extends Component {
}
console.log(Number(Number(total).toFixed(2) / Number(totalWeightz)).toFixed(2))
let listPerfomanceDefault = this.state.parameterPerfom.filter((val) => String(val.company_name).toLocaleLowerCase() == "default")
let indexPerform = this.state.parameterPerfom.findIndex((val) => val.company_id == this.props.company.company_id)
let listPerfomanceDefault = []
if (indexPerform == -1) {
listPerfomanceDefault = this.state.parameterPerfom.filter((val) => String(val.company_name).toLocaleLowerCase() == "default")
} else {
listPerfomanceDefault = this.state.parameterPerfom.filter((val) => val.company_id == this.props.company.company_id)
}
let performanceScore = ''
let perfomanceScoreColor = '#fff'
if (listPerfomanceDefault.length > 0) {
......
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