Commit 1f207c41 authored by Riri Novita's avatar Riri Novita

handleChange

parent 3838bdb2
...@@ -4,6 +4,7 @@ import React, { Component } from 'react' ...@@ -4,6 +4,7 @@ import React, { Component } from 'react'
import ReactTooltip from 'react-tooltip'; import ReactTooltip from 'react-tooltip';
import Images from '../../assets/Images'; import Images from '../../assets/Images';
import api from '../../api'; import api from '../../api';
import NumberFormat from 'react-number-format';
const LightTooltip = withStyles((theme) => ({ const LightTooltip = withStyles((theme) => ({
tooltip: { tooltip: {
...@@ -164,6 +165,19 @@ export default class ProfitLossMR extends Component { ...@@ -164,6 +165,19 @@ export default class ProfitLossMR extends Component {
let a = dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = value let a = dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = value
console.log(dataTable2[tableMeta.rowIndex]); 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 = [ let columns = [
{ {
name: "", name: "",
...@@ -327,7 +341,7 @@ export default class ProfitLossMR extends Component { ...@@ -327,7 +341,7 @@ export default class ProfitLossMR extends Component {
paddingRight: 0 paddingRight: 0
} }
}), }),
customBodyRender: (val, tableMeta, updateValue) => { customBodyRender: (value, tableMeta, updateValue) => {
// console.log(tableMeta); // console.log(tableMeta);
return ( return (
<div> <div>
...@@ -336,7 +350,7 @@ export default class ProfitLossMR extends Component { ...@@ -336,7 +350,7 @@ export default class ProfitLossMR extends Component {
<div style={{ textAlign: 'right', width: 90 }}> <div style={{ textAlign: 'right', width: 90 }}>
{tableMeta.rowData[0] === 4 ? {tableMeta.rowData[0] === 4 ?
null : null :
val.mb value.mb
} }
</div> </div>
</div> </div>
...@@ -344,7 +358,7 @@ export default class ProfitLossMR extends Component { ...@@ -344,7 +358,7 @@ export default class ProfitLossMR extends Component {
<div style={{ textAlign: 'right', width: 90 }}> <div style={{ textAlign: 'right', width: 90 }}>
{tableMeta.rowData[0] === 4 ? {tableMeta.rowData[0] === 4 ?
null : null :
val.rb value.rb
} }
</div> </div>
</div> </div>
...@@ -352,7 +366,62 @@ export default class ProfitLossMR extends Component { ...@@ -352,7 +366,62 @@ export default class ProfitLossMR extends Component {
<div style={{ textAlign: 'right', width: 90 }}> <div style={{ textAlign: 'right', width: 90 }}>
{tableMeta.rowData[0] === 4 ? {tableMeta.rowData[0] === 4 ?
null : 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="input"
value={Number(value.actual).toFixed(1)}
onBlur={(event) => {
handleChange(event.target.value, tableMeta, 2)
// console.log(dataTable2)
}}
/>
}
/>
</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