|
|
|
|
@ -8,79 +8,79 @@ import { GridSizeSelect } from "./GridSizeSelect";
|
|
|
|
|
import { ModelSelect } from "./ModelSelect";
|
|
|
|
|
import { Settings } from "./Settings";
|
|
|
|
|
|
|
|
|
|
// const activeTablesMapper = {
|
|
|
|
|
// net_3: ["point3", "net_3"],
|
|
|
|
|
// net_4: ["point4", "net_4"],
|
|
|
|
|
// net_5: ["point5", "net_5"],
|
|
|
|
|
// };
|
|
|
|
|
|
|
|
|
|
// function download(filename, data) {
|
|
|
|
|
// const link = document.createElement("a");
|
|
|
|
|
// link.href =
|
|
|
|
|
// "data:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;base64," +
|
|
|
|
|
// encodeURIComponent(data);
|
|
|
|
|
// link.setAttribute("download", filename);
|
|
|
|
|
//
|
|
|
|
|
// link.style.display = "none";
|
|
|
|
|
// document.body.appendChild(link);
|
|
|
|
|
//
|
|
|
|
|
// link.click();
|
|
|
|
|
//
|
|
|
|
|
// document.body.removeChild(link);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// const getRegionParam = (regionId) => {
|
|
|
|
|
// if (!regionId) return null;
|
|
|
|
|
//
|
|
|
|
|
// const [type, id] = regionId.split("-");
|
|
|
|
|
//
|
|
|
|
|
// if (type === "ao") {
|
|
|
|
|
// return { msk_ao: Number(id) };
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// return { msk_rayon: Number(id) };
|
|
|
|
|
// };
|
|
|
|
|
const activeTablesMapper = {
|
|
|
|
|
net_3: ["point3", "net_3"],
|
|
|
|
|
net_4: ["point4", "net_4"],
|
|
|
|
|
net_5: ["point5", "net_5"],
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
function download(filename, data) {
|
|
|
|
|
const link = document.createElement("a");
|
|
|
|
|
link.href =
|
|
|
|
|
"data:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;base64," +
|
|
|
|
|
encodeURIComponent(data);
|
|
|
|
|
link.setAttribute("download", filename);
|
|
|
|
|
|
|
|
|
|
link.style.display = "none";
|
|
|
|
|
document.body.appendChild(link);
|
|
|
|
|
|
|
|
|
|
link.click();
|
|
|
|
|
|
|
|
|
|
document.body.removeChild(link);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const getRegionParam = (regionId) => {
|
|
|
|
|
if (!regionId) return null;
|
|
|
|
|
|
|
|
|
|
const [type, id] = regionId.split("-");
|
|
|
|
|
|
|
|
|
|
if (type === "ao") {
|
|
|
|
|
return { msk_ao: Number(id) };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return { msk_rayon: Number(id) };
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const Sidebar = () => {
|
|
|
|
|
// const { factors } = useFactors();
|
|
|
|
|
// const { activeTypes } = useActiveTypes();
|
|
|
|
|
// const { region } = useRegion();
|
|
|
|
|
// const { gridSize } = useGridSize();
|
|
|
|
|
//
|
|
|
|
|
// const handleExport = async () => {
|
|
|
|
|
// const params = {
|
|
|
|
|
// koefs: factors,
|
|
|
|
|
// tables: activeTablesMapper[gridSize],
|
|
|
|
|
// };
|
|
|
|
|
//
|
|
|
|
|
// if (region) {
|
|
|
|
|
// params.filters = {
|
|
|
|
|
// ...params.filters,
|
|
|
|
|
// ...getRegionParam(region),
|
|
|
|
|
// };
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// if (activeTypes.length) {
|
|
|
|
|
// params.filters = {
|
|
|
|
|
// ...params.filters,
|
|
|
|
|
// category: activeTypes,
|
|
|
|
|
// };
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// const resp = await api.post("/api/raschet/", params);
|
|
|
|
|
// const blob = resp.data;
|
|
|
|
|
//
|
|
|
|
|
// const downloadLink = window.document.createElement("a");
|
|
|
|
|
// downloadLink.href = window.URL.createObjectURL(
|
|
|
|
|
// new Blob([blob], {
|
|
|
|
|
// type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
|
|
|
// })
|
|
|
|
|
// );
|
|
|
|
|
// downloadLink.download = "postamates.xlsx";
|
|
|
|
|
// document.body.appendChild(downloadLink);
|
|
|
|
|
// downloadLink.click();
|
|
|
|
|
// document.body.removeChild(downloadLink);
|
|
|
|
|
// };
|
|
|
|
|
const { factors } = useFactors();
|
|
|
|
|
const { activeTypes } = useActiveTypes();
|
|
|
|
|
const { region } = useRegion();
|
|
|
|
|
const { gridSize } = useGridSize();
|
|
|
|
|
|
|
|
|
|
const handleExport = async () => {
|
|
|
|
|
const params = {
|
|
|
|
|
koefs: factors,
|
|
|
|
|
tables: activeTablesMapper[gridSize],
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (region) {
|
|
|
|
|
params.filters = {
|
|
|
|
|
...params.filters,
|
|
|
|
|
...getRegionParam(region),
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (activeTypes.length) {
|
|
|
|
|
params.filters = {
|
|
|
|
|
...params.filters,
|
|
|
|
|
category: activeTypes,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const resp = await api.post("/api/raschet/", params);
|
|
|
|
|
const blob = resp.data;
|
|
|
|
|
|
|
|
|
|
const downloadLink = window.document.createElement("a");
|
|
|
|
|
downloadLink.href = window.URL.createObjectURL(
|
|
|
|
|
new Blob([blob], {
|
|
|
|
|
type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
downloadLink.download = "postamates.xlsx";
|
|
|
|
|
document.body.appendChild(downloadLink);
|
|
|
|
|
downloadLink.click();
|
|
|
|
|
document.body.removeChild(downloadLink);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className="absolute top-[20px] right-[20px] bg-white-background w-[300px] rounded-xl p-3 max-h-[calc(100vh-40px)] overflow-y-auto z-10">
|
|
|
|
|
|