From d2d58bbda45b6e91955bf67013fc819ffe03939b Mon Sep 17 00:00:00 2001 From: limengnan <420004014@qq.com> Date: Wed, 11 Mar 2026 18:12:59 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business-css/frontend/src/utils/request.ts | 15 ++--- .../modelTrainTask/index.vue | 58 ++++++++++++------- 2 files changed, 45 insertions(+), 28 deletions(-) diff --git a/business-css/frontend/src/utils/request.ts b/business-css/frontend/src/utils/request.ts index abe108e..6175508 100644 --- a/business-css/frontend/src/utils/request.ts +++ b/business-css/frontend/src/utils/request.ts @@ -6,17 +6,18 @@ import { useUserStoreHook } from '@/store/modules/user'; // 创建 axios 实例 const service = axios.create({ baseURL: import.meta.env.VITE_APP_BASE_API, - timeout: 50000, - headers: { 'Content-Type': 'application/json;charset=utf-8' } + timeout: 50000 }); // 请求拦截器 service.interceptors.request.use( - (config: AxiosRequestConfig) => { + (config: any) => { if (!config.headers) { - throw new Error( - `Expected 'config' and 'config.headers' not to be undefined` - ); + config.headers = {}; + } + // Only set Content-Type if data is not FormData + if (!(config.data instanceof FormData)) { + config.headers['Content-Type'] = 'application/json;charset=utf-8'; } const user = useUserStoreHook(); if (user.Token) { @@ -31,7 +32,7 @@ service.interceptors.request.use( // 响应拦截器 service.interceptors.response.use( - (response: AxiosResponse) => { + (response: any) => { const { status, msg } = response; if (status === 200) { if (response.data.code == 401) { diff --git a/business-css/frontend/src/views/business/algorithmManagement/modelTrainTask/index.vue b/business-css/frontend/src/views/business/algorithmManagement/modelTrainTask/index.vue index d48a1dc..2d323e7 100644 --- a/business-css/frontend/src/views/business/algorithmManagement/modelTrainTask/index.vue +++ b/business-css/frontend/src/views/business/algorithmManagement/modelTrainTask/index.vue @@ -14,11 +14,14 @@ const apiUrl = import.meta.env.VITE_APP_BASE_API; // 基础路径 const fileList:any = ref([]) const isSwitch = ref(false); // 搜索框 -const queryParams = ref({ +const queryParams:any = ref({ current: 1, size: 10, total: 0, title: '', + algorithmType: '', + deviceType: '', + state: '', }); //新建训练任务 const rules = reactive({ @@ -132,15 +135,21 @@ function addClick() { function confirmClick(formEl: any) { formEl.validate((valid: any) => { if (valid) { - if(isSwitch.value == true){ - return - } - isSwitch.value == true + if(isSwitch.value == true){ + return + } + isSwitch.value = true // const data:any = { // taskJson: JSON.stringify(info.value), // } + const data = new FormData() - data.append('taskJson', JSON.stringify(info.value)) + info.value.trainParams = JSON.stringify(trainParamsData.value) + data.append('task', JSON.stringify(info.value)) + // Add file if exists + if (fileList.value.length > 0) { + data.append('file', fileList.value[0].raw) + } dialogVisible.value = false addAlgorithms(data).then((res: any) => { dialogVisible.value = false; @@ -148,20 +157,16 @@ function confirmClick(formEl: any) { message: "新增成功", type: "success", }) - }) gettableData(); - }else{ - isSwitch.value = false; - } - }).catch(() => { dialogVisible.value = false; - + isSwitch.value = false; }) - + }else{ + isSwitch.value = false; } - - + }) +} //新建角色-取消按钮 function handleClose() { dialogVisible.value = false; @@ -296,7 +301,18 @@ function addTrainParams(){ function delTrainParams(index:any){ trainParamsData.value.splice(index,1) } - +function resetClick(){ + queryParams.value = { + current: 1, + size: 10, + total: 0, + title: '', + algorithmType: '', + deviceType: '', + state: '', + } + gettableData() +}