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

push

parent 87576ef4
......@@ -75,6 +75,7 @@ export default class CreateMasterDataCAT extends Component {
maxAchDisable: true,
listPeriode: null,
// periode: null,
getParent: []
}
}
......@@ -135,20 +136,21 @@ export default class CreateMasterDataCAT extends Component {
getParentIR() {
let payload = {
"report_id":3,
"years":this.state.periode.periode
"report_id": 3,
"years": this.state.periode.periode
}
api.create().getParentItemReport(payload).then(response => {
console.log(payload)
console.log(response)
if (response.data) {
if (response.data.status === "success") {
response.data.data.map((item) => {
console.log(item.description)
this.setState({
itemReport1 : String(item.description).toLocaleLowerCase().includes("financial").tolocal ? item.description : null
})
})
this.setState({ getParent: response.data.data.filter((val) => String(val.type_item_report_name).toLocaleLowerCase() != 'break')})
// response.data.data.map((item) => {
// console.log(item.description)
// this.setState({
// itemReport1: String(item.description).toLocaleLowerCase().includes("financial").tolocal ? item.description : null
// })
// })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
......@@ -157,70 +159,79 @@ export default class CreateMasterDataCAT extends Component {
})
}
handleChange(e, type) {
let data = this.state
let isDate = type !== '' ? true : false
if (isDate && type === 'start_date') {
this.setState({
...data, startDate: format(e, 'yyyy-MM-dd'), endDate: null,
errorOrder: false,
errorDesc: false,
errorFormula: false,
errorRV: false,
errorStartDate: false,
errorEndDate: false,
errorTipeData: false,
errorCondition: false,
msgErrorTipeData: '',
msgErrorCondition: '',
msgErrorOrder: '',
msgErrorDesc: '',
msgErrorFormula: '',
msgErrorRV: '',
msgErrorSD: '',
msgErrorED: '',
})
} else if (isDate && type === 'end_date') {
this.setState({
...data, endDate: format(e, 'yyyy-MM-dd'),
errorOrder: false,
errorDesc: false,
errorFormula: false,
errorRV: false,
errorStartDate: false,
errorEndDate: false,
errorTipeData: false,
errorCondition: false,
msgErrorTipeData: '',
msgErrorCondition: '',
msgErrorOrder: '',
msgErrorDesc: '',
msgErrorFormula: '',
msgErrorRV: '',
msgErrorSD: '',
msgErrorED: '',
})
} else {
this.setState({
...data, [e.target.name]: e.target.value,
errorOrder: false,
errorDesc: false,
errorFormula: false,
errorRV: false,
errorStartDate: false,
errorEndDate: false,
errorTipeData: false,
errorCondition: false,
msgErrorTipeData: '',
msgErrorCondition: '',
msgErrorOrder: '',
msgErrorDesc: '',
msgErrorFormula: '',
msgErrorRV: '',
msgErrorSD: '',
msgErrorED: '',
handleChange(e, item) {
// let data = this.state
// let isDate = type !== '' ? true : false
let dataSource = this.state.getParent
let indexID = dataSource.findIndex((val) => val.item_report_id == item.item_report_id)
// console.log(indexID)
if (indexID != -1) {
dataSource[indexID].weight = e.target.value
this.setState({getParent: dataSource}, () => {
console.log(this.state.getParent);
})
}
// if (isDate && type === 'start_date') {
// this.setState({
// ...data, startDate: format(e, 'yyyy-MM-dd'), endDate: null,
// errorOrder: false,
// errorDesc: false,
// errorFormula: false,
// errorRV: false,
// errorStartDate: false,
// errorEndDate: false,
// errorTipeData: false,
// errorCondition: false,
// msgErrorTipeData: '',
// msgErrorCondition: '',
// msgErrorOrder: '',
// msgErrorDesc: '',
// msgErrorFormula: '',
// msgErrorRV: '',
// msgErrorSD: '',
// msgErrorED: '',
// })
// } else if (isDate && type === 'end_date') {
// this.setState({
// ...data, endDate: format(e, 'yyyy-MM-dd'),
// errorOrder: false,
// errorDesc: false,
// errorFormula: false,
// errorRV: false,
// errorStartDate: false,
// errorEndDate: false,
// errorTipeData: false,
// errorCondition: false,
// msgErrorTipeData: '',
// msgErrorCondition: '',
// msgErrorOrder: '',
// msgErrorDesc: '',
// msgErrorFormula: '',
// msgErrorRV: '',
// msgErrorSD: '',
// msgErrorED: '',
// })
// } else {
// this.setState({
// ...data, [e.target.name]: e.target.value,
// errorOrder: false,
// errorDesc: false,
// errorFormula: false,
// errorRV: false,
// errorStartDate: false,
// errorEndDate: false,
// errorTipeData: false,
// errorCondition: false,
// msgErrorTipeData: '',
// msgErrorCondition: '',
// msgErrorOrder: '',
// msgErrorDesc: '',
// msgErrorFormula: '',
// msgErrorRV: '',
// msgErrorSD: '',
// msgErrorED: '',
// })
// }
}
validasi() {
......@@ -657,8 +668,11 @@ export default class CreateMasterDataCAT extends Component {
</div>
</div>
{this.state.getParent.map((item, index) => {
return (
<div>
<div style={{ borderBottom: 'solid 1px #c4c4c4', margin: 20, marginBottom: 10 }} >
<Typography style={{ fontSize: '12px', color: '#4b4b4b', padding: 10, fontWeight: 'bold' }}>Item Report - 1</Typography>
<Typography style={{ fontSize: '12px', color: '#4b4b4b', padding: 10, fontWeight: 'bold' }}>{`Item Report - ${index + 1}`}</Typography>
</div>
<div className="grid grid-2x grid-mobile-none gap-15px" style={{ paddingLeft: 20, paddingRight: 20 }}>
......@@ -666,7 +680,7 @@ export default class CreateMasterDataCAT extends Component {
<div className="margin-top-10px" style={{ backgroundColor: '#e8e8e8', padding: 10, borderRadius: 5 }}>
<TextField
style={{ width: '100%' }}
value={'-'}
value={item.item_report_id}
id="ID"
label="ID"
disabled
......@@ -696,7 +710,7 @@ export default class CreateMasterDataCAT extends Component {
disabled
// onChange={(e) => this.handleChange(e, null)}
// value={this.state.order}
value={'CAT'}
value={item.report_name}
// error={this.state.errorOrder}
// helperText={this.state.msgErrorOrder}
inputProps={{
......@@ -730,7 +744,7 @@ export default class CreateMasterDataCAT extends Component {
disabled
// onChange={(e) => this.handleChange(e, null)}
// value={this.state.order}
value={'item report name'}
value={item.description}
// error={this.state.errorOrder}
// helperText={this.state.msgErrorOrder}
inputProps={{
......@@ -758,8 +772,8 @@ export default class CreateMasterDataCAT extends Component {
id="weight1"
name="weight1"
label="Weight"
value={this.state.weight}
onChange={(e) => this.handleChange(e, '')}
value={item.weight}
onChange={(e) => this.handleChange(e, item)}
inputProps={{
style: {
fontSize: 11,
......@@ -778,8 +792,12 @@ export default class CreateMasterDataCAT extends Component {
</div>
</div>
</div>
</div>
)
})}
<div style={{ borderBottom: 'solid 1px #c4c4c4', margin: 20, marginBottom: 10 }} >
{/* <div style={{ borderBottom: 'solid 1px #c4c4c4', margin: 20, marginBottom: 10 }} >
<Typography style={{ fontSize: '12px', color: '#4b4b4b', padding: 10, fontWeight: 'bold' }}>Item Report - 2</Typography>
</div>
......@@ -1143,7 +1161,7 @@ export default class CreateMasterDataCAT extends Component {
</TextField>
</div>
</div>
</div>
</div> */}
<div className="grid grid-2x grid-mobile-none gap-15px" style={{ paddingLeft: 20, paddingRight: 20 }}>
<div className="column-1">
......
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