Generate filtering/sorting and searchable dropdowns
Includes backend q search + generated list UX from DSL.
This commit is contained in:
@@ -1,8 +1,24 @@
|
||||
import { DataProvider, fetchUtils } from 'react-admin';
|
||||
|
||||
const apiUrl = 'http://localhost:3000';
|
||||
const apiUrl = 'http://localhost:3001';
|
||||
const httpClient = fetchUtils.fetchJson;
|
||||
|
||||
function buildQueryString(query: Record<string, unknown>) {
|
||||
const search = new URLSearchParams();
|
||||
Object.entries(query).forEach(([key, val]) => {
|
||||
if (val === undefined || val === null || val === '') return;
|
||||
if (Array.isArray(val)) {
|
||||
val.forEach((v) => {
|
||||
if (v === undefined || v === null || v === '') return;
|
||||
search.append(key, String(v));
|
||||
});
|
||||
return;
|
||||
}
|
||||
search.set(key, String(val));
|
||||
});
|
||||
return search.toString();
|
||||
}
|
||||
|
||||
const dataProvider: DataProvider = {
|
||||
getList: async (resource, params) => {
|
||||
const { page, perPage } = params.pagination!;
|
||||
@@ -10,23 +26,15 @@ const dataProvider: DataProvider = {
|
||||
const start = (page - 1) * perPage;
|
||||
const end = page * perPage;
|
||||
|
||||
const query: Record<string, string> = {
|
||||
_start: String(start),
|
||||
_end: String(end),
|
||||
const query: Record<string, unknown> = {
|
||||
_start: start,
|
||||
_end: end,
|
||||
_sort: field,
|
||||
_order: order,
|
||||
...(params.filter ?? {}),
|
||||
};
|
||||
|
||||
if (params.filter) {
|
||||
Object.keys(params.filter).forEach((key) => {
|
||||
const val = params.filter[key];
|
||||
if (val !== undefined && val !== null && val !== '') {
|
||||
query[key] = String(val);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
const queryString = new URLSearchParams(query).toString();
|
||||
const queryString = buildQueryString(query);
|
||||
const url = `${apiUrl}/${resource}?${queryString}`;
|
||||
const { json, headers } = await httpClient(url);
|
||||
|
||||
@@ -55,15 +63,16 @@ const dataProvider: DataProvider = {
|
||||
const start = (page - 1) * perPage;
|
||||
const end = page * perPage;
|
||||
|
||||
const query: Record<string, string> = {
|
||||
_start: String(start),
|
||||
_end: String(end),
|
||||
const query: Record<string, unknown> = {
|
||||
_start: start,
|
||||
_end: end,
|
||||
_sort: field,
|
||||
_order: order,
|
||||
[params.target]: String(params.id),
|
||||
[params.target]: params.id,
|
||||
...(params.filter ?? {}),
|
||||
};
|
||||
|
||||
const queryString = new URLSearchParams(query).toString();
|
||||
const queryString = buildQueryString(query);
|
||||
const url = `${apiUrl}/${resource}?${queryString}`;
|
||||
const { json, headers } = await httpClient(url);
|
||||
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
import { Create, SimpleForm, TextInput, NumberInput } from 'react-admin';
|
||||
import { Create, SimpleForm, TextInput } from 'react-admin';
|
||||
|
||||
|
||||
export const EquipmentTypeCreate = () => (
|
||||
<Create>
|
||||
<SimpleForm>
|
||||
<TextInput source="code" label="Код" isRequired />
|
||||
<TextInput source="name" label="Наименование" isRequired />
|
||||
<TextInput source="manufacturer" label="Производитель" />
|
||||
<NumberInput source="maintenanceIntervalHours" label="Периодичность ТО (ч)" />
|
||||
<NumberInput source="overhaulIntervalHours" label="Периодичность КР (ч)" />
|
||||
<TextInput source="code" label="code" isRequired />
|
||||
<TextInput source="name" label="name" isRequired />
|
||||
<TextInput source="manufacturer" label="manufacturer" />
|
||||
<TextInput source="maintenanceIntervalHours" label="maintenanceIntervalHours" />
|
||||
<TextInput source="overhaulIntervalHours" label="overhaulIntervalHours" />
|
||||
</SimpleForm>
|
||||
</Create>
|
||||
);
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
import { Edit, SimpleForm, TextInput, NumberInput } from 'react-admin';
|
||||
import { Edit, SimpleForm, TextInput } from 'react-admin';
|
||||
|
||||
|
||||
export const EquipmentTypeEdit = () => (
|
||||
<Edit>
|
||||
<SimpleForm>
|
||||
<TextInput source="code" label="Код" disabled />
|
||||
<TextInput source="name" label="Наименование" isRequired />
|
||||
<TextInput source="manufacturer" label="Производитель" />
|
||||
<NumberInput source="maintenanceIntervalHours" label="Периодичность ТО (ч)" />
|
||||
<NumberInput source="overhaulIntervalHours" label="Периодичность КР (ч)" />
|
||||
<TextInput source="code" label="code" disabled />
|
||||
<TextInput source="name" label="name" isRequired />
|
||||
<TextInput source="manufacturer" label="manufacturer" />
|
||||
<TextInput source="maintenanceIntervalHours" label="maintenanceIntervalHours" />
|
||||
<TextInput source="overhaulIntervalHours" label="overhaulIntervalHours" />
|
||||
</SimpleForm>
|
||||
</Edit>
|
||||
);
|
||||
|
||||
@@ -1,13 +1,38 @@
|
||||
import { List, Datagrid, TextField, NumberField } from 'react-admin';
|
||||
import {
|
||||
List,
|
||||
Datagrid,
|
||||
TextField,
|
||||
TextInput,
|
||||
TopToolbar,
|
||||
FilterButton,
|
||||
CreateButton,
|
||||
ExportButton,
|
||||
NumberField
|
||||
} from 'react-admin';
|
||||
|
||||
|
||||
const equipmentTypeFilters = [
|
||||
<TextInput key="q" source="q" label="Поиск" alwaysOn />,
|
||||
<TextInput key="name" source="name" label="name" />,
|
||||
<TextInput key="manufacturer" source="manufacturer" label="manufacturer" />
|
||||
];
|
||||
|
||||
const EquipmentTypeListActions = () => (
|
||||
<TopToolbar>
|
||||
<FilterButton filters={equipmentTypeFilters} />
|
||||
<CreateButton />
|
||||
<ExportButton />
|
||||
</TopToolbar>
|
||||
);
|
||||
|
||||
export const EquipmentTypeList = () => (
|
||||
<List>
|
||||
<List actions={<EquipmentTypeListActions />} filters={equipmentTypeFilters} sort={{ field: 'code', order: 'ASC' }}>
|
||||
<Datagrid rowClick="show">
|
||||
<TextField source="code" label="Код" />
|
||||
<TextField source="name" label="Наименование" />
|
||||
<TextField source="manufacturer" label="Производитель" />
|
||||
<NumberField source="maintenanceIntervalHours" label="Периодичность ТО (ч)" />
|
||||
<NumberField source="overhaulIntervalHours" label="Периодичность КР (ч)" />
|
||||
<TextField source="code" label="code" />
|
||||
<TextField source="name" label="name" />
|
||||
<TextField source="manufacturer" label="manufacturer" />
|
||||
<NumberField source="maintenanceIntervalHours" label="maintenanceIntervalHours" />
|
||||
<NumberField source="overhaulIntervalHours" label="overhaulIntervalHours" />
|
||||
</Datagrid>
|
||||
</List>
|
||||
);
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import { Show, SimpleShowLayout, TextField, NumberField } from 'react-admin';
|
||||
import { Show, SimpleShowLayout, TextField } from 'react-admin';
|
||||
|
||||
export const EquipmentTypeShow = () => (
|
||||
<Show>
|
||||
<SimpleShowLayout>
|
||||
<TextField source="code" label="Код" />
|
||||
<TextField source="name" label="Наименование" />
|
||||
<TextField source="manufacturer" label="Производитель" />
|
||||
<NumberField source="maintenanceIntervalHours" label="Периодичность ТО (ч)" />
|
||||
<NumberField source="overhaulIntervalHours" label="Периодичность КР (ч)" />
|
||||
<TextField source="code" label="code" />
|
||||
<TextField source="name" label="name" />
|
||||
<TextField source="manufacturer" label="manufacturer" />
|
||||
<TextField source="maintenanceIntervalHours" label="maintenanceIntervalHours" />
|
||||
<TextField source="overhaulIntervalHours" label="overhaulIntervalHours" />
|
||||
</SimpleShowLayout>
|
||||
</Show>
|
||||
);
|
||||
|
||||
@@ -1,36 +1,28 @@
|
||||
import {
|
||||
Create,
|
||||
SimpleForm,
|
||||
TextInput,
|
||||
NumberInput,
|
||||
DateInput,
|
||||
SelectInput,
|
||||
ReferenceInput,
|
||||
} from 'react-admin';
|
||||
import { Create, SimpleForm, TextInput, SelectInput, ReferenceInput, AutocompleteInput } from 'react-admin';
|
||||
|
||||
const statusChoices = [
|
||||
{ id: 'Active', name: 'В эксплуатации' },
|
||||
{ id: 'Repair', name: 'В ремонте' },
|
||||
{ id: 'Reserve', name: 'В резерве' },
|
||||
{ id: 'WriteOff', name: 'Списано' },
|
||||
{ id: 'Active', name: 'Active' },
|
||||
{ id: 'Repair', name: 'Repair' },
|
||||
{ id: 'Reserve', name: 'Reserve' },
|
||||
{ id: 'WriteOff', name: 'WriteOff' },
|
||||
];
|
||||
|
||||
export const EquipmentCreate = () => (
|
||||
<Create>
|
||||
<SimpleForm>
|
||||
<TextInput source="inventoryNumber" label="Инвентарный номер" isRequired />
|
||||
<TextInput source="serialNumber" label="Заводской номер" />
|
||||
<TextInput source="name" label="Наименование" isRequired />
|
||||
<ReferenceInput source="equipmentTypeCode" reference="equipment-types" label="Вид оборудования">
|
||||
<SelectInput optionText="name" optionValue="code" isRequired />
|
||||
<TextInput source="inventoryNumber" label="inventoryNumber" isRequired />
|
||||
<TextInput source="serialNumber" label="serialNumber" />
|
||||
<TextInput source="name" label="name" isRequired />
|
||||
<ReferenceInput source="equipmentTypeCode" reference="equipment-types" label="equipmentTypeCode">
|
||||
<AutocompleteInput optionText={(record) => record.code ? `${record.code} — ${record.name ?? record.code}` : (record.name ?? record.id)} filterToQuery={(searchText) => ({ q: searchText })} />
|
||||
</ReferenceInput>
|
||||
<SelectInput source="status" label="Статус" choices={statusChoices} defaultValue="Active" />
|
||||
<TextInput source="location" label="Место эксплуатации" />
|
||||
<DateInput source="commissionedAt" label="Дата ввода в эксплуатацию" />
|
||||
<NumberInput source="totalEngineHours" label="Общая наработка (ч)" />
|
||||
<NumberInput source="engineHoursSinceLastRepair" label="Наработка с последнего ремонта (ч)" />
|
||||
<DateInput source="lastRepairAt" label="Дата последнего ремонта" />
|
||||
<TextInput source="notes" label="Примечания" multiline />
|
||||
<SelectInput source="status" label="status" choices={statusChoices} emptyText="Не выбрано" />
|
||||
<TextInput source="location" label="location" />
|
||||
<TextInput source="commissionedAt" label="commissionedAt" />
|
||||
<TextInput source="totalEngineHours" label="totalEngineHours" />
|
||||
<TextInput source="engineHoursSinceLastRepair" label="engineHoursSinceLastRepair" />
|
||||
<TextInput source="lastRepairAt" label="lastRepairAt" />
|
||||
<TextInput source="notes" label="notes" />
|
||||
</SimpleForm>
|
||||
</Create>
|
||||
);
|
||||
|
||||
@@ -1,36 +1,29 @@
|
||||
import {
|
||||
Edit,
|
||||
SimpleForm,
|
||||
TextInput,
|
||||
NumberInput,
|
||||
DateInput,
|
||||
SelectInput,
|
||||
ReferenceInput,
|
||||
} from 'react-admin';
|
||||
import { Edit, SimpleForm, TextInput, SelectInput, ReferenceInput, AutocompleteInput } from 'react-admin';
|
||||
|
||||
const statusChoices = [
|
||||
{ id: 'Active', name: 'В эксплуатации' },
|
||||
{ id: 'Repair', name: 'В ремонте' },
|
||||
{ id: 'Reserve', name: 'В резерве' },
|
||||
{ id: 'WriteOff', name: 'Списано' },
|
||||
{ id: 'Active', name: 'Active' },
|
||||
{ id: 'Repair', name: 'Repair' },
|
||||
{ id: 'Reserve', name: 'Reserve' },
|
||||
{ id: 'WriteOff', name: 'WriteOff' },
|
||||
];
|
||||
|
||||
export const EquipmentEdit = () => (
|
||||
<Edit>
|
||||
<SimpleForm>
|
||||
<TextInput source="inventoryNumber" label="Инвентарный номер" isRequired />
|
||||
<TextInput source="serialNumber" label="Заводской номер" />
|
||||
<TextInput source="name" label="Наименование" isRequired />
|
||||
<ReferenceInput source="equipmentTypeCode" reference="equipment-types" label="Вид оборудования">
|
||||
<SelectInput optionText="name" optionValue="code" isRequired />
|
||||
<TextInput source="id" label="id" disabled />
|
||||
<TextInput source="inventoryNumber" label="inventoryNumber" isRequired />
|
||||
<TextInput source="serialNumber" label="serialNumber" />
|
||||
<TextInput source="name" label="name" isRequired />
|
||||
<ReferenceInput source="equipmentTypeCode" reference="equipment-types" label="equipmentTypeCode">
|
||||
<AutocompleteInput optionText={(record) => record.code ? `${record.code} — ${record.name ?? record.code}` : (record.name ?? record.id)} filterToQuery={(searchText) => ({ q: searchText })} />
|
||||
</ReferenceInput>
|
||||
<SelectInput source="status" label="Статус" choices={statusChoices} />
|
||||
<TextInput source="location" label="Место эксплуатации" />
|
||||
<DateInput source="commissionedAt" label="Дата ввода в эксплуатацию" />
|
||||
<NumberInput source="totalEngineHours" label="Общая наработка (ч)" />
|
||||
<NumberInput source="engineHoursSinceLastRepair" label="Наработка с последнего ремонта (ч)" />
|
||||
<DateInput source="lastRepairAt" label="Дата последнего ремонта" />
|
||||
<TextInput source="notes" label="Примечания" multiline />
|
||||
<SelectInput source="status" label="status" choices={statusChoices} emptyText="Не выбрано" />
|
||||
<TextInput source="location" label="location" />
|
||||
<TextInput source="commissionedAt" label="commissionedAt" />
|
||||
<TextInput source="totalEngineHours" label="totalEngineHours" />
|
||||
<TextInput source="engineHoursSinceLastRepair" label="engineHoursSinceLastRepair" />
|
||||
<TextInput source="lastRepairAt" label="lastRepairAt" />
|
||||
<TextInput source="notes" label="notes" />
|
||||
</SimpleForm>
|
||||
</Edit>
|
||||
);
|
||||
|
||||
@@ -2,29 +2,65 @@ import {
|
||||
List,
|
||||
Datagrid,
|
||||
TextField,
|
||||
TextInput,
|
||||
TopToolbar,
|
||||
FilterButton,
|
||||
CreateButton,
|
||||
ExportButton,
|
||||
NumberField,
|
||||
DateField,
|
||||
SelectField,
|
||||
ReferenceField,
|
||||
SelectArrayInput,
|
||||
ReferenceInput,
|
||||
AutocompleteInput
|
||||
} from 'react-admin';
|
||||
|
||||
const statusChoices = [
|
||||
{ id: 'Active', name: 'В эксплуатации' },
|
||||
{ id: 'Repair', name: 'В ремонте' },
|
||||
{ id: 'Reserve', name: 'В резерве' },
|
||||
{ id: 'WriteOff', name: 'Списано' },
|
||||
{ id: 'Active', name: 'Active' },
|
||||
{ id: 'Repair', name: 'Repair' },
|
||||
{ id: 'Reserve', name: 'Reserve' },
|
||||
{ id: 'WriteOff', name: 'WriteOff' },
|
||||
];
|
||||
|
||||
const equipmentFilters = [
|
||||
<TextInput key="q" source="q" label="Поиск" alwaysOn />,
|
||||
<TextInput key="inventoryNumber" source="inventoryNumber" label="inventoryNumber" />,
|
||||
<TextInput key="serialNumber" source="serialNumber" label="serialNumber" />,
|
||||
<TextInput key="name" source="name" label="name" />,
|
||||
<ReferenceInput key="equipmentTypeCode" source="equipmentTypeCode" reference="equipment-types" label="equipmentTypeCode">
|
||||
<AutocompleteInput optionText={(record) => record.code ? `${record.code} — ${record.name ?? record.code}` : (record.name ?? record.id)} filterToQuery={(searchText) => ({ q: searchText })} />
|
||||
</ReferenceInput>,
|
||||
<SelectArrayInput key="status" source="status" label="status" choices={statusChoices} />,
|
||||
<TextInput key="location" source="location" label="location" />,
|
||||
<TextInput key="notes" source="notes" label="notes" />
|
||||
];
|
||||
|
||||
const EquipmentListActions = () => (
|
||||
<TopToolbar>
|
||||
<FilterButton filters={equipmentFilters} />
|
||||
<CreateButton />
|
||||
<ExportButton />
|
||||
</TopToolbar>
|
||||
);
|
||||
|
||||
export const EquipmentList = () => (
|
||||
<List>
|
||||
<List actions={<EquipmentListActions />} filters={equipmentFilters} sort={{ field: 'id', order: 'ASC' }}>
|
||||
<Datagrid rowClick="show">
|
||||
<TextField source="inventoryNumber" label="Инвентарный номер" />
|
||||
<TextField source="name" label="Наименование" />
|
||||
<ReferenceField source="equipmentTypeCode" reference="equipment-types" label="Вид оборудования" link="show">
|
||||
<TextField source="id" label="id" />
|
||||
<TextField source="inventoryNumber" label="inventoryNumber" />
|
||||
<TextField source="serialNumber" label="serialNumber" />
|
||||
<TextField source="name" label="name" />
|
||||
<ReferenceField source="equipmentTypeCode" reference="equipment-types" label="equipmentTypeCode" link="show">
|
||||
<TextField source="name" />
|
||||
</ReferenceField>
|
||||
<SelectField source="status" label="Статус" choices={statusChoices} />
|
||||
<TextField source="location" label="Место эксплуатации" />
|
||||
<NumberField source="totalEngineHours" label="Наработка (ч)" />
|
||||
<SelectField source="status" label="status" choices={statusChoices} />
|
||||
<TextField source="location" label="location" />
|
||||
<DateField source="commissionedAt" label="commissionedAt" />
|
||||
<NumberField source="totalEngineHours" label="totalEngineHours" />
|
||||
<NumberField source="engineHoursSinceLastRepair" label="engineHoursSinceLastRepair" />
|
||||
<DateField source="lastRepairAt" label="lastRepairAt" />
|
||||
<TextField source="notes" label="notes" />
|
||||
</Datagrid>
|
||||
</List>
|
||||
);
|
||||
|
||||
@@ -1,36 +1,20 @@
|
||||
import {
|
||||
Show,
|
||||
SimpleShowLayout,
|
||||
TextField,
|
||||
NumberField,
|
||||
DateField,
|
||||
SelectField,
|
||||
ReferenceField,
|
||||
} from 'react-admin';
|
||||
|
||||
const statusChoices = [
|
||||
{ id: 'Active', name: 'В эксплуатации' },
|
||||
{ id: 'Repair', name: 'В ремонте' },
|
||||
{ id: 'Reserve', name: 'В резерве' },
|
||||
{ id: 'WriteOff', name: 'Списано' },
|
||||
];
|
||||
import { Show, SimpleShowLayout, TextField } from 'react-admin';
|
||||
|
||||
export const EquipmentShow = () => (
|
||||
<Show>
|
||||
<SimpleShowLayout>
|
||||
<TextField source="inventoryNumber" label="Инвентарный номер" />
|
||||
<TextField source="serialNumber" label="Заводской номер" />
|
||||
<TextField source="name" label="Наименование" />
|
||||
<ReferenceField source="equipmentTypeCode" reference="equipment-types" label="Вид оборудования" link="show">
|
||||
<TextField source="name" />
|
||||
</ReferenceField>
|
||||
<SelectField source="status" label="Статус" choices={statusChoices} />
|
||||
<TextField source="location" label="Место эксплуатации" />
|
||||
<DateField source="commissionedAt" label="Дата ввода в эксплуатацию" />
|
||||
<NumberField source="totalEngineHours" label="Общая наработка (ч)" />
|
||||
<NumberField source="engineHoursSinceLastRepair" label="Наработка с последнего ремонта (ч)" />
|
||||
<DateField source="lastRepairAt" label="Дата последнего ремонта" />
|
||||
<TextField source="notes" label="Примечания" />
|
||||
<TextField source="id" label="id" />
|
||||
<TextField source="inventoryNumber" label="inventoryNumber" />
|
||||
<TextField source="serialNumber" label="serialNumber" />
|
||||
<TextField source="name" label="name" />
|
||||
<TextField source="equipmentTypeCode" label="equipmentTypeCode" />
|
||||
<TextField source="status" label="status" />
|
||||
<TextField source="location" label="location" />
|
||||
<TextField source="commissionedAt" label="commissionedAt" />
|
||||
<TextField source="totalEngineHours" label="totalEngineHours" />
|
||||
<TextField source="engineHoursSinceLastRepair" label="engineHoursSinceLastRepair" />
|
||||
<TextField source="lastRepairAt" label="lastRepairAt" />
|
||||
<TextField source="notes" label="notes" />
|
||||
</SimpleShowLayout>
|
||||
</Show>
|
||||
);
|
||||
|
||||
@@ -1,46 +1,38 @@
|
||||
import {
|
||||
Create,
|
||||
SimpleForm,
|
||||
TextInput,
|
||||
NumberInput,
|
||||
DateInput,
|
||||
SelectInput,
|
||||
ReferenceInput,
|
||||
} from 'react-admin';
|
||||
import { Create, SimpleForm, TextInput, SelectInput, ReferenceInput, AutocompleteInput } from 'react-admin';
|
||||
|
||||
const repairKindChoices = [
|
||||
{ id: 'TO', name: 'Техническое обслуживание' },
|
||||
{ id: 'TR', name: 'Текущий ремонт' },
|
||||
{ id: 'TRE', name: 'Текущий расширенный ремонт' },
|
||||
{ id: 'KR', name: 'Капитальный ремонт' },
|
||||
{ id: 'AR', name: 'Аварийный ремонт' },
|
||||
{ id: 'MP', name: 'Метрологическая поверка' },
|
||||
{ id: 'TO', name: 'TO' },
|
||||
{ id: 'TR', name: 'TR' },
|
||||
{ id: 'TRE', name: 'TRE' },
|
||||
{ id: 'KR', name: 'KR' },
|
||||
{ id: 'AR', name: 'AR' },
|
||||
{ id: 'MP', name: 'MP' },
|
||||
];
|
||||
|
||||
const statusChoices = [
|
||||
{ id: 'Draft', name: 'Черновик' },
|
||||
{ id: 'Approved', name: 'Утверждена' },
|
||||
{ id: 'InWork', name: 'В работе' },
|
||||
{ id: 'Done', name: 'Выполнена' },
|
||||
{ id: 'Cancelled', name: 'Отменена' },
|
||||
{ id: 'Draft', name: 'Draft' },
|
||||
{ id: 'Approved', name: 'Approved' },
|
||||
{ id: 'InWork', name: 'InWork' },
|
||||
{ id: 'Done', name: 'Done' },
|
||||
{ id: 'Cancelled', name: 'Cancelled' },
|
||||
];
|
||||
|
||||
export const RepairOrderCreate = () => (
|
||||
<Create>
|
||||
<SimpleForm>
|
||||
<TextInput source="number" label="Номер заявки" isRequired />
|
||||
<ReferenceInput source="equipmentId" reference="equipment" label="Оборудование">
|
||||
<SelectInput optionText="name" isRequired />
|
||||
<TextInput source="number" label="number" isRequired />
|
||||
<ReferenceInput source="equipmentId" reference="equipment" label="equipmentId">
|
||||
<AutocompleteInput optionText={(record) => record.code ? `${record.code} — ${record.name ?? record.code}` : (record.name ?? record.id)} filterToQuery={(searchText) => ({ q: searchText })} />
|
||||
</ReferenceInput>
|
||||
<SelectInput source="repairKind" label="Вид ремонта" choices={repairKindChoices} isRequired />
|
||||
<SelectInput source="status" label="Статус" choices={statusChoices} defaultValue="Draft" />
|
||||
<DateInput source="plannedAt" label="Плановая дата начала" isRequired />
|
||||
<DateInput source="startedAt" label="Фактическая дата начала" />
|
||||
<DateInput source="completedAt" label="Фактическая дата завершения" />
|
||||
<TextInput source="contractor" label="Подрядная организация" />
|
||||
<NumberInput source="engineHoursAtRepair" label="Наработка на момент ремонта (ч)" />
|
||||
<TextInput source="description" label="Описание работ / дефекта" multiline />
|
||||
<TextInput source="notes" label="Примечания" multiline />
|
||||
<SelectInput source="repairKind" label="repairKind" choices={repairKindChoices} emptyText="Не выбрано" />
|
||||
<SelectInput source="status" label="status" choices={statusChoices} emptyText="Не выбрано" />
|
||||
<TextInput source="plannedAt" label="plannedAt" />
|
||||
<TextInput source="startedAt" label="startedAt" />
|
||||
<TextInput source="completedAt" label="completedAt" />
|
||||
<TextInput source="contractor" label="contractor" />
|
||||
<TextInput source="engineHoursAtRepair" label="engineHoursAtRepair" />
|
||||
<TextInput source="description" label="description" />
|
||||
<TextInput source="notes" label="notes" />
|
||||
</SimpleForm>
|
||||
</Create>
|
||||
);
|
||||
|
||||
@@ -1,46 +1,39 @@
|
||||
import {
|
||||
Edit,
|
||||
SimpleForm,
|
||||
TextInput,
|
||||
NumberInput,
|
||||
DateInput,
|
||||
SelectInput,
|
||||
ReferenceInput,
|
||||
} from 'react-admin';
|
||||
import { Edit, SimpleForm, TextInput, SelectInput, ReferenceInput, AutocompleteInput } from 'react-admin';
|
||||
|
||||
const repairKindChoices = [
|
||||
{ id: 'TO', name: 'Техническое обслуживание' },
|
||||
{ id: 'TR', name: 'Текущий ремонт' },
|
||||
{ id: 'TRE', name: 'Текущий расширенный ремонт' },
|
||||
{ id: 'KR', name: 'Капитальный ремонт' },
|
||||
{ id: 'AR', name: 'Аварийный ремонт' },
|
||||
{ id: 'MP', name: 'Метрологическая поверка' },
|
||||
{ id: 'TO', name: 'TO' },
|
||||
{ id: 'TR', name: 'TR' },
|
||||
{ id: 'TRE', name: 'TRE' },
|
||||
{ id: 'KR', name: 'KR' },
|
||||
{ id: 'AR', name: 'AR' },
|
||||
{ id: 'MP', name: 'MP' },
|
||||
];
|
||||
|
||||
const statusChoices = [
|
||||
{ id: 'Draft', name: 'Черновик' },
|
||||
{ id: 'Approved', name: 'Утверждена' },
|
||||
{ id: 'InWork', name: 'В работе' },
|
||||
{ id: 'Done', name: 'Выполнена' },
|
||||
{ id: 'Cancelled', name: 'Отменена' },
|
||||
{ id: 'Draft', name: 'Draft' },
|
||||
{ id: 'Approved', name: 'Approved' },
|
||||
{ id: 'InWork', name: 'InWork' },
|
||||
{ id: 'Done', name: 'Done' },
|
||||
{ id: 'Cancelled', name: 'Cancelled' },
|
||||
];
|
||||
|
||||
export const RepairOrderEdit = () => (
|
||||
<Edit>
|
||||
<SimpleForm>
|
||||
<TextInput source="number" label="Номер заявки" isRequired />
|
||||
<ReferenceInput source="equipmentId" reference="equipment" label="Оборудование">
|
||||
<SelectInput optionText="name" isRequired />
|
||||
<TextInput source="id" label="id" disabled />
|
||||
<TextInput source="number" label="number" isRequired />
|
||||
<ReferenceInput source="equipmentId" reference="equipment" label="equipmentId">
|
||||
<AutocompleteInput optionText={(record) => record.code ? `${record.code} — ${record.name ?? record.code}` : (record.name ?? record.id)} filterToQuery={(searchText) => ({ q: searchText })} />
|
||||
</ReferenceInput>
|
||||
<SelectInput source="repairKind" label="Вид ремонта" choices={repairKindChoices} isRequired />
|
||||
<SelectInput source="status" label="Статус" choices={statusChoices} />
|
||||
<DateInput source="plannedAt" label="Плановая дата начала" isRequired />
|
||||
<DateInput source="startedAt" label="Фактическая дата начала" />
|
||||
<DateInput source="completedAt" label="Фактическая дата завершения" />
|
||||
<TextInput source="contractor" label="Подрядная организация" />
|
||||
<NumberInput source="engineHoursAtRepair" label="Наработка на момент ремонта (ч)" />
|
||||
<TextInput source="description" label="Описание работ / дефекта" multiline />
|
||||
<TextInput source="notes" label="Примечания" multiline />
|
||||
<SelectInput source="repairKind" label="repairKind" choices={repairKindChoices} emptyText="Не выбрано" />
|
||||
<SelectInput source="status" label="status" choices={statusChoices} emptyText="Не выбрано" />
|
||||
<TextInput source="plannedAt" label="plannedAt" />
|
||||
<TextInput source="startedAt" label="startedAt" />
|
||||
<TextInput source="completedAt" label="completedAt" />
|
||||
<TextInput source="contractor" label="contractor" />
|
||||
<TextInput source="engineHoursAtRepair" label="engineHoursAtRepair" />
|
||||
<TextInput source="description" label="description" />
|
||||
<TextInput source="notes" label="notes" />
|
||||
</SimpleForm>
|
||||
</Edit>
|
||||
);
|
||||
|
||||
@@ -2,39 +2,76 @@ import {
|
||||
List,
|
||||
Datagrid,
|
||||
TextField,
|
||||
TextInput,
|
||||
TopToolbar,
|
||||
FilterButton,
|
||||
CreateButton,
|
||||
ExportButton,
|
||||
NumberField,
|
||||
DateField,
|
||||
SelectField,
|
||||
ReferenceField,
|
||||
SelectArrayInput,
|
||||
SelectInput,
|
||||
ReferenceInput,
|
||||
AutocompleteInput
|
||||
} from 'react-admin';
|
||||
|
||||
const repairKindChoices = [
|
||||
{ id: 'TO', name: 'Техническое обслуживание' },
|
||||
{ id: 'TR', name: 'Текущий ремонт' },
|
||||
{ id: 'TRE', name: 'Текущий расширенный ремонт' },
|
||||
{ id: 'KR', name: 'Капитальный ремонт' },
|
||||
{ id: 'AR', name: 'Аварийный ремонт' },
|
||||
{ id: 'MP', name: 'Метрологическая поверка' },
|
||||
{ id: 'TO', name: 'TO' },
|
||||
{ id: 'TR', name: 'TR' },
|
||||
{ id: 'TRE', name: 'TRE' },
|
||||
{ id: 'KR', name: 'KR' },
|
||||
{ id: 'AR', name: 'AR' },
|
||||
{ id: 'MP', name: 'MP' },
|
||||
];
|
||||
|
||||
const statusChoices = [
|
||||
{ id: 'Draft', name: 'Черновик' },
|
||||
{ id: 'Approved', name: 'Утверждена' },
|
||||
{ id: 'InWork', name: 'В работе' },
|
||||
{ id: 'Done', name: 'Выполнена' },
|
||||
{ id: 'Cancelled', name: 'Отменена' },
|
||||
{ id: 'Draft', name: 'Draft' },
|
||||
{ id: 'Approved', name: 'Approved' },
|
||||
{ id: 'InWork', name: 'InWork' },
|
||||
{ id: 'Done', name: 'Done' },
|
||||
{ id: 'Cancelled', name: 'Cancelled' },
|
||||
];
|
||||
|
||||
const repairOrderFilters = [
|
||||
<TextInput key="q" source="q" label="Поиск" alwaysOn />,
|
||||
<TextInput key="number" source="number" label="number" />,
|
||||
<ReferenceInput key="equipmentId" source="equipmentId" reference="equipment" label="equipmentId">
|
||||
<AutocompleteInput optionText={(record) => record.code ? `${record.code} — ${record.name ?? record.code}` : (record.name ?? record.id)} filterToQuery={(searchText) => ({ q: searchText })} />
|
||||
</ReferenceInput>,
|
||||
<SelectInput key="repairKind" source="repairKind" label="repairKind" choices={repairKindChoices} emptyText="Все" />,
|
||||
<SelectArrayInput key="status" source="status" label="status" choices={statusChoices} />,
|
||||
<TextInput key="contractor" source="contractor" label="contractor" />,
|
||||
<TextInput key="description" source="description" label="description" />,
|
||||
<TextInput key="notes" source="notes" label="notes" />
|
||||
];
|
||||
|
||||
const RepairOrderListActions = () => (
|
||||
<TopToolbar>
|
||||
<FilterButton filters={repairOrderFilters} />
|
||||
<CreateButton />
|
||||
<ExportButton />
|
||||
</TopToolbar>
|
||||
);
|
||||
|
||||
export const RepairOrderList = () => (
|
||||
<List>
|
||||
<List actions={<RepairOrderListActions />} filters={repairOrderFilters} sort={{ field: 'id', order: 'ASC' }}>
|
||||
<Datagrid rowClick="show">
|
||||
<TextField source="number" label="Номер" />
|
||||
<ReferenceField source="equipmentId" reference="equipment" label="Оборудование" link="show">
|
||||
<TextField source="id" label="id" />
|
||||
<TextField source="number" label="number" />
|
||||
<ReferenceField source="equipmentId" reference="equipment" label="equipmentId" link="show">
|
||||
<TextField source="name" />
|
||||
</ReferenceField>
|
||||
<SelectField source="repairKind" label="Вид ремонта" choices={repairKindChoices} />
|
||||
<SelectField source="status" label="Статус" choices={statusChoices} />
|
||||
<DateField source="plannedAt" label="Плановая дата" />
|
||||
<TextField source="contractor" label="Подрядчик" />
|
||||
<SelectField source="repairKind" label="repairKind" choices={repairKindChoices} />
|
||||
<SelectField source="status" label="status" choices={statusChoices} />
|
||||
<DateField source="plannedAt" label="plannedAt" />
|
||||
<DateField source="startedAt" label="startedAt" />
|
||||
<DateField source="completedAt" label="completedAt" />
|
||||
<TextField source="contractor" label="contractor" />
|
||||
<NumberField source="engineHoursAtRepair" label="engineHoursAtRepair" />
|
||||
<TextField source="description" label="description" />
|
||||
<TextField source="notes" label="notes" />
|
||||
</Datagrid>
|
||||
</List>
|
||||
);
|
||||
|
||||
@@ -1,46 +1,20 @@
|
||||
import {
|
||||
Show,
|
||||
SimpleShowLayout,
|
||||
TextField,
|
||||
NumberField,
|
||||
DateField,
|
||||
SelectField,
|
||||
ReferenceField,
|
||||
} from 'react-admin';
|
||||
|
||||
const repairKindChoices = [
|
||||
{ id: 'TO', name: 'Техническое обслуживание' },
|
||||
{ id: 'TR', name: 'Текущий ремонт' },
|
||||
{ id: 'TRE', name: 'Текущий расширенный ремонт' },
|
||||
{ id: 'KR', name: 'Капитальный ремонт' },
|
||||
{ id: 'AR', name: 'Аварийный ремонт' },
|
||||
{ id: 'MP', name: 'Метрологическая поверка' },
|
||||
];
|
||||
|
||||
const statusChoices = [
|
||||
{ id: 'Draft', name: 'Черновик' },
|
||||
{ id: 'Approved', name: 'Утверждена' },
|
||||
{ id: 'InWork', name: 'В работе' },
|
||||
{ id: 'Done', name: 'Выполнена' },
|
||||
{ id: 'Cancelled', name: 'Отменена' },
|
||||
];
|
||||
import { Show, SimpleShowLayout, TextField } from 'react-admin';
|
||||
|
||||
export const RepairOrderShow = () => (
|
||||
<Show>
|
||||
<SimpleShowLayout>
|
||||
<TextField source="number" label="Номер заявки" />
|
||||
<ReferenceField source="equipmentId" reference="equipment" label="Оборудование" link="show">
|
||||
<TextField source="name" />
|
||||
</ReferenceField>
|
||||
<SelectField source="repairKind" label="Вид ремонта" choices={repairKindChoices} />
|
||||
<SelectField source="status" label="Статус" choices={statusChoices} />
|
||||
<DateField source="plannedAt" label="Плановая дата начала" />
|
||||
<DateField source="startedAt" label="Фактическая дата начала" />
|
||||
<DateField source="completedAt" label="Фактическая дата завершения" />
|
||||
<TextField source="contractor" label="Подрядная организация" />
|
||||
<NumberField source="engineHoursAtRepair" label="Наработка на момент ремонта (ч)" />
|
||||
<TextField source="description" label="Описание работ / дефекта" />
|
||||
<TextField source="notes" label="Примечания" />
|
||||
<TextField source="id" label="id" />
|
||||
<TextField source="number" label="number" />
|
||||
<TextField source="equipmentId" label="equipmentId" />
|
||||
<TextField source="repairKind" label="repairKind" />
|
||||
<TextField source="status" label="status" />
|
||||
<TextField source="plannedAt" label="plannedAt" />
|
||||
<TextField source="startedAt" label="startedAt" />
|
||||
<TextField source="completedAt" label="completedAt" />
|
||||
<TextField source="contractor" label="contractor" />
|
||||
<TextField source="engineHoursAtRepair" label="engineHoursAtRepair" />
|
||||
<TextField source="description" label="description" />
|
||||
<TextField source="notes" label="notes" />
|
||||
</SimpleShowLayout>
|
||||
</Show>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user