Commit 9aa2cbd6 authored by Deni Rinaldi's avatar Deni Rinaldi

Merge branch 'deni-dev(pc)' into 'master'

menegdoc

See merge request !349
parents 414d27e9 b6c5d5a1
...@@ -40,7 +40,10 @@ export default class EditManagementDoc extends Component { ...@@ -40,7 +40,10 @@ export default class EditManagementDoc extends Component {
messageAlert: '', messageAlert: '',
fileType: '', fileType: '',
konfirmasi: false, konfirmasi: false,
docId:'' docId: '',
document_name: "",
document_size: 0,
loadUpload: false
} }
} }
...@@ -50,7 +53,7 @@ export default class EditManagementDoc extends Component { ...@@ -50,7 +53,7 @@ export default class EditManagementDoc extends Component {
} }
} }
getDetailDoc(){ getDetailDoc() {
api.create().getDetailDocument(this.props.idoc).then(response => { api.create().getDetailDocument(this.props.idoc).then(response => {
console.log(response) console.log(response)
if (response.data) { if (response.data) {
...@@ -65,10 +68,13 @@ export default class EditManagementDoc extends Component { ...@@ -65,10 +68,13 @@ export default class EditManagementDoc extends Component {
period: data.document_periode, period: data.document_periode,
getMonthName: data.document_month, getMonthName: data.document_month,
description: data.description, description: data.description,
document_name: data.document_name,
document_size: data.document_size,
// id: data.approval_matrix_id, // id: data.approval_matrix_id,
// status: data.status, // status: data.status,
created: data.created, created: data.created,
updated: data.updated === null ? "" : data.updated updated: data.updated === null ? "" : data.updated,
loadUpload: true
}, () => { }, () => {
this.getDataCompany() this.getDataCompany()
this.getDataDocument() this.getDataDocument()
...@@ -110,7 +116,7 @@ export default class EditManagementDoc extends Component { ...@@ -110,7 +116,7 @@ export default class EditManagementDoc extends Component {
getOptionLabel: (option) => option.company_name, getOptionLabel: (option) => option.company_name,
}; };
let index = typeData.findIndex((val) => val.company_id == this.state.companyId) let index = typeData.findIndex((val) => val.company_id == this.state.companyId)
this.setState({ perusahaan: typeProps, perusahaanData: response.data.data, getPerusahaan: index === -1 ? typeData[0]: typeData[index] }) this.setState({ perusahaan: typeProps, perusahaanData: response.data.data, getPerusahaan: index === -1 ? typeData[0] : typeData[index] })
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => { this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Someone Logged In")) { if (response.data.message.includes("Someone Logged In")) {
...@@ -150,7 +156,7 @@ export default class EditManagementDoc extends Component { ...@@ -150,7 +156,7 @@ export default class EditManagementDoc extends Component {
getOptionLabel: (option) => option.document_category_name, getOptionLabel: (option) => option.document_category_name,
}; };
let index = typeData.findIndex((val) => val.document_category_id == this.state.categoryId) let index = typeData.findIndex((val) => val.document_category_id == this.state.categoryId)
this.setState({ document: typeProps, documentData: response.data.data, getDocument: index === -1 ? typeData[0]: typeData[index] }) this.setState({ document: typeProps, documentData: response.data.data, getDocument: index === -1 ? typeData[0] : typeData[index] })
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => { this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Someone Logged In")) { if (response.data.message.includes("Someone Logged In")) {
...@@ -190,7 +196,7 @@ export default class EditManagementDoc extends Component { ...@@ -190,7 +196,7 @@ export default class EditManagementDoc extends Component {
}) })
} }
getMonth(){ getMonth() {
api.create().getMonthTransaction().then(response => { api.create().getMonthTransaction().then(response => {
let dateNow = new Date let dateNow = new Date
// let bulan = format(dateNow, 'MMMM') // let bulan = format(dateNow, 'MMMM')
...@@ -258,14 +264,14 @@ export default class EditManagementDoc extends Component { ...@@ -258,14 +264,14 @@ export default class EditManagementDoc extends Component {
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);
this.setState({ formData }, ()=> { this.setState({ formData }, () => {
this.props.updateDocument(this.state.formData) this.props.updateDocument(this.state.formData)
}) })
} }
} }
deleteFile(e){ deleteFile(e) {
this.setState({ file: null}) this.setState({ file: null })
} }
closeAlert() { closeAlert() {
...@@ -373,6 +379,7 @@ export default class EditManagementDoc extends Component { ...@@ -373,6 +379,7 @@ export default class EditManagementDoc extends Component {
</div> </div>
</div> </div>
<div style={{ paddingLeft: 30, paddingRight: 30 }}> <div style={{ paddingLeft: 30, paddingRight: 30 }}>
{this.state.loadUpload && (
<UploadFile <UploadFile
type={this.state.uploadStatus} type={this.state.uploadStatus}
percentage={this.state.percentage} percentage={this.state.percentage}
...@@ -388,7 +395,10 @@ export default class EditManagementDoc extends Component { ...@@ -388,7 +395,10 @@ export default class EditManagementDoc extends Component {
}} }}
onUpload={() => alert('sukses')} onUpload={() => alert('sukses')}
value={this.state.file} value={this.state.file}
docSize={this.state.document_size}
docName={this.state.document_name}
/> />
)}
</div> </div>
<div className="margin-top-10px" style={{ paddingLeft: 30, paddingRight: 30, borderRadius: 5, paddingBottom: 20 }}> <div className="margin-top-10px" style={{ paddingLeft: 30, paddingRight: 30, borderRadius: 5, paddingBottom: 20 }}>
<TextField <TextField
......
...@@ -45,6 +45,13 @@ class Upload extends Component { ...@@ -45,6 +45,13 @@ class Upload extends Component {
} }
} }
componentDidMount() {
if (this.props.docName !== undefined && this.props.docName !== "") {
console.log('masuk');
this.setState({ docName: this.props.docName, docSize: this.props.docSize, inputVisible: false, editVisible: true })
}
}
onDrop = (acceptedFiles) => { onDrop = (acceptedFiles) => {
const formData = new FormData() const formData = new FormData()
let length = acceptedFiles[0].name.split(".").length let length = acceptedFiles[0].name.split(".").length
...@@ -116,6 +123,7 @@ class Upload extends Component { ...@@ -116,6 +123,7 @@ class Upload extends Component {
if (this.props.intent === "management") { if (this.props.intent === "management") {
this.setState({ this.setState({
previewVisible: false, previewVisible: false,
editVisible: false,
inputVisible: true, inputVisible: true,
uploadProgress: false, uploadProgress: false,
percentage: '0' percentage: '0'
...@@ -124,6 +132,7 @@ class Upload extends Component { ...@@ -124,6 +132,7 @@ class Upload extends Component {
} else { } else {
this.setState({ this.setState({
previewVisible: false, previewVisible: false,
editVisible: false,
inputVisible: true, inputVisible: true,
uploadProgress: false, uploadProgress: false,
percentage: '0' percentage: '0'
...@@ -187,6 +196,29 @@ class Upload extends Component { ...@@ -187,6 +196,29 @@ class Upload extends Component {
</div> </div>
: null} : null}
{/* edit */}
{this.state.editVisible ?
<div className="u-p-file u-p-preview">
<div className="display-flex-normal">
<div className="width width-35px">
<button
onClick={this.onRemove}
className="btn btn-small-circle btn-black"
type="button">
<img src={Images.close} />
</button>
</div>
<div className="width width-full margin-left-10px">
<div className="txt-site txt-12 txt-white txt-bold">
{this.state.docName}
</div>
<div className="txt-site txt-11 txt-white txt-thin">
{this.state.docSize} KB
</div>
</div>
</div>
</div>
: null}
{/* file */} {/* file */}
{this.state.previewVisible {this.state.previewVisible
? ?
......
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