Commit 30ed4bca authored by EKSAD's avatar EKSAD

update PL

parent b5992264
......@@ -56,8 +56,11 @@ export default class ProfitLoss extends Component {
if (response.data.status === "success") {
let dataTable = []
response.data.data.map((item, index) => {
if (item.children.length > 0) {
if (item.children && item.children.length > 0) {
dataTable.push([
item.type_report_id,
item.id,
item.parent,
item.level,
item.description
])
......@@ -65,23 +68,35 @@ export default class ProfitLoss extends Component {
if (i.children) {
if (i.children.length > 0) {
dataTable.push([
i.type_report_id,
i.id,
i.parent,
i.level,
i.description
])
i.children.map(val => {
dataTable.push([
val.type_report_id,
val.id,
val.parent,
val.level,
val.description
])
})
} else {
dataTable.push([
i.type_report_id,
i.id,
i.parent,
i.level,
i.description
])
}
} else {
dataTable.push([
i.type_report_id,
i.id,
i.parent,
i.level,
i.description
])
......@@ -89,6 +104,9 @@ export default class ProfitLoss extends Component {
})
} else {
dataTable.push([
item.type_report_id,
item.id,
item.parent,
item.level,
item.description
])
......@@ -101,14 +119,34 @@ export default class ProfitLoss extends Component {
})
}
handleValue(data) {
let total = 0
this.state.dataTable.map((item,index) => {
if (data.rowData[1] == item[2]) {
total = item[6] == undefined? (total + 0) : (total + item[6])
}
})
let indexParent = this.state.dataTable.findIndex((val) => val[1] == this.state.dataTable[data.rowIndex][2])
let a = this.state.dataTable[data.rowIndex][data.columnIndex] = total
// console.log(indexParent);
return a
}
handleChange(value, tableMeta) {
let data = this.state.dataTable
let a = data[tableMeta.rowIndex][tableMeta.columnIndex] = value
this.setState({
data: a
}, () => console.log(this.state.dataTable))
// let a = data[0].tableMeta.tableData[tableMeta.rowIndex] === value
// console.log(data)
let indexParent = data.findIndex((val) => val[1] == data[tableMeta.rowIndex][2])
// console.log(indexParent);
if (indexParent > 0) {
let a = data[tableMeta.rowIndex][tableMeta.columnIndex] = Number(value)
let jagain = data[indexParent][tableMeta.columnIndex]
a = data[indexParent][tableMeta.columnIndex] = jagain == undefined? (0 + Number(value)) : (jagain + Number(value))
} else {
let a = data[tableMeta.rowIndex][tableMeta.columnIndex] = Number(value)
}
// this.setState({
// data: a,
// }, () => console.log(this.state.dataTable))
}
render() {
......@@ -117,7 +155,22 @@ export default class ProfitLoss extends Component {
options: {
display: false
}
}, {
},{
name: "",
options: {
display: false
}
},{
name: "",
options: {
display: false
}
},{
name: "",
options: {
display: false
}
},{
name: "Account",
options: {
customHeadRender: (columnMeta) => (
......@@ -129,10 +182,10 @@ export default class ProfitLoss extends Component {
customBodyRender: (val, tableMeta) => {
return (
<div style={{ width: 388 }}>
{tableMeta.rowData[0] == 0 ?
{tableMeta.rowData[3] == 0 ?
<span style={{ fontSize: 12, fontWeight: 'bold' }}>{String(val).toUpperCase()}</span>
:
tableMeta.rowData[0] === 1?
tableMeta.rowData[3] === 1?
<span style={{ fontSize: 12, marginLeft: 20 }}>{val}</span> :
<span style={{ fontSize: 12, marginLeft: 40 }}>{val}</span>
}
......@@ -168,25 +221,12 @@ export default class ProfitLoss extends Component {
customBodyRender: (value, tableMeta, updateValue) => {
return (
<div style={{ textAlign: 'right' }}>
{tableMeta.rowIndex === 3 || tableMeta.rowIndex === 4 || tableMeta.rowIndex === 9 ?
{tableMeta.rowData[0] === 4 ?
<div style={{ flex: 1 }}>
<FormControlLabel
style={{ margin: 0 }}
value={value}
control={
// <Input
// value={this.formatValue(value)}
// style={{}}
// inputProps={{
// style: {
// color: "#5198ea",
// fontSize: 12,
// textAlign: 'right'
// }
// }}
// disableUnderline={true}
// inputStyle={{ color: 'red' }}
// />
<NumberFormat
thousandSeparator={true}
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
......@@ -194,6 +234,7 @@ export default class ProfitLoss extends Component {
placeholder=""
value={value}
onChange={event => {
// console.log(event.target)
updateValue(event.target.value)
this.handleChange(event.target.value, tableMeta)
}}
......@@ -201,7 +242,13 @@ export default class ProfitLoss extends Component {
}
/>
</div> :
<span style={{ fontSize: 12, textAlign: 'right' }}>{value === "" ? "-" : value}</span>
tableMeta.rowData[0] === 2 ?
<span style={{ fontSize: 12, textAlign: 'right' }}>{this.handleValue(tableMeta)}</span>
:
tableMeta.rowData[0] === 1 ?
<span>-</span>
:
<span>validasi</span>
}
</div>
)
......
......@@ -666,7 +666,7 @@ export default class ReportItems extends Component {
}
},
{
name: "Company",
name: "Company Name",
options: {
customBodyRender: (val, tableMeta) => {
return (
......
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