|
|
|
@@ -9,8 +9,7 @@ import { addAutoMLReq, getAutoMLInfoReq, updateAutoMLReq } from '@/services/auto |
|
|
|
import { convertEmptyStringToUndefined, parseJsonText, trimCharacter } from '@/utils'; |
|
|
|
import { safeInvoke } from '@/utils/functional'; |
|
|
|
import { to } from '@/utils/promise'; |
|
|
|
import SessionStorage from '@/utils/sessionStorage'; |
|
|
|
import { useNavigate, useParams } from '@umijs/max'; |
|
|
|
import { useLocation, useNavigate, useParams } from '@umijs/max'; |
|
|
|
import { App, Button, Form } from 'antd'; |
|
|
|
import { omit } from 'lodash'; |
|
|
|
import { useEffect } from 'react'; |
|
|
|
@@ -27,27 +26,18 @@ function CreateAutoML() { |
|
|
|
const { message } = App.useApp(); |
|
|
|
const params = useParams(); |
|
|
|
const id = safeInvoke(Number)(params.id); |
|
|
|
const { pathname } = useLocation(); |
|
|
|
const isCopy = pathname.includes('copy'); |
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
// 复制和新建 |
|
|
|
const recordId = SessionStorage.getItem(SessionStorage.autoMLRecordIDKey); |
|
|
|
if (recordId && !Number.isNaN(Number(recordId))) { |
|
|
|
getAutoMLInfo(Number(recordId), true); |
|
|
|
} |
|
|
|
return () => { |
|
|
|
SessionStorage.removeItem(SessionStorage.autoMLRecordIDKey); |
|
|
|
}; |
|
|
|
}, []); |
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
// 编辑 |
|
|
|
// 编辑,复制 |
|
|
|
if (id && !Number.isNaN(id)) { |
|
|
|
getAutoMLInfo(id, false); |
|
|
|
getAutoMLInfo(id); |
|
|
|
} |
|
|
|
}, [id]); |
|
|
|
|
|
|
|
// 获取服务详情 |
|
|
|
const getAutoMLInfo = async (id: number, isCopy = false) => { |
|
|
|
const getAutoMLInfo = async (id: number) => { |
|
|
|
const [res] = await to(getAutoMLInfoReq({ id })); |
|
|
|
if (res && res.data) { |
|
|
|
const autoMLInfo: AutoMLData = res.data; |
|
|
|
@@ -127,14 +117,15 @@ function CreateAutoML() { |
|
|
|
target_columns, |
|
|
|
}; |
|
|
|
|
|
|
|
const params = id |
|
|
|
? { |
|
|
|
id: id, |
|
|
|
...object, |
|
|
|
} |
|
|
|
: object; |
|
|
|
const params = |
|
|
|
id && !isCopy |
|
|
|
? { |
|
|
|
id: id, |
|
|
|
...object, |
|
|
|
} |
|
|
|
: object; |
|
|
|
|
|
|
|
const request = id ? updateAutoMLReq : addAutoMLReq; |
|
|
|
const request = id && !isCopy ? updateAutoMLReq : addAutoMLReq; |
|
|
|
const [res] = await to(request(params)); |
|
|
|
if (res) { |
|
|
|
message.success('操作成功'); |
|
|
|
@@ -153,10 +144,15 @@ function CreateAutoML() { |
|
|
|
}; |
|
|
|
|
|
|
|
let buttonText = '新建'; |
|
|
|
let title = '新增实验'; |
|
|
|
let title = '新建实验'; |
|
|
|
if (id) { |
|
|
|
title = '编辑实验'; |
|
|
|
buttonText = '更新'; |
|
|
|
if (isCopy) { |
|
|
|
title = '复制实验'; |
|
|
|
buttonText = '确定'; |
|
|
|
} else { |
|
|
|
title = '编辑实验'; |
|
|
|
buttonText = '更新'; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return ( |
|
|
|
|