Commit 710caf29 authored by Deni Rinaldi's avatar Deni Rinaldi

isu aplot reaveneu

parent 266d8075
...@@ -62,7 +62,8 @@ export default class ProfitLoss extends Component { ...@@ -62,7 +62,8 @@ export default class ProfitLoss extends Component {
judulColumn: null, judulColumn: null,
updateBy: '-', updateBy: '-',
buttonDraft: true, buttonDraft: true,
handleTekTekTek: 0 handleTekTekTek: 0,
fromUpload: false
} }
this.handleValue = this.handleValue.bind(this) this.handleValue = this.handleValue.bind(this)
this.fileHandler = this.fileHandler.bind(this); this.fileHandler = this.fileHandler.bind(this);
...@@ -338,7 +339,7 @@ export default class ProfitLoss extends Component { ...@@ -338,7 +339,7 @@ export default class ProfitLoss extends Component {
checkUpload() { checkUpload() {
api.create().checkUploadMB(this.state.payload).then(response => { api.create().checkUploadMB(this.state.payload).then(response => {
// console.log(JSON.stringify(this.state.payload)); // console.log(JSON.stringify(this.state.payload));
// console.log(response) console.log(response)
if (response.data) { if (response.data) {
if (response.data.status === 'success') { if (response.data.status === 'success') {
this.setState({ visibleUpload: false, visibleProfitLoss: false, loading: true }) this.setState({ visibleUpload: false, visibleProfitLoss: false, loading: true })
...@@ -371,7 +372,7 @@ export default class ProfitLoss extends Component { ...@@ -371,7 +372,7 @@ export default class ProfitLoss extends Component {
item.error item.error
] ]
}) })
this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: false, editable: true }, () => { this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: false, editable: true, fromUpload: true}, () => {
this.state.dataTable.map(item => { this.state.dataTable.map(item => {
if (item[24].length > 0) { if (item[24].length > 0) {
// console.log('masuk') // console.log('masuk')
...@@ -545,17 +546,21 @@ export default class ProfitLoss extends Component { ...@@ -545,17 +546,21 @@ export default class ProfitLoss 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 handleValue = (data) => { const handleValue = (value, data) => {
let total = 0 let total = 0
dataTable2.map((item, index) => { if (this.state.fromUpload) {
if (data.rowData[1] == item[2]) { return value
total = item[data.columnIndex] == undefined ? (Number(total) + 0) : (Number(total) + Number(item[data.columnIndex])) } else {
} dataTable2.map((item, index) => {
}) if (data.rowData[1] == item[2]) {
let indexParent = dataTable2.findIndex((val) => val[1] == dataTable2[data.rowIndex][2]) total = item[data.columnIndex] == undefined ? (Number(total) + 0) : (Number(total) + Number(item[data.columnIndex]))
let a = dataTable2[data.rowIndex][data.columnIndex] = Number(total) }
// console.log(indexParent); })
return a let indexParent = dataTable2.findIndex((val) => val[1] == dataTable2[data.rowIndex][2])
let a = dataTable2[data.rowIndex][data.columnIndex] = Number(total)
// console.log(indexParent);
return a
}
} }
const handleFormula = (data, tableMeta, month) => { const handleFormula = (data, tableMeta, month) => {
let arrayFormula = tableMeta.rowData[3].match(/[a-zA-Z]+|[0-9]+|[-!$%^&*()_+|~=`{}\[\]:";'<>?,.\/]+(?:\.[0-9]+@|)/g) let arrayFormula = tableMeta.rowData[3].match(/[a-zA-Z]+|[0-9]+|[-!$%^&*()_+|~=`{}\[\]:";'<>?,.\/]+(?:\.[0-9]+@|)/g)
...@@ -853,7 +858,7 @@ export default class ProfitLoss extends Component { ...@@ -853,7 +858,7 @@ export default class ProfitLoss extends Component {
type="text" type="text"
placeholder="" placeholder=""
disabled={true} disabled={true}
value={Number(handleValue(tableMeta)).toFixed(1)} value={Number(handleValue(value,tableMeta)).toFixed(1)}
/> />
</span> </span>
: :
...@@ -972,7 +977,7 @@ export default class ProfitLoss extends Component { ...@@ -972,7 +977,7 @@ export default class ProfitLoss extends Component {
type="text" type="text"
placeholder="" placeholder=""
disabled={true} disabled={true}
value={Number(handleValue(tableMeta)).toFixed(1)} value={Number(handleValue(value,tableMeta)).toFixed(1)}
/> />
</span> </span>
: :
...@@ -1101,7 +1106,7 @@ export default class ProfitLoss extends Component { ...@@ -1101,7 +1106,7 @@ export default class ProfitLoss extends Component {
type="text" type="text"
placeholder="" placeholder=""
disabled={true} disabled={true}
value={Number(handleValue(tableMeta)).toFixed(1)} value={Number(handleValue(value,tableMeta)).toFixed(1)}
/> />
</span> </span>
: :
...@@ -1230,7 +1235,7 @@ export default class ProfitLoss extends Component { ...@@ -1230,7 +1235,7 @@ export default class ProfitLoss extends Component {
type="text" type="text"
placeholder="" placeholder=""
disabled={true} disabled={true}
value={Number(handleValue(tableMeta)).toFixed(1)} value={Number(handleValue(value,tableMeta)).toFixed(1)}
/> />
</span> </span>
: :
...@@ -1359,7 +1364,7 @@ export default class ProfitLoss extends Component { ...@@ -1359,7 +1364,7 @@ export default class ProfitLoss extends Component {
type="text" type="text"
placeholder="" placeholder=""
disabled={true} disabled={true}
value={Number(handleValue(tableMeta)).toFixed(1)} value={Number(handleValue(value,tableMeta)).toFixed(1)}
/> />
</span> </span>
: :
...@@ -1488,7 +1493,7 @@ export default class ProfitLoss extends Component { ...@@ -1488,7 +1493,7 @@ export default class ProfitLoss extends Component {
type="text" type="text"
placeholder="" placeholder=""
disabled={true} disabled={true}
value={Number(handleValue(tableMeta)).toFixed(1)} value={Number(handleValue(value,tableMeta)).toFixed(1)}
/> />
</span> </span>
: :
...@@ -1617,7 +1622,7 @@ export default class ProfitLoss extends Component { ...@@ -1617,7 +1622,7 @@ export default class ProfitLoss extends Component {
type="text" type="text"
placeholder="" placeholder=""
disabled={true} disabled={true}
value={Number(handleValue(tableMeta)).toFixed(1)} value={Number(handleValue(value,tableMeta)).toFixed(1)}
/> />
</span> </span>
: :
...@@ -1746,7 +1751,7 @@ export default class ProfitLoss extends Component { ...@@ -1746,7 +1751,7 @@ export default class ProfitLoss extends Component {
type="text" type="text"
placeholder="" placeholder=""
disabled={true} disabled={true}
value={Number(handleValue(tableMeta)).toFixed(1)} value={Number(handleValue(value,tableMeta)).toFixed(1)}
/> />
</span> </span>
: :
...@@ -1875,7 +1880,7 @@ export default class ProfitLoss extends Component { ...@@ -1875,7 +1880,7 @@ export default class ProfitLoss extends Component {
type="text" type="text"
placeholder="" placeholder=""
disabled={true} disabled={true}
value={Number(handleValue(tableMeta)).toFixed(1)} value={Number(handleValue(value,tableMeta)).toFixed(1)}
/> />
</span> </span>
: :
...@@ -2004,7 +2009,7 @@ export default class ProfitLoss extends Component { ...@@ -2004,7 +2009,7 @@ export default class ProfitLoss extends Component {
type="text" type="text"
placeholder="" placeholder=""
disabled={true} disabled={true}
value={Number(handleValue(tableMeta)).toFixed(1)} value={Number(handleValue(value,tableMeta)).toFixed(1)}
/> />
</span> </span>
: :
...@@ -2133,7 +2138,7 @@ export default class ProfitLoss extends Component { ...@@ -2133,7 +2138,7 @@ export default class ProfitLoss extends Component {
type="text" type="text"
placeholder="" placeholder=""
disabled={true} disabled={true}
value={Number(handleValue(tableMeta)).toFixed(1)} value={Number(handleValue(value,tableMeta)).toFixed(1)}
/> />
</span> </span>
: :
...@@ -2262,7 +2267,7 @@ export default class ProfitLoss extends Component { ...@@ -2262,7 +2267,7 @@ export default class ProfitLoss extends Component {
type="text" type="text"
placeholder="" placeholder=""
disabled={true} disabled={true}
value={Number(handleValue(tableMeta)).toFixed(1)} value={Number(handleValue(value,tableMeta)).toFixed(1)}
/> />
</span> </span>
: :
...@@ -2370,7 +2375,7 @@ export default class ProfitLoss extends Component { ...@@ -2370,7 +2375,7 @@ export default class ProfitLoss extends Component {
type="text" type="text"
placeholder="" placeholder=""
disabled={true} disabled={true}
value={Number(handleValue(tableMeta)).toFixed(1)} value={Number(handleValue(value,tableMeta)).toFixed(1)}
/> />
</span> : </span> :
// tableMeta.rowData[0] === 6 ? // tableMeta.rowData[0] === 6 ?
...@@ -2477,7 +2482,7 @@ export default class ProfitLoss extends Component { ...@@ -2477,7 +2482,7 @@ export default class ProfitLoss extends Component {
type="text" type="text"
placeholder="" placeholder=""
disabled={true} disabled={true}
value={Number(handleValue(tableMeta)).toFixed(1)} value={Number(handleValue(value,tableMeta)).toFixed(1)}
/> />
</span> </span>
: :
...@@ -2606,7 +2611,7 @@ export default class ProfitLoss extends Component { ...@@ -2606,7 +2611,7 @@ export default class ProfitLoss extends Component {
type="text" type="text"
placeholder="" placeholder=""
disabled={true} disabled={true}
value={Number(handleValue(tableMeta)).toFixed(1)} value={Number(handleValue(value,tableMeta)).toFixed(1)}
/> />
</span> </span>
: :
...@@ -2916,7 +2921,7 @@ export default class ProfitLoss extends Component { ...@@ -2916,7 +2921,7 @@ export default class ProfitLoss extends Component {
<div className="col-1"> <div className="col-1">
<button <button
type="button" type="button"
onClick={() => this.setState({ loading: true, dataTable: [] }, () => { onClick={() => this.setState({ loading: true, dataTable: [], fromUpload: false }, () => {
setTimeout(() => { setTimeout(() => {
this.getItemHierarki() this.getItemHierarki()
}, 100); }, 100);
...@@ -2964,7 +2969,7 @@ export default class ProfitLoss extends Component { ...@@ -2964,7 +2969,7 @@ export default class ProfitLoss extends Component {
onClick={() => onClick={() =>
this.state.editable === true ? this.state.editable === true ?
null : null :
this.setState({ loading: true }, () => this.setState({ loading: true, fromUpload: false }, () =>
this.state.handleTekTekTek == 1 ? null : this.state.handleTekTekTek == 1 ? null :
this.setState({ handleTekTekTek: 1 }, () => { this.setState({ handleTekTekTek: 1 }, () => {
setTimeout(() => { setTimeout(() => {
...@@ -2989,7 +2994,7 @@ export default class ProfitLoss extends Component { ...@@ -2989,7 +2994,7 @@ export default class ProfitLoss extends Component {
onClick={() => onClick={() =>
this.state.editable === true ? this.state.editable === true ?
null : null :
this.setState({ loading: true }, () => this.setState({ loading: true, fromUpload: false }, () =>
this.state.handleTekTekTek == 1 ? null : this.state.handleTekTekTek == 1 ? null :
this.setState({ handleTekTekTek: 1 }, () => { this.setState({ handleTekTekTek: 1 }, () => {
setTimeout(() => { setTimeout(() => {
......
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