forked from ddrilling/asb_cloud_front
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:
commit
ed43ebb082
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
@ -12,5 +12,6 @@
|
|||||||
"Setpoints",
|
"Setpoints",
|
||||||
"usehooks"
|
"usehooks"
|
||||||
],
|
],
|
||||||
"liveServer.settings.port": 5501
|
"liveServer.settings.port": 5501,
|
||||||
|
"cSpell.language": "en,ru"
|
||||||
}
|
}
|
@ -4,7 +4,7 @@ import { Button, Modal } from 'antd'
|
|||||||
import { useWell } from '@asb/context'
|
import { useWell } from '@asb/context'
|
||||||
import { invokeWebApiWrapperAsync } from '@components/factory'
|
import { invokeWebApiWrapperAsync } from '@components/factory'
|
||||||
import { EditableTable, makeGroupColumn, makeNumericColumn, makeNumericRender, makeSelectColumn } from '@components/Table'
|
import { EditableTable, makeGroupColumn, makeNumericColumn, makeNumericRender, makeSelectColumn } from '@components/Table'
|
||||||
import { DetectedOperationService, OperationValueService } from '@api'
|
import { OperationValueService } from '@api'
|
||||||
import { arrayOrDefault } from '@utils'
|
import { arrayOrDefault } from '@utils'
|
||||||
|
|
||||||
const columnOptions = {
|
const columnOptions = {
|
||||||
@ -14,7 +14,7 @@ const columnOptions = {
|
|||||||
const scroll = { y: '75vh', scrollToFirstRowOnChange: true }
|
const scroll = { y: '75vh', scrollToFirstRowOnChange: true }
|
||||||
const numericRender = makeNumericRender(2)
|
const numericRender = makeNumericRender(2)
|
||||||
|
|
||||||
export const TargetEditor = memo(({ loading, onChange }) => {
|
export const TargetEditor = memo(({ loading, onChange, options }) => {
|
||||||
const [targets, setTargets] = useState([])
|
const [targets, setTargets] = useState([])
|
||||||
const [showModal, setShowModal] = useState(false)
|
const [showModal, setShowModal] = useState(false)
|
||||||
const [showLoader, setShowLoader] = useState(false)
|
const [showLoader, setShowLoader] = useState(false)
|
||||||
@ -62,9 +62,6 @@ export const TargetEditor = memo(({ loading, onChange }) => {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
invokeWebApiWrapperAsync(
|
invokeWebApiWrapperAsync(
|
||||||
async () => {
|
async () => {
|
||||||
const categories = arrayOrDefault(await DetectedOperationService.getCategories())
|
|
||||||
const options = categories.map(({ id, name }) => ({ value: id, label: name }))
|
|
||||||
|
|
||||||
setTargetColumns([
|
setTargetColumns([
|
||||||
makeSelectColumn('Название', 'idOperationCategory', options, undefined, { ...columnOptions, width: 200 }, {
|
makeSelectColumn('Название', 'idOperationCategory', options, undefined, { ...columnOptions, width: 200 }, {
|
||||||
showSearch: true,
|
showSearch: true,
|
||||||
@ -83,7 +80,7 @@ export const TargetEditor = memo(({ loading, onChange }) => {
|
|||||||
`Не удалось получить список категорий целей`,
|
`Не удалось получить список категорий целей`,
|
||||||
{ actionName: 'Получение списка категорий целей', well }
|
{ actionName: 'Получение списка категорий целей', well }
|
||||||
)
|
)
|
||||||
}, [well])
|
}, [options])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
updateTable()
|
updateTable()
|
||||||
|
@ -8,7 +8,7 @@ import { DateRangeWrapper } from '@components/Table'
|
|||||||
import { invokeWebApiWrapperAsync } from '@components/factory'
|
import { invokeWebApiWrapperAsync } from '@components/factory'
|
||||||
import { unique } from '@utils/filters'
|
import { unique } from '@utils/filters'
|
||||||
import { getPermissions, arrayOrDefault, range, withPermissions, prettify } from '@utils'
|
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 DrillerList from './DrillerList'
|
||||||
import TargetEditor from './TargetEditor'
|
import TargetEditor from './TargetEditor'
|
||||||
@ -26,7 +26,7 @@ const Operations = memo(() => {
|
|||||||
const [data, setData] = useState({})
|
const [data, setData] = useState({})
|
||||||
const [drillers, setDrillers] = useState([])
|
const [drillers, setDrillers] = useState([])
|
||||||
const [drillersLoader, setDrillersLoader] = useState(false)
|
const [drillersLoader, setDrillersLoader] = useState(false)
|
||||||
const [selectedCategory, setSelectedCategory] = useState(14)
|
const [selectedCategory, setSelectedCategory] = useState(5011)
|
||||||
const [categories, setCategories] = useState()
|
const [categories, setCategories] = useState()
|
||||||
|
|
||||||
const [well] = useWell()
|
const [well] = useWell()
|
||||||
@ -78,7 +78,7 @@ const Operations = memo(() => {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
invokeWebApiWrapperAsync(
|
invokeWebApiWrapperAsync(
|
||||||
async () => {
|
async () => {
|
||||||
const categories = arrayOrDefault(await DetectedOperationService.getCategories())
|
const categories = arrayOrDefault(await WellOperationService.getCategories(well.id))
|
||||||
setCategories(categories.map((category) => ({
|
setCategories(categories.map((category) => ({
|
||||||
...category,
|
...category,
|
||||||
value: category.id,
|
value: category.id,
|
||||||
@ -86,10 +86,10 @@ const Operations = memo(() => {
|
|||||||
})))
|
})))
|
||||||
},
|
},
|
||||||
setIsLoading,
|
setIsLoading,
|
||||||
'Не удалось загрзуить категории операций',
|
'Не удалось загрузить категории операций',
|
||||||
{ actionName: 'Получение категорий операций' }
|
{ actionName: 'Получение категорий операций' }
|
||||||
)
|
)
|
||||||
}, [])
|
}, [well])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
invokeWebApiWrapperAsync(
|
invokeWebApiWrapperAsync(
|
||||||
@ -135,6 +135,7 @@ const Operations = memo(() => {
|
|||||||
onChange={setYDomain}
|
onChange={setYDomain}
|
||||||
addonAfter={'мин'}
|
addonAfter={'мин'}
|
||||||
addonBefore={'Верхняя граница'}
|
addonBefore={'Верхняя граница'}
|
||||||
|
style={{width: '20em'}}
|
||||||
/>
|
/>
|
||||||
{permissions.driller.get && (
|
{permissions.driller.get && (
|
||||||
<>
|
<>
|
||||||
@ -142,8 +143,8 @@ const Operations = memo(() => {
|
|||||||
<DrillerList drillers={drillers} loading={drillersLoader} onChange={updateDrillers} />
|
<DrillerList drillers={drillers} loading={drillersLoader} onChange={updateDrillers} />
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
{permissions.detectedOperation.get && permissions.operationValue.get && (
|
{permissions.detectedOperation.get && permissions.operationValue.get && categories && (
|
||||||
<TargetEditor onChange={updateData} />
|
<TargetEditor onChange={updateData} options={categories} />
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<LoaderPortal show={isLoading}>
|
<LoaderPortal show={isLoading}>
|
||||||
|
Loading…
Reference in New Issue
Block a user