Commit 7e0381a9 authored by EKSAD's avatar EKSAD

apdet

parent 717da1a7
...@@ -465,12 +465,11 @@ export default class ReportItems extends Component { ...@@ -465,12 +465,11 @@ export default class ReportItems extends Component {
openPopUp(index, type) { openPopUp(index, type) {
if (type === 'edit') { if (type === 'edit') {
this.setState({ this.setState({
selectIndex: index, rowData: index,
edit: true edit: true
}) })
} else { } else {
this.setState({ this.setState({
data: this.state.listData[index],
add: true add: true
}) })
} }
...@@ -564,6 +563,7 @@ export default class ReportItems extends Component { ...@@ -564,6 +563,7 @@ export default class ReportItems extends Component {
const columns = [{ const columns = [{
name: "Action", name: "Action",
options: { options: {
sort: false,
customBodyRender: (val, tableMeta) => { customBodyRender: (val, tableMeta) => {
return ( return (
<div style={{ display: 'flex' }}> <div style={{ display: 'flex' }}>
...@@ -573,7 +573,7 @@ export default class ReportItems extends Component { ...@@ -573,7 +573,7 @@ export default class ReportItems extends Component {
cursor: 'pointer', cursor: 'pointer',
borderColor: 'transparent' borderColor: 'transparent'
}} }}
onClick={() => this.openPopUp(tableMeta.rowIndex, 'edit')} onClick={() => this.openPopUp(tableMeta.rowData, 'edit')}
> >
<img src={Images.editCopy} /> <img src={Images.editCopy} />
...@@ -875,7 +875,7 @@ export default class ReportItems extends Component { ...@@ -875,7 +875,7 @@ export default class ReportItems extends Component {
{this.state.edit && ( {this.state.edit && (
<EditReportItems <EditReportItems
onClickClose={() => this.setState({ edit: false })} onClickClose={() => this.setState({ edit: false })}
data={this.state.listData[this.state.selectIndex]} data={this.state.rowData}
refresh={this.getData.bind(this)} refresh={this.getData.bind(this)}
updateReportItems={this.updateReportItems.bind(this)} updateReportItems={this.updateReportItems.bind(this)}
/> />
......
...@@ -55,6 +55,12 @@ export default class CreateReportItems extends Component { ...@@ -55,6 +55,12 @@ export default class CreateReportItems extends Component {
this.getPerusahaan() this.getPerusahaan()
this.getReportType() this.getReportType()
// this.getParent() // 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 { ...@@ -269,7 +275,6 @@ export default class CreateReportItems extends Component {
} }
render() { render() {
const { startDate, endDate } = this.state;
return ( return (
<div className="test app-popup-show"> <div className="test app-popup-show">
......
...@@ -53,7 +53,6 @@ export default class EditReportItems extends Component { ...@@ -53,7 +53,6 @@ export default class EditReportItems extends Component {
} }
componentDidMount() { componentDidMount() {
// console.log(this.props.data);
this.getDetailReportItems(); this.getDetailReportItems();
} }
...@@ -124,7 +123,15 @@ export default class EditReportItems extends Component { ...@@ -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)) { 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'}) 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() this.updateReportItems()
} }
...@@ -149,18 +156,20 @@ export default class EditReportItems extends Component { ...@@ -149,18 +156,20 @@ export default class EditReportItems extends Component {
"end_date": this.state.tempData.end_date "end_date": this.state.tempData.end_date
} }
console.log(payload) console.log(payload)
api.create().updateReportItems(payload).then((response) => { // api.create().updateReportItems(payload).then((response) => {
if (response.data.status === 'success') { // if (response.data) {
this.props.onClickClose() // if (response.data.status === 'success') {
this.props.refresh() // this.props.onClickClose()
} else { // this.props.refresh()
alert(response.data.message) // } else {
} // alert(response.data.message)
}) // }
// }
// })
} }
getDetailReportItems() { 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') { if (response.data.status === 'success') {
this.setState({ tempData: response.data.data}, () => this.getInputType(), this.getPerusahaan(), this.getReportType(),) this.setState({ tempData: response.data.data}, () => this.getInputType(), this.getPerusahaan(), this.getReportType(),)
console.log(response.data.data) console.log(response.data.data)
...@@ -235,7 +244,7 @@ export default class EditReportItems extends Component { ...@@ -235,7 +244,7 @@ export default class EditReportItems extends Component {
}; };
let index = reportTypeData.findIndex((val) => val.report_id === this.state.tempData.report_id) 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 { } else {
alert(response.data.message) alert(response.data.message)
} }
...@@ -511,7 +520,12 @@ export default class EditReportItems extends Component { ...@@ -511,7 +520,12 @@ export default class EditReportItems extends Component {
<Autocomplete <Autocomplete
{...this.state.listInputType} {...this.state.listInputType}
id="inputType" 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 debug
renderInput={(params) => renderInput={(params) =>
<TextField {...params} <TextField {...params}
...@@ -566,6 +580,8 @@ export default class EditReportItems extends Component { ...@@ -566,6 +580,8 @@ export default class EditReportItems extends Component {
style={{ width: '100%' }} style={{ width: '100%' }}
id="condition_it_should_be" id="condition_it_should_be"
label="Nilai Seharusnya" 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)} disabled={this.state.InputType == null? true : (this.state.InputType.type_report_name === 'Validation'? false : true)}
name="condition_it_should_be" name="condition_it_should_be"
onChange={(e) => this.handleChange(e, '')} 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