Commit 10c8f0fc authored by d.arizona's avatar d.arizona

Merge branch 'master' of http://103.44.149.204/d.arizona/tia-dev into GGMAC

parents ac3e99dc 35ccdbc7
...@@ -4133,6 +4133,7 @@ export default class SubHolding extends Component { ...@@ -4133,6 +4133,7 @@ export default class SubHolding extends Component {
dataTable={this.state.dataTable} dataTable={this.state.dataTable}
periode={this.state.periode ? this.state.periode.periode : null} periode={this.state.periode ? this.state.periode.periode : null}
quarter={this.state.quarter.name} quarter={this.state.quarter.name}
company={this.state.company}
/> />
)} )}
</div> </div>
......
import { createMuiTheme, FormControlLabel, Input, MuiThemeProvider, TableCell, Typography } from '@material-ui/core' import { createMuiTheme, FormControlLabel, Input, MuiThemeProvider, TableCell, Typography } from '@material-ui/core'
import MUIDataTable from 'mui-datatables'; import MUIDataTable from 'mui-datatables';
import React, { Component } from 'react' import React, { Component } from 'react'
import api from '../../api'
import NumberFormat from 'react-number-format'; import NumberFormat from 'react-number-format';
import * as R from 'ramda' import * as R from 'ramda'
...@@ -38,13 +39,109 @@ export default class TableSubHolding extends Component { ...@@ -38,13 +39,109 @@ export default class TableSubHolding extends Component {
constructor(props) { constructor(props) {
super(props) super(props)
this.state = { this.state = {
perfomanceScoreColor: '#fff', performanceScoreColor: '#fff',
parameterScore: [], parameterScore: [],
totalScore: 0, totalScore: 0,
perfomanceScore: '' performanceScore: '',
parameterPerfom: [],
} }
} }
componentDidMount() {
if (this.props.type === 10 || this.props.type === 11) {
this.getParameterGroup()
this.getParameterGroupPerfom()
}
}
getParameterGroup() {
api.create().getParameterByGroupName({
"group_name": 'ACHIEVEMENT_KPI'
}).then((response) => {
console.log(response.data)
if (response.data) {
this.setState({ parameterScore: response.data.data })
}
})
}
getParameterGroupPerfom() {
api.create().getParameterByGroupName({
"group_name": "PERFORMANCE_KPI"
}).then((response) => {
console.log(response.data)
if (response.data) {
this.setState({ parameterPerfom: response.data.data }, () => {
this.handleTotalScore(this.props.dataTable)
})
}
})
}
handleTotalScore(dataTable2) {
// console.log(dataTable2);
this.setState({ loading: true }, () => {
let totalWeight = 0
let total = 0
let score = 0
let performanceScore = ''
dataTable2.map((item, index) => {
// console.log(item[6])
//total weight
if (item[0] !== 1 && item[0] !== 4) {
if (item[12] == '' || String(item[12]) == '0' || String(item[12]) == '0.0') {
totalWeight += Number(0)
} else {
totalWeight += Number(item[6])
}
}
if (item[0] !== 1 && item[0] !== 4) {
total += Number(item[15])
}
})
totalWeight = Number(totalWeight) / 100
// console.log(total);
// console.log(totalWeight);
score = Number(Number(total).toFixed(2) / Number(totalWeight)).toFixed(2)
let lastTotal = R.equals(score, NaN) ? 0.0 : score
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 performanceScoreColor = '#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(lastTotal) >= Number(item.min_value) && Number(lastTotal) <= Number(item.max_value)) {
// console.log('masuk')
performanceScore = item.description
performanceScoreColor = item.value
}
})
}
// console.log(performanceScoreColor)
// console.log(this.state.parameterPerfom)
// console.log(listPerfomanceDefault)
// console.log(performanceScore)
// console.log(performanceScoreColor)
setTimeout(() => {
this.setState({ totalScore: lastTotal, performanceScore, loading: false, performanceScoreColor }, () => {
this.setState({ loading: true })
setTimeout(() => {
this.setState({ loading: false })
}, 500);
})
}, 500);
})
}
render() { render() {
let dataTable2 = this.props.dataTable let dataTable2 = this.props.dataTable
const handleChangeBS = (value, tableMeta, type) => { const handleChangeBS = (value, tableMeta, type) => {
...@@ -25188,7 +25285,7 @@ export default class TableSubHolding extends Component { ...@@ -25188,7 +25285,7 @@ export default class TableSubHolding extends Component {
/> />
</MuiThemeProvider> </MuiThemeProvider>
</div> </div>
{this.props.type === 10 ? {this.props.type === 10 || this.props.type === 11 ?
<div style={{ paddingBottom: 15 }}> <div style={{ paddingBottom: 15 }}>
<div style={{ display: 'flex', justifyContent: 'space-between', maxWidth: '100%', paddingLeft: 15, paddingRight: 15, marginTop: 5 }}> <div style={{ display: 'flex', justifyContent: 'space-between', maxWidth: '100%', paddingLeft: 15, paddingRight: 15, marginTop: 5 }}>
<div> <div>
...@@ -25216,8 +25313,8 @@ export default class TableSubHolding extends Component { ...@@ -25216,8 +25313,8 @@ export default class TableSubHolding extends Component {
<div style={{ padding: 5 }}> <div style={{ padding: 5 }}>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>PERFOMANCE</Typography> <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>PERFOMANCE</Typography>
</div> </div>
<div style={{ borderStyle: 'solid', backgroundColor: this.state.perfomanceScoreColor, borderWidth: '0px 1px 1px 1px', padding: 5, minWidth: 200, display: 'flex', justifyContent: 'flex-end' }}> <div style={{ borderStyle: 'solid', backgroundColor: this.state.performanceScoreColor, borderWidth: '0px 1px 1px 1px', padding: 5, minWidth: 200, display: 'flex', justifyContent: 'flex-end' }}>
<Typography style={{ fontSize: '11px', color: 'black', fontWeight: 'bold' }}>{this.state.perfomanceScore}</Typography> <Typography style={{ fontSize: '11px', color: 'black', fontWeight: 'bold' }}>{this.state.performanceScore}</Typography>
</div> </div>
</div> </div>
</div> </div>
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