1
Administrator
4 天以前 63703b10d1f68df3f47c2f071c19fad5686274f0
zy-acs-flow/src/map/http.js
@@ -14,6 +14,26 @@
    mapContainer = param;
}
export const fetchMapPreferences = async (zoneId, setMapPreferences) => {
    try {
        const res = await request.post('/map/config/preferences', {
            zoneId: zoneId
        }, {
            headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
        });
        const { code, msg, data } = res.data;
        if (code === 200) {
            setMapPreferences(data);
            return data || {};
        }
        notify?.error(msg);
    } catch (error) {
        notify?.error(error.message);
        console.error(error.message);
    }
    return {};
}
export const fetchMapData = (zoneId, setRcsStatus, setCurSprite) => {
    Tool.clearMapData();
    return request.post('/map/data/fetch', {
@@ -131,8 +151,8 @@
export const getLocGroup = async (row, bay, callback) => {
    await request.post('/map/shelf/group', {
        row: row,
        bay: bay
        rowNo: row,
        bayNo: bay
    }, {
        headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
    }).then((res) => {
@@ -181,6 +201,78 @@
    }).catch((error) => {
        notify.error(error.message);
        console.error(error.message);
    })
}
export const getCodeInfo = async (codeData, callback, errCallBack) => {
    await request.post('/code/info', {
        codeData,
    }, {
        headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
    }).then((res) => {
        const { code, msg, data } = res.data;
        if (code === 200) {
            callback(data);
        } else {
            notify?.error(msg);
            if (errCallBack) {
                errCallBack();
            }
        }
    }).catch((error) => {
        notify?.error(error.message);
        console.error(error.message);
        if (errCallBack) {
            errCallBack();
        }
    })
}
export const getCodeRouteList = async (codeData, callback, errCallBack) => {
    await request.post('/code/route/list', {
        codeData,
    }, {
        headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
    }).then((res) => {
        const { code, msg, data } = res.data;
        if (code === 200) {
            callback(Array.isArray(data) ? data : []);
        } else {
            notify?.error(msg);
            if (errCallBack) {
                errCallBack();
            }
        }
    }).catch((error) => {
        notify?.error(error.message);
        console.error(error.message);
        if (errCallBack) {
            errCallBack();
        }
    })
}
export const getCodeFuncStaList = async (codeData, callback, errCallBack) => {
    await request.post('/code/funcSta/list', {
        codeData,
    }, {
        headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
    }).then((res) => {
        const { code, msg, data } = res.data;
        if (code === 200) {
            callback(Array.isArray(data) ? data : []);
        } else {
            notify?.error(msg);
            if (errCallBack) {
                errCallBack();
            }
        }
    }).catch((error) => {
        notify?.error(error.message);
        console.error(error.message);
        if (errCallBack) {
            errCallBack();
        }
    })
}
@@ -396,18 +488,99 @@
    }
}
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 } = res.data;
        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, data } = res.data;
        if (code === 200) {
            notify.success(msg);
            return data;
        }
        notify.error(msg);
    } catch (error) {
        notify.error(error.message);
        console.error(error.message);
    }
    return null;
};
export const removeArea = async (id) => {
    try {
        const res = await request.post('/map/area/remove', { id });
        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 [];
}
export const fetchNewsLogs = async () => {
    try {
        const res = await request.get('/news/print');
        const { code, msg, data } = res.data;
        if (code === 200) {
            return Array.isArray(data) ? data : [];
        }
        notify?.error(msg);
    } catch (error) {
        notify?.error(error.message);
        console.error(error.message);
    }
    return null;
}