+
@@ -82,7 +103,12 @@ export function FilesList({ files, loading, labelFor }: { files: FileOut[]; load
),
},
- { title: head('Период'), key: 'period', width: 110, render: (_, r) => r.period },
+ {
+ title: head('Период'),
+ key: 'period',
+ width: 110,
+ render: (_, r) => r.period,
+ },
{
title: head('Проверка'),
key: 'check',
@@ -106,6 +132,21 @@ export function FilesList({ files, loading, labelFor }: { files: FileOut[]; load
),
},
+
+ {
+ key: 'actions',
+ title: '',
+ dataIndex: 'action',
+ render: (_, r) => (
+
}
+ onClick={(e) => {
+ e.stopPropagation();
+ onDeleteClick(r);
+ }}
+ />
+ ),
+ },
];
if (loading && files.length === 0) {
@@ -125,7 +166,14 @@ export function FilesList({ files, loading, labelFor }: { files: FileOut[]; load
dataSource={rows}
locale={{ emptyText: 'Документов нет' }}
onRow={(r) => ({
- onClick: r.linkable && r.documentId ? () => navigate(`/documents/${r.documentId}`) : undefined,
+ onClick:
+ r.linkable && r.documentId && r.legalEntityId && r.consolidationId
+ ? () => {
+ navigate(`/documents?consolidation_id=${r.consolidationId}&legal_entity_id=${r.legalEntityId}&document_id=${r.documentId}`);
+ }
+ : () => {
+ message.warning('Просмотр данного документа недоступен');
+ },
style: r.linkable ? { cursor: 'pointer' } : undefined,
})}
/>
diff --git a/src/widgets/FilesDrawer/ReplaceDocModal.tsx b/src/widgets/FilesDrawer/ReplaceDocModal.tsx
new file mode 100644
index 0000000..4b9fa3d
--- /dev/null
+++ b/src/widgets/FilesDrawer/ReplaceDocModal.tsx
@@ -0,0 +1,75 @@
+import React, { useEffect, useState } from 'react';
+import { Modal, Input, Upload, Button } from 'antd';
+import { UploadOutlined, FileAddOutlined } from '@ant-design/icons';
+import { useAppSelector } from '../../store/store';
+
+const { Dragger } = Upload;
+
+export default function ReplaceDocModal({ open, docName, submitting, onCancel, onSubmit }) {
+ const [comment, setComment] = useState('');
+ const [fileList, setFileList] = useState([]);
+ const leName = useAppSelector((s) => s.consolidations.current_legal_entity_name);
+
+ // reset form every time the modal is opened
+ useEffect(() => {
+ if (open) {
+ setComment('');
+ setFileList([]);
+ }
+ }, [open]);
+
+ const handleOk = () => {
+ const file = fileList[0]?.originFileObj ?? fileList[0];
+ onSubmit({ file, comment });
+ };
+
+ return (
+
, // icon is rendered before the text
+ disabled: fileList.length === 0 || comment.length === 0,
+ }}
+ confirmLoading={submitting}>
+
+
{leName}
+
+ Заменяемый документ: {docName}
+
+
+
setComment(e.target.value)} />
+
+
{
+ setFileList([file]);
+ return false;
+ }}
+ onRemove={() => setFileList([])}>
+
+
+
+
+ Перетащите файлы сюда
+
+
+
+
+
+ );
+}
diff --git a/src/widgets/FilesDrawer/documentRows.ts b/src/widgets/FilesDrawer/documentRows.ts
index d5873ee..369e959 100644
--- a/src/widgets/FilesDrawer/documentRows.ts
+++ b/src/widgets/FilesDrawer/documentRows.ts
@@ -20,6 +20,8 @@ export interface DocumentRow {
statusLabel: string;
errorReason: string | null;
linkable: boolean;
+ consolidationId: string | null;
+ legalEntityId: string | null;
/** предупреждения разбора файла (общие для всех документов файла) */
fileWarnings: FileWarningOut[];
mappingWarnings: string[];
@@ -72,6 +74,8 @@ export function buildDocumentRows(files: FileOut[], labelFor?: (f: FileOut) => s
statusLabel: failed ? 'Ошибка' : 'Обработка',
errorReason: errorReason(f),
linkable: false,
+ consolidationId: f.consolidation_id,
+ legalEntityId: f.legal_entity_id,
fileWarnings,
mappingWarnings,
issueCounts: { error: 0, info: 0 },
@@ -86,7 +90,10 @@ export function buildDocumentRows(files: FileOut[], labelFor?: (f: FileOut) => s
const status = documentRowStatus(d.status);
return {
key: d.id,
+ consolidationId: f.consolidation_id,
documentId: d.id,
+ file_id: f.id,
+ legalEntityId: f.legal_entity_id,
name,
fileType: f.file_type,
subtitle: join([typeText, f.file_type, date, extra]),