Добавлена кнопка оповещения ответственных по категориям на странице "Дело скважины"

This commit is contained in:
Александр Сироткин 2022-11-28 05:52:24 +05:00
parent 7acb7ce2b2
commit 7731dfe8e7
2 changed files with 34 additions and 11 deletions

View File

@ -23,7 +23,7 @@ export const HistoryTable = memo(({ category }) => {
async () => {
const result = await WellFinalDocumentsService.getFilesHistoryByIdCategory(well.id, category.idCategory)
if (!result) return
const files = result.file
const files = result.files
files.sort((a, b) => moment(a.uploadDate) - moment(b.uploadDate))
const fileSource = files.map((file) => ({
file,

View File

@ -1,5 +1,6 @@
import { memo, useCallback, useEffect, useMemo, useState } from 'react'
import { Alert, Button } from 'antd'
import { NotificationOutlined } from '@ant-design/icons'
import { Alert, Button, Popconfirm } from 'antd'
import { useWell } from '@asb/context'
import { UserView } from '@components/views'
@ -42,6 +43,17 @@ const WellCase = memo(() => {
)
}, [well])
const notifyPublisher = useCallback((category) => {
invokeWebApiWrapperAsync(
async () => {
await fetch(`/api/WellFinalDocuments/${well.id}/reNotifyPublishers?idCategory=${category.idCategory}`)
},
setIsLoading,
`Не удалось повторно оповестить ответственного по "${category.nameCategory}"`,
{ actionName: `Повторное оповещение ответственного по "${category.nameCategory}"`, well },
)
}, [well])
const columns = useMemo(() => [
makeTextColumn('Категория', 'nameCategory', undefined, undefined, undefined, { width: 300 }),
makeColumn('Файл', 'file', {
@ -49,14 +61,25 @@ const WellCase = memo(() => {
<div className={'file-cell'}>
{file ? <DownloadLink file={file} /> : <span style={{ marginLeft: 15 }}>Файл не загружен</span>}
{category.permissionToUpload && (
<UploadForm
url={`/api/WellFinalDocuments/${well.id}?idCategory=${category.idCategory}`}
onUploadStart={() => setIsLoading(true)}
onUploadComplete={updateTable}
onUploadError={() => setIsLoading(false)}
/>
)}
<div style={{ display: 'flex', gap: 5 }}>
{!file && canEdit && (
<Popconfirm
onConfirm={() => notifyPublisher(category)}
title={'Повторно оповестить ответственного о необходимости подгрузки документа'}
>
<Button icon={<NotificationOutlined />}></Button>
</Popconfirm>
)}
{category.permissionToUpload && (
<UploadForm
url={`/api/WellFinalDocuments/${well.id}?idCategory=${category.idCategory}`}
onUploadStart={() => setIsLoading(true)}
onUploadComplete={updateTable}
onUploadError={() => setIsLoading(false)}
/>
)}
</div>
</div>
),
width: 300,
@ -66,7 +89,7 @@ const WellCase = memo(() => {
render: (publishers) => publishers?.map((user, i) => <UserView key={`${i}`} user={user} style={{ marginLeft: 10 }} />),
width: 200,
}),
], [well, updateTable])
], [well, canEdit, updateTable])
const onEditClose = useCallback((changed = false) => {
setShowEdit(false)