Browse Source

add divisi project field

pull/2/head
Muhammad Sulaiman Yusuf 2 years ago
parent
commit
2395642628
  1. 6
      src/views/SimproV2/CreatedProyek/DialogForm.js
  2. 30
      src/views/SimproV2/CreatedProyek/DialogFormProyek.js
  3. 50
      src/views/SimproV2/CreatedProyek/index.js

6
src/views/SimproV2/CreatedProyek/DialogForm.js

@ -2,7 +2,6 @@ import React, { useEffect, useState } from "react";
import { Modal, ModalHeader, ModalBody, ModalFooter } from "reactstrap"; import { Modal, ModalHeader, ModalBody, ModalFooter } from "reactstrap";
import { Button, Form, FormGroup, Label, Input, Col, Row } from "reactstrap"; import { Button, Form, FormGroup, Label, Input, Col, Row } from "reactstrap";
import { DatePicker, Tooltip, Select } from "antd"; import { DatePicker, Tooltip, Select } from "antd";
// import { Language } from 'src/const/LanguageConst';
import axios from "../../../const/interceptorApi"; import axios from "../../../const/interceptorApi";
import moment from "moment"; import moment from "moment";
import { import {
@ -18,7 +17,6 @@ import {
} from "../../../const/ApiConst"; } from "../../../const/ApiConst";
const { Option } = Select; const { Option } = Select;
// import DialogMap from './DialogMap';
const DialogForm = ({ const DialogForm = ({
openDialog, openDialog,
@ -56,7 +54,6 @@ const DialogForm = ({
.get(URL, HEADER) .get(URL, HEADER)
.then((res) => res) .then((res) => res)
.catch((err) => err.response); .catch((err) => err.response);
console.log("proyek by id", result);
if (result && result.data && result.data.code === 200) { if (result && result.data && result.data.code === 200) {
const val = result.data.data; const val = result.data.data;
setName(val.nama); setName(val.nama);
@ -93,7 +90,6 @@ const DialogForm = ({
useEffect(() => { useEffect(() => {
if (idTask && idTask > 0) { if (idTask && idTask > 0) {
console.log("cel data Edit");
handleGetdataIdproyek(idTask); handleGetdataIdproyek(idTask);
} else { } else {
handleCLearData(); handleCLearData();
@ -135,7 +131,6 @@ const DialogForm = ({
area_kerja: workArea, area_kerja: workArea,
keterangan: description, keterangan: description,
}; };
console.log(data);
closeDialog("add", data); closeDialog("add", data);
} }
handleCLearData(); handleCLearData();
@ -151,7 +146,6 @@ const DialogForm = ({
}; };
const onChangePm = (val) => { const onChangePm = (val) => {
console.log("chnage pm", val);
setPic(val); setPic(val);
}; };

30
src/views/SimproV2/CreatedProyek/DialogFormProyek.js

@ -27,6 +27,7 @@ const DialogFormProyek = ({
idTask, idTask,
dataTypeProyek, dataTypeProyek,
dataPhaseProject, dataPhaseProject,
dataDivisions,
dataPM, dataPM,
}) => { }) => {
const token = localStorage.getItem("token"); const token = localStorage.getItem("token");
@ -43,6 +44,7 @@ const DialogFormProyek = ({
const [biaya, setBiaya] = useState(""); const [biaya, setBiaya] = useState("");
const [typeProject, setTypeproject] = useState(null); const [typeProject, setTypeproject] = useState(null);
const [phaseProject, setPhaseProject] = useState(null); const [phaseProject, setPhaseProject] = useState(null);
const [divisiProject, setDivisiProject] = useState(null);
const [budgetHealth, setHealthBudget] = useState(null); const [budgetHealth, setHealthBudget] = useState(null);
const [sdm, setSdm] = useState(0); const [sdm, setSdm] = useState(0);
const [pic, setPic] = useState(null); const [pic, setPic] = useState(null);
@ -84,6 +86,7 @@ const DialogFormProyek = ({
setBiaya(val.rencana_biaya ? formatNumber(val.rencana_biaya) : ""); setBiaya(val.rencana_biaya ? formatNumber(val.rencana_biaya) : "");
setTypeproject(val.type_proyek_id); setTypeproject(val.type_proyek_id);
setPhaseProject(val.phase_id); setPhaseProject(val.phase_id);
setDivisiProject(val.divisi_id);
setHealthBudget(val.budget_health); setHealthBudget(val.budget_health);
setPic(val.pm_id); setPic(val.pm_id);
setStartDate(moment(val.mulai_proyek)); setStartDate(moment(val.mulai_proyek));
@ -198,6 +201,7 @@ const DialogFormProyek = ({
akhir_proyek: endDate, akhir_proyek: endDate,
type_proyek_id: parseInt(typeProject), type_proyek_id: parseInt(typeProject),
phase_id: parseInt(phaseProject), phase_id: parseInt(phaseProject),
divisi_id: parseInt(divisiProject),
budget_health: budgetHealth, budget_health: budgetHealth,
pm_id: pic, pm_id: pic,
investor, investor,
@ -224,6 +228,7 @@ const DialogFormProyek = ({
akhir_proyek: endDate, akhir_proyek: endDate,
type_proyek_id: parseInt(typeProject), type_proyek_id: parseInt(typeProject),
phase_id: parseInt(phaseProject), phase_id: parseInt(phaseProject),
divisi_id: parseInt(divisiProject),
health_budget: budgetHealth, health_budget: budgetHealth,
pm_id: pic, pm_id: pic,
investor, investor,
@ -258,6 +263,10 @@ const DialogFormProyek = ({
setPhaseProject(val); setPhaseProject(val);
}; };
const onChangeDivisiProject = (val) => {
setDivisiProject(val);
};
const onChangeBudgetHealth = (val) => { const onChangeBudgetHealth = (val) => {
setHealthBudget(val); setHealthBudget(val);
}; };
@ -590,6 +599,25 @@ const DialogFormProyek = ({
</FormGroup> </FormGroup>
</Col> </Col>
</Row> </Row>
<Row>
<Col md={6}>
<FormGroup>
<Label>Handled By Division</Label>
<Select
value={divisiProject}
defaultValue={divisiProject}
onChange={onChangeDivisiProject}
style={{ width: "100%" }}
>
{dataDivisions.map((res) => (
<Option key={res.id} value={res.id}>
{res.displayName}
</Option>
))}
</Select>
</FormGroup>
</Col>
</Row>
<Divider orientation="left" plain> <Divider orientation="left" plain>
Info Dashboard Info Dashboard
</Divider> </Divider>
@ -598,7 +626,6 @@ const DialogFormProyek = ({
<FormGroup> <FormGroup>
<Label>Phase</Label> <Label>Phase</Label>
<Select <Select
showSearch
value={phaseProject} value={phaseProject}
defaultValue={phaseProject} defaultValue={phaseProject}
onChange={onChangePhaseProject} onChange={onChangePhaseProject}
@ -616,7 +643,6 @@ const DialogFormProyek = ({
<FormGroup> <FormGroup>
<Label>Cost Health</Label> <Label>Cost Health</Label>
<Select <Select
showSearch
value={budgetHealth} value={budgetHealth}
defaultValue={budgetHealth} defaultValue={budgetHealth}
onChange={onChangeBudgetHealth} onChange={onChangeBudgetHealth}

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

@ -1,6 +1,5 @@
import React, { useState, useEffect, useMemo } from "react"; import React, { useState, useEffect, useMemo } from "react";
import { Card, CardBody, CardHeader, Col, Row, Input } from "reactstrap"; import { Card, CardBody, CardHeader, Col, Row, Input } from "reactstrap";
// import { DownloadOutlined } from '@ant-design/icons';
import axios from "../../../const/interceptorApi"; import axios from "../../../const/interceptorApi";
import jsPDF from "jspdf"; import jsPDF from "jspdf";
import autoTable from "jspdf-autotable"; import autoTable from "jspdf-autotable";
@ -51,6 +50,7 @@ import {
CHECKLIST_K3_LIST, CHECKLIST_K3_LIST,
VERSION_GANTT_SEARCH, VERSION_GANTT_SEARCH,
PHASE_PROYEK, PHASE_PROYEK,
DIVISI_LIST
} from "../../../const/ApiConst"; } from "../../../const/ApiConst";
import { import {
formatNumber, formatNumber,
@ -90,7 +90,6 @@ const CreatedProyek = ({ params, ...props }) => {
const [idTask, setidTask] = useState(0); const [idTask, setidTask] = useState(0);
const [dataTable, setDatatable] = useState([]); const [dataTable, setDatatable] = useState([]);
console.log(`dataTable`, dataTable);
const [search, setSearch] = useState(""); const [search, setSearch] = useState("");
const [currentPage, setCurrentPage] = useState(1); const [currentPage, setCurrentPage] = useState(1);
const [totalPage, setTotalPage] = useState(0); const [totalPage, setTotalPage] = useState(0);
@ -114,6 +113,7 @@ const CreatedProyek = ({ params, ...props }) => {
const [toolsResource, setToolsResource] = useState([]); const [toolsResource, setToolsResource] = useState([]);
const [dataTypeProyek, setDataTypeProyek] = useState([]); const [dataTypeProyek, setDataTypeProyek] = useState([]);
const [dataPhaseProject, setDataPhaseProject] = useState([]); const [dataPhaseProject, setDataPhaseProject] = useState([]);
const [dataDivisions, setDataDivisions] = useState([]);
const [dataPm, setDataPM] = useState([]); const [dataPm, setDataPM] = useState([]);
const [openDialogDoc, setOpenDialogDoc] = useState(false); const [openDialogDoc, setOpenDialogDoc] = useState(false);
const [proyekName, setProyekName] = useState(""); const [proyekName, setProyekName] = useState("");
@ -135,6 +135,7 @@ const CreatedProyek = ({ params, ...props }) => {
getDataToolsResource(); getDataToolsResource();
handleGetTipeProject(); handleGetTipeProject();
handleGetPhaseProject(); handleGetPhaseProject();
handleGetDivisions();
handleGetDataPm(); handleGetDataPm();
getDataK3(); getDataK3();
}, []); }, []);
@ -166,7 +167,6 @@ const CreatedProyek = ({ params, ...props }) => {
.get(TYPE_PROYEK, HEADER) .get(TYPE_PROYEK, HEADER)
.then((res) => res) .then((res) => res)
.catch((err) => err.response); .catch((err) => err.response);
console.log(result);
if (result && result.data && result.data.code === 200) { if (result && result.data && result.data.code === 200) {
setDataTypeProyek(result.data.data); setDataTypeProyek(result.data.data);
} else { } else {
@ -178,19 +178,26 @@ const CreatedProyek = ({ params, ...props }) => {
.get(PHASE_PROYEK, HEADER) .get(PHASE_PROYEK, HEADER)
.then((res) => res) .then((res) => res)
.catch((err) => err.response); .catch((err) => err.response);
console.log("PHASEEEE", result);
if (result && result.data && result.data.code === 200) { if (result && result.data && result.data.code === 200) {
setDataPhaseProject(result.data.data); setDataPhaseProject(result.data.data);
} }
}; };
const handleGetDivisions = async () => {
const result = await axios
.get(DIVISI_LIST, HEADER)
.then((res) => res)
.catch((err) => err.response);
if (result && result.data && result.data.code === 200) {
setDataDivisions(result.data.data);
}
};
const handleGetDataPm = async () => { const handleGetDataPm = async () => {
const result = await axios const result = await axios
.get(USER_LIST, HEADER) .get(USER_LIST, HEADER)
.then((res) => res) .then((res) => res)
.catch((err) => err.response); .catch((err) => err.response);
console.log(result);
if (result && result.data && result.data.code === 200) { if (result && result.data && result.data.code === 200) {
setDataPM(result.data.data); setDataPM(result.data.data);
} else { } else {
@ -208,7 +215,7 @@ const CreatedProyek = ({ params, ...props }) => {
columns: [ columns: [
{ {
name: "nama", name: "nama",
logic_operator: "like", logic_operator: "ilike",
value: search, value: search,
operator: "AND", operator: "AND",
}, },
@ -244,7 +251,6 @@ const CreatedProyek = ({ params, ...props }) => {
if (result && result.data && result.data.code == 200) { if (result && result.data && result.data.code == 200) {
// console.log("cek proyek", result)
let dataRes = result.data.data || []; let dataRes = result.data.data || [];
setDatatable(dataRes); setDatatable(dataRes);
@ -261,7 +267,6 @@ const CreatedProyek = ({ params, ...props }) => {
.catch((error) => error.response); .catch((error) => error.response);
if (result && result.data && result.data.code == 200) { if (result && result.data && result.data.code == 200) {
console.log("cek material resource", result.data.data);
let dataRes = result.data.data || []; let dataRes = result.data.data || [];
setMaterialResource(dataRes); setMaterialResource(dataRes);
} else { } else {
@ -304,7 +309,6 @@ const CreatedProyek = ({ params, ...props }) => {
.catch((error) => error.response); .catch((error) => error.response);
if (result && result.data && result.data.code == 200) { if (result && result.data && result.data.code == 200) {
console.log("cek tools resource", result.data.data);
let dataRes = result.data.data || []; let dataRes = result.data.data || [];
setToolsResource(dataRes); setToolsResource(dataRes);
} else { } else {
@ -319,7 +323,6 @@ const CreatedProyek = ({ params, ...props }) => {
.catch((error) => error.response); .catch((error) => error.response);
if (result && result.data && result.data.code == 200) { if (result && result.data && result.data.code == 200) {
console.log("cek k3 list", result.data.data);
let dataRes = result.data.data || []; let dataRes = result.data.data || [];
const finalData = []; const finalData = [];
if (dataRes.length > 0) { if (dataRes.length > 0) {
@ -343,7 +346,6 @@ const CreatedProyek = ({ params, ...props }) => {
}; };
const handleOpenDialogProyek = (id) => { const handleOpenDialogProyek = (id) => {
console.log("handleOpenDialogProyek", id);
setOpenDialogProyek(true); setOpenDialogProyek(true);
setidTask(id); setidTask(id);
}; };
@ -382,14 +384,12 @@ const CreatedProyek = ({ params, ...props }) => {
const handleOpenDialogTools = (data) => { const handleOpenDialogTools = (data) => {
setOpenDialogTools(true); setOpenDialogTools(true);
console.log("handleOpenDialogTools", data);
setidTask(data.id); setidTask(data.id);
setProyekName(data.nama); setProyekName(data.nama);
setUserProyek(data.user_proyeks); setUserProyek(data.user_proyeks);
}; };
const handleOpenDialogViewDetail = async (data) => { const handleOpenDialogViewDetail = async (data) => {
// console.log('handleOpenDialogViewDetail', data);
setidTask(data.id); setidTask(data.id);
// setDataView(data) // setDataView(data)
await getDataProject(data.id); await getDataProject(data.id);
@ -541,7 +541,6 @@ const CreatedProyek = ({ params, ...props }) => {
.post(PROYEK_ADD, formData, HEADER) .post(PROYEK_ADD, formData, HEADER)
.then((res) => res) .then((res) => res)
.catch((error) => error.response); .catch((error) => error.response);
console.log(result);
if (result && result.data && result.data.code === 200) { if (result && result.data && result.data.code === 200) {
const { participants, milestones, approval } = data.projectCharter; const { participants, milestones, approval } = data.projectCharter;
const resultParticipant = await saveParticipant( const resultParticipant = await saveParticipant(
@ -556,7 +555,6 @@ const CreatedProyek = ({ params, ...props }) => {
result.data.data_result.id, result.data.data_result.id,
approval approval
); );
console.log({ resultApproval, resultMilestone, resultParticipant });
if ( if (
resultParticipant === "berhasil" && resultParticipant === "berhasil" &&
resultMilestone === "berhasil" && resultMilestone === "berhasil" &&
@ -586,11 +584,9 @@ const CreatedProyek = ({ params, ...props }) => {
}; };
return axios.post(PROJECT_PARTICIPANT_ADD, payload, HEADER); return axios.post(PROJECT_PARTICIPANT_ADD, payload, HEADER);
}); });
console.log(request);
const arr = await Promise.all(request) const arr = await Promise.all(request)
.then((values) => values) .then((values) => values)
.catch((err) => err.response); .catch((err) => err.response);
console.log("result participant", arr);
const result = arr.map((res) => res.data.code == 200); const result = arr.map((res) => res.data.code == 200);
if (result.length > 0) { if (result.length > 0) {
return "gagal"; return "gagal";
@ -609,11 +605,9 @@ const CreatedProyek = ({ params, ...props }) => {
}; };
return axios.post(PROJECT_MILESTONE_ADD, payload, HEADER); return axios.post(PROJECT_MILESTONE_ADD, payload, HEADER);
}); });
console.log(request);
const arr = await Promise.all(request) const arr = await Promise.all(request)
.then((values) => values) .then((values) => values)
.catch((err) => err.response); .catch((err) => err.response);
console.log("result milestone", arr);
const result = arr.map((res) => res.data.code !== 200); const result = arr.map((res) => res.data.code !== 200);
if (result.length > 0) { if (result.length > 0) {
return "gagal"; return "gagal";
@ -632,11 +626,9 @@ const CreatedProyek = ({ params, ...props }) => {
}; };
return axios.post(PROJECT_APPROVAL_ADD, payload, HEADER); return axios.post(PROJECT_APPROVAL_ADD, payload, HEADER);
}); });
console.log(request);
const arr = await Promise.all(request) const arr = await Promise.all(request)
.then((values) => values) .then((values) => values)
.catch((err) => err.response); .catch((err) => err.response);
console.log("result approval", arr);
const result = arr.map((res) => res.data.code !== 200); const result = arr.map((res) => res.data.code !== 200);
if (result.length > 0) { if (result.length > 0) {
return "gagal"; return "gagal";
@ -654,7 +646,6 @@ const CreatedProyek = ({ params, ...props }) => {
.put(urlEdit, formData, HEADER) .put(urlEdit, formData, HEADER)
.then((res) => res) .then((res) => res)
.catch((error) => error.response); .catch((error) => error.response);
console.log("cek result", result);
const resultParticipant = await editParticipant(data.id, participants); const resultParticipant = await editParticipant(data.id, participants);
const resultMilestone = await editMilestone(data.id, milestones); const resultMilestone = await editMilestone(data.id, milestones);
const resultApproval = await editApproval(data.id, approval); const resultApproval = await editApproval(data.id, approval);
@ -677,12 +668,9 @@ const CreatedProyek = ({ params, ...props }) => {
}; };
return axios.post(PROJECT_PARTICIPANT_ADD, payload, HEADER); return axios.post(PROJECT_PARTICIPANT_ADD, payload, HEADER);
}); });
console.log(request);
const arr = await Promise.all(request) const arr = await Promise.all(request)
.then((values) => values) .then((values) => values)
.catch((err) => err.response); .catch((err) => err.response);
console.log("result participant", arr);
// let dataTittle = arr.data.tittle
const result = arr.map((res) => res.data.code !== 200); const result = arr.map((res) => res.data.code !== 200);
if (result.length > 0) { if (result.length > 0) {
return "gagal"; return "gagal";
@ -693,7 +681,6 @@ const CreatedProyek = ({ params, ...props }) => {
const editMilestone = async (id, data) => { const editMilestone = async (id, data) => {
await axios.delete(PROJECT_MILESTONE_DELETE_BY_PROYEK(id), HEADER); await axios.delete(PROJECT_MILESTONE_DELETE_BY_PROYEK(id), HEADER);
console.log("res due", data);
const request = data.map((res) => { const request = data.map((res) => {
const payload = { const payload = {
proyek_id: parseInt(id), proyek_id: parseInt(id),
@ -703,11 +690,9 @@ const CreatedProyek = ({ params, ...props }) => {
}; };
return axios.post(PROJECT_MILESTONE_ADD, payload, HEADER); return axios.post(PROJECT_MILESTONE_ADD, payload, HEADER);
}); });
console.log(request);
const arr = await Promise.all(request) const arr = await Promise.all(request)
.then((values) => values) .then((values) => values)
.catch((err) => err.response); .catch((err) => err.response);
console.log("result milestone", arr);
const result = arr.map((res) => res.data.code !== 200); const result = arr.map((res) => res.data.code !== 200);
if (result.length > 0) { if (result.length > 0) {
return "gagal"; return "gagal";
@ -716,7 +701,6 @@ const CreatedProyek = ({ params, ...props }) => {
}; };
const editApproval = async (id, data) => { const editApproval = async (id, data) => {
console.log("cek data edit approval", data);
await axios.delete(PROJECT_APPROVAL_DELETE_BY_PROYEK(id), HEADER); await axios.delete(PROJECT_APPROVAL_DELETE_BY_PROYEK(id), HEADER);
const request = data.map((res) => { const request = data.map((res) => {
const payload = { const payload = {
@ -727,11 +711,9 @@ const CreatedProyek = ({ params, ...props }) => {
}; };
return axios.post(PROJECT_APPROVAL_ADD, payload, HEADER); return axios.post(PROJECT_APPROVAL_ADD, payload, HEADER);
}); });
console.log(request);
const arr = await Promise.all(request) const arr = await Promise.all(request)
.then((values) => values) .then((values) => values)
.catch((err) => err.response); .catch((err) => err.response);
console.log("result approval", arr);
// if(arr) // if(arr)
// const result = arr.map(res => res.data.code !== 200) // const result = arr.map(res => res.data.code !== 200)
@ -742,7 +724,6 @@ const CreatedProyek = ({ params, ...props }) => {
}; };
const handleDelete = async (id) => { const handleDelete = async (id) => {
// console.log('Delete')
await setAlertDelete(true); await setAlertDelete(true);
await setIdDelete(id); await setIdDelete(id);
}; };
@ -758,9 +739,6 @@ const CreatedProyek = ({ params, ...props }) => {
const handleExportExcel = async () => { const handleExportExcel = async () => {
const payload = { const payload = {
paging: { start: 0, length: -1 }, paging: { start: 0, length: -1 },
// "columns": [
// { "name": "nama", "logic_operator": "like", "value": search, "operator": "AND" }
// ],
joins: [], joins: [],
orders: { columns: ["id"], ascending: false }, orders: { columns: ["id"], ascending: false },
}; };
@ -807,7 +785,6 @@ const CreatedProyek = ({ params, ...props }) => {
}; };
excelData.push(dataRow); excelData.push(dataRow);
}); });
// console.log("cek excel data", excelData)
await setDataExport(excelData); await setDataExport(excelData);
} else { } else {
NotificationManager.error("Gagal Export Data!!", "Failed"); NotificationManager.error("Gagal Export Data!!", "Failed");
@ -1151,6 +1128,7 @@ const CreatedProyek = ({ params, ...props }) => {
idTask={idTask} idTask={idTask}
dataTypeProyek={dataTypeProyek} dataTypeProyek={dataTypeProyek}
dataPhaseProject={dataPhaseProject} dataPhaseProject={dataPhaseProject}
dataDivisions={dataDivisions}
dataPM={dataPm} dataPM={dataPm}
/> />
), ),

Loading…
Cancel
Save