|
|
|
@ -19,7 +19,7 @@ import {
|
|
|
|
|
Tooltip, |
|
|
|
|
Popover, |
|
|
|
|
Skeleton, |
|
|
|
|
Divider, |
|
|
|
|
Spin, |
|
|
|
|
} from "antd"; |
|
|
|
|
import { |
|
|
|
|
PROJECT_APPROVAL_ADD, |
|
|
|
@ -136,6 +136,7 @@ const CreatedProyek = ({ params, ...props }) => {
|
|
|
|
|
const [dataVersionGantt, setDataVersionGantt] = useState([]); |
|
|
|
|
const [dataHierarchy, setDataHierarchy] = useState([]); |
|
|
|
|
const [dataDetail, setDataDetail] = useState(null); |
|
|
|
|
const [loading, setLoading] = useState(true); |
|
|
|
|
|
|
|
|
|
const pageName = params.name; |
|
|
|
|
|
|
|
|
@ -167,7 +168,7 @@ const CreatedProyek = ({ params, ...props }) => {
|
|
|
|
|
}, [openDialogProyek]); |
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
getDataProyek(); |
|
|
|
|
role_id !== "44" ? getDataProyek() : getDataProyekByCustomer(); |
|
|
|
|
}, [search, rowsPerPage, currentPage]); |
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
@ -230,6 +231,30 @@ const CreatedProyek = ({ params, ...props }) => {
|
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const handleDashboard = async (text) => { |
|
|
|
|
const URL = `${BASE_OSPRO}/api/project/detail/${text.id}`; |
|
|
|
|
const result = await axios |
|
|
|
|
.get(URL, HEADER) |
|
|
|
|
.then((res) => res) |
|
|
|
|
.catch((err) => err.response); |
|
|
|
|
if (!result) { |
|
|
|
|
NotificationManager.error(`Could not connect to internet.`, "Failed"); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (result.status !== 200) { |
|
|
|
|
NotificationManager.error( |
|
|
|
|
`Get project detail failed, ${result.data.message}`, |
|
|
|
|
"Failed" |
|
|
|
|
); |
|
|
|
|
return; |
|
|
|
|
} else if (result.status == 200 && result.data.data) { |
|
|
|
|
history.push( |
|
|
|
|
`dashboard-customer/${text.id}/${result.data.gantt.last_gantt_id}/1` |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const getDataProyek = async () => { |
|
|
|
|
let start = 0; |
|
|
|
|
|
|
|
|
@ -246,6 +271,80 @@ const CreatedProyek = ({ params, ...props }) => {
|
|
|
|
|
operator: "AND", |
|
|
|
|
}, |
|
|
|
|
], |
|
|
|
|
select: [ |
|
|
|
|
"id", |
|
|
|
|
"nama", |
|
|
|
|
"rencana_biaya", |
|
|
|
|
"type_proyek_id", |
|
|
|
|
"currency_symbol", |
|
|
|
|
"mulai_proyek", |
|
|
|
|
"akhir_proyek", |
|
|
|
|
], |
|
|
|
|
joins: [ |
|
|
|
|
{ |
|
|
|
|
name: "m_users", |
|
|
|
|
column_join: "pm_id", |
|
|
|
|
column_results: ["name", "username"], |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
name: "m_type_proyek", |
|
|
|
|
column_join: "type_proyek_id", |
|
|
|
|
column_results: ["name", "description"], |
|
|
|
|
}, |
|
|
|
|
// { "name": "subproyeks.m_subproyek", "column_join": "parent_id", "column_results": ["nama", "biaya", "color_progress", "jumlah_pekerja", "pic", "mulai_proyek", "akhir_proyek", "biaya_actual", "persentase_progress_plan", "persentase_progress_actual"] }
|
|
|
|
|
], |
|
|
|
|
orders: { columns: ["id"], ascending: false }, |
|
|
|
|
paging: { start: start, length: rowsPerPage }, |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
if (parseInt(role_id) !== 1) { |
|
|
|
|
payload["columns"] = [ |
|
|
|
|
{ name: "id", logic_operator: "=", value: proyek_id, operator: "AND" }, |
|
|
|
|
]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const result = await axios |
|
|
|
|
.post(PROYEK_SEARCH, payload, HEADER) |
|
|
|
|
.then((res) => res) |
|
|
|
|
.catch((error) => error.response); |
|
|
|
|
|
|
|
|
|
if (result && result.data && result.data.code == 200) { |
|
|
|
|
let dataRes = result.data.data || []; |
|
|
|
|
|
|
|
|
|
setDatatable(dataRes); |
|
|
|
|
setTotalPage(result.data.totalRecord); |
|
|
|
|
setLoading(false); |
|
|
|
|
} else { |
|
|
|
|
setLoading(false); |
|
|
|
|
NotificationManager.error("Gagal Mengambil Data!!", "Failed"); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const getDataProyekByCustomer = async () => { |
|
|
|
|
let start = 0; |
|
|
|
|
|
|
|
|
|
if (currentPage !== 1 && currentPage > 1) { |
|
|
|
|
start = currentPage * rowsPerPage - rowsPerPage; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const payload = { |
|
|
|
|
columns: [ |
|
|
|
|
{ |
|
|
|
|
name: "nama", |
|
|
|
|
logic_operator: "ilike", |
|
|
|
|
value: search, |
|
|
|
|
operator: "AND", |
|
|
|
|
}, |
|
|
|
|
], |
|
|
|
|
select: [ |
|
|
|
|
"id", |
|
|
|
|
"nama", |
|
|
|
|
"rencana_biaya", |
|
|
|
|
"type_proyek_id", |
|
|
|
|
"currency_symbol", |
|
|
|
|
"mulai_proyek", |
|
|
|
|
"akhir_proyek", |
|
|
|
|
], |
|
|
|
|
joins: [ |
|
|
|
|
{ |
|
|
|
|
name: "m_users", |
|
|
|
@ -257,11 +356,10 @@ const CreatedProyek = ({ params, ...props }) => {
|
|
|
|
|
column_join: "proyek_id", |
|
|
|
|
column_results: ["type_proyek_id"], |
|
|
|
|
}, |
|
|
|
|
// { "name": "subproyeks.m_subproyek", "column_join": "parent_id", "column_results": ["nama", "biaya", "color_progress", "jumlah_pekerja", "pic", "mulai_proyek", "akhir_proyek", "biaya_actual", "persentase_progress_plan", "persentase_progress_actual"] }
|
|
|
|
|
], |
|
|
|
|
user_id: { user_id: user_id }, |
|
|
|
|
orders: { columns: ["id"], ascending: false }, |
|
|
|
|
paging: { start: start, length: rowsPerPage }, |
|
|
|
|
user_id: { user_id: user_id } |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
if (parseInt(role_id) !== 1) { |
|
|
|
@ -277,12 +375,12 @@ const CreatedProyek = ({ params, ...props }) => {
|
|
|
|
|
|
|
|
|
|
if (result && result.data && result.data.code == 200) { |
|
|
|
|
let dataRes = result.data.data || []; |
|
|
|
|
// const filteredData = dataRes.filter(
|
|
|
|
|
// (item) => item.join_first_role_id === parseInt(role_id)
|
|
|
|
|
// );
|
|
|
|
|
|
|
|
|
|
setDatatable(dataRes); |
|
|
|
|
setTotalPage(result.data.totalRecord); |
|
|
|
|
setLoading(false); |
|
|
|
|
} else { |
|
|
|
|
setLoading(false); |
|
|
|
|
NotificationManager.error("Gagal Mengambil Data!!", "Failed"); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
@ -304,6 +402,7 @@ const CreatedProyek = ({ params, ...props }) => {
|
|
|
|
|
const getdataGantt = async (idTask) => { |
|
|
|
|
setLoadVersionGantt(true); |
|
|
|
|
const payload = { |
|
|
|
|
select: ["id", "name_version"], |
|
|
|
|
columns: [ |
|
|
|
|
{ |
|
|
|
|
name: "proyek_id", |
|
|
|
@ -591,7 +690,8 @@ const CreatedProyek = ({ params, ...props }) => {
|
|
|
|
|
.catch((error) => error.response); |
|
|
|
|
|
|
|
|
|
if (result && result.data && result.data.code === 200) { |
|
|
|
|
getDataProyek(); |
|
|
|
|
role_id !== "44" ? getDataProyek() : getDataProyekByCustomer(); |
|
|
|
|
|
|
|
|
|
setIdDelete(0); |
|
|
|
|
setAlertDelete(false); |
|
|
|
|
NotificationManager.success(`Data proyek berhasil dihapus`, "Success!!"); |
|
|
|
@ -637,7 +737,7 @@ const CreatedProyek = ({ params, ...props }) => {
|
|
|
|
|
NotificationManager.success(`${result.data.message}`, "Success!!"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
getDataProyek(); |
|
|
|
|
role_id !== "44" ? getDataProyek() : getDataProyekByCustomer(); |
|
|
|
|
} else { |
|
|
|
|
NotificationManager.error(`${result.data.message}`, "Failed!!"); |
|
|
|
|
} |
|
|
|
@ -718,7 +818,7 @@ const CreatedProyek = ({ params, ...props }) => {
|
|
|
|
|
const resultMilestone = await editMilestone(data.id, milestones); |
|
|
|
|
const resultApproval = await editApproval(data.id, approval); |
|
|
|
|
if (result && result.status === 200) { |
|
|
|
|
getDataProyek(); |
|
|
|
|
role_id !== "44" ? getDataProyek() : getDataProyekByCustomer(); |
|
|
|
|
NotificationManager.success(`Data proyek berhasil Ubah`, "Success!!"); |
|
|
|
|
} else { |
|
|
|
|
NotificationManager.error(`${result.data.message}`, "Failed!!"); |
|
|
|
@ -898,7 +998,7 @@ const CreatedProyek = ({ params, ...props }) => {
|
|
|
|
|
const data = resData.map((elt) => [ |
|
|
|
|
elt.nama, |
|
|
|
|
`Rp. ${formatThousand(elt.rencana_biaya)}`, |
|
|
|
|
elt.nama_type_proyek, |
|
|
|
|
elt.join_second_name, |
|
|
|
|
elt.join_first_name, |
|
|
|
|
`${moment(elt.mulai_proyek).format(format)} - ${moment( |
|
|
|
|
elt.akhir_proyek |
|
|
|
@ -1112,7 +1212,21 @@ const CreatedProyek = ({ params, ...props }) => {
|
|
|
|
|
title: "Action", |
|
|
|
|
dataIndex: "", |
|
|
|
|
key: "x", |
|
|
|
|
render: (text, record) => ( |
|
|
|
|
render: (text, record) => |
|
|
|
|
role_id == "44" ? ( |
|
|
|
|
<> |
|
|
|
|
<Tooltip title="Dashboard Project"> |
|
|
|
|
<Button |
|
|
|
|
size="small" |
|
|
|
|
onClick={() => handleDashboard(text)} |
|
|
|
|
type="link" |
|
|
|
|
style={{ color: "green" }} |
|
|
|
|
> |
|
|
|
|
<i className="fa fa-line-chart"></i> |
|
|
|
|
</Button> |
|
|
|
|
</Tooltip> |
|
|
|
|
</> |
|
|
|
|
) : ( |
|
|
|
|
<> |
|
|
|
|
<Popover |
|
|
|
|
placement="rightTop" |
|
|
|
@ -1165,7 +1279,7 @@ const CreatedProyek = ({ params, ...props }) => {
|
|
|
|
|
dataIndex: "color_progress", |
|
|
|
|
key: "color_progress", |
|
|
|
|
render: (text, record) => ( |
|
|
|
|
<>{record.nama_type_proyek ? record.nama_type_proyek : "-"}</> |
|
|
|
|
<>{record.join_second_name ? record.join_second_name : "-"}</> |
|
|
|
|
), |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
@ -1436,6 +1550,7 @@ const CreatedProyek = ({ params, ...props }) => {
|
|
|
|
|
/> |
|
|
|
|
</Col> |
|
|
|
|
<Col> |
|
|
|
|
{role_id == "44" ? null : ( // role kustomer
|
|
|
|
|
<Tooltip title="Add Project"> |
|
|
|
|
<Button |
|
|
|
|
style={{ background: "#4caf50", color: "#fff" }} |
|
|
|
@ -1444,6 +1559,7 @@ const CreatedProyek = ({ params, ...props }) => {
|
|
|
|
|
<i className="fa fa-plus"></i> |
|
|
|
|
</Button> |
|
|
|
|
</Tooltip> |
|
|
|
|
)} |
|
|
|
|
<Tooltip title="Export Excel"> |
|
|
|
|
<Popover |
|
|
|
|
// content={<a onClick={hide}>Close</a>}
|
|
|
|
@ -1486,7 +1602,10 @@ const CreatedProyek = ({ params, ...props }) => {
|
|
|
|
|
</Row> |
|
|
|
|
</CardHeader> |
|
|
|
|
<CardBody> |
|
|
|
|
<Spin tip="Loading..." spinning={loading}> |
|
|
|
|
{RenderTable} |
|
|
|
|
</Spin> |
|
|
|
|
|
|
|
|
|
<Pagination |
|
|
|
|
style={{ marginTop: "25px" }} |
|
|
|
|
showSizeChanger |
|
|
|
|