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

push brw

parent 35a850b1
......@@ -288,7 +288,7 @@ export default class BalanceSheet extends Component {
} else {
data[tableMeta.rowIndex][tableMeta.columnIndex] = Number(val)
}
this.forceUpdate()
// this.forceUpdate()
// console.log(this.state.dataTable)
// this.setState({
// data: a,
......@@ -296,6 +296,32 @@ export default class BalanceSheet extends Component {
}
render() {
let dataTable2 = this.state.dataTable
const handleChange = (value, tableMeta) => {
let val = String(value).split(",").join("")
// let data = this.state.dataTable2
let indexParent = dataTable2.findIndex((val) => val[1] == dataTable2[tableMeta.rowIndex][2])
if (indexParent > 0) {
// console.log(indexParent)
let a = dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(val)
let jagain = dataTable2[indexParent][tableMeta.columnIndex]
a = dataTable2[indexParent][tableMeta.columnIndex] = jagain == undefined ? (0 + Number(val)) : (jagain + Number(val))
} else {
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(val)
}
}
const handleValue = (data) => {
let total = 0
dataTable2.map((item, index) => {
if (data.rowData[1] == item[2]) {
total = item[data.columnIndex] == undefined ? (total + 0) : (total + item[data.columnIndex])
}
})
let indexParent = dataTable2.findIndex((val) => val[1] == dataTable2[data.rowIndex][2])
let a = dataTable2[data.rowIndex][data.columnIndex] = total
// console.log(indexParent);
return a
}
const columns = [{
name: "",
options: {
......@@ -367,10 +393,10 @@ export default class BalanceSheet extends Component {
type="text"
placeholder=""
value={value}
onChange={event => {
// console.log(event.target)
updateValue(event.target.value)
// this.handleChange(event.target.value, tableMeta)
onBlur={(event) => {
// updateValue(event.target.value)
handleChange(event.target.value, tableMeta)
console.log(dataTable2)
}}
/>
}
......@@ -384,7 +410,7 @@ export default class BalanceSheet extends Component {
type="text"
placeholder=""
disabled={true}
value={this.handleValue(tableMeta)}
value={handleValue(tableMeta)}
/>
</span>
:
......@@ -423,10 +449,10 @@ export default class BalanceSheet extends Component {
type="text"
placeholder=""
value={value}
onChange={event => {
// console.log(event.target)
updateValue(event.target.value)
this.handleChange(event.target.value, tableMeta)
onBlur={(event) => {
// updateValue(event.target.value)
handleChange(event.target.value, tableMeta)
console.log(dataTable2)
}}
/>
}
......@@ -440,7 +466,7 @@ export default class BalanceSheet extends Component {
type="text"
placeholder=""
disabled={true}
value={this.handleValue(tableMeta)}
value={handleValue(tableMeta)}
/>
</span>
:
......@@ -476,10 +502,10 @@ export default class BalanceSheet extends Component {
type="text"
placeholder=""
value={value}
onChange={event => {
// console.log(event.target)
updateValue(event.target.value)
this.handleChange(event.target.value, tableMeta)
onBlur={(event) => {
// updateValue(event.target.value)
handleChange(event.target.value, tableMeta)
console.log(dataTable2)
}}
/>
}
......@@ -493,7 +519,7 @@ export default class BalanceSheet extends Component {
type="text"
placeholder=""
disabled={true}
value={this.handleValue(tableMeta)}
value={handleValue(tableMeta)}
/>
</span>
:
......@@ -529,10 +555,10 @@ export default class BalanceSheet extends Component {
type="text"
placeholder=""
value={value}
onChange={event => {
// console.log(event.target)
updateValue(event.target.value)
this.handleChange(event.target.value, tableMeta)
onBlur={(event) => {
// updateValue(event.target.value)
handleChange(event.target.value, tableMeta)
console.log(dataTable2)
}}
/>
}
......@@ -546,7 +572,7 @@ export default class BalanceSheet extends Component {
type="text"
placeholder=""
disabled={true}
value={this.handleValue(tableMeta)}
value={handleValue(tableMeta)}
/>
</span>
:
......@@ -582,10 +608,10 @@ export default class BalanceSheet extends Component {
type="text"
placeholder=""
value={value}
onChange={event => {
// console.log(event.target)
updateValue(event.target.value)
this.handleChange(event.target.value, tableMeta)
onBlur={(event) => {
// updateValue(event.target.value)
handleChange(event.target.value, tableMeta)
console.log(dataTable2)
}}
/>
}
......@@ -599,7 +625,7 @@ export default class BalanceSheet extends Component {
type="text"
placeholder=""
disabled={true}
value={this.handleValue(tableMeta)}
value={handleValue(tableMeta)}
/>
</span>
:
......@@ -635,10 +661,10 @@ export default class BalanceSheet extends Component {
type="text"
placeholder=""
value={value}
onChange={event => {
// console.log(event.target)
updateValue(event.target.value)
this.handleChange(event.target.value, tableMeta)
onBlur={(event) => {
// updateValue(event.target.value)
handleChange(event.target.value, tableMeta)
console.log(dataTable2)
}}
/>
}
......@@ -652,7 +678,7 @@ export default class BalanceSheet extends Component {
type="text"
placeholder=""
disabled={true}
value={this.handleValue(tableMeta)}
value={handleValue(tableMeta)}
/>
</span>
:
......@@ -688,10 +714,10 @@ export default class BalanceSheet extends Component {
type="text"
placeholder=""
value={value}
onChange={event => {
// console.log(event.target)
updateValue(event.target.value)
this.handleChange(event.target.value, tableMeta)
onBlur={(event) => {
// updateValue(event.target.value)
handleChange(event.target.value, tableMeta)
console.log(dataTable2)
}}
/>
}
......@@ -705,7 +731,7 @@ export default class BalanceSheet extends Component {
type="text"
placeholder=""
disabled={true}
value={this.handleValue(tableMeta)}
value={handleValue(tableMeta)}
/>
</span>
:
......@@ -789,7 +815,7 @@ export default class BalanceSheet extends Component {
<div style={{ marginTop: 20, width: '100%' }}>
<MuiThemeProvider theme={getMuiTheme()}>
<MUIDataTable
data={this.state.dataTable}
data={dataTable2}
columns={columns}
options={options}
/>
......
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