导入修改
This commit is contained in:
parent
0116134b27
commit
2a8996130c
@ -55,4 +55,26 @@ export function selectTsNodesById(queryParams: any) {
|
|||||||
method: 'post',
|
method: 'post',
|
||||||
params: queryParams
|
params: queryParams
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
export function exportTaskSql(queryParams: any) {
|
||||||
|
return request({
|
||||||
|
url: '/experimentalData/tstask/exportTaskSql',
|
||||||
|
method: 'post',
|
||||||
|
params: queryParams,
|
||||||
|
responseType: 'blob'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
export function getMaxTaskCode() {
|
||||||
|
return request({
|
||||||
|
url: '/experimentalData/tstask/getMaxTaskCode',
|
||||||
|
method: 'get',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
export function importTaskSql(queryParams: any) {
|
||||||
|
return request({
|
||||||
|
url: '/experimentalData/tstask/importTaskSql',
|
||||||
|
method: 'post',
|
||||||
|
data: queryParams,
|
||||||
|
headers: { 'Content-Type': 'multipart/form-data' }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|||||||
BIN
web/src/assets/MenuIcon/lbcz_dc.png
Normal file
BIN
web/src/assets/MenuIcon/lbcz_dc.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 472 B |
143
web/src/views/testdata/testtask/index.vue
vendored
143
web/src/views/testdata/testtask/index.vue
vendored
@ -8,7 +8,11 @@ export default {
|
|||||||
import { onMounted, ref } from "vue";
|
import { onMounted, ref } from "vue";
|
||||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||||
import Page from '@/components/Pagination/page.vue'
|
import Page from '@/components/Pagination/page.vue'
|
||||||
import { tstaskPage, addtsTask, updatetsTask, deleteTsTaskById, deleteTsTaskByIds, confirmDeleteTask, selectTsNodesById } from "@/api/testtask";
|
import {
|
||||||
|
tstaskPage, addtsTask, updatetsTask, exportTaskSql, deleteTsTaskById,
|
||||||
|
deleteTsTaskByIds, confirmDeleteTask, selectTsNodesById, getMaxTaskCode,
|
||||||
|
importTaskSql
|
||||||
|
} from "@/api/testtask";
|
||||||
import { storagesBytype } from "@/api/storage";
|
import { storagesBytype } from "@/api/storage";
|
||||||
import { getDict } from '@/api/dict'
|
import { getDict } from '@/api/dict'
|
||||||
///////
|
///////
|
||||||
@ -39,6 +43,14 @@ const queryParams: any = ref({
|
|||||||
endDate: ''
|
endDate: ''
|
||||||
});
|
});
|
||||||
const total = ref(0);
|
const total = ref(0);
|
||||||
|
const importDialog = ref(false)
|
||||||
|
const importForm: any = ref({})
|
||||||
|
const importRules: any = ref({
|
||||||
|
localStorageId: [{ required: true, message: "请选择本地存储空间", trigger: "change" }],
|
||||||
|
backupStorageId: [{ required: true, message: "请选择minio存储空间", trigger: "change" }],
|
||||||
|
})
|
||||||
|
const fileList = ref([])
|
||||||
|
const importFormRef = ref()
|
||||||
//转化时间格式
|
//转化时间格式
|
||||||
function zhuandata(dateString: any) {
|
function zhuandata(dateString: any) {
|
||||||
// 创建Date对象
|
// 创建Date对象
|
||||||
@ -196,6 +208,57 @@ function delproject(row: any) {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
function expproject(row: any) {
|
||||||
|
ElMessageBox.confirm(
|
||||||
|
'您确定要导出该任务吗?',
|
||||||
|
'提示',
|
||||||
|
{
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.then(() => {
|
||||||
|
exportTaskSql({ taskId: row.id }).then((res: any) => {
|
||||||
|
console.log(res)
|
||||||
|
console.log('响应头:', res.headers);
|
||||||
|
if (res) {
|
||||||
|
// 正确访问响应头
|
||||||
|
//const disposition = res.headers['Content-Disposition'];
|
||||||
|
|
||||||
|
const fileName = `${row.id}_data.sql.zip`; // 或从响应头中获取文件名
|
||||||
|
|
||||||
|
// if (disposition) {
|
||||||
|
// const filenameMatch = disposition.match(/filename="?([^"]+)"?/);
|
||||||
|
// if (filenameMatch && filenameMatch[1]) {
|
||||||
|
// fileName = decodeURIComponent(filenameMatch[1]);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// 处理响应数据
|
||||||
|
const blob = new Blob([res.data], { type: 'application/zip' });
|
||||||
|
|
||||||
|
// 创建临时链接并触发下载
|
||||||
|
const url = window.URL.createObjectURL(blob);
|
||||||
|
const link = document.createElement('a');
|
||||||
|
link.href = url;
|
||||||
|
link.download = `${row.id}_data.sql.zip`;
|
||||||
|
link.style.display = 'none';
|
||||||
|
document.body.appendChild(link);
|
||||||
|
link.click();
|
||||||
|
document.body.removeChild(link);
|
||||||
|
window.URL.revokeObjectURL(url);
|
||||||
|
ElMessage({
|
||||||
|
type: 'success',
|
||||||
|
message: '导出成功',
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
ElMessage.error("导出失败")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
//表格多选
|
//表格多选
|
||||||
const tableIdarr = ref([])
|
const tableIdarr = ref([])
|
||||||
function handleSelectionChange(val: any) {
|
function handleSelectionChange(val: any) {
|
||||||
@ -406,6 +469,47 @@ function reset() {
|
|||||||
visible.vlaue = false
|
visible.vlaue = false
|
||||||
getdata()
|
getdata()
|
||||||
}
|
}
|
||||||
|
function importproject() {
|
||||||
|
getMaxTaskCode().then((res: any) => {
|
||||||
|
if (res.data) {
|
||||||
|
importForm.value.taskCode = res.data
|
||||||
|
importDialog.value = true
|
||||||
|
} else {
|
||||||
|
ElMessage.warning('查询编号失败')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
function fileChange(uploadFile, uploadFiles) {
|
||||||
|
console.log(uploadFile, uploadFiles)
|
||||||
|
importForm.value.fileName = uploadFile.name
|
||||||
|
fileList.value = []
|
||||||
|
fileList.value = [uploadFile.raw]
|
||||||
|
console.log(fileList.value, 999)
|
||||||
|
}
|
||||||
|
function importSubmit(formEl: any) {
|
||||||
|
if (!formEl) return
|
||||||
|
formEl.validate((valid: any, fields: any) => {
|
||||||
|
if (valid) {
|
||||||
|
if (fileList.value.length == 0) {
|
||||||
|
return ElMessage.warning('请选择导入的文件!')
|
||||||
|
}
|
||||||
|
const formData = new FormData()
|
||||||
|
formData.append('file', fileList.value[0])
|
||||||
|
formData.append('taskCode', importForm.value.taskCode)
|
||||||
|
formData.append('localStorageId', importForm.value.localStorageId)
|
||||||
|
formData.append('backupStorageId', importForm.value.backupStorageId)
|
||||||
|
importTaskSql(formData).then((res: any) => {
|
||||||
|
if (res) {
|
||||||
|
ElMessage.success('上传成功')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
function importClose() {
|
||||||
|
importDialog.value = false
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@ -459,6 +563,7 @@ function reset() {
|
|||||||
<div>
|
<div>
|
||||||
<el-button type="primary" @click="addproject()">新增</el-button>
|
<el-button type="primary" @click="addproject()">新增</el-button>
|
||||||
<el-button type="primary" @click="delprojectArr()" :disabled="tableIdarr.length == 0">删除</el-button>
|
<el-button type="primary" @click="delprojectArr()" :disabled="tableIdarr.length == 0">删除</el-button>
|
||||||
|
<el-button type="primary" @click="importproject()">导入</el-button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<el-table v-loading="loading" :data="tableData" @selection-change="handleSelectionChange"
|
<el-table v-loading="loading" :data="tableData" @selection-change="handleSelectionChange"
|
||||||
@ -513,7 +618,7 @@ function reset() {
|
|||||||
<span>{{ typeName1(minioarr, scope.row.backupStorageId) }}</span>
|
<span>{{ typeName1(minioarr, scope.row.backupStorageId) }}</span>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column fixed="right" label="操作" width="80" align="center">
|
<el-table-column fixed="right" label="操作" width="100" align="center">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<span
|
<span
|
||||||
style="display: flex;display: -webkit-flex;justify-content: space-around;-webkit-justify-content: space-around; ">
|
style="display: flex;display: -webkit-flex;justify-content: space-around;-webkit-justify-content: space-around; ">
|
||||||
@ -521,6 +626,8 @@ function reset() {
|
|||||||
style="cursor: pointer;">
|
style="cursor: pointer;">
|
||||||
<img src="@/assets/MenuIcon/lbcz_sc.png" alt="" title="删除" @click="delproject(scope.row)"
|
<img src="@/assets/MenuIcon/lbcz_sc.png" alt="" title="删除" @click="delproject(scope.row)"
|
||||||
style="cursor: pointer;">
|
style="cursor: pointer;">
|
||||||
|
<img src="@/assets/MenuIcon/lbcz_dc.png" alt="" title="导出" @click="expproject(scope.row)"
|
||||||
|
style="cursor: pointer;">
|
||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
@ -654,6 +761,38 @@ function reset() {
|
|||||||
</el-scrollbar>
|
</el-scrollbar>
|
||||||
</div>
|
</div>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
|
<el-dialog title="导入试验任务参数设定" v-model="importDialog" width="30%" :before-close="importClose" top="30px"
|
||||||
|
:close-on-click-modal="false" destroy-on-close>
|
||||||
|
<!-- importForm -->
|
||||||
|
<el-form ref="importFormRef" style="max-width: 600px" :model="importForm" :rules="importRules"
|
||||||
|
label-width="auto">
|
||||||
|
<el-form-item label="新编号" prop="taskCode">
|
||||||
|
<div>{{ importForm.taskCode }}</div>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="本地存储空间" prop="localStorageId" style="width: 100%;">
|
||||||
|
<el-select v-model="importForm.localStorageId" clearable placeholder="请选择本地存储空间">
|
||||||
|
<el-option v-for="item in localarr" :key="item.id" :label="item.name" :value="item.id" />
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="备份存储空间" prop="backupStorageId" style="width: 100%">
|
||||||
|
<el-select v-model="importForm.backupStorageId" clearable placeholder="请选择备份存储空间">
|
||||||
|
<el-option v-for="item in minioarr" :key="item.id" :label="item.name" :value="item.id" />
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item>
|
||||||
|
<div style="width: 100%;display: flex;align-items: center;">
|
||||||
|
<el-input v-model="importForm.fileName" disabled style="margin-right: 15px;" />
|
||||||
|
<el-upload v-model="fileList" :auto-upload="false" :show-file-list="false" class="upload-demo"
|
||||||
|
action="" :on-change="fileChange">
|
||||||
|
<el-button type="primary">导入</el-button>
|
||||||
|
</el-upload>
|
||||||
|
</div>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<div style="width: 100%;display: flex;justify-content: end;margin-top: 10px;">
|
||||||
|
<el-button type="primary" @click="importSubmit(importFormRef)">确定</el-button>
|
||||||
|
</div>
|
||||||
|
</el-dialog>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user