SourceTermAnalysisSystem_vue/src/utils/axios/fskjk/index.ts
2026-08-11 18:24:37 +08:00

136 lines
3.1 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { baseURL, serverIp } from "@/gis/common/config";
import { ElLoading, ElMessage } from "element-plus";
import request from "@/utils/request"; // 复用已有的Axios请求实例
import axios from "axios";
/**
* 生成任务所属GIF文件
*/
export async function getrwssGifFileData(
params: any,
callback?: (data: any) => void,
): Promise<any> {
const response = await request({
url: `${serverIp}${baseURL}/transportResult/genGif`,
method: "POST",
params,
});
if (response.success && response.code === 200) {
ElMessage({
type: "success",
message: response.message,
});
callback?.(response);
}
}
/**
* 下载任务所属GIF文件
*/
export async function downGifSsFile(
params: any,
callback?: (data: any) => void,
): Promise<any> {
// 开启Loading和你项目样式保持一致
const loadingInstance = ElLoading.service({
lock: true,
text: "Loading...",
background: "rgba(0, 0, 0, 0.7)",
target: document.querySelector(".base-layout"),
});
try {
const token = localStorage.getItem("token");
const fullResponse = await axios({
baseURL: serverIp,
url: `${serverIp}${baseURL}/transportResult/downloadGif`,
method: "GET",
params,
responseType: "blob",
timeout: 300000,
headers: {
"Content-Type": "application/json;charset=utf-8",
...(token ? { "X-Access-Token": token } : {}),
},
});
console.log(fullResponse, "完整响应");
callback?.(fullResponse);
} catch (err) {
ElMessage.error("gif下载请求失败");
throw err;
} finally {
// 无论成功失败一定关闭loading
loadingInstance.close();
}
}
/**
* 获取任务生成GIF文件过程日志
*/
export async function getRwscGifFileGcrz(
params: any,
callback?: (data: any) => void,
): Promise<any> {
const response = await request({
url: `${serverIp}${baseURL}/transportResult/getGenGiflog`,
method: "GET",
params,
});
if (response.success && response.code === 200) {
callback?.(response);
}
}
/**
* 缓存数据
*/
export async function getHcQxData(
params: any,
callback?: (data: any) => void,
): Promise<any> {
const response = await request({
url: `${serverIp}${baseURL}/weatherData/cacheWeatherData`,
method: "GET",
params,
});
if (response.success && response.code === 200) {
callback?.(response);
}
}
// 获取任务NC文件最大值
export async function getRwNcMaxValue(
params: any,
callback?: (data: any) => void,
): Promise<any> {
const response = await request({
url: `${serverIp}${baseURL}/transportResult/getNCResultGlobalMaximum`,
method: "GET",
params,
});
if (response.success && response.code === 200) {
callback?.(response);
}
}
// 停止任务
export async function stopRw(
params: any,
callback?: (data: any) => void,
): Promise<any> {
const response = await request({
url: `${serverIp}${baseURL}/transportTask/stopTask`,
method: "PUT",
params,
});
if (response.success && response.code === 200) {
ElMessage({
type: "success",
message: "停止成功",
});
callback?.(response);
}
}