Commit e34859c4 authored by Deni Rinaldi's avatar Deni Rinaldi

Merge branch 'riri' into 'master'

handleChange

See merge request !679
parents cf0f2890 511c3fef
......@@ -4,6 +4,7 @@ import React, { Component } from 'react'
import ReactTooltip from 'react-tooltip';
import Images from '../../assets/Images';
import api from '../../api';
import NumberFormat from 'react-number-format';
const LightTooltip = withStyles((theme) => ({
tooltip: {
......@@ -164,6 +165,19 @@ export default class ProfitLossMR extends Component {
let a = dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = value
console.log(dataTable2[tableMeta.rowIndex]);
}
const handleChange = (value, tableMeta, indexChilds) => {
console.log(dataTable2)
let val = String(value).split(",").join("")
if (indexChilds == 0) {
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].mb = Number(val)
}
else if (indexChilds == 1) {
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].rb = Number(val)
}
else if (indexChilds == 2) {
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].actual = Number(val)
}
}
let columns = [
{
name: "",
......@@ -292,7 +306,22 @@ export default class ProfitLossMR extends Component {
<div style={{ textAlign: 'right', width: 90 }}>
{tableMeta.rowData[0] === 4 ?
null :
val
<div style={{ flex: 1 }}>
<FormControlLabel
style={{ margin: 0 }}
value={val}
control={
<NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={Number(val).toFixed(1)}
/>
}
/>
</div>
}
</div>
)
......@@ -327,7 +356,7 @@ export default class ProfitLossMR extends Component {
paddingRight: 0
}
}),
customBodyRender: (val, tableMeta, updateValue) => {
customBodyRender: (value, tableMeta, updateValue) => {
// console.log(tableMeta);
return (
<div>
......@@ -336,7 +365,22 @@ export default class ProfitLossMR extends Component {
<div style={{ textAlign: 'right', width: 90 }}>
{tableMeta.rowData[0] === 4 ?
null :
val.mb
<div style={{ flex: 1 }}>
<FormControlLabel
style={{ margin: 0 }}
value={value.mb}
control={
<NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={Number(value.mb).toFixed(1)}
/>
}
/>
</div>
}
</div>
</div>
......@@ -344,7 +388,22 @@ export default class ProfitLossMR extends Component {
<div style={{ textAlign: 'right', width: 90 }}>
{tableMeta.rowData[0] === 4 ?
null :
val.rb
<div style={{ flex: 1 }}>
<FormControlLabel
style={{ margin: 0 }}
value={value.rb}
control={
<NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={Number(value.rb).toFixed(1)}
/>
}
/>
</div>
}
</div>
</div>
......@@ -352,7 +411,62 @@ export default class ProfitLossMR extends Component {
<div style={{ textAlign: 'right', width: 90 }}>
{tableMeta.rowData[0] === 4 ?
null :
val.actual
tableMeta.rowData[0] === 2 ?
<div style={{ flex: 1 }}>
<FormControlLabel
style={{ margin: 0 }}
value={value.actual}
control={
<NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={Number(value.actual).toFixed(1)}
/>
}
/>
</div> :
tableMeta.rowData[0] === 6 ?
<div style={{ flex: 1 }}>
<FormControlLabel
style={{ margin: 0 }}
value={value.actual}
control={
<NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={Number(value.actual).toFixed(1)}
/>
}
/>
</div>
:
tableMeta.rowData[0] === 1 ?
null :
<div style={{ flex: 1 }}>
<FormControlLabel
style={{ margin: 0 }}
value={value.actual}
control={
<NumberFormat
thousandSeparator={true}
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
value={Number(value.actual).toFixed(1)}
onBlur={(event) => {
handleChange(event.target.value, tableMeta, 2)
// console.log(dataTable2)
}}
/>
}
/>
</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