Commit ed4d3356 authored by d.arizona's avatar d.arizona

update last

parent 758245e9
...@@ -128,7 +128,7 @@ export default class CorporateAnnualTargetMR extends Component { ...@@ -128,7 +128,7 @@ export default class CorporateAnnualTargetMR extends Component {
checkStatus = false checkStatus = false
} }
this.setState({ viewOnly: !checkApprover && checkLastStatus && checkStatus && checkPrevRev}) this.setState({ viewOnly: !checkApprover && checkLastStatus && checkStatus && checkPrevRev })
} }
getParameterGroup() { getParameterGroup() {
...@@ -238,7 +238,7 @@ export default class CorporateAnnualTargetMR extends Component { ...@@ -238,7 +238,7 @@ export default class CorporateAnnualTargetMR extends Component {
]) ])
// let index = dataTable.findIndex((val) => val[5] == item.description) // let index = dataTable.findIndex((val) => val[5] == item.description)
console.log(index, length - 1) console.log(index, length - 1)
if (index == length -1 && item.parent_name == "LEARNING & GROWTH PERSPECTIVE") { if (index == length - 1 && item.parent_name == "LEARNING & GROWTH PERSPECTIVE") {
dataTable.push([ dataTable.push([
4, 4,
0, 0,
...@@ -705,9 +705,9 @@ export default class CorporateAnnualTargetMR extends Component { ...@@ -705,9 +705,9 @@ export default class CorporateAnnualTargetMR extends Component {
let target = item[12] == "" ? 0 : Number(item[12]) let target = item[12] == "" ? 0 : Number(item[12])
if (target < 0) { if (target < 0) {
if (actual >= target) { if (actual >= target) {
totalAch = ((target-actual) / target) + 1 totalAch = ((target - actual) / target) + 1
} else { } else {
totalAch = (target-actual) / target totalAch = (target - actual) / target
} }
} else if (target == 0) { } else if (target == 0) {
if (target <= actual) { if (target <= actual) {
...@@ -721,7 +721,7 @@ export default class CorporateAnnualTargetMR extends Component { ...@@ -721,7 +721,7 @@ export default class CorporateAnnualTargetMR extends Component {
} else { } else {
totalAch = 1 - (actual / target) totalAch = 1 - (actual / target)
} }
} }
} }
totalAch = String(totalAch) == 'NaN' || String(totalAch) == 'Infinity' || String(totalAch) == '-Infinity' ? 0 : totalAch totalAch = String(totalAch) == 'NaN' || String(totalAch) == 'Infinity' || String(totalAch) == '-Infinity' ? 0 : totalAch
totalAch = Number(totalAch) * 100 totalAch = Number(totalAch) * 100
...@@ -734,22 +734,30 @@ export default class CorporateAnnualTargetMR extends Component { ...@@ -734,22 +734,30 @@ export default class CorporateAnnualTargetMR extends Component {
let listParameterFilter = listParameter.filter((val) => val.setting_type == String(parameterMix).toLocaleUpperCase()) let listParameterFilter = listParameter.filter((val) => val.setting_type == String(parameterMix).toLocaleUpperCase())
let listParameterFilterCompany = listParameterFilter.filter((val) => val.company_id == this.props.company.company_id) let listParameterFilterCompany = listParameterFilter.filter((val) => val.company_id == this.props.company.company_id)
let totalScore = 0 let totalScore = 0
let achx100 = item[9] == '100%' && (item[8] == 'HIB' || item[8] == 'HIG')? Number(totalAch) / 100 > 1 ? 1 : Number(totalAch) / 100 : Number(totalAch) / 100 let achx100 = item[9] == '100%' && (item[8] == 'HIB' || item[8] == 'HIG') ? Number(totalAch) / 100 > 1 ? 1 : Number(totalAch) / 100 : Number(totalAch) / 100
// if (item[5] == "Max Quality drop from Bor-Barge") {
// console.log(listParameterFilter)
// console.log(listParameterFilterCompany)
// // console.log(Number(item.min_value))
// console.log(Number(item.max_value))
// }
if (listParameterFilterCompany.length == 0) { if (listParameterFilterCompany.length == 0) {
listParameterFilter.map((item, index) => { listParameterFilter.map((items, index) => {
if (Number(achx100) >= Number(item.min_value) && Number(achx100) <= Number(item.max_value)) { if (Number(achx100) >= Number(items.min_value) && Number(achx100) <= Number(items.max_value)) {
totalScore = Number(item.value) totalScore = Number(items.value)
} }
}) })
} else { } else {
listParameterFilterCompany.map((item, index) => { listParameterFilterCompany.map((items, index) => {
if (Number(achx100) >= Number(item.min_value) && Number(achx100) <= Number(item.max_value)) { if (Number(achx100) >= Number(items.min_value) && Number(achx100) <= Number(items.max_value)) {
totalScore = Number(item.value) totalScore = Number(items.value)
} }
}) })
} }
let totalScorez = Number(totalScore).toFixed(0) let totalScorez = Number(totalScore).toFixed(0)
// if (item[5] == "Max Quality drop from Bor-Barge") {
// console.log(totalScorez)
// }
//Score X Weight //Score X Weight
let totalSW = 0 let totalSW = 0
let handlePercent = '' let handlePercent = ''
...@@ -776,25 +784,25 @@ export default class CorporateAnnualTargetMR extends Component { ...@@ -776,25 +784,25 @@ export default class CorporateAnnualTargetMR extends Component {
// console.log(totalSW) // console.log(totalSW)
// console.log(total) // console.log(total)
return [ return [
item[0], item[0],
item[1], item[1],
item[2], item[2],
item[3], item[3],
item[4], item[4],
item[5], item[5],
item[6], item[6],
item[7], item[7],
item[8], item[8],
item[9], item[9],
item[10], item[10],
item[11], item[11],
item[12], item[12],
totalAch, totalAch,
totalScorez, totalScorez,
totalSW, totalSW,
item[16], item[16],
item[17], item[17],
item[18], item[18],
// item[19], // item[19],
// ] // ]
] ]
...@@ -802,7 +810,7 @@ export default class CorporateAnnualTargetMR extends Component { ...@@ -802,7 +810,7 @@ export default class CorporateAnnualTargetMR extends Component {
// console.log(totalWeight) // console.log(totalWeight)
// console.log(total) // console.log(total)
// console.log(datatable3); // console.log(datatable3);
let totalWeightz = Number(totalWeight) / 100 let totalWeightz = Number(totalWeight) / 100
let totalz = Number(Number(total).toFixed(2) / Number(totalWeightz)).toFixed(2) let totalz = Number(Number(total).toFixed(2) / Number(totalWeightz)).toFixed(2)
console.log(totalz) console.log(totalz)
let lastTotal = R.equals(totalz, NaN) ? 0.0 : totalz let lastTotal = R.equals(totalz, NaN) ? 0.0 : totalz
...@@ -812,7 +820,7 @@ export default class CorporateAnnualTargetMR extends Component { ...@@ -812,7 +820,7 @@ export default class CorporateAnnualTargetMR extends Component {
} else { } else {
lastTotal = totalz lastTotal = totalz
} }
console.log(Number(Number(total).toFixed(2) / Number(totalWeightz)).toFixed(2)) 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 listPerfomanceDefault = this.state.parameterPerfom.filter((val) => String(val.company_name).toLocaleLowerCase() == "default")
...@@ -835,6 +843,7 @@ export default class CorporateAnnualTargetMR extends Component { ...@@ -835,6 +843,7 @@ export default class CorporateAnnualTargetMR extends Component {
console.log(listPerfomanceDefault) console.log(listPerfomanceDefault)
console.log(perfomanceScore) console.log(perfomanceScore)
console.log(perfomanceScoreColor) console.log(perfomanceScoreColor)
console.log(datatable3)
// if (lastTotal >= 1.00 && lastTotal <= 2.00) { // if (lastTotal >= 1.00 && lastTotal <= 2.00) {
// perfomanceScore = 'K' // perfomanceScore = 'K'
// } else if (lastTotal >= 2.01 && lastTotal <= 2.75) { // } else if (lastTotal >= 2.01 && lastTotal <= 2.75) {
...@@ -851,10 +860,10 @@ export default class CorporateAnnualTargetMR extends Component { ...@@ -851,10 +860,10 @@ export default class CorporateAnnualTargetMR extends Component {
// perfomanceScore = 'IST' // perfomanceScore = 'IST'
// } // }
setTimeout(() => { setTimeout(() => {
this.setState({ totalScore: lastTotal, perfomanceScore, loading: false, perfomanceScoreColor}, () => { this.setState({ totalScore: lastTotal, perfomanceScore, loading: false, perfomanceScoreColor }, () => {
this.setState({loading: true}) this.setState({ loading: true })
setTimeout(() => { setTimeout(() => {
this.setState({loading: false}) this.setState({ loading: false })
}, 500); }, 500);
}) })
}, 500); }, 500);
...@@ -1288,9 +1297,9 @@ export default class CorporateAnnualTargetMR extends Component { ...@@ -1288,9 +1297,9 @@ export default class CorporateAnnualTargetMR extends Component {
let target = tableMeta.rowData[12] == "" ? 0 : Number(tableMeta.rowData[12]) let target = tableMeta.rowData[12] == "" ? 0 : Number(tableMeta.rowData[12])
if (target < 0) { if (target < 0) {
if (actual >= target) { if (actual >= target) {
total = ((target-actual) / target) + 1 total = ((target - actual) / target) + 1
} else { } else {
total = (target-actual) / target total = (target - actual) / target
} }
} else if (target == 0) { } else if (target == 0) {
if (target <= actual) { if (target <= actual) {
...@@ -1304,7 +1313,7 @@ export default class CorporateAnnualTargetMR extends Component { ...@@ -1304,7 +1313,7 @@ export default class CorporateAnnualTargetMR extends Component {
} else { } else {
total = 1 - (actual / target) total = 1 - (actual / target)
} }
} }
} }
total = String(total) == 'NaN' || String(total) == 'Infinity' || String(total) == '-Infinity' ? 0 : total total = String(total) == 'NaN' || String(total) == 'Infinity' || String(total) == '-Infinity' ? 0 : total
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(total) * 100 dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(total) * 100
...@@ -1333,12 +1342,12 @@ export default class CorporateAnnualTargetMR extends Component { ...@@ -1333,12 +1342,12 @@ export default class CorporateAnnualTargetMR extends Component {
} }
}) })
} }
if (Number(tableMeta.rowData[12]) > Number(0)){ if (Number(tableMeta.rowData[12]) == Number(0)) {
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(totalScore).toFixed(0)
return Number(totalScore).toFixed(0)
} else {
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(0).toFixed(0) dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(0).toFixed(0)
return Number(0).toFixed(0) return Number(0).toFixed(0)
} else {
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(totalScore).toFixed(0)
return Number(totalScore).toFixed(0)
} }
} }
...@@ -1351,13 +1360,13 @@ export default class CorporateAnnualTargetMR extends Component { ...@@ -1351,13 +1360,13 @@ export default class CorporateAnnualTargetMR extends Component {
// } // }
if (tableMeta.rowData[0] == 4) { if (tableMeta.rowData[0] == 4) {
let totalScore = 0 let totalScore = 0
dataTable2.map((item,index) => { dataTable2.map((item, index) => {
if(item[0] !== 4 && item[0] !== 1) { if (item[0] !== 4 && item[0] !== 1) {
totalScore += Number(item[15]) totalScore += Number(item[15])
} }
}) })
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(totalScore).toFixed(2) dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(totalScore).toFixed(2)
if (tableMeta.rowIndex == dataTable2.length -1) { if (tableMeta.rowIndex == dataTable2.length - 1) {
someXXX = Number(totalScore).toFixed(2) someXXX = Number(totalScore).toFixed(2)
console.log(someXXX) console.log(someXXX)
} }
...@@ -1379,7 +1388,7 @@ export default class CorporateAnnualTargetMR extends Component { ...@@ -1379,7 +1388,7 @@ export default class CorporateAnnualTargetMR extends Component {
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(total).toFixed(2) dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(total).toFixed(2)
return total return total
} }
} }
let columns = [ let columns = [
...@@ -1789,32 +1798,32 @@ export default class CorporateAnnualTargetMR extends Component { ...@@ -1789,32 +1798,32 @@ export default class CorporateAnnualTargetMR extends Component {
customBodyRender: (value, tableMeta) => { customBodyRender: (value, tableMeta) => {
return ( return (
<div style={{ width: 75 }}> <div style={{ width: 75 }}>
{tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2? {tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 ?
null : null :
tableMeta.rowData[0] === 4? tableMeta.rowData[0] === 4 ?
handleTotal(tableMeta) handleTotal(tableMeta)
:
this.state.get_for == 'view' ?
<NumberFormat
thousandSeparator={true}
style={{ color: "black", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
value={Number(value).toFixed(2)}
// disabled={this.props.isApprover ? true : ((this.props.lastStatus == 'SUBMIT' || this.props.lastStatus == 'REVISION') && this.props.prevRevision === false && (this.props.status === 'revision' || this.props.status === 'not-yet' || this.props.status === 'draft' || this.props.status === 'submitted') ? false : true)}
disabled={true}
decimalScale={2}
/>
: :
<NumberFormat this.state.get_for == 'view' ?
thousandSeparator={true} <NumberFormat
style={{ color: "black", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }} thousandSeparator={true}
type="text" style={{ color: "black", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
placeholder="" type="text"
value={handleTotal(tableMeta).toFixed(2)} placeholder=""
decimalScale={2} value={Number(value).toFixed(2)}
disabled={true} // disabled={this.props.isApprover ? true : ((this.props.lastStatus == 'SUBMIT' || this.props.lastStatus == 'REVISION') && this.props.prevRevision === false && (this.props.status === 'revision' || this.props.status === 'not-yet' || this.props.status === 'draft' || this.props.status === 'submitted') ? false : true)}
/> disabled={true}
decimalScale={2}
/>
:
<NumberFormat
thousandSeparator={true}
style={{ color: "black", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
value={handleTotal(tableMeta).toFixed(2)}
decimalScale={2}
disabled={true}
/>
} }
</div> </div>
) )
...@@ -1998,7 +2007,7 @@ export default class CorporateAnnualTargetMR extends Component { ...@@ -1998,7 +2007,7 @@ export default class CorporateAnnualTargetMR extends Component {
<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.perfomanceScoreColor, borderWidth: '0px 1px 1px 1px', padding: 5, minWidth: 200, display: 'flex', justifyContent: 'flex-end' }}>
{!this.state.loading && ( {!this.state.loading && (
<Typography style={{ fontSize: '11px', color: 'black', fontWeight: 'bold' }}>{this.state.perfomanceScore}</Typography> <Typography style={{ fontSize: '11px', color: 'black', fontWeight: 'bold' }}>{this.state.perfomanceScore}</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