Merge branch 'feature/damage_report' into 'develop'
Feature/damage report See merge request witel-front-end/rms!73
This commit is contained in:
@@ -15,6 +15,7 @@ import KeyboardDoubleArrowLeftIcon from "@mui/icons-material/KeyboardDoubleArrow
|
||||
import DamageReport from "./DamageReport";
|
||||
import DamageItem from "./DamageItem";
|
||||
import validateNationalCode from "@/core/utils/nationalCodeValidation";
|
||||
import AssessmentIcon from "@mui/icons-material/Assessment";
|
||||
|
||||
function TabPanel(props) {
|
||||
const { children, value, index } = props;
|
||||
@@ -171,7 +172,7 @@ const CreateFormContent = ({ setOpen, SubmitDamage, defaultData }) => {
|
||||
}}
|
||||
>
|
||||
<Tab icon={<InfoIcon />} label="اطلاعات تصادف" />
|
||||
<Tab disabled={tabState === 0} icon={<FileCopyIcon />} label="گزارش میزان خسارت" />
|
||||
<Tab disabled={tabState === 0} icon={<AssessmentIcon />} label="گزارش خسارت" />
|
||||
<Tab disabled={tabState === 0 || tabState === 1} icon={<MinorCrashIcon />} label="آیتم خسارت" />
|
||||
</Tabs>
|
||||
<DialogContent dividers sx={{ overflowY: "auto", maxHeight: "70vh" }}>
|
||||
|
||||
@@ -21,7 +21,7 @@ const EditForm = ({ row, mutate, rowId }) => {
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
<Dialog
|
||||
maxWidth="sm"
|
||||
maxWidth="md"
|
||||
fullWidth
|
||||
open={openEditDialog}
|
||||
PaperProps={{
|
||||
|
||||
@@ -12,7 +12,8 @@ import useEdaratLists from "@/lib/hooks/useEdaratLists";
|
||||
import ImageDialog from "./RowActions/ImageDialog";
|
||||
import LocationForm from "./RowActions/LocationForm";
|
||||
import ShowPlate from "./RowActions/ShowPlate";
|
||||
import DamageItemDialog from "@/components/dashboard/damages/operator/RowActions/DamageItemDialog";
|
||||
import DamageItemDialog from "./RowActions/DamageItemDialog";
|
||||
import DamageReportDialog from "./RowActions/DamageReport";
|
||||
|
||||
const OperatorList = () => {
|
||||
const statusOptions = [
|
||||
@@ -259,6 +260,31 @@ const OperatorList = () => {
|
||||
grow: false,
|
||||
size: 50,
|
||||
columns: [
|
||||
{
|
||||
header: "گزارش خسارت",
|
||||
id: "damageReport",
|
||||
enableColumnFilter: false,
|
||||
enableSorting: false,
|
||||
datatype: "array",
|
||||
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"}>
|
||||
<DamageReportDialog rowId={row.getValue("id")} />
|
||||
</Stack>
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
header: "آیتم های خسارت",
|
||||
id: "damageItems",
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
import { Box, Button, Chip, DialogContent, Divider, Grid, Typography } from "@mui/material";
|
||||
import PaymentIcon from "@mui/icons-material/Payment";
|
||||
import moment from "jalali-moment";
|
||||
import DownloadIcon from "@mui/icons-material/Download";
|
||||
import FormatListNumberedIcon from "@mui/icons-material/FormatListNumbered";
|
||||
import EventNoteIcon from "@mui/icons-material/EventNote";
|
||||
import ImageIcon from "@mui/icons-material/Image";
|
||||
|
||||
const DamageReportContent = ({ damageReportDetails }) => {
|
||||
return (
|
||||
<>
|
||||
<DialogContent>
|
||||
<Grid container spacing={3} sx={{ alignItems: "center", justifyContent: "space-around" }}>
|
||||
<Grid item xs={12} sm={12} sx={{ display: "flex", alignItems: "center" }}>
|
||||
<Box sx={{ display: "flex", alignItems: "center" }}>
|
||||
<Chip
|
||||
icon={<PaymentIcon />}
|
||||
label={
|
||||
<Typography variant="body2" sx={{ fontWeight: 600, color: "grey.700" }}>
|
||||
گزارش دهنده
|
||||
</Typography>
|
||||
}
|
||||
/>
|
||||
</Box>
|
||||
<Divider sx={{ flex: 1, mx: 2 }} />
|
||||
<Typography variant="body2" sx={{ fontWeight: 600, color: "grey.800" }}>
|
||||
{damageReportDetails?.report_base === 1
|
||||
? "بازدید عوامل و کارشناسان راهداری"
|
||||
: "کروکی یا نامه پلیس راه"}
|
||||
</Typography>
|
||||
</Grid>
|
||||
{damageReportDetails?.report_base === 0 && (
|
||||
<>
|
||||
<Grid item xs={12} sm={12} sx={{ display: "flex", alignItems: "center" }}>
|
||||
<Box sx={{ display: "flex", alignItems: "center" }}>
|
||||
<Chip
|
||||
icon={<FormatListNumberedIcon />}
|
||||
label={
|
||||
<Typography variant="body2" sx={{ fontWeight: 600, color: "grey.700" }}>
|
||||
شماره کروکی یا نامه پلیس راه
|
||||
</Typography>
|
||||
}
|
||||
/>
|
||||
</Box>
|
||||
<Divider sx={{ flex: 1, mx: 2 }} />
|
||||
<Typography variant="body2" sx={{ fontWeight: 600, color: "grey.800" }}>
|
||||
{damageReportDetails?.police_serial}
|
||||
</Typography>
|
||||
</Grid>
|
||||
<Grid item xs={12} sm={12} sx={{ display: "flex", alignItems: "center" }}>
|
||||
<Box sx={{ display: "flex", alignItems: "center" }}>
|
||||
<Chip
|
||||
icon={<EventNoteIcon />}
|
||||
label={
|
||||
<Typography variant="body2" sx={{ fontWeight: 600, color: "grey.700" }}>
|
||||
تاریخ کروکی یا نامه پلیس راه
|
||||
</Typography>
|
||||
}
|
||||
/>
|
||||
</Box>
|
||||
<Divider sx={{ flex: 1, mx: 2 }} />
|
||||
<Typography variant="body2" sx={{ fontWeight: 600, color: "grey.800" }}>
|
||||
{moment(damageReportDetails?.police_file_date, "YYYY-MM-DD HH:mm:ss")
|
||||
.locale("fa")
|
||||
.format("YYYY/MM/DD")}
|
||||
</Typography>
|
||||
</Grid>
|
||||
<Grid item xs={12} sm={12} sx={{ display: "flex", alignItems: "center" }}>
|
||||
<Box sx={{ display: "flex", alignItems: "center" }}>
|
||||
<Chip
|
||||
icon={<ImageIcon />}
|
||||
label={
|
||||
<Typography variant="body2" sx={{ fontWeight: 600, color: "grey.700" }}>
|
||||
تصویر کروکی یا نامه پلیس راه
|
||||
</Typography>
|
||||
}
|
||||
/>
|
||||
</Box>
|
||||
<Divider sx={{ flex: 1, mx: 2 }} />
|
||||
<Button
|
||||
variant="contained"
|
||||
color="primary"
|
||||
size="small"
|
||||
startIcon={<DownloadIcon />}
|
||||
onClick={() => {
|
||||
if (damageReportDetails?.police_file) {
|
||||
window.open(damageReportDetails.police_file, "_blank");
|
||||
} else {
|
||||
alert("فایلی برای دانلود موجود نیست.");
|
||||
}
|
||||
}}
|
||||
>
|
||||
دانلود فایل
|
||||
</Button>
|
||||
</Grid>
|
||||
</>
|
||||
)}
|
||||
</Grid>
|
||||
</DialogContent>
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default DamageReportContent;
|
||||
@@ -0,0 +1,34 @@
|
||||
import useRequest from "@/lib/hooks/useRequest";
|
||||
import { useEffect, useState } from "react";
|
||||
import { GET_DAMAGE_ITEM_DETAILS } from "@/core/utils/routes";
|
||||
import DialogLoading from "@/core/components/DialogLoading";
|
||||
import DamageReportContent from "./DamageReportContent";
|
||||
|
||||
const DamageReportController = ({ rowId }) => {
|
||||
const requestServer = useRequest();
|
||||
const [damageReportDetails, setDamageReportDetails] = useState(null);
|
||||
const [damageItemDetailsLoading, setDamageItemDetailsLoading] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
setDamageItemDetailsLoading(true);
|
||||
requestServer(`${GET_DAMAGE_ITEM_DETAILS}/${rowId}`, "get")
|
||||
.then((response) => {
|
||||
setDamageReportDetails(response.data.data);
|
||||
setDamageItemDetailsLoading(false);
|
||||
})
|
||||
.catch((e) => {
|
||||
setDamageItemDetailsLoading(false);
|
||||
});
|
||||
}, [rowId]);
|
||||
|
||||
return (
|
||||
<>
|
||||
{damageItemDetailsLoading ? (
|
||||
<DialogLoading />
|
||||
) : (
|
||||
<DamageReportContent damageReportDetails={damageReportDetails} />
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default DamageReportController;
|
||||
@@ -0,0 +1,38 @@
|
||||
import React, { useState } from "react";
|
||||
import { Tooltip, IconButton, Dialog, DialogTitle, DialogActions, Button } from "@mui/material";
|
||||
import AssessmentIcon from "@mui/icons-material/Assessment";
|
||||
import DamageReportController from "./DamageReportController";
|
||||
const DamageReportDialog = ({ rowId }) => {
|
||||
const [openDamageReportDialog, setOpenDamageReportDialog] = useState(false);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Tooltip title="گزارش خسارت">
|
||||
<IconButton color="primary" onClick={() => setOpenDamageReportDialog(true)}>
|
||||
<AssessmentIcon />
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
<Dialog
|
||||
open={openDamageReportDialog}
|
||||
onClose={() => setOpenDamageReportDialog(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"}
|
||||
fullWidth
|
||||
>
|
||||
<DialogTitle>گزارش خسارت</DialogTitle>
|
||||
{openDamageReportDialog && <DamageReportController rowId={rowId} />}
|
||||
<DialogActions>
|
||||
<Button onClick={() => setOpenDamageReportDialog(false)} variant="outlined" color="secondary">
|
||||
بستن
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</Dialog>
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default DamageReportDialog;
|
||||
Reference in New Issue
Block a user