forked from ddrilling/asb_cloud_front
Исправлено отображение данных в таблице "Заполнить режимы текущей скважины" и в таблице на странице "Режимы"
This commit is contained in:
parent
c82fec8f60
commit
38fa8ffbeb
@ -12,7 +12,6 @@ export {
|
||||
makeNumericColumnPlanFact,
|
||||
makeNumericStartEnd,
|
||||
makeNumericMinMax,
|
||||
makeNumericAvgRange
|
||||
} from './numeric'
|
||||
export { makeColumnsPlanFact } from './plan_fact'
|
||||
export { makeSelectColumn } from './select'
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { InputNumber } from 'antd'
|
||||
import { ReactNode } from 'react'
|
||||
|
||||
import { makeNumericObjSorter, makeNumericSorter } from '../sorters'
|
||||
import { makeNumericSorter } from '../sorters'
|
||||
import { columnPropsOther, makeGroupColumn, RenderMethod } from '.'
|
||||
|
||||
export const RegExpIsFloat = /^[-+]?\d+\.?\d*$/
|
||||
@ -21,22 +21,6 @@ export const makeNumericRender = <T extends unknown>(fixed?: number): RenderMeth
|
||||
)
|
||||
}
|
||||
|
||||
export const makeNumericObjRender = (fixed?: number, columnKey?: [string, string]): RenderMethod => (value, obj) => {
|
||||
let val = '-'
|
||||
const isSelected = obj && columnKey && obj[columnKey[0]] ? obj[columnKey[0]][columnKey[1]] : false
|
||||
|
||||
if ((value ?? null) !== null && Number.isFinite(+value)) {
|
||||
val = (fixed ?? null) !== null
|
||||
? (+value).toFixed(fixed)
|
||||
: (+value).toPrecision(5)
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={`text-align-r-container ${isSelected ? 'color-pale-green' : ''}`}>
|
||||
<span>{val}</span>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export const makeNumericColumnOptions = (fixed?: number, sorterKey?: string): columnPropsOther => ({
|
||||
editable: true,
|
||||
@ -51,19 +35,6 @@ export const makeNumericColumnOptions = (fixed?: number, sorterKey?: string): co
|
||||
render: makeNumericRender(fixed),
|
||||
})
|
||||
|
||||
export const makeNumericColumnOptionsWithColor = (fixed?: number, sorterKey?: [string, string], columnKey?: [string, string]): columnPropsOther => ({
|
||||
editable: true,
|
||||
initialValue: 0,
|
||||
width: 100,
|
||||
sorter: sorterKey ? makeNumericObjSorter(sorterKey) : undefined,
|
||||
formItemRules: [{
|
||||
required: true,
|
||||
message: 'Введите число',
|
||||
pattern: RegExpIsFloat,
|
||||
}],
|
||||
render: makeNumericObjRender(fixed, columnKey),
|
||||
})
|
||||
|
||||
export const makeNumericColumn = (
|
||||
title: ReactNode,
|
||||
dataIndex: string,
|
||||
@ -86,28 +57,6 @@ export const makeNumericColumn = (
|
||||
...other
|
||||
})
|
||||
|
||||
export const makeNumericObjColumn = (
|
||||
title: ReactNode,
|
||||
dataIndex: [string, string],
|
||||
filters: object[],
|
||||
filterDelegate: (key: [string, string]) => any,
|
||||
renderDelegate: (_: any, row: object) => any,
|
||||
width: string,
|
||||
other?: columnPropsOther
|
||||
) => ({
|
||||
title: title,
|
||||
dataIndex: dataIndex,
|
||||
key: dataIndex,
|
||||
filters: filters,
|
||||
onFilter: filterDelegate ? filterDelegate(dataIndex) : null,
|
||||
sorter: makeNumericObjSorter(dataIndex),
|
||||
width: width,
|
||||
input: <InputNumber style={{ width: '100%' }}/>,
|
||||
render: renderDelegate ?? makeNumericRender(),
|
||||
align: 'right',
|
||||
...other
|
||||
})
|
||||
|
||||
export const makeNumericColumnPlanFact = (
|
||||
title: ReactNode,
|
||||
dataIndex: string,
|
||||
@ -146,18 +95,4 @@ export const makeNumericMinMax = (
|
||||
makeNumericColumn('макс', dataIndex + 'Max', filters, filterDelegate, renderDelegate, width, makeNumericColumnOptions(fixed, dataIndex + 'Max')),
|
||||
])
|
||||
|
||||
export const makeNumericAvgRange = (
|
||||
title: ReactNode,
|
||||
dataIndex: string,
|
||||
fixed: number,
|
||||
filters: object[],
|
||||
filterDelegate: (key: [string, string]) => any,
|
||||
renderDelegate: (_: any, row: object) => any,
|
||||
width: string
|
||||
) => makeGroupColumn(title, [
|
||||
makeNumericObjColumn('мин', [dataIndex, 'min'], filters, filterDelegate, renderDelegate, width, makeNumericColumnOptionsWithColor(fixed, [dataIndex, 'min'], [dataIndex, 'isMin'])),
|
||||
makeNumericObjColumn('сред', [dataIndex, 'avg'], filters, filterDelegate, renderDelegate, width, makeNumericColumnOptionsWithColor(fixed, [dataIndex, 'avg'])),
|
||||
makeNumericObjColumn('макс', [dataIndex, 'max'], filters, filterDelegate, renderDelegate, width, makeNumericColumnOptionsWithColor(fixed, [dataIndex, 'max'], [dataIndex, 'isMax']))
|
||||
])
|
||||
|
||||
export default makeNumericColumn
|
||||
|
@ -20,7 +20,6 @@ export {
|
||||
makeNumericColumnPlanFact,
|
||||
makeNumericStartEnd,
|
||||
makeNumericMinMax,
|
||||
makeNumericAvgRange,
|
||||
makeSelectColumn,
|
||||
makeTagColumn,
|
||||
makeTagInput,
|
||||
|
@ -1,17 +1,87 @@
|
||||
import { useState, useEffect, useCallback, memo, useMemo } from 'react'
|
||||
import { InputNumber } from 'antd'
|
||||
|
||||
import { useWell } from '@asb/context'
|
||||
import {
|
||||
EditableTable,
|
||||
makeSelectColumn,
|
||||
makeNumericAvgRange,
|
||||
makeGroupColumn,
|
||||
makeNumericRender,
|
||||
makeNumericSorter,
|
||||
makeSelectColumn,
|
||||
RegExpIsFloat,
|
||||
} from '@components/Table'
|
||||
import LoaderPortal from '@components/LoaderPortal'
|
||||
import { invokeWebApiWrapperAsync } from '@components/factory'
|
||||
import { DrillParamsService, WellOperationService } from '@api'
|
||||
import { arrayOrDefault } from '@utils'
|
||||
|
||||
import { makeNumericObjSorter } from '@components/Table/sorters'
|
||||
|
||||
const makeNumericObjRender = (fixed, columnKey) => (value, obj) => {
|
||||
let val = '-'
|
||||
const isSelected = obj && columnKey && obj[columnKey[0]] ? obj[columnKey[0]][columnKey[1]] : false
|
||||
|
||||
if ((value ?? null) !== null && Number.isFinite(+value)) {
|
||||
val = (fixed ?? null) !== null
|
||||
? (+value).toFixed(fixed)
|
||||
: (+value).toPrecision(5)
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={`text-align-r-container ${isSelected ? 'color-pale-green' : ''}`}>
|
||||
<span>{val}</span>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
const makeNumericColumnOptionsWithColor = (fixed, sorterKey, columnKey) => ({
|
||||
editable: true,
|
||||
initialValue: 0,
|
||||
width: 100,
|
||||
sorter: sorterKey ? makeNumericObjSorter(sorterKey) : undefined,
|
||||
formItemRules: [{
|
||||
required: true,
|
||||
message: 'Введите число',
|
||||
pattern: RegExpIsFloat,
|
||||
}],
|
||||
render: makeNumericObjRender(fixed, columnKey),
|
||||
})
|
||||
|
||||
const makeNumericObjColumn = (
|
||||
title,
|
||||
dataIndex,
|
||||
filters,
|
||||
filterDelegate,
|
||||
renderDelegate,
|
||||
width,
|
||||
other
|
||||
) => ({
|
||||
title: title,
|
||||
dataIndex: dataIndex,
|
||||
key: dataIndex,
|
||||
filters: filters,
|
||||
onFilter: filterDelegate ? filterDelegate(dataIndex) : null,
|
||||
sorter: makeNumericObjSorter(dataIndex),
|
||||
width: width,
|
||||
input: <InputNumber style={{ width: '100%' }}/>,
|
||||
render: renderDelegate ?? makeNumericRender(),
|
||||
align: 'right',
|
||||
...other
|
||||
})
|
||||
|
||||
const makeNumericAvgRange = (
|
||||
title,
|
||||
dataIndex,
|
||||
fixed,
|
||||
filters,
|
||||
filterDelegate,
|
||||
renderDelegate,
|
||||
width
|
||||
) => makeGroupColumn(title, [
|
||||
makeNumericObjColumn('мин', [dataIndex, 'min'], filters, filterDelegate, renderDelegate, width, makeNumericColumnOptionsWithColor(fixed, [dataIndex, 'min'], [dataIndex, 'isMin'])),
|
||||
makeNumericObjColumn('сред', [dataIndex, 'avg'], filters, filterDelegate, renderDelegate, width, makeNumericColumnOptionsWithColor(fixed, [dataIndex, 'avg'])),
|
||||
makeNumericObjColumn('макс', [dataIndex, 'max'], filters, filterDelegate, renderDelegate, width, makeNumericColumnOptionsWithColor(fixed, [dataIndex, 'max'], [dataIndex, 'isMax']))
|
||||
])
|
||||
|
||||
export const getColumns = async (idWell) => {
|
||||
let sectionTypes = await WellOperationService.getSectionTypes(idWell)
|
||||
|
Loading…
Reference in New Issue
Block a user