Commit c26cc487 authored by Rifka Kurnia Irfiana's avatar Rifka Kurnia Irfiana

issue manag doc

parent 6a516f21
......@@ -55,6 +55,8 @@ export default class CreateManagementDoc extends Component {
this.getPeriode()
this.getMonth()
this.getFileSize()
console.log(this.props.setting_id)
console.log(this.props.name)
}
getFileSize(){
......@@ -229,27 +231,37 @@ export default class CreateManagementDoc extends Component {
}
validasi() {
if (String(this.props.name).includes('Manual Book TIA')){
} else {
if (R.isNil(this.state.periode)) {
this.setState({ errorPeriode: true, msgErrorPeriode: 'Period Cannot be Empty' })
} else if (R.isNil(this.state.monthId)) {
this.setState({ errorMonth: true, msgErrorMonth: 'Month Cannot be Empty' })
}
}
if (R.isNil(this.state.getPerusahaan)) {
this.setState({ errorPerusahaan: true, msgErrorPerusahaan: 'Company Cannot be Empty' })
} else if (R.isNil(this.state.getDocument)) {
this.setState({ errorDocument: true, msgErrorDocument: 'Category Cannot be Empty' })
}
else if (R.isNil(this.state.periode)) {
this.setState({ errorPeriode: true, msgErrorPeriode: 'Period Cannot be Empty' })
} else if (R.isNil(this.state.monthId)) {
this.setState({ errorMonth: true, msgErrorMonth: 'Month Cannot be Empty' })
}
else if (R.isNil(this.state.file)) {
this.setState({ alert: true, messageAlert: 'File Cannot be Empty', tipeAlert: 'warning' })
} else {
console.log("save")
const formData = new FormData();
formData.append("file", this.state.file);
formData.append("companyId", this.state.getPerusahaan.company_id);
formData.append("settingId", this.state.getDocument.document_category_id);
formData.append("documentPeriode", this.state.periode.periode);
formData.append("documentMonth", this.state.monthId.month_id);
formData.append("description", this.state.description);
formData.append("extension", this.state.fileType);
if(String(this.props.name).includes('Manual Book TIA')){
formData.append("documentPeriode", null);
formData.append("documentMonth", null);
} else {
formData.append("documentPeriode", this.state.periode.periode);
formData.append("documentMonth", this.state.monthId.month_id);
}
this.setState({ formData }, ()=> {
this.props.createDocument(this.state.formData, this.props.setting_id)
})
......@@ -325,6 +337,7 @@ export default class CreateManagementDoc extends Component {
/>
</div>
</div>
{String(this.props.name).includes('Manual Book TIA') ? false : (
<div className="column-1">
<div style={{ padding: 10, borderRadius: 5 }}>
<Autocomplete
......@@ -345,6 +358,8 @@ export default class CreateManagementDoc extends Component {
/>
</div>
</div>
)}
{String(this.props.name).includes('Manual Book TIA') ? false : (
<div className="column-2">
<div style={{ padding: 10, borderRadius: 5 }}>
<Autocomplete
......@@ -365,8 +380,9 @@ export default class CreateManagementDoc extends Component {
/>
</div>
</div>
)}
</div>
<div style={{ paddingLeft: 30, paddingRight: 30 }}>
<div style={{ paddingLeft: 30, paddingRight: 30, paddingTop: 10 }}>
<UploadFile
type={this.state.uploadStatus}
percentage={this.state.percentage}
......
......@@ -28,6 +28,7 @@ export default class DocumentManagement extends Component {
btnedit: false,
btndelete: false,
load: false,
name: ''
}
}
......@@ -66,7 +67,7 @@ export default class DocumentManagement extends Component {
this.getPermission()
}
getDataDocument(id) {
getDataDocument(id, name) {
// let payload = {
// "setting_group_id": 7,
// "setting_type_id": 167,
......@@ -80,6 +81,7 @@ export default class DocumentManagement extends Component {
this.setState({
listData: response.data.data,
id: id === undefined ? response.data.data[0].setting_id : id,
name: name === undefined ? response.data.data[0].value : name,
loadTable: true,
refresh: id === undefined ? '' : 'create'
})
......@@ -216,7 +218,7 @@ export default class DocumentManagement extends Component {
{this.state.listData.map((item, index) => {
return (
<Tab
onClick={() => this.setState({ id: item.setting_id, refresh: '', loadTable : false }, () => this.setState({loadTable: true}))}
onClick={() => this.setState({ name: item.value, id: item.setting_id, refresh: '', loadTable : false }, () => this.setState({loadTable: true}))}
label={item.value}
/>
)
......@@ -292,6 +294,7 @@ export default class DocumentManagement extends Component {
// getDataDocument={this.getDataDocument.bind(this)}
createDocument={this.createDocument.bind(this)}
setting_id={this.state.id}
name={this.state.name}
/>
)}
</div>
......
......@@ -48,7 +48,8 @@ export default class EditManagementDoc extends Component {
document_name: "",
document_size: 0,
loadUpload: false,
sizeUpload: "1"
sizeUpload: "1",
name: ''
}
}
......@@ -56,6 +57,7 @@ export default class EditManagementDoc extends Component {
this.getFileSize()
if (this.props.type === 'edit') {
this.getDetailDoc()
console.log(this.props.data)
}
}
......@@ -101,7 +103,8 @@ export default class EditManagementDoc extends Component {
fileType: data.document_type,
created: data.created,
updated: data.updated === null ? "" : data.updated,
loadUpload: true
loadUpload: true,
name: data.values
}, () => {
this.getDataCompany()
this.getDataDocument()
......@@ -278,7 +281,14 @@ export default class EditManagementDoc extends Component {
}
validasi() {
console.log(this.state.file);
if (String(this.props.name).includes('Manual Book TIA')){
} else {
if (R.isNil(this.state.periode)) {
this.setState({ errorPeriode: true, msgErrorPeriode: 'Period Cannot be Empty' })
} else if (R.isNil(this.state.monthId)) {
this.setState({ errorMonth: true, msgErrorMonth: 'Month Cannot be Empty' })
}
}
if (R.isNil(this.state.getPerusahaan)) {
this.setState({ errorPerusahaan: true, msgErrorPerusahaan: 'Company Cannot be Empty' })
} else if (R.isNil(this.state.getDocument)) {
......@@ -286,11 +296,7 @@ export default class EditManagementDoc extends Component {
} else if (R.isNil(this.state.file)) {
this.setState({ alert: true, messageAlert: 'File Cannot be Empty', tipeAlert: 'warning' })
}
else if (R.isNil(this.state.periode)) {
this.setState({ errorPeriode: true, msgErrorPeriode: 'Period Cannot be Empty' })
} else if (R.isNil(this.state.monthId)) {
this.setState({ errorMonth: true, msgErrorMonth: 'Month Cannot be Empty' })
}
else {
const formData = new FormData();
if (this.state.file == this.state.filePath){
......@@ -300,10 +306,15 @@ export default class EditManagementDoc extends Component {
formData.append("updated", 1);
formData.append("file", this.state.file);
}
if (String(this.props.name).includes('Manual Book TIA')){
formData.append("documentMonth", null);
formData.append("documentPeriode", null);
} else {
formData.append("documentMonth", this.state.monthId.month_id);
formData.append("documentPeriode", this.state.periode.periode);
}
formData.append("companyId", this.state.getPerusahaan.company_id);
formData.append("settingId", this.state.getDocument.document_category_id);
formData.append("documentMonth", this.state.monthId.month_id);
formData.append("documentPeriode", this.state.periode.periode);
formData.append("description", this.state.description);
formData.append("extension", this.state.fileType);
formData.append("documentId", this.props.idoc);
......@@ -388,6 +399,7 @@ export default class EditManagementDoc extends Component {
/>
</div>
</div>
{String(this.state.name).includes('Manual Book TIA') ? false : (
<div className="column-1">
<div style={{ padding: 10, borderRadius: 5 }}>
<Autocomplete
......@@ -408,6 +420,8 @@ export default class EditManagementDoc extends Component {
/>
</div>
</div>
)}
{String(this.state.name).includes('Manual Book TIA') ? false : (
<div className="column-2">
<div style={{ padding: 10, borderRadius: 5 }}>
<Autocomplete
......@@ -428,8 +442,9 @@ export default class EditManagementDoc extends Component {
/>
</div>
</div>
)}
</div>
<div style={{ paddingLeft: 30, paddingRight: 30 }}>
<div style={{ paddingLeft: 30, paddingRight: 30, paddingTop: 10 }}>
{this.state.loadUpload && (
<UploadFile
type={this.state.uploadStatus}
......
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