Merge pull request '[AURORA-1041] - работа со справочниками' (#44) from AURORA-1041-front into test

Reviewed-on: #44
This commit is contained in:
Veronika 2026-06-09 14:35:15 +03:00
commit 27cefec47b
7 changed files with 56 additions and 53 deletions

View File

@ -14,6 +14,8 @@ export const DictVspApi = {
return api.delete(`/dict/info/${dict_vsp_id}`).then((r) => r.data);
},
export(payload) {
return api.post(`/dict/info/export`, payload);
return api.post(`/dict/info/export`, payload, {
responseType: 'blob',
});
},
};

View File

@ -2,7 +2,7 @@ import api from "./client";
export const UsersApi = {
me() {
return api.get("/users/me").then((r) => r.data);
return api.get("/users/me", { params: { load_orgs: true } }).then((r) => r.data);
},
getById(userId) {
return api.get(`/users/${userId}`).then((r) => r.data);

View File

@ -95,7 +95,7 @@ export const TaskCardComponent = ({
onExportClick,
}) => {
const navigate = useNavigate();
const { id, title, name, start_date, end_date, tables_count, org_unit, form_type_code } = taskForm;
const { id, title, org_unit, form_type_code, year } = taskForm;
const [isEditModalOpen, setEditModalOpen] = useState(false);
const [editedTitle, setEditedTitle] = useState('');
@ -181,8 +181,6 @@ export const TaskCardComponent = ({
await updateTask(nextTitle);
};
const formattedDateRange = `${formatDate(start_date)}${formatDate(end_date)}`;
return (
<>
<TaskCard
@ -222,15 +220,13 @@ export const TaskCardComponent = ({
>
<CardBody>
<IconWithContent icon={<DateIcon />}>
{formattedDateRange}
</IconWithContent>
<IconWithContent icon={<DateIcon />}>{year}</IconWithContent>
<IconWithContent icon={<UserIcon />}>
<Chip>{org_unit.title}</Chip>
</IconWithContent>
<IconWithContent icon={<TableIcon />}>
{/* <IconWithContent icon={<TableIcon />}>
Таблиц: {tables_count}
</IconWithContent>
</IconWithContent> */}
</CardBody>
{exportMode && (

View File

@ -42,13 +42,10 @@ function DictVspPage() {
if (!user) return;
setIsLoading(true);
try {
const isAdmin = user.role_id == ROLES_NAME_ID.admin;
const [vspResponse, sspResponse] = await Promise.all([
DictVspApi.get(),
user.role_id === ROLES_NAME_ID.admin
? SspApi.getAll()
: user.role_id === ROLES_NAME_ID.executor_dfip
? SspApi.getManySsp(user.id)
: SspApi.getSsp(user.ssp[0].id),
isAdmin ? SspApi.getAll() : Promise.resolve(null),
]);
if (!vspResponse.success) {
@ -57,17 +54,15 @@ function DictVspPage() {
}
setDictVspData(vspResponse.result || []);
if (isAdmin) {
if (!sspResponse.success) {
toast.error('Ошибка загрузки списка ССП');
return;
}
setSsps(
sspResponse.result?.ssp
? sspResponse.result.ssp
: Array.isArray(sspResponse.result)
? sspResponse.result
: [sspResponse.result],
);
setSsps(sspResponse.result);
} else {
setSsps(user.org_units ?? []);
}
} catch (error) {
console.error('Error loading data:', error);
toast.error('Ошибка загрузки данных');
@ -147,8 +142,8 @@ function DictVspPage() {
<DictVspInfo />
{/* <HeaderSwitch /> */}
<PageContainer>
<Stack alignItems={'center'}>
<Box minWidth={'84.5rem'} width={'auto'}>
<Stack alignItems={'stretch'} width="100%">
<Box width="100%">
{user.role_id !== ROLES_NAME_ID.executor_rf && (
<DictVspFilters
ssps={ssps}

View File

@ -9,17 +9,12 @@ import {
} from '@mui/material';
import { styled } from '@mui/material';
const FormLabelStyled = styled(FormLabel)`
color: #4a5565;
font-size: 0.75rem;
font-weight: 400;
`;
const AutocompleteStyled = styled(Autocomplete)`
& .MuiOutlinedInput-root {
background-color: white;
height: 2.56rem;
padding: 0;
width: 250px;
& input {
padding: 0.5rem 0.75rem;
@ -51,7 +46,7 @@ const DictVspFilters = ({ ssps, selectedSsp = null, onSspChange }) => {
mb: '1.5rem',
}}
>
<Stack direction={'row'} spacing={'1rem'} sx={{ width: '100%' }}>
<Stack direction={'row'} spacing={'1rem'}>
<Box width="30rem">
<AutocompleteStyled
size="small"

View File

@ -467,10 +467,19 @@ const ModalEditAddVsp = ({
error={!!errors.location_form}
helperText={errors.location_form}
disabled={loading}
SelectProps={{
slotProps={{
select: {
MenuProps: {
sx: { zIndex: 9999 },
PaperProps: { sx: { zIndex: 9999 } },
sx: { zIndex: 1301 },
style: { zIndex: 1301 },
PaperProps: {
sx: {
zIndex: 1301,
backgroundColor: '#fff',
color: '#171a1c',
},
},
},
},
}}
>

View File

@ -110,17 +110,13 @@ const TableDictVsp = ({
enableSorting: false,
},
{
accessorKey: 'ssp_id',
accessorKey: 'regional_branch',
header: 'Региональный филиал/ССП',
size: 120,
minSize: 100,
maxSize: 150,
Cell: ({ cell }) => (
<Typography variant="body2">
{cell.getValue()
? ssps.find((s) => s.id == cell.getValue())?.title
: '-'}
</Typography>
<Typography variant="body2">{cell.getValue() || '-'}</Typography>
),
enableColumnActions: false,
enableSorting: false,
@ -308,12 +304,15 @@ const TableDictVsp = ({
},
},
renderTopToolbarCustomActions: () => (
renderTopToolbar: () => (
<Box
justifyContent={'space-between'}
flexDirection={'row'}
display={'flex'}
width={'100%'}
sx={{
display: 'flex',
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center',
width: '100%',
}}
>
<Typography
sx={{
@ -347,6 +346,7 @@ const TableDictVsp = ({
'& .MuiToolbar-root': {
padding: 0,
minHeight: 'auto',
width: '100%',
},
},
},
@ -399,10 +399,11 @@ const TableDictVsp = ({
sx: {
borderRadius: '.63rem',
border: '1px solid #f2f2f2',
padding: 0,
boxShadow: 'none',
overflow: 'hidden',
position: 'relative',
padding: '20px',
width: '100%',
},
},
@ -410,8 +411,9 @@ const TableDictVsp = ({
ref: tableContainerRef,
sx: {
maxHeight: 'calc(100vh - 450px)',
minHeight: '50rem',
maxWidth: '100rem',
minHeight: '40rem',
width: '100%',
marginTop: '1.5rem',
overflowX: 'auto', // Включаем горизонтальный скролл
overflowY: 'auto', // Вертикальный скролл
position: 'relative',
@ -522,11 +524,15 @@ const TableDictVsp = ({
display: 'none',
},
},
localization: {
noRecordsToDisplay: 'Нет данных для отображения',
},
});
return (
<>
<Box sx={{ position: 'relative' }}>
<Box sx={{ position: 'relative', width: '100%' }}>
<MaterialReactTable table={table} />
</Box>