Commit 7e0381a9 authored by EKSAD's avatar EKSAD

apdet

parent 717da1a7
......@@ -465,12 +465,11 @@ export default class ReportItems extends Component {
openPopUp(index, type) {
if (type === 'edit') {
this.setState({
selectIndex: index,
rowData: index,
edit: true
})
} else {
this.setState({
data: this.state.listData[index],
add: true
})
}
......@@ -564,6 +563,7 @@ export default class ReportItems extends Component {
const columns = [{
name: "Action",
options: {
sort: false,
customBodyRender: (val, tableMeta) => {
return (
<div style={{ display: 'flex' }}>
......@@ -573,7 +573,7 @@ export default class ReportItems extends Component {
cursor: 'pointer',
borderColor: 'transparent'
}}
onClick={() => this.openPopUp(tableMeta.rowIndex, 'edit')}
onClick={() => this.openPopUp(tableMeta.rowData, 'edit')}
>
<img src={Images.editCopy} />
......@@ -875,7 +875,7 @@ export default class ReportItems extends Component {
{this.state.edit && (
<EditReportItems
onClickClose={() => this.setState({ edit: false })}
data={this.state.listData[this.state.selectIndex]}
data={this.state.rowData}
refresh={this.getData.bind(this)}
updateReportItems={this.updateReportItems.bind(this)}
/>
......
......@@ -55,6 +55,12 @@ export default class CreateReportItems extends Component {
this.getPerusahaan()
this.getReportType()
// this.getParent()
let date = format(new Date, 'yyyy-MM-dd')
console.log(date);
this.setState({
startDate: date,
endDate: date
})
}
......@@ -269,7 +275,6 @@ export default class CreateReportItems extends Component {
}
render() {
const { startDate, endDate } = this.state;
return (
<div className="test app-popup-show">
......
......@@ -53,7 +53,6 @@ export default class EditReportItems extends Component {
}
componentDidMount() {
// console.log(this.props.data);
this.getDetailReportItems();
}
......@@ -124,7 +123,15 @@ export default class EditReportItems extends Component {
else if (this.state.InputType.type_report_name === 'Formula' || this.state.InputType.type_report_name === 'Validation' && R.isEmpty(this.state.tempData.formula)) {
this.setState({errorFormula: true, msgErrorFormula: 'Formula Harus Diisi'})
}
else {
else if (this.state.InputType.type_report_name === 'Validation' && R.isEmpty(this.state.tempData.condition_it_should_be)) {
this.setState({errorRV: true, msgErrorRV: 'Nilai Seharusnya Harus Diisi'})
}
else if (this.state.InputType.type_report_name === 'Validation' && R.isNil(this.state.condition)) return alert("Kondisi Jika Salah is Required.");
else if (R.isNil(this.state.tempData.start_date)) {
this.setState({ errorStartDate: true, msgErrorSD: 'Start Date Harus Diisi' })
} else if (R.isNil(this.state.tempData.end_date)) {
this.setState({ errorEndDate: true, msgErrorED: 'End Date Harus Diisi' })
} else {
this.updateReportItems()
}
......@@ -149,18 +156,20 @@ export default class EditReportItems extends Component {
"end_date": this.state.tempData.end_date
}
console.log(payload)
api.create().updateReportItems(payload).then((response) => {
if (response.data.status === 'success') {
this.props.onClickClose()
this.props.refresh()
} else {
alert(response.data.message)
}
})
// api.create().updateReportItems(payload).then((response) => {
// if (response.data) {
// if (response.data.status === 'success') {
// this.props.onClickClose()
// this.props.refresh()
// } else {
// alert(response.data.message)
// }
// }
// })
}
getDetailReportItems() {
api.create().getDetailReportItems(this.props.data.item_report_id).then((response) => {
api.create().getDetailReportItems(this.props.data[1]).then((response) => {
if (response.data.status === 'success') {
this.setState({ tempData: response.data.data}, () => this.getInputType(), this.getPerusahaan(), this.getReportType(),)
console.log(response.data.data)
......@@ -235,7 +244,7 @@ export default class EditReportItems extends Component {
};
let index = reportTypeData.findIndex((val) => val.report_id === this.state.tempData.report_id)
this.setState({listReportType: defaultProps, reportType: index === -1 ? null: reportTypeData[index]})
this.setState({listReportType: defaultProps, reportType: index === -1 ? null: reportTypeData[index]}, () => this.getParent())
} else {
alert(response.data.message)
}
......@@ -511,7 +520,12 @@ export default class EditReportItems extends Component {
<Autocomplete
{...this.state.listInputType}
id="inputType"
onChange={(event, newInputValue) => this.setState({InputType: newInputValue}, () => console.log(this.state.InputType))}
onChange={(event, newInputValue) =>
this.setState({InputType: newInputValue,
tempData: {...this.state.tempData, formula: '', condition_it_should_be: '', condition_if_wrong: ''},
errorFormula: false, msgErrorFormula: '',
errorRV: false, msgErrorRV: ''},
() => console.log(this.state.InputType))}
debug
renderInput={(params) =>
<TextField {...params}
......@@ -566,6 +580,8 @@ export default class EditReportItems extends Component {
style={{ width: '100%' }}
id="condition_it_should_be"
label="Nilai Seharusnya"
error={this.state.errorRV}
helperText={this.state.msgErrorRV}
disabled={this.state.InputType == null? true : (this.state.InputType.type_report_name === 'Validation'? false : true)}
name="condition_it_should_be"
onChange={(e) => this.handleChange(e, '')}
......
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