|
|
@ -1,16 +1,71 @@ |
|
|
|
import React, { useEffect, useState } from 'react' |
|
|
|
import React, { useState } from 'react' |
|
|
|
import DocumentService from '../services/DocumentService' |
|
|
|
import { Box, Button } from '@mui/material' |
|
|
|
import { Box, Button, Typography } from '@mui/material' |
|
|
|
import { GridColDef } from '@mui/x-data-grid' |
|
|
|
import DataTable from '../components/DataTable' |
|
|
|
|
|
|
|
export default function Documents() { |
|
|
|
const [data, setData] = useState() |
|
|
|
const [companies, setCompanies] = useState() |
|
|
|
const [departments, setDepartments] = useState() |
|
|
|
const [organizations, setOrganizations] = useState() |
|
|
|
const [banks, setBanks] = useState() |
|
|
|
|
|
|
|
const [documents, setDocuments] = useState() |
|
|
|
|
|
|
|
const fetchData = async () => { |
|
|
|
await DocumentService.getCompanies().then(response => { |
|
|
|
setCompanies(response.data) |
|
|
|
}) |
|
|
|
|
|
|
|
await DocumentService.getOrganizations().then(response => { |
|
|
|
setOrganizations(response.data) |
|
|
|
}) |
|
|
|
|
|
|
|
await DocumentService.getDepartments().then(response => { |
|
|
|
setDepartments(response.data) |
|
|
|
}) |
|
|
|
|
|
|
|
await DocumentService.getBanks().then(response => { |
|
|
|
setBanks(response.data) |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
const fetchDocuments = async () => { |
|
|
|
await DocumentService.getDocuments().then(response => { |
|
|
|
setData(response.data) |
|
|
|
setDocuments(response.data) |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
const organizationColumns: GridColDef[] = [ |
|
|
|
{ field: 'id', headerName: 'ID', type: "number", width: 90 }, |
|
|
|
{ field: 'id_1c', headerName: 'ID 1C', type: "string", width: 90 }, |
|
|
|
{ field: 'name', headerName: 'Наименование', type: "string", width: 90 }, |
|
|
|
{ field: 'full_name', headerName: 'Полное наименование', type: "string", width: 90 }, |
|
|
|
{ field: 'inn', headerName: 'ИНН', type: "string", width: 70 }, |
|
|
|
{ field: 'ogrn', headerName: 'ОГРН', width: 130 }, |
|
|
|
{ field: 'kpp', headerName: 'КПП', width: 130 }, |
|
|
|
{ field: 'okopf', headerName: 'ОКОПФ', width: 90 }, |
|
|
|
{ field: 'legal_address', headerName: 'Юридический адрес', width: 90 }, |
|
|
|
{ field: 'actual_address', headerName: 'Фактический адрес', width: 90 }, |
|
|
|
{ field: 'mail_address', headerName: 'Почтовый адрес', type: "string", width: 90 }, |
|
|
|
{ field: 'id_budget', headerName: 'Активен', type: "number", width: 90 }, |
|
|
|
{ field: 'fio_dir', headerName: 'Активен', type: "string", width: 90 }, |
|
|
|
{ field: 'phone', headerName: 'Телефон', type: "string", width: 90 }, |
|
|
|
{ field: 'email', headerName: 'Email', type: "string", width: 90 }, |
|
|
|
{ field: 'comment', headerName: 'Комментарий', type: "string", width: 90 }, |
|
|
|
{ field: 'id_bank', headerName: 'Банк', type: "string", width: 90 }, |
|
|
|
{ field: 'active', headerName: 'Активен', type: "boolean", width: 90 }, |
|
|
|
]; |
|
|
|
|
|
|
|
const bankColumns: GridColDef[] = [ |
|
|
|
{ field: 'id', headerName: 'ID', type: "number", width: 90 }, |
|
|
|
{ field: 'id_1c', headerName: 'ID 1C', type: "string", width: 90 }, |
|
|
|
{ field: 'name', headerName: 'Наименование', type: "string", width: 90 }, |
|
|
|
{ field: 'bik', headerName: 'БИК', type: "string", width: 90 }, |
|
|
|
{ field: 'corschet', headerName: 'Кор. счет', type: "string", width: 70 }, |
|
|
|
{ field: 'activ', headerName: 'Активен', type: "boolean", width: 130 }, |
|
|
|
]; |
|
|
|
|
|
|
|
return ( |
|
|
|
<div> |
|
|
|
<Button onClick={() => { |
|
|
@ -20,8 +75,45 @@ export default function Documents() { |
|
|
|
</Button> |
|
|
|
|
|
|
|
<Box> |
|
|
|
{JSON.stringify(data)} |
|
|
|
<Typography variant='h6'> |
|
|
|
Companies |
|
|
|
</Typography> |
|
|
|
{JSON.stringify(companies)} |
|
|
|
</Box> |
|
|
|
|
|
|
|
<Box> |
|
|
|
<Typography variant='h6'> |
|
|
|
Organizations |
|
|
|
</Typography> |
|
|
|
{organizations && |
|
|
|
<DataTable columns={organizationColumns} rows={organizations} /> |
|
|
|
} |
|
|
|
</Box> |
|
|
|
|
|
|
|
<Box> |
|
|
|
<Typography variant='h6'> |
|
|
|
Departments |
|
|
|
</Typography> |
|
|
|
{JSON.stringify(departments)} |
|
|
|
</Box> |
|
|
|
|
|
|
|
<Box> |
|
|
|
<Typography variant='h6'> |
|
|
|
Get banks |
|
|
|
</Typography> |
|
|
|
{banks && |
|
|
|
<DataTable columns={bankColumns} rows={banks} /> |
|
|
|
} |
|
|
|
</Box> |
|
|
|
|
|
|
|
|
|
|
|
<Button onClick={() => { |
|
|
|
fetchDocuments() |
|
|
|
}}> |
|
|
|
Get documents |
|
|
|
</Button> |
|
|
|
|
|
|
|
{JSON.stringify(documents)} |
|
|
|
</div> |
|
|
|
) |
|
|
|
} |