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

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

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

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

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

Loading…
Cancel
Save