修改代码
This commit is contained in:
parent
959b073c23
commit
d2d58bbda4
@ -6,17 +6,18 @@ import { useUserStoreHook } from '@/store/modules/user';
|
|||||||
// 创建 axios 实例
|
// 创建 axios 实例
|
||||||
const service = axios.create({
|
const service = axios.create({
|
||||||
baseURL: import.meta.env.VITE_APP_BASE_API,
|
baseURL: import.meta.env.VITE_APP_BASE_API,
|
||||||
timeout: 50000,
|
timeout: 50000
|
||||||
headers: { 'Content-Type': 'application/json;charset=utf-8' }
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// 请求拦截器
|
// 请求拦截器
|
||||||
service.interceptors.request.use(
|
service.interceptors.request.use(
|
||||||
(config: AxiosRequestConfig) => {
|
(config: any) => {
|
||||||
if (!config.headers) {
|
if (!config.headers) {
|
||||||
throw new Error(
|
config.headers = {};
|
||||||
`Expected 'config' and 'config.headers' not to be undefined`
|
}
|
||||||
);
|
// 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();
|
const user = useUserStoreHook();
|
||||||
if (user.Token) {
|
if (user.Token) {
|
||||||
@ -31,7 +32,7 @@ service.interceptors.request.use(
|
|||||||
|
|
||||||
// 响应拦截器
|
// 响应拦截器
|
||||||
service.interceptors.response.use(
|
service.interceptors.response.use(
|
||||||
(response: AxiosResponse) => {
|
(response: any) => {
|
||||||
const { status, msg } = response;
|
const { status, msg } = response;
|
||||||
if (status === 200) {
|
if (status === 200) {
|
||||||
if (response.data.code == 401) {
|
if (response.data.code == 401) {
|
||||||
|
|||||||
@ -14,11 +14,14 @@ const apiUrl = import.meta.env.VITE_APP_BASE_API; // 基础路径
|
|||||||
const fileList:any = ref([])
|
const fileList:any = ref([])
|
||||||
const isSwitch = ref(false);
|
const isSwitch = ref(false);
|
||||||
// 搜索框
|
// 搜索框
|
||||||
const queryParams = ref({
|
const queryParams:any = ref({
|
||||||
current: 1,
|
current: 1,
|
||||||
size: 10,
|
size: 10,
|
||||||
total: 0,
|
total: 0,
|
||||||
title: '',
|
title: '',
|
||||||
|
algorithmType: '',
|
||||||
|
deviceType: '',
|
||||||
|
state: '',
|
||||||
});
|
});
|
||||||
//新建训练任务
|
//新建训练任务
|
||||||
const rules = reactive<FormRules>({
|
const rules = reactive<FormRules>({
|
||||||
@ -132,15 +135,21 @@ function addClick() {
|
|||||||
function confirmClick(formEl: any) {
|
function confirmClick(formEl: any) {
|
||||||
formEl.validate((valid: any) => {
|
formEl.validate((valid: any) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
if(isSwitch.value == true){
|
if(isSwitch.value == true){
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
isSwitch.value == true
|
isSwitch.value = true
|
||||||
// const data:any = {
|
// const data:any = {
|
||||||
// taskJson: JSON.stringify(info.value),
|
// taskJson: JSON.stringify(info.value),
|
||||||
// }
|
// }
|
||||||
|
|
||||||
const data = new FormData()
|
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
|
dialogVisible.value = false
|
||||||
addAlgorithms(data).then((res: any) => {
|
addAlgorithms(data).then((res: any) => {
|
||||||
dialogVisible.value = false;
|
dialogVisible.value = false;
|
||||||
@ -148,20 +157,16 @@ function confirmClick(formEl: any) {
|
|||||||
message: "新增成功",
|
message: "新增成功",
|
||||||
type: "success",
|
type: "success",
|
||||||
})
|
})
|
||||||
})
|
|
||||||
gettableData();
|
gettableData();
|
||||||
}else{
|
|
||||||
isSwitch.value = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
dialogVisible.value = false;
|
dialogVisible.value = false;
|
||||||
|
isSwitch.value = false;
|
||||||
})
|
})
|
||||||
|
}else{
|
||||||
|
isSwitch.value = false;
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
//新建角色-取消按钮
|
//新建角色-取消按钮
|
||||||
function handleClose() {
|
function handleClose() {
|
||||||
dialogVisible.value = false;
|
dialogVisible.value = false;
|
||||||
@ -296,7 +301,18 @@ function addTrainParams(){
|
|||||||
function delTrainParams(index:any){
|
function delTrainParams(index:any){
|
||||||
trainParamsData.value.splice(index,1)
|
trainParamsData.value.splice(index,1)
|
||||||
}
|
}
|
||||||
|
function resetClick(){
|
||||||
|
queryParams.value = {
|
||||||
|
current: 1,
|
||||||
|
size: 10,
|
||||||
|
total: 0,
|
||||||
|
title: '',
|
||||||
|
algorithmType: '',
|
||||||
|
deviceType: '',
|
||||||
|
state: '',
|
||||||
|
}
|
||||||
|
gettableData()
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<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">
|
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;">
|
<div style="display: flex;display: -webkit-flex;">
|
||||||
<el-input v-model="input" placeholder="请输入训练任务名称" @keyup.enter="gettableData" style="width: 200px" clearable />
|
<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-option v-for="item in algorithmData" :key="item.algorithmType" :label="item.algorithmType" :value="item.algorithmType" ></el-option>
|
||||||
</el-select>
|
</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-option v-for="item in menuData" :key="item.itemCode" :label="item.dictName" :value="item.itemCode" ></el-option>
|
||||||
</el-select>
|
</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-option v-for="item in statusData" :key="item.itemCode" :label="item.dictName" :value="item.itemCode" ></el-option>
|
||||||
</el-select>
|
</el-select>
|
||||||
<el-button type="primary" style="margin-left: 10px" @click="gettableData">搜索</el-button>
|
<el-button type="primary" style="margin-left: 10px" @click="gettableData">搜索</el-button>
|
||||||
</div>
|
</div>
|
||||||
<div style="display: flex;display: -webkit-flex;">
|
<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>
|
<el-button type="primary" @click="addClick">新建训练任务</el-button>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
@ -392,7 +408,7 @@ function delTrainParams(index:any){
|
|||||||
<div style="display: flex;" v-for="(item,index) in trainParamsData" :key="index">
|
<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.key" style="width: 100%" placeholder="输入算法名称"></el-input>
|
||||||
<el-input v-model="item.value" 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>
|
||||||
</div>
|
</div>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user