diff --git a/web/src/views/login/index.vue b/web/src/views/login/index.vue index cc2756f..df9b74d 100644 --- a/web/src/views/login/index.vue +++ b/web/src/views/login/index.vue @@ -300,13 +300,14 @@ $light_gray: #eee; position: relative; // justify-content: center; // -webkit-justify-content: center; + text-align: center; .login-container-title{ font-size: 60px; font-weight: 700; color: #fff; margin: 0 auto; margin-top: 2%; - width: 800px; + // width: 800px; letter-spacing: 5px; } .login-container-content { diff --git a/web/src/views/testdata/testtask/index.vue b/web/src/views/testdata/testtask/index.vue index f5186f2..4c47e6e 100644 --- a/web/src/views/testdata/testtask/index.vue +++ b/web/src/views/testdata/testtask/index.vue @@ -15,6 +15,7 @@ import { } from "@/api/testtask"; import { storagesBytype } from "@/api/storage"; import { getDict } from '@/api/dict' +import { getUserInfo } from '@/api/user'; /////// let result2 = ref([]) let result1 = ref([ @@ -43,6 +44,7 @@ const queryParams: any = ref({ endDate: '' }); const total = ref(0); +//导入 const importDialog = ref(false) const importForm: any = ref({}) const importRules: any = ref({ @@ -51,6 +53,8 @@ const importRules: any = ref({ }) const fileList = ref([]) const importFormRef = ref() +// 是否单机 +const standAlone = ref(false) //转化时间格式 function zhuandata(dateString: any) { // 创建Date对象 @@ -66,7 +70,6 @@ function zhuandata(dateString: any) { const loading = ref(false) //获取表格数据 function getdata() { - loading.value = true if (dataduan.value && dataduan.value.length > 0) { const dataArr = [] @@ -158,6 +161,11 @@ function addproject() { localStorageId: '', backupStorageId: '' } + if (standAlone.value) { + projectForme.value.localStorageId = 1 + projectForme.value.backupStorageId = -1 + } + console.log(projectForme.value) // formitemarr.value.length = 0 shidou.value = true } @@ -223,26 +231,15 @@ function expproject(row: 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 fileName = `${row.taskCode}_exportdata.zip`; // 或从响应头中获取文件名 // 处理响应数据 - const blob = new Blob([res.data], { type: 'application/zip' }); + const blob = new Blob([res], { 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.download = fileName; link.style.display = 'none'; document.body.appendChild(link); link.click(); @@ -372,6 +369,13 @@ const moderules = ref({ backupStorageId: [{ required: true, message: "请选择minio存储空间", trigger: "change" }], }); onMounted(() => { + getUserInfo().then((res: any) => { + const roles = res.data.roles + const hasSingleMachineUser = roles.some(name => name === '单机用户'); + if (hasSingleMachineUser) { + standAlone.value = true + } + }) getdata() getDictOne() }); @@ -470,6 +474,10 @@ function reset() { getdata() } function importproject() { + fileList.value = [] + importForm.value.fileName = '' + importForm.value.localStorageId = '' + importForm.value.backupStorageId = '' getMaxTaskCode().then((res: any) => { if (res.data) { importForm.value.taskCode = res.data @@ -485,23 +493,34 @@ function fileChange(uploadFile, uploadFiles) { importForm.value.fileName = uploadFile.name fileList.value = [] fileList.value = [uploadFile.raw] - console.log(fileList.value, 999) } +const isconnect = ref(false) function importSubmit(formEl: any) { if (!formEl) return formEl.validate((valid: any, fields: any) => { if (valid) { if (fileList.value.length == 0) { - return ElMessage.warning('请选择导入的文件!') + return ElMessage.warning('请上传导入文件!') + } + if (isconnect.value) { + return } 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) + isconnect.value = true importTaskSql(formData).then((res: any) => { - if (res) { + if (res.code == '0') { + isconnect.value = false + importDialog.value = false ElMessage.success('上传成功') + getdata() + } else { + isconnect.value = false + importDialog.value = false + ElMessage.error(res.msg) } }) } @@ -563,7 +582,7 @@ function importClose() {