feat: добавил поле организация во все заявки, а также расширил компонет выбора даты для ui-kit
This commit is contained in:
@@ -36,6 +36,7 @@ import {
|
||||
IAttachmentInfo
|
||||
} from '../../shared/attachments/attachments.service';
|
||||
import { effectiveUserEmail } from '../../shared/impersonation';
|
||||
import { getEmployeeOrganizations, formatEmployeeOrganizations } from '../../shared/dictionary';
|
||||
import { friendlyErrorMessage } from '../../shared/diagnostics';
|
||||
import { IRequestFormProps } from '../../models/types';
|
||||
import {
|
||||
@@ -77,15 +78,28 @@ const TmcTransferForm: React.FC<IRequestFormProps> = ({
|
||||
}
|
||||
const user = context.pageContext.user;
|
||||
const today = new Date().toISOString().slice(0, 10);
|
||||
const requesterEmail = effectiveUserEmail(context);
|
||||
setData((prev) => ({
|
||||
...prev,
|
||||
// email — через effectiveUserEmail (учитывает отладочную подмену личности);
|
||||
// displayName подменить нечем, справочник ФИО тут не читается — при
|
||||
// подмене имя останется настоящим, для отладки это неважно.
|
||||
RequesterEmail: effectiveUserEmail(context),
|
||||
RequesterEmail: requesterEmail,
|
||||
AuthorName: user.displayName || '',
|
||||
RequestDate: prev.RequestDate || today
|
||||
}));
|
||||
// Организации заявителя (Employee/ByEmail) — read-only, см. shared/ui/OrganizationField.
|
||||
let alive = true;
|
||||
getEmployeeOrganizations(context, requesterEmail)
|
||||
.then((records) => {
|
||||
if (alive) {
|
||||
setData((prev) => ({ ...prev, Organization: formatEmployeeOrganizations(records) }));
|
||||
}
|
||||
})
|
||||
.catch(() => undefined);
|
||||
return () => {
|
||||
alive = false;
|
||||
};
|
||||
}, [editId, context]);
|
||||
|
||||
// Открыта СВОЯ заявка на редактирование — подгружаем содержимое, статус и вложения.
|
||||
|
||||
@@ -38,6 +38,7 @@ export async function loadTmcTransferRequest(itemId: number, listId?: string): P
|
||||
'Recipient',
|
||||
'RequesterEmail',
|
||||
'AuthorName',
|
||||
'Organization',
|
||||
'Subject',
|
||||
'RequestDate',
|
||||
'SourceProject',
|
||||
@@ -60,6 +61,7 @@ export async function loadTmcTransferRequest(itemId: number, listId?: string): P
|
||||
Recipient: (item.Recipient as string) || '',
|
||||
RequesterEmail: (item.RequesterEmail as string) || '',
|
||||
AuthorName: (item.AuthorName as string) || '',
|
||||
Organization: (item.Organization as string) || '',
|
||||
Subject: (item.Subject as string) || '',
|
||||
RequestDate: requestDate.slice(0, 10), // ISO → YYYY-MM-DD для input type=date
|
||||
SourceProject: (item.SourceProject as string) || '',
|
||||
|
||||
@@ -20,6 +20,12 @@ export interface IFormData {
|
||||
// NB: не «Author» — это зарезервированное системное имя колонки SP (Created By).
|
||||
RequesterEmail: string; // От — email заявителя (текущий пользователь)
|
||||
AuthorName: string; // От — Ф.И.О. заявителя (для печати)
|
||||
/**
|
||||
* Организации заявителя (`\n`-joined «Компания — должность» на строку) —
|
||||
* подтягивается автоматически из Employee/ByEmail, read-only (см.
|
||||
* shared/ui/OrganizationField).
|
||||
*/
|
||||
Organization: string;
|
||||
Subject: string; // Тема (по умолч. «Перемещение ТМЦ»)
|
||||
RequestDate: string; // Дата (YYYY-MM-DD)
|
||||
|
||||
@@ -58,6 +64,7 @@ export const EMPTY_DATA: IFormData = {
|
||||
Recipient: DEFAULT_RECIPIENT,
|
||||
RequesterEmail: '',
|
||||
AuthorName: '',
|
||||
Organization: '',
|
||||
Subject: DEFAULT_SUBJECT,
|
||||
RequestDate: '',
|
||||
SourceProject: '',
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
{ "internalName": "Recipient", "title": "Кому", "type": "Text" },
|
||||
{ "internalName": "RequesterEmail", "title": "От (email заявителя)", "type": "Text" },
|
||||
{ "internalName": "AuthorName", "title": "От (Ф.И.О.)", "type": "Text" },
|
||||
{ "internalName": "Organization", "title": "Организация", "type": "Note" },
|
||||
{ "internalName": "Subject", "title": "Тема", "type": "Text" },
|
||||
{ "internalName": "RequestDate", "title": "Дата", "type": "DateTime", "dateOnly": true },
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import * as React from 'react';
|
||||
import { FormGrid, FormField, TextInput, TextArea } from '../../../shared/ui';
|
||||
import { FormGrid, FormField, TextInput, TextArea, OrganizationField } from '../../../shared/ui';
|
||||
import { ProjectPicker } from '../../../shared/dictionary';
|
||||
import { ISectionProps } from '../model';
|
||||
|
||||
@@ -9,6 +9,7 @@ import { ISectionProps } from '../model';
|
||||
*/
|
||||
export const HeaderSection: React.FC<ISectionProps> = ({ data, set, context }) => (
|
||||
<FormGrid>
|
||||
<OrganizationField value={data.Organization} />
|
||||
<FormField label="Откуда (проект-источник)" htmlFor="SourceProject" required>
|
||||
<ProjectPicker
|
||||
id="SourceProject"
|
||||
|
||||
Reference in New Issue
Block a user