Commit 40c36111 authored by d.arizona's avatar d.arizona

Merge branch 'master' of http://103.44.149.204/d.arizona/tia-dev into didam

parents 531b7efe 438eb1c7
...@@ -414,6 +414,7 @@ export default class ReportItems extends Component { ...@@ -414,6 +414,7 @@ export default class ReportItems extends Component {
<CreateReportItems <CreateReportItems
onClickClose={() => this.setState({ add: false })} onClickClose={() => this.setState({ add: false })}
data={this.state.listData} data={this.state.listData}
refresh={this.getData.bind(this)}
createReportItems={this.createReportItems.bind(this)} createReportItems={this.createReportItems.bind(this)}
/> />
)} )}
...@@ -421,6 +422,7 @@ export default class ReportItems extends Component { ...@@ -421,6 +422,7 @@ export default class ReportItems extends Component {
<EditReportItems <EditReportItems
onClickClose={() => this.setState({ edit: false })} onClickClose={() => this.setState({ edit: false })}
data={this.state.listData[this.state.selectIndex]} data={this.state.listData[this.state.selectIndex]}
refresh={this.getData.bind(this)}
updateReportItems={this.updateReportItems.bind(this)} updateReportItems={this.updateReportItems.bind(this)}
/> />
)} )}
......
...@@ -17,13 +17,14 @@ export default class CreateReportItems extends Component { ...@@ -17,13 +17,14 @@ export default class CreateReportItems extends Component {
reportType: null, reportType: null,
startDate: null, startDate: null,
endDate: null, endDate: null,
order: '', order: null,
description: '', description: '',
uom: '', uom: '',
weight: '', weight: null,
formula: '', formula: '',
realVal: '', realVal: '',
condition: '', condition: null,
inputValue: '',
date: new Date(), date: new Date(),
listInputType: null, listInputType: null,
listCompany: null, listCompany: null,
...@@ -33,16 +34,18 @@ export default class CreateReportItems extends Component { ...@@ -33,16 +34,18 @@ export default class CreateReportItems extends Component {
errorDesc: false, errorDesc: false,
errorFormula: false, errorFormula: false,
errorRV: false, errorRV: false,
errorCF: false,
errorStartDate: false, errorStartDate: false,
errorEndDate: false, errorEndDate: false,
msgErrorOrder: '', msgErrorOrder: '',
msgErrorDesc: '', msgErrorDesc: '',
msgErrorFormula: '', msgErrorFormula: '',
masgErrorRV: '', msgErrorRV: '',
msgErrorCF: '',
msgErrorSD: '', msgErrorSD: '',
msgErrorED: '', msgErrorED: '',
disabledFormula: true,
disabledCondt: true,
disabledValue: true,
options: ['WARNING', 'STOPPER']
} }
} }
...@@ -54,33 +57,52 @@ export default class CreateReportItems extends Component { ...@@ -54,33 +57,52 @@ export default class CreateReportItems extends Component {
this.getParent() this.getParent()
} }
handleChange(e, type) { handleChange(e, type) {
let data = this.state let data = this.state
let isDate = type !== ''? true : false let isDate = type !== ''? true : false
if (isDate && type === 'start_date') { if (isDate && type === 'start_date') {
this.setState({...data, startDate: format(e, 'yyyy-MM-dd'), endDate: null, this.setState({...data, startDate: format(e, 'yyyy-MM-dd'), endDate: null,
errorOrder: false, errorOrder: false,
errorDesc: false,
errorFormula: false,
errorRV: false,
errorStartDate: false, errorStartDate: false,
errorEndDate: false, errorEndDate: false,
msgErrorOrder: '', msgErrorOrder: '',
msgErrorDesc: '',
msgErrorFormula: '',
msgErrorRV: '',
msgErrorSD: '', msgErrorSD: '',
msgErrorED: '', msgErrorED: '',
}) })
} else if (isDate && type === 'end_date') { } else if (isDate && type === 'end_date') {
this.setState({...data, endDate : format(e, 'yyyy-MM-dd'), this.setState({...data, endDate : format(e, 'yyyy-MM-dd'),
errorOrder: false, errorOrder: false,
errorDesc: false,
errorFormula: false,
errorRV: false,
errorStartDate: false, errorStartDate: false,
errorEndDate: false, errorEndDate: false,
msgErrorOrder: '', msgErrorOrder: '',
msgErrorDesc: '',
msgErrorFormula: '',
msgErrorRV: '',
msgErrorSD: '', msgErrorSD: '',
msgErrorED: '', msgErrorED: '',
}) })
} else { } else {
this.setState({...data, [e.target.name]: e.target.value, this.setState({...data, [e.target.name]: e.target.value,
errorOrder: false, errorOrder: false,
errorDesc: false,
errorFormula: false,
errorRV: false,
errorStartDate: false, errorStartDate: false,
errorEndDate: false, errorEndDate: false,
msgErrorOrder: '', msgErrorOrder: '',
msgErrorDesc: '',
msgErrorFormula: '',
msgErrorRV: '',
msgErrorSD: '', msgErrorSD: '',
msgErrorED: '', msgErrorED: '',
}) })
...@@ -89,36 +111,62 @@ export default class CreateReportItems extends Component { ...@@ -89,36 +111,62 @@ export default class CreateReportItems extends Component {
validasi() { validasi() {
// alert('coba ya') // alert('coba ya')
if (R.isEmpty(this.state.order)) { if (R.isNil(this.state.reportType)) return alert("Jenis Laporan is Required.");
if (R.isNil(this.state.company)) return alert("Perusahaan is Required.");
else if (R.isNil(this.state.order)) {
this.setState({errorOrder: true, msgErrorOrder: 'Order Harus Diisi'}) this.setState({errorOrder: true, msgErrorOrder: 'Order Harus Diisi'})
} else if (R.isNil(this.state.startDate)) { }
else if (R.isEmpty(this.state.description)) {
this.setState({errorDesc: true, msgErrorDesc: 'Deskripsi Harus Diisi'})
}
else if (R.isNil(this.state.parent)) return alert("Parent ID is Required.")
else if (R.isNil(this.state.InputType)) return alert("Tipe Data is Required.");
else if (this.state.disabledFormula === false && R.isEmpty(this.state.formula)) {
this.setState({errorFormula: true, msgErrorFormula: 'Formula Harus Diisi'})
}
else if (this.state.disabledValue === false && R.isEmpty(this.state.realVal)) {
this.setState({errorRV: true, msgErrorRV: 'Nilai Seharusnya Harus Diisi'})
}
else if (this.state.disabledCondt === false && R.isEmpty(this.state.condition)) return alert("Kondisi Jika Salah is Required.")
else if (R.isNil(this.state.startDate)) {
this.setState({errorStartDate: true, msgErrorSD: 'Start Date tidak boleh kosong'}) this.setState({errorStartDate: true, msgErrorSD: 'Start Date tidak boleh kosong'})
} else if (R.isNil(this.state.endDate)) { }
else if (R.isNil(this.state.endDate)) {
this.setState({errorEndDate: true, msgErrorED: 'End Date tidak boleh kosong'}) this.setState({errorEndDate: true, msgErrorED: 'End Date tidak boleh kosong'})
} else { }
else {
this.addReportItems() this.addReportItems()
} }
} }
addReportItems() { addReportItems() {
alert("test") // alert("test")
// let payload = { let payload = {
// "role_name": this.state.roleName, "report_id": this.state.reportType.report_id,
// "start_date": this.state.startDate, "company_id": this.state.company.company_id,
// "end_date": this.state.endDate, "description": this.state.description,
// "privileges": this.state.privileges "orders": this.state.order,
// } "parent": this.state.parent.item_report_id,
// // console.log(payload) "type_report_id": this.state.InputType.type_report_id,
// api.create().addRole(payload).then((response) => { "formula": this.state.formula,
// console.log(response) "uom": this.state.uom,
// if (response.data.status === 'success') { "weight": this.state.weight,
// this.props.refresh() "condition_if_wrong": this.state.condition,
// this.props.onClickClose() "condition_it_should_be": this.state.realVal,
// } else { "start_date": this.state.startDate,
// alert(response.data.message) "end_date": this.state.endDate
// } }
// }) console.log(payload)
api.create().createReportItems(payload).then((response) => {
console.log(response)
if (response.data.status === 'success') {
this.props.onClickClose()
this.props.refresh()
} else {
alert(response.data.message)
}
})
} }
getInputType() { getInputType() {
...@@ -194,12 +242,13 @@ export default class CreateReportItems extends Component { ...@@ -194,12 +242,13 @@ export default class CreateReportItems extends Component {
let data = response.data.data let data = response.data.data
let parentData = data.map((item) => { let parentData = data.map((item) => {
return { return {
item_report_id: item.item_report_id item_report_id: item.item_report_id,
report_name: item.report_name
} }
}) })
let defaultProps = { let defaultProps = {
options: parentData, options: parentData,
getOptionLabel: (option) => titleCase(option.item_report_id), getOptionLabel: (option) => titleCase(option.report_name),
}; };
this.setState({listParent: defaultProps, parentData: response.data.data}) this.setState({listParent: defaultProps, parentData: response.data.data})
} else { } else {
...@@ -208,13 +257,18 @@ export default class CreateReportItems extends Component { ...@@ -208,13 +257,18 @@ export default class CreateReportItems extends Component {
}) })
} }
handleDate(item) {
let value = format(item, 'dd MMMM yyyy')
return value
}
render() { render() {
const { startDate, endDate } = this.state; const { startDate, endDate } = this.state;
return ( return (
<div className="test app-popup-show"> <div className="test app-popup-show">
<div className="popup-content background-white border-radius" style={{ borderRadius: 8 }}> <div className="popup-content background-white border-radius" style={{ borderRadius: 8 }}>
<div className="popup-panel grid grid-2x" style={{ backgroundColor: '#51c6ea', height: 64, borderTopRightRadius: 8, borderTopLeftRadius: 8 }}> <div className="popup-panel grid grid-2x main-color" style={{ height: 64, borderTopRightRadius: 8, borderTopLeftRadius: 8 }}>
<div className="col-1" style={{ maxWidth: "inherit", display: 'flex', alignItems: 'center' }}> <div className="col-1" style={{ maxWidth: "inherit", display: 'flex', alignItems: 'center' }}>
<div className="popup-title"> <div className="popup-title">
<span style={{ color: '#fff', fontSize: 16, fontWeight: 'bold' }}>Tambah Data</span> <span style={{ color: '#fff', fontSize: 16, fontWeight: 'bold' }}>Tambah Data</span>
...@@ -237,7 +291,7 @@ export default class CreateReportItems extends Component { ...@@ -237,7 +291,7 @@ export default class CreateReportItems extends Component {
<div className="margin-top-10px" style={{ backgroundColor: '#e8e8e8', padding: 10, borderRadius: 5 }}> <div className="margin-top-10px" style={{ backgroundColor: '#e8e8e8', padding: 10, borderRadius: 5 }}>
<TextField <TextField
style={{ width: '100%' }} style={{ width: '100%' }}
value={1} value={'-'}
id="ID" id="ID"
label="ID" label="ID"
disabled disabled
...@@ -285,6 +339,11 @@ export default class CreateReportItems extends Component { ...@@ -285,6 +339,11 @@ export default class CreateReportItems extends Component {
style={{ width: '100%' }} style={{ width: '100%' }}
id="description" id="description"
label="Deskripsi" label="Deskripsi"
name="description"
value={this.state.description}
error={this.state.errorDesc}
helperText={this.state.msgErrorDesc}
onChange={(e) => this.handleChange(e, '')}
// value={this.props.data.business_unit_name} // value={this.props.data.business_unit_name}
inputProps={{ inputProps={{
style: { style: {
...@@ -308,8 +367,10 @@ export default class CreateReportItems extends Component { ...@@ -308,8 +367,10 @@ export default class CreateReportItems extends Component {
<TextField <TextField
style={{ width: '100%' }} style={{ width: '100%' }}
id="uom" id="uom"
name="uom"
label="UOM" label="UOM"
// value={this.props.data.business_unit_name} value={this.state.uom}
onChange={(e) => this.handleChange(e, '')}
inputProps={{ inputProps={{
style: { style: {
fontSize: 11, fontSize: 11,
...@@ -332,7 +393,12 @@ export default class CreateReportItems extends Component { ...@@ -332,7 +393,12 @@ export default class CreateReportItems extends Component {
<Autocomplete <Autocomplete
{...this.state.listInputType} {...this.state.listInputType}
id="inputType" id="inputType"
onChange={(event, newInputValue) => this.setState({InputType: newInputValue})} onChange={(event, newInputValue) => this.setState({InputType: newInputValue},
() => newInputValue === null ? this.setState({disabledFormula: true, disabledCondt: true, disabledValue: true, formula: '', condition: '', realVal: ''})
: newInputValue.type_report_name === 'FORMULA' ? this.setState({disabledFormula: false, disabledCondt: true, disabledValue: true, formula: '', condition: '', realVal: ''})
: newInputValue.type_report_name === 'VALIDATION' ? this.setState({disabledFormula: false, disabledCondt: false, disabledValue: false, formula: '', condition: '', realVal: ''})
: this.setState({disabledFormula: true, disabledCondt: true, disabledValue: true, formula: '', condition: '', realVal: ''})
)}
debug debug
renderInput={(params) => renderInput={(params) =>
<TextField {...params} <TextField {...params}
...@@ -351,14 +417,17 @@ export default class CreateReportItems extends Component { ...@@ -351,14 +417,17 @@ export default class CreateReportItems extends Component {
/> />
</div> </div>
<div className="margin-top-10px" style={{ backgroundColor: '#e8e8e8', padding: 10, borderRadius: 5 }}> <div className="margin-top-10px" style={{padding: 10}}>
<TextField <TextField
style={{ width: '100%' }} style={{ width: '100%' }}
// value={this.props.data.status} id="realVal"
id="realValue"
label="Nilai Seharusnya" label="Nilai Seharusnya"
value="-" name="realVal"
disabled disabled={this.state.disabledValue}
value={this.state.realVal}
error={this.state.errorRV}
helperText={this.state.msgErrorRV}
onChange={(e) => this.handleChange(e, '')}
inputProps={{ inputProps={{
style: { style: {
fontSize: 11, fontSize: 11,
...@@ -411,7 +480,7 @@ export default class CreateReportItems extends Component { ...@@ -411,7 +480,7 @@ export default class CreateReportItems extends Component {
<div className="margin-top-10px" style={{ backgroundColor: '#e8e8e8', padding: 10, borderRadius: 5 }}> <div className="margin-top-10px" style={{ backgroundColor: '#e8e8e8', padding: 10, borderRadius: 5 }}>
<TextField <TextField
style={{ width: '100%' }} style={{ width: '100%' }}
value="Aktif" value={'Aktif'}
id="status" id="status"
label="Status" label="Status"
disabled disabled
...@@ -474,6 +543,7 @@ export default class CreateReportItems extends Component { ...@@ -474,6 +543,7 @@ export default class CreateReportItems extends Component {
id="orders" id="orders"
name="order" name="order"
label="Order" label="Order"
onChange={(e) => this.handleChange(e, '')}
value={this.state.order} value={this.state.order}
error={this.state.errorOrder} error={this.state.errorOrder}
helperText={this.state.msgErrorOrder} helperText={this.state.msgErrorOrder}
...@@ -523,7 +593,9 @@ export default class CreateReportItems extends Component { ...@@ -523,7 +593,9 @@ export default class CreateReportItems extends Component {
style={{ width: '100%' }} style={{ width: '100%' }}
id="weight" id="weight"
label="Weight" label="Weight"
// value="" name="weight"
value={this.state.weight}
onChange={(e) => this.handleChange(e, '')}
inputProps={{ inputProps={{
style: { style: {
fontSize: 11, fontSize: 11,
...@@ -547,7 +619,12 @@ export default class CreateReportItems extends Component { ...@@ -547,7 +619,12 @@ export default class CreateReportItems extends Component {
style={{ width: '100%' }} style={{ width: '100%' }}
id="formula" id="formula"
label="Formula" label="Formula"
// value="" name="formula"
disabled={this.state.disabledFormula}
value={this.state.formula}
error={this.state.errorFormula}
helperText={this.state.msgErrorFormula}
onChange={(e) => this.handleChange(e, '')}
inputProps={{ inputProps={{
style: { style: {
fontSize: 11, fontSize: 11,
...@@ -566,28 +643,28 @@ export default class CreateReportItems extends Component { ...@@ -566,28 +643,28 @@ export default class CreateReportItems extends Component {
> >
</TextField> </TextField>
</div> </div>
<div className="margin-top-10px" style={{ backgroundColor: '#e8e8e8', padding: 10, borderRadius: 5 }}> <div className="margin-top-10px" style={{padding: 10}}>
<TextField <Autocomplete
style={{ width: '100%' }} value={this.state.condition}
value="-"
id="isWrongCondition" id="isWrongCondition"
label="Kondisi Jika Salah" disabled={this.state.disabledCondt}
disabled onChange={(event, newValue) => {
inputProps={{ this.setState({condition: newValue});
style: {
fontSize: 11,
fontWeight: 600,
fontFamily: 'Nunito Sans, sans-serif',
}
}}
InputLabelProps={{
style: {
fontSize: 11,
fontWeight: 600,
fontFamily: 'Nunito Sans, sans-serif',
color: '#7e8085',
}
}} }}
options={this.state.options}
renderInput={(params) =>
<TextField {...params}
label="Kondisi Jika Salah"
InputLabelProps={{
style: {
fontSize: 11,
fontWeight: 600,
fontFamily: 'Nunito Sans, sans-serif',
color: '#7e8085'
}
}}
InputProps={{ ...params.InputProps, style: { fontSize: 11, fontWeight: 600, fontFamily: 'Nunito Sans, sans-serif' } }}
/>}
/> />
</div> </div>
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}> <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
......
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