Commit 6810bbc2 authored by EKSAD's avatar EKSAD

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

parents 6c559b9b a45e0661
......@@ -110,6 +110,7 @@ export default class CorporateAnnualTarget extends Component {
const handlePushChild = (item) => {
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'
dataTable.push([
item.type_report_id,
item.id,
......@@ -119,7 +120,7 @@ export default class CorporateAnnualTarget extends Component {
"",
item.description,
item.type_report_id == 1 ? `${Number(item.weight) * 100}%` : item.cat.weight,
item.cat.uom,
parentTrue? item.cat.uom : item.uom,
item.cat.kpi_type == "" ? null : { value: item.cat.kpi_type },
item.cat.max_ach == "" ? null : { value: item.cat.max_ach },
item.cat.formula == "" ? null : { value: item.cat.formula },
......@@ -296,6 +297,7 @@ export default class CorporateAnnualTarget extends Component {
company_id: this.props.company.company_id,
periode: this.props.periode,
report_id: this.props.report_id,
status: '',
cat: payload
}
console.log(body)
......@@ -308,6 +310,7 @@ export default class CorporateAnnualTarget extends Component {
let dataDelete = this.state.dataDelete
api.create().getIdDeleteFromExcel(this.state.payload).then((response) => {
if (response.data) {
// console.log(response.data)
let idDelete = response.data.data.item_report_id
if (idDelete.length > 0) {
idDelete.map((item, index) => {
......@@ -317,7 +320,7 @@ export default class CorporateAnnualTarget extends Component {
}
}
})
console.log(JSON.stringify(this.state.payload))
api.create().checkUploadMB(this.state.payload).then(response => {
// console.log(JSON.stringify(this.state.payload));
console.log(response)
......@@ -450,13 +453,47 @@ export default class CorporateAnnualTarget extends Component {
handleValidate() {
let data = []
console.log(this.state.dataTable)
this.state.dataTable.map(i => {
// console.log(i[9] == null? "" : i[9].value)
let totalWeight = 0
let dataTableBaru = this.state.dataTable
let dataTampung = []
let weightReal = null
this.state.dataTable.map((i, index) => {
if (i[0] ==1) {
dataTampung.push({
id: i[1],
maxValue: i[7],
valChild: 0
})
}
if (i[0] !== 1 && i[0] !== 4) {
totalWeight += Number(i[7] == "" || i[7] == undefined? 0 : i[7].replace('%', ''))
}
if (i[2] !== null) {
let indexID = dataTampung.findIndex((val) => val.id == i[2])
if (indexID !== -1) {
let weightParent = Number(dataTampung[indexID].maxValue == "" || dataTampung[indexID].maxValue == undefined? 0 : dataTampung[indexID].maxValue.replace('%', ''))
let valChild = Number(dataTampung[indexID].valChild)
let valReal = Number(i[7] == "" || i[7] == undefined? 0 : i[7].replace('%', ''))
let totalBaru = valChild + valReal
if (totalBaru > weightParent) {
dataTableBaru[index][7] = `${(weightParent - valChild)}%`
dataTampung[indexID].valChild = dataTampung[indexID].valChild + weightParent - valChild
weightReal = `${(weightParent - valChild)}%`
} else {
dataTableBaru[index][7] = i[7]
weightReal = i[7]
dataTampung[indexID].valChild = dataTampung[indexID].valChild + Number(i[7] == "" || i[7] == undefined? 0 : i[7].replace('%', ''))
}
}
}
data.push({
"item_report_id": i[1],
"item_name": i[1] == "" ? null : String(i[6]),
"parent": i[1] == "" ? null : i[2],
"weight": String(i[7]),
"item_name": i[6] == "" ? null : String(i[6]),
"parent": i[2] == "" ? null : i[2],
"weight": weightReal == null? String(i[7]) : weightReal,
"uom": String(i[8]),
"kpi_type": i[9] == null ? "" : i[9].value,
"max_ach": i[10] == null ? "" : i[10].value,
......@@ -481,6 +518,8 @@ export default class CorporateAnnualTarget extends Component {
"pic": String(i[29])
})
})
console.log(dataTableBaru)
console.log(JSON.stringify(data))
let payload = {
"submission_id": this.props.submissionID,
......@@ -490,16 +529,10 @@ export default class CorporateAnnualTarget extends Component {
"status": "submitted",
"cat": data
}
let totalWeight = 0
this.state.dataTable.map((items, indexs) => {
if (items[0] !== 1 || items[0] !== 4) {
console.log(items[7])
totalWeight += Number(items[7].replace('%', ''))
}
})
console.log(totalWeight)
// this.setState({dataTable: dataTampung})
if (totalWeight < 100) {
this.setState({ alert: true, messageAlert: 'Total weight less than 100%', tipeAlert: 'warning', loading: false, buttonError: true, editable: true })
this.setState({ alert: true, messageAlert: 'Total weight less than 100%', tipeAlert: 'warning', loading: false, buttonError: true, editable: true})
} else {
api.create().validateSubmitReport(payload).then((response) => {
console.log(response)
......@@ -581,7 +614,7 @@ export default class CorporateAnnualTarget extends Component {
// })
})
} else {
console.log('sini jing')
// console.log('sini jing')
// api.create().validateSubmitReport(payloadBro).then((response) => {
// console.log(response)
// if (response.data.data.result) {
......@@ -702,21 +735,21 @@ export default class CorporateAnnualTarget extends Component {
let dataDelete = this.state.dataDelete
const handleChange = (value, tableMeta) => {
let val = String(value).split(",").join("")
let total = 0
let lastValz = 0
// let total = 0
// let lastValz = 0
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(val)
dataTable2[tableMeta.rowIndex].map((item, index) => {
if (index >= 13 && index <= 24) {
let valItem = item == undefined || item == "" ? 0 : item
total += Number(valItem)
if (index == 24) {
lastValz += Number(valItem)
}
}
})
let valz = dataTable2[tableMeta.rowIndex][11] == null ? 'SUM' : dataTable2[tableMeta.rowIndex][11].value
dataTable2[tableMeta.rowIndex][25] = (valz == 'SUM' ? total : (valz == 'AVG' ? (total / 12) : lastValz))
console.log(dataTable2[tableMeta.rowIndex])
// dataTable2[tableMeta.rowIndex].map((item, index) => {
// if (index >= 13 && index <= 24) {
// let valItem = item == undefined || item == "" ? 0 : item
// total += Number(valItem)
// if (index == 24) {
// lastValz += Number(valItem)
// }
// }
// })
// let valz = dataTable2[tableMeta.rowIndex][11] == null ? 'SUM' : dataTable2[tableMeta.rowIndex][11].value
// dataTable2[tableMeta.rowIndex][25] = (valz == 'SUM' ? total : (valz == 'AVG' ? (total / 12) : lastValz))
// console.log(dataTable2[tableMeta.rowIndex])
}
const handleChangeDropdown = (value, tableMeta) => {
......@@ -739,36 +772,33 @@ export default class CorporateAnnualTarget extends Component {
}
const handleChangePercentage = (value, tableMeta) => {
let valueReal = value.replace('%', '')
let indexParentDatatable = dataTable2.findIndex((val) => val[1] == tableMeta.rowData[2])
let indexParentReal = this.state.dataReal.findIndex((val) => val.id == tableMeta.rowData[2])
// console.log(indexParentDatatable)
// console.log(indexParentReal)
let valParent = dataTable2[indexParentDatatable][7]
valParent.replace('%', '')
let valChild = 0
// let valueReal = value.replace('%', '')
// let indexParentDatatable = dataTable2.findIndex((val) => val[1] == tableMeta.rowData[2])
// let indexParentReal = this.state.dataReal.findIndex((val) => val.id == tableMeta.rowData[2])
// let valParent = dataTable2[indexParentDatatable][7]
// valParent.replace('%', '')
// let valChild = 0
dataTable2.map((item, index) => {
if (item[2] == dataTable2[indexParentDatatable][1] && item[1] !== tableMeta.rowData[1]) {
let weightItem = item[7] == "" ? 0 : item[7].replace('%', '')
console.log(weightItem)
valChild += Number(weightItem)
}
})
// dataTable2.map((item, index) => {
// if (item[2] == dataTable2[indexParentDatatable][1] && item[1] !== tableMeta.rowData[1]) {
// let weightItem = item[7] == "" ? 0 : item[7].replace('%', '')
// console.log(weightItem)
// valChild += Number(weightItem)
// }
// })
// let endVal = ''
// if ((Number(valueReal) + Number(valChild)) > Number(valParent.replace('%', ''))) {
// endVal = `${Number(valParent.replace('%', '')) - (Number(valChild))}%`
// console.log(endVal)
// } else {
// endVal = `${Number(valueReal)}%`
// console.log(endVal)
// }
// // console.log(endVal)
// dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = endVal
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = value
let endVal = ''
// console.log(Number(valueReal) + Number(valChild))
// console.log(valueReal)
// console.log(Number(valParent.replace('%', '')))
if ((Number(valueReal) + Number(valChild)) > Number(valParent.replace('%', ''))) {
endVal = `${Number(valParent.replace('%', '')) - (Number(valChild))}%`
console.log(endVal)
} else {
endVal = `${Number(valueReal)}%`
console.log(endVal)
}
// console.log(endVal)
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = endVal
}
const handleChangeText = (value, tableMeta) => {
......@@ -851,6 +881,24 @@ export default class CorporateAnnualTarget extends Component {
})
}
const handleTotal = (tableMeta) => {
// let val = String(value).split(",").join("")
let total = 0
let lastValz = 0
dataTable2[tableMeta.rowIndex].map((item, index) => {
if (index >= 13 && index <= 24) {
let valItem = item == undefined || item == "" ? 0 : item
total += Number(valItem)
if (index == 24) {
lastValz += Number(valItem)
}
}
})
let valz = dataTable2[tableMeta.rowIndex][11] == null ? 'SUM' : dataTable2[tableMeta.rowIndex][11].value
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = (valz == 'SUM' ? total : (valz == 'AVG' ? (total / 12) : lastValz))
return (valz == 'SUM' ? total : (valz == 'AVG' ? (total / 12) : lastValz))
}
const columns = [{
name: "",
options: {
......@@ -965,8 +1013,8 @@ export default class CorporateAnnualTarget extends Component {
</div>
:
<div style={{ width: 300 }}>
{tableMeta.rowData[22] ?
tableMeta.rowData[22].length > 0 ?
{tableMeta.rowData[30] ?
tableMeta.rowData[30].length > 0 ?
<div style={{ paddingLeft: 20 * Number(tableMeta.rowData[4]) }}>
<LightTooltip title={"Report Items Not Registered"} arrow>
<span style={{ fontSize: 12, color: 'red' }}>{tableMeta.rowData[0] === 4 ? "" : val}</span>
......@@ -1232,7 +1280,7 @@ export default class CorporateAnnualTarget extends Component {
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
value={value}
value={Number(value).toFixed(1)}
disabled={this.props.isApprover}
decimalScale={1}
onBlur={(event) => {
......@@ -1273,7 +1321,7 @@ export default class CorporateAnnualTarget extends Component {
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
value={value}
value={Number(value).toFixed(1)}
disabled={this.props.isApprover}
decimalScale={1}
onBlur={(event) => {
......@@ -1314,7 +1362,7 @@ export default class CorporateAnnualTarget extends Component {
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
value={value}
value={Number(value).toFixed(1)}
disabled={this.props.isApprover}
decimalScale={1}
onBlur={(event) => {
......@@ -1355,7 +1403,7 @@ export default class CorporateAnnualTarget extends Component {
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
value={value}
value={Number(value).toFixed(1)}
decimalScale={1}
disabled={this.props.isApprover}
onBlur={(event) => {
......@@ -1396,7 +1444,7 @@ export default class CorporateAnnualTarget extends Component {
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
value={value}
value={Number(value).toFixed(1)}
disabled={this.props.isApprover}
decimalScale={1}
onBlur={(event) => {
......@@ -1438,7 +1486,7 @@ export default class CorporateAnnualTarget extends Component {
type="text"
placeholder=""
disabled={this.props.isApprover}
value={value}
value={Number(value).toFixed(1)}
decimalScale={1}
onBlur={(event) => {
// updateValue(event.target.value)
......@@ -1479,7 +1527,7 @@ export default class CorporateAnnualTarget extends Component {
type="text"
placeholder=""
disabled={this.props.isApprover}
value={value}
value={Number(value).toFixed(1)}
decimalScale={1}
onBlur={(event) => {
// updateValue(event.target.value)
......@@ -1519,7 +1567,7 @@ export default class CorporateAnnualTarget extends Component {
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
value={value}
value={Number(value).toFixed(1)}
disabled={this.props.isApprover}
decimalScale={1}
onBlur={(event) => {
......@@ -1560,7 +1608,7 @@ export default class CorporateAnnualTarget extends Component {
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
value={value}
value={Number(value).toFixed(1)}
disabled={this.props.isApprover}
decimalScale={1}
onBlur={(event) => {
......@@ -1603,7 +1651,7 @@ export default class CorporateAnnualTarget extends Component {
placeholder=""
disabled={this.props.isApprover}
decimalScale={1}
value={value}
value={Number(value).toFixed(1)}
onBlur={(event) => {
// updateValue(event.target.value)
handleChange(event.target.value, tableMeta)
......@@ -1642,7 +1690,7 @@ export default class CorporateAnnualTarget extends Component {
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
value={value}
value={Number(value).toFixed(1)}
disabled={this.props.isApprover}
decimalScale={1}
onBlur={(event) => {
......@@ -1683,7 +1731,7 @@ export default class CorporateAnnualTarget extends Component {
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
value={value}
value={Number(value).toFixed(1)}
disabled={this.props.isApprover}
decimalScale={1}
onBlur={(event) => {
......@@ -1724,7 +1772,7 @@ export default class CorporateAnnualTarget extends Component {
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
value={value}
value={Number(value).toFixed(1)}
disabled={this.props.isApprover}
decimalScale={1}
onBlur={(event) => {
......@@ -1763,7 +1811,7 @@ export default class CorporateAnnualTarget extends Component {
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
value={value}
value={Number(handleTotal(tableMeta)).toFixed(1)}
decimalScale={1}
disabled={true}
// onBlur={(event) => {
......@@ -1803,7 +1851,7 @@ export default class CorporateAnnualTarget extends Component {
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
value={value}
value={Number(value).toFixed(1)}
disabled={this.props.isApprover}
decimalScale={1}
onBlur={(event) => {
......@@ -1844,7 +1892,7 @@ export default class CorporateAnnualTarget extends Component {
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
value={value}
value={Number(value).toFixed(1)}
disabled={this.props.isApprover}
decimalScale={1}
onBlur={(event) => {
......
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