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); return api.delete(`/dict/info/${dict_vsp_id}`).then((r) => r.data);
}, },
export(payload) { 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 = { export const UsersApi = {
me() { 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) { getById(userId) {
return api.get(`/users/${userId}`).then((r) => r.data); return api.get(`/users/${userId}`).then((r) => r.data);

View File

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

View File

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

View File

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

View File

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