diff --git a/src/pages/WellOperations.jsx b/src/pages/WellOperations.jsx
index bf444e0..427522f 100644
--- a/src/pages/WellOperations.jsx
+++ b/src/pages/WellOperations.jsx
@@ -38,10 +38,10 @@ export default function WellOperations({idWell}) {
sss
-
+
- sss
+
diff --git a/src/pages/WellOperationsEditor.jsx b/src/pages/WellOperationsEditor.jsx
index c9199bd..b8d577d 100644
--- a/src/pages/WellOperationsEditor.jsx
+++ b/src/pages/WellOperationsEditor.jsx
@@ -1,13 +1,21 @@
import { useState, useEffect } from 'react'
-import { Input, DatePicker } from 'antd'
+import { Input, DatePicker, Select } from 'antd'
import { EditableTable } from "../components/EditableTable"
import LoaderPortal from '../components/LoaderPortal'
import { makeColumn, RegExpIsFloat, invokeWebApiWrapperAsync } from '../components/factory'
import { WellOperationService} from '../services/api'
+import moment from 'moment'
+
+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,
@@ -17,41 +25,54 @@ const numericColumnOptions = {
],
};
-const TypeSelector =
-
-const DataListSectionTypes =
-
-const columns = [
- makeColumn('Конструкция секции','wellSectionTypeName', {editable:true, input:TypeSelector}),
- makeColumn('Операция','categoryName', {editable:true, input:TypeSelector}),
- makeColumn('Доп. инфо','info', {editable:true}),
- makeColumn('Глубина забоя','wellDepth', numericColumnOptions),
- makeColumn('Время начала','startDate', {editable:true, input:}),
- makeColumn('Продолжительность','durationHours', numericColumnOptions),
- makeColumn('Комментарий','comment', {editable:true}),
+const dictionarySectionType = [
+ {id:1, name:'Пилотный ствол'},
+ {id:2, name:'Направление'},
+ {id:3, name:'Кондуктор'},
+ {id:4, name:'Эксплуатационная колонна'},
+ {id:5, name:'Транспортный ствол'},
+ {id:6, name:'Хвостовик'},
]
-const basePageSize = 32;
+const getNameById = (dictionary, id) => {
+ if(!dictionary?.length)
+ return id
+ const item = dictionary.find(i => i?.id === id)
+ return item?.name ?? id
+}
-export default function WellOperationsEditor({idWell, type}){
+const DatePickerWrapper = ({value, onChange, ...other}) => {
+ return onChange(date)}
+ {...other}
+ />
+}
+
+export default function 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, type, undefined, undefined, undefined, undefined, skip, take )
- setOperations(paginatedOperations?.items??[])
+ 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)
},
@@ -59,22 +80,73 @@ export default function WellOperationsEditor({idWell, type}){
'Не удалось загрузить список операций по скважине'
)
- useEffect(updateOperations, [idWell, type, pageNumAndPageSize])
+ useEffect(updateOperations, [idWell, idType, pageNumAndPageSize])
- const onAdd = (newOperation) => {
+ 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:}),
+ makeColumn('Глубина забоя','wellDepth', {...numericColumnOptions}),
+ makeColumn('Время начала','startDate', {
+ editable:true,
+ width:200,
+ input:,
+ render:(_, record) => moment.utc(record.startDate).local().format(format)
+ }),
+ makeColumn('Часы','durationHours', {...numericColumnOptions}),
+ makeColumn('Комментарий','comment', {editable:true, input:}),
+ ]
+
+ const onAdd = async (operation) => {
+ operation.idType = idType
+ await WellOperationService.insertRange(idWell, [operation])
+ updateOperations()
}
- const onEdit= (newOperation) => {
-
+ const onEdit= async (operation) => {
+ if(!operation.id)
+ return
+ operation.idType = idType
+ await WellOperationService.update(idWell, operation.id, operation)
+ updateOperations()
}
- const onDelete= (newOperation) => {
-
+ const onDelete= async (operation) => {
+ if(!operation.id)
+ return
+ await WellOperationService.delete(idWell, operation.id)
+ updateOperations()
}
return
setPageNumAndPageSize({current: page, pageSize: pageSize})
}}
/>
- {DataListSectionTypes}
}
\ No newline at end of file