forked from ddrilling/asb_cloud_front
Формат даты исправлен
This commit is contained in:
parent
de72f13bac
commit
e82868bd2e
@ -1,15 +1,15 @@
|
|||||||
import {Table, Select, DatePicker, Input} from 'antd';
|
import { Table, Select, DatePicker, Input } from 'antd'
|
||||||
import { useState, useEffect } from 'react'
|
import { useState, useEffect } from 'react'
|
||||||
import moment from 'moment'
|
import moment from 'moment'
|
||||||
|
|
||||||
import { MessageService } from '../services/api'
|
import { MessageService } from '../services/api'
|
||||||
import LoaderPortal from '../components/LoaderPortal'
|
import LoaderPortal from '../components/LoaderPortal'
|
||||||
import { notify } from "../components/factory"
|
import { notify } from '../components/factory'
|
||||||
import '../styles/message.css'
|
import '../styles/message.css'
|
||||||
|
|
||||||
const { Option } = Select
|
const { Option } = Select
|
||||||
const pageSize = 26
|
const pageSize = 26
|
||||||
const {RangePicker} = DatePicker;
|
const { RangePicker } = DatePicker
|
||||||
const { Search } = Input
|
const { Search } = Input
|
||||||
|
|
||||||
// Словарь категорий для строк таблицы
|
// Словарь категорий для строк таблицы
|
||||||
@ -24,33 +24,29 @@ const columns = [
|
|||||||
title: 'Дата',
|
title: 'Дата',
|
||||||
key: 'date',
|
key: 'date',
|
||||||
dataIndex: 'date',
|
dataIndex: 'date',
|
||||||
render: (item) => moment(item).format('DD MMM YYYY, HH:MM:ss'),
|
render: item => moment(item).format('DD MMM YYYY, HH:mm:ss'),
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
title: 'Глубина',
|
title: 'Глубина',
|
||||||
key: 'wellDepth',
|
key: 'wellDepth',
|
||||||
dataIndex: 'wellDepth',
|
dataIndex: 'wellDepth',
|
||||||
render: (_, item) => <span>{_} м.</span>,
|
render: depth => <span>{depth.toFixed(2)} м.</span>,
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
title: 'Категория',
|
title: 'Категория',
|
||||||
key: 'categoryId',
|
key: 'categoryId',
|
||||||
dataIndex: 'categoryId',
|
dataIndex: 'categoryId',
|
||||||
render: (_, item) => categoryDictionary[item.categoryId].title,
|
render: (_, item) => categoryDictionary[item.categoryId].title,
|
||||||
style: (_, item) => categoryDictionary[item.categoryId].style,
|
style: (_, item) => categoryDictionary[item.categoryId].style,
|
||||||
ellipsis: true,
|
ellipsis: true,
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
title: 'Сообщение',
|
title: 'Сообщение',
|
||||||
key: 'message',
|
key: 'message',
|
||||||
dataIndex: 'message',
|
dataIndex: 'message',
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
title: 'Пользователь',
|
title: 'Пользователь',
|
||||||
key: 'user',
|
key: 'user',
|
||||||
dataIndex: 'user',
|
dataIndex: 'user',
|
||||||
},
|
},
|
||||||
];
|
]
|
||||||
|
|
||||||
const filterOptions = [
|
const filterOptions = [
|
||||||
{label: 'Важное', value: 1},
|
{label: 'Важное', value: 1},
|
||||||
@ -70,29 +66,15 @@ export default function Messages({idWell}) {
|
|||||||
|
|
||||||
const children = filterOptions.map((line) => <Option key={line.value}>{line.label}</Option>)
|
const children = filterOptions.map((line) => <Option key={line.value}>{line.label}</Option>)
|
||||||
|
|
||||||
const onChangeRange = (range) => {
|
const onChangeRange = (range) => setRange(range)
|
||||||
setRange(range)
|
const onChangeSearchString = (message) => setSearchString(message.length > 2 ? message : '')
|
||||||
}
|
|
||||||
|
|
||||||
const onChangeSearchString = (message) => {
|
|
||||||
if (message.length < 3) {
|
|
||||||
setSearchString('')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
setSearchString(message)
|
|
||||||
}
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const GetMessages = async () => {
|
const GetMessages = async () => {
|
||||||
setShowLoader(true)
|
setShowLoader(true)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let begin = null
|
const [begin, end] = range?.length > 1 ? [range[0].toISOString(), range[1].toISOString()] : [null, null]
|
||||||
let end = null
|
|
||||||
if (range?.length > 1) {
|
|
||||||
begin = range[0].toISOString()
|
|
||||||
end = range[1].toISOString()
|
|
||||||
}
|
|
||||||
let paginatedMessages = await MessageService.getMessages(idWell,
|
let paginatedMessages = await MessageService.getMessages(idWell,
|
||||||
(page - 1) * pageSize,
|
(page - 1) * pageSize,
|
||||||
pageSize,
|
pageSize,
|
||||||
@ -106,14 +88,12 @@ export default function Messages({idWell}) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
setMessages(paginatedMessages.items.map(m => {
|
setMessages(paginatedMessages.items.map(m => ({
|
||||||
return {
|
|
||||||
key: m.id,
|
key: m.id,
|
||||||
categoryids: categoryDictionary[m.categoryId],
|
categoryids: categoryDictionary[m.categoryId],
|
||||||
begin: m.date,
|
begin: m.date,
|
||||||
...m
|
...m
|
||||||
}
|
})))
|
||||||
}))
|
|
||||||
setPagination({
|
setPagination({
|
||||||
total: paginatedMessages.count,
|
total: paginatedMessages.count,
|
||||||
current: Math.floor(paginatedMessages.skip / pageSize),
|
current: Math.floor(paginatedMessages.skip / pageSize),
|
||||||
@ -133,10 +113,10 @@ export default function Messages({idWell}) {
|
|||||||
<div className='filter-group'>
|
<div className='filter-group'>
|
||||||
<h3 className='filter-group-heading'>Фильтр сообщений</h3>
|
<h3 className='filter-group-heading'>Фильтр сообщений</h3>
|
||||||
<Select
|
<Select
|
||||||
mode="multiple"
|
mode={'multiple'}
|
||||||
allowClear
|
allowClear
|
||||||
placeholder="Фильтр сообщений"
|
placeholder={'Фильтр сообщений'}
|
||||||
className="filter-selector"
|
className={'filter-selector'}
|
||||||
value={categories}
|
value={categories}
|
||||||
onChange={setCategories}>
|
onChange={setCategories}>
|
||||||
{children}
|
{children}
|
||||||
@ -146,8 +126,8 @@ export default function Messages({idWell}) {
|
|||||||
onChange={onChangeRange}
|
onChange={onChangeRange}
|
||||||
/>
|
/>
|
||||||
<Search
|
<Search
|
||||||
className="filter-selector"
|
className={'filter-selector'}
|
||||||
placeholder="Фильтр сообщений по тексту"
|
placeholder={'Фильтр сообщений по тексту'}
|
||||||
onSearch={onChangeSearchString}
|
onSearch={onChangeSearchString}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user