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