From 6f6f62f04c1dc8ee65c4dbb26ed74566a24ed54b Mon Sep 17 00:00:00 2001 From: limengnan <420004014@qq.com> Date: Tue, 7 Apr 2026 14:44:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=AF=BC=E5=85=A5=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E6=96=B9=E6=B3=95=EF=BC=8C=E4=BF=AE=E6=94=B9=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0=E6=95=B0=E6=8D=AE=E6=BA=90=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/api/business/project/index.ts | 8 + .../modelTrainTask/index.vue | 215 +++++++++++++++--- .../src/views/business/project/index.vue | 66 ++++-- 3 files changed, 242 insertions(+), 47 deletions(-) diff --git a/business-css/frontend/src/api/business/project/index.ts b/business-css/frontend/src/api/business/project/index.ts index 95068bb..4f65002 100644 --- a/business-css/frontend/src/api/business/project/index.ts +++ b/business-css/frontend/src/api/business/project/index.ts @@ -124,3 +124,11 @@ export function exportProject(queryParams: any) { } +//导入项目 +export function importProject(data:any){ + return request({ + url:'/projects/importProject' , + method: 'Post', + data: data + }); +} \ No newline at end of file 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 36fcfeb..915e63a 100644 --- a/business-css/frontend/src/views/business/algorithmManagement/modelTrainTask/index.vue +++ b/business-css/frontend/src/views/business/algorithmManagement/modelTrainTask/index.vue @@ -11,13 +11,14 @@ import { addAlgorithms,deleteAlgorithms,trainAlgorithmsPage,trainPublish,trainSt import { useUserStore } from '@/store/modules/user'; import { searchAlgorithmsPage,algorithmsType } from "@/api/business/algorithm"; import { getDictItemById } from '@/api/dict'; +import { getToken } from '@/utils/auth' // @ts-ignore import SockJS from 'sockjs-client' // @ts-ignore import * as Stomp from 'stompjs'; import Page from '@/components/Pagination/page.vue' +import * as XLSX from 'xlsx' const userStore = useUserStore(); - const apiUrl = import.meta.env.VITE_APP_BASE_API; // 基础路径 const webSocketUrl = import.meta.env.VITE_APP_WS_API; const fileList:any = ref([]) @@ -161,6 +162,11 @@ function addClick() { supportedDeviceTypes: "", defaultHyperParams: "", }; + + input_cols.value = [] + target_col.value = "" + fileFlow.value = null + trainParamsData.value = [] algorithmsTypeData.value = [] fileList.value = [] @@ -170,21 +176,30 @@ function addClick() { //新建训练任务-确认按钮/修改按钮 function confirmClick(formEl: any) { formEl.validate((valid: any) => { - - if(fileList.value.length == 0){ - return ElMessage({ - type: "error", - message: "请上传数据源类型", - }); - } if (valid) { + if(fileFlow.value == null || fileFlow.value.uid == null){ + return ElMessage({ + type: "error", + message: "请上传数据集", + }); + } + if(input_cols.value.length == 0 ){ + return ElMessage({ + type: "error", + message: "特征列不能为空", + }); + } + if(target_col.value == null || target_col.value == ""){ + return ElMessage({ + type: "error", + message: "目标列不能为空", + }); + } if(isSwitch.value == true){ return } isSwitch.value = true - const data = new FormData() - if(algorithmsTypeData.value.length != 0){ let template:any = {} algorithmsTypeData.value.forEach((element:any) => { @@ -193,13 +208,13 @@ function confirmClick(formEl: any) { info.value.trainParams = JSON.stringify(template) } - - - - data.append('task', JSON.stringify(info.value)) - if (fileList.value.length > 0) { - data.append('file', fileList.value[0].raw) + let infoTemp = JSON.parse(JSON.stringify(info.value)) + let feature_map_config = { + input_cols: input_cols.value, + target_col: target_col.value, } + infoTemp.feature_map_config = JSON.stringify(feature_map_config) + data.append('task', JSON.stringify(feature_map_config)) dialogVisibles.value = false addAlgorithms(data).then((res: any) => { dialogVisibles.value = false; @@ -227,6 +242,7 @@ function handleClose() { } function handleClosed(){ modelVisible.value = false + tableVisible.value = false } //修改训练任务 function viewClick(row: any) { @@ -260,9 +276,6 @@ function viewClick(row: any) { }) }, 2000); - - - dialogViewVisible.value = true; } @@ -460,6 +473,106 @@ const objectSpanMethod = ({ } } +const fileFlow:any = ref(null) +function handlePreview(file: any){ + // loadingtext.value = "正在导入数据,请耐心等待!" + loading.value = true + fileFlow.value = file + input_cols.value = [] + target_col.value = "" +} + +const upload:any = ref(null) +const columnsData:any = ref([]) +function handlesSuccess(file: any) { + columnsData.value = [] + input_cols.value = [] + target_col.value = '' + loading.value = false + if(file !== false && file.code == '0'){ + columnsData.value = file.data.columns + ElMessage({ + message: "导入成功!", + type: "success", + }); + }else{ + ElMessage({ + message: "导入失败!", + type: "error", + }); + } + gettableData() + upload.value.clearFiles() +} +function handleError(file: any){ + loading.value = false + ElMessage({ + message: "导入失败!", + type: "error", + }); + upload.value.clearFiles() +} + +const input_cols = ref([]) +const target_col = ref('') + + +const tableHeaders:any = ref([]) +const tableXlsxData:any = ref([]) +// const tableData = ref([]) +function previewData(){ + const file:any = fileFlow.value + const reader = new FileReader() + reader.onload = (e:any) => { + try { + // 解析二进制数据 + const data = new Uint8Array(e.target.result) + const workbook = XLSX.read(data, { type: 'array' }) + + // 取第一个工作表 + const firstSheetName = workbook.SheetNames[0] + const worksheet = workbook.Sheets[firstSheetName] + + // 转换为JSON格式 + const jsonData:any = XLSX.utils.sheet_to_json(worksheet) + + // 提取表头 + let columnsTemp = jsonData.length ? Object.keys(jsonData[0]) : [] + + let columns:any = [{ + key: 'order', + dataKey: 'order', + width: 70, + title: '序号', + align: 'center', + }] + for(let i = 0;i ({ + ...item, + order: index + 1, + })) + debugger + } catch (error) { + console.error('文件解析失败:', error) + alert('文件格式不正确或已损坏') + } + } + reader.readAsArrayBuffer(file) + tableVisible.value = true +} + + +const tableVisible = ref(false) + @@ -550,17 +663,39 @@ const objectSpanMethod = ({ - - - - - - - + + + + 预览数据 + + + + + {{item}} + + + + + + {{item}} + + + + + + + +
@@ -628,8 +763,8 @@ const objectSpanMethod = ({ - - + +
@@ -637,7 +772,6 @@ const objectSpanMethod = ({ :
-
@@ -645,10 +779,6 @@ const objectSpanMethod = ({ - -
@@ -694,6 +824,25 @@ const objectSpanMethod = ({ 确定 + + + +
+ + + +
+
diff --git a/business-css/frontend/src/views/business/project/index.vue b/business-css/frontend/src/views/business/project/index.vue index c82761e..24630ad 100644 --- a/business-css/frontend/src/views/business/project/index.vue +++ b/business-css/frontend/src/views/business/project/index.vue @@ -7,7 +7,8 @@ export default {