| | |
| | | console.error(error.message); |
| | | } |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | export const locateAllAgv = async (param) => { |
| | | try { |
| | | const res = await request.post('/handler/locateAllAgv', param, { |
| | | headers: { |
| | | 'appKey': HANDLE_APP_KEY |
| | | } |
| | | }); |
| | | const { code, msg, data } = res.data; |
| | | if (code === 200) { |
| | | notify.success(msg); |
| | | return true; |
| | | } else { |
| | | notify.error(msg); |
| | | } |
| | | } catch (error) { |
| | | notify.error(error.message); |
| | | console.error(error.message); |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | export const startPatrolBatch = async (param) => { |
| | | try { |
| | | const res = await request.post('/handler/patrol/batch/startup', param, { |
| | | headers: { |
| | | 'appKey': HANDLE_APP_KEY |
| | | } |
| | | }); |
| | | const { code, msg, data } = res.data; |
| | | if (code === 200) { |
| | | notify.success(msg); |
| | | return true; |
| | | } else { |
| | | notify.error(msg); |
| | | } |
| | | } catch (error) { |
| | | notify.error(error.message); |
| | | console.error(error.message); |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | export const cancelPatrolBatch = async (param) => { |
| | | try { |
| | | const res = await request.post('/handler/patrol/batch/shutdown', param, { |
| | | headers: { |
| | | 'appKey': HANDLE_APP_KEY |
| | | } |
| | | }); |
| | | const { code, msg, data } = res.data; |
| | | if (code === 200) { |
| | | notify.success(msg); |
| | | return true; |
| | | } else { |
| | | notify.error(msg); |
| | | } |
| | | } catch (error) { |
| | | notify.error(error.message); |
| | | console.error(error.message); |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | |
| | | export const fetchAreaList = async (zoneId) => { |
| | | try { |
| | | const res = await request.post('/map/area/list', { |
| | | zoneId: zoneId, |
| | | }, { |
| | | headers: { 'Content-Type': 'application/x-www-form-urlencoded' } |
| | | }); |
| | | const { code, msg, data } = res.data; |
| | | if (code === 200) { |
| | | return data || []; |
| | | } else { |
| | | notify.error(msg); |
| | | return []; |
| | | } |
| | | } catch (error) { |
| | | notify.error(error.message); |
| | | console.error(error.message); |
| | | return []; |
| | | } |
| | | } |
| | | |
| | | export const getAreaInfo = async (param, callback) => { |
| | | await request.get('/map/area/get', param).then((res) => { |
| | | const { code, msg, data } = res.data; |
| | | if (code === 200) { |
| | | if (callback) { |
| | | callback(data) |
| | | } |
| | | } else { |
| | | notify.error(msg); |
| | | } |
| | | }).catch((error) => { |
| | | notify.error(error.message); |
| | | console.error(error.message); |
| | | }) |
| | | } |
| | | |
| | | export const saveAreaData = async (zoneId, areaData) => { |
| | | try { |
| | | const res = await request.post('/map/area/save', { |
| | | zoneId: zoneId, |
| | | ...areaData, |
| | | }); |
| | | const { code, msg, data } = res.data; |
| | | if (code !== 200) { |
| | | notify.error(msg); |
| | | return null; |
| | | } |
| | | return data; |
| | | } catch (error) { |
| | | notify.error(error.message); |
| | | console.error(error.message); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | export const updateAreaData = async (payload = {}) => { |
| | | try { |
| | | const res = await request.post('/map/area/update', payload); |
| | | const { code, msg } = res.data; |
| | | if (code === 200) { |
| | | notify.success?.(msg); |
| | | return true; |
| | | } |
| | | notify?.error?.(msg); |
| | | } catch (error) { |
| | | notify.error(error.message); |
| | | console.error(error.message); |
| | | } |
| | | return false; |
| | | }; |
| | | |
| | | export const removeArea = async (areaId) => { |
| | | try { |
| | | const res = await request.post('/map/area/remove', { areaId }); |
| | | const { code, msg } = res.data; |
| | | if (code === 200) { |
| | | notify.success(msg); |
| | | return true; |
| | | } |
| | | notify.error(msg); |
| | | } catch (error) { |
| | | notify.error(error.message); |
| | | console.error(error.message); |
| | | } |
| | | return false; |
| | | }; |
| | | |
| | | export const fetchAgvListAll = async () => { |
| | | try { |
| | | const res = await request.post('/agv/list', {}); |
| | | const { code, msg, data } = res.data; |
| | | if (code === 200) { |
| | | return data || []; |
| | | } |
| | | notify.error(msg); |
| | | } catch (error) { |
| | | notify.error(error.message); |
| | | console.error(error.message); |
| | | } |
| | | return []; |
| | | } |