|
|
@ -14,7 +14,7 @@ import { |
|
|
|
PROYEK_ADD, PROYEK_SEARCH, PROYEK_EDIT, PROYEK_DELETE, |
|
|
|
PROYEK_ADD, PROYEK_SEARCH, PROYEK_EDIT, PROYEK_DELETE, |
|
|
|
MATERIAL_RESOURCE_ADD, MATERIAL_RESOURCE_EDIT, MATERIAL_RESOURCE_DELETE, MATERIAL_RESOURCE_SEARCH, |
|
|
|
MATERIAL_RESOURCE_ADD, MATERIAL_RESOURCE_EDIT, MATERIAL_RESOURCE_DELETE, MATERIAL_RESOURCE_SEARCH, |
|
|
|
REQUEST_MATERIAL_SEARCH, REQUEST_MATERIAL_EDIT, |
|
|
|
REQUEST_MATERIAL_SEARCH, REQUEST_MATERIAL_EDIT, |
|
|
|
REQUEST_MATERIAL_UPDATE_WAREHOUSE_SITE |
|
|
|
REQUEST_MATERIAL_UPDATE_WAREHOUSE_SITE, SATUAN_SEARCH |
|
|
|
} from '../../../const/ApiConst'; |
|
|
|
} from '../../../const/ApiConst'; |
|
|
|
|
|
|
|
|
|
|
|
const { TabPane } = Tabs; |
|
|
|
const { TabPane } = Tabs; |
|
|
@ -52,6 +52,7 @@ const Resource = ({ params }) => { |
|
|
|
const [dataExport, setDataExport] = useState([]) |
|
|
|
const [dataExport, setDataExport] = useState([]) |
|
|
|
const [dataReqMaterial, setDataReqMaterial] = useState([]) |
|
|
|
const [dataReqMaterial, setDataReqMaterial] = useState([]) |
|
|
|
const [dataTable, setDatatable] = useState([]) |
|
|
|
const [dataTable, setDatatable] = useState([]) |
|
|
|
|
|
|
|
const [dataSatuan, setDatasatuan] = useState([]) |
|
|
|
const [idDelete, setIdDelete] = useState(0) |
|
|
|
const [idDelete, setIdDelete] = useState(0) |
|
|
|
const [openDialog, setOpenDialog] = useState(false) |
|
|
|
const [openDialog, setOpenDialog] = useState(false) |
|
|
|
const [rowsPerPage, setRowsPerPage] = useState(10) |
|
|
|
const [rowsPerPage, setRowsPerPage] = useState(10) |
|
|
@ -62,6 +63,7 @@ const Resource = ({ params }) => { |
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
useEffect(() => { |
|
|
|
getDataReqMaterial() |
|
|
|
getDataReqMaterial() |
|
|
|
|
|
|
|
getDataSatuan() |
|
|
|
}, []) |
|
|
|
}, []) |
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
useEffect(() => { |
|
|
@ -71,7 +73,9 @@ const Resource = ({ params }) => { |
|
|
|
useEffect(() => { |
|
|
|
useEffect(() => { |
|
|
|
const cekData = dataExport || [] |
|
|
|
const cekData = dataExport || [] |
|
|
|
if (cekData.length > 0) { |
|
|
|
if (cekData.length > 0) { |
|
|
|
exportExcel() |
|
|
|
exportExcelRequestMaterial() |
|
|
|
|
|
|
|
exportExcelMaterialResource() |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
}, [dataExport]) |
|
|
|
}, [dataExport]) |
|
|
|
|
|
|
|
|
|
|
@ -159,6 +163,53 @@ const Resource = ({ params }) => { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const getDataSatuan = async () => { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let start = 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (currentPage !== 1 && currentPage > 1) { |
|
|
|
|
|
|
|
start = (currentPage * rowsPerPage) - rowsPerPage |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const payload = { |
|
|
|
|
|
|
|
"columns": [ |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
"name": "name", |
|
|
|
|
|
|
|
"logic_operator": "ilike", |
|
|
|
|
|
|
|
"value": search, |
|
|
|
|
|
|
|
"operator": "AND" |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
"name": "description", |
|
|
|
|
|
|
|
"logic_operator": "ilike", |
|
|
|
|
|
|
|
"value": search, |
|
|
|
|
|
|
|
"operator": "AND" |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
"orders": { |
|
|
|
|
|
|
|
"ascending": true, |
|
|
|
|
|
|
|
"columns": [ |
|
|
|
|
|
|
|
'id' |
|
|
|
|
|
|
|
] |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
"paging": { |
|
|
|
|
|
|
|
"length": rowsPerPage, |
|
|
|
|
|
|
|
"start": start |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const result = await axios |
|
|
|
|
|
|
|
.post(SATUAN_SEARCH, payload, HEADER) |
|
|
|
|
|
|
|
.then(res => res) |
|
|
|
|
|
|
|
.catch((error) => error.response); |
|
|
|
|
|
|
|
if (result && result.data && result.data.code == 200) { |
|
|
|
|
|
|
|
setDatasatuan(result.data.data); |
|
|
|
|
|
|
|
setTotalPage(result.data.totalRecord); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
NotificationManager.error('Gagal Mengambil Data!!', 'Failed'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const handleSearch = e => { |
|
|
|
const handleSearch = e => { |
|
|
|
const value = e.target.value |
|
|
|
const value = e.target.value |
|
|
|
setSearch(value); |
|
|
|
setSearch(value); |
|
|
@ -170,9 +221,9 @@ const Resource = ({ params }) => { |
|
|
|
setTypeDialog(type) |
|
|
|
setTypeDialog(type) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const exportExcel = () => { |
|
|
|
const exportExcelRequestMaterial = () => { |
|
|
|
const dataExcel = dataExport || []; |
|
|
|
const dataExcel = dataExport || []; |
|
|
|
const fileName = `Data ${pageName}.xlsx`; |
|
|
|
const fileName = `Data Request Material.xlsx`; |
|
|
|
const ws = XLSX.utils.json_to_sheet(dataExcel); |
|
|
|
const ws = XLSX.utils.json_to_sheet(dataExcel); |
|
|
|
const wb = XLSX.utils.book_new(); |
|
|
|
const wb = XLSX.utils.book_new(); |
|
|
|
XLSX.utils.book_append_sheet(wb, ws, `Data ${pageName}`); |
|
|
|
XLSX.utils.book_append_sheet(wb, ws, `Data ${pageName}`); |
|
|
@ -180,24 +231,128 @@ const Resource = ({ params }) => { |
|
|
|
setDataExport([]) |
|
|
|
setDataExport([]) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const exportExcelMaterialResource = () => { |
|
|
|
|
|
|
|
const dataExcel = dataExport || []; |
|
|
|
|
|
|
|
const fileName = `Data MaterialResource.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 handleExportExcel = async () => { |
|
|
|
const handleExportExcelMaterialDel = async () => { |
|
|
|
|
|
|
|
|
|
|
|
const payload = { |
|
|
|
const payload = { |
|
|
|
"paging": { "start": 0, "length": -1 }, |
|
|
|
"columns": [ |
|
|
|
"joins": [], |
|
|
|
{ "name": "description", "logic_operator": "ilike", "value": "", "operator": "AND" }, |
|
|
|
"orders": { "columns": ["id"], "ascending": false } |
|
|
|
], |
|
|
|
|
|
|
|
"joins": [ |
|
|
|
|
|
|
|
{ "name": "m_proyek", "column_join": "proyek_id", "column_results": ["kode_sortname", "nama"] } |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
"orders": { "columns": ["id"], "ascending": true }, |
|
|
|
|
|
|
|
"paging": { "start": 0, "length": -1 } |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (parseInt(role_id) !== 1) { |
|
|
|
|
|
|
|
payload["columns"] = [ |
|
|
|
const result = await axios |
|
|
|
{ "name": "id", "logic_operator": "=", "value": proyek_id, "operator": "AND" } |
|
|
|
.post(REQUEST_MATERIAL_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 Material": n.description, |
|
|
|
|
|
|
|
"Quantity": n.qty, |
|
|
|
|
|
|
|
"Status": n.status, |
|
|
|
|
|
|
|
"Price": n.price, |
|
|
|
|
|
|
|
"Uom": n.uom, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
excelData.push(dataRow) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
await setDataExport(excelData); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
NotificationManager.error('Gagal Export Data!!', 'Failed'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const handleExportExcelRequestMaterial = async () => { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const payload = { |
|
|
|
|
|
|
|
"columns": [ |
|
|
|
|
|
|
|
{ "name": "description", "logic_operator": "ilike", "value": "", "operator": "AND" }, |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
"joins": [ |
|
|
|
|
|
|
|
{ "name": "m_proyek", "column_join": "proyek_id", "column_results": ["kode_sortname", "nama"] } |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
"orders": { "columns": ["id"], "ascending": true }, |
|
|
|
|
|
|
|
"paging": { "start": 0, "length": -1 } |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const result = await axios |
|
|
|
|
|
|
|
.post(REQUEST_MATERIAL_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 Material": n.description, |
|
|
|
|
|
|
|
"Quantity": n.qty, |
|
|
|
|
|
|
|
"Status": n.status, |
|
|
|
|
|
|
|
"Price": n.price, |
|
|
|
|
|
|
|
"Uom": n.uom, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
excelData.push(dataRow) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
await setDataExport(excelData); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
NotificationManager.error('Gagal Export Data!!', 'Failed'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const handleExportExcelMatResource = async () => { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let start = 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (currentPage !== 1 && currentPage > 1) { |
|
|
|
|
|
|
|
start = (currentPage * rowsPerPage) - rowsPerPage |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const payload = { |
|
|
|
|
|
|
|
"columns": [ |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
"name": "name", |
|
|
|
|
|
|
|
"logic_operator": "ilike", |
|
|
|
|
|
|
|
"value": search, |
|
|
|
|
|
|
|
"operator": "AND" |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
"orders": { |
|
|
|
|
|
|
|
"ascending": true, |
|
|
|
|
|
|
|
"columns": [ |
|
|
|
|
|
|
|
'id' |
|
|
|
] |
|
|
|
] |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
"paging": { |
|
|
|
|
|
|
|
"length": -1, |
|
|
|
|
|
|
|
"start": start |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const result = await axios |
|
|
|
const result = await axios |
|
|
|
.post(PROYEK_SEARCH, payload, HEADER) |
|
|
|
.post(MATERIAL_RESOURCE_SEARCH, payload, HEADER) |
|
|
|
.then(res => res) |
|
|
|
.then(res => res) |
|
|
|
.catch((error) => error.response); |
|
|
|
.catch((error) => error.response); |
|
|
|
|
|
|
|
|
|
|
@ -207,12 +362,12 @@ const Resource = ({ params }) => { |
|
|
|
const excelData = []; |
|
|
|
const excelData = []; |
|
|
|
resData.map((n, index) => { |
|
|
|
resData.map((n, index) => { |
|
|
|
let dataRow = { |
|
|
|
let dataRow = { |
|
|
|
"Nama Proyek": n.nama, |
|
|
|
"Nama Material": n.name, |
|
|
|
"Biaya": n.biaya, |
|
|
|
"Quantity": n.qty, |
|
|
|
"Color Progress": n.color_progress, |
|
|
|
"Status": n.status, |
|
|
|
"Jumlah Pekerja": n.jumlah_pekerja, |
|
|
|
"Unit Price": n.unit_price, |
|
|
|
"Tanggal Mulai": n.mulai_proyek ? moment(n.mulai_proyek).format(format) : "-", |
|
|
|
"Uom": n.uom, |
|
|
|
"Tanggal Selesai": n.akhir_proyek ? moment(n.akhir_proyek).format(format) : "-", |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
excelData.push(dataRow) |
|
|
|
excelData.push(dataRow) |
|
|
|
}) |
|
|
|
}) |
|
|
@ -507,7 +662,7 @@ const Resource = ({ params }) => { |
|
|
|
<Button style={{ background: "#4caf50", color: "#fff" }} onClick={() => handleOpenDialog('Save')}><i className="fa fa-plus"></i></Button> |
|
|
|
<Button style={{ background: "#4caf50", color: "#fff" }} onClick={() => handleOpenDialog('Save')}><i className="fa fa-plus"></i></Button> |
|
|
|
</Tooltip> |
|
|
|
</Tooltip> |
|
|
|
<Tooltip title="Export Excel"> |
|
|
|
<Tooltip title="Export Excel"> |
|
|
|
<Button style={{ marginLeft: "5px" }} onClick={() => handleExportExcel()}><i className="fa fa-print"></i></Button> |
|
|
|
<Button style={{ marginLeft: "5px" }} onClick={() => handleExportExcelMatResource()}><i className="fa fa-print"></i></Button> |
|
|
|
</Tooltip> |
|
|
|
</Tooltip> |
|
|
|
</Col> |
|
|
|
</Col> |
|
|
|
</Row> |
|
|
|
</Row> |
|
|
@ -540,7 +695,7 @@ const Resource = ({ params }) => { |
|
|
|
</Col> |
|
|
|
</Col> |
|
|
|
<Col> |
|
|
|
<Col> |
|
|
|
<Tooltip title="Export Excel"> |
|
|
|
<Tooltip title="Export Excel"> |
|
|
|
<Button style={{ marginLeft: "5px" }} onClick={() => handleExportExcel()}><i className="fa fa-print"></i></Button> |
|
|
|
<Button style={{ marginLeft: "5px" }} onClick={() => handleExportExcelRequestMaterial()}><i className="fa fa-print"></i></Button> |
|
|
|
</Tooltip> |
|
|
|
</Tooltip> |
|
|
|
</Col> |
|
|
|
</Col> |
|
|
|
</Row> |
|
|
|
</Row> |
|
|
@ -565,7 +720,7 @@ const Resource = ({ params }) => { |
|
|
|
</Col> |
|
|
|
</Col> |
|
|
|
<Col> |
|
|
|
<Col> |
|
|
|
<Tooltip title="Export Excel"> |
|
|
|
<Tooltip title="Export Excel"> |
|
|
|
<Button style={{ marginLeft: "5px" }} onClick={() => handleExportExcel()}><i className="fa fa-print"></i></Button> |
|
|
|
{/* <Button style={{ marginLeft: "5px" }} onClick={() => handleExportExcel()}><i className="fa fa-print"></i></Button> */} |
|
|
|
</Tooltip> |
|
|
|
</Tooltip> |
|
|
|
</Col> |
|
|
|
</Col> |
|
|
|
</Row> |
|
|
|
</Row> |
|
|
@ -603,6 +758,7 @@ const Resource = ({ params }) => { |
|
|
|
dataEdit={dataEdit} |
|
|
|
dataEdit={dataEdit} |
|
|
|
clickOpenModal={clickOpenModal} |
|
|
|
clickOpenModal={clickOpenModal} |
|
|
|
dataParent={allDataMenu} |
|
|
|
dataParent={allDataMenu} |
|
|
|
|
|
|
|
dataUom={dataSatuan} |
|
|
|
/> |
|
|
|
/> |
|
|
|
<Tabs defaultActiveKey="1"> |
|
|
|
<Tabs defaultActiveKey="1"> |
|
|
|
<TabPane tab="Material Resource Pool" key="1"> |
|
|
|
<TabPane tab="Material Resource Pool" key="1"> |
|
|
|