diff --git a/web/src/api/testtask/index.ts b/web/src/api/testtask/index.ts index 5f42a39..6b90488 100644 --- a/web/src/api/testtask/index.ts +++ b/web/src/api/testtask/index.ts @@ -55,4 +55,26 @@ export function selectTsNodesById(queryParams: any) { method: 'post', params: queryParams }); -} \ No newline at end of file +} +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' } + }); +} diff --git a/web/src/assets/MenuIcon/lbcz_dc.png b/web/src/assets/MenuIcon/lbcz_dc.png new file mode 100644 index 0000000..ee96b61 Binary files /dev/null and b/web/src/assets/MenuIcon/lbcz_dc.png differ diff --git a/web/src/views/testdata/testtask/index.vue b/web/src/views/testdata/testtask/index.vue index 8460441..f5186f2 100644 --- a/web/src/views/testdata/testtask/index.vue +++ b/web/src/views/testdata/testtask/index.vue @@ -8,7 +8,11 @@ export default { import { onMounted, ref } from "vue"; import { ElMessage, ElMessageBox } from 'element-plus' 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 { getDict } from '@/api/dict' /////// @@ -39,6 +43,14 @@ const queryParams: any = ref({ endDate: '' }); 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) { // 创建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([]) function handleSelectionChange(val: any) { @@ -406,6 +469,47 @@ function reset() { visible.vlaue = false 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 +} @@ -459,6 +563,7 @@ function reset() { 新增 删除 + 导入 {{ typeName1(minioarr, scope.row.backupStorageId) }} - + @@ -521,6 +626,8 @@ function reset() { style="cursor: pointer;"> + @@ -654,6 +761,38 @@ function reset() { + + + + + {{ importForm.taskCode }} + + + + + + + + + + + + + + + + 导入 + + + + + + 确定 + +