Browse Source

fix: add props & adding multi location hierarchy

pull/1/head
wahyun 6 months ago
parent
commit
075f6bbda4
  1. 3
      src/views/SimproV2/CreatedProyek/DialogFormHierarchy.js
  2. 57
      src/views/SimproV2/CreatedProyek/DialogHierarchy.js
  3. 22
      src/views/SimproV2/CreatedProyek/index.js

3
src/views/SimproV2/CreatedProyek/DialogFormHierarchy.js

@ -3,9 +3,6 @@ import {
Modal, ModalHeader, ModalBody, ModalFooter, Modal, ModalHeader, ModalBody, ModalFooter,
Button, Form, FormGroup, Label, Input, Col, Row Button, Form, FormGroup, Label, Input, Col, Row
} from 'reactstrap'; } from 'reactstrap';
import { DatePicker, Tooltip, Select } from 'antd';
import { formatRupiah, formatNumber } from '../../../const/CustomFunc'
import moment from 'moment';
import 'antd/dist/antd.css'; import 'antd/dist/antd.css';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';

57
src/views/SimproV2/CreatedProyek/DialogHierarchy.js

@ -1,7 +1,7 @@
import React, { useEffect, useState, useMemo } from 'react' import React, { useEffect, useState, useMemo } from 'react'
import { Modal, ModalHeader, ModalBody, } from 'reactstrap'; import { Modal, ModalHeader, ModalBody, } from 'reactstrap';
import { Button } from 'reactstrap'; import { Button } from 'reactstrap';
import { Space, Table, Tooltip, Spin } from 'antd'; import { Table, Tooltip, Spin } from 'antd';
import 'antd/dist/antd.css'; import 'antd/dist/antd.css';
import moment from 'moment'; import moment from 'moment';
import SweetAlert from 'react-bootstrap-sweetalert'; import SweetAlert from 'react-bootstrap-sweetalert';
@ -14,8 +14,7 @@ import DialogFormGantt from './DialogFormGantt';
import DialogGantt from './DialogGantt'; import DialogGantt from './DialogGantt';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import _ from 'lodash'; import _ from 'lodash';
const DialogHierarchy = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName, dataViewStartDate }) => { const DialogHierarchy = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName, dataViewStartDate, token, role_id, user_id, companyName, companyId, isLogin }) => {
const token = localStorage.getItem("token")
const HEADER = { const HEADER = {
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
@ -26,7 +25,6 @@ const DialogHierarchy = ({ openDialog, closeDialog, toggleDialog, idTask, proyek
const [id, setId] = useState(0) const [id, setId] = useState(0)
const [parentId, setParentId] = useState(0) const [parentId, setParentId] = useState(0)
const [parentName, setParentName] = useState(null) const [parentName, setParentName] = useState(null)
const [dataGantt, setDataGantt] = useState([])
const [typeDialog, setTypeDialog] = useState("add") const [typeDialog, setTypeDialog] = useState("add")
const [openDialogForm, setOpenDialogForm] = useState(false) const [openDialogForm, setOpenDialogForm] = useState(false)
const [openDialogGantt, setOpenDialogGantt] = useState(false) const [openDialogGantt, setOpenDialogGantt] = useState(false)
@ -36,7 +34,6 @@ const DialogHierarchy = ({ openDialog, closeDialog, toggleDialog, idTask, proyek
const [alertDelete, setAlertDelete] = useState(false) const [alertDelete, setAlertDelete] = useState(false)
const [idDelete, setIdDelete] = useState(0) const [idDelete, setIdDelete] = useState(0)
const [idGantt, setIdGantt] = useState(0) const [idGantt, setIdGantt] = useState(0)
const [humanResource, setHumanResource] = useState([])
const { t } = useTranslation(); const { t } = useTranslation();
const [loading, setLoading] = useState(true); const [loading, setLoading] = useState(true);
useEffect(() => { useEffect(() => {
@ -44,40 +41,11 @@ const DialogHierarchy = ({ openDialog, closeDialog, toggleDialog, idTask, proyek
setLoading(true); setLoading(true);
getdataHierarchy(); getdataHierarchy();
} }
}, [idTask, openDialog, closeDialog, openDialogFormGantt]) }, [idTask, openDialog, openDialogFormGantt])
useEffect(() => { useEffect(() => {
if (!openDialog) {
setDataHierarchy([]); setDataHierarchy([]);
} else { }, [openDialog])
}
}, [openDialog, closeDialog])
const getDataHumanResource = async () => {
const result = await axios
.get(USER_LIST, HEADER)
.then(res => res)
.catch((error) => error.response);
if (result && result.status == 200) {
setTransferUser(result.data.data);
} else {
}
}
const setTransferUser = (data) => {
const finalData = []
data.map((val, index) => {
let data = {
key: val.id,
title: val.name
}
finalData.push(data)
});
setHumanResource(finalData)
}
const handleAdd = async () => { const handleAdd = async () => {
await setTypeDialog("Save") await setTypeDialog("Save")
@ -137,8 +105,6 @@ const DialogHierarchy = ({ openDialog, closeDialog, toggleDialog, idTask, proyek
const closeDialogFromHierarchy = (type, data) => { const closeDialogFromHierarchy = (type, data) => {
if (type == 'save') { if (type == 'save') {
saveHierarchy(data) saveHierarchy(data)
} else {
updateHierarchy(data)
} }
setId(0); setId(0);
setOpenDialogForm(false); setOpenDialogForm(false);
@ -157,11 +123,6 @@ const DialogHierarchy = ({ openDialog, closeDialog, toggleDialog, idTask, proyek
} }
} }
const updateHierarchy = async (data) => {
}
const getdataHierarchy = async () => { const getdataHierarchy = async () => {
const url = HIERARCHY_FTTH_TREE(idTask) const url = HIERARCHY_FTTH_TREE(idTask)
const result = await axios const result = await axios
@ -311,9 +272,6 @@ const DialogHierarchy = ({ openDialog, closeDialog, toggleDialog, idTask, proyek
</div> </div>
</Spin> </Spin>
</ModalBody> </ModalBody>
{/* <ModalFooter>
<Button className="capitalize" color="secondary" onClick={() => handleCancel()}>Batal</Button>
</ModalFooter> */}
</Modal> </Modal>
<NotificationContainer /> <NotificationContainer />
<SweetAlert <SweetAlert
@ -335,6 +293,13 @@ const DialogHierarchy = ({ openDialog, closeDialog, toggleDialog, idTask, proyek
hierarchyId={parentId} hierarchyId={parentId}
hierarchyName={parentName} hierarchyName={parentName}
idTask={idTask} idTask={idTask}
role_id={role_id}
user_id={user_id}
token={token}
isLogin={isLogin}
companyName={companyName}
proyekName={proyekName}
companyId={companyId}
openDialogHierarchy={openDialog} openDialogHierarchy={openDialog}
dataViewStartDate={dataViewStartDate} dataViewStartDate={dataViewStartDate}
/> />

22
src/views/SimproV2/CreatedProyek/index.js

@ -428,7 +428,7 @@ const CreatedProyek = ({ params, ...props }) => {
{ {
name: "m_type_proyek", name: "m_type_proyek",
column_join: "type_proyek_id", column_join: "type_proyek_id",
column_results: ["name", "description"], column_results: ["name", "description", "is_multiLocation"],
} }
], ],
orders: { columns: ["nama"], ascending: true }, orders: { columns: ["nama"], ascending: true },
@ -583,6 +583,7 @@ const CreatedProyek = ({ params, ...props }) => {
setDataViewStartDate(data.mulai_proyek) setDataViewStartDate(data.mulai_proyek)
setidTask(data.id); setidTask(data.id);
setProyekName(data.nama); setProyekName(data.nama);
setCompanyName(role_name === 'Super Admin' ? data.join_third_company_name : JSON.parse(configApp).company_name);
setCompanyId(data.company_id); setCompanyId(data.company_id);
setOpenDialogGantt(true); setOpenDialogGantt(true);
}; };
@ -1686,13 +1687,13 @@ const CreatedProyek = ({ params, ...props }) => {
const popupMenuGantt = (text, record) => { const popupMenuGantt = (text, record) => {
return ( return (
<div> <div>
{text.type_proyek_id !== 9 && loadVersionGantt && ( {text.join_second_is_multiLocation !== true && loadVersionGantt && (
<div className="menu-list"> <div className="menu-list">
<Skeleton active /> <Skeleton active />
</div> </div>
)} )}
{!loadVersionGantt && text.type_proyek_id !== 9 && ( {!loadVersionGantt && text.join_second_is_multiLocation !== true && (
<> <>
{dataVersionGantt.slice(0, 8).map((res) => ( {dataVersionGantt.slice(0, 8).map((res) => (
<Link to={{ <Link to={{
@ -1704,7 +1705,7 @@ const CreatedProyek = ({ params, ...props }) => {
user_id, user_id,
company_id: text.company_id, company_id: text.company_id,
dataViewStartDate, dataViewStartDate,
configApp companyName: (role_name === 'Super Admin' ? text.join_third_company_name : JSON.parse(configApp).company_name)
} }
}}> }}>
<div className="menu-list"> <div className="menu-list">
@ -1729,7 +1730,7 @@ const CreatedProyek = ({ params, ...props }) => {
)} )}
</> </>
)} )}
{text.type_proyek_id == 9 ? ( {text.join_second_is_multiLocation == true ? (
<div <div
className="menu-list" className="menu-list"
onClick={() => handleOpenDialogHierarchy(text)} onClick={() => handleOpenDialogHierarchy(text)}
@ -1799,7 +1800,7 @@ const CreatedProyek = ({ params, ...props }) => {
content={popupMenuGantt(text, record)} content={popupMenuGantt(text, record)}
trigger="click" trigger="click"
> >
{text.type_proyek_id == 9 ? ( {text.join_second_is_multiLocation == true ? (
<Button size="small" type="link" style={{ color: "green" }}> <Button size="small" type="link" style={{ color: "green" }}>
<i className="fa fa-bars"></i> <i className="fa fa-bars"></i>
</Button> </Button>
@ -2103,6 +2104,7 @@ const CreatedProyek = ({ params, ...props }) => {
closeDialog={handleCloseReport} closeDialog={handleCloseReport}
toggleDialog={toggleAddDialogRA} toggleDialog={toggleAddDialogRA}
projectId={projectId} projectId={projectId}
token={token}
proyekName={proyekName} proyekName={proyekName}
/> />
), ),
@ -2119,7 +2121,7 @@ const CreatedProyek = ({ params, ...props }) => {
user_id={user_id} user_id={user_id}
token={token} token={token}
isLogin={isLogin} isLogin={isLogin}
configApp={configApp} companyName={companyName}
proyekName={proyekName} proyekName={proyekName}
companyId={companyId} companyId={companyId}
dataViewStartDate={dataViewStartDate} dataViewStartDate={dataViewStartDate}
@ -2135,7 +2137,13 @@ const CreatedProyek = ({ params, ...props }) => {
closeDialog={closeDialogHierarchy} closeDialog={closeDialogHierarchy}
toggleDialog={toggleDialogHierarchy} toggleDialog={toggleDialogHierarchy}
idTask={idTask} idTask={idTask}
role_id={role_id}
user_id={user_id}
token={token}
isLogin={isLogin}
companyName={companyName}
proyekName={proyekName} proyekName={proyekName}
companyId={companyId}
dataViewStartDate={dataViewStartDate} dataViewStartDate={dataViewStartDate}
/> />
), ),

Loading…
Cancel
Save