Browse Source

Documents page, WIP

master
cracklesparkle 11 months ago
parent
commit
e70d94afec
  1. 1
      frontend_reactjs/src/components/modals/CreateUserModal.tsx
  2. 102
      frontend_reactjs/src/pages/Documents.tsx
  3. 13
      frontend_reactjs/src/pages/Users.tsx
  4. 4
      frontend_reactjs/src/services/DocumentService.ts

1
frontend_reactjs/src/components/modals/CreateUserModal.tsx

@ -58,7 +58,6 @@ export default function CreateUserModal({
aria-describedby="modal-modal-description"
>
<form onSubmit={handleSubmit(onSubmit)}>
<Box sx={style}>
<Typography variant="h6" component="h6" gutterBottom>
Создание пользователя

102
frontend_reactjs/src/pages/Documents.tsx

@ -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>
)
}

13
frontend_reactjs/src/pages/Users.tsx

@ -24,15 +24,10 @@ export default function Users() {
{
field: 'role_id',
headerName: 'Роль',
valueGetter: (value, row) => {
if (roles) {
const roleName = roles.find((role: IRole) => role.id === value).name
return roleName
} else {
return value
}
},
width: 90
valueOptions: roles ? roles.map((role: IRole) => ({ label: role.name, value: role.id })) : [],
type: 'singleSelect',
width: 90,
editable: true
},
];

4
frontend_reactjs/src/services/DocumentService.ts

@ -100,7 +100,7 @@ export default class DocumentService {
// Upload Files
static async uploadFiles(folder_id: number, files: any) {
return await axiosInstance.post(`/info//documents/upload/${folder_id}`, files)
return await axiosInstance.post(`/info/documents/upload/${folder_id}`, files)
}
// Download Doc
@ -149,7 +149,7 @@ export default class DocumentService {
}
// Get Banks
static async getBanks(bank_id: string, search?: string, limit?: number, offset?: number) {
static async getBanks(bank_id?: string, search?: string, limit?: number, offset?: number) {
return await axiosInstance.get(`/info/organization/banks`, {
params: {
bank_id: bank_id,

Loading…
Cancel
Save