general manager show

This commit is contained in:
2025-11-26 11:33:09 +03:30
parent 84529088fb
commit 65beffa11e
9 changed files with 405 additions and 1 deletions

View File

@@ -1,11 +1,12 @@
import WithPermission from "@/core/middlewares/withPermission";
import GeneralManagerPage from "@/components/dashboard/inquiryPrivacy/general-manager";
export const metadata = {
title: "کارتابل مدیر",
};
const Page = () => {
return (
<WithPermission permission_name={["all"]}>
<h1>کارتابل مدیر</h1>
<GeneralManagerPage />
</WithPermission>
);
};

View File

@@ -0,0 +1,243 @@
import CustomSelectByDependency from "@/core/components/DataTable/filter/fieldsType/CustomSelectByDependency";
import DataTableWithAuth from "@/core/components/DataTableWithAuth";
import useInquiryPrivacyState from "@/lib/hooks/useInquiryPrivacyState";
import AutorenewIcon from "@mui/icons-material/Autorenew";
import DangerousIcon from "@mui/icons-material/Dangerous";
import ManageAccountsIcon from "@mui/icons-material/ManageAccounts";
import MapsHomeWorkIcon from "@mui/icons-material/MapsHomeWork";
import PsychologyAltIcon from "@mui/icons-material/PsychologyAlt";
import ReceiptLongIcon from "@mui/icons-material/ReceiptLong";
import SecurityIcon from "@mui/icons-material/Security";
import WindowIcon from "@mui/icons-material/Window";
import { Box, Stack } from "@mui/material";
import moment from "jalali-moment";
import { useMemo } from "react";
import RowActions from "./RowActions";
import { GET_GENERAL_MANAGER_LIST } from "@/core/utils/routes";
import ShowPrimaryArea from "./ShowPrimaryArea";
const GeneralManagerList = () => {
const stateIcon = (state_id) => {
if (state_id === 1) return <MapsHomeWorkIcon sx={{ color: "#A0B9C6" }} />;
if (state_id === 2 || state_id === 5 || state_id === 13) return <SecurityIcon sx={{ color: "#995FA3" }} />;
if (state_id === 3 || state_id === 6 || state_id === 14)
return <ManageAccountsIcon sx={{ color: "#9A98B5" }} />;
if (state_id === 4 || state_id === 7 || state_id === 15) return <PsychologyAltIcon sx={{ color: "#1B9AAA" }} />;
if (state_id === 8) return <ReceiptLongIcon sx={{ color: "#9A98B5" }} />;
if (state_id === 9 || state_id === 11) return <WindowIcon sx={{ color: "#DDDBCB" }} />;
if (state_id === 10) return <DangerousIcon sx={{ color: "error.main" }} />;
if (state_id === 12) return <AutorenewIcon sx={{ color: "#899878" }} />;
};
const columns = useMemo(() => {
return [
{
accessorKey: "panjare_vahed_id",
header: "کدرهگیری درخواست",
id: "panjare_vahed_id",
enableColumnFilter: true,
datatype: "text",
filterMode: "equals",
sortDescFirst: false,
columnFilterModeOptions: ["equals", "contains"],
grow: false,
size: 100,
Cell: ({ row }) => <>{row.original.panjare_vahed_id}</>,
},
{
accessorKey: "national_id",
header: "کد ملی",
id: "national_id",
enableColumnFilter: true,
datatype: "text",
filterMode: "equals",
sortDescFirst: false,
columnFilterModeOptions: ["equals", "contains"],
grow: false,
size: 100,
Cell: ({ row }) => <>{row.original.national_id}</>,
},
{
accessorKey: "state_id",
header: "وضعیت",
id: "state_id",
enableColumnFilter: true,
datatype: "numeric",
filterMode: "equals",
sortDescFirst: false,
grow: false,
size: 100,
ColumnSelectComponent: (props) => {
const { itemsList, loadingItemsList, errorItemsList } = useInquiryPrivacyState();
const getColumnSelectOptions = useMemo(() => {
if (loadingItemsList) {
return [{ value: "loading", label: "در حال بارگذاری..." }];
}
if (errorItemsList) {
return [{ value: "error", label: "خطا در بارگذاری" }];
}
return [
{ value: "", label: "همه موارد" },
...itemsList.map((item) => ({
value: item.id,
label: item.name,
})),
];
}, [itemsList, loadingItemsList, errorItemsList]);
return (
<CustomSelectByDependency
{...props}
value={loadingItemsList ? "loading" : props.filterParameters.value}
columnSelectOption={getColumnSelectOptions}
/>
);
},
Cell: ({ row }) => (
<Box sx={{ display: "flex", alignItems: "center" }}>
{stateIcon(row.original.state_id)}
<Box component="span" ml={1}>
{row.original.state_name}
</Box>
</Box>
),
},
{
accessorKey: "plan_title",
header: "عنوان طرح",
id: "plan_title",
enableColumnFilter: true,
datatype: "text",
filterMode: "equals",
sortDescFirst: false,
columnFilterModeOptions: ["equals", "contains"],
grow: false,
size: 100,
Cell: ({ row }) => <>{row.original.plan_title}</>,
},
{
accessorKey: "plan_group",
header: "گروه طرح",
id: "plan_group",
enableColumnFilter: true,
datatype: "text",
filterMode: "equals",
sortDescFirst: false,
columnFilterModeOptions: ["equals", "contains"],
grow: false,
size: 100,
Cell: ({ row }) => <>{row.original.plan_group}</>,
},
{
accessorKey: "requested_organization",
header: "دستگاه صادر کننده",
id: "requested_organization",
enableColumnFilter: true,
datatype: "text",
filterMode: "equals",
sortDescFirst: false,
columnFilterModeOptions: ["equals", "contains"],
grow: false,
size: 100,
Cell: ({ row }) => <>{row.original.requested_organization}</>,
},
{
accessorKey: "worksheet_id",
header: "شناسه کاربرگ",
id: "worksheet_id",
enableColumnFilter: true,
datatype: "text",
filterMode: "equals",
sortDescFirst: false,
columnFilterModeOptions: ["equals", "contains"],
grow: false,
size: 100,
Cell: ({ row }) => <>{row.original.worksheet_id}</>,
},
{
accessorKey: "primary_area",
header: "نمایش محدوده طرح",
id: "primary_area",
enableColumnFilter: true,
datatype: "text",
filterMode: "equals",
sortDescFirst: false,
columnFilterModeOptions: ["equals", "contains"],
grow: false,
size: 100,
Cell: ({ row }) =>
row.original.primary_area ? (
<Stack alignItems={"center"} justifyContent={"center"}>
<ShowPrimaryArea primaryArea={row.original.primary_area} />
</Stack>
) : (
"-"
),
},
{
accessorKey: "province_id",
header: "استان",
id: "province_id",
enableColumnFilter: false,
datatype: "numeric",
sortDescFirst: false,
grow: false,
size: 100,
Cell: ({ row }) => <>{row.original.province_name}</>,
},
{
accessorKey: "city_id",
header: "شهر",
id: "city_id",
enableColumnFilter: false,
datatype: "numeric",
sortDescFirst: false,
grow: false,
size: 100,
Cell: ({ row }) => <>{row.original.city_name}</>,
},
{
accessorKey: "isic",
header: "کد آیسیک",
id: "isic",
enableColumnFilter: true,
datatype: "text",
filterMode: "equals",
sortDescFirst: false,
columnFilterModeOptions: ["equals", "contains"],
grow: false,
size: 100,
Cell: ({ row }) => <>{row.original.isic}</>,
},
{
accessorFn: (row) => moment(row.request_date).locale("fa").format("YYYY/MM/DD"),
header: "تاریخ درخواست",
id: "request_date",
enableColumnFilter: true,
datatype: "date",
filterMode: "between",
grow: false,
size: 100,
},
];
}, []);
return (
<>
<Box sx={{ p: 1, border: 1, borderColor: "divider", borderRadius: 1 }}>
<DataTableWithAuth
need_filter={true}
columns={columns}
table_url={GET_GENERAL_MANAGER_LIST}
page_name={"PrivacyOffice"}
table_name={"GeneralManagerList"}
enableRowActions
positionActionsColumn={"first"}
RowActions={RowActions}
/>
</Box>
</>
);
};
export default GeneralManagerList;

View File

@@ -0,0 +1,17 @@
import ThumbUpIcon from "@mui/icons-material/ThumbUp";
import { IconButton, Tooltip } from "@mui/material";
import { useState } from "react";
const ConfirmAction = ({ rowId, mutate }) => {
const [openConfirmDialog, setOpenConfirmDialog] = useState(false);
return (
<>
<Tooltip title="تایید اقدام">
<IconButton color="success" onClick={() => setOpenConfirmDialog(true)}>
<ThumbUpIcon />
</IconButton>
</Tooltip>
</>
);
};
export default ConfirmAction;

View File

@@ -0,0 +1,17 @@
import ThumbDownIcon from "@mui/icons-material/ThumbDown";
import { IconButton, Tooltip } from "@mui/material";
import { useState } from "react";
const RejectAction = ({ rowId, mutate }) => {
const [openRejectDialog, setOpenRejectDialog] = useState(false);
return (
<>
<Tooltip title="عدم تایید اقدام">
<IconButton color="error" onClick={() => setOpenRejectDialog(true)}>
<ThumbDownIcon />
</IconButton>
</Tooltip>
</>
);
};
export default RejectAction;

View File

@@ -0,0 +1,13 @@
import { Box } from "@mui/material";
import ConfirmAction from "./ConfirmAction";
import RejectAction from "./RejectAction";
const RowActions = ({ row, mutate }) => {
return (
<Box sx={{ display: "flex", gap: 1, justifyContent: "Center" }}>
<RejectAction />
<ConfirmAction />
</Box>
);
};
export default RowActions;

View File

@@ -0,0 +1,29 @@
import { useEffect, useRef } from "react";
import { FeatureGroup, useMap } from "react-leaflet";
const ShowBound = ({ bound }) => {
const map = useMap();
const featureRef = useRef(null);
const safeFitBounds = (layer) => {
if (!layer || !map) return;
try {
const latLngs = layer.getLatLngs();
map.fitBounds(latLngs, {
paddingTopLeft: [20, 20],
paddingBottomRight: [20, 20],
});
} catch (e) {
console.warn("fitBounds failed:", e);
}
};
useEffect(() => {
bound?.editing?.disable();
featureRef.current.addLayer(bound);
safeFitBounds(bound);
}, []);
return <FeatureGroup ref={featureRef} />;
};
export default ShowBound;

View File

@@ -0,0 +1,69 @@
const {
Button,
IconButton,
Tooltip,
Box,
Dialog,
DialogTitle,
Typography,
DialogContent,
DialogActions,
} = require("@mui/material");
import LayersIcon from "@mui/icons-material/Layers";
import CloseIcon from "@mui/icons-material/Close";
import { useMemo, useState } from "react";
import MapLayer from "@/core/components/MapLayer";
import ShowBound from "./ShowBound";
const ShowPrimaryArea = ({ primaryArea }) => {
const [openShowAreaDialog, setOpenShowAreaDialog] = useState(false);
const bound = useMemo(() => {
const latLngCoords = primaryArea.coordinates.map((coord) => [coord[1], coord[0]]);
return primaryArea.type === "polygon" ? L.polygon(latLngCoords) : L.polyline(latLngCoords);
}, [primaryArea]);
return (
<Box>
<Tooltip title="نمایش پلیگان" placement="right" arrow>
<IconButton size="small" color="primary" onClick={() => setOpenShowAreaDialog(true)}>
<LayersIcon />
</IconButton>
</Tooltip>
<Dialog
open={openShowAreaDialog}
onClose={() => setOpenShowAreaDialog(false)}
PaperProps={{
sx: {
transition: "all .3s",
boxShadow: "rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px",
borderRadius: 2,
padding: 1,
},
}}
maxWidth="sm"
fullWidth
dir="rtl"
>
<DialogTitle sx={{ display: "flex", justifyContent: "space-between", padding: "16px 24px" }}>
<Typography variant="body1" sx={{ fontWeight: "bold", fontSize: "large" }}>
محدوده طرح
</Typography>
<IconButton onClick={() => setOpenShowAreaDialog(false)} size="small">
<CloseIcon />
</IconButton>
</DialogTitle>
<DialogContent>
<Box sx={{ flex: 1 }}>
<Box sx={{ width: "100%", height: "400px" }}>
<MapLayer style={{ borderRadius: "4px" }}>
<ShowBound bound={bound} />
</MapLayer>
</Box>
</Box>
</DialogContent>
</Dialog>
</Box>
);
};
export default ShowPrimaryArea;

View File

@@ -0,0 +1,14 @@
"use client";
import PageTitle from "@/core/components/PageTitle";
import { Stack } from "@mui/material";
import GeneralManagerList from "./GeneralManagerList";
const GeneralManagerPage = () => {
return (
<Stack spacing={1}>
<PageTitle title={"کارتابل اداره حریم استعلام حریم"} />
<GeneralManagerList />
</Stack>
);
};
export default GeneralManagerPage;

View File

@@ -240,3 +240,4 @@ export const GET_CITY_ADMIN_LIST = api + "/api/v3/harim/province_office";
export const GET_INQUIRY_PRIVACY_STATE_LIST = api + "/api/v3/harim/detail/states";
export const CITY_ADMIN_FEEDBACK = api + "/api/v3/harim/province_office/feedback";
export const GET_PRIVACY_ADMIN_LIST = api + "/api/v3/harim/harim_office";
export const GET_GENERAL_MANAGER_LIST = api + "/api/v3/harim/general_manager";