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

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 () => { async () => {
const result = await WellFinalDocumentsService.getFilesHistoryByIdCategory(well.id, category.idCategory) const result = await WellFinalDocumentsService.getFilesHistoryByIdCategory(well.id, category.idCategory)
if (!result) return if (!result) return
const files = result.file const files = result.files
files.sort((a, b) => moment(a.uploadDate) - moment(b.uploadDate)) files.sort((a, b) => moment(a.uploadDate) - moment(b.uploadDate))
const fileSource = files.map((file) => ({ const fileSource = files.map((file) => ({
file, file,

View File

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