| | |
| | | import { getAreaInfo, fetchAgvListAll, updateAreaData, removeArea } from '../http'; |
| | | |
| | | const getAgvOptionId = (option) => { |
| | | // console.log(option); |
| | | |
| | | if (typeof option === 'string') { |
| | | return option; |
| | | } |
| | |
| | | |
| | | useEffect(() => { |
| | | if (curAreaInfo) { |
| | | console.log(curAreaInfo); |
| | | |
| | | setName(curAreaInfo.name || ''); |
| | | setCode(curAreaInfo.code || ''); |
| | | setMaxCount(curAreaInfo.maxCount ?? ''); |
| | |
| | | setPriority(curAreaInfo.priority ?? ''); |
| | | |
| | | const selected = curAreaInfo.agvList || []; |
| | | const normalizedSelection = mapSelectionToOptions(selected, agvOptions); |
| | | setAgvList(normalizedSelection); |
| | | // const normalizedSelection = mapSelectionToOptions(selected, agvOptions); |
| | | setAgvList(selected); |
| | | setInitialBasic({ |
| | | name: curAreaInfo.name || '', |
| | | agvIds: normalizedSelection.map(getAgvOptionId) |
| | | agvIds: selected |
| | | }); |
| | | |
| | | const codes = curAreaInfo.codeList || []; |
| | |
| | | name, |
| | | agvIds: agvList.map(getAgvOptionId), |
| | | }; |
| | | const success = await updateAreaData(payload); |
| | | if (success) { |
| | | setInitialBasic({ |
| | | name, |
| | | agvIds: payload.agvIds, |
| | | }); |
| | | fetchAreaInfo(id); |
| | | const data = await updateAreaData(payload); |
| | | if (data) { |
| | | console.log(data); |
| | | |
| | | setCurAreaInfo(data); |
| | | // setInitialBasic({ |
| | | // name, |
| | | // agvIds: payload.agvIds, |
| | | // }); |
| | | // fetchAreaInfo(id); |
| | | } |
| | | }; |
| | | |