|
|
|
@ -5,7 +5,7 @@ import { Table, Tooltip, Popover, Spin } from 'antd';
|
|
|
|
|
import 'antd/dist/antd.css'; |
|
|
|
|
import moment from 'moment'; |
|
|
|
|
import SweetAlert from 'react-bootstrap-sweetalert'; |
|
|
|
|
import { DOCUMENT_DOWNLOAD, DOCUMENT_GET, BASE_SIMPRO_LUMEN_FILE, REQUEST_MATERIAL_EDIT, DOCUMENT_DELETE, DOCUMENT_SEARCH, FOLDER_DOCUMENT_PROYEK_GET_TREE, FOLDER_DOCUMENT_PROYEK_DELETE } from '../../../const/ApiConst'; |
|
|
|
|
import { DOCUMENT_DOWNLOAD, DOCUMENT_GET, BASE_SIMPRO_LUMEN_FILE_COMPANY, REQUEST_MATERIAL_EDIT, DOCUMENT_DELETE, DOCUMENT_SEARCH, FOLDER_DOCUMENT_PROYEK_GET_TREE, FOLDER_DOCUMENT_PROYEK_DELETE } from '../../../const/ApiConst'; |
|
|
|
|
import axios from "../../../const/interceptorApi" |
|
|
|
|
import { NotificationContainer, NotificationManager } from 'react-notifications'; |
|
|
|
|
import DialogRequest from './FormDocument'; |
|
|
|
@ -18,13 +18,6 @@ const DialogDocument = ({ openDialog, closeDialog, toggleDialog, idTask, proyekN
|
|
|
|
|
"Authorization": `Bearer ${token}` |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
const config = { |
|
|
|
|
headers: |
|
|
|
|
{ |
|
|
|
|
Authorization: `Bearer ${token}`, |
|
|
|
|
"Content-type": `application/json` |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
const [dataDocument, setDataDocument] = useState([]) |
|
|
|
|
const [openDialogReq, setOpenDialogReq] = useState(false) |
|
|
|
|
const [openDialogNewFolder, setOpenDialogNewFolder] = useState(false) |
|
|
|
@ -34,6 +27,7 @@ const DialogDocument = ({ openDialog, closeDialog, toggleDialog, idTask, proyekN
|
|
|
|
|
const [dataEdit, setDataEdit] = useState(null) |
|
|
|
|
const [parentIdNewFolder, setParentIdNewFolder] = useState(0) |
|
|
|
|
const [loading, setLoading] = useState(true); |
|
|
|
|
const company_id = window.localStorage.getItem('company_id'); |
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
if (idTask > 0) { |
|
|
|
@ -58,7 +52,7 @@ const DialogDocument = ({ openDialog, closeDialog, toggleDialog, idTask, proyekN
|
|
|
|
|
const getDataDocument = async () => { |
|
|
|
|
const url = FOLDER_DOCUMENT_PROYEK_GET_TREE(idTask) |
|
|
|
|
const result = await axios |
|
|
|
|
.get(url, config) |
|
|
|
|
.get(url, HEADER) |
|
|
|
|
.then(res => res) |
|
|
|
|
.catch((error) => error.response); |
|
|
|
|
if (result && result.data && result.data.code == 200) { |
|
|
|
@ -86,7 +80,7 @@ const DialogDocument = ({ openDialog, closeDialog, toggleDialog, idTask, proyekN
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const handleDownload = (id, file) => { |
|
|
|
|
fetch(DOCUMENT_DOWNLOAD(id), { |
|
|
|
|
fetch(DOCUMENT_DOWNLOAD(id, company_id), { |
|
|
|
|
headers: new Headers({ |
|
|
|
|
'Content-Type': 'application/json', |
|
|
|
|
'Authorization': `Bearer ${token}` |
|
|
|
@ -101,14 +95,12 @@ const DialogDocument = ({ openDialog, closeDialog, toggleDialog, idTask, proyekN
|
|
|
|
|
a.click(); |
|
|
|
|
a.remove(); |
|
|
|
|
}); |
|
|
|
|
//window.location.href = response.url;
|
|
|
|
|
}); |
|
|
|
|
// const urlDownload = DOCUMENT_DOWNLOAD(id);
|
|
|
|
|
// window.open(urlDownload);
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const handleShow = (file) => { |
|
|
|
|
const urlShow = `${BASE_SIMPRO_LUMEN_FILE}/${file}` |
|
|
|
|
const configApp = JSON.parse(window.localStorage.getItem('configApp')); |
|
|
|
|
const urlShow = `${BASE_SIMPRO_LUMEN_FILE_COMPANY(file, configApp.company_name)}` |
|
|
|
|
window.open(urlShow); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -215,7 +207,7 @@ const DialogDocument = ({ openDialog, closeDialog, toggleDialog, idTask, proyekN
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const onConfirmDelete = async () => { |
|
|
|
|
let urlDel = DOCUMENT_DELETE(idDelete) |
|
|
|
|
let urlDel = DOCUMENT_DELETE(idDelete, company_id) |
|
|
|
|
const result = await axios.delete(urlDel, HEADER) |
|
|
|
|
.then(res => res) |
|
|
|
|
.catch((error) => error.response); |
|
|
|
|