forked from ddrilling/asb_cloud_front
Исправлена ошибка с исчезновением столбца "Часы"
This commit is contained in:
parent
befac57c30
commit
cacacd1749
@ -27,8 +27,9 @@ const basePageSize = 160
|
|||||||
const dayRender = makeNumericRender(2)
|
const dayRender = makeNumericRender(2)
|
||||||
const dayWithoutNptRender = (_, row) => dayRender((row.day ?? 0) - (row.nptHours ?? 0) / 24)
|
const dayWithoutNptRender = (_, row) => dayRender((row.day ?? 0) - (row.nptHours ?? 0) / 24)
|
||||||
|
|
||||||
const defaultColumns = [
|
const generateColumns = (showNpt = false, categories = [], sectionTypes = []) => [
|
||||||
makeSelectColumn('Конструкция секции', 'idWellSectionType', [], undefined, {
|
makeSelectColumn('Конструкция секции', 'idWellSectionType', sectionTypes, undefined, {
|
||||||
|
sorter: makeNumericSorter('idWellSectionType'),
|
||||||
editable: true,
|
editable: true,
|
||||||
width: 160,
|
width: 160,
|
||||||
formItemRules: [() => ({
|
formItemRules: [() => ({
|
||||||
@ -39,7 +40,11 @@ const defaultColumns = [
|
|||||||
}
|
}
|
||||||
})],
|
})],
|
||||||
}),
|
}),
|
||||||
makeSelectColumn('Операция', 'idCategory', [], undefined, { editable: true, width: 200 }),
|
makeSelectColumn('Операция', 'idCategory', categories, undefined, {
|
||||||
|
sorter: makeNumericSorter('idCategory'),
|
||||||
|
editable: true,
|
||||||
|
width: 200,
|
||||||
|
}),
|
||||||
makeTextColumn('Доп. инфо', 'categoryInfo', null, null, null, { editable: true, width: 300, input: <TextArea/> }),
|
makeTextColumn('Доп. инфо', 'categoryInfo', null, null, null, { editable: true, width: 300, input: <TextArea/> }),
|
||||||
makeColumn('Глубина забоя на начало, м', 'depthStart', makeNumericColumnOptions(2, 'depthStart')),
|
makeColumn('Глубина забоя на начало, м', 'depthStart', makeNumericColumnOptions(2, 'depthStart')),
|
||||||
makeColumn('Глубина забоя при завершении, м', 'depthEnd', makeNumericColumnOptions(2, 'depthEnd')),
|
makeColumn('Глубина забоя при завершении, м', 'depthEnd', makeNumericColumnOptions(2, 'depthEnd')),
|
||||||
@ -49,16 +54,21 @@ const defaultColumns = [
|
|||||||
initialValue: moment().format(),
|
initialValue: moment().format(),
|
||||||
}),
|
}),
|
||||||
makeNumericColumn('День', 'day', null, null, dayRender, 80),
|
makeNumericColumn('День', 'day', null, null, dayRender, 80),
|
||||||
|
showNpt && makeNumericColumn('День без НПВ', 'dayWithoutNpt', null, null, dayWithoutNptRender, 80),
|
||||||
makeColumn('Часы', 'durationHours', { ...makeNumericColumnOptions(2, 'durationHours'), width: 70 }),
|
makeColumn('Часы', 'durationHours', { ...makeNumericColumnOptions(2, 'durationHours'), width: 70 }),
|
||||||
makeTextColumn('Комментарий', 'comment', null, null, null, { editable: true, input: <TextArea/> }),
|
makeTextColumn('Комментарий', 'comment', null, null, null, { editable: true, input: <TextArea/> }),
|
||||||
]
|
].filter(Boolean)
|
||||||
|
|
||||||
export const WellOperationsEditor = memo(({ idWell, idType, showNpt, ...other }) => {
|
export const WellOperationsEditor = memo(({ idWell, idType, showNpt, ...other }) => {
|
||||||
const [pageNumAndPageSize, setPageNumAndPageSize] = useState({ current: 1, pageSize: basePageSize })
|
const [pageNumAndPageSize, setPageNumAndPageSize] = useState({ current: 1, pageSize: basePageSize })
|
||||||
const [paginationTotal, setPaginationTotal] = useState(0)
|
const [paginationTotal, setPaginationTotal] = useState(0)
|
||||||
const [operations, setOperations] = useState([])
|
const [operations, setOperations] = useState([])
|
||||||
const [showLoader, setShowLoader] = useState(false)
|
const [showLoader, setShowLoader] = useState(false)
|
||||||
const [columns, setColumns] = useState(defaultColumns)
|
|
||||||
|
const [categories, setCategories] = useState([])
|
||||||
|
const [sectionTypes, setSectionTypes] = useState([])
|
||||||
|
|
||||||
|
const columns = useMemo(() => generateColumns(showNpt, categories, sectionTypes), [showNpt, categories, sectionTypes])
|
||||||
|
|
||||||
const location = useLocation()
|
const location = useLocation()
|
||||||
const selectedIds = useMemo(() => {
|
const selectedIds = useMemo(() => {
|
||||||
@ -66,56 +76,19 @@ export const WellOperationsEditor = memo(({ idWell, idType, showNpt, ...other })
|
|||||||
return arrayOrDefault(query.get('selectedId')?.split(',')?.map(parseInt))
|
return arrayOrDefault(query.get('selectedId')?.split(',')?.map(parseInt))
|
||||||
}, [location])
|
}, [location])
|
||||||
|
|
||||||
// useEffect(() => {
|
|
||||||
// setColumns((preColumns) => preColumns.find(()))
|
|
||||||
// }, [showNpt])
|
|
||||||
|
|
||||||
useEffect(() => invokeWebApiWrapperAsync(
|
useEffect(() => invokeWebApiWrapperAsync(
|
||||||
async () => {
|
async () => {
|
||||||
let categories = arrayOrDefault(await WellOperationService.getCategories(idWell))
|
const categories = arrayOrDefault(await WellOperationService.getCategories(idWell))
|
||||||
categories = categories.map((item) => ({ value: item.id, label: item.name }))
|
setCategories(categories.map((item) => ({ value: item.id, label: item.name })))
|
||||||
|
|
||||||
let sectionTypes = await WellOperationService.getSectionTypes(idWell) ?? {}
|
const sectionTypes = Object.entries(await WellOperationService.getSectionTypes(idWell) ?? {})
|
||||||
sectionTypes = Object.entries(sectionTypes).map(([id, label]) => ({ value: parseInt(id), label }))
|
setSectionTypes(sectionTypes.map(([id, label]) => ({ value: parseInt(id), label })))
|
||||||
|
|
||||||
setColumns(preColumns => [
|
|
||||||
makeSelectColumn('Конструкция секции', 'idWellSectionType', sectionTypes, undefined, {
|
|
||||||
editable: true,
|
|
||||||
width: 160,
|
|
||||||
sorter: makeNumericSorter('idWellSectionType'),
|
|
||||||
}),
|
|
||||||
makeSelectColumn('Операция', 'idCategory', categories, undefined, {
|
|
||||||
editable: true,
|
|
||||||
width: 200,
|
|
||||||
sorter: makeNumericSorter('idCategory'),
|
|
||||||
}),
|
|
||||||
...preColumns.slice(2),
|
|
||||||
])
|
|
||||||
},
|
},
|
||||||
setShowLoader,
|
setShowLoader,
|
||||||
'Не удалось загрузить список операций по скважине',
|
'Не удалось загрузить список операций по скважине',
|
||||||
'Получение списка операций по скважине'
|
'Получение списка операций по скважине'
|
||||||
), [idWell])
|
), [idWell])
|
||||||
|
|
||||||
useEffect(() => invokeWebApiWrapperAsync(
|
|
||||||
async() => {
|
|
||||||
setColumns((preColumns) => {
|
|
||||||
if (!!preColumns.find((col) => col.key === 'dayWithoutNpt') === showNpt)
|
|
||||||
return preColumns
|
|
||||||
const newColumns = preColumns.slice(0, 7)
|
|
||||||
if (showNpt)
|
|
||||||
newColumns.push(
|
|
||||||
makeNumericColumn('День без НПВ', 'dayWithoutNpt', null, null, dayWithoutNptRender, 80),
|
|
||||||
...preColumns.slice(7)
|
|
||||||
)
|
|
||||||
else newColumns.push(...preColumns.slice(8))
|
|
||||||
return newColumns
|
|
||||||
})
|
|
||||||
},
|
|
||||||
setShowLoader,
|
|
||||||
'Не удалось добавить стоблец "День без НПВ"'
|
|
||||||
), [showNpt])
|
|
||||||
|
|
||||||
const updateOperations = useCallback(() => invokeWebApiWrapperAsync(
|
const updateOperations = useCallback(() => invokeWebApiWrapperAsync(
|
||||||
async () => {
|
async () => {
|
||||||
const skip = ((pageNumAndPageSize.current - 1) * pageNumAndPageSize.pageSize) || 0
|
const skip = ((pageNumAndPageSize.current - 1) * pageNumAndPageSize.pageSize) || 0
|
||||||
|
Loading…
Reference in New Issue
Block a user