Compare commits
22 Commits
3a17fcb448
...
dev
| Author | SHA1 | Date | |
|---|---|---|---|
| 468ad9079e | |||
| 28f7d5c991 | |||
| 763d5b79d3 | |||
| f8e8e7f1f1 | |||
| 63aed5572c | |||
| 59ae3b76d9 | |||
| 93867ce7ee | |||
| 4210dbd7e2 | |||
| 3624b3bc70 | |||
| 4d00b0d492 | |||
| ed7b257ed8 | |||
| 03136f5f30 | |||
| 908a69ce0e | |||
| a818683247 | |||
| 95780cfbc9 | |||
| 071c3e159b | |||
| 90f51c6899 | |||
| e967329108 | |||
| f8d2da4f28 | |||
| bb1d5b3315 | |||
| d8d415a8f5 | |||
| f58c8e6c58 |
@@ -6,12 +6,12 @@ import { OrganizationsTypes } from "../partials/management/OrganizationsTypes";
|
||||
|
||||
export default function Organizations() {
|
||||
const tabItems = [
|
||||
{ label: "سازمان ها" },
|
||||
{
|
||||
label: "نهاد",
|
||||
page: "organizations",
|
||||
access: "Show-Organization-Type",
|
||||
},
|
||||
{ label: "سازمان ها" },
|
||||
];
|
||||
|
||||
const [selectedTab, setSelectedTab] = useState<number>(0);
|
||||
@@ -22,7 +22,7 @@ export default function Organizations() {
|
||||
return (
|
||||
<Grid container column className="gap-2">
|
||||
<Tabs tabs={tabItems} onChange={handleTabChange} size="medium" />
|
||||
{selectedTab === 0 ? <OrganizationsList /> : <OrganizationsTypes />}
|
||||
{selectedTab === 0 ? <OrganizationsTypes /> : <OrganizationsList />}
|
||||
</Grid>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,55 +1,411 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { useParams } from "@tanstack/react-router";
|
||||
import { Bars3Icon, CubeIcon, SparklesIcon } from "@heroicons/react/24/outline";
|
||||
import { useApiRequest } from "../utils/useApiRequest";
|
||||
import { useModalStore } from "../context/zustand-store/appStore";
|
||||
import { formatJustDate, formatJustTime } from "../utils/formatTime";
|
||||
import ShowMoreInfo from "../components/ShowMoreInfo/ShowMoreInfo";
|
||||
import { Grid } from "../components/Grid/Grid";
|
||||
import Typography from "../components/Typography/Typography";
|
||||
import Table from "../components/Table/Table";
|
||||
import { Popover } from "../components/PopOver/PopOver";
|
||||
import Button from "../components/Button/Button";
|
||||
import { Tooltip } from "../components/Tooltip/Tooltip";
|
||||
import { DistributeFromDistribution } from "../partials/tagging/DistributeFromDistribution";
|
||||
import { DocumentOperation } from "../components/DocumentOperation/DocumentOperation";
|
||||
import { DocumentDownloader } from "../components/DocumentDownloader/DocumentDownloader";
|
||||
import { BooleanQuestion } from "../components/BooleanQuestion/BooleanQuestion";
|
||||
import { useUserProfileStore } from "../context/zustand-store/userStore";
|
||||
import { DeleteButtonForPopOver } from "../components/PopOverButtons/PopOverButtons";
|
||||
|
||||
const speciesMap: Record<number, string> = {
|
||||
1: "گاو",
|
||||
2: "گاومیش",
|
||||
3: "شتر",
|
||||
4: "گوسفند",
|
||||
5: "بز",
|
||||
};
|
||||
|
||||
export default function TagDistribtutionDetails() {
|
||||
const { id } = useParams({ strict: false });
|
||||
const [tableData, setTableData] = useState([]);
|
||||
const { openModal } = useModalStore();
|
||||
const [childTableInfo, setChildTableInfo] = useState({
|
||||
page: 1,
|
||||
page_size: 10,
|
||||
});
|
||||
const [childTableData, setChildTableData] = useState([]);
|
||||
|
||||
const { data } = useApiRequest({
|
||||
const { data, refetch: refetchData } = useApiRequest({
|
||||
api: `/tag/web/api/v1/tag_distribution_batch/${id}/`,
|
||||
method: "get",
|
||||
queryKey: ["tagBatchInnerDashboard", id],
|
||||
enabled: !!id,
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (data?.distributions) {
|
||||
const rows = data.distributions.map((item: any, index: number) => [
|
||||
index + 1,
|
||||
item?.dist_identity,
|
||||
item?.batch_identity,
|
||||
item?.distribution_type === "batch" ? "توزیع گروهی" : "توزیع تصادفی",
|
||||
item?.species_code,
|
||||
item?.total_tag_count,
|
||||
item?.distributed_number,
|
||||
item?.remaining_number,
|
||||
`از ${item?.serial_from} تا ${item?.serial_to}`,
|
||||
]);
|
||||
setTableData(rows);
|
||||
const { data: childData, refetch: refetchChildList } = useApiRequest({
|
||||
api: `/tag/web/api/v1/tag_distribution_batch/${id}/child_list/`,
|
||||
method: "get",
|
||||
queryKey: ["tagDistributionChildList", id, childTableInfo],
|
||||
params: {
|
||||
...childTableInfo,
|
||||
},
|
||||
enabled: !!id,
|
||||
});
|
||||
|
||||
const { profile } = useUserProfileStore();
|
||||
|
||||
const showAssignDocColumn =
|
||||
childData?.results?.some(
|
||||
(item: any) =>
|
||||
profile?.role?.type?.key === "ADM" ||
|
||||
profile?.organization?.id === item?.assigned_org?.id,
|
||||
) ?? false;
|
||||
|
||||
const AbleToSeeAssignDoc = (item: any) => {
|
||||
if (
|
||||
profile?.role?.type?.key === "ADM" ||
|
||||
profile?.organization?.id === item?.assigned_org?.id
|
||||
) {
|
||||
return (
|
||||
<DocumentOperation
|
||||
key={item?.id}
|
||||
downloadLink={`/tag/web/api/v1/tag_distribution_batch/${item?.id}/distribution_pdf_view/`}
|
||||
payloadKey="dist_exit_document"
|
||||
validFiles={["pdf"]}
|
||||
page="tag_distribution"
|
||||
access="Upload-Assign-Document"
|
||||
uploadLink={`/tag/web/api/v1/tag_distribution_batch/${item?.id}/assign_document/`}
|
||||
onUploadSuccess={handleUpdate}
|
||||
/>
|
||||
);
|
||||
} else {
|
||||
return "-";
|
||||
}
|
||||
}, [data]);
|
||||
};
|
||||
|
||||
const handleUpdate = () => {
|
||||
refetchData();
|
||||
refetchChildList();
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (childData?.results) {
|
||||
const formattedData = childData.results.map(
|
||||
(item: any, index: number) => {
|
||||
const dist = item?.distributions;
|
||||
|
||||
return [
|
||||
childTableInfo.page === 1
|
||||
? index + 1
|
||||
: index +
|
||||
childTableInfo.page_size * (childTableInfo.page - 1) +
|
||||
1,
|
||||
item?.dist_batch_identity ?? "-",
|
||||
`${formatJustDate(item?.create_date) ?? "-"} (${
|
||||
formatJustDate(item?.create_date)
|
||||
? (formatJustTime(item?.create_date) ?? "-")
|
||||
: "-"
|
||||
})`,
|
||||
item?.assigner_org?.name ?? "-",
|
||||
item?.assigned_org?.name ?? "-",
|
||||
item?.total_tag_count?.toLocaleString() ?? "-",
|
||||
item?.total_distributed_tag_count?.toLocaleString() ?? "-",
|
||||
item?.remaining_tag_count?.toLocaleString() ?? "-",
|
||||
item?.distribution_type === "batch"
|
||||
? "توزیع گروهی"
|
||||
: "توزیع تصادفی",
|
||||
<ShowMoreInfo key={item?.id} title="جزئیات توزیع">
|
||||
<Grid container column className="gap-4 w-full">
|
||||
{dist?.map((opt: any, idx: number) => (
|
||||
<Grid
|
||||
key={idx}
|
||||
container
|
||||
column
|
||||
className="gap-3 w-full rounded-xl border border-gray-200 dark:border-gray-700 p-4"
|
||||
>
|
||||
<Grid container className="gap-2 items-center">
|
||||
<SparklesIcon className="w-5 h-5 text-gray-500 dark:text-gray-300" />
|
||||
<Typography variant="body2" className="font-medium">
|
||||
گونه:
|
||||
</Typography>
|
||||
<Typography
|
||||
variant="body2"
|
||||
className="text-gray-700 dark:text-gray-300"
|
||||
>
|
||||
{speciesMap[opt?.species_code] ?? "-"}
|
||||
</Typography>
|
||||
</Grid>
|
||||
|
||||
{item?.distribution_type === "batch" &&
|
||||
opt?.serial_from != null && (
|
||||
<Grid container className="gap-2 items-center">
|
||||
<Bars3Icon className="w-5 h-5 text-gray-500 dark:text-gray-300" />
|
||||
<Typography variant="body2" className="font-medium">
|
||||
بازه سریال:
|
||||
</Typography>
|
||||
<Typography
|
||||
variant="body2"
|
||||
className="text-gray-600 dark:text-gray-400"
|
||||
>
|
||||
از {opt?.serial_from ?? "-"} تا{" "}
|
||||
{opt?.serial_to ?? "-"}
|
||||
</Typography>
|
||||
</Grid>
|
||||
)}
|
||||
|
||||
<Grid container className="gap-2 items-center">
|
||||
<CubeIcon className="w-5 h-5 text-gray-500 dark:text-gray-300" />
|
||||
<Typography variant="body2" className="font-medium">
|
||||
تعداد پلاک:
|
||||
</Typography>
|
||||
<Typography
|
||||
variant="body2"
|
||||
className="text-gray-700 dark:text-gray-300"
|
||||
>
|
||||
{opt?.total_tag_count?.toLocaleString() ?? "-"}
|
||||
</Typography>
|
||||
</Grid>
|
||||
<Grid container className="gap-2 items-center">
|
||||
<CubeIcon className="w-5 h-5 text-gray-500 dark:text-gray-300" />
|
||||
<Typography variant="body2" className="font-medium">
|
||||
پلاک های توزیع شده:
|
||||
</Typography>
|
||||
<Typography
|
||||
variant="body2"
|
||||
className="text-gray-700 dark:text-gray-300"
|
||||
>
|
||||
{opt?.distributed_number?.toLocaleString() ?? "-"}
|
||||
</Typography>
|
||||
</Grid>
|
||||
<Grid container className="gap-2 items-center">
|
||||
<CubeIcon className="w-5 h-5 text-gray-500 dark:text-gray-300" />
|
||||
<Typography variant="body2" className="font-medium">
|
||||
پلاک های باقیمانده:
|
||||
</Typography>
|
||||
<Typography
|
||||
variant="body2"
|
||||
className="text-gray-700 dark:text-gray-300"
|
||||
>
|
||||
{opt?.remaining_number?.toLocaleString() ?? "-"}
|
||||
</Typography>
|
||||
</Grid>
|
||||
</Grid>
|
||||
))}
|
||||
</Grid>
|
||||
</ShowMoreInfo>,
|
||||
...(showAssignDocColumn ? [AbleToSeeAssignDoc(item)] : []),
|
||||
<DocumentDownloader
|
||||
key={`doc-${item?.id}`}
|
||||
link={item?.warehouse_exit_doc}
|
||||
title="دانلود"
|
||||
/>,
|
||||
item?.exit_doc_status ? (
|
||||
"تایید شده"
|
||||
) : (
|
||||
<Button
|
||||
key={`btn-${item?.id}`}
|
||||
page="tag_distribution"
|
||||
access="Accept-Assign-Document"
|
||||
size="small"
|
||||
disabled={item?.exit_doc_status}
|
||||
onClick={() => {
|
||||
openModal({
|
||||
title: "تایید سند خروج",
|
||||
content: (
|
||||
<BooleanQuestion
|
||||
api={`/tag/web/api/v1/tag_distribution_batch/${item?.id}/accept_exit_doc/`}
|
||||
method="post"
|
||||
getData={handleUpdate}
|
||||
title="آیا از تایید سند خروج مطمئنید؟"
|
||||
/>
|
||||
),
|
||||
});
|
||||
}}
|
||||
>
|
||||
تایید سند خروج
|
||||
</Button>
|
||||
),
|
||||
<Popover key={`popover-${item?.id}`}>
|
||||
<Tooltip title="ویرایش توزیع" position="right">
|
||||
<Button
|
||||
variant="edit"
|
||||
page="tag_distribution"
|
||||
access="Submit-Tag-Distribution"
|
||||
onClick={() => {
|
||||
openModal({
|
||||
title: "ویرایش توزیع",
|
||||
content: (
|
||||
<DistributeFromDistribution
|
||||
getData={handleUpdate}
|
||||
item={item}
|
||||
isEdit
|
||||
parentDistributions={data?.distributions}
|
||||
/>
|
||||
),
|
||||
});
|
||||
}}
|
||||
/>
|
||||
</Tooltip>
|
||||
<DeleteButtonForPopOver
|
||||
page="tag_distribution"
|
||||
access="Delete-Tag-Distribution"
|
||||
api={`/tag/web/api/v1/tag_distribution_batch/${item?.id}/`}
|
||||
getData={handleUpdate}
|
||||
/>
|
||||
</Popover>,
|
||||
];
|
||||
},
|
||||
);
|
||||
setChildTableData(formattedData);
|
||||
} else {
|
||||
setChildTableData([]);
|
||||
}
|
||||
}, [childData, childTableInfo]);
|
||||
|
||||
const dist = data?.distributions;
|
||||
|
||||
return (
|
||||
<Grid container column className="gap-4">
|
||||
<Grid container column className="gap-4 mt-2">
|
||||
<Grid isDashboard>
|
||||
<Table
|
||||
title="جزئیات توزیع پلاک"
|
||||
isDashboard
|
||||
title="مشخصات توزیع پلاک"
|
||||
noSearch
|
||||
noPagination
|
||||
columns={[
|
||||
"شناسه توزیع",
|
||||
"تاریخ ثبت",
|
||||
"توزیع کننده",
|
||||
"دریافت کننده",
|
||||
"تعداد کل پلاک",
|
||||
"پلاک های توزیع شده",
|
||||
"پلاک های باقیمانده",
|
||||
"نوع توزیع",
|
||||
"جزئیات توزیع",
|
||||
]}
|
||||
rows={[
|
||||
[
|
||||
data?.dist_batch_identity ?? "-",
|
||||
`${formatJustDate(data?.create_date) ?? "-"} (${
|
||||
formatJustDate(data?.create_date)
|
||||
? (formatJustTime(data?.create_date) ?? "-")
|
||||
: "-"
|
||||
})`,
|
||||
data?.assigner_org?.name ?? "-",
|
||||
data?.assigned_org?.name ?? "-",
|
||||
data?.total_tag_count?.toLocaleString() ?? "-",
|
||||
data?.total_distributed_tag_count?.toLocaleString() ?? "-",
|
||||
data?.remaining_tag_count?.toLocaleString() ?? "-",
|
||||
data?.distribution_type === "batch"
|
||||
? "توزیع گروهی"
|
||||
: "توزیع تصادفی",
|
||||
<ShowMoreInfo key={data?.id} title="جزئیات توزیع">
|
||||
<Grid container column className="gap-4 w-full">
|
||||
{dist?.map((opt: any, index: number) => (
|
||||
<Grid
|
||||
key={index}
|
||||
container
|
||||
column
|
||||
className="gap-3 w-full rounded-xl border border-gray-200 dark:border-gray-700 p-4"
|
||||
>
|
||||
<Grid container className="gap-2 items-center">
|
||||
<SparklesIcon className="w-5 h-5 text-gray-500 dark:text-gray-300" />
|
||||
<Typography variant="body2" className="font-medium">
|
||||
گونه:
|
||||
</Typography>
|
||||
<Typography
|
||||
variant="body2"
|
||||
className="text-gray-700 dark:text-gray-300"
|
||||
>
|
||||
{speciesMap[opt?.species_code] ?? "-"}
|
||||
</Typography>
|
||||
</Grid>
|
||||
|
||||
{data?.distribution_type === "batch" &&
|
||||
opt?.serial_from != null && (
|
||||
<Grid container className="gap-2 items-center">
|
||||
<Bars3Icon className="w-5 h-5 text-gray-500 dark:text-gray-300" />
|
||||
<Typography variant="body2" className="font-medium">
|
||||
بازه سریال:
|
||||
</Typography>
|
||||
<Typography
|
||||
variant="body2"
|
||||
className="text-gray-600 dark:text-gray-400"
|
||||
>
|
||||
از {opt?.serial_from ?? "-"} تا{" "}
|
||||
{opt?.serial_to ?? "-"}
|
||||
</Typography>
|
||||
</Grid>
|
||||
)}
|
||||
|
||||
<Grid container className="gap-2 items-center">
|
||||
<CubeIcon className="w-5 h-5 text-gray-500 dark:text-gray-300" />
|
||||
<Typography variant="body2" className="font-medium">
|
||||
تعداد پلاک:
|
||||
</Typography>
|
||||
<Typography
|
||||
variant="body2"
|
||||
className="text-gray-700 dark:text-gray-300"
|
||||
>
|
||||
{opt?.total_tag_count?.toLocaleString() ?? "-"}
|
||||
</Typography>
|
||||
</Grid>
|
||||
<Grid container className="gap-2 items-center">
|
||||
<CubeIcon className="w-5 h-5 text-gray-500 dark:text-gray-300" />
|
||||
<Typography variant="body2" className="font-medium">
|
||||
پلاک های توزیع شده:
|
||||
</Typography>
|
||||
<Typography
|
||||
variant="body2"
|
||||
className="text-gray-700 dark:text-gray-300"
|
||||
>
|
||||
{opt?.distributed_number?.toLocaleString() ?? "-"}
|
||||
</Typography>
|
||||
</Grid>
|
||||
<Grid container className="gap-2 items-center">
|
||||
<CubeIcon className="w-5 h-5 text-gray-500 dark:text-gray-300" />
|
||||
<Typography variant="body2" className="font-medium">
|
||||
پلاک های باقیمانده:
|
||||
</Typography>
|
||||
<Typography
|
||||
variant="body2"
|
||||
className="text-gray-700 dark:text-gray-300"
|
||||
>
|
||||
{opt?.remaining_number?.toLocaleString() ?? "-"}
|
||||
</Typography>
|
||||
</Grid>
|
||||
</Grid>
|
||||
))}
|
||||
</Grid>
|
||||
</ShowMoreInfo>,
|
||||
],
|
||||
]}
|
||||
/>
|
||||
</Grid>
|
||||
|
||||
<Table
|
||||
className="mt-2"
|
||||
onChange={setChildTableInfo}
|
||||
count={childData?.count || 0}
|
||||
isPaginated
|
||||
title="توزیع های مجدد"
|
||||
columns={[
|
||||
"ردیف",
|
||||
"شناسه توزیع",
|
||||
"شناسه پلاک",
|
||||
"تاریخ ثبت",
|
||||
"توزیع کننده",
|
||||
"دریافت کننده",
|
||||
"تعداد کل پلاک",
|
||||
"پلاک های توزیع شده",
|
||||
"پلاک های باقیمانده",
|
||||
"نوع توزیع",
|
||||
"کد گونه",
|
||||
"تعداد کل پلاک ها",
|
||||
"تعداد توزیع شده",
|
||||
"تعداد باقیمانده",
|
||||
"بازه سریال",
|
||||
"جزئیات توزیع",
|
||||
...(showAssignDocColumn ? ["امضا سند خروج از انبار"] : []),
|
||||
"سند خروج از انبار",
|
||||
"تایید سند خروج",
|
||||
"عملیات",
|
||||
]}
|
||||
rows={tableData}
|
||||
rows={childTableData}
|
||||
/>
|
||||
</Grid>
|
||||
);
|
||||
|
||||
@@ -196,11 +196,11 @@ const AutoComplete: React.FC<AutoCompleteProps> = ({
|
||||
if (window.visualViewport) {
|
||||
window.visualViewport.addEventListener(
|
||||
"resize",
|
||||
handleVisualViewportResize
|
||||
handleVisualViewportResize,
|
||||
);
|
||||
window.visualViewport.addEventListener(
|
||||
"scroll",
|
||||
handleVisualViewportScroll
|
||||
handleVisualViewportScroll,
|
||||
);
|
||||
}
|
||||
const inputElement = inputRef.current;
|
||||
@@ -222,11 +222,11 @@ const AutoComplete: React.FC<AutoCompleteProps> = ({
|
||||
if (window.visualViewport) {
|
||||
window.visualViewport.removeEventListener(
|
||||
"resize",
|
||||
handleVisualViewportResize
|
||||
handleVisualViewportResize,
|
||||
);
|
||||
window.visualViewport.removeEventListener(
|
||||
"scroll",
|
||||
handleVisualViewportScroll
|
||||
handleVisualViewportScroll,
|
||||
);
|
||||
}
|
||||
const inputElement = inputRef.current;
|
||||
@@ -247,7 +247,7 @@ const AutoComplete: React.FC<AutoCompleteProps> = ({
|
||||
target.closest(".select-group") && !clickedInsideCurrent;
|
||||
|
||||
const clickedOnPortalDropdown = target.closest(
|
||||
`[data-autocomplete-portal="${uniqueId}"]`
|
||||
`[data-autocomplete-portal="${uniqueId}"]`,
|
||||
);
|
||||
|
||||
if (clickedOnAnotherAutocomplete) {
|
||||
@@ -318,7 +318,7 @@ const AutoComplete: React.FC<AutoCompleteProps> = ({
|
||||
const preventTouchMove = (e: TouchEvent) => {
|
||||
const target = e.target as HTMLElement;
|
||||
const dropdown = document.querySelector(
|
||||
`[data-autocomplete-portal="${uniqueId}"]`
|
||||
`[data-autocomplete-portal="${uniqueId}"]`,
|
||||
);
|
||||
|
||||
if (dropdown) {
|
||||
@@ -326,7 +326,7 @@ const AutoComplete: React.FC<AutoCompleteProps> = ({
|
||||
if (touch) {
|
||||
const elementAtPoint = document.elementFromPoint(
|
||||
touch.clientX,
|
||||
touch.clientY
|
||||
touch.clientY,
|
||||
);
|
||||
if (
|
||||
elementAtPoint &&
|
||||
@@ -375,12 +375,12 @@ const AutoComplete: React.FC<AutoCompleteProps> = ({
|
||||
setLocalInputValue(value);
|
||||
setIsTyping(true);
|
||||
const filtered = data.filter((item) =>
|
||||
item.value.toLowerCase().includes(value.toLowerCase())
|
||||
item.value.toLowerCase().includes(value.toLowerCase()),
|
||||
);
|
||||
setFilteredData(filtered);
|
||||
setShowOptions(true);
|
||||
},
|
||||
[data]
|
||||
[data],
|
||||
);
|
||||
|
||||
const handleChange = useCallback(
|
||||
@@ -390,7 +390,7 @@ const AutoComplete: React.FC<AutoCompleteProps> = ({
|
||||
|
||||
if (onChangeValue && newSelectedKeys.length > 0) {
|
||||
const selectedItem = data.find(
|
||||
(item) => item.key === newSelectedKeys[0]
|
||||
(item) => item.key === newSelectedKeys[0],
|
||||
);
|
||||
if (selectedItem) {
|
||||
onChangeValue({
|
||||
@@ -400,7 +400,7 @@ const AutoComplete: React.FC<AutoCompleteProps> = ({
|
||||
}
|
||||
}
|
||||
},
|
||||
[onChange, onChangeValue, data]
|
||||
[onChange, onChangeValue, data],
|
||||
);
|
||||
|
||||
const handleOptionClick = useCallback(
|
||||
@@ -430,7 +430,7 @@ const AutoComplete: React.FC<AutoCompleteProps> = ({
|
||||
setShowOptions(false);
|
||||
}
|
||||
},
|
||||
[multiselect, handleChange]
|
||||
[multiselect, handleChange],
|
||||
);
|
||||
|
||||
const handleInputClick = useCallback(() => {
|
||||
@@ -602,7 +602,7 @@ const AutoComplete: React.FC<AutoCompleteProps> = ({
|
||||
>
|
||||
{dropdownOptions}
|
||||
</motion.ul>,
|
||||
document.body
|
||||
document.body,
|
||||
);
|
||||
}, [
|
||||
showOptions,
|
||||
@@ -638,6 +638,7 @@ const AutoComplete: React.FC<AutoCompleteProps> = ({
|
||||
placeholder={title || "انتخاب کنید..."}
|
||||
/>
|
||||
<ChevronDownIcon
|
||||
onClick={handleInputClick}
|
||||
className={`absolute left-3 text-dark-400 dark:text-dark-100 transition-transform duration-200 ${
|
||||
showOptions ? "transform rotate-180" : ""
|
||||
} ${getSizeStyles(size).icon}`}
|
||||
|
||||
236
src/components/DocumentOperation/DocumentOperation.tsx
Normal file
236
src/components/DocumentOperation/DocumentOperation.tsx
Normal file
@@ -0,0 +1,236 @@
|
||||
import React, { useRef, useState, useEffect, ChangeEvent } from "react";
|
||||
import {
|
||||
ArrowDownTrayIcon,
|
||||
ArrowUpTrayIcon,
|
||||
CheckCircleIcon,
|
||||
} from "@heroicons/react/24/outline";
|
||||
import api from "../../utils/axios";
|
||||
import { useBackdropStore } from "../../context/zustand-store/appStore";
|
||||
import { useToast } from "../../hooks/useToast";
|
||||
import { useUserProfileStore } from "../../context/zustand-store/userStore";
|
||||
import { RolesContextMenu } from "../Button/RolesContextMenu";
|
||||
|
||||
interface DocumentOperationProps {
|
||||
downloadLink: string;
|
||||
uploadLink: string;
|
||||
validFiles?: string[];
|
||||
payloadKey: string;
|
||||
onUploadSuccess?: () => void;
|
||||
page?: string;
|
||||
access?: string;
|
||||
limitSize?: number;
|
||||
}
|
||||
|
||||
const buildAcceptString = (extensions: string[]): string => {
|
||||
const mimeTypes: string[] = [];
|
||||
|
||||
extensions.forEach((ext) => {
|
||||
const lower = ext.toLowerCase().replace(".", "");
|
||||
|
||||
if (lower === "img" || lower === "image") {
|
||||
mimeTypes.push("image/*");
|
||||
} else {
|
||||
mimeTypes.push(`.${lower}`);
|
||||
}
|
||||
});
|
||||
|
||||
return mimeTypes.join(",");
|
||||
};
|
||||
|
||||
export const DocumentOperation = ({
|
||||
downloadLink,
|
||||
uploadLink,
|
||||
validFiles = [],
|
||||
payloadKey,
|
||||
onUploadSuccess,
|
||||
page = "",
|
||||
access = "",
|
||||
limitSize,
|
||||
}: DocumentOperationProps) => {
|
||||
const { openBackdrop, closeBackdrop } = useBackdropStore();
|
||||
const showToast = useToast();
|
||||
const fileInputRef = useRef<HTMLInputElement>(null);
|
||||
const [uploadedFileName, setUploadedFileName] = useState<string>("");
|
||||
const { profile } = useUserProfileStore();
|
||||
const [contextMenu, setContextMenu] = useState<{
|
||||
x: number;
|
||||
y: number;
|
||||
} | null>(null);
|
||||
|
||||
const isAdmin = profile?.role?.type?.key === "ADM";
|
||||
|
||||
const ableToSee = () => {
|
||||
if (!access || !page) {
|
||||
return true;
|
||||
}
|
||||
const found = profile?.permissions?.find(
|
||||
(item: any) => item.page_name === page,
|
||||
);
|
||||
if (found && found.page_access.includes(access)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
const handleContextMenu = (e: React.MouseEvent<HTMLDivElement>) => {
|
||||
if (isAdmin && page && access) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
setContextMenu({
|
||||
x: e.clientX,
|
||||
y: e.clientY,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
const handleClick = () => {
|
||||
if (contextMenu) {
|
||||
setContextMenu(null);
|
||||
}
|
||||
};
|
||||
|
||||
if (contextMenu) {
|
||||
document.addEventListener("click", handleClick);
|
||||
}
|
||||
|
||||
return () => {
|
||||
document.removeEventListener("click", handleClick);
|
||||
};
|
||||
}, [contextMenu]);
|
||||
|
||||
const handleDownload = async () => {
|
||||
if (!downloadLink) return;
|
||||
|
||||
openBackdrop();
|
||||
try {
|
||||
const response = await api.get(downloadLink, {
|
||||
responseType: "blob",
|
||||
});
|
||||
|
||||
const contentDisposition = response.headers["content-disposition"];
|
||||
let fileName = "document";
|
||||
|
||||
if (contentDisposition) {
|
||||
const match = contentDisposition.match(
|
||||
/filename\*?=(?:UTF-8''|"?)([^";]+)/i,
|
||||
);
|
||||
if (match?.[1]) {
|
||||
fileName = decodeURIComponent(match[1].replace(/"/g, ""));
|
||||
}
|
||||
} else {
|
||||
const urlParts = downloadLink.split("/").filter(Boolean);
|
||||
const lastPart = urlParts[urlParts.length - 1];
|
||||
if (lastPart && lastPart.includes(".")) {
|
||||
fileName = lastPart;
|
||||
}
|
||||
}
|
||||
|
||||
const url = window.URL.createObjectURL(new Blob([response.data]));
|
||||
const link = document.createElement("a");
|
||||
link.href = url;
|
||||
link.setAttribute("download", fileName);
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
window.URL.revokeObjectURL(url);
|
||||
|
||||
showToast("فایل با موفقیت دانلود شد", "success");
|
||||
} catch {
|
||||
showToast("خطا در دانلود فایل", "error");
|
||||
} finally {
|
||||
closeBackdrop();
|
||||
}
|
||||
};
|
||||
|
||||
const handleUploadClick = () => {
|
||||
fileInputRef.current?.click();
|
||||
};
|
||||
|
||||
const handleFileChange = async (e: ChangeEvent<HTMLInputElement>) => {
|
||||
const file = e.target.files?.[0];
|
||||
if (!file) return;
|
||||
|
||||
if (fileInputRef.current) {
|
||||
fileInputRef.current.value = "";
|
||||
}
|
||||
|
||||
if (limitSize && file.size > limitSize * 1024 * 1024) {
|
||||
showToast(`حداکثر حجم فایل ${limitSize} مگابایت است`, "error");
|
||||
return;
|
||||
}
|
||||
|
||||
openBackdrop();
|
||||
try {
|
||||
const formData = new FormData();
|
||||
formData.append(payloadKey, file);
|
||||
|
||||
await api.post(uploadLink, formData, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data",
|
||||
},
|
||||
});
|
||||
|
||||
setUploadedFileName(file.name);
|
||||
showToast("فایل با موفقیت آپلود شد", "success");
|
||||
onUploadSuccess?.();
|
||||
} catch {
|
||||
showToast("خطا در آپلود فایل", "error");
|
||||
} finally {
|
||||
closeBackdrop();
|
||||
}
|
||||
};
|
||||
|
||||
const acceptString =
|
||||
validFiles.length > 0 ? buildAcceptString(validFiles) : undefined;
|
||||
|
||||
return (
|
||||
<>
|
||||
<div
|
||||
className="inline-flex items-center"
|
||||
onContextMenu={handleContextMenu}
|
||||
>
|
||||
<input
|
||||
type="file"
|
||||
ref={fileInputRef}
|
||||
onChange={handleFileChange}
|
||||
className="hidden"
|
||||
accept={acceptString}
|
||||
/>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
onClick={handleDownload}
|
||||
disabled={!downloadLink || !ableToSee()}
|
||||
className="flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-r-lg border border-l-0 border-primary-300 dark:border-dark-400 bg-primary-50 dark:bg-dark-600 text-primary-700 dark:text-primary-200 hover:bg-primary-100 dark:hover:bg-dark-500 transition-colors duration-200 cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
>
|
||||
<ArrowDownTrayIcon className="w-4 h-4" />
|
||||
<span>دانلود</span>
|
||||
</button>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
onClick={handleUploadClick}
|
||||
disabled={!uploadLink || !ableToSee()}
|
||||
className="flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-l-lg border border-primary-300 dark:border-dark-400 bg-primary-600 dark:bg-primary-700 text-white hover:bg-primary-500 dark:hover:bg-primary-800 transition-colors duration-200 cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
>
|
||||
{uploadedFileName ? (
|
||||
<CheckCircleIcon className="w-4 h-4 text-green-300" />
|
||||
) : (
|
||||
<ArrowUpTrayIcon className="w-4 h-4" />
|
||||
)}
|
||||
<span>آپلود</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{contextMenu && page && access && (
|
||||
<RolesContextMenu
|
||||
page={page}
|
||||
access={access}
|
||||
position={contextMenu}
|
||||
onClose={() => setContextMenu(null)}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
@@ -7,6 +7,7 @@ import { getNestedValue } from "../../utils/getNestedValue";
|
||||
type FormEnterLocationsProps = {
|
||||
title: string;
|
||||
api: string;
|
||||
size?: "small" | "medium" | "large";
|
||||
error?: boolean;
|
||||
errorMessage?: any;
|
||||
multiple?: boolean;
|
||||
@@ -15,6 +16,7 @@ type FormEnterLocationsProps = {
|
||||
keyField?: string;
|
||||
secondaryKey?: string | string[];
|
||||
tertiaryKey?: string | string[];
|
||||
quaternaryKey?: string | string[];
|
||||
valueField?: string | string[];
|
||||
valueField2?: string | string[];
|
||||
valueField3?: string | string[];
|
||||
@@ -31,6 +33,7 @@ type FormEnterLocationsProps = {
|
||||
export const FormApiBasedAutoComplete = ({
|
||||
title,
|
||||
api,
|
||||
size,
|
||||
error,
|
||||
errorMessage,
|
||||
onChange,
|
||||
@@ -38,6 +41,7 @@ export const FormApiBasedAutoComplete = ({
|
||||
keyField = "id",
|
||||
secondaryKey,
|
||||
tertiaryKey,
|
||||
quaternaryKey,
|
||||
valueField = "name",
|
||||
valueField2,
|
||||
valueField3,
|
||||
@@ -94,7 +98,7 @@ export const FormApiBasedAutoComplete = ({
|
||||
if (filterAddress && filterValue) {
|
||||
data = apiData.results?.filter(
|
||||
(item: any) =>
|
||||
!filterValue.includes(getNestedValue(item, filterAddress))
|
||||
!filterValue.includes(getNestedValue(item, filterAddress)),
|
||||
);
|
||||
} else {
|
||||
data = apiData.results;
|
||||
@@ -111,6 +115,11 @@ export const FormApiBasedAutoComplete = ({
|
||||
? option[tertiaryKey]
|
||||
: getNestedValue(option, tertiaryKey)
|
||||
: undefined,
|
||||
quaternaryKey: quaternaryKey
|
||||
? typeof quaternaryKey === "string"
|
||||
? option[quaternaryKey]
|
||||
: getNestedValue(option, quaternaryKey)
|
||||
: undefined,
|
||||
value: valueTemplate
|
||||
? valueTemplate
|
||||
.replace(
|
||||
@@ -121,8 +130,8 @@ export const FormApiBasedAutoComplete = ({
|
||||
: typeof valueField === "string"
|
||||
? option[valueField]
|
||||
: getNestedValue(option, valueField),
|
||||
"v1"
|
||||
)
|
||||
"v1",
|
||||
),
|
||||
)
|
||||
.replace(
|
||||
/v2/g,
|
||||
@@ -132,8 +141,8 @@ export const FormApiBasedAutoComplete = ({
|
||||
? option[valueField2]
|
||||
: getNestedValue(option, valueField2)
|
||||
: "",
|
||||
"v2"
|
||||
)
|
||||
"v2",
|
||||
),
|
||||
)
|
||||
.replace(
|
||||
/v3/g,
|
||||
@@ -143,8 +152,8 @@ export const FormApiBasedAutoComplete = ({
|
||||
? option[valueField3]
|
||||
: getNestedValue(option, valueField3)
|
||||
: "",
|
||||
"v3"
|
||||
)
|
||||
"v3",
|
||||
),
|
||||
)
|
||||
: `${
|
||||
valueField === "page"
|
||||
@@ -208,7 +217,7 @@ export const FormApiBasedAutoComplete = ({
|
||||
setData(finalData);
|
||||
|
||||
const actualDataItems = finalData.filter(
|
||||
(item: any) => !item.isGroupHeader && !item.disabled
|
||||
(item: any) => !item.isGroupHeader && !item.disabled,
|
||||
);
|
||||
|
||||
if (defaultKey !== undefined && defaultKey !== null) {
|
||||
@@ -218,10 +227,10 @@ export const FormApiBasedAutoComplete = ({
|
||||
setSelectedKeys([]);
|
||||
} else {
|
||||
const defaultIds = defaultKey.map((item: any) =>
|
||||
typeof item === "object" ? item[keyField] : item
|
||||
typeof item === "object" ? item[keyField] : item,
|
||||
);
|
||||
const defaultItems = actualDataItems.filter((item: any) =>
|
||||
defaultIds.includes(item.key)
|
||||
defaultIds.includes(item.key),
|
||||
);
|
||||
setSelectedKeys(defaultItems.map((item: any) => item.key));
|
||||
if (onChange) {
|
||||
@@ -237,12 +246,17 @@ export const FormApiBasedAutoComplete = ({
|
||||
key3: item?.tertiaryKey,
|
||||
}
|
||||
: {}),
|
||||
...(quaternaryKey
|
||||
? {
|
||||
key4: item?.quaternaryKey,
|
||||
}
|
||||
: {}),
|
||||
};
|
||||
})
|
||||
}),
|
||||
);
|
||||
if (onChangeValue) {
|
||||
onChangeValue(
|
||||
defaultItems.map((item: any) => item.value.trim())
|
||||
defaultItems.map((item: any) => item.value.trim()),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
@@ -258,7 +272,7 @@ export const FormApiBasedAutoComplete = ({
|
||||
? defaultKey[keyField]
|
||||
: defaultKey;
|
||||
const defaultItem = actualDataItems.find(
|
||||
(item: any) => item.key === keyToFind
|
||||
(item: any) => item.key === keyToFind,
|
||||
);
|
||||
if (defaultItem) {
|
||||
setSelectedKeys([keyToFind]);
|
||||
@@ -268,6 +282,9 @@ export const FormApiBasedAutoComplete = ({
|
||||
key1: defaultItem.key,
|
||||
key2: defaultItem.secondaryKey,
|
||||
...(tertiaryKey ? { key3: defaultItem.tertiaryKey } : {}),
|
||||
...(quaternaryKey
|
||||
? { key4: defaultItem.quaternaryKey }
|
||||
: {}),
|
||||
});
|
||||
} else {
|
||||
onChange(keyToFind);
|
||||
@@ -278,6 +295,7 @@ export const FormApiBasedAutoComplete = ({
|
||||
key1: defaultItem.key,
|
||||
key2: defaultItem.secondaryKey,
|
||||
...(tertiaryKey ? { key3: defaultItem.tertiaryKey } : {}),
|
||||
...(quaternaryKey ? { key4: defaultItem.quaternaryKey } : {}),
|
||||
value: defaultItem.value.trim(),
|
||||
});
|
||||
}
|
||||
@@ -296,18 +314,18 @@ export const FormApiBasedAutoComplete = ({
|
||||
|
||||
const groupItemKeys = groupItems.map((item: any) => item.key);
|
||||
const allGroupItemsSelected = groupItemKeys.every((key) =>
|
||||
selectedKeys.includes(key)
|
||||
selectedKeys.includes(key),
|
||||
);
|
||||
|
||||
let newSelectedKeys: (string | number)[];
|
||||
|
||||
if (allGroupItemsSelected) {
|
||||
newSelectedKeys = selectedKeys.filter(
|
||||
(key) => !groupItemKeys.includes(key)
|
||||
(key) => !groupItemKeys.includes(key),
|
||||
);
|
||||
} else {
|
||||
const newKeys = groupItemKeys.filter(
|
||||
(key) => !selectedKeys.includes(key)
|
||||
(key) => !selectedKeys.includes(key),
|
||||
);
|
||||
newSelectedKeys = [...selectedKeys, ...newKeys];
|
||||
}
|
||||
@@ -320,7 +338,7 @@ export const FormApiBasedAutoComplete = ({
|
||||
(item: any) =>
|
||||
newSelectedKeys.includes(item.key) &&
|
||||
!item.isGroupHeader &&
|
||||
!item.disabled
|
||||
!item.disabled,
|
||||
);
|
||||
|
||||
if (secondaryKey) {
|
||||
@@ -329,7 +347,8 @@ export const FormApiBasedAutoComplete = ({
|
||||
key1: item.key,
|
||||
key2: item.secondaryKey,
|
||||
...(tertiaryKey ? { key3: item.tertiaryKey } : {}),
|
||||
}))
|
||||
...(quaternaryKey ? { key4: item.quaternaryKey } : {}),
|
||||
})),
|
||||
);
|
||||
if (onChangeValue) {
|
||||
onChangeValue(selectedItems.map((item: any) => item.value.trim()));
|
||||
@@ -344,6 +363,7 @@ export const FormApiBasedAutoComplete = ({
|
||||
<AutoComplete
|
||||
multiselect={multiple}
|
||||
selectField={selectField}
|
||||
size={size}
|
||||
data={data}
|
||||
selectedKeys={selectedKeys}
|
||||
onChange={(newSelectedKeys) => {
|
||||
@@ -357,7 +377,7 @@ export const FormApiBasedAutoComplete = ({
|
||||
(item: any) =>
|
||||
newSelectedKeys.includes(item.key) &&
|
||||
!item.isGroupHeader &&
|
||||
!item.disabled
|
||||
!item.disabled,
|
||||
);
|
||||
|
||||
onChange(
|
||||
@@ -365,16 +385,17 @@ export const FormApiBasedAutoComplete = ({
|
||||
key1: item.key,
|
||||
key2: item.secondaryKey,
|
||||
...(tertiaryKey ? { key3: item.tertiaryKey } : {}),
|
||||
}))
|
||||
...(quaternaryKey ? { key4: item.quaternaryKey } : {}),
|
||||
})),
|
||||
);
|
||||
if (onChangeValue) {
|
||||
onChangeValue(
|
||||
selectedItems.map((item: any) => item.value.trim())
|
||||
selectedItems.map((item: any) => item.value.trim()),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
const validKeys = newSelectedKeys.filter(
|
||||
(key) => !String(key).startsWith("__group__")
|
||||
(key) => !String(key).startsWith("__group__"),
|
||||
);
|
||||
onChange(validKeys);
|
||||
}
|
||||
@@ -384,7 +405,7 @@ export const FormApiBasedAutoComplete = ({
|
||||
(item: any) =>
|
||||
item.key === newSelectedKeys[0] &&
|
||||
!item.isGroupHeader &&
|
||||
!item.disabled
|
||||
!item.disabled,
|
||||
);
|
||||
if (onChangeValue) {
|
||||
onChangeValue({
|
||||
@@ -394,6 +415,9 @@ export const FormApiBasedAutoComplete = ({
|
||||
...(tertiaryKey
|
||||
? { key3: selectedItem?.tertiaryKey ?? "" }
|
||||
: {}),
|
||||
...(quaternaryKey
|
||||
? { key4: selectedItem?.quaternaryKey ?? "" }
|
||||
: {}),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -402,6 +426,9 @@ export const FormApiBasedAutoComplete = ({
|
||||
key1: selectedItem.key,
|
||||
key2: selectedItem.secondaryKey,
|
||||
...(tertiaryKey ? { key3: selectedItem.tertiaryKey } : {}),
|
||||
...(quaternaryKey
|
||||
? { key4: selectedItem.quaternaryKey }
|
||||
: {}),
|
||||
});
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -8,7 +8,6 @@ import {
|
||||
zValidateNumber,
|
||||
zValidateNumberOptional,
|
||||
zValidateString,
|
||||
zValidateStringOptional,
|
||||
} from "../../data/getFormTypeErrors";
|
||||
import { z } from "zod";
|
||||
import { useApiMutation } from "../../utils/useApiRequest";
|
||||
@@ -21,16 +20,23 @@ import { getToastResponse } from "../../data/getToastResponse";
|
||||
import { useUserProfileStore } from "../../context/zustand-store/userStore";
|
||||
import { useState } from "react";
|
||||
import Checkbox from "../../components/CheckBox/CheckBox";
|
||||
import {
|
||||
ArrowPathIcon,
|
||||
CheckBadgeIcon,
|
||||
PlusIcon,
|
||||
TrashIcon,
|
||||
} from "@heroicons/react/24/outline";
|
||||
import axios from "axios";
|
||||
|
||||
const schema = z.object({
|
||||
name: zValidateString("نام سازمان"),
|
||||
national_unique_id: zValidateString("شناسه کشوری"),
|
||||
address: zValidateStringOptional("آدرس"),
|
||||
field_of_activity: zValidateAutoComplete("حوزه فعالیت"),
|
||||
province: zValidateNumber("استان"),
|
||||
city: zValidateNumber("شهر"),
|
||||
organization: zValidateNumberOptional("سازمان"),
|
||||
organizationType: zValidateNumber("سازمان"),
|
||||
unique_unit_identity: zValidateNumberOptional("شناسه یکتا واحد"),
|
||||
is_repeatable: z.boolean(),
|
||||
free_visibility_by_scope: z.boolean(),
|
||||
});
|
||||
@@ -75,8 +81,8 @@ export const AddOrganization = ({ getData, item }: AddPageProps) => {
|
||||
resolver: zodResolver(schema),
|
||||
defaultValues: {
|
||||
name: item?.name || "",
|
||||
address: item?.address || "",
|
||||
national_unique_id: item?.national_unique_id || "",
|
||||
unique_unit_identity: item?.unique_unit_identity || "",
|
||||
free_visibility_by_scope: item?.free_visibility_by_scope || false,
|
||||
field_of_activity:
|
||||
item && item?.field_of_activity !== "EM"
|
||||
@@ -95,9 +101,78 @@ export const AddOrganization = ({ getData, item }: AddPageProps) => {
|
||||
city: string | any;
|
||||
}>({ province: "", city: "" });
|
||||
|
||||
const [addresses, setAddresses] = useState<
|
||||
{ postal_code: string; address: string }[]
|
||||
>(
|
||||
item?.addresses?.length
|
||||
? item.addresses.map((a: any) => ({
|
||||
postal_code: a.postal_code || "",
|
||||
address: a.address || "",
|
||||
}))
|
||||
: [{ postal_code: "", address: "" }],
|
||||
);
|
||||
|
||||
const [isInquiryRequired, setIsInquiryRequired] = useState(false);
|
||||
const [inquiryPassed, setInquiryPassed] = useState(false);
|
||||
const [inquiryLoading, setInquiryLoading] = useState(false);
|
||||
|
||||
const handleAddAddress = () => {
|
||||
setAddresses((prev) => [...prev, { postal_code: "", address: "" }]);
|
||||
};
|
||||
|
||||
const handleRemoveAddress = (index: number) => {
|
||||
setAddresses((prev) => prev.filter((_, i) => i !== index));
|
||||
};
|
||||
|
||||
const handleAddressChange = (
|
||||
index: number,
|
||||
field: "postal_code" | "address",
|
||||
value: string,
|
||||
) => {
|
||||
setAddresses((prev) =>
|
||||
prev.map((item, i) => (i === index ? { ...item, [field]: value } : item)),
|
||||
);
|
||||
};
|
||||
|
||||
const handleInquiry = async () => {
|
||||
const code = getValues("unique_unit_identity");
|
||||
if (!code) {
|
||||
showToast("لطفاً شناسه یکتا واحد را وارد کنید!", "error");
|
||||
return;
|
||||
}
|
||||
setInquiryLoading(true);
|
||||
try {
|
||||
await axios.get(
|
||||
`https://rsibackend.rasadyar.com/app/has_code_in_db/?code=${code}`,
|
||||
);
|
||||
setInquiryPassed(true);
|
||||
showToast("استعلام با موفقیت انجام شد!", "success");
|
||||
} catch (error: any) {
|
||||
if (error?.response?.status === 404) {
|
||||
setInquiryPassed(false);
|
||||
showToast("شناسه موجود نیست!", "error");
|
||||
} else {
|
||||
showToast("خطا در استعلام!", "error");
|
||||
}
|
||||
} finally {
|
||||
setInquiryLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
const onSubmit = async (data: FormValues) => {
|
||||
if (isInquiryRequired && !data.unique_unit_identity) {
|
||||
showToast("شناسه یکتا واحد الزامی است!", "error");
|
||||
return;
|
||||
}
|
||||
if (isInquiryRequired && !inquiryPassed) {
|
||||
showToast("لطفاً ابتدا استعلام شناسه یکتا واحد را انجام دهید!", "error");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await mutation.mutateAsync({
|
||||
addresses: addresses.filter(
|
||||
(a) => a.postal_code.trim() || a.address.trim(),
|
||||
),
|
||||
organization: {
|
||||
name: `${data?.name} ${
|
||||
data?.is_repeatable
|
||||
@@ -111,6 +186,9 @@ export const AddOrganization = ({ getData, item }: AddPageProps) => {
|
||||
type: data.organizationType,
|
||||
}),
|
||||
national_unique_id: data?.national_unique_id,
|
||||
...(data?.unique_unit_identity && {
|
||||
unique_unit_identity: data.unique_unit_identity,
|
||||
}),
|
||||
province: data?.province,
|
||||
city: data?.city,
|
||||
...(data.organization && {
|
||||
@@ -118,7 +196,6 @@ export const AddOrganization = ({ getData, item }: AddPageProps) => {
|
||||
}),
|
||||
field_of_activity: data.field_of_activity[0],
|
||||
free_visibility_by_scope: data.free_visibility_by_scope,
|
||||
address: data.address,
|
||||
},
|
||||
});
|
||||
showToast(getToastResponse(item, "سازمان"), "success");
|
||||
@@ -128,12 +205,12 @@ export const AddOrganization = ({ getData, item }: AddPageProps) => {
|
||||
if (error?.status === 403) {
|
||||
showToast(
|
||||
error?.response?.data?.message || "این سازمان تکراری است!",
|
||||
"error"
|
||||
"error",
|
||||
);
|
||||
} else {
|
||||
showToast(
|
||||
error?.response?.data?.message || "خطا در ثبت اطلاعات!",
|
||||
"error"
|
||||
"error",
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -153,6 +230,7 @@ export const AddOrganization = ({ getData, item }: AddPageProps) => {
|
||||
keyField="id"
|
||||
secondaryKey="is_repeatable"
|
||||
tertiaryKey="org_type_field"
|
||||
quaternaryKey="key"
|
||||
valueField="name"
|
||||
error={!!errors.organizationType}
|
||||
errorMessage={errors.organizationType?.message}
|
||||
@@ -163,6 +241,12 @@ export const AddOrganization = ({ getData, item }: AddPageProps) => {
|
||||
trigger(["organizationType"]);
|
||||
}}
|
||||
onChangeValue={(r) => {
|
||||
if (r.key4 === "U" || r.key4 === "CO") {
|
||||
setIsInquiryRequired(true);
|
||||
} else {
|
||||
setIsInquiryRequired(false);
|
||||
setInquiryPassed(false);
|
||||
}
|
||||
if (!r.key2) {
|
||||
setValue("name", r.value);
|
||||
} else {
|
||||
@@ -223,6 +307,62 @@ export const AddOrganization = ({ getData, item }: AddPageProps) => {
|
||||
)}
|
||||
/>
|
||||
|
||||
<Controller
|
||||
name="unique_unit_identity"
|
||||
control={control}
|
||||
render={({ field }) => (
|
||||
<div className="flex items-start gap-2 w-full">
|
||||
<Textfield
|
||||
fullWidth
|
||||
placeholder={
|
||||
isInquiryRequired
|
||||
? "شناسه یکتا واحد"
|
||||
: "شناسه یکتا واحد (اختیاری)"
|
||||
}
|
||||
value={field.value}
|
||||
onChange={(e) => {
|
||||
field.onChange(e);
|
||||
setInquiryPassed(false);
|
||||
}}
|
||||
error={
|
||||
!!errors.unique_unit_identity ||
|
||||
(isInquiryRequired && !inquiryPassed && !!field.value)
|
||||
}
|
||||
helperText={
|
||||
errors.unique_unit_identity?.message ||
|
||||
(isInquiryRequired && inquiryPassed
|
||||
? "استعلام تایید شده"
|
||||
: undefined)
|
||||
}
|
||||
/>
|
||||
{isInquiryRequired && (
|
||||
<button
|
||||
type="button"
|
||||
onClick={handleInquiry}
|
||||
disabled={inquiryLoading || !field.value}
|
||||
className={`shrink-0 flex items-center gap-1 mt-[2px] px-4 py-2 rounded-lg text-sm font-medium transition-colors ${
|
||||
inquiryPassed
|
||||
? "bg-green-500 text-white hover:bg-green-600"
|
||||
: "bg-blue-500 text-white hover:bg-blue-600"
|
||||
} disabled:opacity-50 disabled:cursor-not-allowed`}
|
||||
>
|
||||
{inquiryLoading
|
||||
? "..."
|
||||
: inquiryPassed
|
||||
? "تایید شده"
|
||||
: "استعلام"}
|
||||
|
||||
{inquiryPassed && !inquiryLoading ? (
|
||||
<CheckBadgeIcon className="w-4 h-4 text-white" />
|
||||
) : (
|
||||
<ArrowPathIcon className="w-4 h-4 text-white" />
|
||||
)}
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
/>
|
||||
|
||||
<Controller
|
||||
name="province"
|
||||
control={control}
|
||||
@@ -258,7 +398,7 @@ export const AddOrganization = ({ getData, item }: AddPageProps) => {
|
||||
defaultKey={item?.parent_organization?.id}
|
||||
title="سازمان والد (اختیاری)"
|
||||
api={`auth/api/v1/organization/organizations_by_province?province=${getValues(
|
||||
"province"
|
||||
"province",
|
||||
)}`}
|
||||
keyField="id"
|
||||
valueField="name"
|
||||
@@ -273,20 +413,53 @@ export const AddOrganization = ({ getData, item }: AddPageProps) => {
|
||||
)}
|
||||
/>
|
||||
|
||||
<Controller
|
||||
name="address"
|
||||
control={control}
|
||||
render={({ field }) => (
|
||||
<div className="flex flex-col gap-2 w-full">
|
||||
<div className="flex items-center justify-between">
|
||||
<span className="text-sm font-medium text-gray-700">آدرسها</span>
|
||||
<button
|
||||
type="button"
|
||||
onClick={handleAddAddress}
|
||||
className="flex items-center gap-1 text-sm text-blue-500 dark:text-blue-300 hover:text-blue-800 transition-colors"
|
||||
>
|
||||
<PlusIcon className="w-4 h-4" />
|
||||
افزودن آدرس
|
||||
</button>
|
||||
</div>
|
||||
{addresses.map((addr, index) => (
|
||||
<div
|
||||
key={index}
|
||||
className="flex items-start gap-2 p-3 border border-gray-200 rounded-lg"
|
||||
>
|
||||
<div className="flex flex-col gap-2 flex-1">
|
||||
<Textfield
|
||||
fullWidth
|
||||
placeholder="آدرس (اختیاری)"
|
||||
value={field.value}
|
||||
onChange={field.onChange}
|
||||
error={!!errors.address}
|
||||
helperText={errors.address?.message}
|
||||
placeholder="کد پستی"
|
||||
value={addr.postal_code}
|
||||
onChange={(e) =>
|
||||
handleAddressChange(index, "postal_code", e.target.value)
|
||||
}
|
||||
/>
|
||||
<Textfield
|
||||
fullWidth
|
||||
placeholder="آدرس"
|
||||
value={addr.address}
|
||||
onChange={(e) =>
|
||||
handleAddressChange(index, "address", e.target.value)
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
{addresses.length > 1 && (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => handleRemoveAddress(index)}
|
||||
className="mt-2 text-red-500 hover:text-red-700 transition-colors shrink-0"
|
||||
>
|
||||
<TrashIcon className="w-5 h-5" />
|
||||
</button>
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<Controller
|
||||
name="free_visibility_by_scope"
|
||||
|
||||
@@ -3,6 +3,7 @@ import { Grid } from "../../components/Grid/Grid";
|
||||
import Button from "../../components/Button/Button";
|
||||
import { AddOrganization } from "./AddOrganization";
|
||||
import AutoComplete from "../../components/AutoComplete/AutoComplete";
|
||||
import { FormApiBasedAutoComplete } from "../../components/FormItems/FormApiBasedAutoComplete";
|
||||
import Table from "../../components/Table/Table";
|
||||
import { useModalStore } from "../../context/zustand-store/appStore";
|
||||
import { useApiRequest } from "../../utils/useApiRequest";
|
||||
@@ -19,6 +20,9 @@ export const OrganizationsList = () => {
|
||||
const [selectedProvinceKeys, setSelectedProvinceKeys] = useState<
|
||||
(string | number)[]
|
||||
>([]);
|
||||
const [selectedOrganizationType, setSelectedOrganizationType] = useState<
|
||||
string | number
|
||||
>("");
|
||||
const [params, setParams] = useState({ page: 1, page_size: 10 });
|
||||
const [tableData, setTableData] = useState([]);
|
||||
const { profile } = useUserProfileStore();
|
||||
@@ -32,11 +36,16 @@ export const OrganizationsList = () => {
|
||||
|
||||
const { data: apiData, refetch } = useApiRequest({
|
||||
api: selectedProvinceKeys?.length
|
||||
? `/auth/api/v1/organization/organizations_by_province?province=${selectedProvinceKeys[0]}`
|
||||
: "/auth/api/v1/organization/",
|
||||
? `/auth/api/v1/organization/organizations_by_province?province=${selectedProvinceKeys[0]}${selectedOrganizationType ? `&org_type=${selectedOrganizationType}` : ""}`
|
||||
: `/auth/api/v1/organization/${selectedOrganizationType ? `?org_type=${selectedOrganizationType}` : ""}`,
|
||||
method: "get",
|
||||
params: params,
|
||||
queryKey: ["organizations", params, selectedProvinceKeys],
|
||||
queryKey: [
|
||||
"organizations",
|
||||
params,
|
||||
selectedProvinceKeys,
|
||||
selectedOrganizationType,
|
||||
],
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
@@ -50,6 +59,7 @@ export const OrganizationsList = () => {
|
||||
`${item?.type?.name}`,
|
||||
item?.parent_organization?.name,
|
||||
item?.national_unique_id,
|
||||
item?.unique_unit_identity || "-",
|
||||
item?.field_of_activity === "CO"
|
||||
? "کشور"
|
||||
: item?.field_of_activity === "PR"
|
||||
@@ -59,7 +69,14 @@ export const OrganizationsList = () => {
|
||||
: "نامشخص",
|
||||
item?.province?.name,
|
||||
item?.city?.name,
|
||||
item?.address || "-",
|
||||
<ShowMoreInfo
|
||||
key={`address-${i}`}
|
||||
title="آدرسها"
|
||||
disabled={!item?.addresses?.length}
|
||||
data={item?.addresses}
|
||||
columns={["کد پستی", "آدرس"]}
|
||||
accessKeys={[["postal_code"], ["address"]]}
|
||||
/>,
|
||||
<ShowMoreInfo
|
||||
key={i}
|
||||
title="اطلاعات حساب"
|
||||
@@ -151,6 +168,16 @@ export const OrganizationsList = () => {
|
||||
ایجاد سازمان
|
||||
</Button>
|
||||
</Grid>
|
||||
<Grid>
|
||||
<FormApiBasedAutoComplete
|
||||
size="small"
|
||||
title="فیلتر نهاد"
|
||||
api={`auth/api/v1/organization-type`}
|
||||
keyField="id"
|
||||
valueField="name"
|
||||
onChange={(r) => setSelectedOrganizationType(r)}
|
||||
/>
|
||||
</Grid>
|
||||
{profile?.organization?.type?.org_type_field === "CO" && (
|
||||
<Grid>
|
||||
<AutoComplete
|
||||
@@ -177,6 +204,7 @@ export const OrganizationsList = () => {
|
||||
"نهاد",
|
||||
"سازمان والد",
|
||||
"شناسه کشوری",
|
||||
"شناسه یکتا واحد",
|
||||
"حوزه فعالیت",
|
||||
"استان",
|
||||
"شهر",
|
||||
|
||||
@@ -27,7 +27,12 @@ type ParentDistItem = {
|
||||
label?: string;
|
||||
};
|
||||
|
||||
export const DistributeFromDistribution = ({ item, getData }: any) => {
|
||||
export const DistributeFromDistribution = ({
|
||||
item,
|
||||
getData,
|
||||
isEdit,
|
||||
parentDistributions,
|
||||
}: any) => {
|
||||
const showToast = useToast();
|
||||
const { closeModal } = useModalStore();
|
||||
|
||||
@@ -54,12 +59,12 @@ export const DistributeFromDistribution = ({ item, getData }: any) => {
|
||||
api: `/tag/web/api/v1/tag_distribution_batch/${item?.id}/`,
|
||||
method: "get",
|
||||
queryKey: ["tagDistributionBatchDetail", item?.id],
|
||||
enabled: !!item?.id,
|
||||
enabled: !!item?.id && !isEdit,
|
||||
});
|
||||
|
||||
const mutation = useApiMutation({
|
||||
api: `/tag/web/api/v1/tag_distribution/${item?.id}/distribute_distribution/`,
|
||||
method: "post",
|
||||
api: `/tag/web/api/v1/tag_distribution/${item?.id}/${isEdit ? "edit_" : ""}distribute_distribution/`,
|
||||
method: isEdit ? "put" : "post",
|
||||
});
|
||||
|
||||
const { data: speciesData } = useApiRequest({
|
||||
@@ -70,7 +75,9 @@ export const DistributeFromDistribution = ({ item, getData }: any) => {
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
const sourceDistributions = item?.distributions?.length
|
||||
const sourceDistributions = isEdit
|
||||
? parentDistributions
|
||||
: item?.distributions?.length
|
||||
? item.distributions
|
||||
: batchDetail?.distributions;
|
||||
|
||||
@@ -81,8 +88,7 @@ export const DistributeFromDistribution = ({ item, getData }: any) => {
|
||||
}
|
||||
|
||||
const parentDists: ParentDistItem[] = sourceDistributions.map((d: any) => {
|
||||
const maxCount =
|
||||
d?.remaining_number ?? d?.total_tag_count ?? d?.distributed_number ?? 0;
|
||||
const maxCount = d?.remaining_number || 0;
|
||||
return {
|
||||
id: d?.id ?? d?.dist_identity,
|
||||
dist_identity: d?.dist_identity,
|
||||
@@ -97,9 +103,32 @@ export const DistributeFromDistribution = ({ item, getData }: any) => {
|
||||
});
|
||||
|
||||
setDists(parentDists);
|
||||
|
||||
if (isEdit && item?.distributions?.length) {
|
||||
const defaultCounts: Record<number, number | ""> = {};
|
||||
const defaultSpeciesKeys: (string | number)[] = [];
|
||||
|
||||
parentDists.forEach((pd) => {
|
||||
const childDist = item.distributions.find(
|
||||
(cd: any) =>
|
||||
cd.parent_tag_distribution === pd.id ||
|
||||
cd.species_code === pd.species_code,
|
||||
);
|
||||
if (childDist) {
|
||||
defaultCounts[pd.id] = childDist.total_tag_count || 0;
|
||||
if (!defaultSpeciesKeys.includes(pd.species_code)) {
|
||||
defaultSpeciesKeys.push(pd.species_code);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
setCounts(defaultCounts);
|
||||
setSelectedSpeciesKeys(defaultSpeciesKeys);
|
||||
} else {
|
||||
setCounts({});
|
||||
setSelectedSpeciesKeys([]);
|
||||
}, [item?.distributions, batchDetail?.distributions]);
|
||||
}
|
||||
}, [item?.distributions, batchDetail?.distributions, parentDistributions]);
|
||||
|
||||
const speciesOptions = () =>
|
||||
speciesData?.results?.map((opt: any) => ({
|
||||
@@ -146,7 +175,12 @@ export const DistributeFromDistribution = ({ item, getData }: any) => {
|
||||
dists: distsPayload,
|
||||
});
|
||||
|
||||
showToast("توزیع از توزیع با موفقیت انجام شد", "success");
|
||||
showToast(
|
||||
isEdit
|
||||
? "ویرایش توزیع با موفقیت انجام شد"
|
||||
: "توزیع از توزیع با موفقیت انجام شد",
|
||||
"success",
|
||||
);
|
||||
getData();
|
||||
closeModal();
|
||||
} catch (error: any) {
|
||||
@@ -189,6 +223,7 @@ export const DistributeFromDistribution = ({ item, getData }: any) => {
|
||||
control={control}
|
||||
render={() => (
|
||||
<FormApiBasedAutoComplete
|
||||
defaultKey={item?.assigned_org?.id}
|
||||
title="انتخاب سازمان (دریافتکننده)"
|
||||
api={`auth/api/v1/organization/organizations_by_province?exclude=PSP&province=${item?.assigner_org?.province}`}
|
||||
keyField="id"
|
||||
@@ -247,7 +282,7 @@ export const DistributeFromDistribution = ({ item, getData }: any) => {
|
||||
)}
|
||||
|
||||
<Button disabled={!hasValidDists} type="submit">
|
||||
توزیع از توزیع
|
||||
ثبت
|
||||
</Button>
|
||||
</Grid>
|
||||
</form>
|
||||
|
||||
@@ -23,6 +23,9 @@ import { TableButton } from "../../components/TableButton/TableButton";
|
||||
import { DistributionSpeciesModal } from "./DistributionSpeciesModal";
|
||||
import { useNavigate } from "@tanstack/react-router";
|
||||
import { TAG_DISTRIBUTION } from "../../routes/paths";
|
||||
import { DocumentOperation } from "../../components/DocumentOperation/DocumentOperation";
|
||||
import { DocumentDownloader } from "../../components/DocumentDownloader/DocumentDownloader";
|
||||
import { useUserProfileStore } from "../../context/zustand-store/userStore";
|
||||
|
||||
export default function TagActiveDistributions() {
|
||||
const { openModal } = useModalStore();
|
||||
@@ -39,12 +42,44 @@ export default function TagActiveDistributions() {
|
||||
},
|
||||
});
|
||||
|
||||
const { profile } = useUserProfileStore();
|
||||
|
||||
const { data: tagDashboardData, refetch: updateDashboard } = useApiRequest({
|
||||
api: "/tag/web/api/v1/tag_distribution_batch/main_dashboard/?is_closed=false",
|
||||
method: "get",
|
||||
queryKey: ["tagDistributionActivesDashboard"],
|
||||
});
|
||||
|
||||
const showAssignDocColumn =
|
||||
(profile?.role?.type?.key === "ADM" ||
|
||||
tagsData?.results?.some(
|
||||
(item: any) => profile?.organization?.id === item?.assigned_org?.id,
|
||||
)) ??
|
||||
false;
|
||||
|
||||
const AbleToSeeAssignDoc = (item: any) => {
|
||||
if (
|
||||
profile?.role?.type?.key === "ADM" ||
|
||||
profile?.organization?.id === item?.assigned_org?.id
|
||||
) {
|
||||
return (
|
||||
<DocumentOperation
|
||||
key={item?.id}
|
||||
downloadLink={`/tag/web/api/v1/tag_distribution_batch/${item?.id}/distribution_pdf_view/`}
|
||||
payloadKey="dist_exit_document"
|
||||
// validFiles={["pdf"]}
|
||||
page="tag_distribution"
|
||||
access="Upload-Assign-Document"
|
||||
uploadLink={`/tag/web/api/v1/tag_distribution_batch/${item?.id}/assign_document/`}
|
||||
onUploadSuccess={handleUpdate}
|
||||
limitSize={3}
|
||||
/>
|
||||
);
|
||||
} else {
|
||||
return "-";
|
||||
}
|
||||
};
|
||||
|
||||
const handleUpdate = () => {
|
||||
refetch();
|
||||
updateDashboard();
|
||||
@@ -75,6 +110,8 @@ export default function TagActiveDistributions() {
|
||||
item?.assigner_org?.name,
|
||||
item?.assigned_org?.name,
|
||||
item?.total_tag_count,
|
||||
item?.total_distributed_tag_count,
|
||||
item?.remaining_tag_count,
|
||||
item?.distribution_type === "batch" ? "توزیع گروهی" : "توزیع تصادفی",
|
||||
<ShowMoreInfo key={item?.id} title="جزئیات توزیع">
|
||||
<Grid container column className="gap-4 w-full">
|
||||
@@ -85,6 +122,19 @@ export default function TagActiveDistributions() {
|
||||
column
|
||||
className="gap-3 w-full rounded-xl border border-gray-200 dark:border-gray-700 p-4"
|
||||
>
|
||||
<Grid container className="gap-2 items-center">
|
||||
<SparklesIcon className="w-5 h-5 text-gray-500 dark:text-gray-300" />
|
||||
<Typography variant="body2" className="font-medium">
|
||||
گونه:
|
||||
</Typography>
|
||||
<Typography
|
||||
variant="body2"
|
||||
className="text-gray-700 dark:text-gray-300"
|
||||
>
|
||||
{speciesMap[opt?.species_code] ?? "-"}
|
||||
</Typography>
|
||||
</Grid>
|
||||
|
||||
{item?.distribution_type === "batch" && opt?.serial_from && (
|
||||
<Grid container className="gap-2 items-center">
|
||||
<Bars3Icon className="w-5 h-5 text-gray-500 dark:text-gray-300" />
|
||||
@@ -112,25 +162,67 @@ export default function TagActiveDistributions() {
|
||||
{opt?.total_tag_count?.toLocaleString()}
|
||||
</Typography>
|
||||
</Grid>
|
||||
|
||||
<Grid container className="gap-2 items-center">
|
||||
<SparklesIcon className="w-5 h-5 text-gray-500 dark:text-gray-300" />
|
||||
<CubeIcon className="w-5 h-5 text-gray-500 dark:text-gray-300" />
|
||||
<Typography variant="body2" className="font-medium">
|
||||
گونه:
|
||||
پلاک های توزیع شده:
|
||||
</Typography>
|
||||
<Typography
|
||||
variant="body2"
|
||||
className="text-gray-700 dark:text-gray-300"
|
||||
>
|
||||
{speciesMap[opt?.species_code] ?? "-"}
|
||||
{opt?.distributed_number?.toLocaleString()}
|
||||
</Typography>
|
||||
</Grid>
|
||||
<Grid container className="gap-2 items-center">
|
||||
<CubeIcon className="w-5 h-5 text-gray-500 dark:text-gray-300" />
|
||||
<Typography variant="body2" className="font-medium">
|
||||
پلاک های باقیمانده:
|
||||
</Typography>
|
||||
<Typography
|
||||
variant="body2"
|
||||
className="text-gray-700 dark:text-gray-300"
|
||||
>
|
||||
{opt?.remaining_number?.toLocaleString()}
|
||||
</Typography>
|
||||
</Grid>
|
||||
</Grid>
|
||||
))}
|
||||
</Grid>
|
||||
</ShowMoreInfo>,
|
||||
...(showAssignDocColumn ? [AbleToSeeAssignDoc(item)] : []),
|
||||
<DocumentDownloader
|
||||
key={index}
|
||||
link={item?.warehouse_exit_doc}
|
||||
title="دانلود"
|
||||
/>,
|
||||
item?.exit_doc_status ? (
|
||||
"تایید شده"
|
||||
) : (
|
||||
<Button
|
||||
page="tag_distribution"
|
||||
access="Accept-Assign-Document"
|
||||
size="small"
|
||||
disabled={item?.exit_doc_status}
|
||||
onClick={() => {
|
||||
openModal({
|
||||
title: "تایید سند خروج",
|
||||
content: (
|
||||
<BooleanQuestion
|
||||
api={`/tag/web/api/v1/tag_distribution_batch/${item?.id}/accept_exit_doc/`}
|
||||
method="post"
|
||||
getData={handleUpdate}
|
||||
title="آیا از تایید سند خروج مطمئنید؟"
|
||||
/>
|
||||
),
|
||||
});
|
||||
}}
|
||||
>
|
||||
تایید سند خروج
|
||||
</Button>
|
||||
),
|
||||
<Popover key={index}>
|
||||
<Tooltip title="جزيٓیات توزیع" position="right">
|
||||
<Tooltip title="جزئیات توزیع" position="right">
|
||||
<Button
|
||||
variant="detail"
|
||||
page="tag_distribution_detail"
|
||||
@@ -291,8 +383,13 @@ export default function TagActiveDistributions() {
|
||||
"توزیع کننده",
|
||||
"دریافت کننده",
|
||||
"تعداد کل پلاک",
|
||||
"پلاک های توزیع شده",
|
||||
"پلاک های باقیمانده",
|
||||
"نوع توزیع",
|
||||
"جزئیات توزیع",
|
||||
...(showAssignDocColumn ? ["امضا سند خروج از انبار"] : []),
|
||||
"سند خروج از انبار",
|
||||
"تایید سند خروج",
|
||||
"عملیات",
|
||||
]}
|
||||
rows={tagsTableData}
|
||||
|
||||
@@ -1 +1 @@
|
||||
02.63
|
||||
02.67
|
||||
|
||||
Reference in New Issue
Block a user