Commit b83e2c26 authored by Deni Rinaldi's avatar Deni Rinaldi

cat issue refresh

parent c1b792c8
......@@ -54,7 +54,7 @@ const theme = createMuiTheme({
export default class CorporateAnnualTargetMR extends Component {
constructor(props) {
super(props)
super(props)
this.state = {
dataTables: [],
loading: true,
......@@ -73,7 +73,7 @@ export default class CorporateAnnualTargetMR extends Component {
totalScore: 0,
perfomanceScore: '',
buttonError: true,
viewOnly : true
viewOnly: true
}
this.fileHandler = this.fileHandler.bind(this);
}
......@@ -88,7 +88,7 @@ export default class CorporateAnnualTargetMR extends Component {
}
handleGetFor(type) {
this.setState({get_for: type}, () => {
this.setState({ get_for: type }, () => {
this.getLatestUpdate()
this.getKPIType()
this.getMaxAch()
......@@ -105,32 +105,32 @@ export default class CorporateAnnualTargetMR extends Component {
} else {
checkApprover = false
}
if (this.props.lastStatus == 'SUBMIT' || this.props.lastStatus == 'REVISION') {
checkLastStatus = true
} else {
checkLastStatus = false
}
}
// else if (this.props.prevRevision) {
// viewOnly = false
// }
if (this.props.status === 'revision' || this.props.status === 'not-yet' || this.props.status === 'draft' || this.props.status === 'submitted') {
checkStatus = true
} else {
checkStatus = false
}
this.setState({viewOnly: !checkApprover && checkLastStatus && checkStatus})
this.setState({ viewOnly: !checkApprover && checkLastStatus && checkStatus })
}
getParameterGroup() {
api.create().getParameterByGroupName({
"group_name" : 'ACHIEVEMENT_KPI'
"group_name": 'ACHIEVEMENT_KPI'
}).then((response) => {
// console.log(response.data.data)
if (response.data) {
this.setState({parameterScore: response.data.data})
this.setState({ parameterScore: response.data.data })
}
})
}
......@@ -180,7 +180,7 @@ export default class CorporateAnnualTargetMR extends Component {
"months": this.props.month.month_id,
"get_for": this.state.get_for
}
api.create().getHierarkiMontlyReportCAT(payload).then(response => {
let dataTable = []
console.log(payload);
......@@ -192,7 +192,7 @@ export default class CorporateAnnualTargetMR extends Component {
let indexIDzz = dataTable.findIndex((val) => val[1] === item.id)
if (indexIDzz === -1) {
let parentTrue = item.parent_name == 'INTERNAL BUSINESS PROCESS PERSPECTIVE' || item.parent_name == 'CUSTOMER PERSPECTIVE'
let weight = String(item.corporate_annual_target.weight).substr(0,String(item.corporate_annual_target.weight).length-1)
let weight = String(item.corporate_annual_target.weight).substr(0, String(item.corporate_annual_target.weight).length - 1)
// console.log(weight)
dataTable.push([
item.type_report_id,
......@@ -201,7 +201,7 @@ export default class CorporateAnnualTargetMR extends Component {
item.formula,
item.level,
item.description,
item.corporate_annual_target.weight == ""? Number(0).toFixed(1) : Number(weight).toFixed(1),
item.corporate_annual_target.weight == "" ? Number(0).toFixed(1) : Number(weight).toFixed(1),
parentTrue ? item.corporate_annual_target.uom : item.uom,
parentTrue ? item.corporate_annual_target.jenis_kpi == "" ? null : item.corporate_annual_target.jenis_kpi : item.jenis_kpi == "" ? null : item.kpi_type,
// parentTrue ? item.corporate_annual_target.kpi_type == "" ? null : { value: item.corporate_annual_target.kpi_type } : item.kpi_type == "" ? null : { value: item.kpi_type },
......@@ -210,12 +210,12 @@ export default class CorporateAnnualTargetMR extends Component {
item.corporate_annual_target.formula_ytd == "" ? null : item.corporate_annual_target.formula_ytd,
// parentTrue ? item.corporate_annual_target.formula == "" ? null : { value: item.corporate_annual_target.formula } : item.formula_ytd == "" ? null : { value: item.formula_ytd },
item.corporate_annual_target.actual_monthly == "" ? item.corporate_annual_target.actual_monthly : String(item.corporate_annual_target.actual_monthly).indexOf(".") == -1 ? Number(item.corporate_annual_target.actual_monthly) : Number(item.corporate_annual_target.actual_monthly).toFixed(1),
item.corporate_annual_target.target_monthly === null ? "0" : item.corporate_annual_target.target_monthly,
item.corporate_annual_target.achivement_monthly === null ? "0" : item.corporate_annual_target.achivement_monthly,
item.corporate_annual_target.score === null ? "0" : item.corporate_annual_target.score,
item.corporate_annual_target.score_x_weight === null ? "0" : item.corporate_annual_target.score_x_weight,
item.corporate_annual_target.notes === null ? "" : item.corporate_annual_target.notes,
item.corporate_annual_target.actual_formula === null? [] : item.corporate_annual_target.actual_formula,
item.corporate_annual_target.target_monthly === null ? "0" : item.corporate_annual_target.target_monthly,
item.corporate_annual_target.achivement_monthly === null ? "0" : item.corporate_annual_target.achivement_monthly,
item.corporate_annual_target.score === null ? "0" : item.corporate_annual_target.score,
item.corporate_annual_target.score_x_weight === null ? "0" : item.corporate_annual_target.score_x_weight,
item.corporate_annual_target.notes === null ? "" : item.corporate_annual_target.notes,
item.corporate_annual_target.actual_formula === null ? [] : item.corporate_annual_target.actual_formula,
item.order
])
}
......@@ -235,7 +235,7 @@ export default class CorporateAnnualTargetMR extends Component {
item.formula,
item.level,
item.description,
item.weight == ''? Number(0).toFixed(1) : Number(Number(item.weight) * 100).toFixed(1),
item.weight == '' ? Number(0).toFixed(1) : Number(Number(item.weight) * 100).toFixed(1),
item.uom,
item.kpi_type == "" ? null : item.kpi_type,
// item.kpi_type == "" ? null : { value: item.kpi_type },
......@@ -244,12 +244,12 @@ export default class CorporateAnnualTargetMR extends Component {
item.corporate_annual_target.formula == "" ? null : item.corporate_annual_target.formula_ytd,
// item.formula == "" ? null : { value: item.formula_ytd },
item.corporate_annual_target.actual_monthly == "" ? item.corporate_annual_target.actual_monthly : String(item.corporate_annual_target.actual_monthly).indexOf(".") == -1 ? Number(item.corporate_annual_target.actual_monthly) : Number(item.corporate_annual_target.actual_monthly).toFixed(1),
item.corporate_annual_target.target_monthly === null ? "0" : item.corporate_annual_target.target_monthly,
item.corporate_annual_target.achivement_monthly === null ? "0" : item.corporate_annual_target.achivement_monthly,
item.corporate_annual_target.score === null ? "0" : item.corporate_annual_target.score,
item.corporate_annual_target.score_x_weight === null ? "0" : item.corporate_annual_target.score_x_weight,
item.corporate_annual_target.notes === null ? "" : item.corporate_annual_target.notes,
item.corporate_annual_target.actual_formula === null? [] : item.corporate_annual_target.actual_formula,
item.corporate_annual_target.target_monthly === null ? "0" : item.corporate_annual_target.target_monthly,
item.corporate_annual_target.achivement_monthly === null ? "0" : item.corporate_annual_target.achivement_monthly,
item.corporate_annual_target.score === null ? "0" : item.corporate_annual_target.score,
item.corporate_annual_target.score_x_weight === null ? "0" : item.corporate_annual_target.score_x_weight,
item.corporate_annual_target.notes === null ? "" : item.corporate_annual_target.notes,
item.corporate_annual_target.actual_formula === null ? [] : item.corporate_annual_target.actual_formula,
item.order
])
if (item.children !== null) {
......@@ -262,7 +262,7 @@ export default class CorporateAnnualTargetMR extends Component {
})
// console.log(dataTable);
this.setState({ dataTable, loading: false, saveDraft: true }, () => {
this.handleCalculate()
this.handleCalculate(dataTable)
})
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
......@@ -295,7 +295,7 @@ export default class CorporateAnnualTargetMR extends Component {
a.href = url;
a.download = 'Template Monthly Report Corporate Annual Target.xlsx'
a.click();
}
}
}
async downloadAllData() {
......@@ -353,9 +353,9 @@ export default class CorporateAnnualTargetMR extends Component {
}
});
}
checkUpload() {
this.setState({loading: true})
this.setState({ loading: true })
api.create().checkUploadMonthlyReportCAT(this.state.payload).then(response => {
// console.log(JSON.stringify(this.state.payload));
console.log(this.state.payload)
......@@ -382,7 +382,7 @@ export default class CorporateAnnualTargetMR extends Component {
item.score,
item.score_x_weight,
item.notes,
item.actual_formula === null? [] : item.actual_formula,
item.actual_formula === null ? [] : item.actual_formula,
item.order,
item.error
]
......@@ -557,7 +557,7 @@ export default class CorporateAnnualTargetMR extends Component {
"uom": i[7],
"jenis_kpi": i[8] == null ? "" : i[8],
"max_ach": i[9] == null ? "" : i[9],
"formula_ytd":i[10] == null ? "" : i[10],
"formula_ytd": i[10] == null ? "" : i[10],
"actual_monthly": i[11] == null || i[11] == "" ? 0.0 : i[11],
"target_monthly": i[12] == null || i[12] == "" ? 0.0 : i[12],
"achivement_monthly": i[13],
......@@ -565,7 +565,7 @@ export default class CorporateAnnualTargetMR extends Component {
"score_x_weight": i[15],
"notes": i[16]
})
})
})
let payload = {
"monthly_report_id": this.props.monthlyReportId,
"company_id": this.props.company.company_id,
......@@ -579,7 +579,7 @@ export default class CorporateAnnualTargetMR extends Component {
}
// console.log(JSON.stringify(payload));
console.log(payload);
api.create('UPLOAD').createMonthlyReportCAT(payload).then(response => {
console.log(response);
if (response.data) {
......@@ -595,59 +595,62 @@ export default class CorporateAnnualTargetMR extends Component {
// this.getSubmission()
document.body.style.overflow = 'unset';
})
}
})
}
})
}
closeAlert() {
this.setState({ alert: false })
}
handleCalculate(){
let total = 0
let perfomanceScore = ''
let dataTable2 = this.state.dataTable
// console.log(dataTable2)
dataTable2.map((item,index) => {
let value = String(item[15]) == 'NaN' || String(item[15]) == ''? 0 : Number(item[15])
total += value
handleCalculate(datatable) {
this.setState({ loading: false }, () => {
let total = 0
let perfomanceScore = ''
console.log(datatable)
datatable.map((item, index) => {
let value = String(item[15]) == 'NaN' || String(item[15]) == '' ? 0 : Number(item[15])
total += value
})
console.log(total);
total = Number(total).toFixed(2)
if (total >= 1.00 && total <= 2.00) {
perfomanceScore = 'K'
} else if (total >= 2.01 && total <= 2.75) {
perfomanceScore = 'C'
} else if (total >= 2.76 && total <= 3.00) {
perfomanceScore = 'B-'
} else if (total >= 3.01 && total <= 3.75) {
perfomanceScore = 'B'
} else if (total >= 3.76 && total <= 4.00) {
perfomanceScore = 'B+'
} else if (total >= 4.01 && total <= 4.75) {
perfomanceScore = 'BS'
} else if (total >= 4.76 && total <= 5.00) {
perfomanceScore = 'IST'
}
this.setState({ totalScore: total, perfomanceScore })
})
total = Number(total).toFixed(2)
if ( total >= 1.00 && total <= 2.00) {
perfomanceScore = 'K'
} else if ( total >= 2.01 && total <= 2.75) {
perfomanceScore = 'C'
} else if ( total >= 2.76 && total <= 3.00) {
perfomanceScore = 'B-'
} else if ( total >= 3.01 && total <= 3.75) {
perfomanceScore = 'B'
} else if ( total >= 3.76 && total <= 4.00) {
perfomanceScore = 'B+'
} else if ( total >= 4.01 && total <= 4.75) {
perfomanceScore = 'BS'
} else if ( total >= 4.76 && total <= 5.00) {
perfomanceScore = 'IST'
}
this.setState({totalScore: total, perfomanceScore, loading: false})
}
handleBackgroundPerf(total) {
console.log(total)
let color = 'white'
if ( total >= 1.00 && total <= 2.00) {
if (total >= 1.00 && total <= 2.00) {
color = 'red'
} else if ( total >= 2.01 && total <= 2.75) {
} else if (total >= 2.01 && total <= 2.75) {
color = 'yellow'
} else if ( total >= 2.76 && total <= 3.00) {
} else if (total >= 2.76 && total <= 3.00) {
color = 'lightgreen'
} else if ( total >= 3.01 && total <= 3.75) {
} else if (total >= 3.01 && total <= 3.75) {
color = 'yellowgreen'
} else if ( total >= 3.76 && total <= 4.00) {
} else if (total >= 3.76 && total <= 4.00) {
color = 'forestgreen'
} else if ( total >= 4.01 && total <= 4.75) {
} else if (total >= 4.01 && total <= 4.75) {
color = 'deepskyblue'
} else if ( total >= 4.76 && total <= 5.00) {
} else if (total >= 4.76 && total <= 5.00) {
color = 'dodgerblue'
}
return color
......@@ -691,37 +694,37 @@ export default class CorporateAnnualTargetMR extends Component {
anjay.push(item)
} else if (item == '' || item == '@') {
// } else if (item == "CurrMonth") {
// anjay.push(String(column))
// } else if (item.includes('[CM]SUM')) {
// let columnStart = 13
// let indexX = String(item).indexOf('[')
// let formulaAwal = String(item).substr(0, indexX)
// let columnEnd = 24
// let month = column - 1
// let total = 0
// // // // console.log(formulaAwal)
// if (forecast == undefined) {
// dataTable2[tableMeta.rowIndex].map((itemz, indexz) => {
// if (indexz >= columnStart && indexz <= columnStart + month) {
// let indexID = value.formula.findIndex((val) => val.item_formula == String(`@${formulaAwal}`) && val.periode == Number(this.props.periode))
// if (indexID !== -1) {
// let valuezz = Number(value.formula[indexID].value)
// total += valuezz
// }
// }
// })
// } else {
// } else if (item == "CurrMonth") {
// anjay.push(String(column))
// } else if (item.includes('[CM]SUM')) {
// let columnStart = 13
// let indexX = String(item).indexOf('[')
// let formulaAwal = String(item).substr(0, indexX)
// let columnEnd = 24
// let month = column - 1
// let total = 0
// // // // console.log(formulaAwal)
// if (forecast == undefined) {
// dataTable2[tableMeta.rowIndex].map((itemz, indexz) => {
// if (indexz >= columnStart && indexz <= columnStart + month) {
// let indexID = value.formula.findIndex((val) => val.item_formula == String(`@${formulaAwal}`) && val.periode == Number(this.props.periode))
// if (indexID !== -1) {
// let valuezz = Number(value.formula[indexID].value)
// total += valuezz
// }
// }
// })
// } else {
// }
// }
// anjay.push(String(total))
// } else if (item.includes('[CM]AVG')) {
// if (forecast == undefined) {
// anjay.push('/')
// anjay.push(column)
// }
}
// anjay.push(String(total))
// } else if (item.includes('[CM]AVG')) {
// if (forecast == undefined) {
// anjay.push('/')
// anjay.push(column)
// }
}
else if (item.includes('X')) {
let indexX = String(item).indexOf('X')
if (indexX == 0) {
......@@ -925,37 +928,37 @@ export default class CorporateAnnualTargetMR extends Component {
return false
} else {
// if ((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')) {
if (idParent !== null) {
// console.log(tableMeta)
let indexsss = dataTable2.findIndex((val) => val[1] == idParent)
if (dataTable2[indexsss][5] == 'CUSTOMER PERSPECTIVE' || dataTable2[indexsss][5] == 'INTERNAL BUSINESS PROCESS PERSPECTIVE') {
return true
} else {
if (typeReport == 3) {
return true
} else {
return false
}
}
if (idParent !== null) {
// console.log(tableMeta)
let indexsss = dataTable2.findIndex((val) => val[1] == idParent)
if (dataTable2[indexsss][5] == 'CUSTOMER PERSPECTIVE' || dataTable2[indexsss][5] == 'INTERNAL BUSINESS PROCESS PERSPECTIVE') {
return true
} else {
if (typeReport == null || typeReport == 3) {
if (typeReport == 3) {
return true
} else if (tableMeta !== undefined && tableMeta.rowData[0] == 1) {
let indexID = dataTable2.findIndex((val) => val[2] == tableMeta.rowData[1])
if (indexID !== -1) {
return false
} else {
return true
}
} else {
return false
}
}
} else {
if (typeReport == null || typeReport == 3) {
return true
} else if (tableMeta !== undefined && tableMeta.rowData[0] == 1) {
let indexID = dataTable2.findIndex((val) => val[2] == tableMeta.rowData[1])
if (indexID !== -1) {
return false
} else {
return true
}
} else {
return false
}
}
// } else {
// return false
// }
}
}
const handleTambah = (data, rowIndex) => {
......@@ -967,7 +970,7 @@ export default class CorporateAnnualTargetMR extends Component {
newData.push([
null,
"",
item[2] == null || item[2] == ""? item[1] : item[2],
item[2] == null || item[2] == "" ? item[1] : item[2],
item[3],
item[4],
"",
......@@ -1023,42 +1026,42 @@ export default class CorporateAnnualTargetMR extends Component {
const handleAchiement = (tableMeta) => {
let total = 0
if (tableMeta.rowData[8] == 'HIB') {
let actual = tableMeta.rowData[11] == ""? 0 : Number(tableMeta.rowData[11])
let target = tableMeta.rowData[12] == ""? 0 : Number(tableMeta.rowData[12])
let actual = tableMeta.rowData[11] == "" ? 0 : Number(tableMeta.rowData[11])
let target = tableMeta.rowData[12] == "" ? 0 : Number(tableMeta.rowData[12])
total = 2 - (actual / target)
} else {
let actual = tableMeta.rowData[11] == ""? 0 : Number(tableMeta.rowData[11])
let target = tableMeta.rowData[12] == ""? 0 : Number(tableMeta.rowData[12])
total = actual/target
let actual = tableMeta.rowData[11] == "" ? 0 : Number(tableMeta.rowData[11])
let target = tableMeta.rowData[12] == "" ? 0 : Number(tableMeta.rowData[12])
total = actual / target
}
total = String(total) == 'NaN' || String(total) == 'Infinity' || String(total) == '-Infinity' ? 0 : total
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(total) * 100
return Number(total)*100
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(total) * 100
return Number(total) * 100
}
const handleScore = (tableMeta) => {
let listParameter = this.state.parameterScore
let parameterKpi = tableMeta.rowData[8]
let parameterAch = String(tableMeta.rowData[9]).includes('%')? `MAX${String(tableMeta.rowData[9]).substr(0,String(tableMeta.rowData[9]).length - 1)}` : String(tableMeta.rowData[9])
let parameterAch = String(tableMeta.rowData[9]).includes('%') ? `MAX${String(tableMeta.rowData[9]).substr(0, String(tableMeta.rowData[9]).length - 1)}` : String(tableMeta.rowData[9])
let parameterMix = `${parameterKpi}_${parameterAch}`
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 totalScore = 0
let achx100 = tableMeta.rowData[9] == '100%'? Number(tableMeta.rowData[13])/100 > 1? 1 : Number(tableMeta.rowData[13])/100 : Number(tableMeta.rowData[13])/100
let achx100 = tableMeta.rowData[9] == '100%' ? Number(tableMeta.rowData[13]) / 100 > 1 ? 1 : Number(tableMeta.rowData[13]) / 100 : Number(tableMeta.rowData[13]) / 100
if (listParameterFilterCompany.length == 0) {
listParameterFilter.map((item,index) => {
listParameterFilter.map((item, index) => {
if (Number(achx100) >= Number(item.min_value) && Number(achx100) <= Number(item.max_value)) {
totalScore = Number(item.value)
}
})
} else {
listParameterFilterCompany.map((item,index) => {
listParameterFilterCompany.map((item, index) => {
if (Number(achx100) >= Number(item.min_value) && Number(achx100) <= Number(item.max_value)) {
totalScore = Number(item.value)
}
})
}
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(totalScore).toFixed(0)
return Number(totalScore).toFixed(0)
}
......@@ -1068,7 +1071,7 @@ export default class CorporateAnnualTargetMR extends Component {
// if (tableMeta.rowData[5] == 'Trading profit (NPBT buah luar & plasma)') {
// console.log(dataTable2[tableMeta.rowIndex])
// }
let handlePercent = String(dataTable2[tableMeta.rowIndex][6]).substr(0,String(dataTable2[tableMeta.rowIndex][6]).length-1)
let handlePercent = String(dataTable2[tableMeta.rowIndex][6]).substr(0, String(dataTable2[tableMeta.rowIndex][6]).length - 1)
if (dataTable2[tableMeta.rowIndex][12] == '' || String(dataTable2[tableMeta.rowIndex][12]) == '0' || String(dataTable2[tableMeta.rowIndex][12]) == '0.0') {
total = 0
} else {
......@@ -1076,27 +1079,27 @@ export default class CorporateAnnualTargetMR extends Component {
// console.log(total)
}
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(total).toFixed(2)
if (tableMeta.rowIndex == dataTable2.length -1) {
if (tableMeta.rowIndex == dataTable2.length - 1) {
let totals = 0
let perfomanceScoreX = ''
dataTable2.map((item,index) => {
let value = String(item[15]) == 'NaN' || String(item[15]) == ''? 0 : Number(item[15])
dataTable2.map((item, index) => {
let value = String(item[15]) == 'NaN' || String(item[15]) == '' ? 0 : Number(item[15])
totals += value
})
totals = Number(totals).toFixed(2)
if ( totals >= 1.00 && totals <= 2.00) {
if (totals >= 1.00 && totals <= 2.00) {
perfomanceScoreX = 'K'
} else if ( totals >= 2.01 && totals <= 2.75) {
} else if (totals >= 2.01 && totals <= 2.75) {
perfomanceScoreX = 'C'
} else if ( totals >= 2.76 && totals <= 3.00) {
} else if (totals >= 2.76 && totals <= 3.00) {
perfomanceScoreX = 'B-'
} else if ( totals >= 3.01 && totals <= 3.75) {
} else if (totals >= 3.01 && totals <= 3.75) {
perfomanceScoreX = 'B'
} else if ( totals >= 3.76 && totals <= 4.00) {
} else if (totals >= 3.76 && totals <= 4.00) {
perfomanceScoreX = 'B+'
} else if ( totals >= 4.01 && totals <= 4.75) {
} else if (totals >= 4.01 && totals <= 4.75) {
perfomanceScoreX = 'BS'
} else if ( totals >= 4.76 && totals <= 5.00) {
} else if (totals >= 4.76 && totals <= 5.00) {
perfomanceScoreX = 'IST'
}
// totalScoreXXX = totals
......@@ -1105,7 +1108,7 @@ export default class CorporateAnnualTargetMR extends Component {
// console.log(totalScoreXXX)
// console.log(perfomanceScore)
// }, 300);
}
return total
}
......@@ -1140,7 +1143,7 @@ export default class CorporateAnnualTargetMR extends Component {
options: {
display: false
}
},
},
{
name: "Key Performance Indicator",
options: {
......@@ -1152,7 +1155,7 @@ export default class CorporateAnnualTargetMR extends Component {
setCellProps: () => ({ style }),
customBodyRender: (val, tableMeta) => {
return (
handleAction(tableMeta.rowData[2], tableMeta.rowData[0], tableMeta) && (tableMeta.rowData[1] == "" || String(this.props.status).toLocaleLowerCase() == 'draft' || String(this.props.status).toLocaleLowerCase() == 'submitted' || String(this.props.status).toLocaleLowerCase() == 'revision')?
handleAction(tableMeta.rowData[2], tableMeta.rowData[0], tableMeta) && (tableMeta.rowData[1] == "" || String(this.props.status).toLocaleLowerCase() == 'draft' || String(this.props.status).toLocaleLowerCase() == 'submitted' || String(this.props.status).toLocaleLowerCase() == 'revision') ?
<div style={{ textAlign: 'left', paddingLeft: 20 * Number(tableMeta.rowData[4]) }}>
{!this.state.loading && <FormControlLabel
style={{ margin: 0 }}
......@@ -1226,7 +1229,7 @@ export default class CorporateAnnualTargetMR extends Component {
{tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
null :
<FormControlLabel
style={{ margin: 0}}
style={{ margin: 0 }}
value={value}
control={
<NumberFormat
......@@ -1257,7 +1260,7 @@ export default class CorporateAnnualTargetMR extends Component {
),
customBodyRender: (value, tableMeta, updateValue) => {
return (
<div style={{ textAlign: 'center' }}>
<div style={{ textAlign: 'center' }}>
<div style={{ textAlign: 'center', width: 60 }}>
{value}
</div>
......@@ -1336,7 +1339,7 @@ export default class CorporateAnnualTargetMR extends Component {
{tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
null
:
this.state.get_for == 'view'?
this.state.get_for == 'view' ?
<NumberFormat
thousandSeparator={true}
style={{ color: "black", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
......@@ -1347,30 +1350,30 @@ export default class CorporateAnnualTargetMR extends Component {
disabled={true}
decimalScale={1}
/>
:
<div style={{ flex: 1, textAlign: 'right' }}>
<FormControlLabel
style={{ margin: 0 }}
value={Number(value).toFixed(1)}
control={
<NumberFormat
thousandSeparator={true}
style={{ color: this.state.get_for == 'view'? "black" : handleAction(tableMeta.rowData[2], tableMeta.rowData[0], tableMeta)? "#5198ea" : 'black', fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
value={ tableMeta.rowData[0] === 5 || tableMeta.rowData[0] === 6? Number(handleValueFormula(value, tableMeta, tableMeta.columnIndex)).toFixed(1) : Number(value).toFixed(1)}
// 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={this.state.get_for == 'view'? true : !handleAction(tableMeta.rowData[2], tableMeta.rowData[0], tableMeta)}
decimalScale={1}
onBlur={(event) => {
// updateValue(event.target.value)
handleChange(event.target.value, tableMeta)
// // console.log(dataTable2)
}}
/>
}
/>
</div>
:
<div style={{ flex: 1, textAlign: 'right' }}>
<FormControlLabel
style={{ margin: 0 }}
value={Number(value).toFixed(1)}
control={
<NumberFormat
thousandSeparator={true}
style={{ color: this.state.get_for == 'view' ? "black" : handleAction(tableMeta.rowData[2], tableMeta.rowData[0], tableMeta) ? "#5198ea" : 'black', fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
value={tableMeta.rowData[0] === 5 || tableMeta.rowData[0] === 6 ? Number(handleValueFormula(value, tableMeta, tableMeta.columnIndex)).toFixed(1) : Number(value).toFixed(1)}
// 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={this.state.get_for == 'view' ? true : !handleAction(tableMeta.rowData[2], tableMeta.rowData[0], tableMeta)}
decimalScale={1}
onBlur={(event) => {
// updateValue(event.target.value)
handleChange(event.target.value, tableMeta)
// // console.log(dataTable2)
}}
/>
}
/>
</div>
}
</div>
)
......@@ -1422,7 +1425,7 @@ export default class CorporateAnnualTargetMR extends Component {
<div style={{ width: 75, textAlign: 'right' }}>
{tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
null :
this.state.get_for == 'view'?
this.state.get_for == 'view' ?
<NumberFormat
thousandSeparator={true}
style={{ color: "black", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
......@@ -1434,23 +1437,23 @@ export default class CorporateAnnualTargetMR extends Component {
suffix={"%"}
decimalScale={1}
/>
:
<FormControlLabel
style={{ margin: 0 }}
value={Number(value).toFixed(1)}
control={
<NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
suffix={"%"}
value={handleAchiement(tableMeta).toFixed(1)}
decimalScale={1}
disabled={true}
/>
}
/>
:
<FormControlLabel
style={{ margin: 0 }}
value={Number(value).toFixed(1)}
control={
<NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
suffix={"%"}
value={handleAchiement(tableMeta).toFixed(1)}
decimalScale={1}
disabled={true}
/>
}
/>
}
</div>
)
......@@ -1469,7 +1472,7 @@ export default class CorporateAnnualTargetMR extends Component {
<div style={{ width: 70, textAlign: 'right' }}>
{tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
null :
this.state.get_for == 'view'?
this.state.get_for == 'view' ?
<NumberFormat
thousandSeparator={true}
style={{ color: "black", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
......@@ -1480,27 +1483,27 @@ export default class CorporateAnnualTargetMR extends Component {
disabled={true}
decimalScale={0}
/>
:
<FormControlLabel
style={{ margin: 0 }}
value={Number(value).toFixed(0)}
control={
<NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
value={handleScore(tableMeta)}
decimalScale={0}
disabled={true}
// onBlur={(event) => {
// // updateValue(event.target.value)
// handleChange(event.target.value, tableMeta)
// // // console.log(dataTable2)
// }}
/>
}
/>
:
<FormControlLabel
style={{ margin: 0 }}
value={Number(value).toFixed(0)}
control={
<NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
value={handleScore(tableMeta)}
decimalScale={0}
disabled={true}
// onBlur={(event) => {
// // updateValue(event.target.value)
// handleChange(event.target.value, tableMeta)
// // // console.log(dataTable2)
// }}
/>
}
/>
}
</div>
)
......@@ -1519,7 +1522,7 @@ export default class CorporateAnnualTargetMR extends Component {
<div style={{ width: 75 }}>
{tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
null :
this.state.get_for == 'view'?
this.state.get_for == 'view' ?
<NumberFormat
thousandSeparator={true}
style={{ color: "black", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
......@@ -1530,7 +1533,7 @@ export default class CorporateAnnualTargetMR extends Component {
disabled={true}
decimalScale={2}
/>
:
:
<NumberFormat
thousandSeparator={true}
style={{ color: "black", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
......@@ -1559,30 +1562,30 @@ export default class CorporateAnnualTargetMR extends Component {
{tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
null
:
this.state.get_for == 'view'?
value
:
<FormControlLabel
style={{ margin: 0 }}
control={
<ThemeProvider theme={theme}>
<Input
disableUnderline={true}
style={{ color: this.state.get_for == 'view'? "black" : "#5198ea", fontSize: 12, textAlign: 'left', borderColor: 'transparent', margin: 0, width: 150, backgroundColor: 'transparent' }}
type="text"
placeholder=""
multiline={true}
defaultValue={value}
disabled={this.state.get_for == 'view'}
onBlur={(event) => {
// updateValue(event.target.value)
handleChange(event.target.value, tableMeta, 'text')
// // console.log(dataTable2)
}}
/>
</ThemeProvider>
}
/>
this.state.get_for == 'view' ?
value
:
<FormControlLabel
style={{ margin: 0 }}
control={
<ThemeProvider theme={theme}>
<Input
disableUnderline={true}
style={{ color: this.state.get_for == 'view' ? "black" : "#5198ea", fontSize: 12, textAlign: 'left', borderColor: 'transparent', margin: 0, width: 150, backgroundColor: 'transparent' }}
type="text"
placeholder=""
multiline={true}
defaultValue={value}
disabled={this.state.get_for == 'view'}
onBlur={(event) => {
// updateValue(event.target.value)
handleChange(event.target.value, tableMeta, 'text')
// // console.log(dataTable2)
}}
/>
</ThemeProvider>
}
/>
}
</div>
)
......@@ -1594,7 +1597,7 @@ export default class CorporateAnnualTargetMR extends Component {
options: {
display: false
}
},
},
]
......@@ -1643,7 +1646,7 @@ export default class CorporateAnnualTargetMR extends Component {
borderColor: 'transparent',
margin: 5
}}
onClick={() => this.downloadTemplate() }
onClick={() => this.downloadTemplate()}
>
<img src={Images.template} />
</button>
......@@ -1671,10 +1674,10 @@ export default class CorporateAnnualTargetMR extends Component {
borderColor: 'transparent',
margin: 5
}}
onClick={() =>
onClick={() =>
this.setState({ loading: true }, () => {
setTimeout(() => {
this.downloadAllData()
this.downloadAllData()
}, 100);
})}
>
......@@ -1697,28 +1700,28 @@ export default class CorporateAnnualTargetMR extends Component {
</MuiThemeProvider>
)}
</div>
<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>
<Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 10 }}>Last Updated by : {this.state.updateBy}</Typography>
</div>
<div style={{display: 'flex', flexDirection: 'row'}}>
<div style={{padding: 5}}>
<div style={{ display: 'flex', flexDirection: 'row' }}>
<div style={{ padding: 5 }}>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>TOTAL SCORE</Typography>
</div>
<div style={{border: '1px solid black', padding: 5, minWidth: 200, display: 'flex', justifyContent: 'flex-end'}}>
<div style={{ border: '1px solid black', padding: 5, minWidth: 200, display: 'flex', justifyContent: 'flex-end' }}>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>{this.state.totalScore}</Typography>
</div>
</div>
</div>
<div style={{ display: 'flex', justifyContent: 'space-between', maxWidth: '100%', paddingLeft: 15, paddingRight: 15}}>
<div style={{ display: 'flex', justifyContent: 'space-between', maxWidth: '100%', paddingLeft: 15, paddingRight: 15 }}>
<div>
<Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 10 }}>Notes : {this.state.notes}</Typography>
</div>
<div style={{display: 'flex', flexDirection: 'row'}}>
<div style={{padding: 5}}>
<div style={{ display: 'flex', flexDirection: 'row' }}>
<div style={{ padding: 5 }}>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>PERFOMANCE</Typography>
</div>
<div style={{borderStyle: 'solid', backgroundColor: this.handleBackgroundPerf(this.state.totalScore), borderWidth: '0px 1px 1px 1px', padding: 5, minWidth: 200, display: 'flex', justifyContent: 'flex-end'}}>
<div style={{ borderStyle: 'solid', backgroundColor: this.handleBackgroundPerf(this.state.totalScore), 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>
</div>
</div>
......@@ -1746,7 +1749,7 @@ export default class CorporateAnnualTargetMR extends Component {
</button>
</div>
{this.props.isApprover === true ?
<div className="col-2"></div>
<div className="col-2"></div>
:
<div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%' }}>
{this.state.get_for == 'view' && this.state.viewOnly && <button
......@@ -1760,7 +1763,7 @@ export default class CorporateAnnualTargetMR extends Component {
marginRight: 20
}}
onClick={() => {
this.setState({loading: true}, () => {
this.setState({ loading: true }, () => {
this.handleGetFor('edit')
})
}}
......@@ -1783,7 +1786,7 @@ export default class CorporateAnnualTargetMR extends Component {
this.setState({ loading: true, dataTable: dataTable2, saveDraft: false, buttonError: false }, () => {
setTimeout(() => {
// this.handleValidate()
this.handleCalculate()
this.handleCalculate(dataTable2)
}, 100);
})
}}
......@@ -1838,7 +1841,7 @@ export default class CorporateAnnualTargetMR extends Component {
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save & Complete</Typography>
</div>
</button>}
</div>
</div>
}
</div>
</Paper> :
......@@ -1863,34 +1866,34 @@ export default class CorporateAnnualTargetMR extends Component {
</MuiThemeProvider>
)}
</div>
<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>
<Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 10 }}>Last Updated by : {this.state.updateBy}</Typography>
</div>
<div style={{display: 'flex', flexDirection: 'row'}}>
<div style={{padding: 5}}>
<div style={{ display: 'flex', flexDirection: 'row' }}>
<div style={{ padding: 5 }}>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>TOTAL SCORE</Typography>
</div>
<div style={{border: '1px solid black', padding: 5, minWidth: 200, display: 'flex', justifyContent: 'flex-end'}}>
<div style={{ border: '1px solid black', padding: 5, minWidth: 200, display: 'flex', justifyContent: 'flex-end' }}>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>{this.state.totalScore}</Typography>
</div>
</div>
</div>
<div style={{ display: 'flex', justifyContent: 'space-between', maxWidth: '100%', paddingLeft: 15, paddingRight: 15}}>
<div style={{ display: 'flex', justifyContent: 'space-between', maxWidth: '100%', paddingLeft: 15, paddingRight: 15 }}>
<div>
<Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 10 }}>Notes : {this.state.notes}</Typography>
</div>
<div style={{display: 'flex', flexDirection: 'row'}}>
<div style={{padding: 5}}>
<div style={{ display: 'flex', flexDirection: 'row' }}>
<div style={{ padding: 5 }}>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>PERFOMANCE</Typography>
</div>
<div style={{borderStyle: 'solid', backgroundColor: this.handleBackgroundPerf(this.state.totalScore), borderWidth: '0px 1px 1px 1px', padding: 5, minWidth: 200, display: 'flex', justifyContent: 'flex-end'}}>
<div style={{ borderStyle: 'solid', backgroundColor: this.handleBackgroundPerf(this.state.totalScore), 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>
</div>
</div>
</div>
<div className="grid grid-2x" style={{ marginTop: 10, padding: 20, paddingLeft: 0, paddingRight: 0 }}>
<div className="col-1" style={{paddingLeft: 0}}>
<div className="col-1" style={{ paddingLeft: 0 }}>
<button
type="button"
onClick={() => this.setState({ loading: true, visibleCATMR: true }, () => {
......@@ -1925,7 +1928,7 @@ export default class CorporateAnnualTargetMR extends Component {
this.setState({ loading: true, dataTable: dataTable2, saveDraft: false, buttonError: false }, () => {
setTimeout(() => {
// this.handleValidate()
this.handleCalculate()
this.handleCalculate(dataTable2)
}, 100);
})
}}
......@@ -1980,7 +1983,7 @@ export default class CorporateAnnualTargetMR extends Component {
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save & Complete</Typography>
</div>
</button>
</div>
</div>
</div>
</div>
</Paper>
......
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