added excel export & removed polygons in missions
This commit is contained in:
@@ -12,7 +12,6 @@ const MapLayer = dynamic(() => import("@/core/components/MapLayer"), {
|
||||
|
||||
const Area = ({ allData, setAllData, handlePrev, setTabState }) => {
|
||||
const [bound, setBound] = useState(allData.bound);
|
||||
const [boundType, setBoundType] = useState(allData.bound_type);
|
||||
|
||||
const handleNext = useCallback(() => {
|
||||
setAllData({ bound: bound });
|
||||
@@ -23,19 +22,9 @@ const Area = ({ allData, setAllData, handlePrev, setTabState }) => {
|
||||
<>
|
||||
<DialogContent dividers>
|
||||
<Stack spacing={2}>
|
||||
<SelectBoundType
|
||||
boundType={boundType}
|
||||
setBoundType={setBoundType}
|
||||
setBound={setBound}
|
||||
setAllData={setAllData}
|
||||
/>
|
||||
<Box sx={{ width: "100%", height: "400px" }}>
|
||||
<MapLayer style={{ borderRadius: "4px" }}>
|
||||
{boundType == "polygon" ? (
|
||||
<MapControlPolygon bound={bound} setBound={setBound} boundType={boundType} />
|
||||
) : (
|
||||
<MapControlPolyline bound={bound} setBound={setBound} boundType={boundType} />
|
||||
)}
|
||||
<MapControlPolyline bound={bound} setBound={setBound} boundType={"polyline"} />
|
||||
</MapLayer>
|
||||
</Box>
|
||||
</Stack>
|
||||
|
||||
@@ -60,7 +60,7 @@ const CreateForm = ({ defaultValues, submitForm, setOpen, submitting }) => {
|
||||
>
|
||||
<Tab icon={<InsertDriveFile />} label="مشخصات" />
|
||||
<Tab disabled={tabState < 1} icon={<AccessTime />} label="زمانبندی" />
|
||||
<Tab disabled={tabState < 2} icon={<Route />} label="منطقه عملیاتی" />
|
||||
<Tab disabled={tabState < 2} icon={<Route />} label="مسیر عملیاتی" />
|
||||
<Tab disabled={tabState < 3} icon={<Engineering />} label="همراهان" />
|
||||
<Tab disabled={tabState < 4} icon={<Verified />} label="بررسی نهایی" />
|
||||
</Tabs>
|
||||
|
||||
@@ -20,16 +20,8 @@ const Create = ({ mutate }) => {
|
||||
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]);
|
||||
let area = 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,
|
||||
|
||||
@@ -61,7 +61,7 @@ const CreateForm = ({ defaultValues, submitForm, setOpen, submitting }) => {
|
||||
>
|
||||
<Tab icon={<InsertDriveFile />} label="مشخصات" />
|
||||
<Tab disabled={tabState < 1} icon={<AccessTime />} label="زمانبندی" />
|
||||
<Tab disabled={tabState < 2} icon={<Route />} label="منطقه عملیاتی" />
|
||||
<Tab disabled={tabState < 2} icon={<Route />} label="مسیر عملیاتی" />
|
||||
<Tab disabled={tabState < 3} icon={<LocalShipping />} label="خودرو و راننده" />
|
||||
<Tab disabled={tabState < 4} icon={<Engineering />} label="همراهان" />
|
||||
<Tab disabled={tabState < 5} icon={<Verified />} label="بررسی نهایی" />
|
||||
|
||||
@@ -20,16 +20,7 @@ const CreateWithoutProcess = ({ mutate }) => {
|
||||
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 });
|
||||
}
|
||||
let area = bound.map((latlng) => [latlng.lng, latlng.lat]);
|
||||
|
||||
await requestServer(REQUEST_MISSION_WITHOUT_PROCESS, "post", {
|
||||
data: {
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
"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 { EXPORT_COUNTRY_ROAD_MISSIONS_REPORTS, EXPORT_PROVINCE_ROAD_MISSIONS_REPORTS } from "@/core/utils/routes";
|
||||
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";
|
||||
import DescriptionIcon from "@mui/icons-material/Description";
|
||||
import { Button, CircularProgress, IconButton, useMediaQuery } from "@mui/material";
|
||||
import FileSaver from "file-saver";
|
||||
import moment from "jalali-moment";
|
||||
import { useMemo, useState } from "react";
|
||||
|
||||
const PrintExcel = ({ table, filterData }) => {
|
||||
const theme = useTheme();
|
||||
@@ -33,7 +33,9 @@ const PrintExcel = ({ table, filterData }) => {
|
||||
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;
|
||||
CountryOrProvince.value === "-1"
|
||||
? EXPORT_COUNTRY_ROAD_MISSIONS_REPORTS
|
||||
: EXPORT_PROVINCE_ROAD_MISSIONS_REPORTS;
|
||||
requestServer(`${requestUrl}?${filterParams}`, "get", {
|
||||
requestOptions: { responseType: "blob" },
|
||||
})
|
||||
|
||||
@@ -8,9 +8,9 @@ const ReportLists = ({ data, specialFilter }) => {
|
||||
const columns = useMemo(() => {
|
||||
return [
|
||||
{
|
||||
accessorKey: "province_name",
|
||||
accessorKey: "edare_name",
|
||||
header: "اداره کل",
|
||||
id: "province_name",
|
||||
id: "edare_name",
|
||||
enableColumnFilter: false,
|
||||
enableSorting: false,
|
||||
datatype: "text",
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
import PrintExcel from "./ExcelPrint";
|
||||
import { Box } from "@mui/material";
|
||||
import PrintExcel from "./ExcelPrint";
|
||||
|
||||
const Toolbar = ({ table, filterData, mutate }) => {
|
||||
return <Box sx={{ display: "flex", gap: 1 }}>{/* <PrintExcel table={table} filterData={filterData} /> */}</Box>;
|
||||
return (
|
||||
<Box sx={{ display: "flex", gap: 1 }}>
|
||||
<PrintExcel table={table} filterData={filterData} />
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
export default Toolbar;
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
"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_CITY_ACTIVITY_REPORT, GET_MISSION_CITY_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 { GET_COUNTRY_ACTIVITY_REPORT, GET_PROVINCE_ACTIVITY_REPORT } from "@/core/utils/routes";
|
||||
import { useAuth } from "@/lib/contexts/auth";
|
||||
import { usePermissions } from "@/lib/hooks/usePermissions";
|
||||
import useRequest from "@/lib/hooks/useRequest";
|
||||
import { yupResolver } from "@hookform/resolvers/yup";
|
||||
import { LinearProgress, Stack } from "@mui/material";
|
||||
import moment from "jalali-moment";
|
||||
import { useEffect, useState } from "react";
|
||||
import { useForm } from "react-hook-form";
|
||||
import * as yup from "yup";
|
||||
import ReportLists from "./ReportLists";
|
||||
import SearchReportList from "./Search";
|
||||
|
||||
const ReportPage = () => {
|
||||
const [data, setData] = useState(null);
|
||||
@@ -41,57 +41,61 @@ const ReportPage = () => {
|
||||
{ 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 {
|
||||
params.set("province_id", `${data.province_id}`);
|
||||
const response = await requestServer(`${GET_CITY_ACTIVITY_REPORT}?${params}`);
|
||||
const result = response.data.data;
|
||||
const nationalReportForItem = result.activities.find((report) => report.province_id === "-1");
|
||||
const nationalReport = {
|
||||
edare_name: "کل کشور",
|
||||
...nationalReportForItem,
|
||||
};
|
||||
if (data.province_id === "-1") {
|
||||
try {
|
||||
params.set("province_id", `${data.province_id}`);
|
||||
const response = await requestServer(`${GET_COUNTRY_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);
|
||||
console.log(filteredReports);
|
||||
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_MISSION_CITY_ACTIVITY_REPORT}?${params}`);
|
||||
// const result = response.data.data;
|
||||
// const nationalReportForItem = result.activities.find((report) => report.edare_id === "-1");
|
||||
// const nationalReport = {
|
||||
// ...nationalReportForItem,
|
||||
// edare_name: "کل استان",
|
||||
// };
|
||||
// setData({
|
||||
// data: [
|
||||
// nationalReport,
|
||||
// ...result.edarateShahri.map((edare) => {
|
||||
// const filteredReports = result.activities.find((report) => report.edare_id == edare.id);
|
||||
// return {
|
||||
// edare_name: edare.name_fa,
|
||||
// ...filteredReports,
|
||||
// };
|
||||
// }),
|
||||
// ],
|
||||
// filters: data,
|
||||
// });
|
||||
// } catch (e) {}
|
||||
// }
|
||||
setData({
|
||||
data: [
|
||||
nationalReport,
|
||||
...result.provinces.map((province) => {
|
||||
const filteredReports = result.activities.find(
|
||||
(report) => report.province_id == province.id
|
||||
);
|
||||
console.log(filteredReports);
|
||||
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_PROVINCE_ACTIVITY_REPORT}?${params}`);
|
||||
const result = response.data.data;
|
||||
|
||||
const nationalReportForItem = result.activities.find((report) => report.city_id === "-1");
|
||||
|
||||
const nationalReport = {
|
||||
...nationalReportForItem,
|
||||
edare_name: "کل استان",
|
||||
};
|
||||
setData({
|
||||
data: [
|
||||
nationalReport,
|
||||
...result.city.map((city) => {
|
||||
const filteredReports = result.activities.find((report) => report.city_id == city.id);
|
||||
return {
|
||||
edare_name: city.name_fa,
|
||||
...filteredReports,
|
||||
};
|
||||
}),
|
||||
],
|
||||
filters: data,
|
||||
});
|
||||
} catch (e) {}
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
@@ -42,8 +42,8 @@ export const CREATE_PATROL = api + "/api/v3/road_patrols/operator/store";
|
||||
export const GET_FMS_DATA = api + "/api/v3/fms_vehicle/get_activity";
|
||||
export const GET_OTP_TOKEN = api + "/api/v3/otp/get_token";
|
||||
|
||||
export const GET_PROVINCE_ACTIVITY_REPORT = api + "/api/v3/road_patrols/report/country_activity";
|
||||
export const GET_CITY_ACTIVITY_REPORT = api + "/api/v3/missions/report/country_activity";
|
||||
export const GET_PROVINCE_ACTIVITY_REPORT = api + "/api/v3/missions/report/province_activity";
|
||||
export const GET_COUNTRY_ACTIVITY_REPORT = api + "/api/v3/missions/report/country_activity";
|
||||
export const EXPORT_COUNTRY_ROAD_PATROL_REPORTS = api + "/api/v3/road_patrols/report/country_activity_excel";
|
||||
export const EXPORT_PROVINCE_ROAD_PATROL_REPORTS = api + "/api/v3/road_patrols/report/province_activity_excel";
|
||||
|
||||
@@ -233,6 +233,8 @@ export const GET_MISSION_PROVINCE_ACTIVITY_REPORT = api + "/api/v3/missions/repo
|
||||
export const GET_MISSION_CITY_ACTIVITY_REPORT = api + "/api/v3/missions/report/country_activity";
|
||||
export const CREATE_VIOLATION = api + "/api/v3/missions/violation_management";
|
||||
export const EDIT_VIOLATION = api + "/api/v3/missions/violation_management";
|
||||
export const EXPORT_COUNTRY_ROAD_MISSIONS_REPORTS = api + "/api/v3/missions/report/country_excel_activity";
|
||||
export const EXPORT_PROVINCE_ROAD_MISSIONS_REPORTS = api + "/api/v3/missions/report/province_excel_activity";
|
||||
|
||||
export const GET_MACHINES_TABLE_LIST = api + "/api/v3/cmms_machines";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user