|
|
|
@@ -3,7 +3,6 @@ |
|
|
|
* @Date: 2024-04-16 13:58:08 |
|
|
|
* @Description: 创建服务版本 |
|
|
|
*/ |
|
|
|
import CodeSelect from '@/components/CodeSelect'; |
|
|
|
import PageTitle from '@/components/PageTitle'; |
|
|
|
import ParameterSelect from '@/components/ParameterSelect'; |
|
|
|
import ResourceSelect, { |
|
|
|
@@ -36,7 +35,7 @@ export type FormData = { |
|
|
|
description: string; // 描述 |
|
|
|
model: ParameterInputObject; // 模型 |
|
|
|
image: ParameterInputObject; // 镜像 |
|
|
|
code_config: ParameterInputObject; // 代码 |
|
|
|
// code_config: ParameterInputObject; // 代码 |
|
|
|
resource: string; // 资源规格 |
|
|
|
replicas: string; // 副本数量 |
|
|
|
mount_path: string; // 模型路径 |
|
|
|
@@ -75,28 +74,23 @@ function CreateServiceVersion() { |
|
|
|
setOperationType(res.operationType); |
|
|
|
setLastPage(res.lastPage); |
|
|
|
setVersionInfo(res); |
|
|
|
let model, codeConfig, envVariables; |
|
|
|
let model, envVariables; |
|
|
|
// 模型 |
|
|
|
if (res.model && typeof res.model === 'object') { |
|
|
|
model = changePropertyName(res.model, { show_value: 'showValue' }); |
|
|
|
// 接口返回是数据没有 value 值,但是 form 需要 value |
|
|
|
model.value = model.showValue; |
|
|
|
} |
|
|
|
if (res.code_config && typeof res.code_config === 'object') { |
|
|
|
codeConfig = changePropertyName(res.code_config, { show_value: 'showValue' }); |
|
|
|
// 接口返回是数据没有 value 值,但是 form 需要 value |
|
|
|
codeConfig.value = codeConfig.showValue; |
|
|
|
} |
|
|
|
// 环境变量 |
|
|
|
if (res.env_variables && typeof res.env_variables === 'object') { |
|
|
|
envVariables = Object.entries(res.env_variables).map(([key, value]) => ({ |
|
|
|
key, |
|
|
|
value, |
|
|
|
})); |
|
|
|
} |
|
|
|
|
|
|
|
const formData = { |
|
|
|
...omit(res, 'model', 'code_config', 'env_variables'), |
|
|
|
...omit(res, 'model', 'env_variables'), |
|
|
|
model: model, |
|
|
|
code_config: codeConfig, |
|
|
|
env_variables: envVariables, |
|
|
|
}; |
|
|
|
form.setFieldsValue(formData); |
|
|
|
@@ -124,7 +118,6 @@ function CreateServiceVersion() { |
|
|
|
const createServiceVersion = async (formData: FormData) => { |
|
|
|
const envList = formData['env_variables']; |
|
|
|
const model = formData['model']; |
|
|
|
const codeConfig = formData['code_config']; |
|
|
|
const envVariables = envList?.reduce((acc, cur) => { |
|
|
|
acc[cur.key] = cur.value; |
|
|
|
return acc; |
|
|
|
@@ -132,18 +125,13 @@ function CreateServiceVersion() { |
|
|
|
|
|
|
|
// 根据后台要求,修改表单数据 |
|
|
|
const object = { |
|
|
|
...omit(formData, ['replicas', 'env_variables', 'model', 'code_config']), |
|
|
|
...omit(formData, ['replicas', 'env_variables', 'model']), |
|
|
|
replicas: Number(formData.replicas), |
|
|
|
env_variables: envVariables, |
|
|
|
model: changePropertyName( |
|
|
|
pick(model, ['id', 'name', 'version', 'path', 'identifier', 'owner', 'showValue']), |
|
|
|
{ showValue: 'show_value' }, |
|
|
|
), |
|
|
|
code_config: codeConfig |
|
|
|
? changePropertyName(pick(codeConfig, ['code_path', 'branch', 'showValue']), { |
|
|
|
showValue: 'show_value', |
|
|
|
}) |
|
|
|
: undefined, |
|
|
|
service_id: serviceId, |
|
|
|
}; |
|
|
|
|
|
|
|
@@ -335,7 +323,7 @@ function CreateServiceVersion() { |
|
|
|
</Form.Item> |
|
|
|
</Col> |
|
|
|
</Row> |
|
|
|
<Row gutter={8}> |
|
|
|
{/* <Row gutter={8}> |
|
|
|
<Col span={10}> |
|
|
|
<Form.Item |
|
|
|
label="代码配置" |
|
|
|
@@ -350,7 +338,7 @@ function CreateServiceVersion() { |
|
|
|
/> |
|
|
|
</Form.Item> |
|
|
|
</Col> |
|
|
|
</Row> |
|
|
|
</Row> */} |
|
|
|
<Row gutter={8}> |
|
|
|
<Col span={10}> |
|
|
|
<Form.Item |
|
|
|
|