修改代码
This commit is contained in:
parent
959b073c23
commit
d2d58bbda4
@ -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) {
|
||||
|
||||
@ -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<FormRules>({
|
||||
@ -135,12 +138,18 @@ function confirmClick(formEl: any) {
|
||||
if(isSwitch.value == true){
|
||||
return
|
||||
}
|
||||
isSwitch.value == true
|
||||
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();
|
||||
}).catch(() => {
|
||||
dialogVisible.value = false;
|
||||
isSwitch.value = false;
|
||||
})
|
||||
}else{
|
||||
isSwitch.value = false;
|
||||
}
|
||||
|
||||
}).catch(() => {
|
||||
dialogVisible.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()
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@ -306,19 +322,19 @@ function delTrainParams(index:any){
|
||||
style="display: flex;display: -webkit-flex; justify-content: space-between; -webkit-justify-content: space-between;margin-bottom: 10px">
|
||||
<div style="display: flex;display: -webkit-flex;">
|
||||
<el-input v-model="input" placeholder="请输入训练任务名称" @keyup.enter="gettableData" style="width: 200px" clearable />
|
||||
<el-select style="width: 200px;margin-left: 10px;" clearable v-model="info.algorithmType" placeholder="请选择算法类型">
|
||||
<el-select style="width: 200px;margin-left: 10px;" clearable v-model="queryParams.algorithmType" placeholder="请选择算法类型">
|
||||
<el-option v-for="item in algorithmData" :key="item.algorithmType" :label="item.algorithmType" :value="item.algorithmType" ></el-option>
|
||||
</el-select>
|
||||
<el-select style="width: 200px;margin-left: 10px;" clearable v-model="info.deviceType" placeholder="请选择设备类型">
|
||||
<el-select style="width: 200px;margin-left: 10px;" clearable v-model="queryParams.deviceType" placeholder="请选择设备类型">
|
||||
<el-option v-for="item in menuData" :key="item.itemCode" :label="item.dictName" :value="item.itemCode" ></el-option>
|
||||
</el-select>
|
||||
<el-select style="width: 200px;margin-left: 10px;" clearable v-model="info.state" placeholder="请选择状态">
|
||||
<el-select style="width: 200px;margin-left: 10px;" clearable v-model="queryParams.state" placeholder="请选择状态">
|
||||
<el-option v-for="item in statusData" :key="item.itemCode" :label="item.dictName" :value="item.itemCode" ></el-option>
|
||||
</el-select>
|
||||
<el-button type="primary" style="margin-left: 10px" @click="gettableData">搜索</el-button>
|
||||
</div>
|
||||
<div style="display: flex;display: -webkit-flex;">
|
||||
<el-button type="primary" @click="setClick">重置</el-button>
|
||||
<el-button type="primary" @click="resetClick">重置</el-button>
|
||||
<el-button type="primary" @click="addClick">新建训练任务</el-button>
|
||||
|
||||
</div>
|
||||
@ -392,7 +408,7 @@ function delTrainParams(index:any){
|
||||
<div style="display: flex;" v-for="(item,index) in trainParamsData" :key="index">
|
||||
<el-input v-model="item.key" style="width: 100%" placeholder="输入算法名称"></el-input>
|
||||
<el-input v-model="item.value" style="width: 100%" placeholder="输入算法名称"></el-input>
|
||||
<el-button type="primary" @click="delTrainParams">删除</el-button>
|
||||
<el-button type="primary" @click="delTrainParams(index)">删除</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-form-item>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user