diff --git a/.vscode/settings.json b/.vscode/settings.json index c717161..52097f0 100755 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -2,7 +2,15 @@ "cSpell.words": [ "день", "спиннера", - "Saub" + "Saub", + "КНБК", + "САУБ", + "antd", + "Poprompt", + "saub", + "setpoint", + "Setpoints", + "usehooks" ], "liveServer.settings.port": 5501 } \ No newline at end of file diff --git a/src/components/Table/Columns/date.tsx b/src/components/Table/Columns/date.tsx index ed3428a..5342be1 100755 --- a/src/components/Table/Columns/date.tsx +++ b/src/components/Table/Columns/date.tsx @@ -40,6 +40,7 @@ export const makeDateColumn = ( other?: ColumnProps, pickerOther?: DatePickerWrapperProps, ) => makeColumn(title, key, { + editable: true, ...other, render: (date) => (
diff --git a/src/components/Table/Columns/index.ts b/src/components/Table/Columns/index.ts index 778bffd..e21c93c 100755 --- a/src/components/Table/Columns/index.ts +++ b/src/components/Table/Columns/index.ts @@ -9,7 +9,6 @@ import { OmitExtends } from '@utils/types' export * from './date' export * from './time' export * from './numeric' -export * from './plan_fact' export * from './select' export * from './tag' export * from './text' @@ -45,6 +44,7 @@ export const makeColumn = (title: ReactNode, key: Key, other?: ColumnPr title: title, key: key, dataIndex: key, + render: (value: T) => value, ...other, }) diff --git a/src/components/Table/Columns/numeric.tsx b/src/components/Table/Columns/numeric.tsx index 36f89b2..c15ee52 100755 --- a/src/components/Table/Columns/numeric.tsx +++ b/src/components/Table/Columns/numeric.tsx @@ -1,4 +1,3 @@ -import { ColumnFilterItem } from 'antd/lib/table/interface' import { InputNumber } from 'antd' import { Key, ReactNode } from 'react' @@ -46,18 +45,17 @@ export const makeNumericColumnOptions = (fixed?: number, sorte export const makeNumericColumn = ( title: ReactNode, key: Key, - filters?: ColumnFilterItem[], - filterDelegate?: FilterGenerator, renderDelegate?: RenderMethod, + filterDelegate?: FilterGenerator, width?: string | number, other?: ColumnProps, ) => makeColumn(title, key, { - filters, + editable: true, onFilter: filterDelegate ? filterDelegate(key) : undefined, sorter: makeNumericSorter(key), width, - input: , - render: renderDelegate ?? makeNumericRender(2), + input: , + render: renderDelegate || makeNumericRender(2), align: 'right', ...other }) @@ -65,54 +63,78 @@ export const makeNumericColumn = ( export const makeNumericColumnPlanFact = ( title: ReactNode, key: Key, - filters?: ColumnFilterItem[], - filterDelegate?: FilterGenerator, renderDelegate?: RenderMethod, + filterDelegate?: FilterGenerator, + width?: string | number, + other?: ColumnProps, +) => { + return { + title, + children: [ + makeNumericColumn('План', `${key}.plan`, renderDelegate, filterDelegate, width, other), + makeNumericColumn('Факт', `${key}.fact`, renderDelegate, filterDelegate, width, other), + ] + } +} + +/** + * @deprecated Для значений типа план/факт появилась модель `PlanFactDto`, использование 2 полей с суффиксами неактуально + * @param title Заголовок столбца + * @param key Ключ столбца + * @param filters Список значений для фильтрации + * @param filterDelegate Метод фильтрации + * @param renderDelegate Render-метод отображения ячейки + * @param width Ширина столбца + * @param other Дополнительные опции + * @returns Объект-столбец для таблицы + */ +export const makeNumericColumnPlanFactOld = ( + title: ReactNode, + key: Key, + renderDelegate?: RenderMethod, + filterDelegate?: FilterGenerator, width?: string | number, other?: ColumnProps, ) => makeGroupColumn(title, [ - makeNumericColumn('п', key + 'Plan', filters, filterDelegate, renderDelegate, width, other), - makeNumericColumn('ф', key + 'Fact', filters, filterDelegate, renderDelegate, width, other), + makeNumericColumn('План', key + 'Plan', renderDelegate, filterDelegate, width, other), + makeNumericColumn('Факт', key + 'Fact', renderDelegate, filterDelegate, width, other), ]) export const makeNumericStartEnd = ( title: ReactNode, key: Key, fixed: number, - filters?: ColumnFilterItem[], - filterDelegate?: FilterGenerator, renderDelegate?: RenderMethod, + filterDelegate?: FilterGenerator, width?: string | number, ) => makeGroupColumn(title, [ - makeNumericColumn('старт', key + 'Start', filters, filterDelegate, renderDelegate, width, makeNumericColumnOptions(fixed, key + 'Start')), - makeNumericColumn('конец', key + 'End', filters, filterDelegate, renderDelegate, width, makeNumericColumnOptions(fixed, key + 'End')) + makeNumericColumn('старт', key + 'Start', renderDelegate, filterDelegate, width, makeNumericColumnOptions(fixed, key + 'Start')), + makeNumericColumn('конец', key + 'End', renderDelegate, filterDelegate, width, makeNumericColumnOptions(fixed, key + 'End')) ]) export const makeNumericMinMax = ( title: ReactNode, key: Key, fixed: number, - filters?: ColumnFilterItem[], - filterDelegate?: FilterGenerator, renderDelegate?: RenderMethod, + filterDelegate?: FilterGenerator, width?: string | number, ) => makeGroupColumn(title, [ - makeNumericColumn('мин', key + 'Min', filters, filterDelegate, renderDelegate, width, makeNumericColumnOptions(fixed, key + 'Min')), - makeNumericColumn('макс', key + 'Max', filters, filterDelegate, renderDelegate, width, makeNumericColumnOptions(fixed, key + 'Max')), + makeNumericColumn('мин', key + 'Min', renderDelegate, filterDelegate, width, makeNumericColumnOptions(fixed, key + 'Min')), + makeNumericColumn('макс', key + 'Max', renderDelegate, filterDelegate, width, makeNumericColumnOptions(fixed, key + 'Max')), ]) export const makeNumericAvgRange = ( title: ReactNode, key: Key, fixed: number, - filters?: ColumnFilterItem[], - filterDelegate?: FilterGenerator, renderDelegate?: RenderMethod, + filterDelegate?: FilterGenerator, width?: string | number, ) => makeGroupColumn(title, [ - makeNumericColumn('мин', `${key}.min`, filters, filterDelegate, renderDelegate, width, makeNumericColumnOptions(fixed, `${key}.min`)), - makeNumericColumn('сред', `${key}.avg`, filters, filterDelegate, renderDelegate, width, makeNumericColumnOptions(fixed, `${key}.avg`)), - makeNumericColumn('макс', `${key}.max`, filters, filterDelegate, renderDelegate, width, makeNumericColumnOptions(fixed, `${key}.max`)), + makeNumericColumn('мин', `${key}.min`, renderDelegate, filterDelegate, width, makeNumericColumnOptions(fixed, `${key}.min`)), + makeNumericColumn('сред', `${key}.avg`, renderDelegate, filterDelegate, width, makeNumericColumnOptions(fixed, `${key}.avg`)), + makeNumericColumn('макс', `${key}.max`, renderDelegate, filterDelegate, width, makeNumericColumnOptions(fixed, `${key}.max`)), ]) export default makeNumericColumn diff --git a/src/components/Table/Columns/plan_fact.tsx b/src/components/Table/Columns/plan_fact.tsx deleted file mode 100755 index 852b9e4..0000000 --- a/src/components/Table/Columns/plan_fact.tsx +++ /dev/null @@ -1,22 +0,0 @@ -import { Key, ReactNode } from 'react' - -import { ColumnProps, makeColumn } from '.' - -export const makeColumnsPlanFact = ( - title: string | ReactNode, - key: Key | [Key, Key], - columsOther?: ColumnProps | [ColumnProps, ColumnProps], -) => { - const keys = Array.isArray(key) ? key : [`${key}Plan`, `${key}Fact`] - const others = Array.isArray(columsOther) ? columsOther : [columsOther, columsOther] - - return { - title, - children: [ - makeColumn('план', keys[0], others[0]), - makeColumn('факт', keys[1], others[1]), - ] - } -} - -export default makeColumnsPlanFact diff --git a/src/components/Table/Columns/select.tsx b/src/components/Table/Columns/select.tsx index 098d983..54e948b 100755 --- a/src/components/Table/Columns/select.tsx +++ b/src/components/Table/Columns/select.tsx @@ -1,9 +1,17 @@ import { Select, SelectProps } from 'antd' import { DefaultOptionType, SelectValue } from 'antd/lib/select' -import { Key, ReactNode } from 'react' +import { Key, ReactNode, useMemo } from 'react' import { ColumnProps, makeColumn } from '.' +const findOption = (value: any, options: T[] | undefined) => + options?.find((option) => String(option?.value) === String(value)) + +const SelectWrapper = ({ value, options, ...other }: SelectProps) => { + const selectValue = useMemo(() => findOption(value, options)?.label, [value, options]) + return , + input: , render: (value, dataset, index) => { - const item = options?.find(option => String(option?.value) === String(value)) + const item = findOption(value, options) return other?.render?.(item, dataset, index) ?? item?.label ?? defaultValue?.label ?? value?.label ?? '--' } }) diff --git a/src/components/Table/Columns/tag.tsx b/src/components/Table/Columns/tag.tsx index e683f19..c83329b 100755 --- a/src/components/Table/Columns/tag.tsx +++ b/src/components/Table/Columns/tag.tsx @@ -65,6 +65,7 @@ export const makeTagColumn = ( const InputComponent = makeTagInput(value_key, label_key) return makeColumn(title, dataIndex, { + editable: true, ...other, render: (item: T[] | undefined, dataset, index) => item?.map((elm: T) => {other?.render?.(elm, dataset, index) ?? elm[label_key]}) ?? '-', input: , diff --git a/src/components/Table/Columns/text.tsx b/src/components/Table/Columns/text.tsx index 91431ad..69db9a3 100755 --- a/src/components/Table/Columns/text.tsx +++ b/src/components/Table/Columns/text.tsx @@ -1,3 +1,4 @@ +import { Tooltip } from 'antd' import { ColumnFilterItem } from 'antd/lib/table/interface' import { Key, ReactNode } from 'react' @@ -15,6 +16,18 @@ export const makeStringSorter = (key: Key): SorterMethod => return String(vA).localeCompare(String(vB)) } +export const makeTextRender = (def = '---', stringCutter?: (text: string) => string) => (value: T) => { + if (!value) return def + if (stringCutter) { + return ( + + {stringCutter(value)} + + ) + } + return value +} + export const makeFilterTextMatch = (key: keyof DataType) => (filterValue: T, dataItem: DataType) => dataItem[key] === filterValue @@ -26,10 +39,11 @@ export const makeTextColumn = ( render?: RenderMethod, other?: ColumnProps ) => makeColumn(title, key, { + editable: true, filters, onFilter: filters ? makeFilterTextMatch(key) : undefined, - sorter: sorter ?? makeStringSorter(key), - render: render, + sorter: sorter || makeStringSorter(key), + render: render || makeTextRender(), ...other }) diff --git a/src/components/Table/Columns/time.tsx b/src/components/Table/Columns/time.tsx index 7547814..116840c 100644 --- a/src/components/Table/Columns/time.tsx +++ b/src/components/Table/Columns/time.tsx @@ -24,6 +24,7 @@ export const makeTimeColumn = ( other?: ColumnProps, pickerOther?: TimePickerWrapperProps, ) => makeColumn(title, key, { + editable: true, ...other, render: (time) => (
diff --git a/src/components/selectors/WellSelector.jsx b/src/components/selectors/WellSelector.jsx index c0e18bd..1894021 100755 --- a/src/components/selectors/WellSelector.jsx +++ b/src/components/selectors/WellSelector.jsx @@ -59,6 +59,7 @@ export const WellSelector = memo(({ value, onChange, treeData, treeLabels, ...ot { const clusterColumns = useMemo(() => [ makeSelectColumn('Месторождение', 'idDeposit', deposits, '--', { width: 200, - editable: true, sorter: makeStringSorter('idDeposit') }), - makeColumn('Название', 'caption', { - width: 200, - editable: true, - sorter: makeStringSorter('caption'), - formItemRules: min1, - }), - makeColumn('Широта', 'latitude', { width: 150, editable: true, render: coordsFormat }), - makeColumn('Долгота', 'longitude', { width: 150, editable: true, render: coordsFormat }), + makeTextColumn('Название', 'caption', undefined, undefined, undefined, { width: 200, formItemRules: min1 }), + makeNumericColumn('Широта', 'latitude', coordsFormat, undefined, 150), + makeNumericColumn('Долгота', 'longitude', coordsFormat, undefined, 150), makeTimezoneColumn('Зона', 'timezone', null, true, { width: 150 }), ], [deposits]) diff --git a/src/pages/AdminPanel/CompanyController.jsx b/src/pages/AdminPanel/CompanyController.jsx index 454b16c..5577e1f 100755 --- a/src/pages/AdminPanel/CompanyController.jsx +++ b/src/pages/AdminPanel/CompanyController.jsx @@ -3,10 +3,9 @@ import { Input } from 'antd' import { EditableTable, - makeColumn, - makeStringSorter, makeSelectColumn, - defaultPagination + defaultPagination, + makeTextColumn } from '@components/Table' import { invokeWebApiWrapperAsync } from '@components/factory' import { AdminCompanyService, AdminCompanyTypeService } from '@api' @@ -37,16 +36,8 @@ const CompanyController = memo(() => { })) setColumns([ - makeColumn('Название', 'caption', { - width: 200, - editable: true, - sorter: makeStringSorter('caption'), - formItemRules: min1, - }), - makeSelectColumn('Тип компании', 'idCompanyType', companyTypes, null, { - width: 200, - editable: true - }), + makeTextColumn('Название', 'caption', undefined, undefined, undefined, { width: 200, formItemRules: min1 }), + makeSelectColumn('Тип компании', 'idCompanyType', companyTypes, null, { width: 200 }), ]) await updateTable() diff --git a/src/pages/AdminPanel/CompanyTypeController.jsx b/src/pages/AdminPanel/CompanyTypeController.jsx index 3debe2c..601d1aa 100755 --- a/src/pages/AdminPanel/CompanyTypeController.jsx +++ b/src/pages/AdminPanel/CompanyTypeController.jsx @@ -1,19 +1,14 @@ import { memo, useCallback, useEffect, useMemo, useState } from 'react' import { Input } from 'antd' -import { EditableTable, makeColumn, makeStringSorter, defaultPagination } from '@components/Table' +import { EditableTable, defaultPagination, makeTextColumn } from '@components/Table' import { invokeWebApiWrapperAsync } from '@components/factory' import { arrayOrDefault, withPermissions } from '@utils' import { min1 } from '@utils/validationRules' import { AdminCompanyTypeService } from '@api' const columns = [ - makeColumn('Название', 'caption', { - width: 200, - editable: true, - sorter: makeStringSorter('caption'), - formItemRules: min1, - }), + makeTextColumn('Название', 'caption', undefined, undefined, undefined, { width: 200, formItemRules: min1 }), ] const CompanyTypeController = memo(() => { diff --git a/src/pages/AdminPanel/DepositController.jsx b/src/pages/AdminPanel/DepositController.jsx index 748490b..974a420 100755 --- a/src/pages/AdminPanel/DepositController.jsx +++ b/src/pages/AdminPanel/DepositController.jsx @@ -2,15 +2,15 @@ import { memo, useCallback, useEffect, useMemo, useState } from 'react' import { Input } from 'antd' import { invokeWebApiWrapperAsync } from '@components/factory' -import { EditableTable, makeColumn, defaultPagination, makeTimezoneColumn } from '@components/Table' +import { EditableTable, defaultPagination, makeTimezoneColumn, makeTextColumn, makeNumericColumn } from '@components/Table' import { arrayOrDefault, coordsFormat, withPermissions } from '@utils' import { min1 } from '@utils/validationRules' import { AdminDepositService } from '@api' const depositColumns = [ - makeColumn('Название', 'caption', { width: 200, editable: true, formItemRules: min1 }), - makeColumn('Широта', 'latitude', { width: 150, editable: true, render: coordsFormat }), - makeColumn('Долгота', 'longitude', { width: 150, editable: true, render: coordsFormat }), + makeTextColumn('Название', 'caption', undefined, undefined, undefined, { width: 200, formItemRules: min1 }), + makeNumericColumn('Широта', 'latitude', coordsFormat, undefined, 150), + makeNumericColumn('Долгота', 'longitude', coordsFormat, undefined, 150), makeTimezoneColumn('Зона', 'timezone', null, true, { width: 150 }), ] diff --git a/src/pages/AdminPanel/PermissionController.jsx b/src/pages/AdminPanel/PermissionController.jsx index 73db56a..0ee736e 100755 --- a/src/pages/AdminPanel/PermissionController.jsx +++ b/src/pages/AdminPanel/PermissionController.jsx @@ -1,23 +1,15 @@ import { memo, useCallback, useEffect, useMemo, useState } from 'react' import { Input } from 'antd' -import { EditableTable, makeColumn, makeStringSorter } from '@components/Table' +import { EditableTable, makeTextColumn } from '@components/Table' import { invokeWebApiWrapperAsync } from '@components/factory' import { arrayOrDefault, withPermissions } from '@utils' import { min1 } from '@utils/validationRules' import { AdminPermissionService } from '@api' const columns = [ - makeColumn('Название', 'name', { - editable: true, - sorter: makeStringSorter('name'), - isRequired: true, - formItemRules: min1, - }), - makeColumn('Описание', 'description', { - editable: true, - sorter: makeStringSorter('description'), - }), + makeTextColumn('Название', 'name', undefined, undefined, undefined, { isRequired: true, formItemRules: min1 }), + makeTextColumn('Описание', 'description'), ] const PermissionController = memo(() => { diff --git a/src/pages/AdminPanel/RoleController.jsx b/src/pages/AdminPanel/RoleController.jsx index b995fde..6276ac5 100755 --- a/src/pages/AdminPanel/RoleController.jsx +++ b/src/pages/AdminPanel/RoleController.jsx @@ -19,15 +19,13 @@ const RoleController = memo(() => { )), [roles, searchValue]) const columns = useMemo(() => [ - makeTextColumn('Название', 'caption', null, null, null, { width: 100, editable: true, formItemRules: min1 }), + makeTextColumn('Название', 'caption', null, null, null, { width: 100, formItemRules: min1 }), makeTagColumn('Включённые роли', 'roles', roles, 'id', 'caption', { width: 400, - editable: true, render: (role) => }, { allowClear: true }), makeTagColumn('Разрешения', 'permissions', permissions, 'id', 'name', { width: 600, - editable: true, render: (permission) => , }), ], [roles, permissions]) diff --git a/src/pages/AdminPanel/Telemetry/TelemetryViewer.jsx b/src/pages/AdminPanel/Telemetry/TelemetryViewer.jsx index f90ff30..3836aff 100755 --- a/src/pages/AdminPanel/Telemetry/TelemetryViewer.jsx +++ b/src/pages/AdminPanel/Telemetry/TelemetryViewer.jsx @@ -50,7 +50,7 @@ const TelemetryController = memo(() => { const columns = useMemo(() => [ makeColumn('', 'hasParent', { render: mergeRender }), - makeNumericColumn('ID', 'id', null, null, makeNumericRender(0)), + makeNumericColumn('ID', 'id', makeNumericRender(0)), makeTextColumn('UID', 'remoteUid'), makeTextColumn('Назначена на скважину', 'realWell'), makeDateColumn('Дата начала бурения', 'drillingStartDate'), diff --git a/src/pages/AdminPanel/UserController/index.jsx b/src/pages/AdminPanel/UserController/index.jsx index 2f6b301..5bb3ef2 100755 --- a/src/pages/AdminPanel/UserController/index.jsx +++ b/src/pages/AdminPanel/UserController/index.jsx @@ -115,7 +115,6 @@ const UserController = memo(() => { setColumns([ makeTextColumn('Логин', 'login', null, null, null, { - editable: true, formItemRules: [ { required: true }, ...createLoginRules, @@ -130,41 +129,34 @@ const UserController = memo(() => { ], }), makeTextColumn('Фамилия', 'surname', filters.surname, null, null, { - editable: true, formItemRules: [{ required: true }, ...nameRules], filterSearch: true, onFilter: makeTextOnFilter('surname'), }), makeTextColumn('Имя', 'name', filters.name, null, null, { - editable: true, formItemRules: nameRules, filterSearch: true, onFilter: makeTextOnFilter('name'), }), makeTextColumn('Отчество', 'patronymic', filters.partonymic, null, null, { - editable: true, formItemRules: nameRules, filterSearch: true, onFilter: makeTextOnFilter('patronymic'), }), makeTextColumn('E-mail', 'email', filters.email, null, null, { - editable: true, formItemRules: [{ required: true }, ...emailRules], filterSearch: true, onFilter: makeTextOnFilter('email'), }), makeTextColumn('Номер телефона', 'phone', null, null, null, { - editable: true, formItemRules: phoneRules, }), - makeTextColumn('Должность', 'position', null, null, null, { editable: true }), + makeTextColumn('Должность', 'position', null, null, null), makeTextColumn('Роли', 'roleNames', roleFilters, null, rolesRender, { - editable: true, input: , onFilter: makeArrayOnFilter('roleNames'), }), makeSelectColumn('Компания', 'idCompany', companies, '--', { - editable: true, sorter: makeNumericSorter('idCompany'), }) ]) diff --git a/src/pages/AdminPanel/WellController/index.jsx b/src/pages/AdminPanel/WellController/index.jsx index 6fe163e..ed74ca6 100755 --- a/src/pages/AdminPanel/WellController/index.jsx +++ b/src/pages/AdminPanel/WellController/index.jsx @@ -12,11 +12,12 @@ import { EditableTable, makeColumn, makeSelectColumn, - makeStringSorter, makeNumericSorter, makeTagColumn, defaultPagination, makeTimezoneColumn, + makeTextColumn, + makeNumericColumn, } from '@components/Table' import { invokeWebApiWrapperAsync } from '@components/factory' import { TelemetryView, CompanyView } from '@components/views' @@ -81,23 +82,11 @@ const WellController = memo(() => { })) setColumns([ - makeSelectColumn('Куст', 'idCluster', clusters, '--', { - width: '5rem', - editable: true, - sorter: makeNumericSorter('idCluster'), - }), - makeColumn('Название', 'caption', { - width: '5rem', - editable: true, - sorter: makeStringSorter('caption'), - }), - makeSelectColumn('Тип', 'idWellType', wellTypes, '--', { - width: 150, - editable: true, - sorter: makeNumericSorter('idWellType'), - }), - makeColumn('Широта', 'latitude', { width: 150, editable: true, render: coordsFormat }), - makeColumn('Долгота', 'longitude', { width: 150, editable: true, render: coordsFormat }), + makeSelectColumn('Куст', 'idCluster', clusters, '--', { width: '5rem', sorter: makeNumericSorter('idCluster') }), + makeTextColumn('Название', 'caption', undefined, undefined, undefined, { width: '5rem' }), + makeSelectColumn('Тип', 'idWellType', wellTypes, '--', { width: 150, sorter: makeNumericSorter('idWellType') }), + makeNumericColumn('Широта', 'latitude', coordsFormat, undefined, 150), + makeNumericColumn('Долгота', 'longitude', coordsFormat, undefined, 150), makeColumn('Телеметрия', 'telemetry', { editable: true, render: (telemetry) => , @@ -105,7 +94,6 @@ const WellController = memo(() => { }, ), makeTimezoneColumn('Зона', 'timezone', null, true, { width: 170 }), makeTagColumn('Компании', 'companies', companies, 'id', 'caption', { - editable: true, render: (company) => , }), ]) diff --git a/src/pages/Cluster/ClusterWells.jsx b/src/pages/Cluster/ClusterWells.jsx index a84e9cb..81410ec 100755 --- a/src/pages/Cluster/ClusterWells.jsx +++ b/src/pages/Cluster/ClusterWells.jsx @@ -7,7 +7,7 @@ import { makeTextColumn, makeGroupColumn, makeColumn, - makeNumericColumnPlanFact, + makeNumericColumnPlanFactOld, Table, makeNumericRender, makeNumericColumn, @@ -117,7 +117,10 @@ const ClusterWells = memo(({ statsWells }) => { const columns = useMemo(() => [ makeTextColumn('скв №', 'caption', null, null, (_, item) => ( - + { makeDateColumn('начало', 'factStart'), makeDateColumn('окончание', 'factEnd'), ]), - makeNumericColumnPlanFact('Продолжительность, сут', 'period', filtersMinMax, makeFilterMinMaxFunction, numericRender), - makeNumericColumnPlanFact('МСП, м/ч', 'rateOfPenetration', filtersMinMax, makeFilterMinMaxFunction, numericRender), - makeNumericColumnPlanFact('Рейсовая скорость, м/ч', 'routeSpeed', filtersMinMax, makeFilterMinMaxFunction, numericRender), - makeNumericColumn('НПВ, ч', 'notProductiveTimeFact', filtersMinMax, makeFilterMinMaxFunction, numericRender), + makeNumericColumnPlanFactOld('Продолжительность, сут', 'period', numericRender, makeFilterMinMaxFunction, { filters: filtersMinMax }), + makeNumericColumnPlanFactOld('МСП, м/ч', 'rateOfPenetration', numericRender, makeFilterMinMaxFunction, { filters: filtersMinMax }), + makeNumericColumnPlanFactOld('Рейсовая скорость, м/ч', 'routeSpeed', numericRender, makeFilterMinMaxFunction, { filters: filtersMinMax }), + makeNumericColumn('НПВ, ч', 'notProductiveTimeFact', numericRender, makeFilterMinMaxFunction, { filters: filtersMinMax }), makeColumn('TVD', 'tvd', { align: 'center', render: (_, value) => ( - setIsParamsModalVisible(false)} - width={1700} - footer={( - - - - )} - > - - - - - - ) -}) - -export default NewParamsTable diff --git a/src/pages/Well/Analytics/WellCompositeEditor/WellCompositeSections.jsx b/src/pages/Well/Analytics/WellCompositeEditor/WellCompositeSections.jsx index 52931a4..9747b6c 100644 --- a/src/pages/Well/Analytics/WellCompositeEditor/WellCompositeSections.jsx +++ b/src/pages/Well/Analytics/WellCompositeEditor/WellCompositeSections.jsx @@ -1,12 +1,13 @@ import { Link, useLocation } from 'react-router-dom' import { useState, useEffect, memo, useMemo, lazy, Suspense } from 'react' import { LineChartOutlined, ProfileOutlined, TeamOutlined } from '@ant-design/icons' -import { Button, Badge, Divider, Modal, Row, Col } from 'antd' +import { Button, Badge, Divider, Modal } from 'antd' import { useWell } from '@asb/context' import LoaderPortal from '@components/LoaderPortal' +import SuspenseFallback from '@components/SuspenseFallback' import { invokeWebApiWrapperAsync } from '@components/factory' -import { Table, makeTextColumn, makeNumericColumnPlanFact, makeNumericColumn } from '@components/Table' +import { Table, makeTextColumn, makeNumericColumnPlanFactOld, makeNumericColumn } from '@components/Table' import { WellCompositeService } from '@api' import { hasPermission, @@ -16,8 +17,6 @@ import { getOperations } from '@utils' -import NewParamsTable from './NewParamsTable' -import SuspenseFallback from '@asb/components/SuspenseFallback' const Tvd = lazy(() => import('@pages/Well/WellOperations/Tvd')) const CompaniesTable = lazy(() => import('@pages/Cluster/CompaniesTable')) @@ -146,15 +145,15 @@ const WellCompositeSections = memo(({ statsWells, selectedSections }) => { makeTextColumn('скв №', 'caption', null, null, (text, item) => {text ?? '-'} ), - makeTextColumn('Секция', 'sectionType', filtersSectionsType, sortBySectionId, (text) => text ?? '-'), - makeNumericColumnPlanFact('Глубина, м', 'sectionWellDepth', filtersMinMax, makeFilterMinMaxFunction), - makeNumericColumnPlanFact('Продолжительность, ч', 'sectionBuildDays', filtersMinMax, makeFilterMinMaxFunction), - makeNumericColumnPlanFact('МСП, м/ч', 'sectionRateOfPenetration', filtersMinMax, makeFilterMinMaxFunction), - makeNumericColumnPlanFact('Рейсовая скорость, м/ч', 'sectionRouteSpeed', filtersMinMax, makeFilterMinMaxFunction), - makeNumericColumnPlanFact('Спуск КНБК, м/ч', 'sectionBhaDownSpeed', filtersMinMax, makeFilterMinMaxFunction), - makeNumericColumnPlanFact('Подъем КНБК, м/ч', 'sectionBhaUpSpeed', filtersMinMax, makeFilterMinMaxFunction), - makeNumericColumnPlanFact('Скорость спуска ОК, м/ч', 'sectionCasingDownSpeed', filtersMinMax, makeFilterMinMaxFunction), - makeNumericColumn('НПВ, ч', 'nonProductiveHours', filtersMinMax, makeFilterMinMaxFunction, null, '80px'), + makeTextColumn('Секция', 'sectionType', filtersSectionsType, sortBySectionId, (text) => text ?? '-', { width: 100 }), + makeNumericColumnPlanFactOld('Глубина, м', 'sectionWellDepth', undefined, makeFilterMinMaxFunction, undefined, { filters: filtersMinMax }), + makeNumericColumnPlanFactOld('Продолжительность, ч', 'sectionBuildDays', undefined, makeFilterMinMaxFunction, undefined, { filters: filtersMinMax }), + makeNumericColumnPlanFactOld('МСП, м/ч', 'sectionRateOfPenetration', undefined, makeFilterMinMaxFunction, undefined, { filters: filtersMinMax }), + makeNumericColumnPlanFactOld('Рейсовая скорость, м/ч', 'sectionRouteSpeed', undefined, makeFilterMinMaxFunction, undefined, { filters: filtersMinMax }), + makeNumericColumnPlanFactOld('Спуск КНБК, м/ч', 'sectionBhaDownSpeed', undefined, makeFilterMinMaxFunction, undefined, { filters: filtersMinMax }), + makeNumericColumnPlanFactOld('Подъем КНБК, м/ч', 'sectionBhaUpSpeed', undefined, makeFilterMinMaxFunction, undefined, { filters: filtersMinMax }), + makeNumericColumnPlanFactOld('Скорость спуска ОК, м/ч', 'sectionCasingDownSpeed', undefined, makeFilterMinMaxFunction, undefined, { filters: filtersMinMax }), + makeNumericColumn('НПВ, ч', 'nonProductiveHours', undefined, makeFilterMinMaxFunction, '80px', { filters: filtersMinMax }), { title: 'TVD', render: (value) => ( @@ -200,11 +199,11 @@ const WellCompositeSections = memo(({ statsWells, selectedSections }) => { dataSource={rows} size={'small'} bordered - scroll={{ x: true, y: 620 }} + scroll={{ x: true, y: '30vh' }} rowSelection={rowSelection} pagination={false} /> - +

Выбранные секции

@@ -214,12 +213,9 @@ const WellCompositeSections = memo(({ statsWells, selectedSections }) => { rowSelection={rowSelection} size={'small'} bordered - scroll={{ x: true }} + scroll={{ x: true, y: '30vh' }} pagination={false} /> - -
- formatBytes(value)), + makeNumericColumn('Размер', 'size', (value) => formatBytes(value)), makeColumn('Автор', 'author', { render: item => }), makeColumn('Компания', 'company', { render: (_, record) => }), ...(customColumns ?? []) diff --git a/src/pages/Well/Telemetry/Messages.jsx b/src/pages/Well/Telemetry/Messages.jsx index a5aed6d..9ba219d 100644 --- a/src/pages/Well/Telemetry/Messages.jsx +++ b/src/pages/Well/Telemetry/Messages.jsx @@ -29,7 +29,7 @@ const categoryDictionary = { // Конфигурация таблицы export const makeMessageColumns = (idWell) => [ makeDateColumn('Дата', 'date', undefined, undefined, { width: '120px' }), - makeNumericColumn('Глубина, м', 'wellDepth', null, null, (depth, item) => ( + makeNumericColumn('Глубина, м', 'wellDepth', (depth, item) => ( [ {depth.toFixed(2)} - ), '7rem'), + ), undefined, '7rem'), makeColumn('Категория', 'categoryId', { width: '8rem', render: (_, item) => categoryDictionary[item.categoryId].title, diff --git a/src/pages/Well/Telemetry/OperationTime/index.jsx b/src/pages/Well/Telemetry/OperationTime/index.jsx index 4733f56..cc52c70 100644 --- a/src/pages/Well/Telemetry/OperationTime/index.jsx +++ b/src/pages/Well/Telemetry/OperationTime/index.jsx @@ -26,10 +26,10 @@ const tableColumns = [
)}), makeTextColumn('Подсистема', 'subsystemName'), - makeNumericColumn('Использование, %', 'kUsage', undefined, undefined, val => (+val * 100).toFixed(2), 200), - makeNumericColumn('Проходка, м', 'sumDepthInterval', undefined, undefined, undefined, 200), - makeNumericColumn('Время работы, ч', 'usedTimeHours', undefined, undefined, undefined, 200), - makeNumericColumn('Кол-во запусков', 'operationCount', undefined, undefined, makeNumericRender(0), 200), + makeNumericColumn('Использование, %', 'kUsage', val => (+val * 100).toFixed(2), undefined, 200), + makeNumericColumn('Проходка, м', 'sumDepthInterval', undefined, undefined, 200), + makeNumericColumn('Время работы, ч', 'usedTimeHours', undefined, undefined, 200), + makeNumericColumn('Кол-во запусков', 'operationCount', makeNumericRender(0), undefined, 200), ] // Выбор доступен только до текущей даты diff --git a/src/pages/Well/Telemetry/Operations/DrillerList.jsx b/src/pages/Well/Telemetry/Operations/DrillerList.jsx index c1b2081..5a8dd8a 100644 --- a/src/pages/Well/Telemetry/Operations/DrillerList.jsx +++ b/src/pages/Well/Telemetry/Operations/DrillerList.jsx @@ -5,14 +5,13 @@ import { EditableTable, makeTextColumn } from '@components/Table' import { DrillerService } from '@api' const columnOptions = { - editable: true, formItemRules: [{ message: 'Обязательное поле!', required: true }] } const columns = [ makeTextColumn('Фамилия', 'surname', undefined, undefined, undefined, columnOptions), makeTextColumn('Имя', 'name', undefined, undefined, undefined, columnOptions), - makeTextColumn('Отчество', 'patronymic', undefined, undefined, undefined, { editable: true }), + makeTextColumn('Отчество', 'patronymic'), ] const rowClassName = (record) => record.has ? 'driller_list_active' : '' diff --git a/src/pages/Well/Telemetry/Operations/DrillerSchedule.jsx b/src/pages/Well/Telemetry/Operations/DrillerSchedule.jsx index 2727274..a47a6df 100644 --- a/src/pages/Well/Telemetry/Operations/DrillerSchedule.jsx +++ b/src/pages/Well/Telemetry/Operations/DrillerSchedule.jsx @@ -14,7 +14,6 @@ import { arrayOrDefault } from '@utils' import { ScheduleService } from '@api' const columnOptions = { - editable: true, formItemRules: [{ message: 'Обязательное поле!', required: true }] } diff --git a/src/pages/Well/Telemetry/Operations/OperationsTable.jsx b/src/pages/Well/Telemetry/Operations/OperationsTable.jsx index a4e3e9d..d9dabb3 100644 --- a/src/pages/Well/Telemetry/Operations/OperationsTable.jsx +++ b/src/pages/Well/Telemetry/Operations/OperationsTable.jsx @@ -24,11 +24,11 @@ const makeDrillerSorter = (key) => (a, b) => { export const columns = [ makeTextColumn('Бурильщик', 'driller', null, makeDrillerSorter('driller'), drillerRender, { width: 200 }), - makeNumericColumn('Кол-во операций', 'count', null, null, (value) => parseInt(value), 150), - makeNumericColumn('Среднее по ключевому показателю', 'averageValue', null, null, numericRender, 150), - makeNumericColumn('Среднее целевого показателя', 'averageTargetValue', null, null, numericRender, 150), - makeNumericColumn('Эффективность (%)', 'efficiency', null, null, numericRender, 150), - makeNumericColumn('Коэффициент потерь', 'loss', null, null, numericRender, 100), + makeNumericColumn('Кол-во операций', 'count', (value) => parseInt(value), undefined, 150), + makeNumericColumn('Среднее по ключевому показателю', 'averageValue', numericRender, undefined, 150), + makeNumericColumn('Среднее целевого показателя', 'averageTargetValue', numericRender, undefined, 150), + makeNumericColumn('Эффективность (%)', 'efficiency', numericRender, undefined, 150), + makeNumericColumn('Коэффициент потерь', 'loss', numericRender, undefined, 100), ] export const OperationsTable = memo(({ data, height, ...other }) => ( diff --git a/src/pages/Well/Telemetry/Operations/TargetEditor.jsx b/src/pages/Well/Telemetry/Operations/TargetEditor.jsx index 69f49cf..dc1dfd1 100644 --- a/src/pages/Well/Telemetry/Operations/TargetEditor.jsx +++ b/src/pages/Well/Telemetry/Operations/TargetEditor.jsx @@ -8,7 +8,6 @@ import { DetectedOperationService, OperationValueService } from '@api' import { arrayOrDefault } from '@utils' const columnOptions = { - editable: true, formItemRules: [{ message: 'Обязательное поле!', required: true }] } @@ -72,11 +71,11 @@ export const TargetEditor = memo(({ loading, onChange }) => { filterOption: (input, option) => String(option?.label ?? '').toLowerCase().indexOf(input.toLowerCase()) >= 0 }), - makeNumericColumn('Цель', 'targetValue', undefined, undefined, numericRender, 150, columnOptions), - makeNumericColumn('Норм.', 'standardValue', undefined, undefined, numericRender, 150, columnOptions), + makeNumericColumn('Цель', 'targetValue', numericRender, undefined, 150, columnOptions), + makeNumericColumn('Норм.', 'standardValue', numericRender, undefined, 150, columnOptions), makeGroupColumn('Глубина, м', [ - makeNumericColumn('Начало', 'depthStart', undefined, undefined, numericRender, 150, columnOptions), - makeNumericColumn('Окончание', 'depthEnd', undefined, undefined, numericRender, 150, columnOptions), + makeNumericColumn('Начало', 'depthStart', numericRender, undefined, 150, columnOptions), + makeNumericColumn('Окончание', 'depthEnd', numericRender, undefined, 150, columnOptions), ]), ]) }, diff --git a/src/pages/Well/Telemetry/TelemetryView/Setpoints/SetpointSender.jsx b/src/pages/Well/Telemetry/TelemetryView/Setpoints/SetpointSender.jsx index 537ed29..62ee9bf 100644 --- a/src/pages/Well/Telemetry/TelemetryView/Setpoints/SetpointSender.jsx +++ b/src/pages/Well/Telemetry/TelemetryView/Setpoints/SetpointSender.jsx @@ -1,11 +1,11 @@ import { memo, useCallback, useMemo, useState } from 'react' -import { Select, Modal, Input, InputNumber } from 'antd' +import { Modal, Input } from 'antd' import { useWell } from '@asb/context' import { Grid, GridItem } from '@components/Grid' import LoaderPortal from '@components/LoaderPortal' import { invokeWebApiWrapperAsync } from '@components/factory' -import { makeNumericRender, EditableTable } from '@components/Table' +import { makeNumericRender, EditableTable, makeSelectColumn, makeNumericColumn } from '@components/Table' import { PeriodPicker, defaultPeriod } from '@components/selectors/PeriodPicker' import { SetpointsService } from '@api' @@ -19,24 +19,8 @@ export const SetpointSender = memo(({ onClose, visible, setpointNames }) => { const [well] = useWell() const addingColumns = useMemo(() => [ - { - title: 'Наименование уставки', - dataIndex: 'name', - editable: true, - isRequired: true, - width: 200, - input: