|
|
|
@ -46,6 +46,9 @@ const ResourceWorker = ({ params }) => {
|
|
|
|
|
const [dataDeliveryTools, setDataDeliveryTools] = useState([]); |
|
|
|
|
const [dataEdit, setDataEdit] = useState(null) |
|
|
|
|
const [dataExport, setDataExport] = useState([]) |
|
|
|
|
const [dataExportToolsRequest, setDataExportToolsRequest] = useState([]) |
|
|
|
|
const [dataExportToolsDelivery, setDataExportToolsDelivery] = useState([]) |
|
|
|
|
|
|
|
|
|
const [dataReqTools, setDataReqTools] = useState([]); |
|
|
|
|
const [dataTable, setDatatable] = useState([]) |
|
|
|
|
const [idDelete, setIdDelete] = useState(0) |
|
|
|
@ -68,6 +71,27 @@ const ResourceWorker = ({ params }) => {
|
|
|
|
|
getDataTools() |
|
|
|
|
}, [search, rowsPerPage, currentPage]) |
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
const cekData = dataExport || [] |
|
|
|
|
if (cekData.length > 0) { |
|
|
|
|
exportExcel() |
|
|
|
|
} |
|
|
|
|
}, [dataExport]) |
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
const cekData = dataExportToolsRequest || [] |
|
|
|
|
if (cekData.length > 0) { |
|
|
|
|
exportExcelToolsRequest() |
|
|
|
|
} |
|
|
|
|
}, [dataExportToolsRequest]) |
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
const cekData = dataExportToolsDelivery || [] |
|
|
|
|
if (cekData.length > 0) { |
|
|
|
|
exportExcelToolsDilevery() |
|
|
|
|
} |
|
|
|
|
}, [dataExportToolsDelivery]) |
|
|
|
|
|
|
|
|
|
const onShowSizeChange = (current, pageSize) => { |
|
|
|
|
setRowsPerPage(pageSize) |
|
|
|
|
} |
|
|
|
@ -220,7 +244,7 @@ const ResourceWorker = ({ params }) => {
|
|
|
|
|
setTypeDialog(type) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const handleExportExcel = async () => { |
|
|
|
|
const handleExportExcelToolsResource = async () => { |
|
|
|
|
|
|
|
|
|
const payload = { |
|
|
|
|
"paging": { "start": 0, "length": -1 }, |
|
|
|
@ -244,12 +268,11 @@ const ResourceWorker = ({ params }) => {
|
|
|
|
|
const excelData = []; |
|
|
|
|
resData.map((n, index) => { |
|
|
|
|
let dataRow = { |
|
|
|
|
"Nama Proyek": n.nama, |
|
|
|
|
"Biaya": n.biaya, |
|
|
|
|
"Color Progress": n.color_progress, |
|
|
|
|
"Jumlah Pekerja": n.jumlah_pekerja, |
|
|
|
|
"Tanggal Mulai": n.mulai_proyek ? moment(n.mulai_proyek).format(format) : "-", |
|
|
|
|
"Tanggal Selesai": n.akhir_proyek ? moment(n.akhir_proyek).format(format) : "-", |
|
|
|
|
"Nama": n.name, |
|
|
|
|
"Tipe Asset": n.asset_type, |
|
|
|
|
"Deskripsi": n.description, |
|
|
|
|
"Quantity": n.qty, |
|
|
|
|
"UOM": n.uom |
|
|
|
|
} |
|
|
|
|
excelData.push(dataRow) |
|
|
|
|
}) |
|
|
|
@ -259,6 +282,150 @@ const ResourceWorker = ({ params }) => {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const handleExportExcelToolsRequest = async () => { |
|
|
|
|
|
|
|
|
|
const payload = { |
|
|
|
|
"paging": { |
|
|
|
|
"start": 0, |
|
|
|
|
"length": 10 |
|
|
|
|
}, |
|
|
|
|
"columns": [ |
|
|
|
|
{ |
|
|
|
|
"name": "asset_type", |
|
|
|
|
"logic_operator": "ilike", |
|
|
|
|
"value": "", |
|
|
|
|
"operator": "AND" |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
"name": "status", |
|
|
|
|
"logic_operator": "<>", |
|
|
|
|
"value": "receipt to site", |
|
|
|
|
"operator": "AND" |
|
|
|
|
} |
|
|
|
|
], |
|
|
|
|
"joins": [{ "name": "m_proyek", "column_join": "proyek_id", "column_results": ["kode_sortname", "nama"] }], |
|
|
|
|
"orders": { |
|
|
|
|
"columns": [ |
|
|
|
|
"id" |
|
|
|
|
], |
|
|
|
|
"ascending": false |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const result = await axios.post(REQUEST_TOOLS_SEARCH, payload, HEADER) |
|
|
|
|
.then(res => res) |
|
|
|
|
.catch((error) => error.response); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (result && result.data && result.data.code == 200) { |
|
|
|
|
let resData = result.data.data; |
|
|
|
|
const excelData = []; |
|
|
|
|
resData.map((n, index) => { |
|
|
|
|
let dataRow = { |
|
|
|
|
"Company Name": n.join_first_nama ? null : "-", |
|
|
|
|
"Asset Name": n.asset_name, |
|
|
|
|
"Asset Type": n.asset_type, |
|
|
|
|
"Description": n.description, |
|
|
|
|
"Quantity": n.qty, |
|
|
|
|
"UOM": n.uom, |
|
|
|
|
"Status": n.status, |
|
|
|
|
} |
|
|
|
|
console.log('Tools Request', resData) |
|
|
|
|
excelData.push(dataRow) |
|
|
|
|
}) |
|
|
|
|
await setDataExportToolsRequest(excelData); |
|
|
|
|
} else { |
|
|
|
|
NotificationManager.error('Gagal Export Data!!', 'Failed'); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const handleExportExcelToolsDeliver = async () => { |
|
|
|
|
|
|
|
|
|
const payload = { |
|
|
|
|
"paging": { |
|
|
|
|
"start": 0, |
|
|
|
|
"length": 10 |
|
|
|
|
}, |
|
|
|
|
"columns": [ |
|
|
|
|
{ |
|
|
|
|
"name": "asset_type", |
|
|
|
|
"logic_operator": "ilike", |
|
|
|
|
"value": "", |
|
|
|
|
"operator": "AND" |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
"name": "status", |
|
|
|
|
"logic_operator": "=", |
|
|
|
|
"value": "receipt to site", |
|
|
|
|
"operator": "AND" |
|
|
|
|
} |
|
|
|
|
], |
|
|
|
|
"joins": [{ "name": "m_proyek", "column_join": "proyek_id", "column_results": ["kode_sortname", "nama"] }], |
|
|
|
|
"orders": { |
|
|
|
|
"columns": [ |
|
|
|
|
"id" |
|
|
|
|
], |
|
|
|
|
"ascending": false |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const result = await axios.post(TOOLS_RESOURCE_SEARCH, payload, HEADER) |
|
|
|
|
.then(res => res) |
|
|
|
|
.catch((error) => error.response); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (result && result.data && result.data.code == 200) { |
|
|
|
|
let resData = result.data.data; |
|
|
|
|
const excelData = []; |
|
|
|
|
resData.map((n, index) => { |
|
|
|
|
let dataRow = { |
|
|
|
|
"Nama": n.name, |
|
|
|
|
"Tipe Asset": n.asset_type, |
|
|
|
|
"Deskripsi": n.description, |
|
|
|
|
"Quantity": n.qty, |
|
|
|
|
"UOM": n.uom |
|
|
|
|
} |
|
|
|
|
excelData.push(dataRow) |
|
|
|
|
}) |
|
|
|
|
await setDataExportToolsDelivery(excelData); |
|
|
|
|
} else { |
|
|
|
|
NotificationManager.error('Gagal Export Data!!', 'Failed'); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const exportExcel = () => { |
|
|
|
|
const dataExcel = dataExport || []; |
|
|
|
|
const fileName = `Data ${pageName}.xlsx`; |
|
|
|
|
const ws = XLSX.utils.json_to_sheet(dataExcel); |
|
|
|
|
const wb = XLSX.utils.book_new(); |
|
|
|
|
XLSX.utils.book_append_sheet(wb, ws, `Data ${pageName}`); |
|
|
|
|
XLSX.writeFile(wb, fileName); |
|
|
|
|
setDataExport([]) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const exportExcelToolsRequest = () => { |
|
|
|
|
const dataExcel = dataExportToolsRequest || []; |
|
|
|
|
const fileName = `Data Tools Request.xlsx`; |
|
|
|
|
const ws = XLSX.utils.json_to_sheet(dataExcel); |
|
|
|
|
const wb = XLSX.utils.book_new(); |
|
|
|
|
XLSX.utils.book_append_sheet(wb, ws, `Data Tools Request`); |
|
|
|
|
XLSX.writeFile(wb, fileName); |
|
|
|
|
setDataExportToolsRequest([]) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const exportExcelToolsDilevery = () => { |
|
|
|
|
const dataExcel = dataExportToolsDelivery || []; |
|
|
|
|
const fileName = `Data Tools Dilevery.xlsx`; |
|
|
|
|
const ws = XLSX.utils.json_to_sheet(dataExcel); |
|
|
|
|
const wb = XLSX.utils.book_new(); |
|
|
|
|
XLSX.utils.book_append_sheet(wb, ws, `Data Tools Dilevery`); |
|
|
|
|
XLSX.writeFile(wb, fileName); |
|
|
|
|
setDataExportToolsDelivery([]) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const handleEdit = (data) => { |
|
|
|
|
setDataEdit(data) |
|
|
|
|
handleOpenDialog('Edit'); |
|
|
|
@ -383,7 +550,7 @@ const ResourceWorker = ({ params }) => {
|
|
|
|
|
<Button style={{ background: "#4caf50", color: "#fff" }} onClick={() => handleOpenDialog('Save')}><i className="fa fa-plus"></i></Button> |
|
|
|
|
</Tooltip> |
|
|
|
|
<Tooltip title="Export Excel"> |
|
|
|
|
<Button style={{ marginLeft: "5px" }} onClick={() => handleExportExcel()}><i className="fa fa-print"></i></Button> |
|
|
|
|
<Button style={{ marginLeft: "5px" }} onClick={() => handleExportExcelToolsResource()}><i className="fa fa-print"></i></Button> |
|
|
|
|
</Tooltip> |
|
|
|
|
</Col> |
|
|
|
|
</Row> |
|
|
|
@ -467,7 +634,7 @@ const ResourceWorker = ({ params }) => {
|
|
|
|
|
</Col> |
|
|
|
|
<Col> |
|
|
|
|
<Tooltip title="Export Excel"> |
|
|
|
|
<Button style={{ marginLeft: "5px" }} onClick={() => handleExportExcel()}><i className="fa fa-print"></i></Button> |
|
|
|
|
<Button style={{ marginLeft: "5px" }} onClick={() => handleExportExcelToolsRequest()}><i className="fa fa-print"></i></Button> |
|
|
|
|
</Tooltip> |
|
|
|
|
</Col> |
|
|
|
|
</Row> |
|
|
|
@ -498,7 +665,7 @@ const ResourceWorker = ({ params }) => {
|
|
|
|
|
</Col> |
|
|
|
|
<Col> |
|
|
|
|
<Tooltip title="Export Excel"> |
|
|
|
|
<Button style={{ marginLeft: "5px" }} onClick={() => handleExportExcel()}><i className="fa fa-print"></i></Button> |
|
|
|
|
<Button style={{ marginLeft: "5px" }} onClick={() => handleExportExcelToolsDeliver()}><i className="fa fa-print"></i></Button> |
|
|
|
|
</Tooltip> |
|
|
|
|
</Col> |
|
|
|
|
</Row> |
|
|
|
|