Merge pull request 'Актуализировать обработку данных на странице "Операции".' (#4) from fix/changing-operation-categories-controller into dev

Reviewed-on: http://46.146.209.148:8080/DDrilling/asb_cloud_front/pulls/4
Reviewed-by: Александр Сироткин <av.sirotkin@digitaldrilling.ru>
This commit is contained in:
Александр Сироткин 2022-12-20 14:28:13 +05:00
commit ed43ebb082
3 changed files with 13 additions and 14 deletions

View File

@ -12,5 +12,6 @@
"Setpoints",
"usehooks"
],
"liveServer.settings.port": 5501
"liveServer.settings.port": 5501,
"cSpell.language": "en,ru"
}

View File

@ -4,7 +4,7 @@ import { Button, Modal } from 'antd'
import { useWell } from '@asb/context'
import { invokeWebApiWrapperAsync } from '@components/factory'
import { EditableTable, makeGroupColumn, makeNumericColumn, makeNumericRender, makeSelectColumn } from '@components/Table'
import { DetectedOperationService, OperationValueService } from '@api'
import { OperationValueService } from '@api'
import { arrayOrDefault } from '@utils'
const columnOptions = {
@ -14,7 +14,7 @@ const columnOptions = {
const scroll = { y: '75vh', scrollToFirstRowOnChange: true }
const numericRender = makeNumericRender(2)
export const TargetEditor = memo(({ loading, onChange }) => {
export const TargetEditor = memo(({ loading, onChange, options }) => {
const [targets, setTargets] = useState([])
const [showModal, setShowModal] = useState(false)
const [showLoader, setShowLoader] = useState(false)
@ -62,9 +62,6 @@ export const TargetEditor = memo(({ loading, onChange }) => {
useEffect(() => {
invokeWebApiWrapperAsync(
async () => {
const categories = arrayOrDefault(await DetectedOperationService.getCategories())
const options = categories.map(({ id, name }) => ({ value: id, label: name }))
setTargetColumns([
makeSelectColumn('Название', 'idOperationCategory', options, undefined, { ...columnOptions, width: 200 }, {
showSearch: true,
@ -83,7 +80,7 @@ export const TargetEditor = memo(({ loading, onChange }) => {
`Не удалось получить список категорий целей`,
{ actionName: 'Получение списка категорий целей', well }
)
}, [well])
}, [options])
useEffect(() => {
updateTable()

View File

@ -8,7 +8,7 @@ import { DateRangeWrapper } from '@components/Table'
import { invokeWebApiWrapperAsync } from '@components/factory'
import { unique } from '@utils/filters'
import { getPermissions, arrayOrDefault, range, withPermissions, prettify } from '@utils'
import { DetectedOperationService, DrillerService, TelemetryDataSaubService } from '@api'
import { DetectedOperationService, DrillerService, TelemetryDataSaubService, WellOperationService } from '@api'
import DrillerList from './DrillerList'
import TargetEditor from './TargetEditor'
@ -26,7 +26,7 @@ const Operations = memo(() => {
const [data, setData] = useState({})
const [drillers, setDrillers] = useState([])
const [drillersLoader, setDrillersLoader] = useState(false)
const [selectedCategory, setSelectedCategory] = useState(14)
const [selectedCategory, setSelectedCategory] = useState(5011)
const [categories, setCategories] = useState()
const [well] = useWell()
@ -78,7 +78,7 @@ const Operations = memo(() => {
useEffect(() => {
invokeWebApiWrapperAsync(
async () => {
const categories = arrayOrDefault(await DetectedOperationService.getCategories())
const categories = arrayOrDefault(await WellOperationService.getCategories(well.id))
setCategories(categories.map((category) => ({
...category,
value: category.id,
@ -86,10 +86,10 @@ const Operations = memo(() => {
})))
},
setIsLoading,
'Не удалось загрзуить категории операций',
'Не удалось загрузить категории операций',
{ actionName: 'Получение категорий операций' }
)
}, [])
}, [well])
useEffect(() => {
invokeWebApiWrapperAsync(
@ -135,6 +135,7 @@ const Operations = memo(() => {
onChange={setYDomain}
addonAfter={'мин'}
addonBefore={'Верхняя граница'}
style={{width: '20em'}}
/>
{permissions.driller.get && (
<>
@ -142,8 +143,8 @@ const Operations = memo(() => {
<DrillerList drillers={drillers} loading={drillersLoader} onChange={updateDrillers} />
</>
)}
{permissions.detectedOperation.get && permissions.operationValue.get && (
<TargetEditor onChange={updateData} />
{permissions.detectedOperation.get && permissions.operationValue.get && categories && (
<TargetEditor onChange={updateData} options={categories} />
)}
</div>
<LoaderPortal show={isLoading}>