debug road mission cartable area view
This commit is contained in:
@@ -6,10 +6,15 @@ import ShowBound from "../showBound";
|
|||||||
import L from "leaflet";
|
import L from "leaflet";
|
||||||
|
|
||||||
const ShowArea = ({ area }) => {
|
const ShowArea = ({ area }) => {
|
||||||
|
const latLngs = useMemo(() => {
|
||||||
|
return area.coordinates.map(([lng, lat]) => [lat, lng]);
|
||||||
|
}, [area.coordinates]);
|
||||||
|
|
||||||
const bound = useMemo(
|
const bound = useMemo(
|
||||||
() => (area.type == "polygon" ? L.polygon([...area.coordinates]) : L.polyline([...area.coordinates])),
|
() => (area.type === "polygon" ? L.polygon(latLngs) : L.polyline(latLngs)),
|
||||||
[area]
|
[area.type, latLngs]
|
||||||
);
|
);
|
||||||
|
|
||||||
const [openAreaDialog, setOpenAreaDialog] = useState(false);
|
const [openAreaDialog, setOpenAreaDialog] = useState(false);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -21,10 +21,24 @@ const Create = ({ mutate }) => {
|
|||||||
setSubmitting(true);
|
setSubmitting(true);
|
||||||
const bound = result.bound.getLatLngs();
|
const bound = result.bound.getLatLngs();
|
||||||
let area =
|
let area =
|
||||||
result.bound_type == "polygon"
|
result.bound_type === "polygon"
|
||||||
? bound.map((ring) => ring.map((latlng) => [latlng.lat, latlng.lng]))[0]
|
? bound.map((ring) =>
|
||||||
: bound.map((latlng) => [latlng.lat, latlng.lng]);
|
ring.map((latlng) => ([
|
||||||
|
latlng.lng,
|
||||||
|
latlng.lat,
|
||||||
|
]))
|
||||||
|
)[0]
|
||||||
|
: bound.map((latlng) => ([
|
||||||
|
latlng.lng,
|
||||||
|
latlng.lat
|
||||||
|
]
|
||||||
|
));
|
||||||
|
|
||||||
|
// بستن polygon
|
||||||
|
if (result.bound_type === "polygon" && area.length > 0) {
|
||||||
|
const firstPoint = area[0];
|
||||||
|
area.push({ ...firstPoint });
|
||||||
|
}
|
||||||
await requestServer(REQUEST_MISSION, "post", {
|
await requestServer(REQUEST_MISSION, "post", {
|
||||||
data: {
|
data: {
|
||||||
explanation: result.explanation,
|
explanation: result.explanation,
|
||||||
|
|||||||
@@ -1,121 +1,127 @@
|
|||||||
import { REQUEST_MISSION_WITHOUT_PROCESS } from "@/core/utils/routes";
|
import { REQUEST_MISSION_WITHOUT_PROCESS } from "@/core/utils/routes";
|
||||||
import useRequest from "@/lib/hooks/useRequest";
|
import useRequest from "@/lib/hooks/useRequest";
|
||||||
import { AddCircle, AddCircleOutline, Close } from "@mui/icons-material";
|
import { AddCircle, AddCircleOutline, Close } from "@mui/icons-material";
|
||||||
import { Button, Dialog, IconButton, useMediaQuery, useTheme } from "@mui/material";
|
import { Button, Dialog, IconButton, useMediaQuery, useTheme } from "@mui/material";
|
||||||
import moment from "jalali-moment";
|
import moment from "jalali-moment";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import CreateForm from "./Form";
|
import CreateForm from "./Form";
|
||||||
|
|
||||||
const CreateWithoutProcess = ({ mutate }) => {
|
const CreateWithoutProcess = ({ mutate }) => {
|
||||||
const [submitting, setSubmitting] = useState(false);
|
const [submitting, setSubmitting] = useState(false);
|
||||||
const requestServer = useRequest({ notificationSuccess: true });
|
const requestServer = useRequest({ notificationSuccess: true });
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const isMobile = useMediaQuery(theme.breakpoints.down("sm"));
|
const isMobile = useMediaQuery(theme.breakpoints.down("sm"));
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
|
|
||||||
const handleOpen = () => {
|
const handleOpen = () => {
|
||||||
setOpen(true);
|
setOpen(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
const submitForm = async (result) => {
|
const submitForm = async (result) => {
|
||||||
setSubmitting(true);
|
setSubmitting(true);
|
||||||
const bound = result.bound.getLatLngs();
|
const bound = result.bound.getLatLngs();
|
||||||
let area =
|
let area =
|
||||||
result.bound_type == "polygon"
|
result.bound_type === "polygon"
|
||||||
? bound.map((ring) => ring.map((latlng) => [latlng.lat, latlng.lng]))[0]
|
? bound.map((ring) => ring.map((latlng) => [latlng.lng, latlng.lat]))[0]
|
||||||
: bound.map((latlng) => [latlng.lat, latlng.lng]);
|
: bound.map((latlng) => [latlng.lng, latlng.lat]);
|
||||||
|
|
||||||
await requestServer(REQUEST_MISSION_WITHOUT_PROCESS, "post", {
|
// بستن polygon
|
||||||
data: {
|
if (result.bound_type === "polygon" && area.length > 0) {
|
||||||
explanation: result.explanation,
|
const firstPoint = area[0];
|
||||||
category_id: result.category_id,
|
area.push({ ...firstPoint });
|
||||||
...(result.category_id == 3
|
}
|
||||||
? {
|
|
||||||
road_observed_id: result.road_observed_id,
|
await requestServer(REQUEST_MISSION_WITHOUT_PROCESS, "post", {
|
||||||
}
|
data: {
|
||||||
: {}),
|
explanation: result.explanation,
|
||||||
area: {
|
category_id: result.category_id,
|
||||||
type: result.bound_type,
|
...(result.category_id == 3
|
||||||
coordinates: area,
|
? {
|
||||||
},
|
road_observed_id: result.road_observed_id,
|
||||||
...(result.rahdaran.length != 0 ? { rahdaran: result.rahdaran.map((r) => r.id) } : {}),
|
}
|
||||||
zone: result.region,
|
: {}),
|
||||||
end_point: result.end_point,
|
area: {
|
||||||
start_date: `${result.start_date} ${moment(result.start_time).format("HH:mm")}`,
|
type: result.bound_type,
|
||||||
end_date: `${result.end_date} ${moment(result.end_time).format("HH:mm")}`,
|
coordinates: area,
|
||||||
machines: [result.machine.id],
|
},
|
||||||
driver: result.driver.id,
|
...(result.rahdaran.length != 0 ? { rahdaran: result.rahdaran.map((r) => r.id) } : {}),
|
||||||
},
|
zone: result.region,
|
||||||
hasSidebarUpdate: true,
|
end_point: result.end_point,
|
||||||
})
|
start_date: `${result.start_date} ${moment(result.start_time).format("HH:mm")}`,
|
||||||
.then((response) => {
|
end_date: `${result.end_date} ${moment(result.end_time).format("HH:mm")}`,
|
||||||
mutate();
|
machines: [result.machine.id],
|
||||||
setOpen(false);
|
driver: result.driver.id,
|
||||||
})
|
},
|
||||||
.catch((error) => {})
|
hasSidebarUpdate: true,
|
||||||
.finally(() => {
|
})
|
||||||
setSubmitting(false);
|
.then((response) => {
|
||||||
});
|
mutate();
|
||||||
};
|
setOpen(false);
|
||||||
|
})
|
||||||
return (
|
.catch((error) => {})
|
||||||
<>
|
.finally(() => {
|
||||||
{isMobile ? (
|
setSubmitting(false);
|
||||||
<IconButton aria-label="ثبت ماموریت بدون فرایند" color="primary" onClick={handleOpen}>
|
});
|
||||||
<AddCircleOutline sx={{ fontSize: "25px" }} />
|
};
|
||||||
</IconButton>
|
|
||||||
) : (
|
return (
|
||||||
<Button
|
<>
|
||||||
size={"small"}
|
{isMobile ? (
|
||||||
variant="contained"
|
<IconButton aria-label="ثبت ماموریت بدون فرایند" color="primary" onClick={handleOpen}>
|
||||||
color="primary"
|
<AddCircleOutline sx={{ fontSize: "25px" }} />
|
||||||
startIcon={<AddCircle />}
|
</IconButton>
|
||||||
onClick={handleOpen}
|
) : (
|
||||||
>
|
<Button
|
||||||
ثبت ماموریت بدون فرایند
|
size={"small"}
|
||||||
</Button>
|
variant="contained"
|
||||||
)}
|
color="primary"
|
||||||
<Dialog open={open} fullWidth maxWidth="sm">
|
startIcon={<AddCircle />}
|
||||||
<IconButton
|
onClick={handleOpen}
|
||||||
aria-label="close"
|
>
|
||||||
onClick={() => setOpen(false)}
|
ثبت ماموریت بدون فرایند
|
||||||
sx={(theme) => ({
|
</Button>
|
||||||
position: "absolute",
|
)}
|
||||||
right: 8,
|
<Dialog open={open} fullWidth maxWidth="sm">
|
||||||
top: 8,
|
<IconButton
|
||||||
zIndex: 50,
|
aria-label="close"
|
||||||
color: theme.palette.grey[500],
|
onClick={() => setOpen(false)}
|
||||||
})}
|
sx={(theme) => ({
|
||||||
>
|
position: "absolute",
|
||||||
<Close />
|
right: 8,
|
||||||
</IconButton>
|
top: 8,
|
||||||
{open && (
|
zIndex: 50,
|
||||||
<CreateForm
|
color: theme.palette.grey[500],
|
||||||
defaultValues={{
|
})}
|
||||||
explanation: "",
|
>
|
||||||
category_id: "",
|
<Close />
|
||||||
road_observed_id: "",
|
</IconButton>
|
||||||
rahdaran: [],
|
{open && (
|
||||||
bound: null,
|
<CreateForm
|
||||||
bound_type: "polygon",
|
defaultValues={{
|
||||||
start_date: "",
|
explanation: "",
|
||||||
start_time: null,
|
category_id: "",
|
||||||
end_date: "",
|
road_observed_id: "",
|
||||||
end_time: null,
|
rahdaran: [],
|
||||||
end_point: "",
|
bound: null,
|
||||||
region: "",
|
bound_type: "polygon",
|
||||||
machine: null,
|
start_date: "",
|
||||||
driver: null,
|
start_time: null,
|
||||||
}}
|
end_date: "",
|
||||||
submitForm={submitForm}
|
end_time: null,
|
||||||
submitting={submitting}
|
end_point: "",
|
||||||
open={open}
|
region: "",
|
||||||
setOpen={setOpen}
|
machine: null,
|
||||||
mutate={mutate}
|
driver: null,
|
||||||
/>
|
}}
|
||||||
)}
|
submitForm={submitForm}
|
||||||
</Dialog>
|
submitting={submitting}
|
||||||
</>
|
open={open}
|
||||||
);
|
setOpen={setOpen}
|
||||||
};
|
mutate={mutate}
|
||||||
export default CreateWithoutProcess;
|
/>
|
||||||
|
)}
|
||||||
|
</Dialog>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
export default CreateWithoutProcess;
|
||||||
|
|||||||
@@ -6,10 +6,15 @@ import ShowBound from "../showBound";
|
|||||||
import L from "leaflet";
|
import L from "leaflet";
|
||||||
|
|
||||||
const ShowArea = ({ area }) => {
|
const ShowArea = ({ area }) => {
|
||||||
|
const latLngs = useMemo(() => {
|
||||||
|
return area.coordinates.map(([lng, lat]) => [lat, lng]);
|
||||||
|
}, [area.coordinates]);
|
||||||
|
|
||||||
const bound = useMemo(
|
const bound = useMemo(
|
||||||
() => (area.type == "polygon" ? L.polygon([...area.coordinates]) : L.polyline([...area.coordinates])),
|
() => (area.type === "polygon" ? L.polygon(latLngs) : L.polyline(latLngs)),
|
||||||
[area]
|
[area.type, latLngs]
|
||||||
);
|
);
|
||||||
|
|
||||||
const [openAreaDialog, setOpenAreaDialog] = useState(false);
|
const [openAreaDialog, setOpenAreaDialog] = useState(false);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -54,5 +59,5 @@ const ShowArea = ({ area }) => {
|
|||||||
</Dialog>
|
</Dialog>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};;
|
||||||
export default ShowArea;
|
export default ShowArea;
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import RowActions from "./RowActions";
|
|||||||
import MachinesDialog from "./RowActions/Machines";
|
import MachinesDialog from "./RowActions/Machines";
|
||||||
import Toolbar from "./Toolbar";
|
import Toolbar from "./Toolbar";
|
||||||
import RahdaranDialog from "./RowActions/Rahdaran";
|
import RahdaranDialog from "./RowActions/Rahdaran";
|
||||||
|
import DescriptionDialog from "@/components/dashboard/roadMissions/operator/RowActions/DescriptionDialog";
|
||||||
|
|
||||||
const OperatorList = () => {
|
const OperatorList = () => {
|
||||||
const columns = useMemo(
|
const columns = useMemo(
|
||||||
@@ -219,7 +220,7 @@ const OperatorList = () => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Cell: ({ renderedCellValue, row }) => {
|
Cell: ({ row }) => {
|
||||||
return (
|
return (
|
||||||
<Stack alignItems={"center"} justifyContent={"center"}>
|
<Stack alignItems={"center"} justifyContent={"center"}>
|
||||||
<RahdaranDialog rowId={row.original.id} />
|
<RahdaranDialog rowId={row.original.id} />
|
||||||
@@ -227,6 +228,33 @@ const OperatorList = () => {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
header: "دلیل رد درخواست",
|
||||||
|
id: "description",
|
||||||
|
enableColumnFilter: false,
|
||||||
|
enableSorting: false,
|
||||||
|
datatype: "text",
|
||||||
|
filterMode: "contains",
|
||||||
|
columnFilterModeOptions: ["equals", "contains"],
|
||||||
|
grow: false,
|
||||||
|
size: 100,
|
||||||
|
muiTableBodyCellProps: {
|
||||||
|
sx: {
|
||||||
|
borderLeft: "1px solid #e1e1e1",
|
||||||
|
py: 0,
|
||||||
|
"&:first-of-type": {
|
||||||
|
borderLeft: "unset",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Cell: ({ row }) => {
|
||||||
|
return (
|
||||||
|
<Stack alignItems={"center"} justifyContent={"center"}>
|
||||||
|
<DescriptionDialog description={row.original.description} />
|
||||||
|
</Stack>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
accessorFn: (row) =>
|
accessorFn: (row) =>
|
||||||
row.start_time ? moment(row.start_time).locale("fa").format("HH:mm | yyyy/MM/DD") : null,
|
row.start_time ? moment(row.start_time).locale("fa").format("HH:mm | yyyy/MM/DD") : null,
|
||||||
|
|||||||
@@ -12,14 +12,19 @@ const DialogAdd = ({ mutate, setOpen, oldBound, rahdaran, machine, row }) => {
|
|||||||
setSubmitting(true);
|
setSubmitting(true);
|
||||||
const bound = result.bound.getLatLngs();
|
const bound = result.bound.getLatLngs();
|
||||||
let area =
|
let area =
|
||||||
result.bound_type == "polygon"
|
result.bound_type === "polygon"
|
||||||
? bound.map((ring) => ring.map((latlng) => [latlng.lat, latlng.lng]))[0]
|
? bound.map((ring) => ring.map((latlng) => [latlng.lng, latlng.lat]))[0]
|
||||||
: bound.map((latlng) => [latlng.lat, latlng.lng]);
|
: bound.map((latlng) => [latlng.lng, latlng.lat]);
|
||||||
|
|
||||||
|
// بستن polygon
|
||||||
|
if (result.bound_type === "polygon" && area.length > 0) {
|
||||||
|
const firstPoint = area[0];
|
||||||
|
area.push({ ...firstPoint });
|
||||||
|
}
|
||||||
await requestServer(`${REQUEST_MISSION_CONTINUE_MISSION}/${row.original.id}`, "post", {
|
await requestServer(`${REQUEST_MISSION_CONTINUE_MISSION}/${row.original.id}`, "post", {
|
||||||
data: {
|
data: {
|
||||||
...(result.rahdaran.length != 0 ? { rahdaran: result.rahdaran.map((r) => r.id) } : {}),
|
...(result.rahdaran.length != 0 ? { rahdaran: result.rahdaran.map((r) => r.id) } : {}),
|
||||||
machines: [result.machine.id],
|
machine_id: result.machine.id,
|
||||||
driver: result.driver.id,
|
driver: result.driver.id,
|
||||||
zone: result.region,
|
zone: result.region,
|
||||||
type: result.type,
|
type: result.type,
|
||||||
|
|||||||
@@ -0,0 +1,59 @@
|
|||||||
|
import {
|
||||||
|
Button,
|
||||||
|
Card,
|
||||||
|
CardContent,
|
||||||
|
Dialog,
|
||||||
|
DialogActions,
|
||||||
|
DialogContent,
|
||||||
|
DialogTitle,
|
||||||
|
IconButton,
|
||||||
|
Tooltip,
|
||||||
|
Typography,
|
||||||
|
} from "@mui/material";
|
||||||
|
import RemoveRedEyeIcon from "@mui/icons-material/RemoveRedEye";
|
||||||
|
import { useState } from "react";
|
||||||
|
|
||||||
|
const DescriptionDialog = ({ description }) => {
|
||||||
|
const [openDescriptionDialog, setOpenDescriptionDialog] = useState(false);
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Tooltip title="دلیل رد درخواست">
|
||||||
|
<IconButton color="primary" onClick={() => setOpenDescriptionDialog(true)}>
|
||||||
|
<RemoveRedEyeIcon />
|
||||||
|
</IconButton>
|
||||||
|
</Tooltip>
|
||||||
|
<Dialog
|
||||||
|
fullWidth
|
||||||
|
open={openDescriptionDialog}
|
||||||
|
onClose={() => setOpenDescriptionDialog(false)}
|
||||||
|
PaperProps={{
|
||||||
|
sx: {
|
||||||
|
boxShadow: "rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px",
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
dir="rtl"
|
||||||
|
maxWidth={"sm"}
|
||||||
|
>
|
||||||
|
<DialogTitle sx={{ fontSize: "large" }}>دلیل رد درخواست</DialogTitle>
|
||||||
|
<DialogContent>
|
||||||
|
<Card elevation={0}>
|
||||||
|
<CardContent>
|
||||||
|
<Typography variant="body2">{description || "هیچ توضیحی موجود نیست"} </Typography>
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
</DialogContent>
|
||||||
|
<DialogActions>
|
||||||
|
<Button
|
||||||
|
onClick={() => setOpenDescriptionDialog(false)}
|
||||||
|
variant="outlined"
|
||||||
|
color="secondary"
|
||||||
|
autoFocus
|
||||||
|
>
|
||||||
|
بستن
|
||||||
|
</Button>
|
||||||
|
</DialogActions>
|
||||||
|
</Dialog>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
export default DescriptionDialog;
|
||||||
@@ -6,10 +6,15 @@ import ShowBound from "../showBound";
|
|||||||
import L from "leaflet";
|
import L from "leaflet";
|
||||||
|
|
||||||
const ShowArea = ({ area }) => {
|
const ShowArea = ({ area }) => {
|
||||||
|
const latLngs = useMemo(() => {
|
||||||
|
return area.coordinates.map(([lng, lat]) => [lat, lng]);
|
||||||
|
}, [area.coordinates]);
|
||||||
|
|
||||||
const bound = useMemo(
|
const bound = useMemo(
|
||||||
() => (area.type == "polygon" ? L.polygon([...area.coordinates]) : L.polyline([...area.coordinates])),
|
() => (area.type === "polygon" ? L.polygon(latLngs) : L.polyline(latLngs)),
|
||||||
[area]
|
[area.type, latLngs]
|
||||||
);
|
);
|
||||||
|
|
||||||
const [openAreaDialog, setOpenAreaDialog] = useState(false);
|
const [openAreaDialog, setOpenAreaDialog] = useState(false);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -54,5 +59,5 @@ const ShowArea = ({ area }) => {
|
|||||||
</Dialog>
|
</Dialog>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};;
|
||||||
export default ShowArea;
|
export default ShowArea;
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ const AllocationForm = ({ row, mutate, setOpenAllocationDialog }) => {
|
|||||||
setIsSubmitting(true);
|
setIsSubmitting(true);
|
||||||
await requestServer(`${ALLOCATE_REQUEST_MISSION}/${row.id}`, "post", {
|
await requestServer(`${ALLOCATE_REQUEST_MISSION}/${row.id}`, "post", {
|
||||||
data: {
|
data: {
|
||||||
machines: _machine.id,
|
machine_id: _machine.id,
|
||||||
driver: _driver.id,
|
driver: _driver.id,
|
||||||
},
|
},
|
||||||
hasSidebarUpdate: true,
|
hasSidebarUpdate: true,
|
||||||
|
|||||||
@@ -53,10 +53,12 @@ const CreateTollHouse = ({ mutate }) => {
|
|||||||
formData.append("lng", result.start_point.lng);
|
formData.append("lng", result.start_point.lng);
|
||||||
formData.append("area[type]", "polygon");
|
formData.append("area[type]", "polygon");
|
||||||
result.area.map((point, pointIndex) => {
|
result.area.map((point, pointIndex) => {
|
||||||
formData.append(`area[coordinates][${pointIndex}][0]`, point.lat);
|
formData.append(`area[coordinates][${pointIndex}][0]`, point.lon);
|
||||||
formData.append(`area[coordinates][${pointIndex}][1]`, point.lon);
|
formData.append(`area[coordinates][${pointIndex}][1]`, point.lat);
|
||||||
});
|
});
|
||||||
|
const repeat_first = result.area.length;
|
||||||
|
formData.append(`area[coordinates][${repeat_first}][0]`, result.area[0].lon);
|
||||||
|
formData.append(`area[coordinates][${repeat_first}][1]`, result.area[0].lat);
|
||||||
await requestServer(`${CREATE_TOLL_HOUSE}`, "post", {
|
await requestServer(`${CREATE_TOLL_HOUSE}`, "post", {
|
||||||
data: formData,
|
data: formData,
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user