forked from ddrilling/asb_cloud_front
Исправлено отображение данных в таблице "Заполнить режимы текущей скважины" и в таблице на странице "Режимы"
This commit is contained in:
parent
9017ddf835
commit
292d4e0ef0
@ -1,7 +1,7 @@
|
|||||||
import { InputNumber } from 'antd'
|
import { InputNumber } from 'antd'
|
||||||
import { ReactNode } from 'react'
|
import { ReactNode } from 'react'
|
||||||
|
|
||||||
import { makeNumericSorter } from '../sorters'
|
import { makeNumericSorter, makeObjNumericSorter } from '../sorters'
|
||||||
import { columnPropsOther, makeGroupColumn, RenderMethod } from '.'
|
import { columnPropsOther, makeGroupColumn, RenderMethod } from '.'
|
||||||
|
|
||||||
export const RegExpIsFloat = /^[-+]?\d+\.?\d*$/
|
export const RegExpIsFloat = /^[-+]?\d+\.?\d*$/
|
||||||
@ -21,6 +21,25 @@ export const makeNumericRender = <T extends unknown>(fixed?: number): RenderMeth
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ObjRenderType = {
|
||||||
|
max: number
|
||||||
|
avg: number
|
||||||
|
min: number
|
||||||
|
isMax: boolean
|
||||||
|
isMin: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
export const makeObjRender = (key: keyof ObjRenderType, boolKey?: keyof ObjRenderType): RenderMethod<ObjRenderType> => (value: ObjRenderType) => {
|
||||||
|
const val = key ? value[key]: '-'
|
||||||
|
const isSelected = boolKey ? value[boolKey] : false
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className={`text-align-r-container ${isSelected ? 'color-pale-green' : ''}`}>
|
||||||
|
<span>{val}</span>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
export const makeNumericColumnOptions = (fixed?: number, sorterKey?: string): columnPropsOther => ({
|
export const makeNumericColumnOptions = (fixed?: number, sorterKey?: string): columnPropsOther => ({
|
||||||
editable: true,
|
editable: true,
|
||||||
initialValue: 0,
|
initialValue: 0,
|
||||||
@ -34,6 +53,19 @@ export const makeNumericColumnOptions = (fixed?: number, sorterKey?: string): co
|
|||||||
render: makeNumericRender(fixed),
|
render: makeNumericRender(fixed),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
export const makeObjColumnOptions = (key: keyof ObjRenderType, sortedObj?: string, boolKey?: keyof ObjRenderType): columnPropsOther => ({
|
||||||
|
editable: true,
|
||||||
|
initialValue: 0,
|
||||||
|
width: 100,
|
||||||
|
sorter: sortedObj && key ? makeObjNumericSorter(sortedObj, key) : undefined,
|
||||||
|
formItemRules: [{
|
||||||
|
required: true,
|
||||||
|
message: 'Введите число',
|
||||||
|
pattern: RegExpIsFloat,
|
||||||
|
}],
|
||||||
|
render: makeObjRender(key, boolKey),
|
||||||
|
})
|
||||||
|
|
||||||
export const makeNumericColumn = (
|
export const makeNumericColumn = (
|
||||||
title: ReactNode,
|
title: ReactNode,
|
||||||
dataIndex: string,
|
dataIndex: string,
|
||||||
@ -103,9 +135,9 @@ export const makeNumericAvgRange = (
|
|||||||
renderDelegate: (_: any, row: object) => any,
|
renderDelegate: (_: any, row: object) => any,
|
||||||
width: string
|
width: string
|
||||||
) => makeGroupColumn(title, [
|
) => makeGroupColumn(title, [
|
||||||
makeNumericColumn('мин', dataIndex + 'Min', filters, filterDelegate, renderDelegate, width, makeNumericColumnOptions(fixed, dataIndex + 'Min')),
|
makeNumericColumn('мин', dataIndex, filters, filterDelegate, renderDelegate, width, makeObjColumnOptions('min', dataIndex, 'isMin')),
|
||||||
makeNumericColumn('сред', dataIndex + 'Avg', filters, filterDelegate, renderDelegate, width, makeNumericColumnOptions(fixed, dataIndex + 'Avg')),
|
makeNumericColumn('сред', dataIndex, filters, filterDelegate, renderDelegate, width, makeObjColumnOptions('avg', dataIndex)),
|
||||||
makeNumericColumn('макс', dataIndex + 'Max', filters, filterDelegate, renderDelegate, width, makeNumericColumnOptions(fixed, dataIndex + 'Max'))
|
makeNumericColumn('макс', dataIndex, filters, filterDelegate, renderDelegate, width, makeObjColumnOptions('max', dataIndex, 'isMax'))
|
||||||
])
|
])
|
||||||
|
|
||||||
export default makeNumericColumn
|
export default makeNumericColumn
|
||||||
|
@ -7,6 +7,9 @@ import { DataType } from './Columns'
|
|||||||
export const makeNumericSorter = <T extends unknown>(key: keyof DataType<T>) =>
|
export const makeNumericSorter = <T extends unknown>(key: keyof DataType<T>) =>
|
||||||
(a: DataType<T>, b: DataType<T>) => Number(a[key]) - Number(b[key])
|
(a: DataType<T>, b: DataType<T>) => Number(a[key]) - Number(b[key])
|
||||||
|
|
||||||
|
export const makeObjNumericSorter = <T extends unknown>(obj: keyof DataType<T>, key: keyof DataType<T>) =>
|
||||||
|
(a: DataType<DataType<T>>, b: DataType<DataType<T>>) => Number(a[obj][key]) - Number(b[obj][key])
|
||||||
|
|
||||||
export const makeStringSorter = <T extends unknown>(key: keyof DataType<T>) => (a?: DataType<T> | null, b?: DataType<T> | null) => {
|
export const makeStringSorter = <T extends unknown>(key: keyof DataType<T>) => (a?: DataType<T> | null, b?: DataType<T> | null) => {
|
||||||
if (!a && !b) return 0
|
if (!a && !b) return 0
|
||||||
if (!a) return 1
|
if (!a) return 1
|
||||||
|
@ -2,7 +2,7 @@ import { useState, useEffect, useCallback, memo, useMemo } from 'react'
|
|||||||
|
|
||||||
import { useWell } from '@asb/context'
|
import { useWell } from '@asb/context'
|
||||||
import {
|
import {
|
||||||
EditableTable,
|
Table,
|
||||||
makeSelectColumn,
|
makeSelectColumn,
|
||||||
makeNumericAvgRange,
|
makeNumericAvgRange,
|
||||||
makeNumericSorter,
|
makeNumericSorter,
|
||||||
@ -81,15 +81,12 @@ export const WellDrillParams = memo(() => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<LoaderPortal show={showLoader}>
|
<LoaderPortal show={showLoader}>
|
||||||
<EditableTable
|
<Table
|
||||||
bordered
|
bordered
|
||||||
size={'small'}
|
size={'small'}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
dataSource={params}
|
dataSource={params}
|
||||||
tableName={'well_drill_params'}
|
tableName={'well_drill_params'}
|
||||||
onRowAdd={tableHandlers.add}
|
|
||||||
onRowEdit={tableHandlers.edit}
|
|
||||||
onRowDelete={tableHandlers.delete}
|
|
||||||
pagination={false}
|
pagination={false}
|
||||||
/>
|
/>
|
||||||
</LoaderPortal>
|
</LoaderPortal>
|
||||||
|
@ -142,3 +142,15 @@ code {
|
|||||||
height: 32px;
|
height: 32px;
|
||||||
padding: 4px 15px;
|
padding: 4px 15px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.ant-table-cell:has(.color-pale-green) {
|
||||||
|
background-color: #98fb98;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ant-table-tbody > tr > td.ant-table-cell-row-hover:has( > div.color-pale-green) {
|
||||||
|
background: #98fb98;
|
||||||
|
}
|
||||||
|
|
||||||
|
.color-pale-green {
|
||||||
|
background-color: #98fb98;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user