import { useState, useEffect } from 'react' import { Input, DatePicker, Select } from 'antd' import moment from 'moment' import { EditableTable } from "../../components/EditableTable" import LoaderPortal from '../../components/LoaderPortal' import { makeColumn, RegExpIsFloat, invokeWebApiWrapperAsync } from '../../components/factory' import { WellOperationService} from '../../services/api' import { dictionarySectionType, getNameById } from './dictionary' const { Option } = Select const { TextArea } = Input; const basePageSize = 160; const format='YYYY.MM.DD HH:mm' const numericColumnOptions = { editable: true, initialValue: 0, width:100, formItemRules: [ { required: true, message: `Введите число`, pattern: RegExpIsFloat, }, ], }; const DatePickerWrapper = ({value, onChange, ...other}) => { return onChange(date)} {...other} /> } export const WellOperationsEditor = ({idWell, idType}) => { const [pageNumAndPageSize, setPageNumAndPageSize] = useState({current:1, pageSize:basePageSize}) const [paginationTotal, setPaginationTotal] = useState(0) const [dictionaryOperationCategory, setDictionaryOperationCategory] = useState([]) const [operations, setOperations] = useState([]) const [showLoader, setShowLoader] = useState(false) useEffect(() => invokeWebApiWrapperAsync( async () => { const r = await WellOperationService.getCategories(idWell) setDictionaryOperationCategory(r) }),[idWell]) const updateOperations = () => invokeWebApiWrapperAsync( async () => { const skip = ((pageNumAndPageSize.current - 1) * pageNumAndPageSize.pageSize) || 0 const take = pageNumAndPageSize.pageSize const paginatedOperations = await WellOperationService.getOperations(idWell, idType, undefined, undefined, undefined, undefined, skip, take ) const operations = paginatedOperations?.items ?? [] setOperations(operations) const total = paginatedOperations.count?? paginatedOperations.items?.length ?? 0 setPaginationTotal(total) }, setShowLoader, 'Не удалось загрузить список операций по скважине' ) useEffect(updateOperations, [idWell, idType, pageNumAndPageSize]) const SelectorSectionType = const SelectorOperationCategory = const columns = [ makeColumn('Конструкция секции','idWellSectionType', { editable:true, input:SelectorSectionType, width:105, render:(_, record)=>getNameById(dictionarySectionType, record.idWellSectionType) }), makeColumn('Операция','idCategory', { editable:true, input:SelectorOperationCategory, width:200, render:(_, record)=>getNameById(dictionaryOperationCategory, record.idCategory) }), makeColumn('Доп. инфо','categoryInfo', {editable:true, width:300, input: