Merge branch 'feature/road_safety_#86c2a6cz3' into 'develop'
Resolve #86c2a6cz3 "Feature/road safety " See merge request witel-front-end/rms!81
This commit is contained in:
17
src/app/(withAuth)/dashboard/road-safety/report/page.js
Normal file
17
src/app/(withAuth)/dashboard/road-safety/report/page.js
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import ReportPage from "@/components/dashboard/roadSafety/report";
|
||||||
|
import WithPermission from "@/core/middlewares/withPermission";
|
||||||
|
|
||||||
|
const Page = () => {
|
||||||
|
return (
|
||||||
|
<WithPermission
|
||||||
|
permission_name={[
|
||||||
|
"show-safety-and-privacy-operator-cartable",
|
||||||
|
"show-safety-and-privacy-operator-cartable-province",
|
||||||
|
"show-safety-and-privacy-operator-cartable-edarate-shahri",
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<ReportPage />
|
||||||
|
</WithPermission>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
export default Page;
|
||||||
@@ -232,6 +232,7 @@ const ReportLists = ({ data, specialFilter }) => {
|
|||||||
data={data.data}
|
data={data.data}
|
||||||
page_name={"receiptReport"}
|
page_name={"receiptReport"}
|
||||||
table_name={"receiptReportList"}
|
table_name={"receiptReportList"}
|
||||||
|
enablePagination={false}
|
||||||
specialFilter={specialFilter}
|
specialFilter={specialFilter}
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
|
|||||||
@@ -115,8 +115,8 @@ const ComplaintListTable = ({ open, setOpen, mutate }) => {
|
|||||||
props.dependencyFieldValue?.value === ""
|
props.dependencyFieldValue?.value === ""
|
||||||
? "empty"
|
? "empty"
|
||||||
: loadingEdaratList
|
: loadingEdaratList
|
||||||
? "loading"
|
? "loading"
|
||||||
: props.filterParameters.value
|
: props.filterParameters.value
|
||||||
}
|
}
|
||||||
columnSelectOption={getColumnSelectOptions}
|
columnSelectOption={getColumnSelectOptions}
|
||||||
/>
|
/>
|
||||||
@@ -237,7 +237,10 @@ const ComplaintListTable = ({ open, setOpen, mutate }) => {
|
|||||||
size: 100,
|
size: 100,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
accessorFn: (row) => moment(row.StartTime_DateTime, "M/D/YYYY h:mm:ss A").locale("fa").format("HH:mm | yyyy/MM/DD"),
|
accessorFn: (row) =>
|
||||||
|
moment(row.StartTime_DateTime, "M/D/YYYY h:mm:ss A")
|
||||||
|
.locale("fa")
|
||||||
|
.format("HH:mm | yyyy/MM/DD"),
|
||||||
header: "تاریخ ثبت",
|
header: "تاریخ ثبت",
|
||||||
id: "StartTime_DateTime",
|
id: "StartTime_DateTime",
|
||||||
enableColumnFilter: false,
|
enableColumnFilter: false,
|
||||||
@@ -246,8 +249,8 @@ const ComplaintListTable = ({ open, setOpen, mutate }) => {
|
|||||||
grow: false,
|
grow: false,
|
||||||
size: 100,
|
size: 100,
|
||||||
},
|
},
|
||||||
]
|
],
|
||||||
}
|
},
|
||||||
];
|
];
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
|||||||
@@ -6,12 +6,10 @@ import { usePermissions } from "@/lib/hooks/usePermissions";
|
|||||||
|
|
||||||
const RowActions = ({ row, mutate }) => {
|
const RowActions = ({ row, mutate }) => {
|
||||||
const { data: userPermissions } = usePermissions();
|
const { data: userPermissions } = usePermissions();
|
||||||
const hasActionPermission = userPermissions.includes("show-fast-react-edarate-shahri")
|
const hasActionPermission = userPermissions.includes("show-fast-react-edarate-shahri");
|
||||||
return (
|
return (
|
||||||
<Box sx={{ display: "flex", gap: 1 }}>
|
<Box sx={{ display: "flex", gap: 1 }}>
|
||||||
{hasActionPermission && (
|
{hasActionPermission && <RegisterAction mutate={mutate} rowId={row.getValue("road_observeds__id")} />}
|
||||||
<RegisterAction mutate={mutate} rowId={row.getValue("road_observeds__id")} />
|
|
||||||
)}
|
|
||||||
<Refer rowId={row.getValue("road_observeds__id")} mutate={mutate} />
|
<Refer rowId={row.getValue("road_observeds__id")} mutate={mutate} />
|
||||||
<ReferList rowId={row.getValue("road_observeds__id")} />
|
<ReferList rowId={row.getValue("road_observeds__id")} />
|
||||||
</Box>
|
</Box>
|
||||||
|
|||||||
@@ -181,7 +181,10 @@ const OperatorList = () => {
|
|||||||
size: 100,
|
size: 100,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
accessorFn: (row) => moment(row.StartTime_DateTime, "M/D/YYYY h:mm:ss A").locale("fa").format("HH:mm | yyyy/MM/DD"),
|
accessorFn: (row) =>
|
||||||
|
moment(row.StartTime_DateTime, "M/D/YYYY h:mm:ss A")
|
||||||
|
.locale("fa")
|
||||||
|
.format("HH:mm | yyyy/MM/DD"),
|
||||||
header: "تاریخ ثبت",
|
header: "تاریخ ثبت",
|
||||||
id: "StartTime_DateTime",
|
id: "StartTime_DateTime",
|
||||||
enableColumnFilter: false,
|
enableColumnFilter: false,
|
||||||
@@ -190,7 +193,7 @@ const OperatorList = () => {
|
|||||||
grow: false,
|
grow: false,
|
||||||
size: 100,
|
size: 100,
|
||||||
},
|
},
|
||||||
]
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
accessorFn: (row) => {
|
accessorFn: (row) => {
|
||||||
|
|||||||
@@ -18,7 +18,9 @@ const RowActions = ({ row, mutate }) => {
|
|||||||
{hasSupervisePermission && row.original?.status === 0 && (
|
{hasSupervisePermission && row.original?.status === 0 && (
|
||||||
<RejectForm rowId={row.getValue("road_observeds__id")} mutate={mutate} />
|
<RejectForm rowId={row.getValue("road_observeds__id")} mutate={mutate} />
|
||||||
)}
|
)}
|
||||||
{hasRestorePermission && row.original?.status !== 0 && <RestoreForm rowId={row.getValue("road_observeds__id")} mutate={mutate} />}
|
{hasRestorePermission && row.original?.status !== 0 && (
|
||||||
|
<RestoreForm rowId={row.getValue("road_observeds__id")} mutate={mutate} />
|
||||||
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -125,8 +125,8 @@ const SupervisorList = () => {
|
|||||||
props.dependencyFieldValue?.value === ""
|
props.dependencyFieldValue?.value === ""
|
||||||
? "empty"
|
? "empty"
|
||||||
: loadingEdaratList
|
: loadingEdaratList
|
||||||
? "loading"
|
? "loading"
|
||||||
: props.filterParameters.value
|
: props.filterParameters.value
|
||||||
}
|
}
|
||||||
columnSelectOption={getColumnSelectOptions}
|
columnSelectOption={getColumnSelectOptions}
|
||||||
/>
|
/>
|
||||||
@@ -282,7 +282,10 @@ const SupervisorList = () => {
|
|||||||
size: 100,
|
size: 100,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
accessorFn: (row) => moment(row.StartTime_DateTime, "M/D/YYYY h:mm:ss A").locale("fa").format("HH:mm | yyyy/MM/DD"),
|
accessorFn: (row) =>
|
||||||
|
moment(row.StartTime_DateTime, "M/D/YYYY h:mm:ss A")
|
||||||
|
.locale("fa")
|
||||||
|
.format("HH:mm | yyyy/MM/DD"),
|
||||||
header: "تاریخ ثبت",
|
header: "تاریخ ثبت",
|
||||||
id: "StartTime_DateTime",
|
id: "StartTime_DateTime",
|
||||||
enableColumnFilter: false,
|
enableColumnFilter: false,
|
||||||
@@ -291,7 +294,7 @@ const SupervisorList = () => {
|
|||||||
grow: false,
|
grow: false,
|
||||||
size: 100,
|
size: 100,
|
||||||
},
|
},
|
||||||
]
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
accessorFn: (row) => {
|
accessorFn: (row) => {
|
||||||
|
|||||||
@@ -7,10 +7,9 @@ import { GET_ROAD_PATROL_OPERATOR_LIST } from "@/core/utils/routes";
|
|||||||
import moment from "jalali-moment";
|
import moment from "jalali-moment";
|
||||||
import RowActions from "./RowActions";
|
import RowActions from "./RowActions";
|
||||||
import ReportForm from "./RowActions/ReportForm";
|
import ReportForm from "./RowActions/ReportForm";
|
||||||
import RahdaranDialog from "./RowActions/RahdaranForm"
|
import RahdaranDialog from "./RowActions/RahdaranForm";
|
||||||
import MachinePerformanceForm from "./RowActions/MachinePerformanceForm";
|
import MachinePerformanceForm from "./RowActions/MachinePerformanceForm";
|
||||||
|
|
||||||
|
|
||||||
const OperatorList = () => {
|
const OperatorList = () => {
|
||||||
const columns = useMemo(
|
const columns = useMemo(
|
||||||
() => [
|
() => [
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ const MachinePerformanceFetch = ({ row }) => {
|
|||||||
const fetchData = async () => {
|
const fetchData = async () => {
|
||||||
try {
|
try {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
const response = await request(`${GET_CMMS_MACHINE_ROAD_PATROL}/${row.getValue('id')}`);
|
const response = await request(`${GET_CMMS_MACHINE_ROAD_PATROL}/${row.getValue("id")}`);
|
||||||
setData(response.data.data);
|
setData(response.data.data);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
} finally {
|
} finally {
|
||||||
@@ -31,19 +31,20 @@ const MachinePerformanceFetch = ({ row }) => {
|
|||||||
{loading ? (
|
{loading ? (
|
||||||
<DialogLoading />
|
<DialogLoading />
|
||||||
) : data && row.original?.stop_points?.length > 0 ? (
|
) : data && row.original?.stop_points?.length > 0 ? (
|
||||||
<MachinePerformanceContent machinesLists={{
|
<MachinePerformanceContent
|
||||||
stopPoints: row.original?.stop_points,
|
machinesLists={{
|
||||||
fuelConsumption: row.original?.fuel_consumption,
|
stopPoints: row.original?.stop_points,
|
||||||
mileage: row.original?.distance,
|
fuelConsumption: row.original?.fuel_consumption,
|
||||||
accOnDuration: row.original?.vehicle_runtime,
|
mileage: row.original?.distance,
|
||||||
cmms_machine_code: data[0]
|
accOnDuration: row.original?.vehicle_runtime,
|
||||||
|
cmms_machine_code: data[0],
|
||||||
}} />
|
}}
|
||||||
|
/>
|
||||||
) : (
|
) : (
|
||||||
<Typography textAlign={"center"}>عملکرد خودرویی در سامانه یافت نشد</Typography>
|
<Typography textAlign={"center"}>عملکرد خودرویی در سامانه یافت نشد</Typography>
|
||||||
)}
|
)}
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
</>
|
</>
|
||||||
)
|
);
|
||||||
}
|
};
|
||||||
export default MachinePerformanceFetch
|
export default MachinePerformanceFetch;
|
||||||
|
|||||||
@@ -25,9 +25,7 @@ const MachinePerformanceForm = ({ row }) => {
|
|||||||
maxWidth={"md"}
|
maxWidth={"md"}
|
||||||
>
|
>
|
||||||
<DialogTitle sx={{ fontSize: "large" }}>عملکرد خودرو</DialogTitle>
|
<DialogTitle sx={{ fontSize: "large" }}>عملکرد خودرو</DialogTitle>
|
||||||
{openMachinesCodeDialog && (
|
{openMachinesCodeDialog && <MachinePerformanceFetch row={row} />}
|
||||||
<MachinePerformanceFetch row={row} />
|
|
||||||
)}
|
|
||||||
<DialogActions>
|
<DialogActions>
|
||||||
<Button
|
<Button
|
||||||
onClick={() => setOpenMachinesCodeDialog(false)}
|
onClick={() => setOpenMachinesCodeDialog(false)}
|
||||||
|
|||||||
@@ -200,6 +200,7 @@ const ReportLists = ({ data, specialFilter }) => {
|
|||||||
data={data.data}
|
data={data.data}
|
||||||
page_name={"roadPatrolReport"}
|
page_name={"roadPatrolReport"}
|
||||||
table_name={"roadPatrolReportList"}
|
table_name={"roadPatrolReportList"}
|
||||||
|
enablePagination={false}
|
||||||
specialFilter={specialFilter}
|
specialFilter={specialFilter}
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ const MachinePerformanceFetch = ({ row }) => {
|
|||||||
const fetchData = async () => {
|
const fetchData = async () => {
|
||||||
try {
|
try {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
const response = await request(`${GET_CMMS_MACHINE_ROAD_PATROL}/${row.getValue('id')}`);
|
const response = await request(`${GET_CMMS_MACHINE_ROAD_PATROL}/${row.getValue("id")}`);
|
||||||
setData(response.data.data);
|
setData(response.data.data);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
} finally {
|
} finally {
|
||||||
@@ -31,19 +31,20 @@ const MachinePerformanceFetch = ({ row }) => {
|
|||||||
{loading ? (
|
{loading ? (
|
||||||
<DialogLoading />
|
<DialogLoading />
|
||||||
) : data && row.original?.stop_points?.length > 0 ? (
|
) : data && row.original?.stop_points?.length > 0 ? (
|
||||||
<MachinePerformanceContent machinesLists={{
|
<MachinePerformanceContent
|
||||||
stopPoints: row.original?.stop_points,
|
machinesLists={{
|
||||||
fuelConsumption: row.original?.fuel_consumption,
|
stopPoints: row.original?.stop_points,
|
||||||
mileage: row.original?.distance,
|
fuelConsumption: row.original?.fuel_consumption,
|
||||||
accOnDuration: row.original?.vehicle_runtime,
|
mileage: row.original?.distance,
|
||||||
cmms_machine_code: data[0]
|
accOnDuration: row.original?.vehicle_runtime,
|
||||||
|
cmms_machine_code: data[0],
|
||||||
}} />
|
}}
|
||||||
|
/>
|
||||||
) : (
|
) : (
|
||||||
<Typography textAlign={"center"}>عملکرد خودرویی در سامانه یافت نشد</Typography>
|
<Typography textAlign={"center"}>عملکرد خودرویی در سامانه یافت نشد</Typography>
|
||||||
)}
|
)}
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
</>
|
</>
|
||||||
)
|
);
|
||||||
}
|
};
|
||||||
export default MachinePerformanceFetch
|
export default MachinePerformanceFetch;
|
||||||
|
|||||||
@@ -25,9 +25,7 @@ const MachinePerformanceForm = ({ row }) => {
|
|||||||
maxWidth={"md"}
|
maxWidth={"md"}
|
||||||
>
|
>
|
||||||
<DialogTitle sx={{ fontSize: "large" }}>عملکرد خودرو</DialogTitle>
|
<DialogTitle sx={{ fontSize: "large" }}>عملکرد خودرو</DialogTitle>
|
||||||
{openMachinesCodeDialog && (
|
{openMachinesCodeDialog && <MachinePerformanceFetch row={row} />}
|
||||||
<MachinePerformanceFetch row={row} />
|
|
||||||
)}
|
|
||||||
<DialogActions>
|
<DialogActions>
|
||||||
<Button
|
<Button
|
||||||
onClick={() => setOpenMachinesCodeDialog(false)}
|
onClick={() => setOpenMachinesCodeDialog(false)}
|
||||||
|
|||||||
@@ -119,8 +119,8 @@ const SupervisorList = () => {
|
|||||||
props.dependencyFieldValue?.value === ""
|
props.dependencyFieldValue?.value === ""
|
||||||
? "empty"
|
? "empty"
|
||||||
: loadingEdaratList
|
: loadingEdaratList
|
||||||
? "loading"
|
? "loading"
|
||||||
: props.filterParameters.value
|
: props.filterParameters.value
|
||||||
}
|
}
|
||||||
columnSelectOption={getColumnSelectOptions}
|
columnSelectOption={getColumnSelectOptions}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -0,0 +1,72 @@
|
|||||||
|
"use client";
|
||||||
|
import { Button, CircularProgress, IconButton, useMediaQuery } from "@mui/material";
|
||||||
|
import { useMemo, useState } from "react";
|
||||||
|
import moment from "jalali-moment";
|
||||||
|
import FileSaver from "file-saver";
|
||||||
|
import DescriptionIcon from "@mui/icons-material/Description";
|
||||||
|
import useRequest from "@/lib/hooks/useRequest";
|
||||||
|
import { useTheme } from "@emotion/react";
|
||||||
|
import { EXPORT_COUNTRY_ROAD_PATROL_REPORTS, EXPORT_PROVINCE_ROAD_PATROL_REPORTS } from "@/core/utils/routes";
|
||||||
|
|
||||||
|
const PrintExcel = ({ table, filterData }) => {
|
||||||
|
const theme = useTheme();
|
||||||
|
const isMobile = useMediaQuery(theme.breakpoints.down("sm"));
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
|
const requestServer = useRequest({ notificationSuccess: true });
|
||||||
|
const activeFilters = Object.entries(filterData).reduce((acc, [key, filter]) => {
|
||||||
|
if (filter.value) {
|
||||||
|
acc.push({ id: filter.id, value: filter.value });
|
||||||
|
}
|
||||||
|
return acc;
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const filterParams = useMemo(() => {
|
||||||
|
const params = new URLSearchParams();
|
||||||
|
activeFilters.length > 0 &&
|
||||||
|
activeFilters.map((filter, index) => {
|
||||||
|
params.set(`${filter.id}`, filter.value);
|
||||||
|
});
|
||||||
|
return params;
|
||||||
|
}, [activeFilters]);
|
||||||
|
|
||||||
|
const clickHandler = () => {
|
||||||
|
setLoading(true);
|
||||||
|
const CountryOrProvince = activeFilters.find((item) => item.id === "province_id");
|
||||||
|
const requestUrl =
|
||||||
|
CountryOrProvince.value === "-1" ? EXPORT_COUNTRY_ROAD_PATROL_REPORTS : EXPORT_PROVINCE_ROAD_PATROL_REPORTS;
|
||||||
|
requestServer(`${requestUrl}?${filterParams}`, "get", {
|
||||||
|
requestOptions: { responseType: "blob" },
|
||||||
|
})
|
||||||
|
.then((response) => {
|
||||||
|
const filename = `خروجی کارتابل گزارشات گشت راهداری تاریخ_${moment().format("jYYYY_jMM_jDD")}.xlsx`;
|
||||||
|
FileSaver.saveAs(response.data, filename);
|
||||||
|
})
|
||||||
|
.catch(() => {})
|
||||||
|
.finally(() => {
|
||||||
|
setLoading(false);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{isMobile ? (
|
||||||
|
<IconButton aria-label="خروجی اکسل" color="primary" onClick={clickHandler}>
|
||||||
|
<DescriptionIcon sx={{ fontSize: "25px" }} />
|
||||||
|
</IconButton>
|
||||||
|
) : (
|
||||||
|
<Button
|
||||||
|
color="primary"
|
||||||
|
variant="contained"
|
||||||
|
size="small"
|
||||||
|
disabled={loading}
|
||||||
|
sx={{ textTransform: "unset", alignSelf: "center" }}
|
||||||
|
startIcon={loading ? <CircularProgress size={18} color="inherit" /> : <DescriptionIcon />}
|
||||||
|
onClick={clickHandler}
|
||||||
|
>
|
||||||
|
خروجی اکسل
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
export default PrintExcel;
|
||||||
302
src/components/dashboard/roadSafety/report/ReportLists.jsx
Normal file
302
src/components/dashboard/roadSafety/report/ReportLists.jsx
Normal file
@@ -0,0 +1,302 @@
|
|||||||
|
"use client";
|
||||||
|
import DataTableWithAuth from "@/core/components/DataTableWithAuth";
|
||||||
|
import { Box } from "@mui/material";
|
||||||
|
import { useMemo } from "react";
|
||||||
|
import Toolbar from "./Toolbar";
|
||||||
|
|
||||||
|
const ReportLists = ({ data, specialFilter }) => {
|
||||||
|
const columns = useMemo(() => {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
accessorKey: "edare_name",
|
||||||
|
header: "اداره کل",
|
||||||
|
id: "edare_name",
|
||||||
|
enableColumnFilter: false,
|
||||||
|
enableSorting: false,
|
||||||
|
datatype: "text",
|
||||||
|
grow: false,
|
||||||
|
size: 50,
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
accessorKey: "sum",
|
||||||
|
header: "تعداد کل",
|
||||||
|
id: "sum",
|
||||||
|
enableColumnFilter: false,
|
||||||
|
enableSorting: false,
|
||||||
|
datatype: "text",
|
||||||
|
grow: false,
|
||||||
|
size: 50,
|
||||||
|
muiTableBodyCellProps: {
|
||||||
|
sx: {
|
||||||
|
textAlign: "center",
|
||||||
|
borderLeft: "1px solid #e1e1e1",
|
||||||
|
py: 0,
|
||||||
|
"&:first-of-type": {
|
||||||
|
borderLeft: "unset",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Cell: ({ renderedCellValue }) => {
|
||||||
|
return (renderedCellValue / 1).toLocaleString();
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
header: "ساخت و ساز غیر مجاز",
|
||||||
|
enableColumnFilter: false,
|
||||||
|
enableSorting: false,
|
||||||
|
datatype: "text",
|
||||||
|
id: "id_89",
|
||||||
|
grow: false,
|
||||||
|
size: 50,
|
||||||
|
columns: [
|
||||||
|
{
|
||||||
|
accessorFn: (row) => (row["89"] ? row["89"]["1"] : 0),
|
||||||
|
header: "گام اول (شناسایی)",
|
||||||
|
id: "id_89.1",
|
||||||
|
enableColumnFilter: false,
|
||||||
|
enableSorting: false,
|
||||||
|
datatype: "text",
|
||||||
|
grow: false,
|
||||||
|
size: 50,
|
||||||
|
muiTableBodyCellProps: {
|
||||||
|
sx: {
|
||||||
|
textAlign: "center",
|
||||||
|
borderLeft: "1px solid #e1e1e1",
|
||||||
|
py: 0,
|
||||||
|
"&:first-of-type": {
|
||||||
|
borderLeft: "unset",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Cell: ({ renderedCellValue }) => {
|
||||||
|
return (renderedCellValue / 1).toLocaleString();
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
accessorFn: (row) => (row["89"] ? row["89"]["2"] : 0),
|
||||||
|
header: "گام دوم (مستندات قضایی)",
|
||||||
|
id: "id_89.2",
|
||||||
|
enableColumnFilter: false,
|
||||||
|
enableSorting: false,
|
||||||
|
datatype: "text",
|
||||||
|
grow: false,
|
||||||
|
size: 50,
|
||||||
|
muiTableBodyCellProps: {
|
||||||
|
sx: {
|
||||||
|
textAlign: "center",
|
||||||
|
borderLeft: "1px solid #e1e1e1",
|
||||||
|
py: 0,
|
||||||
|
"&:first-of-type": {
|
||||||
|
borderLeft: "unset",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Cell: ({ renderedCellValue }) => {
|
||||||
|
return (renderedCellValue / 1).toLocaleString();
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
accessorFn: (row) => (row["89"] ? row["89"]["3"] : 0),
|
||||||
|
header: "گام سوم (برخورد)",
|
||||||
|
id: "id_89.3",
|
||||||
|
enableColumnFilter: false,
|
||||||
|
enableSorting: false,
|
||||||
|
datatype: "text",
|
||||||
|
grow: false,
|
||||||
|
size: 50,
|
||||||
|
muiTableBodyCellProps: {
|
||||||
|
sx: {
|
||||||
|
textAlign: "center",
|
||||||
|
borderLeft: "1px solid #e1e1e1",
|
||||||
|
py: 0,
|
||||||
|
"&:first-of-type": {
|
||||||
|
borderLeft: "unset",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Cell: ({ renderedCellValue }) => {
|
||||||
|
return (renderedCellValue / 1).toLocaleString();
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
header: "راه دسترسی غیر مجاز",
|
||||||
|
enableColumnFilter: false,
|
||||||
|
enableSorting: false,
|
||||||
|
datatype: "text",
|
||||||
|
id: "id_90",
|
||||||
|
grow: false,
|
||||||
|
size: 50,
|
||||||
|
columns: [
|
||||||
|
{
|
||||||
|
accessorFn: (row) => (row["90"] ? row["90"]["1"] : 0),
|
||||||
|
header: "گام اول (شناسایی)",
|
||||||
|
id: "id_90.1",
|
||||||
|
enableColumnFilter: false,
|
||||||
|
enableSorting: false,
|
||||||
|
datatype: "text",
|
||||||
|
grow: false,
|
||||||
|
size: 50,
|
||||||
|
muiTableBodyCellProps: {
|
||||||
|
sx: {
|
||||||
|
textAlign: "center",
|
||||||
|
borderLeft: "1px solid #e1e1e1",
|
||||||
|
py: 0,
|
||||||
|
"&:first-of-type": {
|
||||||
|
borderLeft: "unset",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Cell: ({ renderedCellValue }) => {
|
||||||
|
return (renderedCellValue / 1).toLocaleString();
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
accessorFn: (row) => (row["90"] ? row["90"]["2"] : 0),
|
||||||
|
header: "گام دوم (مستندات قضایی)",
|
||||||
|
id: "id_90.2",
|
||||||
|
enableColumnFilter: false,
|
||||||
|
enableSorting: false,
|
||||||
|
datatype: "text",
|
||||||
|
grow: false,
|
||||||
|
size: 50,
|
||||||
|
muiTableBodyCellProps: {
|
||||||
|
sx: {
|
||||||
|
textAlign: "center",
|
||||||
|
borderLeft: "1px solid #e1e1e1",
|
||||||
|
py: 0,
|
||||||
|
"&:first-of-type": {
|
||||||
|
borderLeft: "unset",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Cell: ({ renderedCellValue }) => {
|
||||||
|
return (renderedCellValue / 1).toLocaleString();
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
accessorFn: (row) => (row["90"] ? row["90"]["3"] : 0),
|
||||||
|
header: "گام سوم (برخورد)",
|
||||||
|
id: "id_90.3",
|
||||||
|
enableColumnFilter: false,
|
||||||
|
enableSorting: false,
|
||||||
|
datatype: "text",
|
||||||
|
grow: false,
|
||||||
|
size: 50,
|
||||||
|
muiTableBodyCellProps: {
|
||||||
|
sx: {
|
||||||
|
textAlign: "center",
|
||||||
|
borderLeft: "1px solid #e1e1e1",
|
||||||
|
py: 0,
|
||||||
|
"&:first-of-type": {
|
||||||
|
borderLeft: "unset",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Cell: ({ renderedCellValue }) => {
|
||||||
|
return (renderedCellValue / 1).toLocaleString();
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
header: "عبور تاسیسات زیربنایی غیر مجاز",
|
||||||
|
enableColumnFilter: false,
|
||||||
|
enableSorting: false,
|
||||||
|
datatype: "text",
|
||||||
|
id: "id_91",
|
||||||
|
grow: false,
|
||||||
|
size: 50,
|
||||||
|
columns: [
|
||||||
|
{
|
||||||
|
accessorFn: (row) => (row["91"] ? row["91"]["1"] : 0),
|
||||||
|
header: "گام اول (شناسایی)",
|
||||||
|
id: "id_91.1",
|
||||||
|
enableColumnFilter: false,
|
||||||
|
enableSorting: false,
|
||||||
|
datatype: "text",
|
||||||
|
grow: false,
|
||||||
|
size: 50,
|
||||||
|
muiTableBodyCellProps: {
|
||||||
|
sx: {
|
||||||
|
textAlign: "center",
|
||||||
|
borderLeft: "1px solid #e1e1e1",
|
||||||
|
py: 0,
|
||||||
|
"&:first-of-type": {
|
||||||
|
borderLeft: "unset",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Cell: ({ renderedCellValue }) => {
|
||||||
|
return (renderedCellValue / 1).toLocaleString();
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
accessorFn: (row) => (row["91"] ? row["91"]["2"] : 0),
|
||||||
|
header: "گام دوم (مستندات قضایی)",
|
||||||
|
id: "id_91.2",
|
||||||
|
enableColumnFilter: false,
|
||||||
|
enableSorting: false,
|
||||||
|
datatype: "text",
|
||||||
|
grow: false,
|
||||||
|
size: 50,
|
||||||
|
muiTableBodyCellProps: {
|
||||||
|
sx: {
|
||||||
|
textAlign: "center",
|
||||||
|
borderLeft: "1px solid #e1e1e1",
|
||||||
|
py: 0,
|
||||||
|
"&:first-of-type": {
|
||||||
|
borderLeft: "unset",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Cell: ({ renderedCellValue }) => {
|
||||||
|
return (renderedCellValue / 1).toLocaleString();
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
accessorFn: (row) => (row["91"] ? row["91"]["3"] : 0),
|
||||||
|
header: "گام سوم (برخورد)",
|
||||||
|
id: "id_91.3",
|
||||||
|
enableColumnFilter: false,
|
||||||
|
enableSorting: false,
|
||||||
|
datatype: "text",
|
||||||
|
grow: false,
|
||||||
|
size: 50,
|
||||||
|
muiTableBodyCellProps: {
|
||||||
|
sx: {
|
||||||
|
textAlign: "center",
|
||||||
|
borderLeft: "1px solid #e1e1e1",
|
||||||
|
py: 0,
|
||||||
|
"&:first-of-type": {
|
||||||
|
borderLeft: "unset",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Cell: ({ renderedCellValue }) => {
|
||||||
|
return (renderedCellValue / 1).toLocaleString();
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Box sx={{ p: 1, border: 1, borderColor: "divider", borderRadius: 1 }}>
|
||||||
|
<DataTableWithAuth
|
||||||
|
TableToolbar={Toolbar}
|
||||||
|
columns={columns}
|
||||||
|
data={data.data}
|
||||||
|
page_name={"roadSafetyReport"}
|
||||||
|
table_name={"roadSafetyReportList"}
|
||||||
|
enablePagination={false}
|
||||||
|
specialFilter={specialFilter}
|
||||||
|
/>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ReportLists;
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
import { Controller } from "react-hook-form";
|
||||||
|
import MuiDatePicker from "@/core/components/MuiDatePicker";
|
||||||
|
import React from "react";
|
||||||
|
import moment from "jalali-moment";
|
||||||
|
|
||||||
|
const FromDateController = ({ control }) => {
|
||||||
|
return (
|
||||||
|
<Controller
|
||||||
|
name="from_date"
|
||||||
|
control={control}
|
||||||
|
render={({ field: { onChange, value }, fieldState: { error } }) => (
|
||||||
|
<MuiDatePicker
|
||||||
|
name="from_date"
|
||||||
|
error={!!error}
|
||||||
|
value={value}
|
||||||
|
label={"تاریخ ثبت (از تاریخ)"}
|
||||||
|
placeholder={"از تاریخ"}
|
||||||
|
setFieldValue={(name, newValue) => {
|
||||||
|
const formattedDate = moment(new Date(newValue)).locale("en").format("YYYY-MM-DD");
|
||||||
|
onChange(formattedDate); // Update the field value in react-hook-form
|
||||||
|
}}
|
||||||
|
helperText={error ? error.message : null}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
export default FromDateController;
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
import { Button, Grid, LinearProgress, Typography } from "@mui/material";
|
||||||
|
import SearchIcon from "@mui/icons-material/Search";
|
||||||
|
import React from "react";
|
||||||
|
import FromDateController from "./FromDateController";
|
||||||
|
import ToDateController from "./ToDateController";
|
||||||
|
import SelectProvince from "./SelectProvince";
|
||||||
|
import { Controller } from "react-hook-form";
|
||||||
|
|
||||||
|
const SearchReportField = ({ control, hasProvincesPermission }) => {
|
||||||
|
return (
|
||||||
|
<Grid container spacing={2} sx={{ py: 2 }}>
|
||||||
|
<Grid item xs={12} md={hasProvincesPermission ? 3 : 4}>
|
||||||
|
<FromDateController control={control} />
|
||||||
|
</Grid>
|
||||||
|
<Grid item xs={12} md={hasProvincesPermission ? 3 : 4}>
|
||||||
|
<ToDateController control={control} />
|
||||||
|
</Grid>
|
||||||
|
{hasProvincesPermission && (
|
||||||
|
<Grid item xs={12} md={3}>
|
||||||
|
<SelectProvince control={control} />
|
||||||
|
</Grid>
|
||||||
|
)}
|
||||||
|
<Grid item xs={12} md={hasProvincesPermission ? 3 : 4}>
|
||||||
|
<Controller
|
||||||
|
name="submitButton"
|
||||||
|
control={control}
|
||||||
|
render={({ field: { value, onChange }, formState: { isSubmitting } }) => (
|
||||||
|
<Button
|
||||||
|
variant="contained"
|
||||||
|
size="medium"
|
||||||
|
type="submit"
|
||||||
|
disabled={isSubmitting}
|
||||||
|
endIcon={<SearchIcon />}
|
||||||
|
fullWidth
|
||||||
|
>
|
||||||
|
{isSubmitting ? "درحال دریافت اطلاعات" : "جستجو"}
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default SearchReportField;
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
import { Controller } from "react-hook-form";
|
||||||
|
import MuiDatePicker from "@/core/components/MuiDatePicker";
|
||||||
|
import React from "react";
|
||||||
|
import { FormControl, FormHelperText, InputLabel, LinearProgress, MenuItem, Select, Typography } from "@mui/material";
|
||||||
|
import useProvinces from "@/lib/hooks/useProvince";
|
||||||
|
|
||||||
|
const SelectProvince = ({ control }) => {
|
||||||
|
const { provinces, loadingProvinces, errorProvinces } = useProvinces();
|
||||||
|
return (
|
||||||
|
<Controller
|
||||||
|
name="province_id"
|
||||||
|
control={control}
|
||||||
|
render={({ field, fieldState: { error } }) => (
|
||||||
|
<FormControl error={!!error} size="small" fullWidth>
|
||||||
|
<InputLabel id="demo-error-label">استان</InputLabel>
|
||||||
|
<Select
|
||||||
|
{...field}
|
||||||
|
labelId="demo-error-label"
|
||||||
|
id="province_id"
|
||||||
|
value={loadingProvinces ? "loading" : field.value || ""}
|
||||||
|
label="استان"
|
||||||
|
onChange={field.onChange}
|
||||||
|
>
|
||||||
|
{loadingProvinces ? (
|
||||||
|
<MenuItem value={"loading"}>در حال بارگذاری...</MenuItem>
|
||||||
|
) : errorProvinces ? (
|
||||||
|
<MenuItem value={"error"}>خطا در بارگذاری</MenuItem>
|
||||||
|
) : (
|
||||||
|
[
|
||||||
|
<MenuItem key="-1" value={"-1"}>
|
||||||
|
کل کشور
|
||||||
|
</MenuItem>,
|
||||||
|
...provinces.map((province) => (
|
||||||
|
<MenuItem key={province.id} value={province.id}>
|
||||||
|
{province.name_fa}
|
||||||
|
</MenuItem>
|
||||||
|
)),
|
||||||
|
]
|
||||||
|
)}
|
||||||
|
</Select>
|
||||||
|
{error && <FormHelperText>{error.message}</FormHelperText>}
|
||||||
|
</FormControl>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
export default SelectProvince;
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
import { Controller, useWatch } from "react-hook-form";
|
||||||
|
import MuiDatePicker from "@/core/components/MuiDatePicker";
|
||||||
|
import React from "react";
|
||||||
|
import moment from "jalali-moment";
|
||||||
|
|
||||||
|
const ToDateController = ({ control }) => {
|
||||||
|
const minDate = useWatch({ control, name: "from_date" });
|
||||||
|
return (
|
||||||
|
<Controller
|
||||||
|
name="date_to"
|
||||||
|
control={control}
|
||||||
|
render={({ field: { onChange, value }, fieldState: { error } }) => (
|
||||||
|
<MuiDatePicker
|
||||||
|
name="date_to"
|
||||||
|
minDate={minDate}
|
||||||
|
error={!!error}
|
||||||
|
value={value}
|
||||||
|
label={"تاریخ ثبت (تا تاریخ)"}
|
||||||
|
placeholder={"تا تاریخ"}
|
||||||
|
setFieldValue={(name, newValue) => {
|
||||||
|
const formattedDate = moment(new Date(newValue)).locale("en").format("YYYY-MM-DD");
|
||||||
|
onChange(formattedDate); // Update the field value in react-hook-form
|
||||||
|
}}
|
||||||
|
helperText={error ? error.message : null}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
export default ToDateController;
|
||||||
13
src/components/dashboard/roadSafety/report/Search/index.jsx
Normal file
13
src/components/dashboard/roadSafety/report/Search/index.jsx
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
import StyledForm from "@/core/components/StyledForm";
|
||||||
|
import SearchReportField from "./SearchReportField";
|
||||||
|
|
||||||
|
const SearchReportList = ({ handleSubmit, onSearchSubmit, control, hasProvincesPermission }) => {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<StyledForm onSubmit={handleSubmit(onSearchSubmit)}>
|
||||||
|
<SearchReportField control={control} hasProvincesPermission={hasProvincesPermission} />
|
||||||
|
</StyledForm>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
export default SearchReportList;
|
||||||
11
src/components/dashboard/roadSafety/report/Toolbar.jsx
Normal file
11
src/components/dashboard/roadSafety/report/Toolbar.jsx
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import PrintExcel from "./ExcelPrint";
|
||||||
|
import { Box } from "@mui/material";
|
||||||
|
|
||||||
|
const Toolbar = ({ table, filterData, mutate }) => {
|
||||||
|
return (
|
||||||
|
<Box sx={{ display: "flex", gap: 1 }}>
|
||||||
|
<PrintExcel table={table} filterData={filterData} />
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
export default Toolbar;
|
||||||
141
src/components/dashboard/roadSafety/report/index.jsx
Normal file
141
src/components/dashboard/roadSafety/report/index.jsx
Normal file
@@ -0,0 +1,141 @@
|
|||||||
|
"use client";
|
||||||
|
import PageTitle from "@/core/components/PageTitle";
|
||||||
|
import { LinearProgress, Stack } from "@mui/material";
|
||||||
|
import SearchReportList from "./Search";
|
||||||
|
import { useEffect, useState } from "react";
|
||||||
|
import ReportLists from "./ReportLists";
|
||||||
|
import useRequest from "@/lib/hooks/useRequest";
|
||||||
|
import { GET_ROAD_SAFETY_CITY_ACTIVITY_REPORT, GET_ROAD_SAFETY_PROVINCE_ACTIVITY_REPORT } from "@/core/utils/routes";
|
||||||
|
import moment from "jalali-moment";
|
||||||
|
import * as yup from "yup";
|
||||||
|
import { useForm } from "react-hook-form";
|
||||||
|
import { yupResolver } from "@hookform/resolvers/yup";
|
||||||
|
import { usePermissions } from "@/lib/hooks/usePermissions";
|
||||||
|
import { useAuth } from "@/lib/contexts/auth";
|
||||||
|
|
||||||
|
const ReportPage = () => {
|
||||||
|
const [data, setData] = useState(null);
|
||||||
|
const { data: userPermissions } = usePermissions();
|
||||||
|
const { user } = useAuth();
|
||||||
|
const requestServer = useRequest();
|
||||||
|
const hasProvincesPermission = userPermissions.some((item) =>
|
||||||
|
[
|
||||||
|
"show-safety-and-privacy-operator-cartable-province",
|
||||||
|
"show-safety-and-privacy-operator-cartable-edarate-shahri",
|
||||||
|
].includes(item)
|
||||||
|
);
|
||||||
|
|
||||||
|
const defaultValues = {
|
||||||
|
from_date: moment(new Date()).format("YYYY-MM-DD"),
|
||||||
|
date_to: moment(new Date()).format("YYYY-MM-DD"),
|
||||||
|
province_id: hasProvincesPermission ? "-1" : user.province_id,
|
||||||
|
};
|
||||||
|
const defaultFilter = [
|
||||||
|
{ value: `${defaultValues.province_id}`, datatype: "numeric", id: "province_id", fn: "equals" },
|
||||||
|
{ value: `${defaultValues.from_date}`, datatype: "date", id: "from_date", fn: "between" },
|
||||||
|
{ value: `${defaultValues.date_to}`, datatype: "date", id: "date_to", fn: "between" },
|
||||||
|
];
|
||||||
|
const [specialFilter, setSpecialFilter] = useState(defaultFilter);
|
||||||
|
|
||||||
|
const onSearchSubmit = async (data) => {
|
||||||
|
const params = new URLSearchParams();
|
||||||
|
params.set("from_date", `${data.from_date}`);
|
||||||
|
params.set("date_to", `${data.date_to}`);
|
||||||
|
setSpecialFilter([
|
||||||
|
{ value: `${data.province_id}`, datatype: "numeric", id: "province_id", fn: "equals" },
|
||||||
|
{ value: `${data.from_date}`, datatype: "date", id: "from_date", fn: "between" },
|
||||||
|
{ value: `${data.date_to}`, datatype: "date", id: "date_to", fn: "between" },
|
||||||
|
]);
|
||||||
|
if (data.province_id === "-1") {
|
||||||
|
try {
|
||||||
|
const response = await requestServer(`${GET_ROAD_SAFETY_PROVINCE_ACTIVITY_REPORT}?${params}`);
|
||||||
|
const result = response.data.data;
|
||||||
|
const nationalReportForItem = result.activities.find((report) => report.province_id === -1);
|
||||||
|
const nationalReport = {
|
||||||
|
edare_name: "کل کشور",
|
||||||
|
...nationalReportForItem,
|
||||||
|
};
|
||||||
|
|
||||||
|
setData({
|
||||||
|
data: [
|
||||||
|
nationalReport,
|
||||||
|
...result.provinces.map((province) => {
|
||||||
|
const filteredReports = result.activities.find(
|
||||||
|
(report) => report.province_id === province.id
|
||||||
|
);
|
||||||
|
return {
|
||||||
|
...filteredReports,
|
||||||
|
edare_name: province.name_fa,
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
filters: data,
|
||||||
|
});
|
||||||
|
} catch (e) {}
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
params.set("province_id", `${data.province_id}`);
|
||||||
|
const response = await requestServer(`${GET_ROAD_SAFETY_CITY_ACTIVITY_REPORT}?${params}`);
|
||||||
|
const result = response.data.data;
|
||||||
|
const nationalReportForItem = result.activities.find((report) => report.edare_shahri_id == "-1");
|
||||||
|
const nationalReport = {
|
||||||
|
...nationalReportForItem,
|
||||||
|
edare_name: "کل استان",
|
||||||
|
};
|
||||||
|
setData({
|
||||||
|
data: [
|
||||||
|
nationalReport,
|
||||||
|
...result.edarateShahri.map((edare) => {
|
||||||
|
const filteredReports = result.activities.find(
|
||||||
|
(report) => report.edare_shahri_id == edare.id
|
||||||
|
);
|
||||||
|
return {
|
||||||
|
edare_name: edare.name_fa,
|
||||||
|
...filteredReports,
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
filters: data,
|
||||||
|
});
|
||||||
|
} catch (e) {}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!userPermissions) return;
|
||||||
|
onSearchSubmit(defaultValues);
|
||||||
|
}, [userPermissions]);
|
||||||
|
|
||||||
|
const validationSchema = yup.object().shape({
|
||||||
|
from_date: yup
|
||||||
|
.string()
|
||||||
|
.required("تاریخ ثبت الزامی است!")
|
||||||
|
.matches(/^\d{4}-\d{2}-\d{2}$/, "تاریخ ثبت الزامی است!")
|
||||||
|
.test("is-valid-date", "تاریخ ثبت معتبر نیست!", (value) => moment(value, "YYYY-MM-DD", true).isValid()),
|
||||||
|
date_to: yup
|
||||||
|
.string()
|
||||||
|
.required("تاریخ ثبت الزامی است!")
|
||||||
|
.matches(/^\d{4}-\d{2}-\d{2}$/, "تاریخ ثبت الزامی است!")
|
||||||
|
.test("is-valid-date", "تاریخ ثبت معتبر نیست!", (value) => moment(value, "YYYY-MM-DD", true).isValid()),
|
||||||
|
province_id: yup.string().nullable(),
|
||||||
|
});
|
||||||
|
|
||||||
|
const { control, handleSubmit } = useForm({
|
||||||
|
defaultValues,
|
||||||
|
resolver: yupResolver(validationSchema),
|
||||||
|
mode: "onBlur",
|
||||||
|
});
|
||||||
|
return (
|
||||||
|
<Stack spacing={1}>
|
||||||
|
<PageTitle title={"گزارش نگهداری حریم راه"} />
|
||||||
|
<SearchReportList
|
||||||
|
control={control}
|
||||||
|
hasProvincesPermission={hasProvincesPermission}
|
||||||
|
handleSubmit={handleSubmit}
|
||||||
|
onSearchSubmit={onSearchSubmit}
|
||||||
|
/>
|
||||||
|
{!data ? <LinearProgress /> : <ReportLists specialFilter={specialFilter} data={data} />}
|
||||||
|
</Stack>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
export default ReportPage;
|
||||||
@@ -331,20 +331,18 @@ export const pageMenu = [
|
|||||||
"show-safety-and-privacy-operator-cartable",
|
"show-safety-and-privacy-operator-cartable",
|
||||||
"show-safety-and-privacy-operator-cartable-province",
|
"show-safety-and-privacy-operator-cartable-province",
|
||||||
"show-safety-and-privacy-operator-cartable-edarate-shahri",
|
"show-safety-and-privacy-operator-cartable-edarate-shahri",
|
||||||
"add-safety-and-privacy",
|
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "safetyAndPrivacyManagmentReport",
|
id: "safetyAndPrivacyManagmentReport",
|
||||||
label: "گزارش ها",
|
label: "گزارش ها",
|
||||||
type: "page",
|
type: "page",
|
||||||
route: process.env.NEXT_PUBLIC_API_URL + "/v2/safety_and_privacy/report",
|
route: "/dashboard/road-safety/report",
|
||||||
icon: <AssessmentIcon sx={{ width: "inherit", height: "inherit" }} />,
|
icon: <AssessmentIcon sx={{ width: "inherit", height: "inherit" }} />,
|
||||||
permissions: [
|
permissions: [
|
||||||
"show-safety-and-privacy-operator-cartable",
|
"show-safety-and-privacy-operator-cartable",
|
||||||
"show-safety-and-privacy-operator-cartable-province",
|
"show-safety-and-privacy-operator-cartable-province",
|
||||||
"show-safety-and-privacy-operator-cartable-edarate-shahri",
|
"show-safety-and-privacy-operator-cartable-edarate-shahri",
|
||||||
"add-safety-and-privacy",
|
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -127,3 +127,7 @@ export const UPDATE_FAST_REACT = api + "/api/v3/road_observations/modify_registr
|
|||||||
export const EXPORT_FAST_REACT_SUPERVISOR_LIST = api + "/api/v3/road_observations/supervisor_report";
|
export const EXPORT_FAST_REACT_SUPERVISOR_LIST = api + "/api/v3/road_observations/supervisor_report";
|
||||||
export const EXPORT_FAST_REACT_OPERATOR_LIST = api + "/api/v3/road_observations/operator_report";
|
export const EXPORT_FAST_REACT_OPERATOR_LIST = api + "/api/v3/road_observations/operator_report";
|
||||||
export const EXPORT_FAST_REACT_COMPLAINT_LIST = api + "/api/v3/road_observations/complaints_report";
|
export const EXPORT_FAST_REACT_COMPLAINT_LIST = api + "/api/v3/road_observations/complaints_report";
|
||||||
|
|
||||||
|
// road safety
|
||||||
|
export const GET_ROAD_SAFETY_PROVINCE_ACTIVITY_REPORT = api + "/api/v3/safety_and_privacy_report/country_activity";
|
||||||
|
export const GET_ROAD_SAFETY_CITY_ACTIVITY_REPORT = api + "/api/v3/safety_and_privacy_report/province_activity";
|
||||||
|
|||||||
Reference in New Issue
Block a user