Commit 3e88701f authored by Dida Adams Arizona's avatar Dida Adams Arizona

Merge branch 'GGMAC' into 'master'

apdet

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