|
|
|
|
@ -1,20 +1,27 @@
|
|
|
|
|
import { useGetRegions } from "../../../components/RegionSelect.jsx";
|
|
|
|
|
import { useMemo } from "react";
|
|
|
|
|
import { getRegionNameById } from "../../../Map/Popup/mode-popup/config.js";
|
|
|
|
|
import { SearchOutlined } from "@ant-design/icons";
|
|
|
|
|
import { Button, Popover } from "antd";
|
|
|
|
|
import { AddressSearch } from "../../../Map/AddressSearch.jsx";
|
|
|
|
|
import { useTable } from "../../../stores/useTable.js";
|
|
|
|
|
import {useGetRegions} from "../../../components/RegionSelect.jsx";
|
|
|
|
|
import {useMemo} from "react";
|
|
|
|
|
import {getRegionNameById} from "../../../Map/Popup/mode-popup/config.js";
|
|
|
|
|
import {SearchOutlined} from "@ant-design/icons";
|
|
|
|
|
import {Button, Popover} from "antd";
|
|
|
|
|
import {AddressSearch} from "../../../Map/AddressSearch.jsx";
|
|
|
|
|
import {useTable} from "../../../stores/useTable.js";
|
|
|
|
|
import useLocalStorage from "../../../hooks/useLocalStorage.js";
|
|
|
|
|
|
|
|
|
|
const DEFAULT_LENGTH = 11;
|
|
|
|
|
export const useColumns = ({ key }) => {
|
|
|
|
|
const { data: regions } = useGetRegions();
|
|
|
|
|
export const useColumns = (key) => {
|
|
|
|
|
const {data: regions} = useGetRegions();
|
|
|
|
|
const {
|
|
|
|
|
tableState: { fullScreen },
|
|
|
|
|
tableState: {fullScreen},
|
|
|
|
|
} = useTable();
|
|
|
|
|
|
|
|
|
|
const [order, setOrder] = useLocalStorage(key, [...Array(DEFAULT_LENGTH).keys()])
|
|
|
|
|
const [order, setOrder] = useLocalStorage(`${key}Order`, [...Array(DEFAULT_LENGTH).keys()].map((position) => {
|
|
|
|
|
return {
|
|
|
|
|
position,
|
|
|
|
|
show: true,
|
|
|
|
|
}
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
const [sort, setSort] = useLocalStorage(`${key}Sort`, null);
|
|
|
|
|
|
|
|
|
|
const defaultColumns = useMemo(() => {
|
|
|
|
|
return [
|
|
|
|
|
@ -23,20 +30,23 @@ export const useColumns = ({ key }) => {
|
|
|
|
|
<div className="flex items-center justify-between">
|
|
|
|
|
<span>Адрес</span>
|
|
|
|
|
<Popover
|
|
|
|
|
content={<AddressSearch autoFocus={true} />}
|
|
|
|
|
content={<AddressSearch autoFocus={true}/>}
|
|
|
|
|
trigger="click"
|
|
|
|
|
placement={"right"}
|
|
|
|
|
>
|
|
|
|
|
<Button>
|
|
|
|
|
<SearchOutlined />
|
|
|
|
|
<SearchOutlined/>
|
|
|
|
|
</Button>
|
|
|
|
|
</Popover>
|
|
|
|
|
</div>
|
|
|
|
|
) : (
|
|
|
|
|
"Адрес"
|
|
|
|
|
),
|
|
|
|
|
name: "Адрес",
|
|
|
|
|
dataIndex: "address",
|
|
|
|
|
key: "address",
|
|
|
|
|
sorter: true,
|
|
|
|
|
showSorterTooltip: false,
|
|
|
|
|
width: 200,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
@ -45,6 +55,8 @@ export const useColumns = ({ key }) => {
|
|
|
|
|
key: "area",
|
|
|
|
|
width: "120px",
|
|
|
|
|
ellipsis: true,
|
|
|
|
|
sorter: true,
|
|
|
|
|
showSorterTooltip: false,
|
|
|
|
|
render: (_, record) => {
|
|
|
|
|
return getRegionNameById(record.area, regions?.normalized);
|
|
|
|
|
},
|
|
|
|
|
@ -58,6 +70,8 @@ export const useColumns = ({ key }) => {
|
|
|
|
|
render: (_, record) => {
|
|
|
|
|
return getRegionNameById(record.district, regions?.normalized);
|
|
|
|
|
},
|
|
|
|
|
sorter: true,
|
|
|
|
|
showSorterTooltip: false,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: "Название",
|
|
|
|
|
@ -65,6 +79,8 @@ export const useColumns = ({ key }) => {
|
|
|
|
|
key: "name",
|
|
|
|
|
width: "120px",
|
|
|
|
|
ellipsis: true,
|
|
|
|
|
sorter: true,
|
|
|
|
|
showSorterTooltip: false,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: "Категория",
|
|
|
|
|
@ -72,6 +88,8 @@ export const useColumns = ({ key }) => {
|
|
|
|
|
key: "category",
|
|
|
|
|
width: "120px",
|
|
|
|
|
ellipsis: true,
|
|
|
|
|
sorter: true,
|
|
|
|
|
showSorterTooltip: false,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: "План",
|
|
|
|
|
@ -79,6 +97,8 @@ export const useColumns = ({ key }) => {
|
|
|
|
|
key: "plan_current",
|
|
|
|
|
width: "120px",
|
|
|
|
|
ellipsis: true,
|
|
|
|
|
sorter: true,
|
|
|
|
|
showSorterTooltip: false,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: "Факт",
|
|
|
|
|
@ -86,6 +106,8 @@ export const useColumns = ({ key }) => {
|
|
|
|
|
key: "fact",
|
|
|
|
|
width: "120px",
|
|
|
|
|
ellipsis: true,
|
|
|
|
|
sorter: true,
|
|
|
|
|
showSorterTooltip: false,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: "Расхождение с прогнозом",
|
|
|
|
|
@ -93,6 +115,8 @@ export const useColumns = ({ key }) => {
|
|
|
|
|
key: "delta_current",
|
|
|
|
|
width: "120px",
|
|
|
|
|
ellipsis: true,
|
|
|
|
|
sorter: true,
|
|
|
|
|
showSorterTooltip: false,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: "Зрелость",
|
|
|
|
|
@ -100,12 +124,16 @@ export const useColumns = ({ key }) => {
|
|
|
|
|
key: "age_day",
|
|
|
|
|
width: "120px",
|
|
|
|
|
ellipsis: true,
|
|
|
|
|
sorter: true,
|
|
|
|
|
showSorterTooltip: false,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: "Дата начала работы",
|
|
|
|
|
dataIndex: "start_date",
|
|
|
|
|
key: "start_date",
|
|
|
|
|
width: "120px",
|
|
|
|
|
sorter: true,
|
|
|
|
|
showSorterTooltip: false,
|
|
|
|
|
render: (value) => {
|
|
|
|
|
if (!value) return "Нет данных";
|
|
|
|
|
|
|
|
|
|
@ -119,15 +147,31 @@ export const useColumns = ({ key }) => {
|
|
|
|
|
key: "postamat_id",
|
|
|
|
|
width: "70px",
|
|
|
|
|
ellipsis: true,
|
|
|
|
|
sorter: true,
|
|
|
|
|
showSorterTooltip: false,
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
}, [regions?.normalized, fullScreen]);
|
|
|
|
|
|
|
|
|
|
const columns = useMemo(() => {
|
|
|
|
|
return order.map((item) => {
|
|
|
|
|
return defaultColumns[item];
|
|
|
|
|
})
|
|
|
|
|
return order.flatMap((item) => !item.show ? [] : defaultColumns[item.position])
|
|
|
|
|
.map((column) => {
|
|
|
|
|
if (sort && sort.includes(column.key)) return {
|
|
|
|
|
...column,
|
|
|
|
|
defaultSortOrder: sort.includes('-') ? 'descend' : 'ascend',
|
|
|
|
|
};
|
|
|
|
|
return column;
|
|
|
|
|
});
|
|
|
|
|
}, [defaultColumns, order, fullScreen]);
|
|
|
|
|
|
|
|
|
|
return {columns, defaultColumns, order, setOrder};
|
|
|
|
|
return {
|
|
|
|
|
columns,
|
|
|
|
|
orderColumns: {
|
|
|
|
|
defaultColumns,
|
|
|
|
|
order,
|
|
|
|
|
setOrder,
|
|
|
|
|
},
|
|
|
|
|
sort,
|
|
|
|
|
setSort
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|