Merge pull request 'исправила формат для id нуменклатуры в проектах + убрала админа из фильтра' (#160) from fix-stage-front into test

Reviewed-on: #160
This commit is contained in:
PotapovaA 2026-09-16 11:20:35 +03:00
commit 614b5c9abe
3 changed files with 18 additions and 44 deletions

View File

@ -1,7 +1,6 @@
import React, { useMemo, useCallback } from 'react';
import { useCellLock } from '../../contexts/RealtimeContext';
// Константы вне компонента
const BASE_CELL_STYLES = {
width: '100%',
height: '100%',
@ -65,12 +64,13 @@ const CONTAINER_STYLES = {
wordBreak: 'break-word',
};
const INTEGER_COLUMN_IDS = new Set([
const TEXT_COLUMN_IDS = new Set([
'data.header.num_group',
'data.nomenclature_group_id',
'data.header.item_id',
'data.article_id',
'data.code_razdela',
'data.header.num_group_id',
]);
const getColorBrightness = (hexColor) => {
@ -143,11 +143,10 @@ const CellComponent = ({ cell, row, column, onClick, globalFilter, columnFilter,
const isVspDropdown = column?.columnDef?.editType === 'vsp_dropdown';
const nameIndent = column.id === 'data.header.name' ? 8 + row.depth * 16 : 8;
// Мемоизация значения
const { rawValue, displayValue, isNumeric } = useMemo(() => {
const value = cell.getValue();
const isNum = value !== null && value !== undefined && value !== '' && !Number.isNaN(Number(value));
let display = String(value || '');
const isNum = value !== null && value !== undefined && value !== '' && !Number.isNaN(Number(value)) && !TEXT_COLUMN_IDS.has(column.id);
const display = String(value || '');
if (isVspDropdown && value != null) {
const vsp = vspOptions?.find((v) => v.id === Number(value));
@ -155,12 +154,7 @@ const CellComponent = ({ cell, row, column, onClick, globalFilter, columnFilter,
return { rawValue: value, displayValue: vsp.registration_number, isNumeric: false };
}
}
if (isNum) {
const asInteger = INTEGER_COLUMN_IDS.has(column.id);
display = formatNumber(value, asInteger);
}
return { rawValue: value, displayValue: display, isNumeric: isNum };
}, [cell, column.id, isVspDropdown, vspOptions]);

View File

@ -1,32 +1,17 @@
export const ROLES_ID_NAME = {
1: 'admin',
2: 'executor_dfip',
3: 'executor_rf',
4: 'executor_durrs'
};
export const ROLES_NAME_ID = { admin: 1, executor_dfip: 2, executor_rf: 3, executor_durrs: 4 };
export const ROLES_ID_RUSSIAN_NAME = {
1: 'Администратор',
2: 'Исполнитель ДФИП',
3: 'Исполнитель',
4: 'Исполнитель ДУРРС'
};
export const ROLES_ID_RUSSIAN_NAME_ARRAY = [
{ id: 1, role: 'Администратор' },
{ id: 2, role: 'Исполнитель ДФИП' },
{ id: 3, role: 'Исполнитель' },
{ id: 4, role: 'Исполнитель ДУРРС' },
const ROLES = [
{ id: 1, name: 'admin', stageRole: 'ADMIN', label: 'Администратор' },
{ id: 2, name: 'executor_dfip', stageRole: 'DFIP', label: 'Исполнитель ДФИП' },
{ id: 3, name: 'executor_rf', stageRole: 'EXECUTOR_RF', label: 'Исполнитель' },
{ id: 4, name: 'executor_durrs', stageRole: 'DURRS', label: 'Исполнитель ДУРРС' },
];
export const STAGE_ROLE_RUSSIAN_NAME = {
ADMIN: 'Администратор',
DFIP: 'Исполнитель ДФИП',
EXECUTOR_RF: 'Исполнитель',
DURRS: 'Исполнитель ДУРРС',
};
export const ROLES_ID_NAME = Object.fromEntries(ROLES.map(({ id, name }) => [id, name]));
export const ROLES_NAME_ID = Object.fromEntries(ROLES.map(({ id, name }) => [name, id]));
export const ROLES_ID_RUSSIAN_NAME = Object.fromEntries(ROLES.map(({ id, label }) => [id, label]));
export const ROLES_ID_RUSSIAN_NAME_ARRAY = ROLES.map(({ id, label }) => ({ id, role: label }));
export const STAGE_ROLE_RUSSIAN_NAME = Object.fromEntries(
ROLES.filter(({ name }) => name !== 'admin').map(({ stageRole, label }) => [stageRole, label]),
);
export const TYPES_CELLS = { numeric: 'число', text: 'текст' };

View File

@ -122,12 +122,7 @@ export default function PhaseTemplatesTable({
<IconButton
onClick={() => onEdit(row.original)}
aria-label={`Редактировать этап ${row.original.phase_code}`}
sx={{
margin: '0.25rem',
padding: 0,
width: '1rem',
height: '1rem',
}}>
>
<EditPenSvg />
</IconButton>
</Tooltip>