forked from VinokurovVE/tests
Documents page, WIP
This commit is contained in:
@ -58,7 +58,6 @@ export default function CreateUserModal({
|
|||||||
aria-describedby="modal-modal-description"
|
aria-describedby="modal-modal-description"
|
||||||
>
|
>
|
||||||
<form onSubmit={handleSubmit(onSubmit)}>
|
<form onSubmit={handleSubmit(onSubmit)}>
|
||||||
|
|
||||||
<Box sx={style}>
|
<Box sx={style}>
|
||||||
<Typography variant="h6" component="h6" gutterBottom>
|
<Typography variant="h6" component="h6" gutterBottom>
|
||||||
Создание пользователя
|
Создание пользователя
|
||||||
|
@ -1,16 +1,71 @@
|
|||||||
import React, { useEffect, useState } from 'react'
|
import React, { useState } from 'react'
|
||||||
import DocumentService from '../services/DocumentService'
|
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() {
|
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 () => {
|
const fetchData = async () => {
|
||||||
await DocumentService.getDocuments().then(response => {
|
await DocumentService.getCompanies().then(response => {
|
||||||
setData(response.data)
|
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 => {
|
||||||
|
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 (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<Button onClick={() => {
|
<Button onClick={() => {
|
||||||
@ -20,8 +75,45 @@ export default function Documents() {
|
|||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
<Box>
|
<Box>
|
||||||
{JSON.stringify(data)}
|
<Typography variant='h6'>
|
||||||
|
Companies
|
||||||
|
</Typography>
|
||||||
|
{JSON.stringify(companies)}
|
||||||
</Box>
|
</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>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
@ -15,24 +15,19 @@ export default function Users() {
|
|||||||
|
|
||||||
const columns: GridColDef[] = [
|
const columns: GridColDef[] = [
|
||||||
{ field: 'id', headerName: 'ID', type: "number", width: 70 },
|
{ field: 'id', headerName: 'ID', type: "number", width: 70 },
|
||||||
{ field: 'email', headerName: 'Email', width: 130, editable: true},
|
{ field: 'email', headerName: 'Email', width: 130, editable: true },
|
||||||
{ field: 'login', headerName: 'Логин', width: 130, editable: true },
|
{ field: 'login', headerName: 'Логин', width: 130, editable: true },
|
||||||
{ field: 'phone', headerName: 'Телефон', width: 90, editable: true },
|
{ field: 'phone', headerName: 'Телефон', width: 90, editable: true },
|
||||||
{ field: 'name', headerName: 'Имя', width: 90, editable: true },
|
{ field: 'name', headerName: 'Имя', width: 90, editable: true },
|
||||||
{ field: 'surname', headerName: 'Фамилия', width: 90, editable: true },
|
{ field: 'surname', headerName: 'Фамилия', width: 90, editable: true },
|
||||||
{ field: 'is_active', headerName: 'Активен', type: "boolean", width: 90, editable: true},
|
{ field: 'is_active', headerName: 'Активен', type: "boolean", width: 90, editable: true },
|
||||||
{
|
{
|
||||||
field: 'role_id',
|
field: 'role_id',
|
||||||
headerName: 'Роль',
|
headerName: 'Роль',
|
||||||
valueGetter: (value, row) => {
|
valueOptions: roles ? roles.map((role: IRole) => ({ label: role.name, value: role.id })) : [],
|
||||||
if (roles) {
|
type: 'singleSelect',
|
||||||
const roleName = roles.find((role: IRole) => role.id === value).name
|
width: 90,
|
||||||
return roleName
|
editable: true
|
||||||
} else {
|
|
||||||
return value
|
|
||||||
}
|
|
||||||
},
|
|
||||||
width: 90
|
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ export default class DocumentService {
|
|||||||
|
|
||||||
// Upload Files
|
// Upload Files
|
||||||
static async uploadFiles(folder_id: number, files: any) {
|
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
|
// Download Doc
|
||||||
@ -149,7 +149,7 @@ export default class DocumentService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get Banks
|
// 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`, {
|
return await axiosInstance.get(`/info/organization/banks`, {
|
||||||
params: {
|
params: {
|
||||||
bank_id: bank_id,
|
bank_id: bank_id,
|
||||||
|
Reference in New Issue
Block a user