| | |
| | | import { getAreaInfo, fetchAgvListAll, updateAreaData, removeArea } from '../http'; |
| | | |
| | | const getAgvOptionId = (option) => { |
| | | // console.log(option); |
| | | |
| | | if (typeof option === 'string') { |
| | | return option; |
| | | if (option == null) { |
| | | return ''; |
| | | } |
| | | return option?.value ?? option?.id ?? option?.agvNo ?? option?.code ?? option?.name ?? ''; |
| | | if (typeof option === 'string' || typeof option === 'number') { |
| | | return String(option); |
| | | } |
| | | return option?.id ?? ''; |
| | | }; |
| | | |
| | | const areAgvSelectionsEqual = (aIds = [], bIds = []) => { |
| | |
| | | } |
| | | const setA = new Set(aIds); |
| | | return bIds.every(id => setA.has(id)); |
| | | }; |
| | | |
| | | const mapSelectionToOptions = (selection = [], options = []) => { |
| | | const optionMap = new Map(options.map(option => [getAgvOptionId(option), option])); |
| | | return selection |
| | | .map(item => optionMap.get(item) || null) |
| | | .filter(Boolean); |
| | | |
| | | }; |
| | | |
| | | const AreaSettings = (props) => { |
| | |
| | | setPriority(curAreaInfo.priority ?? ''); |
| | | |
| | | const selected = curAreaInfo.agvList || []; |
| | | setAgvList(selected); |
| | | const normalizedSelection = mapSelectionToOptions(selected, agvOptions); |
| | | setAgvList(normalizedSelection); |
| | | setInitialBasic({ |
| | | name: curAreaInfo.name || '', |
| | | agvIds: selected |
| | | agvIds: normalizedSelection.map(getAgvOptionId) |
| | | }); |
| | | |
| | | const codes = curAreaInfo.codeList || []; |