This commit is contained in:
Фролов 2021-08-30 16:41:10 +05:00
commit b5c99b29bd
3 changed files with 34 additions and 10 deletions

View File

@ -92,6 +92,15 @@ export const makeStringSorter = (key: string) => (a: any, b: any) =>
return 0
}
export const makeDateSorter = (key: string) => (a: any, b: any) => {
const date = new Date(a[key])
if(Number.isNaN(date.getTime()))
throw new Error('Date column contains not date formatted string(s)')
return date.getTime() - new Date(b[key]).getTime()
}
export const makeGroupColumn = (title: string, children: object[]) => ({
title: title,
children: children,

View File

@ -74,10 +74,6 @@ export default function ClusterWells({ clusterData }) {
}
}, [selectedWellId]);
const closeModal = () => {
setIsModalVisible(false)
}
calcAndUpdateStatsBySections(wellsStat ?? [], [
"factStart",
"factEnd",
@ -168,9 +164,9 @@ export default function ClusterWells({ clusterData }) {
title='TVD'
centered
visible={isModalVisible}
onOk={closeModal}
onCancel={closeModal}
onCancel={() => setIsModalVisible(false)}
width={1500}
footer={null}
>
<ChartDepthToDay
dataPlan={dataPlan}

View File

@ -1,7 +1,14 @@
import { useState, useEffect } from 'react'
import { Input } from 'antd'
import moment from 'moment'
import { EditableTable, DatePickerWrapper, SelectFromDictionary, numericColumnOptions, makeColumn } from "../../components/Table"
import {
EditableTable,
DatePickerWrapper,
SelectFromDictionary,
makeColumn,
numericColumnOptions,
makeNumericSorter,
makeDateSorter } from "../../components/Table"
import LoaderPortal from '../../components/LoaderPortal'
import { invokeWebApiWrapperAsync } from '../../components/factory'
import { WellOperationService} from '../../services/api'
@ -12,6 +19,15 @@ const { TextArea } = Input;
const basePageSize = 160;
const format='YYYY.MM.DD HH:mm'
const numericSortColumnOptions = Object.assign({
sorter: makeNumericSorter('wellDepth')
}, numericColumnOptions)
const durationFormattedColumnOptions = Object.assign({
render:(value) => Number.isNaN(value.toFixed(2)) ? "-" : value.toFixed(2)
}, numericColumnOptions)
export const WellOperationsEditor = ({idWell, idType}) => {
const [pageNumAndPageSize, setPageNumAndPageSize] = useState({current:1, pageSize:basePageSize})
const [paginationTotal, setPaginationTotal] = useState(0)
@ -31,7 +47,9 @@ export const WellOperationsEditor = ({idWell, idType}) => {
async () => {
const skip = ((pageNumAndPageSize.current - 1) * pageNumAndPageSize.pageSize) || 0
const take = pageNumAndPageSize.pageSize
const paginatedOperations = await WellOperationService.getOperations(idWell, idType, undefined, undefined, undefined, undefined, undefined, undefined, skip, take )
const paginatedOperations = await WellOperationService.getOperations(idWell,
idType, undefined, undefined, undefined, undefined,
undefined, undefined, skip, take )
const operations = paginatedOperations?.items ?? []
setOperations(operations)
const total = paginatedOperations.count?? paginatedOperations.items?.length ?? 0
@ -57,14 +75,15 @@ export const WellOperationsEditor = ({idWell, idType}) => {
render:(_, record)=>getByKeyOrReturnKey(dictionaryOperationCategory, record.idCategory)
}),
makeColumn('Доп. инфо','categoryInfo', {editable:true, width:300, input:<TextArea/>}),
makeColumn('Глубина забоя','wellDepth', numericColumnOptions),
makeColumn('Глубина забоя','wellDepth', numericSortColumnOptions),
makeColumn('Время начала','startDate', {
editable:true,
width:200,
input:<DatePickerWrapper/>,
sorter: makeDateSorter('startDate'),
render:(_, record) => moment.utc(record.startDate).local().format(format)
}),
makeColumn('Часы','durationHours', numericColumnOptions),
makeColumn('Часы','durationHours', durationFormattedColumnOptions),
makeColumn('Комментарий','comment', {editable:true, input:<TextArea/>}),
]