компания необзятаельна
This commit is contained in:
@@ -39,7 +39,7 @@ function toFormState(editing: TemplateRoute | undefined, initialRequestTypeId: s
|
||||
}
|
||||
return {
|
||||
requestTypeId: String(editing.requestTypeId),
|
||||
companyId: editing.companyId,
|
||||
companyId: editing.companyId ?? '',
|
||||
departmentId: editing.departmentId ?? '',
|
||||
byProject: editing.byProject,
|
||||
requiresControl: editing.requiresControl
|
||||
@@ -73,22 +73,19 @@ export const RouteFormModal: React.FC<IRouteFormModalProps> = ({
|
||||
submit.fail(texts.routes.validationRequestType);
|
||||
return;
|
||||
}
|
||||
if (!form.companyId.trim()) {
|
||||
submit.fail(texts.routes.validationCompany);
|
||||
return;
|
||||
}
|
||||
|
||||
const companyId = form.companyId.trim() ? form.companyId.trim() : null;
|
||||
const departmentId = form.departmentId.trim() ? form.departmentId.trim() : null;
|
||||
const request = editing
|
||||
? api.templateRoutes.update(editing.id, {
|
||||
companyId: form.companyId.trim(),
|
||||
companyId,
|
||||
departmentId,
|
||||
byProject: form.byProject,
|
||||
requiresControl: form.requiresControl
|
||||
})
|
||||
: api.templateRoutes.create({
|
||||
requestTypeId: Number(form.requestTypeId),
|
||||
companyId: form.companyId.trim(),
|
||||
companyId,
|
||||
departmentId,
|
||||
byProject: form.byProject,
|
||||
requiresControl: form.requiresControl
|
||||
@@ -120,11 +117,13 @@ export const RouteFormModal: React.FC<IRouteFormModalProps> = ({
|
||||
onChange={e => setForm({ ...form, requestTypeId: e.target.value })}
|
||||
/>
|
||||
</Field>
|
||||
<Field label={texts.routes.companyLabel} required full hint={texts.routes.companyHint}>
|
||||
<Field label={texts.routes.companyLabel} full hint={texts.routes.companyHint}>
|
||||
<SearchableSelect
|
||||
options={companies.map(c => ({ value: c.id, label: c.name }))}
|
||||
value={form.companyId}
|
||||
loading={dictionaryLoading}
|
||||
allowClear
|
||||
clearLabel={texts.routes.companyClear}
|
||||
placeholder={texts.routes.companyPlaceholder}
|
||||
searchPlaceholder={texts.routes.companySearchPlaceholder}
|
||||
onChange={companyId =>
|
||||
|
||||
@@ -92,7 +92,7 @@ export const RoutesScreen: React.FC<IRoutesScreenProps> = ({ api, dictionary, on
|
||||
header: texts.routes.columnRequestType,
|
||||
render: r => <PrimaryCell>{requestTypeName(r.requestTypeId)}</PrimaryCell>
|
||||
},
|
||||
{ key: 'company', header: texts.routes.columnCompany, render: r => companyName(r.companyId) },
|
||||
{ key: 'company', header: texts.routes.columnCompany, render: r => (r.companyId ? companyName(r.companyId) : texts.common.empty) },
|
||||
{ key: 'department', header: texts.routes.columnDepartment, render: r => (r.departmentId ? departmentName(r.departmentId) : texts.common.empty) },
|
||||
{
|
||||
key: 'byProject',
|
||||
|
||||
@@ -4,7 +4,8 @@ export interface TemplateRoute {
|
||||
id: number;
|
||||
requestTypeId: number;
|
||||
departmentId: string | null;
|
||||
companyId: string;
|
||||
/** Опционально — маршрут без компании служит запасным вариантом при resolve. */
|
||||
companyId: string | null;
|
||||
byProject: boolean;
|
||||
requiresControl: boolean;
|
||||
}
|
||||
@@ -12,7 +13,7 @@ export interface TemplateRoute {
|
||||
export interface CreateTemplateRouteInput {
|
||||
requestTypeId: number;
|
||||
departmentId: string | null;
|
||||
companyId: string;
|
||||
companyId: string | null;
|
||||
byProject: boolean;
|
||||
requiresControl: boolean;
|
||||
}
|
||||
@@ -20,14 +21,14 @@ export interface CreateTemplateRouteInput {
|
||||
// Тип заявки у существующего маршрута не меняется — его нет в update-контракте.
|
||||
export interface UpdateTemplateRouteInput {
|
||||
departmentId: string | null;
|
||||
companyId: string;
|
||||
companyId: string | null;
|
||||
byProject: boolean;
|
||||
requiresControl: boolean;
|
||||
}
|
||||
|
||||
export interface PatchTemplateRouteInput {
|
||||
departmentId?: string | null;
|
||||
companyId?: string;
|
||||
companyId?: string | null;
|
||||
byProject?: boolean;
|
||||
requiresControl?: boolean;
|
||||
}
|
||||
|
||||
@@ -152,9 +152,10 @@ export const texts = {
|
||||
requestTypeLabel: 'Тип заявки',
|
||||
requestTypePlaceholder: 'Выберите тип заявки',
|
||||
companyLabel: 'Компания',
|
||||
companyHint: 'Справочник 1С (api.tnsu.kz).',
|
||||
companyPlaceholder: 'Выберите компанию',
|
||||
companyHint: 'Необязательно — пусто означает запасной маршрут, если для компании инициатора своего маршрута нет.',
|
||||
companyPlaceholder: 'Без компании (запасной маршрут)',
|
||||
companySearchPlaceholder: 'Поиск по названию компании...',
|
||||
companyClear: 'Без компании (запасной маршрут)',
|
||||
departmentLabel: 'Отдел',
|
||||
departmentHint: 'Необязательно — пусто означает маршрут «по умолчанию» для всей компании.',
|
||||
departmentHintNoCompany: 'Сначала выберите компанию.',
|
||||
@@ -166,7 +167,6 @@ export const texts = {
|
||||
controlLabel: 'Контроль',
|
||||
controlCheckbox: 'Требуется отдельный контроль исполнения',
|
||||
validationRequestType: 'Выберите тип заявки.',
|
||||
validationCompany: 'Компания обязательна (Guid из справочника api.tnsu.kz).',
|
||||
deleteTitle: 'Удалить маршрут?',
|
||||
deleteText: (routeId: number): string =>
|
||||
`Маршрут #${routeId} и все его шаги будут удалены безвозвратно.`
|
||||
|
||||
Reference in New Issue
Block a user