onClose(false)} onOk={onModalOk}>
-
+
+
+
+
+
setCatSearchText(searchText)}
+ onSelect={onAddCategory}
+ placeholder={'Впишите категорию для добавления'}
+ />
+
+
+
cat.idCategory === selectedCatId)?.idsPublishers ?? []}
+ render={(item) => (
+
+ )}
+ />
+
+
)
})
diff --git a/src/pages/WellCase/index.jsx b/src/pages/WellCase/index.jsx
index 0fcbed3..e55653e 100644
--- a/src/pages/WellCase/index.jsx
+++ b/src/pages/WellCase/index.jsx
@@ -7,64 +7,77 @@ import DownloadLink from '@components/DownloadLink'
import LoaderPortal from '@components/LoaderPortal'
import { invokeWebApiWrapperAsync } from '@components/factory'
import { makeColumn, makeDateColumn, makeTextColumn, Table } from '@components/Table'
-import { delay, wrapPrivateComponent } from '@utils'
+import { WellFinalDocumentsService } from '@api'
+import { MimeTypes, wrapPrivateComponent } from '@utils'
import WellCaseEditor from './WellCaseEditor'
import { HistoryTable } from './HistoryTable'
+import UploadForm from '@asb/components/UploadForm'
-const columns = [
- makeTextColumn('Категория', 'caption'),
- makeColumn('Файл', 'file', {
- render: (file) => file ? (
-
- ) : (
- Файл не загружен
- ),
- }),
- makeDateColumn('Дата загрузки', 'uploadDate'),
- makeColumn('Ответственные', 'responsible', {
- render: (responsible) => responsible.map((user) => (
-
- )),
- }),
-]
+const expandable = {
+ expandedRowRender: (category) => (
+
+ )
+}
const WellCase = memo(() => {
const [isLoading, setIsLoading] = useState(false)
const [categories, setCategories] = useState([])
const [canEdit, setCanEdit] = useState(false)
const [showEdit, setShowEdit] = useState(false)
- const [users, setUsers] = useState([])
const [well] = useWell()
const updateTable = useCallback(() => {
invokeWebApiWrapperAsync(
async () => {
- await delay(1000)
- const categories = [{ responsible: [{}] }]
+ const { permissionToSetPubliher, wellFinalDocuments } = await WellFinalDocumentsService.get(well.id)
- setCanEdit(true)
- const showingCategories = categories.filter((cat) => cat.responsible && cat.responsible?.length > 0)
- setCategories(showingCategories)
+ setCategories(wellFinalDocuments.map((cat) => ({ ...cat, uploadDate: cat.file?.uploadDate })))
+ setCanEdit(permissionToSetPubliher)
},
setIsLoading,
'Не удалось загрузить список категорий',
+ { actionName: 'Загрузка списка категорий', well }
)
}, [well])
+ const columns = useMemo(() => [
+ makeTextColumn('Категория', 'nameCategory'),
+ makeColumn('Файл', 'file', {
+ render: (file, category) => (
+
+ {file ? (
+
+ ) : (
+ Файл не загружен
+ )}
+
+ {category.permissionToUpload && (
+ setIsLoading(true)}
+ onUploadComplete={updateTable}
+ onUploadError={() => setIsLoading(false)}
+ />
+ )}
+
+ ),
+ }),
+ makeDateColumn('Дата загрузки', 'uploadDate'),
+ makeColumn('Ответственные', 'publishers', {
+ render: (publishers) => publishers?.map((user) => (
+
+ )),
+ }),
+ ], [well, updateTable])
+
const onEditClose = useCallback((changed = false) => {
setShowEdit(false)
if (changed) updateTable()
}, [updateTable])
- const expandable = useMemo(() => ({
- expandedRowRender: (category) => (
-
- )
- }), [users])
-
- useEffect(() => updateTable(), [updateTable])
+ useEffect(updateTable, [updateTable])
return (
<>
@@ -80,7 +93,7 @@ const WellCase = memo(() => {
expandable={expandable}
/>
-
+
>
)
})
@@ -89,4 +102,5 @@ export default wrapPrivateComponent(WellCase, {
title: 'Дело скважины',
route: 'well_case',
requirements: [],
+ // requirements: ['WellFinalDocuments.get'],
})