debug road mission cartable area view
This commit is contained in:
@@ -6,10 +6,15 @@ import ShowBound from "../showBound";
|
||||
import L from "leaflet";
|
||||
|
||||
const ShowArea = ({ area }) => {
|
||||
const latLngs = useMemo(() => {
|
||||
return area.coordinates.map(([lng, lat]) => [lat, lng]);
|
||||
}, [area.coordinates]);
|
||||
|
||||
const bound = useMemo(
|
||||
() => (area.type == "polygon" ? L.polygon([...area.coordinates]) : L.polyline([...area.coordinates])),
|
||||
[area]
|
||||
() => (area.type === "polygon" ? L.polygon(latLngs) : L.polyline(latLngs)),
|
||||
[area.type, latLngs]
|
||||
);
|
||||
|
||||
const [openAreaDialog, setOpenAreaDialog] = useState(false);
|
||||
|
||||
return (
|
||||
|
||||
@@ -21,10 +21,24 @@ const Create = ({ mutate }) => {
|
||||
setSubmitting(true);
|
||||
const bound = result.bound.getLatLngs();
|
||||
let area =
|
||||
result.bound_type == "polygon"
|
||||
? bound.map((ring) => ring.map((latlng) => [latlng.lat, latlng.lng]))[0]
|
||||
: bound.map((latlng) => [latlng.lat, latlng.lng]);
|
||||
result.bound_type === "polygon"
|
||||
? bound.map((ring) =>
|
||||
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", {
|
||||
data: {
|
||||
explanation: result.explanation,
|
||||
|
||||
@@ -1,121 +1,127 @@
|
||||
import { REQUEST_MISSION_WITHOUT_PROCESS } from "@/core/utils/routes";
|
||||
import useRequest from "@/lib/hooks/useRequest";
|
||||
import { AddCircle, AddCircleOutline, Close } from "@mui/icons-material";
|
||||
import { Button, Dialog, IconButton, useMediaQuery, useTheme } from "@mui/material";
|
||||
import moment from "jalali-moment";
|
||||
import { useState } from "react";
|
||||
import CreateForm from "./Form";
|
||||
|
||||
const CreateWithoutProcess = ({ mutate }) => {
|
||||
const [submitting, setSubmitting] = useState(false);
|
||||
const requestServer = useRequest({ notificationSuccess: true });
|
||||
const theme = useTheme();
|
||||
const isMobile = useMediaQuery(theme.breakpoints.down("sm"));
|
||||
const [open, setOpen] = useState(false);
|
||||
|
||||
const handleOpen = () => {
|
||||
setOpen(true);
|
||||
};
|
||||
|
||||
const submitForm = async (result) => {
|
||||
setSubmitting(true);
|
||||
const bound = result.bound.getLatLngs();
|
||||
let area =
|
||||
result.bound_type == "polygon"
|
||||
? bound.map((ring) => ring.map((latlng) => [latlng.lat, latlng.lng]))[0]
|
||||
: bound.map((latlng) => [latlng.lat, latlng.lng]);
|
||||
|
||||
await requestServer(REQUEST_MISSION_WITHOUT_PROCESS, "post", {
|
||||
data: {
|
||||
explanation: result.explanation,
|
||||
category_id: result.category_id,
|
||||
...(result.category_id == 3
|
||||
? {
|
||||
road_observed_id: result.road_observed_id,
|
||||
}
|
||||
: {}),
|
||||
area: {
|
||||
type: result.bound_type,
|
||||
coordinates: area,
|
||||
},
|
||||
...(result.rahdaran.length != 0 ? { rahdaran: result.rahdaran.map((r) => r.id) } : {}),
|
||||
zone: result.region,
|
||||
end_point: result.end_point,
|
||||
start_date: `${result.start_date} ${moment(result.start_time).format("HH:mm")}`,
|
||||
end_date: `${result.end_date} ${moment(result.end_time).format("HH:mm")}`,
|
||||
machines: [result.machine.id],
|
||||
driver: result.driver.id,
|
||||
},
|
||||
hasSidebarUpdate: true,
|
||||
})
|
||||
.then((response) => {
|
||||
mutate();
|
||||
setOpen(false);
|
||||
})
|
||||
.catch((error) => {})
|
||||
.finally(() => {
|
||||
setSubmitting(false);
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
{isMobile ? (
|
||||
<IconButton aria-label="ثبت ماموریت بدون فرایند" color="primary" onClick={handleOpen}>
|
||||
<AddCircleOutline sx={{ fontSize: "25px" }} />
|
||||
</IconButton>
|
||||
) : (
|
||||
<Button
|
||||
size={"small"}
|
||||
variant="contained"
|
||||
color="primary"
|
||||
startIcon={<AddCircle />}
|
||||
onClick={handleOpen}
|
||||
>
|
||||
ثبت ماموریت بدون فرایند
|
||||
</Button>
|
||||
)}
|
||||
<Dialog open={open} fullWidth maxWidth="sm">
|
||||
<IconButton
|
||||
aria-label="close"
|
||||
onClick={() => setOpen(false)}
|
||||
sx={(theme) => ({
|
||||
position: "absolute",
|
||||
right: 8,
|
||||
top: 8,
|
||||
zIndex: 50,
|
||||
color: theme.palette.grey[500],
|
||||
})}
|
||||
>
|
||||
<Close />
|
||||
</IconButton>
|
||||
{open && (
|
||||
<CreateForm
|
||||
defaultValues={{
|
||||
explanation: "",
|
||||
category_id: "",
|
||||
road_observed_id: "",
|
||||
rahdaran: [],
|
||||
bound: null,
|
||||
bound_type: "polygon",
|
||||
start_date: "",
|
||||
start_time: null,
|
||||
end_date: "",
|
||||
end_time: null,
|
||||
end_point: "",
|
||||
region: "",
|
||||
machine: null,
|
||||
driver: null,
|
||||
}}
|
||||
submitForm={submitForm}
|
||||
submitting={submitting}
|
||||
open={open}
|
||||
setOpen={setOpen}
|
||||
mutate={mutate}
|
||||
/>
|
||||
)}
|
||||
</Dialog>
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default CreateWithoutProcess;
|
||||
import { REQUEST_MISSION_WITHOUT_PROCESS } from "@/core/utils/routes";
|
||||
import useRequest from "@/lib/hooks/useRequest";
|
||||
import { AddCircle, AddCircleOutline, Close } from "@mui/icons-material";
|
||||
import { Button, Dialog, IconButton, useMediaQuery, useTheme } from "@mui/material";
|
||||
import moment from "jalali-moment";
|
||||
import { useState } from "react";
|
||||
import CreateForm from "./Form";
|
||||
|
||||
const CreateWithoutProcess = ({ mutate }) => {
|
||||
const [submitting, setSubmitting] = useState(false);
|
||||
const requestServer = useRequest({ notificationSuccess: true });
|
||||
const theme = useTheme();
|
||||
const isMobile = useMediaQuery(theme.breakpoints.down("sm"));
|
||||
const [open, setOpen] = useState(false);
|
||||
|
||||
const handleOpen = () => {
|
||||
setOpen(true);
|
||||
};
|
||||
|
||||
const submitForm = async (result) => {
|
||||
setSubmitting(true);
|
||||
const bound = result.bound.getLatLngs();
|
||||
let area =
|
||||
result.bound_type === "polygon"
|
||||
? bound.map((ring) => 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_WITHOUT_PROCESS, "post", {
|
||||
data: {
|
||||
explanation: result.explanation,
|
||||
category_id: result.category_id,
|
||||
...(result.category_id == 3
|
||||
? {
|
||||
road_observed_id: result.road_observed_id,
|
||||
}
|
||||
: {}),
|
||||
area: {
|
||||
type: result.bound_type,
|
||||
coordinates: area,
|
||||
},
|
||||
...(result.rahdaran.length != 0 ? { rahdaran: result.rahdaran.map((r) => r.id) } : {}),
|
||||
zone: result.region,
|
||||
end_point: result.end_point,
|
||||
start_date: `${result.start_date} ${moment(result.start_time).format("HH:mm")}`,
|
||||
end_date: `${result.end_date} ${moment(result.end_time).format("HH:mm")}`,
|
||||
machines: [result.machine.id],
|
||||
driver: result.driver.id,
|
||||
},
|
||||
hasSidebarUpdate: true,
|
||||
})
|
||||
.then((response) => {
|
||||
mutate();
|
||||
setOpen(false);
|
||||
})
|
||||
.catch((error) => {})
|
||||
.finally(() => {
|
||||
setSubmitting(false);
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
{isMobile ? (
|
||||
<IconButton aria-label="ثبت ماموریت بدون فرایند" color="primary" onClick={handleOpen}>
|
||||
<AddCircleOutline sx={{ fontSize: "25px" }} />
|
||||
</IconButton>
|
||||
) : (
|
||||
<Button
|
||||
size={"small"}
|
||||
variant="contained"
|
||||
color="primary"
|
||||
startIcon={<AddCircle />}
|
||||
onClick={handleOpen}
|
||||
>
|
||||
ثبت ماموریت بدون فرایند
|
||||
</Button>
|
||||
)}
|
||||
<Dialog open={open} fullWidth maxWidth="sm">
|
||||
<IconButton
|
||||
aria-label="close"
|
||||
onClick={() => setOpen(false)}
|
||||
sx={(theme) => ({
|
||||
position: "absolute",
|
||||
right: 8,
|
||||
top: 8,
|
||||
zIndex: 50,
|
||||
color: theme.palette.grey[500],
|
||||
})}
|
||||
>
|
||||
<Close />
|
||||
</IconButton>
|
||||
{open && (
|
||||
<CreateForm
|
||||
defaultValues={{
|
||||
explanation: "",
|
||||
category_id: "",
|
||||
road_observed_id: "",
|
||||
rahdaran: [],
|
||||
bound: null,
|
||||
bound_type: "polygon",
|
||||
start_date: "",
|
||||
start_time: null,
|
||||
end_date: "",
|
||||
end_time: null,
|
||||
end_point: "",
|
||||
region: "",
|
||||
machine: null,
|
||||
driver: null,
|
||||
}}
|
||||
submitForm={submitForm}
|
||||
submitting={submitting}
|
||||
open={open}
|
||||
setOpen={setOpen}
|
||||
mutate={mutate}
|
||||
/>
|
||||
)}
|
||||
</Dialog>
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default CreateWithoutProcess;
|
||||
|
||||
@@ -6,10 +6,15 @@ import ShowBound from "../showBound";
|
||||
import L from "leaflet";
|
||||
|
||||
const ShowArea = ({ area }) => {
|
||||
const latLngs = useMemo(() => {
|
||||
return area.coordinates.map(([lng, lat]) => [lat, lng]);
|
||||
}, [area.coordinates]);
|
||||
|
||||
const bound = useMemo(
|
||||
() => (area.type == "polygon" ? L.polygon([...area.coordinates]) : L.polyline([...area.coordinates])),
|
||||
[area]
|
||||
() => (area.type === "polygon" ? L.polygon(latLngs) : L.polyline(latLngs)),
|
||||
[area.type, latLngs]
|
||||
);
|
||||
|
||||
const [openAreaDialog, setOpenAreaDialog] = useState(false);
|
||||
|
||||
return (
|
||||
@@ -54,5 +59,5 @@ const ShowArea = ({ area }) => {
|
||||
</Dialog>
|
||||
</>
|
||||
);
|
||||
};
|
||||
};;
|
||||
export default ShowArea;
|
||||
|
||||
@@ -12,6 +12,7 @@ import RowActions from "./RowActions";
|
||||
import MachinesDialog from "./RowActions/Machines";
|
||||
import Toolbar from "./Toolbar";
|
||||
import RahdaranDialog from "./RowActions/Rahdaran";
|
||||
import DescriptionDialog from "@/components/dashboard/roadMissions/operator/RowActions/DescriptionDialog";
|
||||
|
||||
const OperatorList = () => {
|
||||
const columns = useMemo(
|
||||
@@ -219,7 +220,7 @@ const OperatorList = () => {
|
||||
},
|
||||
},
|
||||
},
|
||||
Cell: ({ renderedCellValue, row }) => {
|
||||
Cell: ({ row }) => {
|
||||
return (
|
||||
<Stack alignItems={"center"} justifyContent={"center"}>
|
||||
<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) =>
|
||||
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);
|
||||
const bound = result.bound.getLatLngs();
|
||||
let area =
|
||||
result.bound_type == "polygon"
|
||||
? bound.map((ring) => ring.map((latlng) => [latlng.lat, latlng.lng]))[0]
|
||||
: bound.map((latlng) => [latlng.lat, latlng.lng]);
|
||||
result.bound_type === "polygon"
|
||||
? bound.map((ring) => 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_CONTINUE_MISSION}/${row.original.id}`, "post", {
|
||||
data: {
|
||||
...(result.rahdaran.length != 0 ? { rahdaran: result.rahdaran.map((r) => r.id) } : {}),
|
||||
machines: [result.machine.id],
|
||||
machine_id: result.machine.id,
|
||||
driver: result.driver.id,
|
||||
zone: result.region,
|
||||
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";
|
||||
|
||||
const ShowArea = ({ area }) => {
|
||||
const latLngs = useMemo(() => {
|
||||
return area.coordinates.map(([lng, lat]) => [lat, lng]);
|
||||
}, [area.coordinates]);
|
||||
|
||||
const bound = useMemo(
|
||||
() => (area.type == "polygon" ? L.polygon([...area.coordinates]) : L.polyline([...area.coordinates])),
|
||||
[area]
|
||||
() => (area.type === "polygon" ? L.polygon(latLngs) : L.polyline(latLngs)),
|
||||
[area.type, latLngs]
|
||||
);
|
||||
|
||||
const [openAreaDialog, setOpenAreaDialog] = useState(false);
|
||||
|
||||
return (
|
||||
@@ -54,5 +59,5 @@ const ShowArea = ({ area }) => {
|
||||
</Dialog>
|
||||
</>
|
||||
);
|
||||
};
|
||||
};;
|
||||
export default ShowArea;
|
||||
|
||||
@@ -28,7 +28,7 @@ const AllocationForm = ({ row, mutate, setOpenAllocationDialog }) => {
|
||||
setIsSubmitting(true);
|
||||
await requestServer(`${ALLOCATE_REQUEST_MISSION}/${row.id}`, "post", {
|
||||
data: {
|
||||
machines: _machine.id,
|
||||
machine_id: _machine.id,
|
||||
driver: _driver.id,
|
||||
},
|
||||
hasSidebarUpdate: true,
|
||||
|
||||
@@ -53,10 +53,12 @@ const CreateTollHouse = ({ mutate }) => {
|
||||
formData.append("lng", result.start_point.lng);
|
||||
formData.append("area[type]", "polygon");
|
||||
result.area.map((point, pointIndex) => {
|
||||
formData.append(`area[coordinates][${pointIndex}][0]`, point.lat);
|
||||
formData.append(`area[coordinates][${pointIndex}][1]`, point.lon);
|
||||
formData.append(`area[coordinates][${pointIndex}][0]`, 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", {
|
||||
data: formData,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user